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

Stefano Sabatini stefano.sabatini-lala at poste.it
Wed Aug 31 19:22:08 CEST 2011


On date Friday 2011-08-26 14:22:03 +0200, Michael Niedermayer encoded:
> On Thu, Aug 25, 2011 at 01:38:52AM +0200, Stefano Sabatini wrote:
> > On date Wednesday 2011-08-24 05:48:55 +0200, Michael Niedermayer encoded:
> > > On Tue, Aug 23, 2011 at 03:31:35PM +0200, Stefano Sabatini wrote:
> > [...]
> > > > +const int64_t avfilter_all_channel_layouts_list[] = {
> > > > +    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
> > > > +};
> > > 
> > > There are more possible layouts than can easily be listed i think
> > 
> > Yes, this should be meant as the "default channel layouts which are
> > automatically selected when choosing 'all channels' in audio filters".
> > 
> > So maybe it should be better named
> > avfilter_default_all_channel_layouts_list.
> > 
> > If you don't like it please suggest alternatives.
> 
> assume the front and rear can be 0,1,2,3 speakers, side 0 or 2
> and wide 0 or 2 and there can be a LFE channel and there can be stereo
> downmix channels
> you get 256 combinations
> IMHO they all should be in the list at least

In other words you're asking for a non statically defined list of
formats, right?

The list would be useful for the elements we need to select all the
possible supported channel layouts, and pass this list to the sink
buffer. With sample/pixel formats it is easy to generate the list of
all formats, since you simply have to enumerate the formats, with
chlayouts this is not possible.

So we need to initialize the list somehow (then we can change the
contained elements in a second moment).

So we can create a function:
int64_t *avfilter_get_all_channel_layouts(void)

which returns a list (to be freed by the user), or returns a const
list which is initialized at some point, for example:

const int64_t *avfilter_get_all_channel_layouts(void);

the problem with this function is that it wouldn't be thread-safe (a
thread calls it, allocates the list and starts to fill it, the second
does the same thing before the first one terminates, and ends up by
allocating a second list, the first one is forgotten, etc.).

So maybe a better solution would be to implement an avfilter_init()
routine (non-thread-safe), which initializes a const list defined like:
extern const int64_t *avfilter_all_channel_layouts_int64;

which can then be accessed safely by the application threads (after it
has been inited).

Comments are welcome.
-- 
FFmpeg = Fundamentalist and Frightening Maxi Puristic Excellent Geek


More information about the ffmpeg-devel mailing list