From dee02802007f7d671d9c312be2e2772f4262eb1a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 28 Dec 2015 13:44:44 +0100 Subject: [PATCH] MPEG 4p10: convert slice NALUs to RBSP before parsing All NALUs must be converted to RBSP before they're parsed. Otherwise the wrong values will be used resulting in e.g. wrong picture order and therefore in wrong timestamps. Fixes #918 and #1548. --- ChangeLog | 4 ++++ src/common/mpeg4_p10.cpp | 2 +- tests/results.txt | 1 + tests/test-517h264_forbidden_byte_sequence_in_slice_nalu.rb | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 tests/test-517h264_forbidden_byte_sequence_in_slice_nalu.rb diff --git a/ChangeLog b/ChangeLog index d92e1d9df..d2e075f39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-12-28 Moritz Bunkus + * mkvmerge: bug fix: the h.264 code wasn't converting slice NALUs + to RBSP form before parsing it resulting in wrongly timestamped + frames under certain conditions. Fixes #918 and #1548. + * mkvmerge: bug fix: the MP4 reader can now understand the 'random access point' sample grouping information for marking open GOP random access points as key frames. Fixes #1543. diff --git a/src/common/mpeg4_p10.cpp b/src/common/mpeg4_p10.cpp index 9813dc66f..8a4f11ab8 100644 --- a/src/common/mpeg4_p10.cpp +++ b/src/common/mpeg4_p10.cpp @@ -1188,7 +1188,7 @@ mpeg4::p10::avc_es_parser_c::handle_slice_nalu(memory_cptr const &nalu) { } slice_info_t si; - if (!parse_slice(nalu, si)) + if (!parse_slice(nalu_to_rbsp(nalu), si)) return; if (m_have_incomplete_frame && flush_decision(si, m_incomplete_frame.m_si)) diff --git a/tests/results.txt b/tests/results.txt index dbc66e101..a7fe0f39d 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -362,3 +362,4 @@ T_513vp9_10bit_key_frame_detection:9eab6e85ec792dcf670873d70a87f6ea:passed:20151 T_514remove_track_statistics_tags_during_remux:43d4c0ec5cbbc31018715e62a99377df-afe190e36be530592fe3b83fb28d3e69-a7f246fe02132a1fb9cd3d7d0f85f180:passed:20151215-134129:1.426290351 T_515aac_sampling_frequency_8000_is_not_sbr:b8f857faf759eae5362fefbb7cbeed23:passed:20151219-130357:0.066237884 T_516hevc_rap_sample_grouping:bb42041df575edd35f36d47aebc341a7:passed:20151228-124607:0.066873869 +T_517h264_forbidden_byte_sequence_in_slice_nalu:74e0fb1a25397078335c6d94974dc168:passed:20151228-134333:3.276176597 diff --git a/tests/test-517h264_forbidden_byte_sequence_in_slice_nalu.rb b/tests/test-517h264_forbidden_byte_sequence_in_slice_nalu.rb new file mode 100755 index 000000000..de515ed73 --- /dev/null +++ b/tests/test-517h264_forbidden_byte_sequence_in_slice_nalu.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby -w + +# T_517h264_forbidden_byte_sequence_in_slice_nalu +describe "mkvmerge / h.264 slices with forbidden byte value requiring NALU-to-RBSP conversion" +test_merge "data/h264/forbidden_byte_sequence_in_slice_header.h264"