From 179555c45b8c58dded73acf7f600b14615fa167f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 22 May 2010 07:44:27 +0200 Subject: [PATCH] basevideodecoder: Take the frame duration into account when calculating the earliest time This formula is used in many other elements too. Fixes bug #619318. --- ext/vp8/gst/video/gstbasevideodecoder.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/vp8/gst/video/gstbasevideodecoder.c b/ext/vp8/gst/video/gstbasevideodecoder.c index b11a0c3d5c..b34820eb38 100644 --- a/ext/vp8/gst/video/gstbasevideodecoder.c +++ b/ext/vp8/gst/video/gstbasevideodecoder.c @@ -353,12 +353,28 @@ gst_base_video_decoder_src_event (GstPad * pad, GstEvent * event) gdouble proportion; GstClockTimeDiff diff; GstClockTime timestamp; + GstClockTime duration; gst_event_parse_qos (event, &proportion, &diff, ×tamp); GST_OBJECT_LOCK (base_video_decoder); base_video_decoder->proportion = proportion; - base_video_decoder->earliest_time = timestamp + diff; + if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (timestamp))) { + if (G_UNLIKELY (diff > 0)) { + if (base_video_decoder->state.fps_n > 0) + duration = + gst_util_uint64_scale (GST_SECOND, + base_video_decoder->state.fps_d, + base_video_decoder->state.fps_n); + else + duration = 0; + base_video_decoder->earliest_time = timestamp + 2 * diff + duration; + } else { + base_video_decoder->earliest_time = timestamp + diff; + } + } else { + base_video_decoder->earliest_time = GST_CLOCK_TIME_NONE; + } GST_OBJECT_UNLOCK (base_video_decoder); GST_DEBUG_OBJECT (base_video_decoder,