mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
avfilter/fruc_vulkan: fall back to a plain timebase when reduction degenerates
The output timebase is derived, as in vf_fps / vf_framerate, by reducing the source timebase against the requested frame rate. That reduction can collapse to a zero time base - av_reduce() bounds its result, so the numerator can underflow to zero, leaving 0/1 - when the source timebase shares no useful factors with the requested rate, leaving an unusable output timebase that breaks the downstream PTS rescaling. Detect the degenerate result and fall back to the plain 1/fps timebase derived directly from the requested rate, so config_output() always yields a valid timebase.
This commit is contained in:
@@ -464,6 +464,17 @@ static int config_output(AVFilterLink *outlink)
|
||||
(int64_t)s->srce_time_base.den * s->dest_frame_rate.den ),
|
||||
(int64_t)s->srce_time_base.den * s->dest_frame_rate.num, INT_MAX);
|
||||
|
||||
/* The source-timebase-derived reduction above can collapse to a zero time
|
||||
* base (av_reduce() bounds its result, so the numerator can underflow to
|
||||
* zero, leaving 0/1) when the source timebase shares no useful factors with
|
||||
* the requested rate, which would make the output timebase unusable. Fall
|
||||
* back to the plain 1/fps timebase in that case so a valid timebase is
|
||||
* always produced. */
|
||||
if (!s->dest_time_base.num || !s->dest_time_base.den) {
|
||||
exact = av_reduce(&s->dest_time_base.num, &s->dest_time_base.den,
|
||||
s->dest_frame_rate.den, s->dest_frame_rate.num, INT_MAX);
|
||||
}
|
||||
|
||||
av_log(ctx, AV_LOG_INFO,
|
||||
"time base:%u/%u -> %u/%u exact:%d\n",
|
||||
s->srce_time_base.num, s->srce_time_base.den,
|
||||
|
||||
Reference in New Issue
Block a user