Commit e98fa96192 for ffmpeg
commit e98fa96192fca03bfd3b6fa81dee784c0f6b2151
Author: Niklas Haas <git@haasn.dev>
Date: Thu Oct 29 13:26:38 2026 +0100
avfilter: apply max_buffered_frames per media type
Minor semantic change to prepare for the upcoming commits.
This shouldn't regress anything because the new behavior is strictly more
permissive than the old behavior, and the distinction is only relevant
for the uncommon case of combined audio-video filters.
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index a13cea2287..70674d2c91 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -149,12 +149,14 @@ int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
int avfilter_link(AVFilterContext *src, unsigned srcpad,
AVFilterContext *dst, unsigned dstpad)
{
+ FFFilterGraph *graphi;
FilterLinkInternal *li;
AVFilterLink *link;
av_assert0(src->graph);
av_assert0(dst->graph);
av_assert0(src->graph == dst->graph);
+ graphi = fffiltergraph(src->graph);
if (src->nb_outputs <= srcpad || dst->nb_inputs <= dstpad ||
src->outputs[srcpad] || dst->inputs[dstpad])
@@ -190,7 +192,8 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
link->format = -1;
link->colorspace = AVCOL_SPC_UNSPECIFIED;
- ff_framequeue_init(&li->fifo, &fffiltergraph(src->graph)->frame_queues);
+ av_assert1(link->type >= 0 && link->type < FF_ARRAY_ELEMS(graphi->frame_queues));
+ ff_framequeue_init(&li->fifo, &graphi->frame_queues[link->type]);
return 0;
}
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index a6b875c37a..e9a6ea8775 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -621,7 +621,8 @@ typedef struct AVFilterGraph {
char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
/**
- * Sets the maximum number of buffered frames in the filtergraph combined.
+ * Sets the maximum number of combined buffered frames of each media type
+ * in the filtergraph.
*
* Zero means no limit. This field must be set before calling
* avfilter_graph_config().
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 66f2394ea0..42940dcb45 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -154,7 +154,7 @@ typedef struct FFFilterGraph {
void *thread;
avfilter_execute_func *thread_execute;
- FFFrameQueueGlobal frame_queues;
+ FFFrameQueueGlobal frame_queues[AVMEDIA_TYPE_NB];
} FFFilterGraph;
static inline FFFilterGraph *fffiltergraph(AVFilterGraph *graph)
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 7d089ad28d..9729ef5fba 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -93,7 +93,8 @@ AVFilterGraph *avfilter_graph_alloc(void)
ret = &graph->p;
ret->av_class = &filtergraph_class;
av_opt_set_defaults(ret);
- ff_framequeue_global_init(&graph->frame_queues);
+ for (int i = 0; i < FF_ARRAY_ELEMS(graph->frame_queues); i++)
+ ff_framequeue_global_init(&graph->frame_queues[i]);
return ret;
}
@@ -1457,10 +1458,14 @@ static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
{
+ FFFilterGraph *graphi = fffiltergraph(graphctx);
int ret;
- if (graphctx->max_buffered_frames)
- fffiltergraph(graphctx)->frame_queues.max_queued = graphctx->max_buffered_frames;
+ for (int i = 0; i < FF_ARRAY_ELEMS(graphi->frame_queues); i++) {
+ const size_t max_queued = graphctx->max_buffered_frames;
+ if (max_queued)
+ graphi->frame_queues[i].max_queued = max_queued;
+ }
if ((ret = graph_check_validity(graphctx, log_ctx)))
return ret;
if ((ret = graph_config_formats(graphctx, log_ctx)))
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 77f38cb9b4..4a69d6be98 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
#include "version_major.h"
-#define LIBAVFILTER_VERSION_MINOR 9
+#define LIBAVFILTER_VERSION_MINOR 10
#define LIBAVFILTER_VERSION_MICRO 100