summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2010-12-12 12:38:55 +0100
committerWim Taymans <wim.taymans@gmail.com>2010-12-12 12:38:55 +0100
commitec48b24291e4587145d012034e76d69761126d43 (patch)
tree7e5097948879887e89fdabb59f75eb6fe2d6a1b5
parent957c728b3d591d2c8a25024e18575db01283784e (diff)
dec: scale the estimated duration by number of frames
When estimating the frame duration, the diff between two incomming timestamps should be scaled by the amount of frames in the interval. Improves duration estimation and DTS interpolation.
-rw-r--r--ext/ffmpeg/gstffmpegdec.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index 20f8751..dd8d41d 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -97,6 +97,7 @@ struct _GstFFMpegDec
gboolean reordered_in;
GstClockTime last_in;
GstClockTime last_diff;
+ guint last_frames;
gboolean reordered_out;
GstClockTime last_out;
GstClockTime next_out;
@@ -499,6 +500,7 @@ gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
{
ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
+ ffmpegdec->last_frames = 0;
ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
ffmpegdec->reordered_in = FALSE;
@@ -2491,12 +2493,22 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
ffmpegdec->reordered_in = TRUE;
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
} else if (in_timestamp > ffmpegdec->last_in) {
+ GstClockTime diff;
/* keep track of timestamp diff to estimate duration */
- ffmpegdec->last_diff = in_timestamp - ffmpegdec->last_in;
+ diff = in_timestamp - ffmpegdec->last_in;
+ /* need to scale with amount of frames in the interval */
+ if (ffmpegdec->last_frames)
+ diff /= ffmpegdec->last_frames;
+
+ GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
+ GST_TIME_ARGS (diff), ffmpegdec->last_frames);
+
+ ffmpegdec->last_diff = diff;
}
}
ffmpegdec->last_in = in_timestamp;
}
+ ffmpegdec->last_frames = 0;
GST_LOG_OBJECT (ffmpegdec,
"Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
@@ -2634,6 +2646,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
} else {
ffmpegdec->clear_ts = TRUE;
}
+ ffmpegdec->last_frames++;
GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
bsize, bdata);