From f1ec8fcb054355e6411bcc6473aae8b00577b5c5 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Tue, 17 Apr 2012 22:46:12 -0400 Subject: [PATCH] jpegparse: Do not set the duration to the input buffer's duration unless valid This causes a bug where the first buffer has ts = 0, dur=X, the second buffer has ts=X (because of ts += duration), dur=-1, then the following buffers will start having a non valid timestamp. The real duration is only calculated during the caps negociation when there is a framerate available and the buffer's duration is invalid. --- gst/jpegformat/gstjpegparse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst/jpegformat/gstjpegparse.c b/gst/jpegformat/gstjpegparse.c index d8367f8d7f..240721380b 100644 --- a/gst/jpegformat/gstjpegparse.c +++ b/gst/jpegformat/gstjpegparse.c @@ -928,7 +928,8 @@ gst_jpeg_parse_chain (GstPad * pad, GstBuffer * buf) if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (parse->priv->next_ts))) parse->priv->next_ts = timestamp; - parse->priv->duration = duration; + if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (duration))) + parse->priv->duration = duration; /* check if we already have a EOI */ len = gst_jpeg_parse_get_image_length (parse); @@ -971,6 +972,7 @@ gst_jpeg_parse_sink_event (GstPad * pad, GstEvent * event) } case GST_EVENT_FLUSH_STOP: parse->priv->next_ts = GST_CLOCK_TIME_NONE; + parse->priv->duration = GST_CLOCK_TIME_NONE; parse->priv->last_offset = 0; parse->priv->last_entropy_len = 0; parse->priv->last_resync = FALSE; @@ -1039,6 +1041,7 @@ gst_jpeg_parse_change_state (GstElement * element, GstStateChange transition) parse->priv->new_segment = FALSE; parse->priv->next_ts = GST_CLOCK_TIME_NONE; + parse->priv->duration = GST_CLOCK_TIME_NONE; parse->priv->last_offset = 0; parse->priv->last_entropy_len = 0;