FFmpeg
Loading...
Searching...
No Matches
iamf.c
Go to the documentation of this file.
1/*
2 * Immersive Audio Model and Formats common helpers and structs
3 * Copyright (c) 2023 James Almer <jamrial@gmail.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
23#include "libavutil/iamf.h"
24#include "libavutil/mem.h"
25#include "iamf.h"
26
30 // "Loudspeaker configuration for Sound System B"
32 // "Loudspeaker configuration for Sound System C"
34 // "Loudspeaker configuration for Sound System D"
36 // "Loudspeaker configuration for Sound System I"
38 // "Loudspeaker configuration for Sound System I" + Ltf + Rtf
40 // "Loudspeaker configuration for Sound System J"
42 // Front subset of "Loudspeaker configuration for Sound System J"
44 // Binaural
46};
47
49 // The low-frequency effects subset (LFE) of "Loudspeaker configuration for Sound System J"
50 {
51 .nb_channels = 1,
53 .u.mask = AV_CH_LOW_FREQUENCY,
54 },
55 // The surround subset (Ls/Rs) of "Loudspeaker configuration for Sound System I"
56 {
57 .nb_channels = 2,
60 },
61 // The side surround subset (Lss/Rss) of "Loudspeaker configuration for Sound System J"
62 {
63 .nb_channels = 2,
66 },
67 // The rear surround subset (Lrs/Rrs) of "Loudspeaker configuration for Sound System J"
68 {
69 .nb_channels = 2,
72 },
73 // The top front subset (Ltf/Rtf) of "Loudspeaker configuration for Sound System J"
74 {
75 .nb_channels = 2,
78 },
79 // The top back subset (Ltb/Rtb) of "Loudspeaker configuration for Sound System J"
80 {
81 .nb_channels = 2,
84 },
85 // The top 4 channels (Ltf/Rtf/Ltb/Rtb) of "Loudspeaker configuration for Sound System J"
86 {
87 .nb_channels = 4,
91 },
92 // The front 3 channels (L/C/R) of "Loudspeaker configuration for Sound System J"
94 // Subset of "Loudspeaker configuration for Sound System H"
96 // Front subset of "Loudspeaker configuration for Sound System H"
98 // The side subset (SiL/SiR) of "Loudspeaker configuration for Sound System H"
99 {
100 .nb_channels = 2,
103 },
104 // The top side subset (TpSiL/TpSiR) of "Loudspeaker configuration for Sound System H"
105 {
106 .nb_channels = 2,
109 },
110 // The top 6 channels (TpFL/TpFR/TpSiL/TpSiR/TpBL/TpBR) of "Loudspeaker configuration for Sound System H"
111 {
112 .nb_channels = 6,
117 },
118};
119
142
144{
145 IAMFAudioElement *audio_element = *paudio_element;
146
147 if (!audio_element)
148 return;
149
150 for (int i = 0; i < audio_element->nb_substreams; i++)
152 av_free(audio_element->substreams);
153 av_free(audio_element->layers);
154 av_iamf_audio_element_free(&audio_element->element);
155 av_freep(paudio_element);
156}
157
159{
160 IAMFMixPresentation *mix_presentation = *pmix_presentation;
161
162 if (!mix_presentation)
163 return;
164
165 for (int i = 0; i < mix_presentation->count_label; i++)
166 av_free(mix_presentation->language_label[i]);
167 av_free(mix_presentation->language_label);
168 av_iamf_mix_presentation_free(&mix_presentation->mix);
169 av_freep(pmix_presentation);
170}
171
173{
174 if (!c)
175 return;
176
177 for (int i = 0; i < c->nb_codec_configs; i++) {
178 av_free(c->codec_configs[i]->extradata);
179 av_free(c->codec_configs[i]);
180 }
181 av_freep(&c->codec_configs);
182 c->nb_codec_configs = 0;
183
184 for (int i = 0; i < c->nb_audio_elements; i++)
185 ff_iamf_free_audio_element(&c->audio_elements[i]);
186 av_freep(&c->audio_elements);
187 c->nb_audio_elements = 0;
188
189 for (int i = 0; i < c->nb_mix_presentations; i++)
190 ff_iamf_free_mix_presentation(&c->mix_presentations[i]);
191 av_freep(&c->mix_presentations);
192 c->nb_mix_presentations = 0;
193
194 for (int i = 0; i < c->nb_param_definitions; i++)
195 av_free(c->param_definitions[i]);
196 av_freep(&c->param_definitions);
197 c->nb_param_definitions = 0;
198}
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
Public libavutil channel layout APIs header.
void avcodec_parameters_free(AVCodecParameters **ppar)
Definition codec_par.c:67
#define AV_CH_LAYOUT_5POINT1POINT4_BACK
#define AV_CH_SIDE_LEFT
#define AV_CH_TOP_FRONT_LEFT
#define AV_CH_BOTTOM_FRONT_CENTER
#define AV_CH_BACK_RIGHT
#define AV_CH_TOP_SIDE_RIGHT
#define AV_CH_TOP_BACK_RIGHT
#define AV_CH_SIDE_RIGHT
#define AV_CH_BACK_LEFT
#define AV_CH_TOP_SIDE_LEFT
#define AV_CH_TOP_BACK_LEFT
#define AV_CH_LOW_FREQUENCY
#define AV_CH_TOP_FRONT_RIGHT
#define AV_CHANNEL_LAYOUT_7POINT2POINT3
#define AV_CHANNEL_LAYOUT_5POINT1POINT2
#define AV_CHANNEL_LAYOUT_BINAURAL
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_7POINT1POINT2
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_5POINT1
#define AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_SURROUND
#define AV_CHANNEL_LAYOUT_22POINT2
#define AV_CHANNEL_LAYOUT_7POINT1
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_9POINT1POINT6
#define AV_CHANNEL_LAYOUT_3POINT1POINT2
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
void av_iamf_audio_element_free(AVIAMFAudioElement **paudio_element)
Free an AVIAMFAudioElement and all its contents.
Definition iamf.c:338
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **pmix_presentation)
Free an AVIAMFMixPresentation and all its contents.
Definition iamf.c:536
void ff_iamf_uninit_context(IAMFContext *c)
Definition iamf.c:172
void ff_iamf_free_mix_presentation(IAMFMixPresentation **pmix_presentation)
Definition iamf.c:158
void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
Definition iamf.c:143
const AVChannelLayout ff_iamf_expanded_scalable_ch_layouts[13]
Definition iamf.c:48
const AVChannelLayout ff_iamf_scalable_ch_layouts[10]
Definition iamf.c:27
const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14]
Definition iamf.c:120
@ SOUND_SYSTEM_E_4_5_1
Definition iamf.h:150
@ SOUND_SYSTEM_10_2_7_0
Definition iamf.h:156
@ SOUND_SYSTEM_H_9_10_3
Definition iamf.h:153
@ SOUND_SYSTEM_11_2_3_0
Definition iamf.h:157
@ SOUND_SYSTEM_F_3_7_0
Definition iamf.h:151
@ SOUND_SYSTEM_I_0_7_0
Definition iamf.h:154
@ SOUND_SYSTEM_A_0_2_0
Definition iamf.h:146
@ SOUND_SYSTEM_12_0_1_0
Definition iamf.h:158
@ SOUND_SYSTEM_J_4_7_0
Definition iamf.h:155
@ SOUND_SYSTEM_G_4_9_0
Definition iamf.h:152
@ SOUND_SYSTEM_D_4_5_0
Definition iamf.h:149
@ SOUND_SYSTEM_13_9_1_6
Definition iamf.h:159
@ SOUND_SYSTEM_B_0_5_0
Definition iamf.h:147
@ SOUND_SYSTEM_C_2_5_0
Definition iamf.h:148
Immersive Audio Model and Formats API header.
Memory handling functions.
An AVChannelLayout holds information about the channel layout of audio data.
IAMFLayer * layers
Definition iamf.h:103
AVIAMFAudioElement * element
element backs celement iff the AVIAMFAudioElement is owned by this structure.
Definition iamf.h:95
unsigned int nb_substreams
Definition iamf.h:99
IAMFSubStream * substreams
Definition iamf.h:98
AVIAMFMixPresentation * mix
mix backs cmix iff the AVIAMFMixPresentation is owned by this structure.
Definition iamf.h:113
unsigned int count_label
Definition iamf.h:117
char ** language_label
Definition iamf.h:118
AVCodecParameters * codecpar
Definition iamf.h:86
#define av_free(p)
#define av_freep(p)
static double c[64]