summaryrefslogtreecommitdiff
path: root/libavfilter/avfiltergraph.c
diff options
context:
space:
mode:
authorNicolas George <george@nsup.org>2021-07-24 19:37:55 +0200
committerNicolas George <george@nsup.org>2021-08-14 09:17:45 +0200
commit85a6404d7e6c759ddf71d6374812d7ff719728ec (patch)
treed1d6fc6eff506ac53c86431fdc9dd9cca6a0a0f5 /libavfilter/avfiltergraph.c
parent86d3dd5627b5c8c179aa48c7e4834a69371a14e6 (diff)
lavfi/formats: describe conversion in negotiation structure.
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r--libavfilter/avfiltergraph.c45
1 files changed, 12 insertions, 33 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 8342e21769..41a91a9bda 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -430,7 +430,7 @@ static int formats_declared(AVFilterContext *f)
static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
int i, j, ret;
- int scaler_count = 0, resampler_count = 0;
+ int converter_count = 0;
int count_queried = 0; /* successful calls to query_formats() */
int count_merged = 0; /* successful merge of formats lists */
int count_already_merged = 0; /* lists already merged */
@@ -497,6 +497,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
const AVFilter *filter;
AVFilterLink *inlink, *outlink;
char inst_name[30];
+ const char *opts;
if (graph->disable_auto_convert) {
av_log(log_ctx, AV_LOG_ERROR,
@@ -507,40 +508,18 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
}
/* couldn't merge format lists. auto-insert conversion filter */
- switch (link->type) {
- case AVMEDIA_TYPE_VIDEO:
- if (!(filter = avfilter_get_by_name("scale"))) {
- av_log(log_ctx, AV_LOG_ERROR, "'scale' filter "
- "not present, cannot convert pixel formats.\n");
- return AVERROR(EINVAL);
- }
-
- snprintf(inst_name, sizeof(inst_name), "auto_scaler_%d",
- scaler_count++);
-
- if ((ret = avfilter_graph_create_filter(&convert, filter,
- inst_name, graph->scale_sws_opts, NULL,
- graph)) < 0)
- return ret;
- break;
- case AVMEDIA_TYPE_AUDIO:
- if (!(filter = avfilter_get_by_name("aresample"))) {
- av_log(log_ctx, AV_LOG_ERROR, "'aresample' filter "
- "not present, cannot convert audio formats.\n");
- return AVERROR(EINVAL);
- }
-
- snprintf(inst_name, sizeof(inst_name), "auto_resampler_%d",
- resampler_count++);
- if ((ret = avfilter_graph_create_filter(&convert, filter,
- inst_name, graph->aresample_swr_opts,
- NULL, graph)) < 0)
- return ret;
- break;
- default:
+ if (!(filter = avfilter_get_by_name(neg->conversion_filter))) {
+ av_log(log_ctx, AV_LOG_ERROR,
+ "'%s' filter not present, cannot convert formats.\n",
+ neg->conversion_filter);
return AVERROR(EINVAL);
}
-
+ snprintf(inst_name, sizeof(inst_name), "auto_%s_%d",
+ neg->conversion_filter, converter_count++);
+ opts = FF_FIELD_AT(char *, neg->conversion_opts_offset, *graph);
+ ret = avfilter_graph_create_filter(&convert, filter, inst_name, opts, NULL, graph);
+ if (ret < 0)
+ return ret;
if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0)
return ret;