[FFmpeg-devel] [PATCH 02/10] lavfi: support unknown channel layouts.
Stefano Sabatini
stefasab at gmail.com
Fri Jan 18 01:00:56 CET 2013
On date Wednesday 2013-01-16 17:50:16 +0100, Nicolas George encoded:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/audio.c | 2 +-
> libavfilter/avcodec.c | 3 --
> libavfilter/avfiltergraph.c | 85 ++++++++++++++++++++++++++++++++++++++++---
> libavfilter/formats.c | 82 ++++++++++++++++++++++++++++++++++++-----
> libavfilter/formats.h | 31 ++++++++++++++++
> 5 files changed, 184 insertions(+), 19 deletions(-)
[...]
> @@ -663,7 +720,23 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter)
> int out_channels = av_get_channel_layout_nb_channels(out_chlayout);
> int count_diff = out_channels - in_channels;
> int matched_channels, extra_channels;
> - int score = 0;
> + int score = 100000;
> +
> + if (FF_LAYOUT2COUNT(in_chlayout) || FF_LAYOUT2COUNT(out_chlayout)) {
> + /* Compute score in case the input or output layout encodes
> + a channel count; in this case the score is not altered by
> + the computation afterwards, as in_chlayout and
> + out_chlayout have both been set to 0 */
> + if (FF_LAYOUT2COUNT(in_chlayout))
> + in_channels = FF_LAYOUT2COUNT(in_chlayout);
> + if (FF_LAYOUT2COUNT(out_chlayout))
> + out_channels = FF_LAYOUT2COUNT(out_chlayout);
> + score -= 10000 + FFABS(out_channels - in_channels) +
> + (in_channels > out_channels ? 10000 : 0);
> + in_chlayout = out_chlayout = 0;
> + /* Let the remaining computation run, even if the score
> + value is not altered */
> + }
Much better, thanks.
[...]
> diff --git a/libavfilter/formats.h b/libavfilter/formats.h
> index c5a4e3d..dd52ec8 100644
> --- a/libavfilter/formats.h
> +++ b/libavfilter/formats.h
> @@ -69,15 +69,46 @@ struct AVFilterFormats {
> struct AVFilterFormats ***refs; ///< references to this list
> };
>
> +/**
> + * A list of supported channel layouts.
> + *
> + * The list works the same as AVFilterFormats, except for the following
> + * differences:
> + * - A list with all_layouts = 1 means all channel layouts with a known
> + * disposition; nb_channel_layouts must then be 0.
> + * - A list with all_counts = 1 means all channel counts, with a known or
> + * unknown disposition ; nb_channel_layouts must then be 0 and all_layouts 1.
nit: "disposition ;" -> "disposition;"
[...]
No more comments from me, looks good assuming FATE is happy with it.
--
FFmpeg = Fiendish & Frightening Multipurpose Plastic Experimenting God
More information about the ffmpeg-devel
mailing list