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

Stefano Sabatini stefano.sabatini-lala at poste.it
Sun Sep 11 11:00:06 CEST 2011


On date Sunday 2011-09-11 02:25:36 +0200, Michael Niedermayer encoded:
> On Sat, Sep 10, 2011 at 09:45:16AM +0200, Stefano Sabatini wrote:
> > On date Saturday 2011-09-10 03:46:23 +0200, Michael Niedermayer encoded:
> > > On Sat, Sep 10, 2011 at 02:01:27AM +0200, Stefano Sabatini wrote:
> > [...]
> > > > > AVFilterFormats *avfilter_all_channel_layouts(void)
> > > > > {
> > > > >     static int64_t cls[] = {
> > > > > #define A(x) (x), (x)|AV_CH_LOW_FREQUENCY
> > > > > #define B(x) A(x|AV_CH_FRONT_CENTER), A(x|AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT), A(x|AV_CH_FRONT_CENTER|AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
> > > > > #define C(x) B(x), B(x|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT), B(x|AV_CH_BACK_CENTER)
> > > > > #define D(x) C(x), C(x|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
> > > > >         D(0), D(AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
> > > > >     };
> > > > > 
> > > > >     for (i = 0; i < FF_ARRAY_ELEMS(cls); i++) {
> > > > >         if (get_channel_layout_nb_channels(cls[i]) > 8) {
> > > > >             cls[i]=AV_CH_FRONT_CENTER;
> > > > >         }
> > > > >     }
> > > > >     return avfilter_make_format64_list(cls);
> > > > > }
> > > > 
> > > > My problem is that I need the list as an int64_t list (for use in the
> > > > audio sink). I could of course convert the formats list to int64_t,
> > > > but would be awkward. That's why I proposed a static int64_t array.
> > > 
> > > Both your code and mine use a static int64_t array and convert it with
> > > avfilter_make_format64_list()
> > > 
> > > the for() loop in mine is just there because we dont support >8
> > > channels ATM, that would be remvoed once that is fixed.
> > > 
> > > Please elaborate on what the problem is
> > 
> > I need the list to be *public*, so I can use it in code like this:
> > 
> >             enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, -1 };
> >             const int packing_fmts[] = { AVFILTER_PACKED, -1 };
> >             const int64_t *chlayouts = avfilter_all_channel_layouts_int64;
> 
> const int64_t avfilter_all_channel_layouts_int64[] = {
> #define A(x) (x), (x)|AV_CH_LOW_FREQUENCY
> #define B(x) A(x|AV_CH_FRONT_CENTER), A(x|AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT), A(x|AV_CH_FRONT_CENTER|AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
> #define C(x) B(x), B(x|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT), B(x|AV_CH_BACK_CENTER)
> #define D(x) C(x), C(x|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
>         D(0), D(AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT),
>         -1
> };

This is only moving the problem:

/**
 * A list of all channel layouts supported by libavfilter.
 */
extern const int64_t avfilter_all_channel_layouts_int64[];

we expect here the list of all supported formats, we could filter out
the non supported formats (the ones with more than 8 channels) in
avfilter_all_channel_layouts()) but then I don't know how to describe
avfilter_all_channel_layouts_int64:

a huge list of channel layouts, some may be not supported by
libavfilter due to the unsupported number of channels

and such obscure definitions quickly lead to bugs/hacks.

That's why I prefer compile-time generation.

...

Extending the number of channels on the other hand is not that simple,
since we need first to extend av_samples_alloc(), which currently
generates max-8-planes samples buffer, not sure if we should simply
extend the number or make this number a parameter.
-- 
FFmpeg = Fanciful and Foolish Minimalistic Philosofic Excellent God


More information about the ffmpeg-devel mailing list