[0.10] gst-plugins-bad: h264parse: fix and tweak frame timestamping

Tim Müller tpm at kemper.freedesktop.org
Wed Jan 4 10:07:57 PST 2012


Module: gst-plugins-bad
Branch: 0.10
Commit: fe42d98e59d097eda30f7305c4960b16e56c9849
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=fe42d98e59d097eda30f7305c4960b16e56c9849

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Wed Jan  4 10:56:51 2012 +0100

h264parse: fix and tweak frame timestamping

... to run with properly init'ed variables, and to only perform interpolation
in safe cases.

---

 gst/videoparsers/gsth264parse.c |   31 ++++++++++++++++++++++++++++---
 gst/videoparsers/gsth264parse.h |    1 +
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c
index 9b51d35..2f58e44 100644
--- a/gst/videoparsers/gsth264parse.c
+++ b/gst/videoparsers/gsth264parse.c
@@ -213,6 +213,10 @@ gst_h264_parse_reset (GstH264Parse * h264parse)
   h264parse->last_report = GST_CLOCK_TIME_NONE;
   h264parse->push_codec = FALSE;
 
+  h264parse->dts = GST_CLOCK_TIME_NONE;
+  h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE;
+  h264parse->do_ts = TRUE;
+
   h264parse->pending_key_unit_ts = GST_CLOCK_TIME_NONE;
   h264parse->force_key_unit_event = NULL;
 
@@ -1222,9 +1226,12 @@ gst_h264_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
 
   gst_h264_parse_update_src_caps (h264parse, NULL);
 
-  gst_h264_parse_get_timestamp (h264parse,
-      &GST_BUFFER_TIMESTAMP (buffer), &GST_BUFFER_DURATION (buffer),
-      h264parse->frame_start);
+  /* don't mess with timestamps if provided by upstream,
+   * 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),
+        h264parse->frame_start);
 
   if (h264parse->keyframe)
     GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
@@ -1710,6 +1717,24 @@ gst_h264_parse_event (GstBaseParse * parse, GstEvent * event)
       gst_event_replace (&h264parse->force_key_unit_event, event);
       break;
     }
+    case GST_EVENT_FLUSH_STOP:
+      h264parse->dts = GST_CLOCK_TIME_NONE;
+      h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE;
+      break;
+    case GST_EVENT_NEWSEGMENT:
+    {
+      gdouble rate, applied_rate;
+      GstFormat format;
+      gint64 start;
+
+      gst_event_parse_new_segment_full (event, NULL, &rate, &applied_rate,
+          &format, &start, NULL, NULL);
+      /* don't try to mess with more subtle cases (e.g. seek) */
+      if (format == GST_FORMAT_TIME &&
+          (start != 0 || rate != 1.0 || applied_rate != 1.0))
+        h264parse->do_ts = FALSE;
+      break;
+    }
     default:
       break;
   }
diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h
index 5cbb5ad..bb81cbe 100644
--- a/gst/videoparsers/gsth264parse.h
+++ b/gst/videoparsers/gsth264parse.h
@@ -90,6 +90,7 @@ struct _GstH264Parse
   GstClockTime dts;
   /* dts at start of last buffering period */
   GstClockTime ts_trn_nb;
+  gboolean do_ts;
 
   /* frame parsing */
   /*guint last_nal_pos;*/



More information about the gstreamer-commits mailing list