mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
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.
This commit is contained in:
parent
957c728b3d
commit
ec48b24291
1 changed files with 14 additions and 1 deletions
|
@ -97,6 +97,7 @@ struct _GstFFMpegDec
|
||||||
gboolean reordered_in;
|
gboolean reordered_in;
|
||||||
GstClockTime last_in;
|
GstClockTime last_in;
|
||||||
GstClockTime last_diff;
|
GstClockTime last_diff;
|
||||||
|
guint last_frames;
|
||||||
gboolean reordered_out;
|
gboolean reordered_out;
|
||||||
GstClockTime last_out;
|
GstClockTime last_out;
|
||||||
GstClockTime next_out;
|
GstClockTime next_out;
|
||||||
|
@ -499,6 +500,7 @@ gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
|
||||||
{
|
{
|
||||||
ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
|
ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
|
||||||
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
|
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
|
||||||
|
ffmpegdec->last_frames = 0;
|
||||||
ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
|
ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
|
||||||
ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
|
ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
|
||||||
ffmpegdec->reordered_in = FALSE;
|
ffmpegdec->reordered_in = FALSE;
|
||||||
|
@ -2491,12 +2493,22 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
ffmpegdec->reordered_in = TRUE;
|
ffmpegdec->reordered_in = TRUE;
|
||||||
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
|
ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
|
||||||
} else if (in_timestamp > ffmpegdec->last_in) {
|
} else if (in_timestamp > ffmpegdec->last_in) {
|
||||||
|
GstClockTime diff;
|
||||||
/* keep track of timestamp diff to estimate duration */
|
/* 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_in = in_timestamp;
|
||||||
}
|
}
|
||||||
|
ffmpegdec->last_frames = 0;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec,
|
GST_LOG_OBJECT (ffmpegdec,
|
||||||
"Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
|
"Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
|
||||||
|
@ -2634,6 +2646,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
|
||||||
} else {
|
} else {
|
||||||
ffmpegdec->clear_ts = TRUE;
|
ffmpegdec->clear_ts = TRUE;
|
||||||
}
|
}
|
||||||
|
ffmpegdec->last_frames++;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
|
GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
|
||||||
bsize, bdata);
|
bsize, bdata);
|
||||||
|
|
Loading…
Reference in a new issue