avfiltergraph: fix format selection.

The old code had two bugs:

For audio filters, the format was not set.

For video filters, if several links reference the same format list,
the same format must be selected in the end. This is done by
setting formats->format_count to 1: the other links sharing
the reference will therefore have only one choice.
If the heuristic does not pick the first format, the selected format
must also be moved to the first position.
This commit is contained in:
Nicolas George 2012-04-23 16:55:11 +02:00
parent 62b745a6d3
commit fd2cd64fc9
1 changed files with 3 additions and 3 deletions

View File

@ -269,12 +269,12 @@ static void pick_format(AVFilterLink *link, AVFilterLink *ref)
enum PixelFormat p = link->in_formats->formats[i]; enum PixelFormat p = link->in_formats->formats[i];
best= avcodec_find_best_pix_fmt2(best, p, ref->format, has_alpha, NULL); best= avcodec_find_best_pix_fmt2(best, p, ref->format, has_alpha, NULL);
} }
link->format = best; link->in_formats->formats[0] = best;
}else }
link->format = link->in_formats->formats[0];
} }
link->in_formats->format_count = 1; link->in_formats->format_count = 1;
link->format = link->in_formats->formats[0];
avfilter_formats_unref(&link->in_formats); avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats); avfilter_formats_unref(&link->out_formats);