From bebf20c9066eb39cfe94f0cd70fc2642a778e524 Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Mon, 11 Nov 2019 12:40:07 -0800 Subject: [PATCH] h264parse: do not push wrong PTS with some raw files Some raw h264 encoded files trigger the assignment of wrong PTS to buffers when some SEI data is provided. This change prevents it to happen. Also ensure this behavior is being tested. --- gst/videoparsers/gsth264parse.c | 4 ++-- tests/check/elements/h264parse.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index a4c7fc1..a39bff9 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -457,7 +457,7 @@ gst_h264_parse_wrap_nal (GstH264Parse * h264parse, guint format, guint8 * data, || format == GST_H264_PARSE_FORMAT_AVC3) { tmp = GUINT32_TO_BE (size << (32 - 8 * nl)); } else { - /* HACK: nl should always be 4 here, otherwise this won't work. + /* HACK: nl should always be 4 here, otherwise this won't work. * There are legit cases where nl in avc stream is 2, but byte-stream * SC is still always 4 bytes. */ nl = 4; @@ -2444,7 +2444,7 @@ gst_h264_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame) * particularly since our ts not that good they handle seeking etc */ if (h264parse->do_ts) gst_h264_parse_get_timestamp (h264parse, - &GST_BUFFER_TIMESTAMP (buffer), &GST_BUFFER_DURATION (buffer), + &GST_BUFFER_DTS (buffer), &GST_BUFFER_DURATION (buffer), h264parse->frame_start); if (h264parse->keyframe) diff --git a/tests/check/elements/h264parse.c b/tests/check/elements/h264parse.c index 543995b..90d8b4e 100644 --- a/tests/check/elements/h264parse.c +++ b/tests/check/elements/h264parse.c @@ -271,6 +271,14 @@ verify_buffer_bs_au (buffer_verify_data_s * vdata, GstBuffer * buffer) fail_unless (ctx_sink_template == &sinktemplate_bs_au); + /* Currently the parser can only predict DTS when dealing with raw data. + * Ensure that this behavior is being checked here. */ + GST_DEBUG ("PTS: %" GST_TIME_FORMAT " DTS: %" GST_TIME_FORMAT, + GST_TIME_ARGS (GST_BUFFER_PTS (buffer)), + GST_TIME_ARGS (GST_BUFFER_DTS (buffer))); + fail_if (GST_BUFFER_PTS_IS_VALID (buffer)); + fail_unless (GST_BUFFER_DTS_IS_VALID (buffer)); + gst_buffer_map (buffer, &map, GST_MAP_READ); fail_unless (map.size > 4); -- 2.7.4