FFmpeg
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 
54  {
55  .nb_channels = 11,
56  .order = AV_CHANNEL_ORDER_NATIVE,
58  },
59  },
68 };
69 
71 {
72  IAMFAudioElement *audio_element = *paudio_element;
73 
74  if (!audio_element)
75  return;
76 
77  for (int i = 0; i < audio_element->nb_substreams; i++)
78  avcodec_parameters_free(&audio_element->substreams[i].codecpar);
79  av_free(audio_element->substreams);
80  av_free(audio_element->layers);
81  av_iamf_audio_element_free(&audio_element->element);
82  av_freep(paudio_element);
83 }
84 
86 {
87  IAMFMixPresentation *mix_presentation = *pmix_presentation;
88 
89  if (!mix_presentation)
90  return;
91 
92  for (int i = 0; i < mix_presentation->count_label; i++)
93  av_free(mix_presentation->language_label[i]);
94  av_free(mix_presentation->language_label);
95  av_iamf_mix_presentation_free(&mix_presentation->mix);
96  av_freep(pmix_presentation);
97 }
98 
100 {
101  if (!c)
102  return;
103 
104  for (int i = 0; i < c->nb_codec_configs; i++) {
105  av_free(c->codec_configs[i]->extradata);
106  av_free(c->codec_configs[i]);
107  }
108  av_freep(&c->codec_configs);
109  c->nb_codec_configs = 0;
110 
111  for (int i = 0; i < c->nb_audio_elements; i++)
112  ff_iamf_free_audio_element(&c->audio_elements[i]);
113  av_freep(&c->audio_elements);
114  c->nb_audio_elements = 0;
115 
116  for (int i = 0; i < c->nb_mix_presentations; i++)
117  ff_iamf_free_mix_presentation(&c->mix_presentations[i]);
118  av_freep(&c->mix_presentations);
119  c->nb_mix_presentations = 0;
120 
121  for (int i = 0; i < c->nb_param_definitions; i++)
122  av_free(c->param_definitions[i]);
123  av_freep(&c->param_definitions);
124  c->nb_param_definitions = 0;
125 }
iamf.h
ff_iamf_free_mix_presentation
void ff_iamf_free_mix_presentation(IAMFMixPresentation **pmix_presentation)
Definition: iamf.c:85
SOUND_SYSTEM_E_4_5_1
@ SOUND_SYSTEM_E_4_5_1
Definition: iamf.h:150
AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK
Definition: channel_layout.h:409
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:379
IAMFAudioElement::nb_substreams
unsigned int nb_substreams
Definition: iamf.h:99
SOUND_SYSTEM_12_0_1_0
@ SOUND_SYSTEM_12_0_1_0
Definition: iamf.h:158
ff_iamf_sound_system_map
const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13]
Definition: iamf.c:48
av_iamf_mix_presentation_free
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **pmix_presentation)
Free an AVIAMFMixPresentation and all its contents.
Definition: iamf.c:534
AV_CHANNEL_LAYOUT_7POINT2POINT3
#define AV_CHANNEL_LAYOUT_7POINT2POINT3
Definition: channel_layout.h:410
SOUND_SYSTEM_J_4_7_0
@ SOUND_SYSTEM_J_4_7_0
Definition: iamf.h:155
SOUND_SYSTEM_10_2_7_0
@ SOUND_SYSTEM_10_2_7_0
Definition: iamf.h:156
AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK
Definition: channel_layout.h:411
AV_CHANNEL_LAYOUT_7POINT1POINT2
#define AV_CHANNEL_LAYOUT_7POINT1POINT2
Definition: channel_layout.h:408
av_iamf_audio_element_free
void av_iamf_audio_element_free(AVIAMFAudioElement **paudio_element)
Free an AVIAMFAudioElement and all its contents.
Definition: iamf.c:336
AV_CH_LAYOUT_5POINT1POINT4_BACK
#define AV_CH_LAYOUT_5POINT1POINT4_BACK
Definition: channel_layout.h:233
IAMFAudioElement::element
AVIAMFAudioElement * element
element backs celement iff the AVIAMFAudioElement is owned by this structure.
Definition: iamf.h:95
AV_CHANNEL_LAYOUT_7POINT1
#define AV_CHANNEL_LAYOUT_7POINT1
Definition: channel_layout.h:401
SOUND_SYSTEM_H_9_10_3
@ SOUND_SYSTEM_H_9_10_3
Definition: iamf.h:153
SOUND_SYSTEM_A_0_2_0
@ SOUND_SYSTEM_A_0_2_0
Definition: iamf.h:146
avcodec_parameters_free
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
Definition: codec_par.c:66
AV_CHANNEL_LAYOUT_3POINT1POINT2
#define AV_CHANNEL_LAYOUT_3POINT1POINT2
Definition: channel_layout.h:394
IAMFAudioElement::layers
IAMFLayer * layers
Definition: iamf.h:103
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AV_CHANNEL_LAYOUT_22POINT2
#define AV_CHANNEL_LAYOUT_22POINT2
Definition: channel_layout.h:414
AV_CH_BOTTOM_FRONT_CENTER
#define AV_CH_BOTTOM_FRONT_CENTER
Definition: channel_layout.h:195
SOUND_SYSTEM_11_2_3_0
@ SOUND_SYSTEM_11_2_3_0
Definition: iamf.h:157
IAMFAudioElement
Definition: iamf.h:89
AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK
#define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK
Definition: channel_layout.h:404
SOUND_SYSTEM_D_4_5_0
@ SOUND_SYSTEM_D_4_5_0
Definition: iamf.h:149
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:303
ff_iamf_uninit_context
void ff_iamf_uninit_context(IAMFContext *c)
Definition: iamf.c:99
IAMFContext
Definition: iamf.h:128
IAMFAudioElement::substreams
IAMFSubStream * substreams
Definition: iamf.h:98
AV_CHANNEL_ORDER_NATIVE
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
Definition: channel_layout.h:118
IAMFSoundSystemMap
Definition: iamf.h:161
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK
#define AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK
Definition: channel_layout.h:407
SOUND_SYSTEM_C_2_5_0
@ SOUND_SYSTEM_C_2_5_0
Definition: iamf.h:148
IAMFMixPresentation::count_label
unsigned int count_label
Definition: iamf.h:117
ff_iamf_free_audio_element
void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
Definition: iamf.c:70
SOUND_SYSTEM_F_3_7_0
@ SOUND_SYSTEM_F_3_7_0
Definition: iamf.h:151
IAMFMixPresentation
Definition: iamf.h:107
channel_layout.h
IAMFMixPresentation::language_label
char ** language_label
Definition: iamf.h:118
SOUND_SYSTEM_G_4_9_0
@ SOUND_SYSTEM_G_4_9_0
Definition: iamf.h:152
mem.h
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:378
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
SOUND_SYSTEM_B_0_5_0
@ SOUND_SYSTEM_B_0_5_0
Definition: iamf.h:147
iamf.h
ff_iamf_scalable_ch_layouts
const AVChannelLayout ff_iamf_scalable_ch_layouts[10]
Definition: iamf.c:27
AV_CHANNEL_LAYOUT_5POINT1_BACK
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
Definition: channel_layout.h:391
IAMFMixPresentation::mix
AVIAMFMixPresentation * mix
mix backs cmix iff the AVIAMFMixPresentation is owned by this structure.
Definition: iamf.h:113
IAMFSubStream::codecpar
AVCodecParameters * codecpar
Definition: iamf.h:86
SOUND_SYSTEM_I_0_7_0
@ SOUND_SYSTEM_I_0_7_0
Definition: iamf.h:154