HEVC parser: detect and ignore invalid default display window VUI parameters

Certain files seem to lack the "default display window" data (well,
the flag that signals its presence/absence). Therefore a
standards-compliant parser would try to read that flag, but the data
read would belong to another flag (the "vui_timing_info_present_flag").

ffmpeg has a heuristic in place for detecting such invalid default
display window parameters. This commit implements the same heuristic
in mkvmerge.

Fixes #1907.
This commit is contained in:
Moritz Bunkus 2017-03-19 18:57:17 +01:00
parent f12df7396f
commit 639407f580
4 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,9 @@
first key frame as they cannot be decoded properly anyway. See #1908.
* mkvmerge: HEVC/h.265 parser: mkvmerge will now drop all frames before the
first key frame as they cannot be decoded properly anyway. See #1908.
* mkvmerge: HEVC/h.265 parser: added a workaround for invalid values for the
"default display window" in the VUI parameters of sequence parameter
sets. Fixes #1907.
## Bug fixes

View File

@ -857,7 +857,11 @@ vui_parameters_copy(bit_reader_c &r,
w.copy_unsigned_golomb(r); // chroma_sample_loc_type_bottom_field
}
w.copy_bits(3, r); // neutral_chroma_indication_flag, field_seq_flag, frame_field_info_present_flag
if (w.copy_bits(1, r) == 1) { // default_display_window_flag
if ( (r.get_remaining_bits() >= 68)
&& (r.peek_bits(21) == 0x100000))
w.put_bit(0); // invalid default display window, signal no default_display_window_flag
else if (w.copy_bits(1, r) == 1) { // default_display_window_flag
w.copy_unsigned_golomb(r); // def_disp_win_left_offset
w.copy_unsigned_golomb(r); // def_disp_win_right_offset
w.copy_unsigned_golomb(r); // def_disp_win_top_offset

View File

@ -431,3 +431,4 @@ T_582reading_mp4_with_and_without_track_order:3d668751b7ae3247e866a6cad96db6f2-3
T_583dvbsub_four_bytes_codecprivate:4e16c6cb196dc6d60b799de8283498ba-4b457add4290c9cb39b792e2313e4043:passed:20170217-183748:0.078521662
T_584ac_3_misdetected_as_mp3:true-5fa0a9abd94a7f555f519b013a55b980:passed:20170218-123152:0.369584022
T_585h264_wrong_mapping_of_timestamps_to_frames:87acc96e91f17b007ab38b23da8cca1d:passed:20170318-172210:0.580192044
T_586h265_invalid_default_display_window_in_sps_vui:f49d79d17235b95a154b5d951e48344f:passed:20170319-185708:0.186032079

View File

@ -0,0 +1,5 @@
#!/usr/bin/ruby -w
# T_586h265_invalid_default_display_window_in_sps_vui
describe "mkvmerge / h.265 with an invalid default display window in the VUI parameters of the sequence parameter sets"
test_merge "data/h265/invalid_default_display_window_in_sps_vui.h265"