Go to the documentation of this file.
69 memcpy(codec_config->
extradata, buf,
sizeof(buf));
136 if (j < iamf->nb_codec_configs) {
178 av_log(log_ctx,
AV_LOG_ERROR,
"parameter_rate needed but not set for parameter_id %u\n",
216 if (iamf_audio_element->
nb_layers != 1) {
217 av_log(log_ctx,
AV_LOG_ERROR,
"Invalid amount of layers for SCENE_BASED audio element. Must be 1\n");
222 av_log(log_ctx,
AV_LOG_ERROR,
"Invalid channel layout for SCENE_BASED audio element\n");
231 av_log(log_ctx,
AV_LOG_ERROR,
"Invalid amount of channels in a stream for MONO mode ambisonics\n");
236 for (
int j,
i = 0;
i < iamf_audio_element->
nb_layers;
i++) {
255 codec_config =
av_mallocz(
sizeof(*codec_config));
265 audio_element =
av_mallocz(
sizeof(*audio_element));
281 if (!audio_element->
layers) {
286 for (
int i = 0, j = 0;
i < iamf_audio_element->
nb_layers;
i++) {
293 for (; nb_channels > 0 && j < stg->
nb_streams; j++) {
303 av_log(log_ctx,
AV_LOG_ERROR,
"Invalid channel count across substreams in layer %u from stream group %u\n",
314 av_log(log_ctx,
AV_LOG_ERROR,
"Duplicate id %u in streams %u and %u from stream group %u\n",
384 mix_presentation =
av_mallocz(
sizeof(*mix_presentation));
385 if (!mix_presentation)
398 "Mix Presentation ID %"PRId64
"\n",
i, stg->
id);
415 av_log(log_ctx,
AV_LOG_ERROR,
"element_mix_config is not present for element %u in submix %u from "
416 "Mix Presentation ID %"PRId64
"\n", j,
i, stg->
id);
450 uint8_t *dyn_buf =
NULL;
550 put_bits(&pb, 1, !!(layer->
flags & AV_IAMF_LAYER_FLAG_RECON_GAIN));
603 switch (param->
type) {
635 uint8_t *dyn_buf =
NULL;
667 if (param_definition_types & 1) {
673 av_log(log_ctx,
AV_LOG_ERROR,
"demixing_info needed but not set in Stream Group #%u\n",
689 if (param_definition_types & 2) {
694 av_log(log_ctx,
AV_LOG_ERROR,
"recon_gain_info needed but not set in Stream Group #%u\n",
739 uint8_t *dyn_buf =
NULL;
755 for (
int i = 0;
i <
mix->nb_submixes;
i++) {
774 av_log(log_ctx,
AV_LOG_ERROR,
"Inconsistent amount of labels in submix %d from Mix Presentation id #%u\n",
835 info_type |= (dialogue || album) << 1;
842 avio_w8(dyn_bc, dialogue + album);
909 uint8_t *dyn_buf =
NULL;
919 av_log(log_ctx,
AV_LOG_ERROR,
"Non-existent Parameter Definition with ID %u referenced by a packet\n",
926 "with ID %u in a packet\n",
953 switch (param->
type) {
967 mix->control_point_relative_time.den)));
986 if (!audio_element) {
991 for (
int j = 0; j < audio_element->
nb_layers; j++) {
994 if (layer->
flags & AV_IAMF_LAYER_FLAG_RECON_GAIN) {
995 unsigned int recon_gain_flags = 0;
999 recon_gain_flags |= (1 << k) * !!recon->
recon_gain[j][k];
1001 recon_gain_flags |= (2 << k) * !!recon->
recon_gain[j][k];
1002 if (recon_gain_flags >> 8)
1003 recon_gain_flags |= (1 << k);
1006 for (k = 0; k < 12; k++) {
1063 unsigned int audio_substream_id)
1065 for (
int i = 0;
i <
c->nb_audio_elements;
i++) {
1070 return audio_element;
1083 const uint8_t *side_data;
1084 uint8_t *dyn_buf =
NULL;
1085 unsigned int skip_samples = 0, discard_padding = 0;
1086 size_t side_data_size;
1087 int dyn_size,
type = audio_substream_id <= 17 ?
1094 size_t new_extradata_size;
1097 &new_extradata_size);
1122 if (side_data && side_data_size >= 10) {
1123 skip_samples =
AV_RL32(side_data);
1124 discard_padding =
AV_RL32(side_data + 4);
1134 put_bits(&pbc, 1, skip_samples || discard_padding);
1139 if (skip_samples || discard_padding) {
1144 if (audio_substream_id > 17)
union AVStreamGroup::@366 params
Group type-specific parameters.
AVIAMFSubmixElement ** elements
Array of submix elements.
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS
The layout follows the loudspeaker sound system convention of ITU-2051-3.
unsigned int nb_layers
Number of layers, or channel groups, in the Audio Element.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int64_t id
Group type-specific group ID.
AVIAMFSubmixLayout ** layouts
Array of submix layouts.
static int mix(int c0, int c1)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
unsigned int default_w
Default weight value as defined in section 3.6 of IAMF.
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
unsigned int nb_substreams
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
unsigned int nb_submixes
Number of submixes in the presentation.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
enum AVIAMFParamDefinitionType type
Parameters type.
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
static int put_bytes_count(const PutBitContext *s, int round_up)
enum AVIAMFSubmixLayoutType layout_type
AVIAMFParamDefinition * param
Parameters as defined in section 3.6.1 of IAMF.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with element_mix_config's par...
static int add_param_definition(IAMFContext *iamf, AVIAMFParamDefinition *param, const IAMFAudioElement *audio_element, void *log_ctx)
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
const AVIAMFMixPresentation * cmix
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
static int write_parameter_block(const IAMFContext *iamf, AVIOContext *pb, const AVIAMFParamDefinition *param, void *log_ctx)
AVRational digital_peak
The digital (sampled) peak value of the audio signal, as defined in ITU-1770-4.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int fill_codec_config(IAMFContext *iamf, const AVStreamGroup *stg, IAMFCodecConfig *codec_config)
@ AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM
IAMF Recon Gain Info Parameter Data associated with the audio frame.
AVRational integrated_loudness
The program integrated loudness information, as defined in ITU-1770-4.
Submix layout as defined in section 3.7.6 of IAMF.
static int put_bits_left(PutBitContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
enum AVIAMFAudioElementType audio_element_type
Audio element type as defined in section 3.6 of IAMF.
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
@ AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN
Subblocks are of struct type AVIAMFReconGain.
static int rescale_rational(AVRational q, int b)
IAMFAudioElement ** audio_elements
AVDictionary * annotations
A dictionary of strings describing the submix in different languages.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int frame_size
Audio only.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
@ AV_IAMF_ANIMATION_TYPE_BEZIER
static int update_extradata(IAMFCodecConfig *codec_config)
int ff_iamf_add_audio_element(IAMFContext *iamf, const AVStreamGroup *stg, void *log_ctx)
unsigned int audio_substream_id
unsigned int substream_count
AVRational dialogue_anchored_loudness
The Dialogue loudness information, as defined in ITU-1770-4.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static av_always_inline void * av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
Get the subblock at the specified.
union AVChannelLayout::@428 u
Details about which channels are present in this layout.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum AVIAMFHeadphonesMode headphones_rendering_mode
A value that indicates whether the referenced channel-based Audio Element shall be rendered to stereo...
unsigned int index
Group index in AVFormatContext.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVChannelLayout ch_layout
void ffio_write_leb(AVIOContext *s, unsigned val)
unsigned int audio_element_id
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
@ AV_CHANNEL_ORDER_AMBISONIC
The audio is represented as the decomposition of the sound field into spherical harmonics.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Rational number (pair of numerator and denominator).
unsigned int duration
The accumulated duration of all blocks in this parameter definition, in units of 1 / parameter_rate.
static IAMFAudioElement * get_audio_element(const IAMFContext *c, unsigned int audio_substream_id)
A layer defining a Channel Layout in the Audio Element.
int ff_iamf_add_mix_presentation(IAMFContext *iamf, const AVStreamGroup *stg, void *log_ctx)
void avio_w8(AVIOContext *s, int b)
@ AV_IAMF_ANIMATION_TYPE_LINEAR
AVChannelLayout ch_layout
Audio only.
const AVIAMFAudioElement * celement
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
int sample_rate
Audio only.
unsigned int output_gain_flags
Output gain channel flags as defined in section 3.6.2 of IAMF.
static int populate_audio_roll_distance(IAMFCodecConfig *codec_config)
unsigned int audio_element_id
The id of the Audio Element this submix element references.
int extradata_size
Size of the extradata content in bytes.
Submix layout as defined in section 3.7 of IAMF.
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
unsigned int coupled_substream_count
#define MKBETAG(a, b, c, d)
int ff_iamf_write_parameter_blocks(const IAMFContext *iamf, AVIOContext *pb, const AVPacket *pkt, void *log_ctx)
struct AVIAMFAudioElement * iamf_audio_element
static int iamf_write_mixing_presentation(const IAMFContext *iamf, const IAMFMixPresentation *mix_presentation, AVIOContext *pb, void *log_ctx)
static const uint8_t header[24]
static int scalable_channel_layout_config(const IAMFAudioElement *audio_element, AVIOContext *dyn_bc)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
IAMFSubStream * substreams
static int iamf_write_codec_config(const IAMFContext *iamf, const IAMFCodecConfig *codec_config, AVIOContext *pb)
unsigned int constant_subblock_duration
The duration of every subblock in the case where all subblocks, with the optional exception of the la...
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
void avio_wl32(AVIOContext *s, unsigned int val)
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
AVStream ** streams
A list of streams in the group.
struct AVIAMFMixPresentation * iamf_mix_presentation
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
IAMFParamDefinition ** param_definitions
#define i(width, name, range_min, range_max)
unsigned int parameter_id
Identifier for the paremeter substream.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
static int param_definition(const IAMFContext *iamf, const IAMFParamDefinition *param_def, AVIOContext *dyn_bc, void *log_ctx)
IAMFCodecConfig ** codec_configs
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
void * av_calloc(size_t nmemb, size_t size)
unsigned int nb_subblocks
Number of subblocks in the array.
@ AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE
int ff_iamf_write_audio_frame(const IAMFContext *iamf, AVIOContext *pb, unsigned audio_substream_id, const AVPacket *pkt)
int ff_iamf_write_descriptors(const IAMFContext *iamf, AVIOContext *pb, void *log_ctx)
unsigned int nb_layouts
Number of layouts in the submix.
static int ambisonics_config(const IAMFAudioElement *audio_element, AVIOContext *dyn_bc)
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int id
Format-specific stream ID.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
@ AV_CHANNEL_ORDER_CUSTOM
The channel order does not correspond to any other predefined order and is stored as an explicit map.
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with output_mix_config's para...
AVRational album_anchored_loudness
The Album loudness information, as defined in ITU-1770-4.
AVRational true_peak
The true peak of the audio signal, as defined in ITU-1770-4.
AVChannelLayout sound_system
Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus 7.1.2ch, 3....
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
@ AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN
Subblocks are of struct type AVIAMFMixGain.
unsigned int nb_elements
Number of elements in the submix.
AVIAMFParamDefinition * demixing_info
Demixing information used to reconstruct a scalable channel audio representation.
unsigned int dmixp_mode
Pre-defined combination of demixing parameters.
AVIAMFParamDefinition * output_mix_config
Information required for post-processing the mixed audio signal to generate the audio signal for play...
enum AVStreamGroupParamsType type
Group type.
IAMFMixPresentation ** mix_presentations
enum AVIAMFAmbisonicsMode ambisonics_mode
Ambisonics mode as defined in section 3.6.3 of IAMF.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
void avio_wb24(AVIOContext *s, unsigned int val)
@ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL
The layout is binaural.
unsigned int flags
A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* flags.
AVRational output_gain
Output gain as defined in section 3.6.2 of IAMF.
@ AV_IAMF_AMBISONICS_MODE_PROJECTION
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
AVIAMFParamDefinition * element_mix_config
Information required required for applying any processing to the referenced and rendered Audio Elemen...
unsigned int parameter_rate
Sample rate for the paremeter substream.
Submix element as defined in section 3.7 of IAMF.
void avio_wb16(AVIOContext *s, unsigned int val)
@ AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL
unsigned int codec_config_id
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
AVIAMFParamDefinition * recon_gain_info
Recon gain information used to reconstruct a scalable channel audio representation.
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
AVIAMFSubmix ** submixes
Array of submixes.
unsigned int mix_presentation_id
uint8_t recon_gain[6][12]
Array of gain values to be applied to each channel for each layer defined in the Audio Element refere...
@ AV_PKT_DATA_IAMF_MIX_GAIN_PARAM
IAMF Mix Gain Parameter Data associated with the audio frame.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
@ AV_IAMF_PARAMETER_DEFINITION_DEMIXING
Subblocks are of struct type AVIAMFDemixingInfo.
static int iamf_write_audio_element(const IAMFContext *iamf, const IAMFAudioElement *audio_element, AVIOContext *pb, void *log_ctx)
@ AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM
IAMF Demixing Info Parameter Data associated with the audio frame.