From d809e013f7a83ee3290724222cf2f90231f4098e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 16 Jun 2005 14:01:14 +0000 Subject: [PATCH] Fix the codec version string for MPEG-4 codecs: if it indicates "DivX packed bitstream" then change it to not say "packed bitstream" anymore. --- ChangeLog | 8 ++++++++ src/output/p_video.cpp | 35 +++++++++++++++++++++++++++++++++++ src/output/p_video.h | 1 + 3 files changed, 44 insertions(+) diff --git a/ChangeLog b/ChangeLog index dd445a9bc..6018907ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-06-16 Moritz Bunkus + + * mkvmerge: bug fixes: Improved the native MPEG-4 generation a lot + (thanks to Haali for testing and pushing me). The codec version + string inside the MPEG-4 initialization data is now checked if it + indicates "DivX packed bitstream" and changed to not indicate it + anymore. + 2005-06-07 Moritz Bunkus * mmg: bug fix: If mmg was minimized when it was closed (e.g. with diff --git a/src/output/p_video.cpp b/src/output/p_video.cpp index 53237f90f..efc16ada6 100644 --- a/src/output/p_video.cpp +++ b/src/output/p_video.cpp @@ -353,6 +353,7 @@ mpeg4_p2_video_packetizer_c::process_non_native(packet_cptr packet) { ti.private_data = config_data->grab(); ti.private_size = config_data->size; delete config_data; + fix_codec_string(); set_codec_private(ti.private_data, ti.private_size); rerender_track_headers(); @@ -404,6 +405,40 @@ mpeg4_p2_video_packetizer_c::process_non_native(packet_cptr packet) { return FILE_STATUS_MOREDATA; } +void +mpeg4_p2_video_packetizer_c::fix_codec_string() { + static const unsigned char start_code[4] = {0x00, 0x00, 0x01, 0xb2}; + unsigned char *end_pos; + int i, size; + + if ((NULL == ti.private_data) || (0 == ti.private_size)) + return; + + size = ti.private_size; + for (i = 0; 9 < size;) { + if (memcmp(&ti.private_data[i], start_code, 4) != 0) { + ++i; + --size; + continue; + } + + i += 8; + size -= 8; + if (strncasecmp((const char *)&ti.private_data[i - 4], "divx", 4) != 0) + continue; + + end_pos = (unsigned char *)memchr(&ti.private_data[i], 0, size); + if (NULL == end_pos) + end_pos = &ti.private_data[i + size]; + + --end_pos; + if ('p' == *end_pos) + *end_pos = 'n'; + + return; + } +} + int mpeg4_p2_video_packetizer_c::process_native(packet_cptr packet) { // Not implemented yet. diff --git a/src/output/p_video.h b/src/output/p_video.h index 56ae65b6b..dd149d7fb 100644 --- a/src/output/p_video.h +++ b/src/output/p_video.h @@ -95,6 +95,7 @@ protected: virtual void flush_frames_maybe(frame_type_e next_frame); virtual void flush_frames(); virtual void extract_aspect_ratio(const unsigned char *buffer, int size); + virtual void fix_codec_string(); }; class mpeg4_p10_video_packetizer_c: public video_packetizer_c {