aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-12-14 15:15:58 +0100
committerNiklas Haas <git@haasn.dev>2023-12-31 13:33:01 -0800
commite687a8485425e3d03ad8fea35b17ac8827ea1b82 (patch)
treeff6ac25a97b12b61e04137c6a6b8750f688ce2ce
parent0e9cf1abf558a5c71834548679c658b68244289d (diff)
downloadffmpeg-e687a8485425e3d03ad8fea35b17ac8827ea1b82.tar.gz
avfilter/formats: set audio fmt lists for vaf filters
Currently, the logic inside the FF_FILTER_FORMATS_QUERY_FUNC branch prevents this code from running in the event that we have a filter with a single video input and a single audio output, as the resulting audio output link will not have its channel counts / samplerates correctly initialized to their default values, possibly triggering a segfault downstream. An example of such a filter is vaf_spectrumsynth. Although this particular filter already sets up the channel counts and samplerates as part of the query function and therefore avoids triggering this bug, the bug still exists in principle. (And importantly, sets a wrong precedent)
-rw-r--r--libavfilter/formats.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index d1c97daf64..114886aeb2 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -808,16 +808,17 @@ int ff_default_query_formats(AVFilterContext *ctx)
/* Intended fallthrough */
case FF_FILTER_FORMATS_PASSTHROUGH:
case FF_FILTER_FORMATS_QUERY_FUNC:
- type = ctx->nb_inputs ? ctx->inputs [0]->type :
- ctx->nb_outputs ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO;
- formats = ff_all_formats(type);
+ type = AVMEDIA_TYPE_UNKNOWN;
+ formats = ff_all_formats(ctx->nb_inputs ? ctx->inputs [0]->type :
+ ctx->nb_outputs ? ctx->outputs[0]->type :
+ AVMEDIA_TYPE_VIDEO);
break;
}
ret = ff_set_common_formats(ctx, formats);
if (ret < 0)
return ret;
- if (type == AVMEDIA_TYPE_AUDIO) {
+ if (type != AVMEDIA_TYPE_VIDEO) {
ret = ff_set_common_all_channel_counts(ctx);
if (ret < 0)
return ret;