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
45 AV_CHANNEL_LAYOUT_BINAURAL,45 AV_CHANNEL_LAYOUT_BINAURAL,
46};46};
47 47
48const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13] = {48const 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
107const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14] = {
49 { SOUND_SYSTEM_A_0_2_0, AV_CHANNEL_LAYOUT_STEREO },108 { SOUND_SYSTEM_A_0_2_0, AV_CHANNEL_LAYOUT_STEREO },
50 { SOUND_SYSTEM_B_0_5_0, AV_CHANNEL_LAYOUT_5POINT1_BACK },109 { SOUND_SYSTEM_B_0_5_0, AV_CHANNEL_LAYOUT_5POINT1_BACK },
51 { SOUND_SYSTEM_C_2_5_0, AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK },110 { 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
65 { SOUND_SYSTEM_10_2_7_0, AV_CHANNEL_LAYOUT_7POINT1POINT2 },124 { SOUND_SYSTEM_10_2_7_0, AV_CHANNEL_LAYOUT_7POINT1POINT2 },
66 { SOUND_SYSTEM_11_2_3_0, AV_CHANNEL_LAYOUT_3POINT1POINT2 },125 { SOUND_SYSTEM_11_2_3_0, AV_CHANNEL_LAYOUT_3POINT1POINT2 },
67 { SOUND_SYSTEM_12_0_1_0, AV_CHANNEL_LAYOUT_MONO },126 { SOUND_SYSTEM_12_0_1_0, AV_CHANNEL_LAYOUT_MONO },
127 { SOUND_SYSTEM_13_9_1_6, AV_CHANNEL_LAYOUT_9POINT1POINT6 },
68};128};
69 129
70void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)130void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
libavformat/iamf.h+3−1
@@ -156,6 +156,7 @@ enum IAMF_Sound_System { · 155 unmodified lines
156 SOUND_SYSTEM_10_2_7_0 = 10, // "Loudspeaker configuration for Sound System I" + Ltf + Rtf156 SOUND_SYSTEM_10_2_7_0 = 10, // "Loudspeaker configuration for Sound System I" + Ltf + Rtf
157 SOUND_SYSTEM_11_2_3_0 = 11, // Front subset of "Loudspeaker configuration for Sound System J"157 SOUND_SYSTEM_11_2_3_0 = 11, // Front subset of "Loudspeaker configuration for Sound System J"
158 SOUND_SYSTEM_12_0_1_0 = 12, // Mono158 SOUND_SYSTEM_12_0_1_0 = 12, // Mono
159 SOUND_SYSTEM_13_9_1_6 = 13, // Subset of "Loudspeaker configuration for Sound System H"
159};160};
160 161
161struct IAMFSoundSystemMap {162struct IAMFSoundSystemMap {
@@ -165,7 +166,8 @@ struct IAMFSoundSystemMap { · 3 unmodified lines
165 166
166FF_VISIBILITY_PUSH_HIDDEN167FF_VISIBILITY_PUSH_HIDDEN
167extern const AVChannelLayout ff_iamf_scalable_ch_layouts[10];168extern const AVChannelLayout ff_iamf_scalable_ch_layouts[10];
168extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13];169extern const AVChannelLayout ff_iamf_expanded_scalable_ch_layouts[13];
170extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14];
169 171
170static inline IAMFCodecConfig *ff_iamf_get_codec_config(const IAMFContext *c,172static inline IAMFCodecConfig *ff_iamf_get_codec_config(const IAMFContext *c,
171 unsigned int codec_config_id)173 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
356 AVIAMFLayer *layer;356 AVIAMFLayer *layer;
357 int loudspeaker_layout, output_gain_is_present_flag;357 int loudspeaker_layout, output_gain_is_present_flag;
358 int substream_count, coupled_substream_count;358 int substream_count, coupled_substream_count;
359 int expanded_loudspeaker_layout = -1;
359 int ret, byte = avio_r8(pb);360 int ret, byte = avio_r8(pb);
360 361
361 layer = av_iamf_audio_element_add_layer(audio_element->element);362 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
379 layer->output_gain = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);380 layer->output_gain = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);
380 }381 }
381 382
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)
383 av_channel_layout_copy(&layer->ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]);388 av_channel_layout_copy(&layer->ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
384 else389 else
385 layer->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC,390 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