History

avformat/iamf_parse: add support for expanded channel layouts

Defined in Immersive Audio Model and Formats 1.1.0, sections 3.6.2 and 3.7.3

James Almer committed 1 year ago

Commit d255f901 parent 21d3dab3 files · +70 −3Browse files

Unified · Split

3 files
  1. libavformat/iamf.c +61 −1
  2. libavformat/iamf.h +3 −1
  3. libavformat/iamf_parse.c +6 −1
libavformat/iamf.c+61−1
@@ -45,7 +45,66 @@ const AVChannelLayout ff_iamf_scalable_ch_layouts[10] = { · 44 unmodified lines
4545 AV_CHANNEL_LAYOUT_BINAURAL,
4646 };
4747
48−const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13] = {
48+const AVChannelLayout ff_iamf_expanded_scalable_ch_layouts[13] = {
49+ {
50+ .nb_channels = 1,
51+ .order = AV_CHANNEL_ORDER_NATIVE,
52+ .u.mask = AV_CH_LOW_FREQUENCY,
53+ },
54+ {
55+ .nb_channels = 2,
56+ .order = AV_CHANNEL_ORDER_NATIVE,
57+ .u.mask = AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT,
58+ },
59+ {
60+ .nb_channels = 2,
61+ .order = AV_CHANNEL_ORDER_NATIVE,
62+ .u.mask = AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT,
63+ },
64+ {
65+ .nb_channels = 2,
66+ .order = AV_CHANNEL_ORDER_NATIVE,
67+ .u.mask = AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT,
68+ },
69+ {
70+ .nb_channels = 2,
71+ .order = AV_CHANNEL_ORDER_NATIVE,
72+ .u.mask = AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_RIGHT,
73+ },
74+ {
75+ .nb_channels = 2,
76+ .order = AV_CHANNEL_ORDER_NATIVE,
77+ .u.mask = AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT,
78+ },
79+ {
80+ .nb_channels = 4,
81+ .order = AV_CHANNEL_ORDER_NATIVE,
82+ .u.mask = AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_RIGHT |
83+ AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT,
84+ },
85+ AV_CHANNEL_LAYOUT_SURROUND,
86+ AV_CHANNEL_LAYOUT_9POINT1POINT6,
87+ AV_CHANNEL_LAYOUT_STEREO,
88+ {
89+ .nb_channels = 2,
90+ .order = AV_CHANNEL_ORDER_NATIVE,
91+ .u.mask = AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT,
92+ },
93+ {
94+ .nb_channels = 2,
95+ .order = AV_CHANNEL_ORDER_NATIVE,
96+ .u.mask = AV_CH_TOP_SIDE_LEFT | AV_CH_TOP_SIDE_RIGHT,
97+ },
98+ {
99+ .nb_channels = 6,
100+ .order = AV_CHANNEL_ORDER_NATIVE,
101+ .u.mask = AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_RIGHT |
102+ AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT |
103+ AV_CH_TOP_SIDE_LEFT | AV_CH_TOP_SIDE_RIGHT,
104+ },
105+};
106+
107+const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14] = {
49108 { SOUND_SYSTEM_A_0_2_0, AV_CHANNEL_LAYOUT_STEREO },
50109 { SOUND_SYSTEM_B_0_5_0, AV_CHANNEL_LAYOUT_5POINT1_BACK },
51110 { SOUND_SYSTEM_C_2_5_0, AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK },
@@ -65,6 +124,7 @@ const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13] = { · 13 unmodified lines
65124 { SOUND_SYSTEM_10_2_7_0, AV_CHANNEL_LAYOUT_7POINT1POINT2 },
66125 { SOUND_SYSTEM_11_2_3_0, AV_CHANNEL_LAYOUT_3POINT1POINT2 },
67126 { SOUND_SYSTEM_12_0_1_0, AV_CHANNEL_LAYOUT_MONO },
127+ { SOUND_SYSTEM_13_9_1_6, AV_CHANNEL_LAYOUT_9POINT1POINT6 },
68128 };
69129
70130 void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
libavformat/iamf.h+3−1
@@ -156,6 +156,7 @@ enum IAMF_Sound_System { · 155 unmodified lines
156156 SOUND_SYSTEM_10_2_7_0 = 10, // "Loudspeaker configuration for Sound System I" + Ltf + Rtf
157157 SOUND_SYSTEM_11_2_3_0 = 11, // Front subset of "Loudspeaker configuration for Sound System J"
158158 SOUND_SYSTEM_12_0_1_0 = 12, // Mono
159+ SOUND_SYSTEM_13_9_1_6 = 13, // Subset of "Loudspeaker configuration for Sound System H"
159160 };
160161
161162 struct IAMFSoundSystemMap {
@@ -165,7 +166,8 @@ struct IAMFSoundSystemMap { · 3 unmodified lines
165166
166167 FF_VISIBILITY_PUSH_HIDDEN
167168 extern const AVChannelLayout ff_iamf_scalable_ch_layouts[10];
168−extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13];
169+extern const AVChannelLayout ff_iamf_expanded_scalable_ch_layouts[13];
170+extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14];
169171
170172 static inline IAMFCodecConfig *ff_iamf_get_codec_config(const IAMFContext *c,
171173 unsigned int codec_config_id)
libavformat/iamf_parse.c+6−1
@@ -356,6 +356,7 @@ static int scalable_channel_layout_config(void *s, AVIOContext *pb, · 355 unmodified lines
356356 AVIAMFLayer *layer;
357357 int loudspeaker_layout, output_gain_is_present_flag;
358358 int substream_count, coupled_substream_count;
359+ int expanded_loudspeaker_layout = -1;
359360 int ret, byte = avio_r8(pb);
360361
361362 layer = av_iamf_audio_element_add_layer(audio_element->element);
@@ -379,7 +380,11 @@ static int scalable_channel_layout_config(void *s, AVIOContext *pb, · 17 unmodified lines
379380 layer->output_gain = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);
380381 }
381382
382− if (loudspeaker_layout < 10)
383+ if (!i && loudspeaker_layout == 15)
384+ expanded_loudspeaker_layout = avio_r8(pb);
385+ if (expanded_loudspeaker_layout > 0 && expanded_loudspeaker_layout < 13)
386+ av_channel_layout_copy(&layer->ch_layout, &ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]);
387+ else if (loudspeaker_layout < 10)
383388 av_channel_layout_copy(&layer->ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
384389 else
385390 layer->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t