| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Immersive Audio Model and Formats helper functions and defines | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef AVUTIL_IAMF_H | ||
| 22 | #define AVUTIL_IAMF_H | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @file | ||
| 26 | * Immersive Audio Model and Formats API header | ||
| 27 | * @see <a href="https://aomediacodec.github.io/iamf/">Immersive Audio Model and Formats</a> | ||
| 28 | */ | ||
| 29 | |||
| 30 | #include <stdint.h> | ||
| 31 | #include <stddef.h> | ||
| 32 | |||
| 33 | #include "attributes.h" | ||
| 34 | #include "avassert.h" | ||
| 35 | #include "channel_layout.h" | ||
| 36 | #include "dict.h" | ||
| 37 | #include "rational.h" | ||
| 38 | |||
| 39 | /** | ||
| 40 | * @defgroup lavu_iamf Immersive Audio Model and Formats | ||
| 41 | * @ingroup lavu_audio | ||
| 42 | * | ||
| 43 | * Immersive Audio Model and Formats related functions and defines | ||
| 44 | * | ||
| 45 | * @defgroup lavu_iamf_params Parameter Definition | ||
| 46 | * @ingroup lavu_iamf | ||
| 47 | * @{ | ||
| 48 | * Parameters as defined in section 3.6.1 and 3.8 of IAMF. | ||
| 49 | * @} | ||
| 50 | * | ||
| 51 | * @defgroup lavu_iamf_audio Audio Element | ||
| 52 | * @ingroup lavu_iamf | ||
| 53 | * @{ | ||
| 54 | * Audio Elements as defined in section 3.6 of IAMF. | ||
| 55 | * @} | ||
| 56 | * | ||
| 57 | * @defgroup lavu_iamf_mix Mix Presentation | ||
| 58 | * @ingroup lavu_iamf | ||
| 59 | * @{ | ||
| 60 | * Mix Presentations as defined in section 3.7 of IAMF. | ||
| 61 | * @} | ||
| 62 | * | ||
| 63 | * @addtogroup lavu_iamf_params | ||
| 64 | * @{ | ||
| 65 | */ | ||
| 66 | enum AVIAMFAnimationType { | ||
| 67 | AV_IAMF_ANIMATION_TYPE_STEP, | ||
| 68 | AV_IAMF_ANIMATION_TYPE_LINEAR, | ||
| 69 | AV_IAMF_ANIMATION_TYPE_BEZIER, | ||
| 70 | }; | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Mix Gain Parameter Data as defined in section 3.8.1 of IAMF. | ||
| 74 | * | ||
| 75 | * @note This struct's size is not a part of the public ABI. | ||
| 76 | */ | ||
| 77 | typedef struct AVIAMFMixGain { | ||
| 78 | const AVClass *av_class; | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Duration for the given subblock, in units of | ||
| 82 | * 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate". | ||
| 83 | * It must not be 0. | ||
| 84 | */ | ||
| 85 | unsigned int subblock_duration; | ||
| 86 | /** | ||
| 87 | * The type of animation applied to the parameter values. | ||
| 88 | */ | ||
| 89 | enum AVIAMFAnimationType animation_type; | ||
| 90 | /** | ||
| 91 | * Parameter value that is applied at the start of the subblock. | ||
| 92 | * Applies to all defined Animation Types. | ||
| 93 | * | ||
| 94 | * Valid range of values is -128.0 to 128.0 | ||
| 95 | */ | ||
| 96 | AVRational start_point_value; | ||
| 97 | /** | ||
| 98 | * Parameter value that is applied at the end of the subblock. | ||
| 99 | * Applies only to AV_IAMF_ANIMATION_TYPE_LINEAR and | ||
| 100 | * AV_IAMF_ANIMATION_TYPE_BEZIER Animation Types. | ||
| 101 | * | ||
| 102 | * Valid range of values is -128.0 to 128.0 | ||
| 103 | */ | ||
| 104 | AVRational end_point_value; | ||
| 105 | /** | ||
| 106 | * Parameter value of the middle control point of a quadratic Bezier | ||
| 107 | * curve, i.e., its y-axis value. | ||
| 108 | * Applies only to AV_IAMF_ANIMATION_TYPE_BEZIER Animation Type. | ||
| 109 | * | ||
| 110 | * Valid range of values is -128.0 to 128.0 | ||
| 111 | */ | ||
| 112 | AVRational control_point_value; | ||
| 113 | /** | ||
| 114 | * Parameter value of the time of the middle control point of a | ||
| 115 | * quadratic Bezier curve, i.e., its x-axis value. | ||
| 116 | * Applies only to AV_IAMF_ANIMATION_TYPE_BEZIER Animation Type. | ||
| 117 | * | ||
| 118 | * Valid range of values is 0.0 to 1.0 | ||
| 119 | */ | ||
| 120 | AVRational control_point_relative_time; | ||
| 121 | } AVIAMFMixGain; | ||
| 122 | |||
| 123 | /** | ||
| 124 | * Demixing Info Parameter Data as defined in section 3.8.2 of IAMF. | ||
| 125 | * | ||
| 126 | * @note This struct's size is not a part of the public ABI. | ||
| 127 | */ | ||
| 128 | typedef struct AVIAMFDemixingInfo { | ||
| 129 | const AVClass *av_class; | ||
| 130 | |||
| 131 | /** | ||
| 132 | * Duration for the given subblock, in units of | ||
| 133 | * 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate". | ||
| 134 | * It must not be 0. | ||
| 135 | */ | ||
| 136 | unsigned int subblock_duration; | ||
| 137 | /** | ||
| 138 | * Pre-defined combination of demixing parameters. | ||
| 139 | */ | ||
| 140 | unsigned int dmixp_mode; | ||
| 141 | } AVIAMFDemixingInfo; | ||
| 142 | |||
| 143 | /** | ||
| 144 | * Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF. | ||
| 145 | * | ||
| 146 | * @note This struct's size is not a part of the public ABI. | ||
| 147 | */ | ||
| 148 | typedef struct AVIAMFReconGain { | ||
| 149 | const AVClass *av_class; | ||
| 150 | |||
| 151 | /** | ||
| 152 | * Duration for the given subblock, in units of | ||
| 153 | * 1 / @ref AVIAMFParamDefinition.parameter_rate "parameter_rate". | ||
| 154 | * It must not be 0. | ||
| 155 | */ | ||
| 156 | unsigned int subblock_duration; | ||
| 157 | |||
| 158 | /** | ||
| 159 | * Array of gain values to be applied to each channel for each layer | ||
| 160 | * defined in the Audio Element referencing the parent Parameter Definition. | ||
| 161 | * Values for layers where the AV_IAMF_LAYER_FLAG_RECON_GAIN flag is not set | ||
| 162 | * are undefined. | ||
| 163 | * | ||
| 164 | * Channel order is: FL, C, FR, SL, SR, TFL, TFR, BL, BR, TBL, TBR, LFE | ||
| 165 | */ | ||
| 166 | uint8_t recon_gain[6][12]; | ||
| 167 | } AVIAMFReconGain; | ||
| 168 | |||
| 169 | enum AVIAMFParamDefinitionType { | ||
| 170 | /** | ||
| 171 | * Subblocks are of struct type AVIAMFMixGain | ||
| 172 | */ | ||
| 173 | AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN, | ||
| 174 | /** | ||
| 175 | * Subblocks are of struct type AVIAMFDemixingInfo | ||
| 176 | */ | ||
| 177 | AV_IAMF_PARAMETER_DEFINITION_DEMIXING, | ||
| 178 | /** | ||
| 179 | * Subblocks are of struct type AVIAMFReconGain | ||
| 180 | */ | ||
| 181 | AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN, | ||
| 182 | }; | ||
| 183 | |||
| 184 | /** | ||
| 185 | * Parameters as defined in section 3.6.1 of IAMF. | ||
| 186 | * | ||
| 187 | * The struct is allocated by av_iamf_param_definition_alloc() along with an | ||
| 188 | * array of subblocks, its type depending on the value of type. | ||
| 189 | * This array is placed subblocks_offset bytes after the start of this struct. | ||
| 190 | * | ||
| 191 | * @note This struct's size is not a part of the public ABI. | ||
| 192 | */ | ||
| 193 | typedef struct AVIAMFParamDefinition { | ||
| 194 | const AVClass *av_class; | ||
| 195 | |||
| 196 | /** | ||
| 197 | * Offset in bytes from the start of this struct, at which the subblocks | ||
| 198 | * array is located. | ||
| 199 | */ | ||
| 200 | size_t subblocks_offset; | ||
| 201 | /** | ||
| 202 | * Size in bytes of each element in the subblocks array. | ||
| 203 | */ | ||
| 204 | size_t subblock_size; | ||
| 205 | /** | ||
| 206 | * Number of subblocks in the array. | ||
| 207 | */ | ||
| 208 | unsigned int nb_subblocks; | ||
| 209 | |||
| 210 | /** | ||
| 211 | * Parameters type. Determines the type of the subblock elements. | ||
| 212 | */ | ||
| 213 | enum AVIAMFParamDefinitionType type; | ||
| 214 | |||
| 215 | /** | ||
| 216 | * Identifier for the parameter substream. | ||
| 217 | */ | ||
| 218 | unsigned int parameter_id; | ||
| 219 | /** | ||
| 220 | * Sample rate for the parameter substream. It must not be 0. | ||
| 221 | */ | ||
| 222 | unsigned int parameter_rate; | ||
| 223 | |||
| 224 | /** | ||
| 225 | * The accumulated duration of all blocks in this parameter definition, | ||
| 226 | * in units of 1 / @ref parameter_rate. | ||
| 227 | * | ||
| 228 | * May be 0, in which case all duration values should be specified in | ||
| 229 | * another parameter definition referencing the same parameter_id. | ||
| 230 | */ | ||
| 231 | unsigned int duration; | ||
| 232 | /** | ||
| 233 | * The duration of every subblock in the case where all subblocks, with | ||
| 234 | * the optional exception of the last subblock, have equal durations. | ||
| 235 | * | ||
| 236 | * Must be 0 if subblocks have different durations. | ||
| 237 | */ | ||
| 238 | unsigned int constant_subblock_duration; | ||
| 239 | } AVIAMFParamDefinition; | ||
| 240 | |||
| 241 | const AVClass *av_iamf_param_definition_get_class(void); | ||
| 242 | |||
| 243 | /** | ||
| 244 | * Allocates memory for AVIAMFParamDefinition, plus an array of {@code nb_subblocks} | ||
| 245 | * amount of subblocks of the given type and initializes the variables. Can be | ||
| 246 | * freed with a normal av_free() call. | ||
| 247 | * | ||
| 248 | * @param size if non-NULL, the size in bytes of the resulting data array is written here. | ||
| 249 | */ | ||
| 250 | AVIAMFParamDefinition *av_iamf_param_definition_alloc(enum AVIAMFParamDefinitionType type, | ||
| 251 | unsigned int nb_subblocks, size_t *size); | ||
| 252 | |||
| 253 | /** | ||
| 254 | * Get the subblock at the specified {@code idx}. Must be between 0 and nb_subblocks - 1. | ||
| 255 | * | ||
| 256 | * The @ref AVIAMFParamDefinition.type "param definition type" defines | ||
| 257 | * the struct type of the returned pointer. | ||
| 258 | */ | ||
| 259 | static av_always_inline void* | ||
| 260 | 335 | av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx) | |
| 261 | { | ||
| 262 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 335 times.
|
335 | av_assert0(idx < par->nb_subblocks); |
| 263 | 335 | return (void *)((uint8_t *)par + par->subblocks_offset + idx * par->subblock_size); | |
| 264 | } | ||
| 265 | |||
| 266 | /** | ||
| 267 | * @} | ||
| 268 | * @addtogroup lavu_iamf_audio | ||
| 269 | * @{ | ||
| 270 | */ | ||
| 271 | |||
| 272 | enum AVIAMFAmbisonicsMode { | ||
| 273 | AV_IAMF_AMBISONICS_MODE_MONO, | ||
| 274 | AV_IAMF_AMBISONICS_MODE_PROJECTION, | ||
| 275 | }; | ||
| 276 | |||
| 277 | /** | ||
| 278 | * Recon gain information for the layer is present in AVIAMFReconGain | ||
| 279 | */ | ||
| 280 | #define AV_IAMF_LAYER_FLAG_RECON_GAIN (1 << 0) | ||
| 281 | |||
| 282 | /** | ||
| 283 | * A layer defining a Channel Layout in the Audio Element. | ||
| 284 | * | ||
| 285 | * When @ref AVIAMFAudioElement.audio_element_type "the parent's Audio Element type" | ||
| 286 | * is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, this corresponds to an Scalable Channel | ||
| 287 | * Layout layer as defined in section 3.6.2 of IAMF. | ||
| 288 | * For AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, it is an Ambisonics channel | ||
| 289 | * layout as defined in section 3.6.3 of IAMF. | ||
| 290 | * | ||
| 291 | * @note The struct should be allocated with av_iamf_audio_element_add_layer() | ||
| 292 | * and its size is not a part of the public ABI. | ||
| 293 | */ | ||
| 294 | typedef struct AVIAMFLayer { | ||
| 295 | const AVClass *av_class; | ||
| 296 | |||
| 297 | AVChannelLayout ch_layout; | ||
| 298 | |||
| 299 | /** | ||
| 300 | * A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* flags. | ||
| 301 | */ | ||
| 302 | unsigned int flags; | ||
| 303 | /** | ||
| 304 | * Output gain channel flags as defined in section 3.6.2 of IAMF. | ||
| 305 | * | ||
| 306 | * This field is defined only if @ref AVIAMFAudioElement.audio_element_type | ||
| 307 | * "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, | ||
| 308 | * must be 0 otherwise. | ||
| 309 | */ | ||
| 310 | unsigned int output_gain_flags; | ||
| 311 | /** | ||
| 312 | * Output gain as defined in section 3.6.2 of IAMF. | ||
| 313 | * | ||
| 314 | * Must be 0 if @ref output_gain_flags is 0. | ||
| 315 | */ | ||
| 316 | AVRational output_gain; | ||
| 317 | /** | ||
| 318 | * Ambisonics mode as defined in section 3.6.3 of IAMF. | ||
| 319 | * | ||
| 320 | * This field is defined only if @ref AVIAMFAudioElement.audio_element_type | ||
| 321 | * "the parent's Audio Element type" is AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE. | ||
| 322 | * | ||
| 323 | * If AV_IAMF_AMBISONICS_MODE_MONO, channel_mapping is defined implicitly | ||
| 324 | * (Ambisonic Order) or explicitly (Custom Order with ambi channels) in | ||
| 325 | * @ref ch_layout. | ||
| 326 | * If AV_IAMF_AMBISONICS_MODE_PROJECTION, @ref demixing_matrix must be set. | ||
| 327 | */ | ||
| 328 | enum AVIAMFAmbisonicsMode ambisonics_mode; | ||
| 329 | |||
| 330 | /** | ||
| 331 | * Demixing matrix as defined in section 3.6.3 of IAMF. | ||
| 332 | * | ||
| 333 | * May be set only if @ref ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION, | ||
| 334 | * must be NULL otherwise. | ||
| 335 | */ | ||
| 336 | AVRational *demixing_matrix; | ||
| 337 | |||
| 338 | /** | ||
| 339 | * The length of the Demixing matrix array. Must be ch_layout.nb_channels multiplied | ||
| 340 | * by the sum of the amount of streams in the group plus the amount of streams in | ||
| 341 | * the group that are stereo. | ||
| 342 | */ | ||
| 343 | unsigned int nb_demixing_matrix; | ||
| 344 | } AVIAMFLayer; | ||
| 345 | |||
| 346 | |||
| 347 | enum AVIAMFAudioElementType { | ||
| 348 | AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, | ||
| 349 | AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, | ||
| 350 | }; | ||
| 351 | |||
| 352 | /** | ||
| 353 | * Information on how to combine one or more audio streams, as defined in | ||
| 354 | * section 3.6 of IAMF. | ||
| 355 | * | ||
| 356 | * @note The struct should be allocated with av_iamf_audio_element_alloc() | ||
| 357 | * and its size is not a part of the public ABI. | ||
| 358 | */ | ||
| 359 | typedef struct AVIAMFAudioElement { | ||
| 360 | const AVClass *av_class; | ||
| 361 | |||
| 362 | AVIAMFLayer **layers; | ||
| 363 | /** | ||
| 364 | * Number of layers, or channel groups, in the Audio Element. | ||
| 365 | * There may be 6 layers at most, and for @ref audio_element_type | ||
| 366 | * AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE, there may be exactly 1. | ||
| 367 | * | ||
| 368 | * Set by av_iamf_audio_element_add_layer(), must not be | ||
| 369 | * modified by any other code. | ||
| 370 | */ | ||
| 371 | unsigned int nb_layers; | ||
| 372 | |||
| 373 | /** | ||
| 374 | * Demixing information used to reconstruct a scalable channel audio | ||
| 375 | * representation. | ||
| 376 | * The @ref AVIAMFParamDefinition.type "type" must be | ||
| 377 | * AV_IAMF_PARAMETER_DEFINITION_DEMIXING. | ||
| 378 | */ | ||
| 379 | AVIAMFParamDefinition *demixing_info; | ||
| 380 | /** | ||
| 381 | * Recon gain information used to reconstruct a scalable channel audio | ||
| 382 | * representation. | ||
| 383 | * The @ref AVIAMFParamDefinition.type "type" must be | ||
| 384 | * AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN. | ||
| 385 | */ | ||
| 386 | AVIAMFParamDefinition *recon_gain_info; | ||
| 387 | |||
| 388 | /** | ||
| 389 | * Audio element type as defined in section 3.6 of IAMF. | ||
| 390 | */ | ||
| 391 | enum AVIAMFAudioElementType audio_element_type; | ||
| 392 | |||
| 393 | /** | ||
| 394 | * Default weight value as defined in section 3.6 of IAMF. | ||
| 395 | */ | ||
| 396 | unsigned int default_w; | ||
| 397 | } AVIAMFAudioElement; | ||
| 398 | |||
| 399 | const AVClass *av_iamf_audio_element_get_class(void); | ||
| 400 | |||
| 401 | /** | ||
| 402 | * Allocates a AVIAMFAudioElement, and initializes its fields with default values. | ||
| 403 | * No layers are allocated. Must be freed with av_iamf_audio_element_free(). | ||
| 404 | * | ||
| 405 | * @see av_iamf_audio_element_add_layer() | ||
| 406 | */ | ||
| 407 | AVIAMFAudioElement *av_iamf_audio_element_alloc(void); | ||
| 408 | |||
| 409 | /** | ||
| 410 | * Allocate a layer and add it to a given AVIAMFAudioElement. | ||
| 411 | * It is freed by av_iamf_audio_element_free() alongside the rest of the parent | ||
| 412 | * AVIAMFAudioElement. | ||
| 413 | * | ||
| 414 | * @return a pointer to the allocated layer. | ||
| 415 | */ | ||
| 416 | AVIAMFLayer *av_iamf_audio_element_add_layer(AVIAMFAudioElement *audio_element); | ||
| 417 | |||
| 418 | /** | ||
| 419 | * Free an AVIAMFAudioElement and all its contents. | ||
| 420 | * | ||
| 421 | * @param audio_element pointer to pointer to an allocated AVIAMFAudioElement. | ||
| 422 | * upon return, *audio_element will be set to NULL. | ||
| 423 | */ | ||
| 424 | void av_iamf_audio_element_free(AVIAMFAudioElement **audio_element); | ||
| 425 | |||
| 426 | /** | ||
| 427 | * @} | ||
| 428 | * @addtogroup lavu_iamf_mix | ||
| 429 | * @{ | ||
| 430 | */ | ||
| 431 | |||
| 432 | enum AVIAMFHeadphonesMode { | ||
| 433 | /** | ||
| 434 | * The referenced Audio Element shall be rendered to stereo loudspeakers. | ||
| 435 | */ | ||
| 436 | AV_IAMF_HEADPHONES_MODE_STEREO, | ||
| 437 | /** | ||
| 438 | * The referenced Audio Element shall be rendered with a binaural renderer. | ||
| 439 | */ | ||
| 440 | AV_IAMF_HEADPHONES_MODE_BINAURAL, | ||
| 441 | }; | ||
| 442 | |||
| 443 | /** | ||
| 444 | * Submix element as defined in section 3.7 of IAMF. | ||
| 445 | * | ||
| 446 | * @note The struct should be allocated with av_iamf_submix_add_element() | ||
| 447 | * and its size is not a part of the public ABI. | ||
| 448 | */ | ||
| 449 | typedef struct AVIAMFSubmixElement { | ||
| 450 | const AVClass *av_class; | ||
| 451 | |||
| 452 | /** | ||
| 453 | * The id of the Audio Element this submix element references. | ||
| 454 | */ | ||
| 455 | unsigned int audio_element_id; | ||
| 456 | |||
| 457 | /** | ||
| 458 | * Information required required for applying any processing to the | ||
| 459 | * referenced and rendered Audio Element before being summed with other | ||
| 460 | * processed Audio Elements. | ||
| 461 | * The @ref AVIAMFParamDefinition.type "type" must be | ||
| 462 | * AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN. | ||
| 463 | */ | ||
| 464 | AVIAMFParamDefinition *element_mix_config; | ||
| 465 | |||
| 466 | /** | ||
| 467 | * Default mix gain value to apply when there are no AVIAMFParamDefinition | ||
| 468 | * with @ref element_mix_config "element_mix_config's" | ||
| 469 | * @ref AVIAMFParamDefinition.parameter_id "parameter_id" available for a | ||
| 470 | * given audio frame. | ||
| 471 | */ | ||
| 472 | AVRational default_mix_gain; | ||
| 473 | |||
| 474 | /** | ||
| 475 | * A value that indicates whether the referenced channel-based Audio Element | ||
| 476 | * shall be rendered to stereo loudspeakers or spatialized with a binaural | ||
| 477 | * renderer when played back on headphones. | ||
| 478 | * If the Audio Element is not of @ref AVIAMFAudioElement.audio_element_type | ||
| 479 | * "type" AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL, then this field is undefined. | ||
| 480 | */ | ||
| 481 | enum AVIAMFHeadphonesMode headphones_rendering_mode; | ||
| 482 | |||
| 483 | /** | ||
| 484 | * A dictionary of strings describing the submix in different languages. | ||
| 485 | * Must have the same amount of entries as | ||
| 486 | * @ref AVIAMFMixPresentation.annotations "the mix's annotations", stored | ||
| 487 | * in the same order, and with the same key strings. | ||
| 488 | * | ||
| 489 | * @ref AVDictionaryEntry.key "key" is a string conforming to BCP-47 that | ||
| 490 | * specifies the language for the string stored in | ||
| 491 | * @ref AVDictionaryEntry.value "value". | ||
| 492 | */ | ||
| 493 | AVDictionary *annotations; | ||
| 494 | } AVIAMFSubmixElement; | ||
| 495 | |||
| 496 | enum AVIAMFSubmixLayoutType { | ||
| 497 | /** | ||
| 498 | * The layout follows the loudspeaker sound system convention of ITU-2051-3. | ||
| 499 | * @ref AVIAMFSubmixLayout.sound_system must be set. | ||
| 500 | */ | ||
| 501 | AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS = 2, | ||
| 502 | /** | ||
| 503 | * The layout is binaural. | ||
| 504 | * | ||
| 505 | * @note @ref AVIAMFSubmixLayout.sound_system may be set to | ||
| 506 | * AV_CHANNEL_LAYOUT_BINAURAL to simplify API usage, but it's not mandatory. | ||
| 507 | */ | ||
| 508 | AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL = 3, | ||
| 509 | }; | ||
| 510 | |||
| 511 | /** | ||
| 512 | * Submix layout as defined in section 3.7.6 of IAMF. | ||
| 513 | * | ||
| 514 | * @note The struct should be allocated with av_iamf_submix_add_layout() | ||
| 515 | * and its size is not a part of the public ABI. | ||
| 516 | */ | ||
| 517 | typedef struct AVIAMFSubmixLayout { | ||
| 518 | const AVClass *av_class; | ||
| 519 | |||
| 520 | enum AVIAMFSubmixLayoutType layout_type; | ||
| 521 | |||
| 522 | /** | ||
| 523 | * Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus | ||
| 524 | * 7.1.2ch, 3.1.2ch, and binaural. | ||
| 525 | * If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS or | ||
| 526 | * AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL, this field is undefined. | ||
| 527 | */ | ||
| 528 | AVChannelLayout sound_system; | ||
| 529 | /** | ||
| 530 | * The program integrated loudness information, as defined in | ||
| 531 | * ITU-1770-4. | ||
| 532 | */ | ||
| 533 | AVRational integrated_loudness; | ||
| 534 | /** | ||
| 535 | * The digital (sampled) peak value of the audio signal, as defined | ||
| 536 | * in ITU-1770-4. | ||
| 537 | */ | ||
| 538 | AVRational digital_peak; | ||
| 539 | /** | ||
| 540 | * The true peak of the audio signal, as defined in ITU-1770-4. | ||
| 541 | */ | ||
| 542 | AVRational true_peak; | ||
| 543 | /** | ||
| 544 | * The Dialogue loudness information, as defined in ITU-1770-4. | ||
| 545 | */ | ||
| 546 | AVRational dialogue_anchored_loudness; | ||
| 547 | /** | ||
| 548 | * The Album loudness information, as defined in ITU-1770-4. | ||
| 549 | */ | ||
| 550 | AVRational album_anchored_loudness; | ||
| 551 | } AVIAMFSubmixLayout; | ||
| 552 | |||
| 553 | /** | ||
| 554 | * Submix layout as defined in section 3.7 of IAMF. | ||
| 555 | * | ||
| 556 | * @note The struct should be allocated with av_iamf_mix_presentation_add_submix() | ||
| 557 | * and its size is not a part of the public ABI. | ||
| 558 | */ | ||
| 559 | typedef struct AVIAMFSubmix { | ||
| 560 | const AVClass *av_class; | ||
| 561 | |||
| 562 | /** | ||
| 563 | * Array of submix elements. | ||
| 564 | * | ||
| 565 | * Set by av_iamf_submix_add_element(), must not be modified by any | ||
| 566 | * other code. | ||
| 567 | */ | ||
| 568 | AVIAMFSubmixElement **elements; | ||
| 569 | /** | ||
| 570 | * Number of elements in the submix. | ||
| 571 | * | ||
| 572 | * Set by av_iamf_submix_add_element(), must not be modified by any | ||
| 573 | * other code. | ||
| 574 | */ | ||
| 575 | unsigned int nb_elements; | ||
| 576 | |||
| 577 | /** | ||
| 578 | * Array of submix layouts. | ||
| 579 | * | ||
| 580 | * Set by av_iamf_submix_add_layout(), must not be modified by any | ||
| 581 | * other code. | ||
| 582 | */ | ||
| 583 | AVIAMFSubmixLayout **layouts; | ||
| 584 | /** | ||
| 585 | * Number of layouts in the submix. | ||
| 586 | * | ||
| 587 | * Set by av_iamf_submix_add_layout(), must not be modified by any | ||
| 588 | * other code. | ||
| 589 | */ | ||
| 590 | unsigned int nb_layouts; | ||
| 591 | |||
| 592 | /** | ||
| 593 | * Information required for post-processing the mixed audio signal to | ||
| 594 | * generate the audio signal for playback. | ||
| 595 | * The @ref AVIAMFParamDefinition.type "type" must be | ||
| 596 | * AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN. | ||
| 597 | */ | ||
| 598 | AVIAMFParamDefinition *output_mix_config; | ||
| 599 | |||
| 600 | /** | ||
| 601 | * Default mix gain value to apply when there are no AVIAMFParamDefinition | ||
| 602 | * with @ref output_mix_config "output_mix_config's" | ||
| 603 | * @ref AVIAMFParamDefinition.parameter_id "parameter_id" available for a | ||
| 604 | * given audio frame. | ||
| 605 | */ | ||
| 606 | AVRational default_mix_gain; | ||
| 607 | } AVIAMFSubmix; | ||
| 608 | |||
| 609 | /** | ||
| 610 | * Information on how to render and mix one or more AVIAMFAudioElement to generate | ||
| 611 | * the final audio output, as defined in section 3.7 of IAMF. | ||
| 612 | * | ||
| 613 | * @note The struct should be allocated with av_iamf_mix_presentation_alloc() | ||
| 614 | * and its size is not a part of the public ABI. | ||
| 615 | */ | ||
| 616 | typedef struct AVIAMFMixPresentation { | ||
| 617 | const AVClass *av_class; | ||
| 618 | |||
| 619 | /** | ||
| 620 | * Array of submixes. | ||
| 621 | * | ||
| 622 | * Set by av_iamf_mix_presentation_add_submix(), must not be modified | ||
| 623 | * by any other code. | ||
| 624 | */ | ||
| 625 | AVIAMFSubmix **submixes; | ||
| 626 | /** | ||
| 627 | * Number of submixes in the presentation. | ||
| 628 | * | ||
| 629 | * Set by av_iamf_mix_presentation_add_submix(), must not be modified | ||
| 630 | * by any other code. | ||
| 631 | */ | ||
| 632 | unsigned int nb_submixes; | ||
| 633 | |||
| 634 | /** | ||
| 635 | * A dictionary of strings describing the mix in different languages. | ||
| 636 | * Must have the same amount of entries as every | ||
| 637 | * @ref AVIAMFSubmixElement.annotations "Submix element annotations", | ||
| 638 | * stored in the same order, and with the same key strings. | ||
| 639 | * | ||
| 640 | * @ref AVDictionaryEntry.key "key" is a string conforming to BCP-47 | ||
| 641 | * that specifies the language for the string stored in | ||
| 642 | * @ref AVDictionaryEntry.value "value". | ||
| 643 | */ | ||
| 644 | AVDictionary *annotations; | ||
| 645 | } AVIAMFMixPresentation; | ||
| 646 | |||
| 647 | const AVClass *av_iamf_mix_presentation_get_class(void); | ||
| 648 | |||
| 649 | /** | ||
| 650 | * Allocates a AVIAMFMixPresentation, and initializes its fields with default | ||
| 651 | * values. No submixes are allocated. | ||
| 652 | * Must be freed with av_iamf_mix_presentation_free(). | ||
| 653 | * | ||
| 654 | * @see av_iamf_mix_presentation_add_submix() | ||
| 655 | */ | ||
| 656 | AVIAMFMixPresentation *av_iamf_mix_presentation_alloc(void); | ||
| 657 | |||
| 658 | /** | ||
| 659 | * Allocate a submix and add it to a given AVIAMFMixPresentation. | ||
| 660 | * It is freed by av_iamf_mix_presentation_free() alongside the rest of the | ||
| 661 | * parent AVIAMFMixPresentation. | ||
| 662 | * | ||
| 663 | * @return a pointer to the allocated submix. | ||
| 664 | */ | ||
| 665 | AVIAMFSubmix *av_iamf_mix_presentation_add_submix(AVIAMFMixPresentation *mix_presentation); | ||
| 666 | |||
| 667 | /** | ||
| 668 | * Allocate a submix element and add it to a given AVIAMFSubmix. | ||
| 669 | * It is freed by av_iamf_mix_presentation_free() alongside the rest of the | ||
| 670 | * parent AVIAMFSubmix. | ||
| 671 | * | ||
| 672 | * @return a pointer to the allocated submix. | ||
| 673 | */ | ||
| 674 | AVIAMFSubmixElement *av_iamf_submix_add_element(AVIAMFSubmix *submix); | ||
| 675 | |||
| 676 | /** | ||
| 677 | * Allocate a submix layout and add it to a given AVIAMFSubmix. | ||
| 678 | * It is freed by av_iamf_mix_presentation_free() alongside the rest of the | ||
| 679 | * parent AVIAMFSubmix. | ||
| 680 | * | ||
| 681 | * @return a pointer to the allocated submix. | ||
| 682 | */ | ||
| 683 | AVIAMFSubmixLayout *av_iamf_submix_add_layout(AVIAMFSubmix *submix); | ||
| 684 | |||
| 685 | /** | ||
| 686 | * Free an AVIAMFMixPresentation and all its contents. | ||
| 687 | * | ||
| 688 | * @param mix_presentation pointer to pointer to an allocated AVIAMFMixPresentation. | ||
| 689 | * upon return, *mix_presentation will be set to NULL. | ||
| 690 | */ | ||
| 691 | void av_iamf_mix_presentation_free(AVIAMFMixPresentation **mix_presentation); | ||
| 692 | |||
| 693 | /** | ||
| 694 | * @} | ||
| 695 | */ | ||
| 696 | |||
| 697 | #endif /* AVUTIL_IAMF_H */ | ||
| 698 |