h264parse: do not push wrong PTS with some raw files
authorJosep Torra <jtorra@oblong.com>
Mon, 11 Nov 2019 20:40:07 +0000 (12:40 -0800)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 10 Jan 2020 15:03:38 +0000 (15:03 +0000)
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
tests/check/elements/h264parse.c

index a4c7fc1..a39bff9 100644 (file)
@@ -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)
index 543995b..90d8b4e 100644 (file)
@@ -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);