From aa645b11f1a844f16afe5e204d083f418bae9779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 3 Feb 2015 12:23:06 +0100 Subject: [PATCH] video{enc,dec}oder: Don't reset latency all the time and handle max=GST_CLOCK_TIME_NONE correctly 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 | 13 +++++++------ gst-libs/gst/video/gstvideoencoder.c | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 9272d0f9b0..1bb3c40154 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -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; diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 227ddc5612..8d64d4e340 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -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);