From b09d57c41d4ee16ebb9737417d8643a03212b2d6 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 26 Mar 2026 15:21:33 +0100 Subject: [PATCH] avfilter/buffersrc: re-add missing overflow warning This was originally introduced by commit 05d6cc116e. During the FFmpeg-libav split, this function was refactored by commit 7e350379f8 into av_buffersrc_add_frame(), replacing av_buffersrc_add_ref(). The new function did not include the overflow warning, despite the same being done for buffersink. Then, when commit a05a44e205 merged the two functions back together, the libav implementation was favored over the FFmpeg implementation, silently removing the overflow warning in the process. This commit re-adds that missing warning. Signed-off-by: Niklas Haas --- libavfilter/buffersrc.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index b18d3f24dd..16efa6e6c8 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -46,6 +46,7 @@ typedef struct BufferSourceContext { AVRational time_base; ///< time_base to set in the output link AVRational frame_rate; ///< frame_rate to set in the output link unsigned nb_failed_requests; + unsigned warning_limit; /* video only */ int w, h, prev_w, prev_h; @@ -274,6 +275,16 @@ int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFra return ret; } + FilterLinkInternal *const li = ff_link_internal(ctx->outputs[0]); + if (s->warning_limit && + ff_framequeue_queued_frames(&li->fifo) >= s->warning_limit) { + av_log(s, AV_LOG_WARNING, + "%d buffers queued in %s, something may be wrong.\n", + s->warning_limit, + (char *)av_x_if_null(ctx->name, ctx->filter->name)); + s->warning_limit *= 10; + } + return 0; } @@ -296,6 +307,14 @@ int av_buffersrc_get_status(AVFilterContext *ctx) return s->eof ? AVERROR(EOF) : 0; } +static av_cold int common_init(AVFilterContext *ctx) +{ + BufferSourceContext *c = ctx->priv; + + c->warning_limit = 100; + return 0; +} + static av_cold int init_video(AVFilterContext *ctx) { BufferSourceContext *c = ctx->priv; @@ -327,7 +346,7 @@ static av_cold int init_video(AVFilterContext *ctx) av_color_space_name(c->color_space), av_color_range_name(c->color_range), av_alpha_mode_name(c->alpha_mode)); - return 0; + return common_init(ctx); } unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src) @@ -400,7 +419,6 @@ static av_cold int init_audio(AVFilterContext *ctx) { BufferSourceContext *s = ctx->priv; char buf[128]; - int ret = 0; if (s->sample_fmt == AV_SAMPLE_FMT_NONE) { av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n"); @@ -444,7 +462,7 @@ static av_cold int init_audio(AVFilterContext *ctx) s->time_base.num, s->time_base.den, av_get_sample_fmt_name(s->sample_fmt), s->sample_rate, buf); - return ret; + return common_init(ctx); } static av_cold void uninit(AVFilterContext *ctx)