History

lavfi/formats: describe conversion in negotiation structure.

Nicolas George committed 5 years ago

Commit 85a64041 parent 86d3dd53 files · +18 −33Browse files

Showing the changes to libavfilter/avfiltergraph.c (1 of 3 files). Show all

Unified · Split

libavfilter/avfiltergraph.c+12−33
@@ -430,7 +430,7 @@ static int formats_declared(AVFilterContext *f) · 429 unmodified lines
430430 static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
431431 {
432432 int i, j, ret;
433− int scaler_count = 0, resampler_count = 0;
433+ int converter_count = 0;
434434 int count_queried = 0; /* successful calls to query_formats() */
435435 int count_merged = 0; /* successful merge of formats lists */
436436 int count_already_merged = 0; /* lists already merged */
@@ -497,6 +497,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 60 unmodified lines
497497 const AVFilter *filter;
498498 AVFilterLink *inlink, *outlink;
499499 char inst_name[30];
500+ const char *opts;
500501
501502 if (graph->disable_auto_convert) {
502503 av_log(log_ctx, AV_LOG_ERROR,
@@ -507,40 +508,18 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 4 unmodified lines
507508 }
508509
509510 /* couldn't merge format lists. auto-insert conversion filter */
510− switch (link->type) {
511− case AVMEDIA_TYPE_VIDEO:
512− if (!(filter = avfilter_get_by_name("scale"))) {
513− av_log(log_ctx, AV_LOG_ERROR, "'scale' filter "
514− "not present, cannot convert pixel formats.\n");
515− return AVERROR(EINVAL);
516− }
517−
518− snprintf(inst_name, sizeof(inst_name), "auto_scaler_%d",
519− scaler_count++);
520−
521− if ((ret = avfilter_graph_create_filter(&convert, filter,
522− inst_name, graph->scale_sws_opts, NULL,
523− graph)) < 0)
524− return ret;
525− break;
526− case AVMEDIA_TYPE_AUDIO:
527− if (!(filter = avfilter_get_by_name("aresample"))) {
528− av_log(log_ctx, AV_LOG_ERROR, "'aresample' filter "
529− "not present, cannot convert audio formats.\n");
530− return AVERROR(EINVAL);
531− }
532−
533− snprintf(inst_name, sizeof(inst_name), "auto_resampler_%d",
534− resampler_count++);
535− if ((ret = avfilter_graph_create_filter(&convert, filter,
536− inst_name, graph->aresample_swr_opts,
537− NULL, graph)) < 0)
538− return ret;
539− break;
540− default:
511+ if (!(filter = avfilter_get_by_name(neg->conversion_filter))) {
512+ av_log(log_ctx, AV_LOG_ERROR,
513+ "'%s' filter not present, cannot convert formats.\n",
514+ neg->conversion_filter);
541515 return AVERROR(EINVAL);
542516 }
543−
517+ snprintf(inst_name, sizeof(inst_name), "auto_%s_%d",
518+ neg->conversion_filter, converter_count++);
519+ opts = FF_FIELD_AT(char *, neg->conversion_opts_offset, *graph);
520+ ret = avfilter_graph_create_filter(&convert, filter, inst_name, opts, NULL, graph);
521+ if (ret < 0)
522+ return ret;
544523 if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0)
545524 return ret;
546525

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t