[FFmpeg-devel] [RFC] Channel layouts

Aurelien Jacobs aurel
Fri Aug 29 21:55:23 CEST 2008


Peter Ross wrote:

> On Fri, Aug 29, 2008 at 10:13:38AM +0200, Benjamin Larsson wrote:
> > Robert Swain wrote:
> > > 2008/8/29 Benjamin Larsson <banan at ludd.ltu.se>:
> > >   
> > >> Peter Ross wrote:
> > >>     
> > >>> Hi.
> > >>>
> > >>> This patch adds the notion of channel layouts to libavcodec.
> > >>>
> > >>> Summary of new concepts:
> > >>>
> > >>> * Channel IDs: We give each speaker a notional bit index.
> > >>>   e.g. CHANNEL_FRONT_LEFT=0, CHANNEL_FRONT_RIGHT=1, CHANNEL_BACK_CENTER=9
> > >>>
> > >>> * Channel Layout: An ORing together of Channel IDs.
> > >>>   e.g. ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT))
> > >>>   The resulting layout is identical to the dwChannelMask value found in
> > >>>   WAVEFORMATEXTENSIBLE. A channel layout of zero implies 'no statement'.
> > >>>
> > >>> * Chanels are stored with the FFmpeg 'samples' array according to ID order
> > >>>   e.g. left comes before right.
> > >>>
> > >>> * Encoders will indicate their supported channel layouts in AVCodec, in the
> > >>>   same way we do for pixel and sample formats.

I really like this proposition.
It has some small limitations (max 32 or 64 channels, etc...) but I don't
really see this as a problem.
This solution is quite simple and should cover all the cases we care about
right now. And it shouldn't be too hard to improve when the need occurs.

> > > Is there any benefit to doing all the bit shifting of the flags or can
> > > we just do the usual 0x1, 0x2, 0x4, 0x8, 0x10, 0x20... that we use for
> > > other bit mask flags?
> > >   
> > I think we just should add the relevant channel mask instead having this 
> > shifting.
> 
> If you can suggest another method to associate an ascii name to each channel
> masks (for the purpose of user friendly i/o), then I am happy to change...

You just don't need to specify the index in the string table as they
are anyway 0, 1, 2....
This should be enough:

+static const char* channel_names[]={
+    "front-left",
+    "front-right",
+    "front-centre",
+    ...

And this allows you to define CHANNEL_* as bitmask and drop the
bit shifting.

Aurel




More information about the ffmpeg-devel mailing list