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 <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-03-26 15:21:33 +01:00
committed by Niklas Haas
parent ab7b6ef0a2
commit b09d57c41d

View File

@@ -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)