MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / query_formats

Function query_formats

libavfilter/avfiltergraph.c:108–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
109{
110 int i, j;
111 int scaler_count = 0;
112 char inst_name[30];
113
114 /* ask all the sub-filters for their supported colorspaces */
115 for(i = 0; i < graph->filter_count; i ++) {
116 if(graph->filters[i]->filter->query_formats)
117 graph->filters[i]->filter->query_formats(graph->filters[i]);
118 else
119 avfilter_default_query_formats(graph->filters[i]);
120 }
121
122 /* go through and merge as many format lists as possible */
123 for(i = 0; i < graph->filter_count; i ++) {
124 AVFilterContext *filter = graph->filters[i];
125
126 for(j = 0; j < filter->input_count; j ++) {
127 AVFilterLink *link = filter->inputs[j];
128 if(link && link->in_formats != link->out_formats) {
129 if(!avfilter_merge_formats(link->in_formats,
130 link->out_formats)) {
131 AVFilterContext *scale;
132 char scale_args[256];
133 /* couldn't merge format lists. auto-insert scale filter */
134 snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
135 scaler_count++);
136 scale =
137 avfilter_open(avfilter_get_by_name("scale"),inst_name);
138
139 snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
140 if(!scale || scale->filter->init(scale, scale_args, NULL) ||
141 avfilter_insert_filter(link, scale, 0, 0)) {
142 avfilter_destroy(scale);
143 return -1;
144 }
145
146 if (avfilter_graph_add_filter(graph, scale) < 0)
147 return -1;
148
149 scale->filter->query_formats(scale);
150 if (((link = scale-> inputs[0]) &&
151 !avfilter_merge_formats(link->in_formats, link->out_formats)) ||
152 ((link = scale->outputs[0]) &&
153 !avfilter_merge_formats(link->in_formats, link->out_formats))) {
154 av_log(log_ctx, AV_LOG_ERROR,
155 "Impossible to convert between the formats supported by the filter "
156 "'%s' and the filter '%s'\n", link->src->name, link->dst->name);
157 return -1;
158 }
159 }
160 }
161 }
162 }
163
164 return 0;
165}

Callers 1

Calls 8

avfilter_merge_formatsFunction · 0.85
avfilter_openFunction · 0.85
avfilter_get_by_nameFunction · 0.85
avfilter_insert_filterFunction · 0.85
avfilter_destroyFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected