32#define IAMF_ADD_FUNC_TEMPLATE(parent_type, parent_name, child_type, child_name, suffix) \
33child_type *av_iamf_ ## parent_name ## _add_ ## child_name(parent_type *parent_name) \
35 child_type **child_name ## suffix, *child_name; \
37 if (parent_name->nb_## child_name ## suffix == UINT_MAX) \
40 child_name ## suffix = av_realloc_array(parent_name->child_name ## suffix, \
41 parent_name->nb_## child_name ## suffix + 1, \
42 sizeof(*parent_name->child_name ## suffix)); \
43 if (!child_name ## suffix) \
46 parent_name->child_name ## suffix = child_name ## suffix; \
48 child_name = parent_name->child_name ## suffix[parent_name->nb_## child_name ## suffix] \
49 = av_mallocz(sizeof(*child_name)); \
53 child_name->av_class = &child_name ## _class; \
54 av_opt_set_defaults(child_name); \
55 parent_name->nb_## child_name ## suffix++; \
60#define FLAGS AV_OPT_FLAG_ENCODING_PARAM
65#define OFFSET(x) offsetof(AVIAMFMixGain, x)
72 {
"control_point_relative_time",
"set control_point_relative_time",
OFFSET(control_point_relative_time),
AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0.0, 1.0,
FLAGS },
77 .class_name =
"AVIAMFMixGain",
84#define OFFSET(x) offsetof(AVIAMFDemixingInfo, x)
92 .class_name =
"AVIAMFDemixingInfo",
99#define OFFSET(x) offsetof(AVIAMFReconGain, x)
106 .class_name =
"AVIAMFReconGain",
113#define OFFSET(x) offsetof(AVIAMFParamDefinition, x)
118 {
"constant_subblock_duration",
"set constant_subblock_duration",
OFFSET(constant_subblock_duration),
AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX,
FLAGS },
124 uintptr_t
i = (uintptr_t)*opaque;
142 *opaque = (
void*)(
i + 1);
147 .class_name =
"AVIAMFParamDefinition",
160 unsigned int nb_subblocks,
size_t *
out_size)
163 struct MixGainStruct {
171 struct ReconGainStruct {
175 size_t subblocks_offset, subblock_size;
181 subblocks_offset = offsetof(
struct MixGainStruct, m);
185 subblocks_offset = offsetof(
struct DemixStruct, d);
189 subblocks_offset = offsetof(
struct ReconGainStruct,
r);
196 size = subblocks_offset;
197 if (nb_subblocks > (SIZE_MAX -
size) / subblock_size)
199 size += subblock_size * nb_subblocks;
213 for (
int i = 0;
i < nb_subblocks;
i++) {
243#define OFFSET(x) offsetof(AVIAMFLayer, x)
251 {.i64 = 0 }, 0, (1 << 6) - 1,
FLAGS, .unit =
"output_gain_flags" },
253 {.i64 = 1 << 5 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
255 {.i64 = 1 << 4 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
257 {.i64 = 1 << 3 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
259 {.i64 = 1 << 2 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
261 {.i64 = 1 << 1 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
263 {.i64 = 1 << 0 }, INT_MIN, INT_MAX,
FLAGS, .unit =
"output_gain_flags"},
278 .class_name =
"AVIAMFLayer",
285#define OFFSET(x) offsetof(AVIAMFAudioElement, x)
300 uintptr_t
i = (uintptr_t)*opaque;
307 *opaque = (
void*)(
i + 1);
312 .class_name =
"AVIAMFAudioElement",
333 return audio_element;
362#define OFFSET(x) offsetof(AVIAMFSubmixElement, x)
364 {
"headphones_rendering_mode",
"Headphones rendering mode",
OFFSET(headphones_rendering_mode),
AV_OPT_TYPE_INT,
387 uintptr_t
i = (uintptr_t)*opaque;
394 *opaque = (
void*)(
i + 1);
399 .class_name =
"AVIAMFSubmixElement",
410#define OFFSET(x) offsetof(AVIAMFSubmixLayout, x)
423 {
"dialog_anchored_loudness",
"Anchored loudness (Dialog)",
OFFSET(dialogue_anchored_loudness),
AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0,
FLAGS },
429 .class_name =
"AVIAMFSubmixLayout",
438#define OFFSET(x) offsetof(AVIAMFSubmix, x)
455 uintptr_t
i = (uintptr_t)*opaque;
473 *opaque = (
void*)(
i + 1);
478 .class_name =
"AVIAMFSubmix",
487#define OFFSET(x) offsetof(AVIAMFMixPresentation, x)
498 uintptr_t
i = (uintptr_t)*opaque;
505 *opaque = (
void*)(
i + 1);
510 .class_name =
"AVIAMFMixPresentation",
526 if (mix_presentation) {
531 return mix_presentation;
540 if (!mix_presentation)
552 for (
int j = 0; j < sub_mix->
nb_layouts; j++) {
static double output_gain(double lin_slope, double ratio, double thres, double knee, double knee_start, double knee_stop, double range, int mode)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
const AVClass * av_iamf_audio_element_get_class(void)
#define AV_IAMF_LAYER_FLAG_RECON_GAIN
Recon gain information for the layer is present in AVIAMFReconGain.
void av_iamf_audio_element_free(AVIAMFAudioElement **paudio_element)
Free an AVIAMFAudioElement and all its contents.
AVIAMFAudioElement * av_iamf_audio_element_alloc(void)
Allocates a AVIAMFAudioElement, and initializes its fields with default values.
@ AV_IAMF_AMBISONICS_MODE_MONO
@ AV_IAMF_AMBISONICS_MODE_PROJECTION
@ AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE
@ AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **pmix_presentation)
Free an AVIAMFMixPresentation and all its contents.
AVIAMFMixPresentation * av_iamf_mix_presentation_alloc(void)
Allocates a AVIAMFMixPresentation, and initializes its fields with default values.
const AVClass * av_iamf_mix_presentation_get_class(void)
@ AV_IAMF_HEADPHONES_MODE_STEREO
The referenced Audio Element shall be rendered to stereo loudspeakers.
@ AV_IAMF_HEADPHONES_MODE_BINAURAL
The referenced Audio Element shall be rendered with a binaural renderer.
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL
The layout is binaural.
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS
The layout follows the loudspeaker sound system convention of ITU-2051-3.
static av_always_inline void * av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
Get the subblock at the specified idx.
AVIAMFParamDefinitionType
const AVClass * av_iamf_param_definition_get_class(void)
AVIAMFParamDefinition * av_iamf_param_definition_alloc(enum AVIAMFParamDefinitionType type, unsigned int nb_subblocks, size_t *out_size)
Allocates memory for AVIAMFParamDefinition, plus an array of nb_subblocks amount of subblocks of the ...
@ AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN
Subblocks are of struct type AVIAMFReconGain.
@ AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN
Subblocks are of struct type AVIAMFMixGain.
@ AV_IAMF_PARAMETER_DEFINITION_DEMIXING
Subblocks are of struct type AVIAMFDemixingInfo.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
void av_opt_free(void *obj)
Free all allocated objects in obj.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static const AVOption mix_gain_options[]
static const AVClass demixing_info_class
static const AVClass layer_class
static const AVClass element_class
static const AVClass submix_class
static const AVClass * mix_presentation_child_iterate(void **opaque)
static const AVOption submix_element_options[]
static const AVOption param_definition_options[]
static const AVOption submix_presentation_options[]
#define IAMF_ADD_FUNC_TEMPLATE(parent_type, parent_name, child_type, child_name, suffix)
static const AVClass recon_gain_class
static const AVClass param_definition_class
static const AVClass mix_gain_class
static const AVClass * audio_element_child_iterate(void **opaque)
static const AVClass * submix_element_child_iterate(void **opaque)
static void * submix_element_child_next(void *obj, void *prev)
static const AVOption audio_element_options[]
static void * submix_presentation_child_next(void *obj, void *prev)
static const AVClass * submix_presentation_child_iterate(void **opaque)
static const AVOptionArrayDef demixing_matrix_def
static const AVClass mix_presentation_class
static const AVClass audio_element_class
static const AVOption recon_gain_options[]
static const AVOption mix_presentation_options[]
static const AVClass * param_definition_child_iterate(void **opaque)
static const AVOption submix_layout_options[]
static const AVClass layout_class
static const AVOption layer_options[]
static const AVOption demixing_info_options[]
Immersive Audio Model and Formats API header.
Memory handling functions.
Describe the class of an AVClass context structure.
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
AVIAMFParamDefinition * recon_gain_info
Recon gain information used to reconstruct a scalable channel audio representation.
AVIAMFParamDefinition * demixing_info
Demixing information used to reconstruct a scalable channel audio representation.
unsigned int nb_layers
Number of layers, or channel groups, in the Audio Element.
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
A layer defining a Channel Layout in the Audio Element.
AVRational * demixing_matrix
Demixing matrix as defined in section 3.6.3 of IAMF.
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
unsigned int nb_submixes
Number of submixes in the presentation.
AVIAMFSubmix ** submixes
Array of submixes.
Parameters as defined in section 3.6.1 of IAMF.
size_t subblocks_offset
Offset in bytes from the start of this struct, at which the subblocks array is located.
size_t subblock_size
Size in bytes of each element in the subblocks array.
enum AVIAMFParamDefinitionType type
Parameters type.
unsigned int nb_subblocks
Number of subblocks in the array.
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
Submix element as defined in section 3.7 of IAMF.
AVIAMFParamDefinition * element_mix_config
Information required required for applying any processing to the referenced and rendered Audio Elemen...
Submix layout as defined in section 3.7.6 of IAMF.
Submix layout as defined in section 3.7 of IAMF.
unsigned int nb_elements
Number of elements in the submix.
AVIAMFSubmixElement ** elements
Array of submix elements.
AVIAMFSubmixLayout ** layouts
Array of submix layouts.
AVIAMFParamDefinition * output_mix_config
Information required for post-processing the mixed audio signal to generate the audio signal for play...
unsigned int nb_layouts
Number of layouts in the submix.
May be set as default_val for AV_OPT_TYPE_FLAG_ARRAY options.