[FFmpeg-devel] [PATCH] lavfi: add ff_all_channel_layouts internal symbol

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Aug 20 15:48:45 CEST 2011


On date Saturday 2011-08-20 15:33:16 +0200, Stefano Sabatini encoded:
> This way the list of all the channel layouts can be easily shared in
> the library, avoid code duplication.
> ---
>  libavfilter/formats.c  |   34 +++++++++++++++++-----------------
>  libavfilter/internal.h |    2 ++
>  2 files changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> index c863be6..504e9d7 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -153,25 +153,25 @@ AVFilterFormats *avfilter_all_formats(enum AVMediaType type)
>      return ret;
>  }
>  
> +const int64_t ff_all_channel_layouts[] = {
> +    AV_CH_LAYOUT_MONO,
> +    AV_CH_LAYOUT_STEREO,
> +    AV_CH_LAYOUT_4POINT0,
> +    AV_CH_LAYOUT_QUAD,
> +    AV_CH_LAYOUT_5POINT0,
> +    AV_CH_LAYOUT_5POINT0_BACK,
> +    AV_CH_LAYOUT_5POINT1,
> +    AV_CH_LAYOUT_5POINT1_BACK,
> +    AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX,
> +    AV_CH_LAYOUT_7POINT1,
> +    AV_CH_LAYOUT_7POINT1_WIDE,
> +    AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX,
> +    -1
> +};
> +
>  AVFilterFormats *avfilter_all_channel_layouts(void)
>  {
> -    static int64_t chlayouts[] = {
> -        AV_CH_LAYOUT_MONO,
> -        AV_CH_LAYOUT_STEREO,
> -        AV_CH_LAYOUT_4POINT0,
> -        AV_CH_LAYOUT_QUAD,
> -        AV_CH_LAYOUT_5POINT0,
> -        AV_CH_LAYOUT_5POINT0_BACK,
> -        AV_CH_LAYOUT_5POINT1,
> -        AV_CH_LAYOUT_5POINT1_BACK,
> -        AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX,
> -        AV_CH_LAYOUT_7POINT1,
> -        AV_CH_LAYOUT_7POINT1_WIDE,
> -        AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX,
> -        -1,
> -    };
> -
> -    return avfilter_make_format64_list(chlayouts);
> +    return avfilter_make_format64_list(ff_all_channel_layouts);
>  }
>  
>  AVFilterFormats *avfilter_all_packing_formats(void)
> diff --git a/libavfilter/internal.h b/libavfilter/internal.h
> index d03b8b8..f6d4990 100644
> --- a/libavfilter/internal.h
> +++ b/libavfilter/internal.h
> @@ -33,6 +33,8 @@ typedef struct AVFilterPool {
>      int count;
>  } AVFilterPool;
>  
> +extern const int64_t ff_all_channel_layouts[];
> +

This is more an RFC than a patch, since I'm not sure this is a proper
solution.

The problem: I need to access the list of all the channel layouts from
libavdevice.

libavfilter provides a list of all the channel layouts in
avfilter_all_channel_layouts(), so I'm simply using that list (for
which I'm including the libavfilter/internal.h header, which is not
very nice).

To be precise, I have this code:

            AVABufferSinkParams abuffersink_params = {
                .sample_fmts     = sample_fmts,
                .packing_fmts    = packing_fmts,
                .channel_layouts = ff_all_channel_layouts;
            };

            if ((ret = avfilter_graph_create_filter(&sink, abuffersink,
                                                    inout->name, NULL,
                                                    &abuffersink_params, lavfi->graph)) < 0)
                FAIL(ret);

so I need ff_all_channel_layouts to contain exactly the same layouts
returned by avfilter_all_channel_layouts().

A more proper solution may be to create a *public* symbol in libavutil
(av_all_channel_layouts) and use it in both libavfilter and
libavdevice. Would this make sense?

What shoul exactly be the semantics of all_channel_layouts anyway?
-- 
FFmpeg = Fundamentalist and Faithful Magical Proud Ecumenical Gigant


More information about the ffmpeg-devel mailing list