[Ffmpeg-devel] channel ordering and downmixing

Justin Ruggles justinruggles
Sun Apr 8 07:15:21 CEST 2007

Michael Niedermayer wrote:
> i even suggest to completely ignore downmix coeffs first and design just the
> channel layout stuff that way we have a smaller set of things to consider
> and after the channel layout is done and in svn work on the downmix coeffs
> (just a random suggestion)

Here is another concept-patch for channel layout handling.  Downmixing
is ignored for now.

The demuxer sets AVCodecContext->channel_layout to the appropriate
layout or leaves it NULL if unknown or codec-dependent.

If required, the decoder sets AVCodecContext->channel_layout to the
channel layout of the input audio stream.  If downmixing is done in the
decoder (current situation), the final downmixed channel layout is
considered the input layout.

The user must set AVCodecContext->channel_layout to one of the encoder's
compatible layouts in AVCodec->channel_layouts.  If the encoder's list
is empty, any layout can be used.

The user's chosen layout must also match one of the muxer's compatible
layouts in AVOutputFormat->channel_layouts.

Channel mixing and reordering API:

av_channel_mix_init allocates the AVChannelMixContext and sets the
values from input parameters.  To help the user with finding compatible
layouts, this function returns NULL if the ilayout and olayout
parameters are not compatible.

av_channel_mix does the channel reordering (and will do downmixing once
it is implemented).

av_channel_mix_close frees the AVChannelMixContext.

The attached patch is not fully-functional, but gives an idea of how it
might work.  The example used is encoding PCM wav to raw AC3.  The
user-level parts (ffmpeg.c and ffplay.c) are not implemented yet, so the
patch doesn't work at this point.

Also, I don't really know what appropriate channel positions should be.
 Anyone have any ideas or references I might refer to for this?

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: channelmix_sketch_2.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070408/eba66d33/attachment.txt>

More information about the ffmpeg-devel mailing list