The way streams are coded in an IAMF struct follows a scalable model where the
channel layouts for each layer may not match the channel order our API can
represent in a Native order layout.

For example, an audio element may have six coded streams in the form of two
stereo streams, followed by two mono streams, and then by another two stereo
streams, for a total of 10 channels, and define for them four scalable layers
with loudspeaker_layout values "Stereo", "5.1ch", "5.1.2ch", and "5.1.4ch".
The first layer references the first stream, and each following layer will
reference all previous streams plus extra ones.
In this case, the "5.1ch" layer will reference four streams (the first two
stereo and the two mono) to encompass six channels, which does not match out
native layout 5.1(side) given that FC and LFE come after FL+FR but before
SL+SR, and here, they are at the end.

For this reason, we need to build Custom order layouts that properly represent
what we're exporting.

----
Before:

  Stream group #0:0[0x12c]: IAMF Audio Element:
    Layer 0: stereo
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
    Layer 1: 5.1(side)
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
    Layer 2: 5.1.2
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:4[0x4]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
    Layer 3: 5.1.4
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:4[0x4]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:5[0x5]: Audio: opus, 48000 Hz, stereo, fltp (dependent)

----
AFter:

  Stream group #0:0[0x12c]: IAMF Audio Element:
    Layer 0: stereo
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
    Layer 1: 6 channels (FL+FR+SL+SR+FC+LFE)
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
    Layer 2: 8 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR)
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:4[0x4]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
    Layer 3: 10 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR+TBL+TBR)
      Stream #0:0[0x0]: Audio: opus, 48000 Hz, stereo, fltp (default)
      Stream #0:1[0x1]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:2[0x2]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:3[0x3]: Audio: opus, 48000 Hz, mono, fltp (dependent)
      Stream #0:4[0x4]: Audio: opus, 48000 Hz, stereo, fltp (dependent)
      Stream #0:5[0x5]: Audio: opus, 48000 Hz, stereo, fltp (dependent)

Signed-off-by: James Almer <jamr...@gmail.com>
---
 libavformat/iamf_parse.c                      | 77 +++++++++++++++++--
 libavformat/iamf_writer.c                     | 28 +++++--
 libavformat/iamfdec.c                         | 19 -----
 tests/ref/fate/iamf-5_1-copy                  |  2 +-
 tests/ref/fate/iamf-5_1-demux                 |  2 +-
 tests/ref/fate/iamf-5_1_4                     |  6 +-
 tests/ref/fate/iamf-7_1_4                     | 54 ++++++-------
 tests/ref/fate/iamf-9_1_6                     |  2 +-
 tests/ref/fate/mov-mp4-iamf-5_1_4             |  6 +-
 tests/ref/fate/mov-mp4-iamf-7_1_4-video-first |  6 +-
 tests/ref/fate/mov-mp4-iamf-7_1_4-video-last  |  6 +-
 11 files changed, 135 insertions(+), 73 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index f37edf5156..7c239ae946 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -357,7 +357,8 @@ static int scalable_channel_layout_config(void *s, 
AVIOContext *pb,
         return AVERROR(ENOMEM);
 
     audio_element->nb_layers = nb_layers;
-    for (int i = 0; i < nb_layers; i++) {
+    for (int i = 0, n = 0; i < nb_layers; i++) {
+        AVChannelLayout ch_layout = { 0 };
         AVIAMFLayer *layer;
         int loudspeaker_layout, output_gain_is_present_flag;
         int substream_count, coupled_substream_count;
@@ -387,12 +388,16 @@ static int scalable_channel_layout_config(void *s, 
AVIOContext *pb,
 
         if (!i && loudspeaker_layout == 15)
             expanded_loudspeaker_layout = avio_r8(pb);
-        if (expanded_loudspeaker_layout > 0 && expanded_loudspeaker_layout < 
13)
-            av_channel_layout_copy(&layer->ch_layout, 
&ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]);
-        else if (loudspeaker_layout < 10)
-            av_channel_layout_copy(&layer->ch_layout, 
&ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
-        else
-            layer->ch_layout = (AVChannelLayout){ .order = 
AV_CHANNEL_ORDER_UNSPEC,
+        if (expanded_loudspeaker_layout > 0 && expanded_loudspeaker_layout < 
13) {
+            av_channel_layout_copy(&ch_layout, 
&ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]);
+            if (i)
+                ch_layout.u.mask &= 
~av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, 
UINT64_MAX);
+        } else if (loudspeaker_layout < 10) {
+            av_channel_layout_copy(&ch_layout, 
&ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
+            if (i)
+                ch_layout.u.mask &= 
~av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, 
UINT64_MAX);
+        } else
+            ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC,
                                                           .nb_channels = 
substream_count +
                                                                          
coupled_substream_count };
 
@@ -407,6 +412,64 @@ static int scalable_channel_layout_config(void *s, 
AVIOContext *pb,
                 return ret;
         }
 
+        if (ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
+            ret = av_channel_layout_custom_init(&layer->ch_layout, 
ch_layout.nb_channels);
+            if (ret < 0)
+                return ret;
+
+            for (int j = 0; j < n; j++)
+                layer->ch_layout.u.map[j].id = 
av_channel_layout_channel_from_index(&audio_element->element->layers[i-1]->ch_layout,
 j);
+
+            coupled_substream_count = 
audio_element->layers[i].coupled_substream_count;
+            while (coupled_substream_count--) {
+                if (ch_layout.u.mask & AV_CH_LAYOUT_STEREO) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_FRONT_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_FRONT_RIGHT;
+                    ch_layout.u.mask &= ~AV_CH_LAYOUT_STEREO;
+                } else if (ch_layout.u.mask & 
(AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)) {
+                    layer->ch_layout.u.map[n++].id = 
AV_CHAN_FRONT_LEFT_OF_CENTER;
+                    layer->ch_layout.u.map[n++].id = 
AV_CHAN_FRONT_RIGHT_OF_CENTER;
+                    ch_layout.u.mask &= 
~(AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER);
+                } else if (ch_layout.u.mask & 
(AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_SIDE_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_SIDE_RIGHT;
+                    ch_layout.u.mask &= ~(AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT);
+                } else if (ch_layout.u.mask & 
(AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_BACK_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_BACK_RIGHT;
+                    ch_layout.u.mask &= ~(AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT);
+                } else if (ch_layout.u.mask & 
(AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_FRONT_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_FRONT_RIGHT;
+                    ch_layout.u.mask &= 
~(AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT);
+                } else if (ch_layout.u.mask & 
(AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT)) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_SIDE_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_SIDE_RIGHT;
+                    ch_layout.u.mask &= 
~(AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT);
+                } else if (ch_layout.u.mask & 
(AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_BACK_LEFT;
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_TOP_BACK_RIGHT;
+                    ch_layout.u.mask &= 
~(AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT);
+                }
+            }
+
+            substream_count -= 
audio_element->layers[i].coupled_substream_count;
+            while (substream_count--) {
+                if (ch_layout.u.mask & AV_CH_FRONT_CENTER) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_FRONT_CENTER;
+                    ch_layout.u.mask &= ~AV_CH_FRONT_CENTER;
+                }
+                if (ch_layout.u.mask & AV_CH_LOW_FREQUENCY) {
+                    layer->ch_layout.u.map[n++].id = AV_CHAN_LOW_FREQUENCY;
+                    ch_layout.u.mask &= ~AV_CH_LOW_FREQUENCY;
+                }
+            }
+
+            ret = av_channel_layout_retype(&layer->ch_layout, 
AV_CHANNEL_ORDER_NATIVE, 0);
+            if (ret < 0 && ret != AVERROR(ENOSYS))
+                return ret;
+        } else // AV_CHANNEL_ORDER_UNSPEC
+            av_channel_layout_copy(&layer->ch_layout, &ch_layout);
     }
 
     return 0;
diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index e34afb9a2c..86d09c3308 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -250,14 +250,18 @@ int ff_iamf_add_audio_element(IAMFContext *iamf, const 
AVStreamGroup *stg, void
 
         for (int j, i = 0; i < iamf_audio_element->nb_layers; i++) {
             const AVIAMFLayer *layer = iamf_audio_element->layers[i];
+
             for (j = 0; j < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); j++)
-                if (!av_channel_layout_compare(&layer->ch_layout, 
&ff_iamf_scalable_ch_layouts[j]))
+                if (av_channel_layout_subset(&layer->ch_layout, UINT64_MAX) ==
+                    av_channel_layout_subset(&ff_iamf_scalable_ch_layouts[j], 
UINT64_MAX))
                     break;
 
             if (j >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) {
                 for (j = 0; j < 
FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts); j++)
-                    if (!av_channel_layout_compare(&layer->ch_layout, 
&ff_iamf_expanded_scalable_ch_layouts[j]))
+                    if (av_channel_layout_subset(&layer->ch_layout, 
UINT64_MAX) ==
+                        
av_channel_layout_subset(&ff_iamf_expanded_scalable_ch_layouts[j], UINT64_MAX))
                         break;
+
                 if (j >= FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts)) 
{
                     av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
                     av_channel_layout_describe_bprint(&layer->ch_layout, &bp);
@@ -592,12 +596,26 @@ static int scalable_channel_layout_config(const 
IAMFAudioElement *audio_element,
             if (!av_channel_layout_compare(&layer->ch_layout, 
&ff_iamf_scalable_ch_layouts[layout]))
                 break;
         }
-        if (layout >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts))
-            for (expanded_layout = 0; expanded_layout < 
FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); expanded_layout++) {
+        if (layout >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) {
+            for (layout = 0; layout < 
FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts); layout++)
+                if (av_channel_layout_subset(&layer->ch_layout, UINT64_MAX) ==
+                    
av_channel_layout_subset(&ff_iamf_scalable_ch_layouts[layout], UINT64_MAX))
+                    break;
+        }
+        if (layout >= FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts)) {
+            for (expanded_layout = 0; expanded_layout < 
FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts); expanded_layout++) {
                 if (!av_channel_layout_compare(&layer->ch_layout, 
&ff_iamf_expanded_scalable_ch_layouts[expanded_layout]))
                     break;
             }
-        av_assert0(expanded_layout > 0 || layout < 
FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts));
+            if (expanded_layout >= 
FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts)) {
+                for (expanded_layout = 0; expanded_layout < 
FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts); expanded_layout++)
+                    if (av_channel_layout_subset(&layer->ch_layout, 
UINT64_MAX) ==
+                        
av_channel_layout_subset(&ff_iamf_expanded_scalable_ch_layouts[expanded_layout],
 UINT64_MAX))
+                        break;
+            }
+        }
+        av_assert0((expanded_layout > 0 && expanded_layout < 
FF_ARRAY_ELEMS(ff_iamf_expanded_scalable_ch_layouts)) ||
+                   layout < FF_ARRAY_ELEMS(ff_iamf_scalable_ch_layouts));
         init_put_bits(&pb, header, sizeof(header));
         put_bits(&pb, 4, expanded_layout >= 0 ? 15 : layout);
         put_bits(&pb, 1, !!layer->output_gain_flags);
diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c
index 3a6276dcde..e7b5bef907 100644
--- a/libavformat/iamfdec.c
+++ b/libavformat/iamfdec.c
@@ -81,10 +81,8 @@ static int iamf_read_header(AVFormatContext *s)
 
     for (int i = 0; i < iamf->nb_audio_elements; i++) {
         IAMFAudioElement *audio_element = iamf->audio_elements[i];
-        const AVIAMFLayer *layer = 
audio_element->element->layers[audio_element->nb_layers - 1];
         AVStreamGroup *stg = avformat_stream_group_create(s, 
AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT, NULL);
         int coupled_substream_count = 
audio_element->layers[audio_element->nb_layers - 1].coupled_substream_count;
-        int side_substream_id = -1, back_substream_id = -1;
 
         if (!stg)
             return AVERROR(ENOMEM);
@@ -114,28 +112,11 @@ static int iamf_read_header(AVFormatContext *s)
                 st->disposition |= AV_DISPOSITION_DEFAULT;
             else if (audio_element->nb_layers > 1 || 
audio_element->layers[0].substream_count > 1)
                 st->disposition |= AV_DISPOSITION_DEPENDENT;
-            if (k == av_channel_layout_index_from_channel(&layer->ch_layout, 
AV_CHAN_BACK_LEFT))
-                back_substream_id = j;
-            else if (k == 
av_channel_layout_index_from_channel(&layer->ch_layout, AV_CHAN_SIDE_LEFT))
-                side_substream_id = j;
             st->id = substream->audio_substream_id;
             avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
             k += 1 + (coupled_substream_count-- > 0);
         }
-
-        // Swap back and side stream ids as our native channel layout ordering 
doen't match the
-        // order from ITU-R - BS.2051-3 for Systems I and J (where side 
channels come before back ones).
-        if (back_substream_id >= 0 && side_substream_id >= 0 && 
av_channel_layout_compare(&layer->ch_layout,
-                                                                
&(AVChannelLayout)AV_CHANNEL_LAYOUT_9POINT1POINT6)) {
-            const IAMFSubStream *back_substream = 
&audio_element->substreams[back_substream_id];
-            const IAMFSubStream *side_substream = 
&audio_element->substreams[side_substream_id];
-            AVStream *back_st = stg->streams[back_substream_id];
-            AVStream *side_st = stg->streams[side_substream_id];
-
-            back_st->id = side_substream->audio_substream_id;
-            side_st->id = back_substream->audio_substream_id;
-        }
     }
 
     for (int i = 0; i < iamf->nb_mix_presentations; i++) {
diff --git a/tests/ref/fate/iamf-5_1-copy b/tests/ref/fate/iamf-5_1-copy
index 5f7d9f98c0..fe912d4ee7 100644
--- a/tests/ref/fate/iamf-5_1-copy
+++ b/tests/ref/fate/iamf-5_1-copy
@@ -37,7 +37,7 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1(side)
+channel_layout=6 channels (FL+FR+SL+SR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/iamf-5_1-demux b/tests/ref/fate/iamf-5_1-demux
index 5f7d9f98c0..fe912d4ee7 100644
--- a/tests/ref/fate/iamf-5_1-demux
+++ b/tests/ref/fate/iamf-5_1-demux
@@ -37,7 +37,7 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1(side)
+channel_layout=6 channels (FL+FR+SL+SR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/iamf-5_1_4 b/tests/ref/fate/iamf-5_1_4
index 1d4c055906..4c765dc8e1 100644
--- a/tests/ref/fate/iamf-5_1_4
+++ b/tests/ref/fate/iamf-5_1_4
@@ -111,17 +111,17 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1(side)
+channel_layout=6 channels (FL+FR+SL+SR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1.2
+channel_layout=8 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1.4
+channel_layout=10 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR+TBL+TBR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/iamf-7_1_4 b/tests/ref/fate/iamf-7_1_4
index 72b10f771a..4259e40135 100644
--- a/tests/ref/fate/iamf-7_1_4
+++ b/tests/ref/fate/iamf-7_1_4
@@ -45,72 +45,72 @@
 0,          0,          0,     4608,     1399, 0x6e89566e
 1,          0,          0,     4608,     1399, 0x6e89566e
 2,          0,          0,     4608,     1396, 0x0dcb5677
-3,          0,          0,     4608,     1399, 0x6e89566e
+3,          0,          0,     4608,     1396, 0x0dcb5677
 4,          0,          0,     4608,     1399, 0x6e89566e
-5,          0,          0,     4608,     1396, 0x0dcb5677
+5,          0,          0,     4608,     1399, 0x6e89566e
 6,          0,          0,     4608,     1399, 0x6e89566e
 0,       4608,       4608,     4608,     1442, 0x6c3c5b13
 1,       4608,       4608,     4608,     1442, 0x6c3c5b13
 2,       4608,       4608,     4608,     1439, 0xc46b5ac5
-3,       4608,       4608,     4608,     1442, 0x6c3c5b13
+3,       4608,       4608,     4608,     1439, 0xc46b5ac5
 4,       4608,       4608,     4608,     1442, 0x6c3c5b13
-5,       4608,       4608,     4608,     1439, 0xc46b5ac5
+5,       4608,       4608,     4608,     1442, 0x6c3c5b13
 6,       4608,       4608,     4608,     1442, 0x6c3c5b13
 0,       9216,       9216,     4608,     1380, 0xc497571b
 1,       9216,       9216,     4608,     1380, 0xc497571b
 2,       9216,       9216,     4608,     1377, 0x5b2a55fe
-3,       9216,       9216,     4608,     1380, 0xc497571b
+3,       9216,       9216,     4608,     1377, 0x5b2a55fe
 4,       9216,       9216,     4608,     1380, 0xc497571b
-5,       9216,       9216,     4608,     1377, 0x5b2a55fe
+5,       9216,       9216,     4608,     1380, 0xc497571b
 6,       9216,       9216,     4608,     1380, 0xc497571b
 0,      13824,      13824,     4608,     1383, 0x48e9510f
 1,      13824,      13824,     4608,     1383, 0x48e9510f
 2,      13824,      13824,     4608,     1380, 0x045550d3
-3,      13824,      13824,     4608,     1383, 0x48e9510f
+3,      13824,      13824,     4608,     1380, 0x045550d3
 4,      13824,      13824,     4608,     1383, 0x48e9510f
-5,      13824,      13824,     4608,     1380, 0x045550d3
+5,      13824,      13824,     4608,     1383, 0x48e9510f
 6,      13824,      13824,     4608,     1383, 0x48e9510f
 0,      18432,      18432,     4608,     1572, 0x9a514719
 1,      18432,      18432,     4608,     1572, 0x9a514719
 2,      18432,      18432,     4608,     1568, 0xa2bc45f4
-3,      18432,      18432,     4608,     1572, 0x9a514719
+3,      18432,      18432,     4608,     1568, 0xa2bc45f4
 4,      18432,      18432,     4608,     1572, 0x9a514719
-5,      18432,      18432,     4608,     1568, 0xa2bc45f4
+5,      18432,      18432,     4608,     1572, 0x9a514719
 6,      18432,      18432,     4608,     1572, 0x9a514719
 0,      23040,      23040,     4608,     1391, 0x74ac5014
 1,      23040,      23040,     4608,     1391, 0x74ac5014
 2,      23040,      23040,     4608,     1388, 0x96c85007
-3,      23040,      23040,     4608,     1391, 0x74ac5014
+3,      23040,      23040,     4608,     1388, 0x96c85007
 4,      23040,      23040,     4608,     1391, 0x74ac5014
-5,      23040,      23040,     4608,     1388, 0x96c85007
+5,      23040,      23040,     4608,     1391, 0x74ac5014
 6,      23040,      23040,     4608,     1391, 0x74ac5014
 0,      27648,      27648,     4608,     1422, 0x2f9d47c5
 1,      27648,      27648,     4608,     1422, 0x2f9d47c5
 2,      27648,      27648,     4608,     1419, 0x4d4d466a
-3,      27648,      27648,     4608,     1422, 0x2f9d47c5
+3,      27648,      27648,     4608,     1419, 0x4d4d466a
 4,      27648,      27648,     4608,     1422, 0x2f9d47c5
-5,      27648,      27648,     4608,     1419, 0x4d4d466a
+5,      27648,      27648,     4608,     1422, 0x2f9d47c5
 6,      27648,      27648,     4608,     1422, 0x2f9d47c5
 0,      32256,      32256,     4608,     1768, 0x2a044b99
 1,      32256,      32256,     4608,     1768, 0x2a044b99
 2,      32256,      32256,     4608,     1765, 0xacb84b24
-3,      32256,      32256,     4608,     1768, 0x2a044b99
+3,      32256,      32256,     4608,     1765, 0xacb84b24
 4,      32256,      32256,     4608,     1768, 0x2a044b99
-5,      32256,      32256,     4608,     1765, 0xacb84b24
+5,      32256,      32256,     4608,     1768, 0x2a044b99
 6,      32256,      32256,     4608,     1768, 0x2a044b99
 0,      36864,      36864,     4608,     1534, 0xb0b35a3f
 1,      36864,      36864,     4608,     1534, 0xb0b35a3f
 2,      36864,      36864,     4608,     1531, 0x996458aa
-3,      36864,      36864,     4608,     1534, 0xb0b35a3f
+3,      36864,      36864,     4608,     1531, 0x996458aa
 4,      36864,      36864,     4608,     1534, 0xb0b35a3f
-5,      36864,      36864,     4608,     1531, 0x996458aa
+5,      36864,      36864,     4608,     1534, 0xb0b35a3f
 6,      36864,      36864,     4608,     1534, 0xb0b35a3f
 0,      41472,      41472,     4608,      926, 0xc26a5eae
 1,      41472,      41472,     4608,      926, 0xc26a5eae
 2,      41472,      41472,     4608,      923, 0xa7225edf
-3,      41472,      41472,     4608,      926, 0xc26a5eae
+3,      41472,      41472,     4608,      923, 0xa7225edf
 4,      41472,      41472,     4608,      926, 0xc26a5eae
-5,      41472,      41472,     4608,      923, 0xa7225edf
+5,      41472,      41472,     4608,      926, 0xc26a5eae
 6,      41472,      41472,     4608,      926, 0xc26a5eae
 [STREAM_GROUP]
 index=0
@@ -127,17 +127,17 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=3.1.2
+channel_layout=6 channels (FL+FR+TFL+TFR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.2
+channel_layout=10 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.4
+channel_layout=12 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR+TBL+TBR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
@@ -226,7 +226,7 @@ DISPOSITION:multilayer=0
 [/STREAM]
 [STREAM]
 index=3
-id=0x5
+id=0x3
 DISPOSITION:default=0
 DISPOSITION:dub=0
 DISPOSITION:original=0
@@ -272,7 +272,7 @@ DISPOSITION:multilayer=0
 [/STREAM]
 [STREAM]
 index=5
-id=0x3
+id=0x5
 DISPOSITION:default=0
 DISPOSITION:dub=0
 DISPOSITION:original=0
@@ -462,7 +462,7 @@ DISPOSITION:multilayer=0
 [/STREAM]
 [STREAM]
 index=3
-id=0x5
+id=0x3
 DISPOSITION:default=0
 DISPOSITION:dub=0
 DISPOSITION:original=0
@@ -508,7 +508,7 @@ DISPOSITION:multilayer=0
 [/STREAM]
 [STREAM]
 index=5
-id=0x3
+id=0x5
 DISPOSITION:default=0
 DISPOSITION:dub=0
 DISPOSITION:original=0
diff --git a/tests/ref/fate/iamf-9_1_6 b/tests/ref/fate/iamf-9_1_6
index 0c55a22774..4082d35729 100644
--- a/tests/ref/fate/iamf-9_1_6
+++ b/tests/ref/fate/iamf-9_1_6
@@ -170,7 +170,7 @@ nb_layers=1
 audio_element_type=0
 default_w=0
 [SUBCOMPONENT]
-channel_layout=9.1.6
+channel_layout=16 channels 
(FL+FR+FLC+FRC+SL+SR+BL+BR+TFL+TFR+TSL+TSR+TBL+TBR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/mov-mp4-iamf-5_1_4 
b/tests/ref/fate/mov-mp4-iamf-5_1_4
index 225bbba267..18a1f5337f 100644
--- a/tests/ref/fate/mov-mp4-iamf-5_1_4
+++ b/tests/ref/fate/mov-mp4-iamf-5_1_4
@@ -111,17 +111,17 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1(side)
+channel_layout=6 channels (FL+FR+SL+SR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1.2
+channel_layout=8 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=5.1.4
+channel_layout=10 channels (FL+FR+SL+SR+FC+LFE+TFL+TFR+TBL+TBR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/mov-mp4-iamf-7_1_4-video-first 
b/tests/ref/fate/mov-mp4-iamf-7_1_4-video-first
index d3b37896b2..d5a1fe1cad 100644
--- a/tests/ref/fate/mov-mp4-iamf-7_1_4-video-first
+++ b/tests/ref/fate/mov-mp4-iamf-7_1_4-video-first
@@ -158,17 +158,17 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=3.1.2
+channel_layout=6 channels (FL+FR+TFL+TFR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.2
+channel_layout=10 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.4
+channel_layout=12 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR+TBL+TBR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
diff --git a/tests/ref/fate/mov-mp4-iamf-7_1_4-video-last 
b/tests/ref/fate/mov-mp4-iamf-7_1_4-video-last
index ede4a40025..caf89d41f6 100644
--- a/tests/ref/fate/mov-mp4-iamf-7_1_4-video-last
+++ b/tests/ref/fate/mov-mp4-iamf-7_1_4-video-last
@@ -158,17 +158,17 @@ output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=3.1.2
+channel_layout=6 channels (FL+FR+TFL+TFR+FC+LFE)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.2
+channel_layout=10 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
 [SUBCOMPONENT]
-channel_layout=7.1.4
+channel_layout=12 channels (FL+FR+TFL+TFR+FC+LFE+SL+SR+BL+BR+TBL+TBR)
 output_gain_flags=0
 output_gain=0/1
 [/SUBCOMPONENT]
-- 
2.50.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to