FFmpeg
Loading...
Searching...
No Matches
iamf.c File Reference
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include "avassert.h"
#include "error.h"
#include "iamf.h"
#include "log.h"
#include "mem.h"
#include "opt.h"

Go to the source code of this file.

Macros

#define IAMF_ADD_FUNC_TEMPLATE(parent_type, parent_name, child_type, child_name, suffix)
 
#define FLAGS   AV_OPT_FLAG_ENCODING_PARAM
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 
#define OFFSET(x)
 

Functions

static const AVClassparam_definition_child_iterate (void **opaque)
 
const AVClassav_iamf_param_definition_get_class (void)
 
AVIAMFParamDefinitionav_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 given type and initializes the variables.
 
static const AVClassaudio_element_child_iterate (void **opaque)
 
const AVClassav_iamf_audio_element_get_class (void)
 
AVIAMFAudioElementav_iamf_audio_element_alloc (void)
 Allocates a AVIAMFAudioElement, and initializes its fields with default values.
 
void av_iamf_audio_element_free (AVIAMFAudioElement **paudio_element)
 Free an AVIAMFAudioElement and all its contents.
 
static void * submix_element_child_next (void *obj, void *prev)
 
static const AVClasssubmix_element_child_iterate (void **opaque)
 
static void * submix_presentation_child_next (void *obj, void *prev)
 
static const AVClasssubmix_presentation_child_iterate (void **opaque)
 
static const AVClassmix_presentation_child_iterate (void **opaque)
 
const AVClassav_iamf_mix_presentation_get_class (void)
 
AVIAMFMixPresentationav_iamf_mix_presentation_alloc (void)
 Allocates a AVIAMFMixPresentation, and initializes its fields with default values.
 
void av_iamf_mix_presentation_free (AVIAMFMixPresentation **pmix_presentation)
 Free an AVIAMFMixPresentation and all its contents.
 

Variables

static const AVOption mix_gain_options []
 
static const AVClass mix_gain_class
 
static const AVOption demixing_info_options []
 
static const AVClass demixing_info_class
 
static const AVOption recon_gain_options []
 
static const AVClass recon_gain_class
 
static const AVOption param_definition_options []
 
static const AVClass param_definition_class
 
static const AVOptionArrayDef demixing_matrix_def = { .size_max = (255 + 255) * 255, .sep = '|' }
 
static const AVOption layer_options []
 
static const AVClass layer_class
 
static const AVOption audio_element_options []
 
static const AVClass audio_element_class
 
static const AVOption submix_element_options []
 
static const AVClass element_class
 
static const AVOption submix_layout_options []
 
static const AVClass layout_class
 
static const AVOption submix_presentation_options []
 
static const AVClass submix_class
 
static const AVOption mix_presentation_options []
 
static const AVClass mix_presentation_class
 

Macro Definition Documentation

◆ IAMF_ADD_FUNC_TEMPLATE

#define IAMF_ADD_FUNC_TEMPLATE ( parent_type,
parent_name,
child_type,
child_name,
suffix )
Value:
child_type *av_iamf_ ## parent_name ## _add_ ## child_name(parent_type *parent_name) \
{ \
child_type **child_name ## suffix, *child_name; \
\
if (parent_name->nb_## child_name ## suffix == UINT_MAX) \
return NULL; \
\
child_name ## suffix = av_realloc_array(parent_name->child_name ## suffix, \
parent_name->nb_## child_name ## suffix + 1, \
sizeof(*parent_name->child_name ## suffix)); \
if (!child_name ## suffix) \
return NULL; \
\
parent_name->child_name ## suffix = child_name ## suffix; \
\
child_name = parent_name->child_name ## suffix[parent_name->nb_## child_name ## suffix] \
= av_mallocz(sizeof(*child_name)); \
if (!child_name) \
return NULL; \
\
child_name->av_class = &child_name ## _class; \
av_opt_set_defaults(child_name); \
parent_name->nb_## child_name ## suffix++; \
\
return child_name; \
}
#define NULL
Definition coverity.c:32
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
#define av_mallocz(s)

Definition at line 32 of file iamf.c.

◆ FLAGS

#define FLAGS   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 60 of file iamf.c.

◆ OFFSET [1/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFMixGain, x)
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
Definition iamf.h:77

Definition at line 65 of file iamf.c.

◆ OFFSET [2/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFDemixingInfo, x)
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
Definition iamf.h:128

Definition at line 65 of file iamf.c.

◆ OFFSET [3/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFReconGain, x)
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
Definition iamf.h:148

Definition at line 65 of file iamf.c.

◆ OFFSET [4/10]

#define OFFSET ( x)
Value:
Parameters as defined in section 3.6.1 of IAMF.
Definition iamf.h:193

Definition at line 65 of file iamf.c.

◆ OFFSET [5/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFLayer, x)
A layer defining a Channel Layout in the Audio Element.
Definition iamf.h:294

Definition at line 65 of file iamf.c.

◆ OFFSET [6/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFAudioElement, x)
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
Definition iamf.h:359

Definition at line 65 of file iamf.c.

◆ OFFSET [7/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFSubmixElement, x)
Submix element as defined in section 3.7 of IAMF.
Definition iamf.h:449

Definition at line 65 of file iamf.c.

◆ OFFSET [8/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFSubmixLayout, x)
Submix layout as defined in section 3.7.6 of IAMF.
Definition iamf.h:517

Definition at line 65 of file iamf.c.

◆ OFFSET [9/10]

#define OFFSET ( x)
Value:
offsetof(AVIAMFSubmix, x)
Submix layout as defined in section 3.7 of IAMF.
Definition iamf.h:559

Definition at line 65 of file iamf.c.

◆ OFFSET [10/10]

#define OFFSET ( x)
Value:
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
Definition iamf.h:616

Definition at line 65 of file iamf.c.

Function Documentation

◆ param_definition_child_iterate()

static const AVClass * param_definition_child_iterate ( void ** opaque)
static

Definition at line 122 of file iamf.c.

◆ audio_element_child_iterate()

static const AVClass * audio_element_child_iterate ( void ** opaque)
static

Definition at line 298 of file iamf.c.

◆ submix_element_child_next()

static void * submix_element_child_next ( void * obj,
void * prev )
static

Definition at line 376 of file iamf.c.

◆ submix_element_child_iterate()

static const AVClass * submix_element_child_iterate ( void ** opaque)
static

Definition at line 385 of file iamf.c.

◆ submix_presentation_child_next()

static void * submix_presentation_child_next ( void * obj,
void * prev )
static

Definition at line 444 of file iamf.c.

◆ submix_presentation_child_iterate()

static const AVClass * submix_presentation_child_iterate ( void ** opaque)
static

Definition at line 453 of file iamf.c.

◆ mix_presentation_child_iterate()

static const AVClass * mix_presentation_child_iterate ( void ** opaque)
static

Definition at line 496 of file iamf.c.

Variable Documentation

◆ mix_gain_options

const AVOption mix_gain_options[]
static
Initial value:
= {
{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
{ "animation_type", "set animation_type", OFFSET(animation_type), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, 2, FLAGS },
{ "start_point_value", "set start_point_value", OFFSET(start_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
{ "end_point_value", "set end_point_value", OFFSET(end_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
{ "control_point_value", "set control_point_value", OFFSET(control_point_value), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, -128.0, 128.0, FLAGS },
{ "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 },
{ NULL },
}
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
Definition opt.h:334

Definition at line 66 of file iamf.c.

◆ mix_gain_class

const AVClass mix_gain_class
static
Initial value:
= {
.class_name = "AVIAMFMixGain",
.item_name = av_default_item_name,
.option = mix_gain_options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption mix_gain_options[]
Definition iamf.c:66

Definition at line 76 of file iamf.c.

Referenced by av_iamf_param_definition_alloc(), and param_definition_child_iterate().

◆ demixing_info_options

const AVOption demixing_info_options[]
static
Initial value:
= {
{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
{ "dmixp_mode", "set dmixp_mode", OFFSET(dmixp_mode), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, 6, FLAGS },
{ NULL },
}

Definition at line 85 of file iamf.c.

◆ demixing_info_class

const AVClass demixing_info_class
static
Initial value:
= {
.class_name = "AVIAMFDemixingInfo",
.item_name = av_default_item_name,
}
static const AVOption demixing_info_options[]
Definition iamf.c:85

Definition at line 91 of file iamf.c.

Referenced by av_iamf_param_definition_alloc(), and param_definition_child_iterate().

◆ recon_gain_options

const AVOption recon_gain_options[]
static
Initial value:
= {
{ "subblock_duration", "set subblock_duration", OFFSET(subblock_duration), AV_OPT_TYPE_UINT, {.i64 = 1 }, 1, UINT_MAX, FLAGS },
{ NULL },
}

Definition at line 100 of file iamf.c.

◆ recon_gain_class

const AVClass recon_gain_class
static
Initial value:
= {
.class_name = "AVIAMFReconGain",
.item_name = av_default_item_name,
.option = recon_gain_options,
}
static const AVOption recon_gain_options[]
Definition iamf.c:100

Definition at line 105 of file iamf.c.

Referenced by av_iamf_param_definition_alloc(), and param_definition_child_iterate().

◆ param_definition_options

const AVOption param_definition_options[]
static
Initial value:
= {
{ "parameter_id", "set parameter_id", OFFSET(parameter_id), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
{ "parameter_rate", "set parameter_rate", OFFSET(parameter_rate), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
{ "duration", "set duration", OFFSET(duration), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
{ "constant_subblock_duration", "set constant_subblock_duration", OFFSET(constant_subblock_duration), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, UINT_MAX, FLAGS },
{ NULL },
}
static int64_t duration
Definition ffplay.c:330

Definition at line 114 of file iamf.c.

◆ param_definition_class

const AVClass param_definition_class
static
Initial value:
= {
.class_name = "AVIAMFParamDefinition",
.item_name = av_default_item_name,
.child_class_iterate = param_definition_child_iterate,
}
static const AVOption param_definition_options[]
Definition iamf.c:114
static const AVClass * param_definition_child_iterate(void **opaque)
Definition iamf.c:122

Definition at line 146 of file iamf.c.

Referenced by av_iamf_param_definition_alloc(), av_iamf_param_definition_get_class(), submix_element_child_iterate(), and submix_presentation_child_iterate().

◆ demixing_matrix_def

const AVOptionArrayDef demixing_matrix_def = { .size_max = (255 + 255) * 255, .sep = '|' }
static

Definition at line 240 of file iamf.c.

◆ layer_options

const AVOption layer_options[]
static

Definition at line 244 of file iamf.c.

◆ layer_class

const AVClass layer_class
static
Initial value:
= {
.class_name = "AVIAMFLayer",
.item_name = av_default_item_name,
.option = layer_options,
}
static const AVOption layer_options[]
Definition iamf.c:244

Definition at line 277 of file iamf.c.

Referenced by audio_element_child_iterate().

◆ audio_element_options

const AVOption audio_element_options[]
static
Initial value:
= {
{ "audio_element_type", "set audio_element_type", OFFSET(audio_element_type), AV_OPT_TYPE_INT,
{ "channel", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL }, .unit = "audio_element_type" },
{ "scene", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE }, .unit = "audio_element_type" },
{ "default_w", "set default_w", OFFSET(default_w), AV_OPT_TYPE_UINT, {.i64 = 0 }, 0, 10, FLAGS },
{ NULL },
}
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE
Definition iamf.h:349
@ AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL
Definition iamf.h:348

Definition at line 286 of file iamf.c.

◆ audio_element_class

const AVClass audio_element_class
static
Initial value:
= {
.class_name = "AVIAMFAudioElement",
.item_name = av_default_item_name,
.child_class_iterate = audio_element_child_iterate,
}
static const AVClass * audio_element_child_iterate(void **opaque)
Definition iamf.c:298
static const AVOption audio_element_options[]
Definition iamf.c:286

Definition at line 311 of file iamf.c.

Referenced by av_iamf_audio_element_alloc(), and av_iamf_audio_element_get_class().

◆ submix_element_options

const AVOption submix_element_options[]
static
Initial value:
= {
{ "headphones_rendering_mode", "Headphones rendering mode", OFFSET(headphones_rendering_mode), AV_OPT_TYPE_INT,
AV_IAMF_HEADPHONES_MODE_STEREO, AV_IAMF_HEADPHONES_MODE_BINAURAL, FLAGS, .unit = "headphones_rendering_mode" },
{ "stereo", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_HEADPHONES_MODE_STEREO }, .unit = "headphones_rendering_mode" },
{ "binaural", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_HEADPHONES_MODE_BINAURAL }, .unit = "headphones_rendering_mode" },
{ "default_mix_gain", "Default mix gain", OFFSET(default_mix_gain), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ "annotations", "Annotations", OFFSET(annotations), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, FLAGS },
{ NULL },
}
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
Definition opt.h:289
@ AV_IAMF_HEADPHONES_MODE_STEREO
The referenced Audio Element shall be rendered to stereo loudspeakers.
Definition iamf.h:436
@ AV_IAMF_HEADPHONES_MODE_BINAURAL
The referenced Audio Element shall be rendered with a binaural renderer.
Definition iamf.h:440

Definition at line 363 of file iamf.c.

◆ element_class

const AVClass element_class
static
Initial value:
= {
.class_name = "AVIAMFSubmixElement",
.item_name = av_default_item_name,
.child_class_iterate = submix_element_child_iterate,
}
static const AVOption submix_element_options[]
Definition iamf.c:363
static const AVClass * submix_element_child_iterate(void **opaque)
Definition iamf.c:385
static void * submix_element_child_next(void *obj, void *prev)
Definition iamf.c:376

Definition at line 398 of file iamf.c.

Referenced by submix_presentation_child_iterate().

◆ submix_layout_options

const AVOption submix_layout_options[]
static
Initial value:
= {
{ "layout_type", "Layout type", OFFSET(layout_type), AV_OPT_TYPE_INT,
{ "loudspeakers", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS }, .unit = "layout_type" },
{ "binaural", NULL, 0, AV_OPT_TYPE_CONST,
{ .i64 = AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL }, .unit = "layout_type" },
{ "sound_system", "Sound System", OFFSET(sound_system), AV_OPT_TYPE_CHLAYOUT, { .str = NULL }, 0, 0, FLAGS },
{ "integrated_loudness", "Integrated loudness", OFFSET(integrated_loudness), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ "digital_peak", "Digital peak", OFFSET(digital_peak), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ "true_peak", "True peak", OFFSET(true_peak), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ "dialog_anchored_loudness", "Anchored loudness (Dialog)", OFFSET(dialogue_anchored_loudness), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ "album_anchored_loudness", "Anchored loudness (Album)", OFFSET(album_anchored_loudness), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ NULL },
}
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL
The layout is binaural.
Definition iamf.h:508
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS
The layout follows the loudspeaker sound system convention of ITU-2051-3.
Definition iamf.h:501

Definition at line 411 of file iamf.c.

◆ layout_class

const AVClass layout_class
static
Initial value:
= {
.class_name = "AVIAMFSubmixLayout",
.item_name = av_default_item_name,
}
static const AVOption submix_layout_options[]
Definition iamf.c:411

Definition at line 428 of file iamf.c.

Referenced by submix_presentation_child_iterate().

◆ submix_presentation_options

const AVOption submix_presentation_options[]
static
Initial value:
= {
{ "default_mix_gain", "Default mix gain", OFFSET(default_mix_gain), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, -128.0, 128.0, FLAGS },
{ NULL },
}

Definition at line 439 of file iamf.c.

◆ submix_class

const AVClass submix_class
static
Initial value:
= {
.class_name = "AVIAMFSubmix",
.item_name = av_default_item_name,
.child_class_iterate = submix_presentation_child_iterate,
}
static const AVOption submix_presentation_options[]
Definition iamf.c:439
static void * submix_presentation_child_next(void *obj, void *prev)
Definition iamf.c:444
static const AVClass * submix_presentation_child_iterate(void **opaque)
Definition iamf.c:453

Definition at line 477 of file iamf.c.

Referenced by mix_presentation_child_iterate().

◆ mix_presentation_options

const AVOption mix_presentation_options[]
static
Initial value:
= {
{ "annotations", "set annotations", OFFSET(annotations), AV_OPT_TYPE_DICT, {.str = NULL }, 0, 0, FLAGS },
{ NULL },
}

Definition at line 488 of file iamf.c.

◆ mix_presentation_class

const AVClass mix_presentation_class
static
Initial value:
= {
.class_name = "AVIAMFMixPresentation",
.item_name = av_default_item_name,
.child_class_iterate = mix_presentation_child_iterate,
}
static const AVClass * mix_presentation_child_iterate(void **opaque)
Definition iamf.c:496
static const AVOption mix_presentation_options[]
Definition iamf.c:488

Definition at line 509 of file iamf.c.

Referenced by av_iamf_mix_presentation_alloc(), and av_iamf_mix_presentation_get_class().