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. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter Ross schrieb:
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.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter, please take this into account: http://msdn.microsoft.com/en-us/library/aa474707.aspx Basically 5.1 must use the side speakers (0x60f) and not the back speakers (0x3f). Unfortunately most software still uses the outdated (wrong) channel mask. So maybe you should support both as input. But both should be interpreted as meaning the side speakers... Regards, madshi.
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.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
------------------------------------------------------------------------
+#define CHANNEL_LAYOUT_MONO (1<<CHANNEL_FRONT_CENTER) +#define CHANNEL_LAYOUT_STEREO ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)) +#define CHANNEL_LAYOUT_QUAD ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT)) +#define CHANNEL_LAYOUT_5POINT1 ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_FRONT_CENTER)|(1<<CHANNEL_LOW_FREQUENCY)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT))
We will need alot more defines to cover all the cases available. DCA has alot of layouts. Anyway I think the codec should have the definitions for all possible layouts. MvH Benjamin Larsson
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.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
I assume it's insisted that the channels be order as they are in the channel mask and the convention is suggested by the third bullet point though I think it should be clarified. It sounds like the internal channel order is defined by channel mask reading from the least significant bit upwards. e.g.
+#define CHANNEL_LAYOUT_5POINT1 ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_FRONT_CENTER)|(1<<CHANNEL_LOW_FREQUENCY)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT))
Would be [FL][FR][C][LFE][SL][SR] in the output samples array. 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? Rob
Robert Swain wrote:
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?
Yes, The shift-values (or index) is used in: +static const char* channel_names[]={ + [CHANNEL_FRONT_LEFT] = "front-left",
2008/8/29 Andreas ?man <andreas at lonelycoder.com>:
Robert Swain wrote:
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?
Yes, The shift-values (or index) is used in:
+static const char* channel_names[]={ + [CHANNEL_FRONT_LEFT] = "front-left",
Ah, I see. OK. :) Rob
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.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
I assume it's insisted that the channels be order as they are in the channel mask and the convention is suggested by the third bullet point though I think it should be clarified. It sounds like the internal channel order is defined by channel mask reading from the least significant bit upwards.
e.g.
If that is correct then all decoders and encoder need a channel order permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
+#define CHANNEL_LAYOUT_5POINT1 ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_FRONT_CENTER)|(1<<CHANNEL_LOW_FREQUENCY)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT))
Would be [FL][FR][C][LFE][SL][SR] in the output samples array.
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.
Rob
MvH Benjamin Larsson
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.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
I assume it's insisted that the channels be order as they are in the channel mask and the convention is suggested by the third bullet point though I think it should be clarified. It sounds like the internal channel order is defined by channel mask reading from the least significant bit upwards.
Correct.
If that is correct then all decoders and encoder need a channel order permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
Why not perform the permutation inside the decoder?
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... -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter Ross wrote:
permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
If that is correct then all decoders and encoder need a channel order
Why not perform the permutation inside the decoder?
Yeah, the issue I'm hinting at is that you might only know how to reorder after you decoded the samples and that you would need to do a memcopy to rearrange the order.
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...
Well we could just add another table. But that is not a large issue. MvH Benjamin Larsson
Benjamin Larsson wrote:
Peter Ross wrote:
permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
If that is correct then all decoders and encoder need a channel order
Why not perform the permutation inside the decoder?
Yeah, the issue I'm hinting at is that you might only know how to reorder after you decoded the samples and that you would need to do a memcopy to rearrange the order.
Wouldn't it be as simple as reordering a few pointer, e.g. before passing them to float_to_int16_interleave? -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd wrote:
Benjamin Larsson wrote:
Peter Ross wrote:
permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
If that is correct then all decoders and encoder need a channel order
Why not perform the permutation inside the decoder?
Yeah, the issue I'm hinting at is that you might only know how to reorder after you decoded the samples and that you would need to do a memcopy to rearrange the order.
Wouldn't it be as simple as reordering a few pointer, e.g. before passing them to float_to_int16_interleave?
Well codecs will not perform float 2 int by themselfs in the future. But in theory yes. MvH Benjamin Larsson
2008/8/29 Benjamin Larsson <banan at ludd.ltu.se>:
M?ns Rullg?rd wrote:
Benjamin Larsson wrote:
Peter Ross wrote:
permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
If that is correct then all decoders and encoder need a channel order
Why not perform the permutation inside the decoder?
Yeah, the issue I'm hinting at is that you might only know how to reorder after you decoded the samples and that you would need to do a memcopy to rearrange the order.
Wouldn't it be as simple as reordering a few pointer, e.g. before passing them to float_to_int16_interleave?
Well codecs will not perform float 2 int by themselfs in the future. But in theory yes.
I guess we'll have to consider this in the channel mixing API. It should probably accept a similar array of pointers to float_to_int16_interleave(). Regards, Rob
Peter Ross wrote:
permutation table to match the internal FFmpeg channel order. I'm not sure how well that would fit for most decoders. One other option would be to decode in codec native order and then pass a channel permutation table via some means. I'll look into what would work best with dca.
If that is correct then all decoders and encoder need a channel order
Why not perform the permutation inside the decoder?
Ok, I looked at the dca code and it should be quite easy to support the native channel order idea there. It would simplify lots of stuff so I support that idea. MvH Benjamin Larsson
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
Aurelien Jacobs wrote:
[...] 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.
It's worth mentioning that this does not actually limit the total number of channels a codec can handle but rather the number of "speaker/channel positions". Audio channels which have no known speaker position will just appear last in order without a corresponding channel layout bit. So it's possible that avctx->channels > number_of_bits(channel_layout). An interactive user application might just pop up a request asking the user what to do with these channels.
Benjamin Larsson wrote:
Peter Ross wrote:
* Encoders will indicate their supported channel layouts in AVCodec, in the same way we do for pixel and sample formats.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
No, rather, the decoders have to be fixed to output/receive the channels in this fixed order.
------------------------------------------------------------------------
+#define CHANNEL_LAYOUT_MONO (1<<CHANNEL_FRONT_CENTER) +#define CHANNEL_LAYOUT_STEREO ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)) +#define CHANNEL_LAYOUT_QUAD ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT)) +#define CHANNEL_LAYOUT_5POINT1 ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_FRONT_CENTER)|(1<<CHANNEL_LOW_FREQUENCY)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT))
We will need alot more defines to cover all the cases available. DCA has alot of layouts. Anyway I think the codec should have the definitions for all possible layouts.
I believe these CHANNEL_LAYOUT_ -defines are just there for convenience. Codecs can assemble the bitmask any way they want to.
On Fri, Aug 29, 2008 at 10:08:33AM +0200, Andreas ?man wrote:
Benjamin Larsson wrote:
Peter Ross wrote:
* Encoders will indicate their supported channel layouts in AVCodec, in the same way we do for pixel and sample formats.
Will this solve the channel order also ? So that transcode from 5.1 dca to ac3 will work ?
No, rather, the decoders have to be fixed to output/receive the channels in this fixed order.
The proposed approach avoids the complexity, but at the expense of having to change existing codecs. This needs to be debated ;-)
------------------------------------------------------------------------
+#define CHANNEL_LAYOUT_MONO (1<<CHANNEL_FRONT_CENTER) +#define CHANNEL_LAYOUT_STEREO ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)) +#define CHANNEL_LAYOUT_QUAD ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT)) +#define CHANNEL_LAYOUT_5POINT1 ((1<<CHANNEL_FRONT_LEFT)|(1<<CHANNEL_FRONT_RIGHT)| \ + (1<<CHANNEL_FRONT_CENTER)|(1<<CHANNEL_LOW_FREQUENCY)| \ + (1<<CHANNEL_BACK_LEFT)|(1<<CHANNEL_BACK_RIGHT))
We will need alot more defines to cover all the cases available. DCA has alot of layouts. Anyway I think the codec should have the definitions for all possible layouts.
I believe these CHANNEL_LAYOUT_ -defines are just there for convenience. Codecs can assemble the bitmask any way they want to.
Yes. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Hello Peter, Peter Ross write:
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.
This is a very good idea. As already discussed in other posts this implies that there is sort of a standard channel order that all codecs have to tribute to, meaning every encoder needs to accept the audio data in exactly that channel order and every decoder needs to deliver in exactly that order. This indeed a huge amount of work, but it is a solution to get rid of the format chaos. BTW have you read EBU tech doc 3306 http://www.ebu.ch/CMSimages/en/tec_doc_t3306-2007_tcm6-42570.pdf They are recommending to extend the channel mask with STEREO_LEFT and STEREO_RIGHT (the bitstream extensions are a little weird I think) to address the issue of audio streams carrying 5.1 and stereo together (this is used in broadcasting when delivering FM stereo and satellite surround in a single program/playout for example). As the channel mask concept allows to add additional positions this doesn't affect codecs that do not care about this additional stereo pair, but it makes it possible to read the data from the file with libav and for example pass it to the audio card or the other way round. Just my 0.02$ Axel
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates
Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future.
Will you object an implementation that doesn't take care of the above issues? As I see it these are all valid points but the suggested proposal is a huge step compared to what we have now and will be suitable for most uses of multichannel audio. MvH Benjamin Larsson
On Fri, Aug 29, 2008 at 04:00:44PM +0200, Benjamin Larsson wrote:
Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future.
Will you object an implementation that doesn't take care of the above issues? As I see it these are all valid points but the suggested proposal is a huge step compared to what we have now and will be suitable for most uses of multichannel audio.
I think that alternative implementations should be discussed and considered only then can we say what is good and what is not. As simple example instead of am int bitmask, an array of flags could be used, thus avoiding the first problem. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is not what we do, but why we do it that matters.
On Fri, Aug 29, 2008 at 04:57:52PM +0200, Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:00:44PM +0200, Benjamin Larsson wrote:
Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future.
Will you object an implementation that doesn't take care of the above issues? As I see it these are all valid points but the suggested proposal is a huge step compared to what we have now and will be suitable for most uses of multichannel audio.
I think that alternative implementations should be discussed and considered only then can we say what is good and what is not.
As simple example instead of am int bitmask, an array of flags could be used, thus avoiding the first problem.
Of course we could also use int64 now and switch to array with a major version bump in case we do need more than 64 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras
Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:57:52PM +0200, Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:00:44PM +0200, Benjamin Larsson wrote:
Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future.
Will you object an implementation that doesn't take care of the above issues? As I see it these are all valid points but the suggested proposal is a huge step compared to what we have now and will be suitable for most uses of multichannel audio. I think that alternative implementations should be discussed and considered only then can we say what is good and what is not.
As simple example instead of am int bitmask, an array of flags could be used, thus avoiding the first problem.
Of course we could also use int64 now and switch to array with a major version bump in case we do need more than 64
I agree that we need more than what is provided by the wav bitmask. We at least need 64 bits, but that is still limiting. For example, SMPTE 428M (D-Cinema) defines 23 channels, and a good many of them are not in the Microsoft list. I think CoreAudio has 40 or so channel definitions. -Justin
On Fri, Aug 29, 2008 at 03:19:41PM +0200, Michael Niedermayer wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, 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.
This suggestion has a few problems. 1. it is limited to 32 (or 64) fixed channel "positions", 18 are already used in this initial patch, that is more than a 1/4 of the available space is alraedy used up. This reminds me a little of a famous quote of how much memory will always be enough for everyone ... 2. It breaks down once x,y,z positions of ideal speakers are available instead of "front left" vs "back center" 3. When audio is returned by decoders as samples of all channels interleaved, like it is done currently, then a fixed order means the user app must reorder unless the destination (SDL, OSS, ALSA, ...) and finally and most importabtly the hardware can handle our order. This of course is irrelevant for planar audio which may be what many decoders will output in the future.
For info: OSS: provides SNDCTL_DSP_GET_CHNORDER ioctl. It returns a 64-bit integer describing the "speaker ID" associated with each each logical channel. There are only eight speaker IDs defined: L,R,C,LFE,SL,SR,RL,RR. http://manuals.opensound.com/developer/SNDCTL_DSP_GET_CHNORDER.html ALSA has standardised on these layouts quad: FL|FR|RL|RR 4.1: FL|FR|RL|RR|LFE 5.0: FL|FR|RL|RR|C 5.1: FL|FR|RL|RR|C|LFE 7.1: FL|FR|RL|RR|C|LFE|SL|SR SDL supports quad and 5.1, using these layouts quad: FL|FR|RL|RR 5.1: FL|FR|RL|RR|C|LFE Win32: uses the dwChannelMasks concept, as proposed in the patch. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Hi, On Fri, Aug 29, 2008 at 2:28 AM, Peter Ross <pross at xvid.org> wrote:
* Encoders will indicate their supported channel layouts in AVCodec, in the same way we do for pixel and sample formats.
If you look at liba52 vs. faad API, it seems like certain codecs aren't limited to fixed-layout styles. How will you support that in the layout API, and how will encoders present that in their AVCodec? E.g. how to distinguish left-right-lfe-back from left-right-back-lfe? Ronald PS the x,y,z channel position thing doesn't need to be supported, only Matroska does that AFAIK and it basically always is a literal translation from a channel layout such as here to litteral coordinates. Just go back by approximation and it should be fine. PS2 thanks for working on this, great addition and I've been wanting to work on something like this for quite a while!
Ronald S. Bultje wrote:
Hi,
On Fri, Aug 29, 2008 at 2:28 AM, Peter Ross <pross at xvid.org> wrote:
* Encoders will indicate their supported channel layouts in AVCodec, in the same way we do for pixel and sample formats.
If you look at liba52 vs. faad API, it seems like certain codecs aren't limited to fixed-layout styles. How will you support that in the layout API, and how will encoders present that in their AVCodec? E.g. how to distinguish left-right-lfe-back from left-right-back-lfe?
The codecs will have to fix the channel order themselfs. This is no more strange than saying that PIX_FMT_YUV expects the output to be in Y U V order. Forcing applications to support other order of YUV just because it's more convenient for the codecs does not make much sense IMHO.
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.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
We also need to add a parameter to request the decoded channelmask. For example dca have 2 4 channel layouts. Without a requested channelmask it would only be possible to get 1 layout. MvH Benjamin Larsson
Benjamin Larsson schrieb:
We also need to add a parameter to request the decoded channelmask. For example dca have 2 4 channel layouts. Without a requested channelmask it would only be possible to get 1 layout.
The DTS header specifies which layout the DTS was encoded with. See bitstream field "Audio Channel Arrangement". E.g. value 7 means "C + L + R+ S" while value 8 means "L + R+ SL+SR". What sense does it make to request a different decoded channel mask then is stored in the DTS track? Regards, madshi.
madshi wrote:
Benjamin Larsson schrieb:
We also need to add a parameter to request the decoded channelmask. For example dca have 2 4 channel layouts. Without a requested channelmask it would only be possible to get 1 layout.
The DTS header specifies which layout the DTS was encoded with. See bitstream field "Audio Channel Arrangement". E.g. value 7 means "C + L + R+ S" while value 8 means "L + R+ SL+SR". What sense does it make to request a different decoded channel mask then is stored in the DTS track?
Regards, madshi.
Sorry I was abit unclear. DTS defines alot of mixing configurations. If you have a strange channel layout you should still be able to mix into that configuration and that needs the possibility to request that specific layout instead of just one. But this might belong to the mixing support. I guess it can be omitted for now. MvH Benjamin Larsson
On Friday, 29 August 2008 at 16:23, madshi wrote:
Benjamin Larsson schrieb:
We also need to add a parameter to request the decoded channelmask. For example dca have 2 4 channel layouts. Without a requested channelmask it would only be possible to get 1 layout.
The DTS header specifies which layout the DTS was encoded with. See bitstream field "Audio Channel Arrangement". E.g. value 7 means "C + L + R+ S" while value 8 means "L + R+ SL+SR". What sense does it make to request a different decoded channel mask then is stored in the DTS track?
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable. Regards, R. -- MPlayer http://mplayerhq.hu | Livna http://rpm.livna.org There should be a science of discontent. People need hard times and oppression to develop psychic muscles. -- from "Collected Sayings of Muad'Dib" by the Princess Irulan
Dominik 'Rathann' Mierzejewski wrote:
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable.
This belongs to the audio layer of a mediaplayer IMHO. Most AV Amplifiers support stuff like: * Phantom Center (Mix C to L+R) * Phantom LFE (Mix LFE to L+R) * Small Front speakers (in 2ch mode, mix L+R to LFE) etc... certainly it should stay out of the codecs.
On Friday, 29 August 2008 at 16:35, Andreas ?man wrote:
Dominik 'Rathann' Mierzejewski wrote:
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable.
This belongs to the audio layer of a mediaplayer IMHO. Most AV Amplifiers support stuff like:
* Phantom Center (Mix C to L+R) * Phantom LFE (Mix LFE to L+R) * Small Front speakers (in 2ch mode, mix L+R to LFE) etc...
certainly it should stay out of the codecs.
But it might be faster to downmix upon decoding. I'm told there are asm optimizations to be easily made in common cases. Regards, R. -- MPlayer http://mplayerhq.hu | Livna http://rpm.livna.org There should be a science of discontent. People need hard times and oppression to develop psychic muscles. -- from "Collected Sayings of Muad'Dib" by the Princess Irulan
2008/8/29 Andreas ?man <andreas at lonelycoder.com>:
Dominik 'Rathann' Mierzejewski wrote:
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable.
This belongs to the audio layer of a mediaplayer IMHO. Most AV Amplifiers support stuff like:
* Phantom Center (Mix C to L+R) * Phantom LFE (Mix LFE to L+R) * Small Front speakers (in 2ch mode, mix L+R to LFE) etc...
certainly it should stay out of the codecs.
...unless the codec specifically supports it. E.g., TrueHD and MLP can embed a two-channel downmix into the stream - if stereo is requested, then it's not necessary to decode any other channels... Ian
Ian Caulfield wrote:
2008/8/29 Andreas ?man <andreas at lonelycoder.com>:
Dominik 'Rathann' Mierzejewski wrote:
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable. This belongs to the audio layer of a mediaplayer IMHO. Most AV Amplifiers support stuff like:
* Phantom Center (Mix C to L+R) * Phantom LFE (Mix LFE to L+R) * Small Front speakers (in 2ch mode, mix L+R to LFE) etc...
certainly it should stay out of the codecs.
...unless the codec specifically supports it. E.g., TrueHD and MLP can embed a two-channel downmix into the stream - if stereo is requested, then it's not necessary to decode any other channels...
Of course, stereo/mono downmix is perfectly supported today, the question is more if anyone will ever write codec-internal rematrixing for other combinations. But as Ben said, this can be added later.
Dominik 'Rathann' Mierzejewski schrieb:
On Friday, 29 August 2008 at 16:23, madshi wrote:
Benjamin Larsson schrieb:
We also need to add a parameter to request the decoded channelmask. For example dca have 2 4 channel layouts. Without a requested channelmask it would only be possible to get 1 layout.
The DTS header specifies which layout the DTS was encoded with. See bitstream field "Audio Channel Arrangement". E.g. value 7 means "C + L + R+ S" while value 8 means "L + R+ SL+SR". What sense does it make to request a different decoded channel mask then is stored in the DTS track?
What if you have 4 speakers but in a different layout than the encoded one? With the two layouts above (C+L+R+S encoded and L+R+SL+SR speakers) I'd expect the sound to come out of the front speakers only, with C+S channels mixed equally with L and R. This could be done by the codec or an audio filter if the codec isn't capable.
Regards, R.
As Benjamin replied in the other post I think this is what a mixer can do. But it should not be the job of a decoder to do funny mixing stuff. IMHO a decoder should simply decode and output whatever channel layout, bitdepth etc is native. Everything that differs from "native" should be done outside of the decoder, I think. Because that is code which is not really decoder specific... Regards, madshi.
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback. Test wav/wma files for 7.1 and 5.1 can be found here: http://www.microsoft.com/windows/windowsmedia/howto/articles/Multichannel.as... Audio coordinates space: my feeling is that this would be best implemented as an alternate/supplemental method of identifying the channel layout. [OT: that said, world/body-coordinate system support in FFmpeg would be useful for geospatial metadata, such as EXIM, GeoTIFF and Distributed Interactive Simulation Audio.]. Cheers, -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Test wav/wma files for 7.1 and 5.1 can be found here: http://www.microsoft.com/windows/windowsmedia/howto/articles/Multichannel.as...
Audio coordinates space: my feeling is that this would be best implemented as an alternate/supplemental method of identifying the channel layout.
I agree. A function to map a list of coordinates to a list of channel position should work fine in all common cases. That can be added when needed.
+void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout) +{ + if (channel_layout==0) + channel_layout = avcodec_guess_channel_layout(nb_channels); + if (nb_channels==1 && channel_layout==CHANNEL_LAYOUT_MONO) { + snprintf(buf, buf_size, "mono"); + }else if (nb_channels==2 && channel_layout==CHANNEL_LAYOUT_STEREO) { + snprintf(buf, buf_size, "stereo"); + }else if (nb_channels==4 && channel_layout==CHANNEL_LAYOUT_QUAD) { + snprintf(buf, buf_size, "quad"); + }else if (nb_channels==6 && channel_layout==CHANNEL_LAYOUT_5POINT1) { + snprintf(buf, buf_size, "5.1"); + }else if (nb_channels==8 && channel_layout==(CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX)) { + snprintf(buf, buf_size, "5.1+downmix"); + }else if (nb_channels==8 && channel_layout==CHANNEL_LAYOUT_7POINT1) { + snprintf(buf, buf_size, "7.1"); + }else if (nb_channels==8 && channel_layout==CHANNEL_LAYOUT_7POINT1_WIDE) { + snprintf(buf, buf_size, "7.1(wide)"); + }else if (nb_channels==10 && channel_layout==(CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX)) { + snprintf(buf, buf_size, "7.1+downmix"); + }else{
Maybe this slightly ugly code could be replace with a lookup table. Something like: static const struct { int nb_channels; int64_t layout; char *string; } layout_map[] = { { 1, CHANNEL_LAYOUT_MONO , "mono" }, { 2, CHANNEL_LAYOUT_STEREO , "stereo" }, { 4, CHANNEL_LAYOUT_QUAD , "quad" }, { 6, CHANNEL_LAYOUT_5POINT1 , "5.1" }, { 8, CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, "5.1+downmix" }, { 8, CHANNEL_LAYOUT_7POINT1 , "7.1" }, { 8, CHANNEL_LAYOUT_7POINT1_WIDE , "7.1(wide)" }, { 10, CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, "7.1+downmix" }, { 0 } }; for (i=0; channel_layout_mapping[i].nb_channels; i++) if (nb_channels == layout_map[i].nb_channels && channel_layout == layout_map[i].layout) { snprintf(buf, buf_size, layout_map[i].string); break; } Aurel
Hi, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec. [...]
I think your solution works well for now. I am not 100% clear about how the encoders/decoders should handle unsupported or undefined layouts. Firstly, is the channel layout is guessed by default? If so, that would eliminate it matching for some codecs. Also, if the layout is unspecified (and not guessed) I'm assuming an encoder or decoder can decide whether to accept or reject it? If it can accept it, then I suppose it would be up to the encoder/decoder to make its own guess? For the ffmpeg program, I think it should revert to undefined if rejected once, then if the codec doesn't support undefined layout return an error.
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0. -Justin
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec. [...]
I think your solution works well for now. I am not 100% clear about how the encoders/decoders should handle unsupported or undefined layouts. Firstly, is the channel layout is guessed by default? If so, that would
At this stage, the guess function is used only for display purposes.
eliminate it matching for some codecs. Also, if the layout is unspecified (and not guessed) I'm assuming an encoder or decoder can decide whether to accept or reject it? If it can accept it, then I suppose it would be up to the encoder/decoder to make its own guess?
If the decoder doesnt know the layout, then it should set layout to 0 (i.e. "no statement"). Each encoder will publish a list of supported input layouts, and libavcodec will provide transformation functions to convert(remix) between different layouts. All encoders will be capable of accepting a layout of 0.
For the ffmpeg program, I think it should revert to undefined if rejected once, then if the codec doesn't support undefined layout return an error.
Yes, that's doable. Eventually lavc will provide a layout transformation (down/upmixing) function. My vision to have FFmpeg negociate the layout in much the sample way it currently negociates different pixel and audio formats.
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
Deal. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec. [...]
I think your solution works well for now. I am not 100% clear about how the encoders/decoders should handle unsupported or undefined layouts. Firstly, is the channel layout is guessed by default? If so, that would
At this stage, the guess function is used only for display purposes.
eliminate it matching for some codecs. Also, if the layout is unspecified (and not guessed) I'm assuming an encoder or decoder can decide whether to accept or reject it? If it can accept it, then I suppose it would be up to the encoder/decoder to make its own guess?
If the decoder doesnt know the layout, then it should set layout to 0 (i.e. "no statement").
Each encoder will publish a list of supported input layouts, and libavcodec will provide transformation functions to convert(remix) between different layouts. All encoders will be capable of accepting a layout of 0.
For the ffmpeg program, I think it should revert to undefined if rejected once, then if the codec doesn't support undefined layout return an error.
Yes, that's doable. Eventually lavc will provide a layout transformation (down/upmixing) function. My vision to have FFmpeg negociate the layout in much the sample way it currently negociates different pixel and audio formats.
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2. -- M?ns Rullg?rd mans at mansr.com
M?ns Rullg?rd wrote:
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
The idea is that the order is the same as the CHANNEL_LAYOUT bits. I.e. LEFT must be the first channel if it exists, then RIGHT, etc. Still, this would only be mandatory for codecs (and formats) that specifies channel_layout. This is IMHO no more strange than that PIX_FMT_YUV always have the planes in Y,U,V order. From an application perspective i find this much more convenient. There might be more work in the decoders though. Still, with float_to_int16_interleave() (that all of the "popular" multi-channel codecs currently use (AC3, DTS and AAC)) this is just a matter of swizzling a few pointers at setup time. For other codecs there might be more work involved. However, that day ffmpeg gets planar audio formats this is even less an issue.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
Just for the record, i've stumbled across 5.0 AC3 in DVB content.
Andreas ?man <andreas at lonelycoder.com> writes:
M?ns Rullg?rd wrote:
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
The idea is that the order is the same as the CHANNEL_LAYOUT bits. I.e. LEFT must be the first channel if it exists, then RIGHT, etc. Still, this would only be mandatory for codecs (and formats) that specifies channel_layout.
This is IMHO no more strange than that PIX_FMT_YUV always have the planes in Y,U,V order. From an application perspective i find this much more convenient. There might be more work in the decoders though. Still, with float_to_int16_interleave() (that all of the "popular" multi-channel codecs currently use (AC3, DTS and AAC)) this is just a matter of swizzling a few pointers at setup time.
Using the same order for all codecs makes sense. At the moment, however, the each decoder outputs channels in a different, and undocumented, order. -- M?ns Rullg?rd mans at mansr.com
Hi, Andreas ?man wrote:
M?ns Rullg?rd wrote:
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
The idea is that the order is the same as the CHANNEL_LAYOUT bits. I.e. LEFT must be the first channel if it exists, then RIGHT, etc. Still, this would only be mandatory for codecs (and formats) that specifies channel_layout.
There should still be a way for the demuxer to communicate the source channel order. Sure, most codecs have a defined channel order, but raw PCM does not. The demuxer should not reorder the channels, but the user-level does need to know what that order is.
This is IMHO no more strange than that PIX_FMT_YUV always have the planes in Y,U,V order. From an application perspective i find this much more convenient. There might be more work in the decoders though. Still, with float_to_int16_interleave() (that all of the "popular" multi-channel codecs currently use (AC3, DTS and AAC)) this is just a matter of swizzling a few pointers at setup time.
I don't know if there is the same complexity of ordering in video as in audio. I do see that we have different PIX_FMT's for RGB and BGR. Here are some of my thoughts on channel order. demuxing: I think it would be a lot better from an application's perspective if the demuxer specified order if it knows it. That way the app doesn't have to necessarily know what the AAC default channel order is, or whatever, and can rely on libavformat to say so if it knows. For raw PCM it is very important to know the order since the channel order depends on the container. decoding: Most audio decoders would be able to set the appropriate channel order based on information in the bitstream and/or codec defaults. PCM decoders would have to either do nothing, which would break the desired behavior, or would have to be told the source channel order so that they could reorder it if necessary. encoding: This is straightforward. The encoder would expect default FFmpeg channel order and reorder if needed. But it would probably need to set the new channel order to communicate it to the user/muxer. The PCM encoder wouldn't have to reorder or change anything. muxing: I think most of the muxers will support the default order for PCM, but not necessarily all of them. I think AIFF puts center between left and right. For other codecs, the muxer knowing what the order is for the payload would be good since some of them can (or need to) set it in the container.
For other codecs there might be more work involved. However, that day ffmpeg gets planar audio formats this is even less an issue.
It would certainly make it easier to do the reordering, but wouldn't alleviate all the issues of needing to know what the order is and when to rearrange it. -Justin
On Sun, Sep 07, 2008 at 11:25:01AM -0400, Justin Ruggles wrote:
Hi,
Andreas ?man wrote:
M?ns Rullg?rd wrote:
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
The idea is that the order is the same as the CHANNEL_LAYOUT bits. I.e. LEFT must be the first channel if it exists, then RIGHT, etc. Still, this would only be mandatory for codecs (and formats) that specifies channel_layout.
There should still be a way for the demuxer to communicate the source channel order. Sure, most codecs have a defined channel order, but raw PCM does not. The demuxer should not reorder the channels, but the user-level does need to know what that order is.
Agree. One way to accomodate this would be to provide a channel reordering matrix, that is set by the demuxer. The PCM codecs, and potentially others, would use this to apply the correct order. The matrix could also be used by user applications to handle layout-variation between FFmpeg and the output device (OSS/ALSA/SDL/Win32).
This is IMHO no more strange than that PIX_FMT_YUV always have the planes in Y,U,V order. From an application perspective i find this much more convenient. There might be more work in the decoders though. Still, with float_to_int16_interleave() (that all of the "popular" multi-channel codecs currently use (AC3, DTS and AAC)) this is just a matter of swizzling a few pointers at setup time.
I don't know if there is the same complexity of ordering in video as in audio. I do see that we have different PIX_FMT's for RGB and BGR.
IMHO it is the same concept, but implemented with less permutations. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
M?ns Rullg?rd wrote:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec. [...] I think your solution works well for now. I am not 100% clear about how
Peter Ross wrote: the encoders/decoders should handle unsupported or undefined layouts. Firstly, is the channel layout is guessed by default? If so, that would At this stage, the guess function is used only for display purposes. [...]
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +} Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
Well, if it's only used for displaying the layout name, why not use generic names if the layout is unspecified, like "3-channel" and "5-channel"? -Justin
M?ns Rullg?rd wrote:
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
4.0 and 5.0 are very common in audio only surround productions, so take a look on you DVD-As and SACD and you'll find these formats. As I already wrote elsewhere in this thread, there are even more formats (bringing in additional stereo signals, if surround already present) in the broadcast world. Just my 0.02? Axel
2008/9/7 M?ns Rullg?rd <mans at mansr.com>:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec. [...]
I think your solution works well for now. I am not 100% clear about how the encoders/decoders should handle unsupported or undefined layouts. Firstly, is the channel layout is guessed by default? If so, that would
At this stage, the guess function is used only for display purposes.
eliminate it matching for some codecs. Also, if the layout is unspecified (and not guessed) I'm assuming an encoder or decoder can decide whether to accept or reject it? If it can accept it, then I suppose it would be up to the encoder/decoder to make its own guess?
If the decoder doesnt know the layout, then it should set layout to 0 (i.e. "no statement").
Each encoder will publish a list of supported input layouts, and libavcodec will provide transformation functions to convert(remix) between different layouts. All encoders will be capable of accepting a layout of 0.
For the ffmpeg program, I think it should revert to undefined if rejected once, then if the codec doesn't support undefined layout return an error.
Yes, that's doable. Eventually lavc will provide a layout transformation (down/upmixing) function. My vision to have FFmpeg negociate the layout in much the sample way it currently negociates different pixel and audio formats.
Don't forget that the channel layout must specify not only which components are present, but also their order. Currently lavc tells you neither, making it practically useless for multi-channel audio.
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
I agree with M?ns on this one. 2.1 and 4.1 would be better choices in my opinion. Rob
2008/9/8 Robert Swain <robert.swain at gmail.com>:
2008/9/7 M?ns Rullg?rd <mans at mansr.com>:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote:
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
I agree with M?ns on this one. 2.1 and 4.1 would be better choices in my opinion.
Actually, now I'm not so sure. I was thinking in terms of end user speaker configurations rather than channel layouts in codecs. Justin's point about just giving them generic names based on the numbers of channels (as this is all they are...) would make more sense as there is the ambiguity of 4.1 versus 5.0 for example. Rob
On 8 sep 2008, at 10:13, Robert Swain wrote:
2008/9/8 Robert Swain <robert.swain at gmail.com>:
2008/9/7 M?ns Rullg?rd <mans at mansr.com>:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote:
+int64_t avcodec_guess_channel_layout(int nb_channels) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 4: return CHANNEL_LAYOUT_QUAD; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +}
Why not add 3 and 5 to the list? My vote would be for left/ right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
I agree with M?ns on this one. 2.1 and 4.1 would be better choices in my opinion.
Actually, now I'm not so sure. I was thinking in terms of end user speaker configurations rather than channel layouts in codecs. Justin's point about just giving them generic names based on the numbers of channels (as this is all they are...) would make more sense as there is the ambiguity of 4.1 versus 5.0 for example.
Why not use names as defined by one of the standards ? I advise people to look into the CoreAudioTypes.h header on OSX. They have a very good separation between channellabels and channellayouts. They also support MPEG, ITU, DVD layout-tagnames (as well as AudioUnit names). CoreAudio can handle almost any channelordering concept and in my opinion is one of the better examples when implementing things like this. DJ
Derk-Jan Hartman wrote:
On 8 sep 2008, at 10:13, Robert Swain wrote:
2008/9/7 M?ns Rullg?rd <mans at mansr.com>:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Peter Ross wrote: > +int64_t avcodec_guess_channel_layout(int nb_channels) > +{ > + switch(nb_channels) { > + case 1: return CHANNEL_LAYOUT_MONO; > + case 2: return CHANNEL_LAYOUT_STEREO; > + case 4: return CHANNEL_LAYOUT_QUAD; > + case 6: return CHANNEL_LAYOUT_5POINT1; > + case 8: return CHANNEL_LAYOUT_7POINT1; > + default: return 0; > + } > +} Why not add 3 and 5 to the list? My vote would be for left/ right/center and 5.0. 2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2. I agree with M?ns on this one. 2.1 and 4.1 would be better choices in my opinion. Actually, now I'm not so sure. I was thinking in terms of end user speaker configurations rather than channel layouts in codecs. Justin's
2008/9/8 Robert Swain <robert.swain at gmail.com>: point about just giving them generic names based on the numbers of channels (as this is all they are...) would make more sense as there is the ambiguity of 4.1 versus 5.0 for example.
Why not use names as defined by one of the standards ? I advise people to look into the CoreAudioTypes.h header on OSX. They have a very good separation between channellabels and channellayouts. They also support MPEG, ITU, DVD layout-tagnames (as well as AudioUnit names).
CoreAudio can handle almost any channelordering concept and in my opinion is one of the better examples when implementing things like this.
The CAFF specification also has the same info. There are some good things about it, and some that are not. The speaker definitions and channel layouts are completely separate from eachother, with different methods of defining a predefined vs. arbitrary layout. They define an enum value for about every layout/order combination imaginable... and a separate enum for every speaker/channel name imaginable. I like Peter's solution better because we can still add channels, then combine them however we want. Something will need to be devised to indicate channel order, but I think having it separate from they layout which just tells which channels are present is more flexible. Possibly some kind of solution which allows for defining a layout/order combination would be good. That way the actual channel information could be inspected automatically to see what kind of reordering/mixing/etc.. would be required for conversion instead of having to track compatibilities between layouts by their names alone. -Justin
"Robert Swain" <robert.swain at gmail.com> writes:
2008/9/7 M?ns Rullg?rd <mans at mansr.com>:
Peter Ross <pross at xvid.org> writes:
On Fri, Aug 29, 2008 at 10:21:28PM -0400, Justin Ruggles wrote:
Why not add 3 and 5 to the list? My vote would be for left/right/center and 5.0.
2.1 and 4.1 are equally, if not more, likely. I have such DVDs, but none with x.0 where x > 2.
I agree with M?ns on this one. 2.1 and 4.1 would be better choices in my opinion.
What does 4.1 mean though? It could be either 2F2R+LFE or 3F1R+LFE. -- M?ns Rullg?rd mans at mansr.com
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
Patch updated.
--- libavcodec/audioconvert.c (revision 15246) +++ libavcodec/audioconvert.c (working copy) @@ -71,6 +71,99 @@
+static const char* channel_names[]={ + "front-centre", + "front-left-of-centre", + "front-right-of-centre", + "back-centre", + "top-centre", + "top-front-centre", + "top-back-centre",
Please use American English spelling.
--- libavcodec/avcodec.h (revision 15246) +++ libavcodec/avcodec.h (working copy) @@ -355,6 +355,51 @@
+/* Audio channel masks */ +#define CHANNEL_FRONT_CENTER 0x00000004 +#define CHANNEL_FRONT_LEFT_OF_CENTER 0x00000040 +#define CHANNEL_FRONT_RIGHT_OF_CENTER 0x00000080 +#define CHANNEL_BACK_CENTER 0x00000100 +#define CHANNEL_TOP_CENTER 0x00000800 +#define CHANNEL_TOP_FRONT_CENTER 0x00002000 +#define CHANNEL_TOP_BACK_CENTER 0x00010000
You already use American English spelling here... Diego
Diego Biurrun <diego at biurrun.de> writes:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
Patch updated.
--- libavcodec/audioconvert.c (revision 15246) +++ libavcodec/audioconvert.c (working copy) @@ -71,6 +71,99 @@
+static const char* channel_names[]={ + "front-centre", + "front-left-of-centre", + "front-right-of-centre", + "back-centre", + "top-centre", + "top-front-centre", + "top-back-centre",
Please use American English spelling.
--- libavcodec/avcodec.h (revision 15246) +++ libavcodec/avcodec.h (working copy) @@ -355,6 +355,51 @@
+/* Audio channel masks */ +#define CHANNEL_FRONT_CENTER 0x00000004 +#define CHANNEL_FRONT_LEFT_OF_CENTER 0x00000040 +#define CHANNEL_FRONT_RIGHT_OF_CENTER 0x00000080 +#define CHANNEL_BACK_CENTER 0x00000100 +#define CHANNEL_TOP_CENTER 0x00000800 +#define CHANNEL_TOP_FRONT_CENTER 0x00002000 +#define CHANNEL_TOP_BACK_CENTER 0x00010000
You already use American English spelling here...
There is no such thing as American English. There is American, which is quite distinct from English. If you don't believe me, try speaking English to an American, and observe the confused look on his face. -- M?ns Rullg?rd mans at mansr.com
On Sun, Sep 07, 2008 at 02:19:32PM +0100, M?ns Rullg?rd wrote:
There is no such thing as American English. There is American, which is quite distinct from English. If you don't believe me, try speaking English to an American, and observe the confused look on his face.
I don't know, I had the impression Mike and Mark understood you just fine at LinuxTag, well, most of the time at least :-P
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated. [...] +static const struct { + int nb_channels; + int64_t layout; + const char *string;
id place the small fields together to reduce the chance of wasted space from padding
+} channel_layout_map[] = { + { 1, CHANNEL_LAYOUT_MONO , "mono" }, + { 2, CHANNEL_LAYOUT_STEREO , "stereo" }, + { 3, CHANNEL_LAYOUT_SURROUND , "surround" }, + { 4, CHANNEL_LAYOUT_QUAD , "quad" }, + { 5, CHANNEL_LAYOUT_5POINT0 , "5.0" }, + { 6, CHANNEL_LAYOUT_5POINT1 , "5.1" }, + { 8, CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, "5.1+downmix" }, + { 8, CHANNEL_LAYOUT_7POINT1 , "7.1" }, + { 8, CHANNEL_LAYOUT_7POINT1_WIDE , "7.1(wide)" }, + { 10, CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, "7.1+downmix" }, + { 0 } +}; + +void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout) +{ + int i; + + if (channel_layout==0) + channel_layout = avcodec_guess_channel_layout(nb_channels); + + for (i=0; channel_layout_map[i].nb_channels; i++) + if (nb_channels == channel_layout_map[i].nb_channels && + channel_layout == channel_layout_map[i].layout) { + snprintf(buf, buf_size, channel_layout_map[i].string); + return; + } + + snprintf(buf, buf_size, "%d channels", nb_channels); + if (channel_layout) { + int i,ch; + snprintf(buf + strlen(buf), buf_size - strlen(buf), "("); + for(i=0,ch=0; i<64 && ch<nb_channels; i++) { + if ((channel_layout & (1<<i))) { + const char *name = get_channel_name(i); + if (name) + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ch==0 ? "%s" : "|%s", name); + ch--; + } + } + snprintf(buf + strlen(buf), buf_size - strlen(buf), ")"); + } +}
av_strlcat(f) may be usefull to simplify some of the snprintf() calls [...]
@@ -2260,6 +2305,13 @@ * - decoding: set by libavcodec. */ int bits_per_raw_sample; + + /** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by user (if container describes layout) and/or set by libavcodec.
maybe there should be a request_channel_layout field and request_channels could be deprecated (and removed with the next major version bump). [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
-- Peter
Ping, Michael what do you think about this ? I really want to get started with supporting proper multichannel handling in FFmpeg. A native ordering would simplify alot of things. MvH Benjamin Larsson
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated. [...] +/** + * Guess the channel layout + */ +int64_t avcodec_guess_channel_layout(int nb_channels);
This should also take a codec_id and or container id/name/whatever [...]
+/* Audio channel convenience macros */ +#define CHANNEL_LAYOUT_MONO (CHANNEL_FRONT_CENTER) +#define CHANNEL_LAYOUT_STEREO (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT) +#define CHANNEL_LAYOUT_SURROUND (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER) +#define CHANNEL_LAYOUT_QUAD (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT) +#define CHANNEL_LAYOUT_5POINT0 (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|\ + CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT) +#define CHANNEL_LAYOUT_5POINT1 (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT) +#define CHANNEL_LAYOUT_7POINT1 (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|\ + CHANNEL_SIDE_LEFT|CHANNEL_SIDE_RIGHT) +#define CHANNEL_LAYOUT_7POINT1_WIDE (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT|\ + CHANNEL_FRONT_LEFT_OF_CENTER|CHANNEL_FRONT_RIGHT_OF_CENTER) +#define CHANNEL_LAYOUT_STEREO_DOWNMIX (CHANNEL_STEREO_LEFT|CHANNEL_STEREO_RIGHT)
each of these could use the previous ones to simplify its define [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.) -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[...]
+ snprintf(buf + strlen(buf), buf_size - strlen(buf), ", ");
av_strlcat()
+ avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); if (enc->sample_fmt != SAMPLE_FMT_NONE) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt)); Index: libavcodec/audioconvert.c =================================================================== --- libavcodec/audioconvert.c (revision 15697) +++ libavcodec/audioconvert.c (working copy) @@ -27,6 +27,7 @@
#include "avcodec.h" #include "audioconvert.h" +#include <libavutil/avstring.h>
typedef struct SampleFmtInfo { const char *name;
@@ -70,6 +71,100 @@ } }
+static const char* channel_names[]={
static const char* const channel_names[]={ [...]
+const char * get_channel_name(int channel_id) +{ + if (channel_id<0 || channel_id>=sizeof(channel_names)/sizeof(char*))
FF_ARRAY_ELEMS
+ return NULL; + return channel_names[channel_id]; +} + +int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name) +{ + switch(nb_channels) { + case 1: return CHANNEL_LAYOUT_MONO; + case 2: return CHANNEL_LAYOUT_STEREO; + case 3: return CHANNEL_LAYOUT_SURROUND; + case 4: return CHANNEL_LAYOUT_QUAD; + case 5: return CHANNEL_LAYOUT_5POINT0; + case 6: return CHANNEL_LAYOUT_5POINT1; + case 8: return CHANNEL_LAYOUT_7POINT1; + default: return 0; + } +} + +static const struct {
+ const char *name; + int nb_channels; + int64_t layout;
was this supposed to be vertically aligned? if so it seems not anymore
+} channel_layout_map[] = { + { "mono", 1, CHANNEL_LAYOUT_MONO }, + { "stereo", 2, CHANNEL_LAYOUT_STEREO }, + { "surround", 3, CHANNEL_LAYOUT_SURROUND }, + { "quad", 4, CHANNEL_LAYOUT_QUAD }, + { "5.0", 5, CHANNEL_LAYOUT_5POINT0 }, + { "5.1", 6, CHANNEL_LAYOUT_5POINT1 }, + { "5.1+downmix", 8, CHANNEL_LAYOUT_5POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, }, + { "7.1", 8, CHANNEL_LAYOUT_7POINT1 }, + { "7.1(wide)", 8, CHANNEL_LAYOUT_7POINT1_WIDE }, + { "7.1+downmix", 10, CHANNEL_LAYOUT_7POINT1|CHANNEL_LAYOUT_STEREO_DOWNMIX, }, + { 0 } +};
this also seems half vertically aligned [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
On Sat, Oct 25, 2008 at 11:32:46AM +0200, Michael Niedermayer wrote:
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
Patch updated.
[...]
+ snprintf(buf + strlen(buf), buf_size - strlen(buf), ", ");
av_strlcat()
Okay. Note that libavcodec/utils.c could be further optimised with av_strlcat/strlcatf. I'll think about doing that later. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Sun, Oct 26, 2008 at 12:06:52PM +1100, Peter Ross wrote:
On Sat, Oct 25, 2008 at 11:32:46AM +0200, Michael Niedermayer wrote:
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote: > Hi. > > This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
Patch updated.
[...]
+ snprintf(buf + strlen(buf), buf_size - strlen(buf), ", ");
av_strlcat()
Okay.
Note that libavcodec/utils.c could be further optimised with av_strlcat/strlcatf. I'll think about doing that later.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Index: libavcodec/utils.c =================================================================== --- libavcodec/utils.c (revision 15697) +++ libavcodec/utils.c (working copy) @@ -741,6 +741,7 @@ {"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"}, {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX}, {NULL}, +{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, A|E|D, "channel_layout"}, };
#undef A
is it intended to be after the NULL? and FF_OPT_TYPE_FLAGS means int not int64 and request_channel_layout is missing [...]
Index: libavcodec/audioconvert.c =================================================================== --- libavcodec/audioconvert.c (revision 15697) +++ libavcodec/audioconvert.c (working copy) @@ -27,6 +27,7 @@
#include "avcodec.h" #include "audioconvert.h" +#include <libavutil/avstring.h>
typedef struct SampleFmtInfo { const char *name; @@ -70,6 +71,100 @@ } }
+static const char* const channel_names[]={ + "front-left", + "front-right", + "front-center", + "low-frequency", + "back-left", + "back-right", + "front-left-of-center", + "front-right-of-center", + "back-center", + "side-left", + "side-right", + "top-center", + "top-front-left", + "top-front-center", + "top-front-right", + "top-back-left", + "top-back-center", + "top-back-right", + [29] = "stereo-left", + [30] = "stereo-right", +};
i think these become too long when ore than a single channel is printed as they are in this patch. [...]
+ snprintf(buf, buf_size, "%d channels", nb_channels); + if (channel_layout) { + int i,ch; + av_strlcat(buf, "(", buf_size); + for(i=0,ch=0; i<64 && ch<nb_channels; i++) { + if ((channel_layout & (1<<i))) { + const char *name = get_channel_name(i); + if (name) { + if (ch>0) av_strlcat(buf, "|", buf_size); + av_strlcat(buf, name, buf_size); + } + ch++; + } + }
is the ch<nb_channels check needed? and there is trailing whitespace [...]
@@ -2202,8 +2237,11 @@ * Decoder should decode to this many channels if it can (0 for default) * - encoding: unused * - decoding: Set by user. + * @deprecated Deprecated in favor of request_channel_layout. */ +#if LIBAVCODEC_VERSION_MAJOR < 53 int request_channels; +#endif
i think the if should also be over the corresponding doxy [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
On Sun, Oct 26, 2008 at 12:06:52PM +1100, Peter Ross wrote:
On Sat, Oct 25, 2008 at 11:32:46AM +0200, Michael Niedermayer wrote:
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote: > Hi. > > This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
Patch updated.
Patch updated (#7). -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Thu, Oct 30, 2008 at 11:31:53PM +1100, Peter Ross wrote:
On Sun, Oct 26, 2008 at 12:06:52PM +1100, Peter Ross wrote:
On Sat, Oct 25, 2008 at 11:32:46AM +0200, Michael Niedermayer wrote:
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote: > On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote: > > Hi. > > > > This patch adds the notion of channel layouts to libavcodec. > > Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
Patch updated.
Patch updated (#7).
iam not 100% happy about the design but as we have no other suggestions nor patches by anyone, this is definitly a big step forward from what we have now so, patch ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
On Thu, Oct 30, 2008 at 11:34:09PM +0100, Michael Niedermayer wrote:
On Thu, Oct 30, 2008 at 11:31:53PM +1100, Peter Ross wrote:
On Sun, Oct 26, 2008 at 12:06:52PM +1100, Peter Ross wrote:
On Sat, Oct 25, 2008 at 11:32:46AM +0200, Michael Niedermayer wrote:
On Sat, Oct 25, 2008 at 03:34:16PM +1100, Peter Ross wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote: > On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote: > > On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote: > > > Hi. > > > > > > This patch adds the notion of channel layouts to libavcodec. > > > > Patch updated. Thanks for the feedback. > > Patch updated.
Patch updated.
Patch updated. (See the parent post for the RIFF/WAV patch.)
Patch updated.
Patch updated (#7).
iam not 100% happy about the design but as we have no other suggestions nor patches by anyone, this is definitly a big step forward from what we have now so, patch ok
Thanks. IIRC, the RIFF demuxer patch still need approving. http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080923/1a9a9f... -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[...]
Index: libavformat/riff.c =================================================================== --- libavformat/riff.c (revision 15391) +++ libavformat/riff.c (working copy) @@ -213,6 +213,10 @@ { 0, 0 }, };
+#define RIFF_SPEAKER_5POINT1_INCORRECT (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT) + #ifdef CONFIG_MUXERS offset_t start_tag(ByteIOContext *pb, const char *tag) { @@ -373,7 +377,11 @@ cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ codec->bits_per_coded_sample = get_le16(pb); - get_le32(pb); /* dwChannelMask */ + codec->channel_layout = get_le32(pb); /* dwChannelMask */ + /* Compensate for incorrect 5.1 configurations. + See: http://msdn.microsoft.com/en-us/library/aa474707.aspx */ + if (codec->channel_layout == RIFF_SPEAKER_5POINT1_INCORRECT) + codec->channel_layout = CHANNEL_LAYOUT_5POINT1;
the text linked seems to be about MS APIs, these may be related to RIFF but then this is not clear ... Besides this would make storing 5p1 with back channels impossible [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus
On Sun, Nov 02, 2008 at 12:07:18AM +0100, Michael Niedermayer wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[...]
Index: libavformat/riff.c =================================================================== --- libavformat/riff.c (revision 15391) +++ libavformat/riff.c (working copy) @@ -213,6 +213,10 @@ { 0, 0 }, };
+#define RIFF_SPEAKER_5POINT1_INCORRECT (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT) + #ifdef CONFIG_MUXERS offset_t start_tag(ByteIOContext *pb, const char *tag) { @@ -373,7 +377,11 @@ cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ codec->bits_per_coded_sample = get_le16(pb); - get_le32(pb); /* dwChannelMask */ + codec->channel_layout = get_le32(pb); /* dwChannelMask */ + /* Compensate for incorrect 5.1 configurations. + See: http://msdn.microsoft.com/en-us/library/aa474707.aspx */ + if (codec->channel_layout == RIFF_SPEAKER_5POINT1_INCORRECT) + codec->channel_layout = CHANNEL_LAYOUT_5POINT1;
the text linked seems to be about MS APIs, these may be related to RIFF but then this is not clear ... Besides this would make storing 5p1 with back channels impossible
Fair enough. I have remvoed the MS API fixup from the patch. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Tue, Nov 04, 2008 at 05:23:12PM +1100, Peter Ross wrote:
On Sun, Nov 02, 2008 at 12:07:18AM +0100, Michael Niedermayer wrote:
On Tue, Sep 23, 2008 at 10:43:22PM +1000, Peter Ross wrote:
On Sun, Sep 07, 2008 at 08:58:28PM +1000, Peter Ross wrote:
On Sat, Aug 30, 2008 at 11:05:43AM +1000, Peter Ross wrote:
On Fri, Aug 29, 2008 at 04:28:00PM +1000, Peter Ross wrote:
Hi.
This patch adds the notion of channel layouts to libavcodec.
Patch updated. Thanks for the feedback.
Patch updated.
Patch updated.
-- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[...]
Index: libavformat/riff.c =================================================================== --- libavformat/riff.c (revision 15391) +++ libavformat/riff.c (working copy) @@ -213,6 +213,10 @@ { 0, 0 }, };
+#define RIFF_SPEAKER_5POINT1_INCORRECT (CHANNEL_FRONT_LEFT|CHANNEL_FRONT_RIGHT|\ + CHANNEL_FRONT_CENTER|CHANNEL_LOW_FREQUENCY|\ + CHANNEL_BACK_LEFT|CHANNEL_BACK_RIGHT) + #ifdef CONFIG_MUXERS offset_t start_tag(ByteIOContext *pb, const char *tag) { @@ -373,7 +377,11 @@ cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ codec->bits_per_coded_sample = get_le16(pb); - get_le32(pb); /* dwChannelMask */ + codec->channel_layout = get_le32(pb); /* dwChannelMask */ + /* Compensate for incorrect 5.1 configurations. + See: http://msdn.microsoft.com/en-us/library/aa474707.aspx */ + if (codec->channel_layout == RIFF_SPEAKER_5POINT1_INCORRECT) + codec->channel_layout = CHANNEL_LAYOUT_5POINT1;
the text linked seems to be about MS APIs, these may be related to RIFF but then this is not clear ... Besides this would make storing 5p1 with back channels impossible
Fair enough. I have remvoed the MS API fixup from the patch.
patch ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato
participants (16)
-
aholzinger@gmx.de -
andreas@lonelycoder.com -
aurel@gnuage.org -
banan@ludd.ltu.se -
dear@madshi.net -
diego@biurrun.de -
dominik@rangers.eu.org -
hartman@videolan.org -
ian.caulfield@gmail.com -
justin.ruggles@gmail.com -
mans@mansr.com -
michaelni@gmx.at -
pross@xvid.org -
Reimar.Doeffinger@stud.uni-karlsruhe.de -
robert.swain@gmail.com -
rsbultje@gmail.com