I apologize for the terribly long message, but here goes. ------------------------------------------------------------------------------------------------- First, regarding existing tools that I now about. libavcodec and users (e.g. HandBrake): - if there are 6 channels or less, the layout is set by the decoder as per the FLAC specification - if there are more than 6 channels, the layout is not set by the decoder, and instead the default libavcodec channel layout guess is used -> 7 channels, 6.1 (front left, right, center, lfe, back center, side left, right) -> 8 channels, 7.1 (front left, right, center, lfe, back left, right, side left, right) - the FLAC decoder and encoder do not reorder channels, so the internal libavcodec order is used -> it matches the WAVEFORMATEXTENSIBLE order for all common channels (see above for 6.1 and 7.1) ------------------------------------------------------------------------------------------------- Then, regarding what the WAVEFORMATEXTENSIBLE order actually is: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757714(v=vs.85).aspx "The dwChannelMask member specifies which channels are present in the multichannel stream. The least significant bit corresponds with the front left speaker, the next least significant bit corresponds to the front right speaker, and so on. The bits, in order of significance, are defined as follows." [?] "The channels specified in dwChannelMask must be present in the prescribed order (from least significant bit up). For example, if only SPEAKER_FRONT_LEFT and SPEAKER_FRONT_RIGHT are specified, then the samples for the front left speaker must come first in the interleaved stream. The number of bits set indwChannelMask should be the same as the number of channels specified in WAVEFORMATEX.nChannels." Which gives us the following order: FL FR FC LFE BL BR FLC FRC BC SL SR TC TFL TFC TFR TBL TBC TBR It happens to be compatible with all currently defined FLAC channel assignments: - 1 channel: mono (FC) - 2 channels: left, right (FL FR) - 3 channels: left, right, center (FL FR FC) - 4 channels: left, right, back left, back right (FL FR BL BR) - 5 channels: left, right, center, back/surround left, back/surround right (FL FR FC BL BR or FL FR FC SL SR, same order so doesn't matter) - 6 channels: left, right, center, LFE, back/surround left, back/surround right (FL FR FC LFE BL BR or FL FR FC LFE SL SR, same order so doesn't matter) ------------------------------------------------------------------------------------------------- My take on this: FLAC should use the WAVEFORMATEXTENSIBLE order. Reasons: - "Where defined, the channel order follows SMPTE/ITU-R recommendations." -> all defined assignments are compatible with WAVEFORMATEXTENSIBLE (see above) - the official FLAC encoder uses a Vorbis comment to store the channel mask, as per WAVEFORMATEXTENSIBLE ("WAVEFORMATEXTENSIBLE_CHANNEL_MASK") - it is my understanding that the official FLAC encoder and decoder already use the "Microsoft order", though being unfamiliar with it, I have no idea what this really means ------------------------------------------------------------------------------------------------- One of the main issues, IMO: the different sets of channel labels in use for "surround" channels. First, there are the WAVEX channel labels: - back left (BL) - back right (BR) - back center (BC) - side left (SL) - side right (SR) And then, the ones typically used by commercial 6.1/7.1 capable codecs: - left surround (Ls) - right surround (Rs) - center surround (Cs) - rear surround left (Rls) - rear surround right (Rrs) ------------------------------------------------------------------------------------------------- Finally, the "main feature". The typical 6.1/7.1 configurations (as found on e.g. Blu-ray discs) feature the following channels: 6.1 -> front: left center right, surround: left center right, LFE 7.1 -> front: left center right, surround: left right, rear surround: left right, LFE ?not necessarily in that order. Now, depending on how we map between the two sets of channel labels described above, the WAVEFORMATEXTENSIBLE channel mask (and therefore channel order) differs! 1) the mapping used by e.g. libavcodec Ls == SL Rs == SR Cs == BC Rls == BL Rrs == BR - 6.1: FL FR FC LFE BC SL SR (L R C LFE Cs Ls Rs) - 7.1: FL FR FC LFE BL BR SL SR (L R C LFE Rls Rrs Ls Rs) 2) the mapping used by e.g. Apple (QuickTime, Core Audio) Ls == BL Rs == BR Cs == BC Rls == ?? // considered to be undefined in WAVEFORMATEXTENSIBLE Rrs == ?? // considered to be undefined in WAVEFORMATEXTENSIBLE - 6.1: FL FR FC LFE BL BR BC (L R C LFE Ls Rs Cs) - 7.1: FL FR FC LFE BL BR ?? ?? (L R C LFE Ls Rs Rls Rrs) or FL FR FC LFE ?? ?? BL BR (L R C LFE Rls Rrs Ls Rs) ?in the 7.1 case, we kind of have a problem. 3) a "hybrid" mapping 6.1: Ls == BL, Rs == BR, Cs == BC 7.1: Ls == SL, Rs == SR, Rls == BL, Rrs == BR - 6.1: FL FR FC LFE BL BR BC (L R C LFE Ls Rs Cs) - 7.1: FL FR FC LFE BL BR SL SR (L R C LFE Rls Rrs Ls Rs) ?which works for both 6.1 and 7.1, but is somewhat inconsistent. 4) no mapping - order is defined without regard for WAVEFORMATEXTENSIBLE channel labels or order ?we end up with channel configurations for which WAVEFORMATEXTENSIBLE_CHANNEL_MASK is (potentially) undefined. I'm personally in favor of mapping (1) as it doesn't vary between 6.1/7.1, and is fully compatible with the WAVEFORMATEXTENSIBLE specification. Tim Walker
Tim W. wrote:> I'm personally in favor of mapping (1) as it doesn't vary between 6.1/7.1, > and is fully compatible with the WAVEFORMATEXTENSIBLE specification.I'm in favour of Tims proposal and intent to apply Ralph's patch to implement this unless someone comes up with a really good reason not to. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Tim's proposal seems reasonable but it conflicts with the FLAC documentation that says the channel ordering follows SMPTE/ITU-R recommendations. I think we may be butting up against an area where the standards aren't clear. ITU-R BS.2159-4 (http://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BS.2159-4-2012-PDF-E.pdf) doesn't define a 7.1 layout but simply diagrams several possibilities on page 27. DTS-HD seems to specify 7 different possible 7.1 layouts (http://www.scribd.com/doc/17630423/21/Channel-Layout). I think my preference for the Apple/Core Audio layouts is known but obviously any standard would be better than none. Do I understand correctly that WAVE_FORMAT_EXTENSIBLE simply defines a standard channel order and FLAC would specify compatible channel masks? http://msdn.microsoft.com/en-us/library/windows/hardware/gg463006.aspx hasn't been updated since 2007 so I may have been looking at an old document. Stephen On Wednesday, January 2, 2013 at 6:54 AM, Erik de Castro Lopo wrote:> Tim W. wrote: > > > I'm personally in favor of mapping (1) as it doesn't vary between 6.1/7.1, > > and is fully compatible with the WAVEFORMATEXTENSIBLE specification. > > > > > I'm in favour of Tims proposal and intent to apply Ralph's patch > to implement this unless someone comes up with a really good reason > not to. > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > _______________________________________________ > flac-dev mailing list > flac-dev at xiph.org (mailto:flac-dev at xiph.org) > http://lists.xiph.org/mailman/listinfo/flac-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20130102/da63c39d/attachment.htm
On 13-01-01 4:36 PM, Tim W. wrote:> - 4 channels: left, right, back left, back right (FL FR BL BR) > - 5 channels: left, right, center, back/surround left, back/surround right > (FL FR FC BL BR or FL FR FC SL SR, same order so doesn't matter) > - 6 channels: left, right, center, LFE, back/surround left, back/surround right > (FL FR FC LFE BL BR or FL FR FC LFE SL SR, same order so doesn't matter)I looked at the 'flac' command-line front-end code today, and it uses Back Left and Back Right for 4 channel but Side Left and Side Right for 5 and 6 channel files when writing out WAVE from FLAC files without a WAVFORMATEXTENSIBLE_CHANNEL_MASK metadata tag. As you say, the order is the same, and for less that 7 channels the physical speaker configurations are equivalent. The encoder accepts both Side and Back in the input channel mask, but passes them on in the tag, of course. If the input is AIFF the support is more limited, rejecting any multichannel file unless the undocumented --channel-map=none is passed, followed by some dead code saying only 1, 2, 3, and 5 channels can be unambiguously mapped.> - 6.1: FL FR FC LFE BC SL SR (L R C LFE Cs Ls Rs) > - 7.1: FL FR FC LFE BL BR SL SR (L R C LFE Rls Rrs Ls Rs)Again, I'm suggesting we update the spec to define these as the default channel maps for 7 and 8 channel FLAC files in the absence of the overriding WAVFORMATEXTENSIBLE_CHANNEL_MASK metadata tag, and modify the included 'flac' front-end to write out those masks when decoding such files. Likewise, we would modify 'flac' to accept files with those channel masks as input when encoding. Untested patch attached. -r -------------- next part --------------
I vote for documenting the --channel-map option in the --help I don't like the idea of rejecting a multichannel file merely for mapping, so there should be a documented option plus an error message pointing to the option. This should compare to the WAVE and AIFF errors where the utility suggests to the user how to get the file converted safely. Brian Willoughby Sound Consulting On Jan 17, 2013, at 17:34, Ralph Giles wrote:> On 13-01-01 4:36 PM, Tim W. wrote: >> - 4 channels: left, right, back left, back right (FL FR BL BR) >> - 5 channels: left, right, center, back/surround left, back/ >> surround right >> (FL FR FC BL BR or FL FR FC SL SR, same order so >> doesn't matter) >> - 6 channels: left, right, center, LFE, back/surround left, back/ >> surround right >> (FL FR FC LFE BL BR or FL FR FC LFE SL SR, same >> order so doesn't matter) > > I looked at the 'flac' command-line front-end code today, and it uses > Back Left and Back Right for 4 channel but Side Left and Side Right > for > 5 and 6 channel files when writing out WAVE from FLAC files without a > WAVFORMATEXTENSIBLE_CHANNEL_MASK metadata tag. > > As you say, the order is the same, and for less that 7 channels the > physical speaker configurations are equivalent. > > The encoder accepts both Side and Back in the input channel mask, but > passes them on in the tag, of course. If the input is AIFF the support > is more limited, rejecting any multichannel file unless the > undocumented > --channel-map=none is passed, followed by some dead code saying > only 1, > 2, 3, and 5 channels can be unambiguously mapped. > >> - 6.1: FL FR FC LFE BC SL SR (L R C LFE Cs Ls Rs) >> - 7.1: FL FR FC LFE BL BR SL SR (L R C LFE Rls Rrs Ls Rs) > > Again, I'm suggesting we update the spec to define these as the > default > channel maps for 7 and 8 channel FLAC files in the absence of the > overriding WAVFORMATEXTENSIBLE_CHANNEL_MASK metadata tag, and > modify the > included 'flac' front-end to write out those masks when decoding such > files. Likewise, we would modify 'flac' to accept files with those > channel masks as input when encoding. > > Untested patch attached.