video{enc,dec}oder: Don't reset latency all the time and handle max=GST_CLOCK_TIME_NO...
authorSebastian Dröge <sebastian@centricular.com>
Tue, 3 Feb 2015 11:23:06 +0000 (12:23 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 3 Feb 2015 11:24:01 +0000 (12:24 +0100)
max=NONE means that *this* element has no maximum latency. If upstream had a
maximum latency we must not override it with NONE.

gst-libs/gst/video/gstvideodecoder.c
gst-libs/gst/video/gstvideoencoder.c

index 9272d0f..1bb3c40 100644 (file)
@@ -568,6 +568,9 @@ gst_video_decoder_init (GstVideoDecoder * decoder, GstVideoDecoderClass * klass)
   decoder->priv->packetized = TRUE;
   decoder->priv->needs_format = FALSE;
 
+  decoder->priv->min_latency = 0;
+  decoder->priv->max_latency = GST_CLOCK_TIME_NONE;
+
   gst_video_decoder_reset (decoder, TRUE, TRUE);
 }
 
@@ -1538,10 +1541,11 @@ gst_video_decoder_src_query_default (GstVideoDecoder * dec, GstQuery * query)
 
         GST_OBJECT_LOCK (dec);
         min_latency += dec->priv->min_latency;
-        if (dec->priv->max_latency == GST_CLOCK_TIME_NONE) {
-          max_latency = GST_CLOCK_TIME_NONE;
-        } else if (max_latency != GST_CLOCK_TIME_NONE) {
+        if (max_latency != GST_CLOCK_TIME_NONE
+            && dec->priv->max_latency != GST_CLOCK_TIME_NONE) {
           max_latency += dec->priv->max_latency;
+        } else if (dec->priv->max_latency != GST_CLOCK_TIME_NONE) {
+          max_latency = dec->priv->max_latency;
         }
         GST_OBJECT_UNLOCK (dec);
 
@@ -1870,9 +1874,6 @@ gst_video_decoder_reset (GstVideoDecoder * decoder, gboolean full,
     priv->qos_frame_duration = 0;
     GST_OBJECT_UNLOCK (decoder);
 
-    priv->min_latency = 0;
-    priv->max_latency = 0;
-
     if (priv->tags)
       gst_tag_list_unref (priv->tags);
     priv->tags = NULL;
index 227ddc5..8d64d4e 100644 (file)
@@ -363,9 +363,6 @@ gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
     priv->tags = NULL;
     priv->tags_changed = FALSE;
 
-    priv->min_latency = 0;
-    priv->max_latency = 0;
-
     g_list_foreach (priv->headers, (GFunc) gst_event_unref, NULL);
     g_list_free (priv->headers);
     priv->headers = NULL;
@@ -456,6 +453,9 @@ gst_video_encoder_init (GstVideoEncoder * encoder, GstVideoEncoderClass * klass)
   priv->headers = NULL;
   priv->new_headers = FALSE;
 
+  priv->min_latency = 0;
+  priv->max_latency = GST_CLOCK_TIME_NONE;
+
   gst_video_encoder_reset (encoder, TRUE);
 }
 
@@ -1199,10 +1199,11 @@ gst_video_encoder_src_query_default (GstVideoEncoder * enc, GstQuery * query)
 
         GST_OBJECT_LOCK (enc);
         min_latency += priv->min_latency;
-        if (enc->priv->max_latency == GST_CLOCK_TIME_NONE) {
-          max_latency = GST_CLOCK_TIME_NONE;
-        } else if (max_latency != GST_CLOCK_TIME_NONE) {
+        if (max_latency != GST_CLOCK_TIME_NONE
+            && enc->priv->max_latency != GST_CLOCK_TIME_NONE) {
           max_latency += enc->priv->max_latency;
+        } else if (enc->priv->max_latency != GST_CLOCK_TIME_NONE) {
+          max_latency = enc->priv->max_latency;
         }
         GST_OBJECT_UNLOCK (enc);