mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
avviddec: Calculate latency only for fixed framerate
The framerate was checked correctly in _negotiate, but not in _set_format. Also fix loss of precision in _negotiate when calculating the framerate. Fixes #3093 Co-authored-by: Sebastian Dröge <sebastian@centricular.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5600>
This commit is contained in:
parent
c4789e6de5
commit
84d9e5b6e7
1 changed files with 13 additions and 11 deletions
|
@ -674,16 +674,18 @@ update_state:
|
||||||
* upstream framerate might not be set but we still want to report a latency
|
* upstream framerate might not be set but we still want to report a latency
|
||||||
* if needed. */
|
* if needed. */
|
||||||
if (ffmpegdec->context->time_base.den && ffmpegdec->context->ticks_per_frame) {
|
if (ffmpegdec->context->time_base.den && ffmpegdec->context->ticks_per_frame) {
|
||||||
gint fps_n =
|
gint fps_n = ffmpegdec->context->time_base.den;
|
||||||
ffmpegdec->context->time_base.den / ffmpegdec->context->ticks_per_frame;
|
gint fps_d =
|
||||||
gint fps_d = ffmpegdec->context->time_base.num;
|
ffmpegdec->context->time_base.num * ffmpegdec->context->ticks_per_frame;
|
||||||
latency = gst_util_uint64_scale_ceil (
|
if (fps_n) {
|
||||||
(ffmpegdec->context->has_b_frames) * GST_SECOND, fps_d, fps_n);
|
latency = gst_util_uint64_scale_ceil (
|
||||||
|
(ffmpegdec->context->has_b_frames) * GST_SECOND, fps_d, fps_n);
|
||||||
|
|
||||||
if (ffmpegdec->context->thread_type & FF_THREAD_FRAME) {
|
if (ffmpegdec->context->thread_type & FF_THREAD_FRAME) {
|
||||||
latency +=
|
latency +=
|
||||||
gst_util_uint64_scale_ceil (ffmpegdec->context->thread_count *
|
gst_util_uint64_scale_ceil (ffmpegdec->context->thread_count *
|
||||||
GST_SECOND, fps_d, fps_n);
|
GST_SECOND, fps_d, fps_n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,8 +1468,8 @@ gst_ffmpegviddec_negotiate (GstFFMpegVidDec * ffmpegdec,
|
||||||
fps_n = in_info->fps_n;
|
fps_n = in_info->fps_n;
|
||||||
fps_d = in_info->fps_d;
|
fps_d = in_info->fps_d;
|
||||||
} else {
|
} else {
|
||||||
fps_n = ffmpegdec->ctx_time_d / ffmpegdec->ctx_ticks;
|
fps_n = ffmpegdec->ctx_time_d;
|
||||||
fps_d = ffmpegdec->ctx_time_n;
|
fps_d = ffmpegdec->ctx_time_n * ffmpegdec->ctx_ticks;
|
||||||
|
|
||||||
if (!fps_d) {
|
if (!fps_d) {
|
||||||
GST_LOG_OBJECT (ffmpegdec, "invalid framerate: %d/0, -> %d/1", fps_n,
|
GST_LOG_OBJECT (ffmpegdec, "invalid framerate: %d/0, -> %d/1", fps_n,
|
||||||
|
|
Loading…
Reference in a new issue