[flac-dev] Define 6.1 and 7.1 channel mappings

Tim W. tdskywalker at gmail.com
Tue Jan 1 16:36:50 PST 2013


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


More information about the flac-dev mailing list