[Ffmpeg-devel] channel ordering and downmixing

Justin Ruggles justinruggles
Thu Apr 5 11:18:11 CEST 2007

Benjamin Larsson wrote:
> Justin Ruggles wrote:
>>Justin Ruggles wrote:
>>>I need some advice on a channel ordering and downmixing framework.  I've
>>>been trying to figure out the best solution for a while and keep running
>>>into road blocks.
>>After spending too much time just pondering different ideas, I decided
>>to give it a go and try one out.
>>The attached patch isn't really meant to be a working patch, but more of
>>a conceptual sketch of a basic design.  I want to get ideas and comments
>>before taking the time to implement it in full.
>>The general concept is:
>> - add an AVChannelLayout struct to AVCodecContext
>> - have the muxer set its preferred channel layout in read_header()
>> - have the decoder override the channel layout if it wants to
>> - user-level API: av_channel_mix_init(), av_channel_mix(),
>>                   av_channel_mix_close()
>> - the encoder can set the channel layout in encode_init or just set the
>>   number of channels and set the mask to CHANNEL_MASK_NONE to let the
>>   muxer decide
>> - if avctx->channel_layout.mask is CHANNEL_MASK_NONE, the muxer should
>>   set the channel layout
>>Any suggestions/critiques would be great. :)
> Don't forget the dts down mixing coeffs. Anyway I think the codecs
> should have the layout and down mixing coeffs, not channelmix.c but that
> is just a technicality. DTS for example has the ability to use coeffs
> from the actual bitstream.

I forgot to mention that part.  Since there is a channel layout struct
in AVCodecContext, the codec can also override the mixing coeffs.  The
default coeffs use -3dB for center and surround mix levels and are
normalized.  I think defaults are a good idea for codecs which don't
explicitly define downmixing coeffs.

As far as where to put the layouts, an alternative idea would be to
define all the unique preset layouts as ff_#_#_#_A/B/C_channel_layout in
channelmix.c and leave out all the duplicate names.

Anyway, I'm off to work, so I hope I have lots of suggestions to read
when I return. :)


More information about the ffmpeg-devel mailing list