[FFmpeg-devel] PATCH: 5.1 AAC SMPTE channel order with libfaad

Jean-Yves Avenard jyavenard
Mon Apr 5 15:34:26 CEST 2010


Hi

On 5 April 2010 23:05, Robert Swain <robert.swain at gmail.com> wrote:
> What about non-5.1 configurations? I need to check the code for that
> but don't have time right now.

Then I leave them untouched.

The only time channels are reordered is when it's a 5.1 stream.
I've never seen AAC audio sample being different than stereo or 5.1.
It's obviously possible technically.

The reordering is done according to the NeAACDecFrameInfo structure
filled by libfaad decode routine. It provides a member
channel_position which is an array of char containing information for
each channel.

so channel_position[0] contains information about the location of the
first channel, channel_position[1] the 2nd etc.. The position is one
of the following value:
#define FRONT_CHANNEL_CENTER (1)
#define FRONT_CHANNEL_LEFT	(2)
#define FRONT_CHANNEL_RIGHT (3)
#define SIDE_CHANNEL_LEFT	(4)
#define SIDE_CHANNEL_RIGHT	(5)
#define BACK_CHANNEL_LEFT	(6)
#define BACK_CHANNEL_RIGHT	(7)
#define BACK_CHANNEL_CENTER (8)
#define LFE_CHANNEL	(9)

Typically, channel_position contains { 2, 3, 6, 7, 9 }

> Other codecs do it in-codec because they can set up an array of
> pointers to be passed to our float to 16-bit int conversion routines
> that will reorder channels and interleave samples on the fly. Generic
> channel reordering for codecs that don't output in
> waveformatextensible order, could be implemented outside the codec and
> be shared between all such codecs. But maybe there's something to be
> said for implementing it in a shared manner, but using it in affected
> codecs so that they do all output the same channel order. I think such
> a thing would simplify matters for anything after the decoder. I think
> this is what M?ns was getting at.

I understand...
The data output but libfaad is already interleaved though, and other
than the incorrect channel order (or more accurately, ffmpeg doesn't
process the channels configuration returned by libfaad) , it's ready
to be used by ffmpeg and passed on to the client.

What about non-16 bits audio? like 32 bits samples ?

I could look into implementing the channel reordering using similar
map ; but based on what was said earlier, that libfaad will get
deprecated soon, it seems to be an awfully more complicated design
than the quick channel re-order I've put in place...

In any case; weither you accept my solution or not ; channels order
with libfaad is currently broken...

I'd love to use ffmpeg own's decoder ; but currently , this is not
something possible.

Is there an ETA on when ffmpeg's own support will be completed?

Another thing I've noticed not to work properly in ffmpeg's own AAC
decoder is the downmix from 5.1 to stereo. Last I check, the center
channel was missing, so typically, you loose most of the dialogues.

JY



More information about the ffmpeg-devel mailing list