diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 9e9464c034..114dfaa655 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -340,33 +340,21 @@ static int filter_check_formats(AVFilterContext *ctx) static int filter_query_formats(AVFilterContext *ctx) { int ret; - AVFilterFormats *formats; - AVFilterChannelLayouts *chlayouts; - enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : - ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : - AVMEDIA_TYPE_VIDEO; - if ((ret = ctx->filter->formats.query_func(ctx)) < 0) { - if (ret != AVERROR(EAGAIN)) - av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n", - ctx->name, av_err2str(ret)); - return ret; - } - ret = filter_check_formats(ctx); - if (ret < 0) - return ret; - - formats = ff_all_formats(type); - if ((ret = ff_set_common_formats(ctx, formats)) < 0) - return ret; - if (type == AVMEDIA_TYPE_AUDIO) { - if ((ret = ff_set_common_all_samplerates(ctx)) < 0) + if (ctx->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) { + if ((ret = ctx->filter->formats.query_func(ctx)) < 0) { + if (ret != AVERROR(EAGAIN)) + av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n", + ctx->name, av_err2str(ret)); return ret; - chlayouts = ff_all_channel_layouts(); - if ((ret = ff_set_common_channel_layouts(ctx, chlayouts)) < 0) + } + + ret = filter_check_formats(ctx); + if (ret < 0) return ret; } - return 0; + + return ff_default_query_formats(ctx); } static int formats_declared(AVFilterContext *f) @@ -415,10 +403,7 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx) AVFilterContext *f = graph->filters[i]; if (formats_declared(f)) continue; - if (f->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) - ret = filter_query_formats(f); - else - ret = ff_default_query_formats(f); + ret = filter_query_formats(f); if (ret < 0 && ret != AVERROR(EAGAIN)) return ret; /* note: EAGAIN could indicate a partial success, not counted yet */