This fixes regressions caused by switching from ffmpegs system to avfilters.
Showing the changes to libavfilter/avfiltergraph.c (1 of 1 file). Show all
Unified · Split
| @@ -24,6 +24,7 @@ · 23 unmodified lines | |||
| 24 | #include <string.h> | 24 | #include <string.h> |
| 25 | 25 | ||
| 26 | #include "libavutil/audioconvert.h" | 26 | #include "libavutil/audioconvert.h" |
| 27 | #include "libavutil/pixdesc.h" | ||
| 27 | #include "avfilter.h" | 28 | #include "avfilter.h" |
| 28 | #include "avfiltergraph.h" | 29 | #include "avfiltergraph.h" |
| 29 | #include "internal.h" | 30 | #include "internal.h" |
| @@ -252,13 +253,26 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 222 unmodified lines | |||
| 252 | return 0; | 253 | return 0; |
| 253 | } | 254 | } |
| 254 | 255 | ||
| 255 | static void pick_format(AVFilterLink *link) | 256 | static void pick_format(AVFilterLink *link, AVFilterLink *ref) |
| 256 | { | 257 | { |
| 257 | if (!link || !link->in_formats) | 258 | if (!link || !link->in_formats) |
| 258 | return; | 259 | return; |
| 259 | 260 | ||
| 261 | if (link->type == AVMEDIA_TYPE_VIDEO) { | ||
| 262 | if(ref && ref->type == AVMEDIA_TYPE_VIDEO){ | ||
| 263 | int has_alpha= av_pix_fmt_descriptors[ref->format].nb_components % 2 == 0; | ||
| 264 | enum PixelFormat best= PIX_FMT_NONE; | ||
| 265 | int i; | ||
| 266 | for (i=0; i<link->in_formats->format_count; i++) { | ||
| 267 | enum PixelFormat p = link->in_formats->formats[i]; | ||
| 268 | best= avcodec_find_best_pix_fmt2(best, p, ref->format, has_alpha, NULL); | ||
| 269 | } | ||
| 270 | link->format = best; | ||
| 271 | }else | ||
| 272 | link->format = link->in_formats->formats[0]; | ||
| 273 | } | ||
| 274 | |||
| 260 | link->in_formats->format_count = 1; | 275 | link->in_formats->format_count = 1; |
| 261 | link->format = link->in_formats->formats[0]; | ||
| 262 | avfilter_formats_unref(&link->in_formats); | 276 | avfilter_formats_unref(&link->in_formats); |
| 263 | avfilter_formats_unref(&link->out_formats); | 277 | avfilter_formats_unref(&link->out_formats); |
| 264 | 278 | ||
| @@ -324,11 +338,21 @@ static void pick_formats(AVFilterGraph *graph) · 59 unmodified lines | |||
| 324 | 338 | ||
| 325 | for (i = 0; i < graph->filter_count; i++) { | 339 | for (i = 0; i < graph->filter_count; i++) { |
| 326 | AVFilterContext *filter = graph->filters[i]; | 340 | AVFilterContext *filter = graph->filters[i]; |
| 327 | 341 | if (filter->input_count && filter->output_count) { | |
| 328 | for (j = 0; j < filter->input_count; j++) | 342 | for (j = 0; j < filter->input_count; j++) |
| 329 | pick_format(filter->inputs[j]); | 343 | pick_format(filter->inputs[j], NULL); |
| 330 | for (j = 0; j < filter->output_count; j++) | 344 | for (j = 0; j < filter->output_count; j++) |
| 331 | pick_format(filter->outputs[j]); | 345 | pick_format(filter->outputs[j], filter->inputs[0]); |
| 346 | } | ||
| 347 | } | ||
| 348 | for (i = 0; i < graph->filter_count; i++) { | ||
| 349 | AVFilterContext *filter = graph->filters[i]; | ||
| 350 | if (!(filter->input_count && filter->output_count)) { | ||
| 351 | for (j = 0; j < filter->input_count; j++) | ||
| 352 | pick_format(filter->inputs[j], NULL); | ||
| 353 | for (j = 0; j < filter->output_count; j++) | ||
| 354 | pick_format(filter->outputs[j], NULL); | ||
| 355 | } | ||
| 332 | } | 356 | } |
| 333 | } | 357 | } |
| 334 | 358 | ||