FFmpeg
Loading...
Searching...
No Matches
iamf.h
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
22#ifndef AVFORMAT_IAMF_H
23#define AVFORMAT_IAMF_H
24
25#include <stddef.h>
26#include <stdint.h>
27
30#include "libavutil/iamf.h"
31#include "libavcodec/codec_id.h"
33
34#define MAX_IAMF_OBU_HEADER_SIZE (1 + 8 * 3)
35
36// OBU types (section 3.2).
65
76
77typedef struct IAMFLayer {
78 unsigned int substream_count;
80} IAMFLayer;
81
82typedef struct IAMFSubStream {
83 unsigned int audio_substream_id;
84
85 // demux
88
89typedef struct IAMFAudioElement {
91 /**
92 * element backs celement iff the AVIAMFAudioElement
93 * is owned by this structure.
94 */
96 unsigned int audio_element_id;
97
99 unsigned int nb_substreams;
100
101 unsigned int codec_config_id;
102
104 unsigned int nb_layers;
106
107typedef struct IAMFMixPresentation {
109 /**
110 * mix backs cmix iff the AVIAMFMixPresentation
111 * is owned by this structure.
112 */
115
116 // demux
117 unsigned int count_label;
120
127
138
144
146 SOUND_SYSTEM_A_0_2_0 = 0, // "Loudspeaker configuration for Sound System A"
147 SOUND_SYSTEM_B_0_5_0 = 1, // "Loudspeaker configuration for Sound System B"
148 SOUND_SYSTEM_C_2_5_0 = 2, // "Loudspeaker configuration for Sound System C"
149 SOUND_SYSTEM_D_4_5_0 = 3, // "Loudspeaker configuration for Sound System D"
150 SOUND_SYSTEM_E_4_5_1 = 4, // "Loudspeaker configuration for Sound System E"
151 SOUND_SYSTEM_F_3_7_0 = 5, // "Loudspeaker configuration for Sound System F"
152 SOUND_SYSTEM_G_4_9_0 = 6, // "Loudspeaker configuration for Sound System G"
153 SOUND_SYSTEM_H_9_10_3 = 7, // "Loudspeaker configuration for Sound System H"
154 SOUND_SYSTEM_I_0_7_0 = 8, // "Loudspeaker configuration for Sound System I"
155 SOUND_SYSTEM_J_4_7_0 = 9, // "Loudspeaker configuration for Sound System J"
156 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"
159 SOUND_SYSTEM_13_9_1_6 = 13, // Subset of "Loudspeaker configuration for Sound System H"
160};
161
166
170extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14];
171
173 unsigned int codec_config_id)
174{
175 IAMFCodecConfig *codec_config = NULL;
176
177 for (int i = 0; i < c->nb_codec_configs; i++) {
178 if (c->codec_configs[i]->codec_config_id == codec_config_id)
179 codec_config = c->codec_configs[i];
180 }
181
182 return codec_config;
183}
184
186 unsigned int parameter_id)
187{
189
190 for (int i = 0; i < iamf->nb_param_definitions; i++)
191 if (iamf->param_definitions[i]->param->parameter_id == parameter_id) {
193 break;
194 }
195
196 return param_definition;
197}
198
199void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element);
200void ff_iamf_free_mix_presentation(IAMFMixPresentation **pmix_presentation);
203
204#endif /* AVFORMAT_IAMF_H */
#define FF_VISIBILITY_PUSH_HIDDEN
#define FF_VISIBILITY_POP_HIDDEN
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
Public libavutil channel layout APIs header.
#define NULL
Definition coverity.c:32
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
static int param_definition(const IAMFContext *iamf, const IAMFParamDefinition *param_def, AVIOContext *dyn_bc, void *log_ctx)
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
void ff_iamf_uninit_context(IAMFContext *c)
Definition iamf.c:172
static IAMFParamDefinition * ff_iamf_get_param_definition(const IAMFContext *iamf, unsigned int parameter_id)
Definition iamf.h:185
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
IAMF_Anchor_Element
Definition iamf.h:139
@ IAMF_ANCHOR_ELEMENT_UNKNWONW
Definition iamf.h:140
@ IAMF_ANCHOR_ELEMENT_DIALOGUE
Definition iamf.h:141
@ IAMF_ANCHOR_ELEMENT_ALBUM
Definition iamf.h:142
static IAMFCodecConfig * ff_iamf_get_codec_config(const IAMFContext *c, unsigned int codec_config_id)
Definition iamf.h:172
IAMF_OBU_Type
Definition iamf.h:37
@ IAMF_OBU_IA_AUDIO_FRAME
Definition iamf.h:43
@ IAMF_OBU_IA_MIX_PRESENTATION
Definition iamf.h:40
@ IAMF_OBU_IA_AUDIO_FRAME_ID13
Definition iamf.h:57
@ IAMF_OBU_IA_PARAMETER_BLOCK
Definition iamf.h:41
@ IAMF_OBU_IA_AUDIO_FRAME_ID6
Definition iamf.h:50
@ IAMF_OBU_IA_AUDIO_FRAME_ID15
Definition iamf.h:59
@ IAMF_OBU_IA_AUDIO_FRAME_ID1
Definition iamf.h:45
@ IAMF_OBU_IA_AUDIO_ELEMENT
Definition iamf.h:39
@ IAMF_OBU_IA_AUDIO_FRAME_ID14
Definition iamf.h:58
@ IAMF_OBU_IA_SEQUENCE_HEADER
Definition iamf.h:63
@ IAMF_OBU_IA_TEMPORAL_DELIMITER
Definition iamf.h:42
@ IAMF_OBU_IA_CODEC_CONFIG
Definition iamf.h:38
@ IAMF_OBU_IA_AUDIO_FRAME_ID5
Definition iamf.h:49
@ IAMF_OBU_IA_AUDIO_FRAME_ID16
Definition iamf.h:60
@ IAMF_OBU_IA_AUDIO_FRAME_ID10
Definition iamf.h:54
@ IAMF_OBU_IA_AUDIO_FRAME_ID9
Definition iamf.h:53
@ IAMF_OBU_IA_AUDIO_FRAME_ID3
Definition iamf.h:47
@ IAMF_OBU_IA_AUDIO_FRAME_ID11
Definition iamf.h:55
@ IAMF_OBU_IA_AUDIO_FRAME_ID8
Definition iamf.h:52
@ IAMF_OBU_IA_AUDIO_FRAME_ID4
Definition iamf.h:48
@ IAMF_OBU_IA_AUDIO_FRAME_ID2
Definition iamf.h:46
@ IAMF_OBU_IA_AUDIO_FRAME_ID12
Definition iamf.h:56
@ IAMF_OBU_IA_AUDIO_FRAME_ID17
Definition iamf.h:61
@ IAMF_OBU_IA_AUDIO_FRAME_ID0
Definition iamf.h:44
@ IAMF_OBU_IA_AUDIO_FRAME_ID7
Definition iamf.h:51
IAMF_Sound_System
Definition iamf.h:145
@ 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.
An AVChannelLayout holds information about the channel layout of audio data.
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
Definition iamf.h:359
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
Definition iamf.h:616
Parameters as defined in section 3.6.1 of IAMF.
Definition iamf.h:193
unsigned int parameter_id
Identifier for the parameter substream.
Definition iamf.h:218
unsigned int codec_config_id
Definition iamf.h:101
IAMFLayer * layers
Definition iamf.h:103
unsigned int audio_element_id
Definition iamf.h:96
const AVIAMFAudioElement * celement
Definition iamf.h:90
unsigned int nb_layers
Definition iamf.h:104
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
int sample_rate
Definition iamf.h:72
int audio_roll_distance
Definition iamf.h:71
int extradata_size
Definition iamf.h:73
enum AVCodecID codec_id
Definition iamf.h:68
unsigned nb_samples
Definition iamf.h:70
unsigned codec_config_id
Definition iamf.h:67
uint32_t codec_tag
Definition iamf.h:69
uint8_t * extradata
Definition iamf.h:74
IAMFParamDefinition ** param_definitions
Definition iamf.h:135
int nb_param_definitions
Definition iamf.h:136
int nb_mix_presentations
Definition iamf.h:134
int nb_codec_configs
Definition iamf.h:130
IAMFMixPresentation ** mix_presentations
Definition iamf.h:133
IAMFAudioElement ** audio_elements
Definition iamf.h:131
IAMFCodecConfig ** codec_configs
Definition iamf.h:129
int nb_audio_elements
Definition iamf.h:132
unsigned int substream_count
Definition iamf.h:78
unsigned int coupled_substream_count
Definition iamf.h:79
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
const AVIAMFMixPresentation * cmix
Definition iamf.h:108
unsigned int mix_presentation_id
Definition iamf.h:114
size_t param_size
Definition iamf.h:125
const IAMFAudioElement * audio_element
Definition iamf.h:122
AVIAMFParamDefinition * param
Definition iamf.h:123
enum IAMF_Sound_System id
Definition iamf.h:163
AVChannelLayout layout
Definition iamf.h:164
AVCodecParameters * codecpar
Definition iamf.h:86
unsigned int audio_substream_id
Definition iamf.h:83
static double c[64]