/* * Immersive Audio Model and Formats helper functions and defines * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVUTIL_IAMF_H #define AVUTIL_IAMF_H /** * @file * Immersive Audio Model and Formats API header * @see <a href="https://aomediacodec.github.io/iamf/">Immersive Audio Model and Formats</a> */ #include <stdint.h> #include <stddef.h> #include "attributes.h" #include "avassert.h" #include "channel_layout.h" #include "dict.h" #include "rational.h" /** * @defgroup lavu_iamf_params Parameter Definition * @{ * Parameters as defined in section 3.6.1 and 3.8 of IAMF. * @} * @defgroup lavu_iamf_audio Audio Element * @{ * Audio Elements as defined in section 3.6 of IAMF. * @} * @defgroup lavu_iamf_mix Mix Presentation * @{ * Mix Presentations as defined in section 3.7 of IAMF. * @} * * @} * @addtogroup lavu_iamf_params * @{ */ enum AVIAMFAnimationType { … }; /** * Mix Gain Parameter Data as defined in section 3.8.1 of IAMF. * * @note This struct's size is not a part of the public ABI. */ AVIAMFMixGain; /** * Demixing Info Parameter Data as defined in section 3.8.2 of IAMF. * * @note This struct's size is not a part of the public ABI. */ AVIAMFDemixingInfo; /** * Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF. * * @note This struct's size is not a part of the public ABI. */ AVIAMFReconGain; enum AVIAMFParamDefinitionType { … }; /** * Parameters as defined in section 3.6.1 of IAMF. * * The struct is allocated by av_iamf_param_definition_alloc() along with an * array of subblocks, its type depending on the value of type. * This array is placed subblocks_offset bytes after the start of this struct. * * @note This struct's size is not a part of the public ABI. */ AVIAMFParamDefinition; const AVClass *av_iamf_param_definition_get_class(void); /** * Allocates memory for AVIAMFParamDefinition, plus an array of {@code nb_subblocks} * amount of subblocks of the given type and initializes the variables. Can be * freed with a normal av_free() call. * * @param size if non-NULL, the size in bytes of the resulting data array is written here. */ AVIAMFParamDefinition *av_iamf_param_definition_alloc(enum AVIAMFParamDefinitionType type, unsigned int nb_subblocks, size_t *size); /** * Get the subblock at the specified {@code idx}. Must be between 0 and nb_subblocks - 1. * * The @ref AVIAMFParamDefinition.type "param definition type" defines * the struct type of the returned pointer. */ static av_always_inline void* av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx) { … } /** * @} * @addtogroup lavu_iamf_audio * @{ */ enum AVIAMFAmbisonicsMode { … }; /** * Recon gain information for the layer is present in AVIAMFReconGain */ #define AV_IAMF_LAYER_FLAG_RECON_GAIN … /** * A layer defining a Channel Layout in the Audio Element. * * When @ref AVIAMFAudioElement.audio_element_type "the parent's Audio Element type" * is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, this corresponds to an Scalable Channel * Layout layer as defined in section 3.6.2 of IAMF. * For AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, it is an Ambisonics channel * layout as defined in section 3.6.3 of IAMF. * * @note The struct should be allocated with av_iamf_audio_element_add_layer() * and its size is not a part of the public ABI. */ AVIAMFLayer; enum AVIAMFAudioElementType { … }; /** * Information on how to combine one or more audio streams, as defined in * section 3.6 of IAMF. * * @note The struct should be allocated with av_iamf_audio_element_alloc() * and its size is not a part of the public ABI. */ AVIAMFAudioElement; const AVClass *av_iamf_audio_element_get_class(void); /** * Allocates a AVIAMFAudioElement, and initializes its fields with default values. * No layers are allocated. Must be freed with av_iamf_audio_element_free(). * * @see av_iamf_audio_element_add_layer() */ AVIAMFAudioElement *av_iamf_audio_element_alloc(void); /** * Allocate a layer and add it to a given AVIAMFAudioElement. * It is freed by av_iamf_audio_element_free() alongside the rest of the parent * AVIAMFAudioElement. * * @return a pointer to the allocated layer. */ AVIAMFLayer *av_iamf_audio_element_add_layer(AVIAMFAudioElement *audio_element); /** * Free an AVIAMFAudioElement and all its contents. * * @param audio_element pointer to pointer to an allocated AVIAMFAudioElement. * upon return, *audio_element will be set to NULL. */ void av_iamf_audio_element_free(AVIAMFAudioElement **audio_element); /** * @} * @addtogroup lavu_iamf_mix * @{ */ enum AVIAMFHeadphonesMode { … }; /** * Submix element as defined in section 3.7 of IAMF. * * @note The struct should be allocated with av_iamf_submix_add_element() * and its size is not a part of the public ABI. */ AVIAMFSubmixElement; enum AVIAMFSubmixLayoutType { … }; /** * Submix layout as defined in section 3.7.6 of IAMF. * * @note The struct should be allocated with av_iamf_submix_add_layout() * and its size is not a part of the public ABI. */ AVIAMFSubmixLayout; /** * Submix layout as defined in section 3.7 of IAMF. * * @note The struct should be allocated with av_iamf_mix_presentation_add_submix() * and its size is not a part of the public ABI. */ AVIAMFSubmix; /** * Information on how to render and mix one or more AVIAMFAudioElement to generate * the final audio output, as defined in section 3.7 of IAMF. * * @note The struct should be allocated with av_iamf_mix_presentation_alloc() * and its size is not a part of the public ABI. */ AVIAMFMixPresentation; const AVClass *av_iamf_mix_presentation_get_class(void); /** * Allocates a AVIAMFMixPresentation, and initializes its fields with default * values. No submixes are allocated. * Must be freed with av_iamf_mix_presentation_free(). * * @see av_iamf_mix_presentation_add_submix() */ AVIAMFMixPresentation *av_iamf_mix_presentation_alloc(void); /** * Allocate a submix and add it to a given AVIAMFMixPresentation. * It is freed by av_iamf_mix_presentation_free() alongside the rest of the * parent AVIAMFMixPresentation. * * @return a pointer to the allocated submix. */ AVIAMFSubmix *av_iamf_mix_presentation_add_submix(AVIAMFMixPresentation *mix_presentation); /** * Allocate a submix element and add it to a given AVIAMFSubmix. * It is freed by av_iamf_mix_presentation_free() alongside the rest of the * parent AVIAMFSubmix. * * @return a pointer to the allocated submix. */ AVIAMFSubmixElement *av_iamf_submix_add_element(AVIAMFSubmix *submix); /** * Allocate a submix layout and add it to a given AVIAMFSubmix. * It is freed by av_iamf_mix_presentation_free() alongside the rest of the * parent AVIAMFSubmix. * * @return a pointer to the allocated submix. */ AVIAMFSubmixLayout *av_iamf_submix_add_layout(AVIAMFSubmix *submix); /** * Free an AVIAMFMixPresentation and all its contents. * * @param mix_presentation pointer to pointer to an allocated AVIAMFMixPresentation. * upon return, *mix_presentation will be set to NULL. */ void av_iamf_mix_presentation_free(AVIAMFMixPresentation **mix_presentation); /** * @} */ #endif /* AVUTIL_IAMF_H */