FFmpeg
Loading...
Searching...
No Matches
iamf_parse.c
Go to the documentation of this file.
1/*
2 * Immersive Audio Model and Formats parsing
3 * Copyright (c) 2023 James Almer <jamrial@gmail.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include "libavutil/avassert.h"
23#include "libavutil/iamf.h"
25#include "libavutil/log.h"
26#include "libavutil/mem.h"
27#include "libavcodec/get_bits.h"
28#include "libavcodec/flac.h"
29#include "libavcodec/leb.h"
31#include "libavcodec/put_bits.h"
32#include "avio_internal.h"
33#include "iamf_parse.h"
34#include "isom.h"
35
36static int opus_decoder_config(IAMFCodecConfig *codec_config,
37 AVIOContext *pb, int len)
38{
39 int ret, left = len - avio_tell(pb);
40
41 if (left < 11 || codec_config->audio_roll_distance >= 0 || left > INT_MAX - 8)
43
44 codec_config->extradata = av_malloc(left + 8);
45 if (!codec_config->extradata)
46 return AVERROR(ENOMEM);
47
48 AV_WB32A(codec_config->extradata, MKBETAG('O','p','u','s'));
49 AV_WB32A(codec_config->extradata + 4, MKBETAG('H','e','a','d'));
50 ret = ffio_read_size(pb, codec_config->extradata + 8, left);
51 if (ret < 0)
52 return ret;
53
54 codec_config->extradata_size = left + 8;
55 codec_config->sample_rate = 48000;
56
57 return 0;
58}
59
60static int aac_decoder_config(IAMFCodecConfig *codec_config,
61 AVIOContext *pb, int len, void *logctx)
62{
63 MPEG4AudioConfig cfg = { 0 };
64 int object_type_id, codec_id, stream_type;
65 int ret, tag, left;
66
67 if (codec_config->audio_roll_distance >= 0)
69
70 ff_mp4_read_descr(logctx, pb, &tag);
73
74 object_type_id = avio_r8(pb);
75 if (object_type_id != 0x40)
77
78 stream_type = avio_r8(pb);
79 if (((stream_type >> 2) != 5) || ((stream_type >> 1) & 1))
81
82 avio_skip(pb, 3); // buffer size db
83 avio_skip(pb, 4); // rc_max_rate
84 avio_skip(pb, 4); // avg bitrate
85
86 codec_id = ff_codec_get_id(ff_mp4_obj_type, object_type_id);
87 if (codec_id && codec_id != codec_config->codec_id)
89
90 left = ff_mp4_read_descr(logctx, pb, &tag);
92 !left || left > (len - avio_tell(pb)))
94
95 // We pad extradata here because avpriv_mpeg4audio_get_config2() needs it.
96 codec_config->extradata = av_malloc((size_t)left + AV_INPUT_BUFFER_PADDING_SIZE);
97 if (!codec_config->extradata)
98 return AVERROR(ENOMEM);
99
100 ret = ffio_read_size(pb, codec_config->extradata, left);
101 if (ret < 0)
102 return ret;
103 codec_config->extradata_size = left;
104 memset(codec_config->extradata + codec_config->extradata_size, 0,
106
108 codec_config->extradata_size, 1, logctx);
109 if (ret < 0)
110 return ret;
111
112 codec_config->sample_rate = cfg.sample_rate;
113 if (codec_config->sample_rate <= 0)
114 return AVERROR_INVALIDDATA;
115
116 return 0;
117}
118
119static int flac_decoder_config(IAMFCodecConfig *codec_config,
120 AVIOContext *pb, int len)
121{
122 int ret, left;
123
124 if (codec_config->audio_roll_distance)
125 return AVERROR_INVALIDDATA;
126
127 avio_skip(pb, 4); // METADATA_BLOCK_HEADER
128
129 left = len - avio_tell(pb);
131 return AVERROR_INVALIDDATA;
132
133 codec_config->extradata = av_malloc(left);
134 if (!codec_config->extradata)
135 return AVERROR(ENOMEM);
136
137 ret = ffio_read_size(pb, codec_config->extradata, left);
138 if (ret < 0)
139 return ret;
140
141 codec_config->extradata_size = left;
142 codec_config->sample_rate = AV_RB24(codec_config->extradata + 10) >> 4;
143 if (codec_config->sample_rate <= 0)
144 return AVERROR_INVALIDDATA;
145
146 return 0;
147}
148
149static int ipcm_decoder_config(IAMFCodecConfig *codec_config,
150 AVIOContext *pb, int len)
151{
152 static const enum AVCodecID sample_fmt[2][3] = {
155 };
156 int sample_format = avio_r8(pb); // 0 = BE, 1 = LE
157 int sample_size = (avio_r8(pb) / 8 - 2); // 16, 24, 32
158 if (sample_format > 1 || sample_size > 2U || codec_config->audio_roll_distance)
159 return AVERROR_INVALIDDATA;
160
161 codec_config->sample_rate = avio_rb32(pb);
162 if (codec_config->sample_rate <= 0)
163 return AVERROR_INVALIDDATA;
164
165 codec_config->codec_id = sample_fmt[sample_format][sample_size];
166
167 if (len - avio_tell(pb))
168 return AVERROR_INVALIDDATA;
169
170 return 0;
171}
172
173static int codec_config_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
174{
175 IAMFCodecConfig **tmp, *codec_config = NULL;
177 AVIOContext *pbc;
178 uint8_t *buf;
179 enum AVCodecID avcodec_id;
180 unsigned codec_config_id, nb_samples, codec_id;
181 int16_t audio_roll_distance;
182 int ret;
183
184 buf = av_malloc(len);
185 if (!buf)
186 return AVERROR(ENOMEM);
187
188 ret = ffio_read_size(pb, buf, len);
189 if (ret < 0)
190 goto fail;
191
192 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
193 pbc = &b.pub;
194
195 codec_config_id = ffio_read_leb(pbc);
196 codec_id = avio_rb32(pbc);
197 nb_samples = ffio_read_leb(pbc);
198 audio_roll_distance = avio_rb16(pbc);
199
200 switch(codec_id) {
201 case MKBETAG('O','p','u','s'):
202 avcodec_id = AV_CODEC_ID_OPUS;
203 break;
204 case MKBETAG('m','p','4','a'):
205 avcodec_id = AV_CODEC_ID_AAC;
206 break;
207 case MKBETAG('f','L','a','C'):
208 avcodec_id = AV_CODEC_ID_FLAC;
209 break;
210 default:
211 avcodec_id = AV_CODEC_ID_NONE;
212 break;
213 }
214
215 for (int i = 0; i < c->nb_codec_configs; i++)
216 if (c->codec_configs[i]->codec_config_id == codec_config_id) {
218 goto fail;
219 }
220
221 tmp = av_realloc_array(c->codec_configs, c->nb_codec_configs + 1, sizeof(*c->codec_configs));
222 if (!tmp) {
223 ret = AVERROR(ENOMEM);
224 goto fail;
225 }
226 c->codec_configs = tmp;
227
228 codec_config = av_mallocz(sizeof(*codec_config));
229 if (!codec_config) {
230 ret = AVERROR(ENOMEM);
231 goto fail;
232 }
233
234 codec_config->codec_config_id = codec_config_id;
235 codec_config->codec_id = avcodec_id;
236 codec_config->nb_samples = nb_samples;
237 codec_config->audio_roll_distance = audio_roll_distance;
238
239 switch(codec_id) {
240 case MKBETAG('O','p','u','s'):
241 ret = opus_decoder_config(codec_config, pbc, len);
242 break;
243 case MKBETAG('m','p','4','a'):
244 ret = aac_decoder_config(codec_config, pbc, len, s);
245 break;
246 case MKBETAG('f','L','a','C'):
247 ret = flac_decoder_config(codec_config, pbc, len);
248 break;
249 case MKBETAG('i','p','c','m'):
250 ret = ipcm_decoder_config(codec_config, pbc, len);
251 break;
252 default:
253 break;
254 }
255 if (ret < 0)
256 goto fail;
257
258 if ((codec_config->nb_samples > INT_MAX) || codec_config->nb_samples <= 0 ||
259 (-codec_config->audio_roll_distance > INT_MAX / codec_config->nb_samples)) {
261 goto fail;
262 }
263
264 c->codec_configs[c->nb_codec_configs++] = codec_config;
265
266 len -= avio_tell(pbc);
267 if (len)
268 av_log(s, AV_LOG_WARNING, "Underread in codec_config_obu. %d bytes left at the end\n", len);
269
270 ret = 0;
271fail:
272 av_free(buf);
273 if (ret < 0) {
274 if (codec_config)
275 av_free(codec_config->extradata);
276 av_free(codec_config);
277 }
278 return ret;
279}
280
282{
283 GetBitContext gb;
284 PutBitContext pb;
285 int ret;
286
287 switch(codecpar->codec_id) {
288 case AV_CODEC_ID_OPUS:
289 AV_WB8(codecpar->extradata + 9, codecpar->ch_layout.nb_channels);
290 AV_WL16A(codecpar->extradata + 10, AV_RB16A(codecpar->extradata + 10)); // Byte swap pre-skip
291 AV_WL32A(codecpar->extradata + 12, AV_RB32A(codecpar->extradata + 12)); // Byte swap sample rate
292 AV_WL16A(codecpar->extradata + 16, AV_RB16A(codecpar->extradata + 16)); // Byte swap Output Gain
293 break;
294 case AV_CODEC_ID_AAC: {
295 uint8_t buf[6];
296 int size = FFMIN(codecpar->extradata_size, sizeof(buf));
297
298 init_put_bits(&pb, buf, sizeof(buf));
299 ret = init_get_bits8(&gb, codecpar->extradata, size);
300 if (ret < 0)
301 return ret;
302
303 ret = get_bits(&gb, 5);
304 put_bits(&pb, 5, ret);
305 if (ret == AOT_ESCAPE) // violates section 3.11.2, but better check for it
306 put_bits(&pb, 6, get_bits(&gb, 6));
307 ret = get_bits(&gb, 4);
308 put_bits(&pb, 4, ret);
309 if (ret == 0x0f)
310 put_bits(&pb, 24, get_bits(&gb, 24));
311
312 skip_bits(&gb, 4);
313 put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set channel config
314 ret = get_bits_left(&gb);
315 if (ret < 0)
316 return AVERROR_INVALIDDATA;
317 ret = FFMIN(ret, put_bits_left(&pb));
318 while (ret >= 32) {
319 put_bits32(&pb, get_bits_long(&gb, 32));
320 ret -= 32;
321 }
322 put_bits(&pb, ret, get_bits_long(&gb, ret));
323 flush_put_bits(&pb);
324
325 memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
326 break;
327 }
328 case AV_CODEC_ID_FLAC: {
329 uint8_t buf[13];
330 int size = FFMIN(codecpar->extradata_size, sizeof(buf));
331
332 init_put_bits(&pb, buf, sizeof(buf));
333 ret = init_get_bits8(&gb, codecpar->extradata, size);
334 if (ret < 0)
335 return ret;
336
337 put_bits32(&pb, get_bits_long(&gb, 32)); // min/max blocksize
338 put_bits63(&pb, 48, get_bits64(&gb, 48)); // min/max framesize
339 put_bits(&pb, 20, get_bits(&gb, 20)); // samplerate
340 skip_bits(&gb, 3);
341 put_bits(&pb, 3, codecpar->ch_layout.nb_channels - 1);
342 ret = get_bits_left(&gb);
343 if (ret < 0)
344 return AVERROR_INVALIDDATA;
345 ret = FFMIN(ret, put_bits_left(&pb));
346 put_bits(&pb, ret, get_bits(&gb, ret));
347 flush_put_bits(&pb);
348
349 memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
350 break;
351 }
352 }
353
354 return 0;
355}
356
358{
359 if (in->u.mask & AV_CH_LAYOUT_STEREO) {
360 out->u.map[n++].id = AV_CHAN_FRONT_LEFT;
361 out->u.map[n++].id = AV_CHAN_FRONT_RIGHT;
364 out->u.map[n++].id = AV_CHAN_FRONT_LEFT_OF_CENTER;
365 out->u.map[n++].id = AV_CHAN_FRONT_RIGHT_OF_CENTER;
367 } else if (in->u.mask & (AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)) {
368 out->u.map[n++].id = AV_CHAN_SIDE_LEFT;
369 out->u.map[n++].id = AV_CHAN_SIDE_RIGHT;
371 } else if (in->u.mask & (AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)) {
372 out->u.map[n++].id = AV_CHAN_BACK_LEFT;
373 out->u.map[n++].id = AV_CHAN_BACK_RIGHT;
376 out->u.map[n++].id = AV_CHAN_TOP_FRONT_LEFT;
377 out->u.map[n++].id = AV_CHAN_TOP_FRONT_RIGHT;
379 } else if (in->u.mask & (AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT)) {
380 out->u.map[n++].id = AV_CHAN_TOP_SIDE_LEFT;
381 out->u.map[n++].id = AV_CHAN_TOP_SIDE_RIGHT;
383 } else if (in->u.mask & (AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)) {
384 out->u.map[n++].id = AV_CHAN_TOP_BACK_LEFT;
385 out->u.map[n++].id = AV_CHAN_TOP_BACK_RIGHT;
387 }
388
389 return n;
390}
391
393 IAMFAudioElement *audio_element,
394 const IAMFCodecConfig *codec_config)
395{
396 int nb_layers, k = 0;
397
398 nb_layers = avio_r8(pb) >> 5; // get_bits(&gb, 3);
399 // skip_bits(&gb, 5); //reserved
400
401 if (nb_layers > 6 || nb_layers == 0)
402 return AVERROR_INVALIDDATA;
403
404 audio_element->layers = av_calloc(nb_layers, sizeof(*audio_element->layers));
405 if (!audio_element->layers)
406 return AVERROR(ENOMEM);
407
408 audio_element->nb_layers = nb_layers;
409 for (int i = 0, n = 0; i < nb_layers; i++) {
410 AVChannelLayout ch_layout = { 0 };
411 AVIAMFLayer *layer;
412 int loudspeaker_layout, output_gain_is_present_flag;
413 int substream_count, coupled_substream_count;
414 int expanded_loudspeaker_layout = -1;
415 int ret, byte = avio_r8(pb);
416 int channels;
417
418 layer = av_iamf_audio_element_add_layer(audio_element->element);
419 if (!layer)
420 return AVERROR(ENOMEM);
421
422 loudspeaker_layout = byte >> 4; // get_bits(&gb, 4);
423 output_gain_is_present_flag = (byte >> 3) & 1; //get_bits1(&gb);
424 if ((byte >> 2) & 1)
426 substream_count = avio_r8(pb);
427 coupled_substream_count = avio_r8(pb);
428
429 if (!substream_count || coupled_substream_count > substream_count ||
430 substream_count + k > audio_element->nb_substreams)
431 return AVERROR_INVALIDDATA;
432
433 audio_element->layers[i].substream_count = substream_count;
434 audio_element->layers[i].coupled_substream_count = coupled_substream_count;
435 if (output_gain_is_present_flag) {
436 layer->output_gain_flags = avio_r8(pb) >> 2; // get_bits(&gb, 6);
437 layer->output_gain = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);
438 }
439
440 if (loudspeaker_layout == 15) {
441 if (i) {
442 av_log(s, AV_LOG_ERROR, "expanded_loudspeaker_layout set with more than one layer in Audio Element #%d\n",
443 audio_element->audio_element_id);
444 return AVERROR_INVALIDDATA;
445 }
446 expanded_loudspeaker_layout = avio_r8(pb);
447 }
448 if (expanded_loudspeaker_layout >= 0 && expanded_loudspeaker_layout < 13) {
449 av_channel_layout_copy(&ch_layout, &ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]);
450 } else if (loudspeaker_layout < 10) {
451 av_channel_layout_copy(&ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
452 if (i) {
453 uint64_t mask = av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, UINT64_MAX);
454 // When the first layer is Mono, the second layer may not have the C channel (e.g. Stereo)
455 if (audio_element->element->layers[i-1]->ch_layout.nb_channels == 1)
456 n--;
457 else if ((ch_layout.u.mask & mask) != mask)
458 return AVERROR_INVALIDDATA;
459 ch_layout.u.mask &= ~mask;
460 }
461 } else {
462 if (expanded_loudspeaker_layout >= 0)
463 avpriv_request_sample(s, "expanded_loudspeaker_layout %d", expanded_loudspeaker_layout);
464 else
465 avpriv_request_sample(s, "loudspeaker_layout %d", loudspeaker_layout);
467 }
468
469 channels = ch_layout.nb_channels;
470 if (i) {
471 if (ch_layout.nb_channels <= audio_element->element->layers[i-1]->ch_layout.nb_channels)
472 return AVERROR_INVALIDDATA;
473 channels -= audio_element->element->layers[i-1]->ch_layout.nb_channels;
474 }
475 if (channels != substream_count + coupled_substream_count)
476 return AVERROR_INVALIDDATA;
477
478 for (int j = 0; j < substream_count; j++) {
479 IAMFSubStream *substream = &audio_element->substreams[k++];
480
481 substream->codecpar->ch_layout = coupled_substream_count-- > 0 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO :
483
484 ret = update_extradata(substream->codecpar);
485 if (ret < 0)
486 return ret;
487 }
488
490 if (ret < 0)
491 return ret;
492 for (int j = 0; j < n; j++)
493 layer->ch_layout.u.map[j].id = av_channel_layout_channel_from_index(&audio_element->element->layers[i-1]->ch_layout, j);
494
495 coupled_substream_count = audio_element->layers[i].coupled_substream_count;
496 while (coupled_substream_count--) {
497 n = parse_coupled_substream(&layer->ch_layout, &ch_layout, n);
498 }
499
500 substream_count -= audio_element->layers[i].coupled_substream_count;
501 n = parse_coupled_substream(&layer->ch_layout, &ch_layout, n); // In case the first layer is Mono
502 while (substream_count--) {
503 if (ch_layout.u.mask & AV_CH_FRONT_CENTER) {
504 layer->ch_layout.u.map[n++].id = AV_CHAN_FRONT_CENTER;
505 ch_layout.u.mask &= ~AV_CH_FRONT_CENTER;
506 }
507 if (ch_layout.u.mask & AV_CH_LOW_FREQUENCY) {
508 layer->ch_layout.u.map[n++].id = AV_CHAN_LOW_FREQUENCY;
509 ch_layout.u.mask &= ~AV_CH_LOW_FREQUENCY;
510 }
511 }
512
513 if (n != ch_layout.nb_channels)
514 return AVERROR_INVALIDDATA;
515
517 if (ret < 0 && ret != AVERROR(ENOSYS))
518 return ret;
519 }
520
521 if (k != audio_element->nb_substreams)
522 return AVERROR_INVALIDDATA;
523
524 return 0;
525}
526
527static int ambisonics_config(void *s, AVIOContext *pb,
528 IAMFAudioElement *audio_element,
529 const IAMFCodecConfig *codec_config)
530{
531 AVIAMFLayer *layer;
532 unsigned ambisonics_mode;
533 int output_channel_count, substream_count, order;
534 int ret;
535
536 ambisonics_mode = ffio_read_leb(pb);
537 if (ambisonics_mode > 1)
538 return AVERROR_INVALIDDATA;
539
540 output_channel_count = avio_r8(pb); // C
541 substream_count = avio_r8(pb); // N
542 if (audio_element->nb_substreams != substream_count || output_channel_count == 0)
543 return AVERROR_INVALIDDATA;
544
545 order = floor(sqrt(output_channel_count - 1));
546 /* incomplete order - some harmonics are missing */
547 if ((order + 1) * (order + 1) != output_channel_count)
548 return AVERROR_INVALIDDATA;
549
550 audio_element->layers = av_mallocz(sizeof(*audio_element->layers));
551 if (!audio_element->layers)
552 return AVERROR(ENOMEM);
553
554 audio_element->nb_layers = 1;
555 audio_element->layers->substream_count = substream_count;
556
557 layer = av_iamf_audio_element_add_layer(audio_element->element);
558 if (!layer)
559 return AVERROR(ENOMEM);
560
561 layer->ambisonics_mode = ambisonics_mode;
562 if (ambisonics_mode == 0) {
563 for (int i = 0; i < substream_count; i++) {
564 IAMFSubStream *substream = &audio_element->substreams[i];
565
567
568 ret = update_extradata(substream->codecpar);
569 if (ret < 0)
570 return ret;
571 }
572
573 ret = av_channel_layout_custom_init(&layer->ch_layout, output_channel_count);
574 if (ret < 0)
575 return ret;
576
577 for (int i = 0; i < output_channel_count; i++)
579
581 if (ret < 0 && ret != AVERROR(ENOSYS))
582 return ret;
583 } else {
584 int coupled_substream_count = avio_r8(pb); // M
585 int count = substream_count + coupled_substream_count;
586 int nb_demixing_matrix = count * output_channel_count;
587
588 audio_element->layers->coupled_substream_count = coupled_substream_count;
589
590 layer->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = output_channel_count };
591 layer->demixing_matrix = av_malloc_array(nb_demixing_matrix, sizeof(*layer->demixing_matrix));
592 if (!layer->demixing_matrix)
593 return AVERROR(ENOMEM);
594
595 layer->nb_demixing_matrix = nb_demixing_matrix;
596
597 for (int i = 0; i < layer->nb_demixing_matrix; i++)
598 layer->demixing_matrix[i] = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 15);
599
600 for (int i = 0; i < substream_count; i++) {
601 IAMFSubStream *substream = &audio_element->substreams[i];
602
603 substream->codecpar->ch_layout = coupled_substream_count-- > 0 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO :
605
606
607 ret = update_extradata(substream->codecpar);
608 if (ret < 0)
609 return ret;
610 }
611 }
612
613 return 0;
614}
615
616static int param_parse(void *s, IAMFContext *c, AVIOContext *pb,
617 unsigned int type,
618 const IAMFAudioElement *audio_element,
619 const IAMFCodecConfig *codec_config,
620 AVIAMFParamDefinition **out_param_definition)
621{
624 unsigned int parameter_id, parameter_rate, mode;
625 unsigned int duration = 0, constant_subblock_duration = 0, nb_subblocks = 0;
626 unsigned int total_duration = 0;
627 size_t param_size;
628
629 parameter_id = ffio_read_leb(pb);
630
631 for (int i = 0; i < c->nb_param_definitions; i++)
632 if (c->param_definitions[i]->param->parameter_id == parameter_id) {
633 param_definition = c->param_definitions[i];
634 break;
635 }
636
637 parameter_rate = ffio_read_leb(pb);
638 if (!parameter_rate)
639 return AVERROR_INVALIDDATA;
640 mode = avio_r8(pb) >> 7;
641
642 if (mode == 0) {
644 if (!duration || duration > av_rescale(codec_config->nb_samples,
645 codec_config->sample_rate, parameter_rate)) {
646 av_log(s, AV_LOG_ERROR, "Invalid block duration in parameter_id %u\n", parameter_id);
647 return AVERROR_INVALIDDATA;
648 }
649 constant_subblock_duration = ffio_read_leb(pb);
650 if (constant_subblock_duration == 0)
651 nb_subblocks = ffio_read_leb(pb);
652 else {
653 if (constant_subblock_duration > duration) {
654 av_log(s, AV_LOG_ERROR, "Invalid block duration in parameter_id %u\n", parameter_id);
655 return AVERROR_INVALIDDATA;
656 }
657 nb_subblocks = duration / constant_subblock_duration;
658 total_duration = duration;
659 }
660 }
661
662 if (nb_subblocks > duration) {
663 av_log(s, AV_LOG_ERROR, "Invalid duration or subblock count in parameter_id %u\n", parameter_id);
664 return AVERROR_INVALIDDATA;
665 }
666
667 param = av_iamf_param_definition_alloc(type, nb_subblocks, &param_size);
668 if (!param)
669 return AVERROR(ENOMEM);
670
671 for (int i = 0; i < nb_subblocks; i++) {
672 void *subblock = av_iamf_param_definition_get_subblock(param, i);
673 unsigned int subblock_duration = constant_subblock_duration;
674
675 if (constant_subblock_duration == 0) {
676 subblock_duration = ffio_read_leb(pb);
677 if (subblock_duration > duration - total_duration) {
678 av_log(s, AV_LOG_ERROR, "Invalid subblock durations in parameter_id %u\n", parameter_id);
679 av_free(param);
680 return AVERROR_INVALIDDATA;
681 }
682 total_duration += subblock_duration;
683 } else if (i == nb_subblocks - 1)
684 subblock_duration = duration - i * constant_subblock_duration;
685
686 switch (type) {
688 AVIAMFMixGain *mix = subblock;
689 mix->subblock_duration = subblock_duration;
690 break;
691 }
693 AVIAMFDemixingInfo *demix = subblock;
694 demix->subblock_duration = subblock_duration;
695 // DefaultDemixingInfoParameterData
696 av_assert0(audio_element);
697 demix->dmixp_mode = avio_r8(pb) >> 5;
698 audio_element->element->default_w = avio_r8(pb) >> 4;
699 break;
700 }
702 AVIAMFReconGain *recon = subblock;
703 recon->subblock_duration = subblock_duration;
704 break;
705 }
706 default:
707 av_free(param);
708 return AVERROR_INVALIDDATA;
709 }
710 }
711
712 if (!mode && !constant_subblock_duration && total_duration != duration) {
713 av_log(s, AV_LOG_ERROR, "Invalid subblock durations in parameter_id %u\n", parameter_id);
714 av_free(param);
715 return AVERROR_INVALIDDATA;
716 }
717
718 param->parameter_id = parameter_id;
719 param->parameter_rate = parameter_rate;
720 param->duration = duration;
721 param->constant_subblock_duration = constant_subblock_duration;
722 param->nb_subblocks = nb_subblocks;
723
724 if (param_definition) {
725 if (param_definition->param_size != param_size || memcmp(param_definition->param, param, param_size)) {
726 av_log(s, AV_LOG_ERROR, "Inconsistent parameters for parameter_id %u\n", parameter_id);
727 av_free(param);
728 return AVERROR_INVALIDDATA;
729 }
730 } else {
731 IAMFParamDefinition **tmp = av_realloc_array(c->param_definitions, c->nb_param_definitions + 1,
732 sizeof(*c->param_definitions));
733 if (!tmp) {
734 av_free(param);
735 return AVERROR(ENOMEM);
736 }
737 c->param_definitions = tmp;
738
740 if (!param_definition) {
741 av_free(param);
742 return AVERROR(ENOMEM);
743 }
744 param_definition->param = param;
745 param_definition->mode = !mode;
746 param_definition->param_size = param_size;
747 param_definition->audio_element = audio_element;
748
749 c->param_definitions[c->nb_param_definitions++] = param_definition;
750 }
751
752 av_assert0(out_param_definition);
753 *out_param_definition = param;
754
755 return 0;
756}
757
758static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
759{
760 const IAMFCodecConfig *codec_config;
761 AVIAMFAudioElement *element;
762 IAMFAudioElement **tmp, *audio_element = NULL;
764 AVIOContext *pbc;
765 uint8_t *buf;
766 unsigned audio_element_id, nb_substreams, codec_config_id, num_parameters;
767 int audio_element_type, ret;
768
769 buf = av_malloc(len);
770 if (!buf)
771 return AVERROR(ENOMEM);
772
773 ret = ffio_read_size(pb, buf, len);
774 if (ret < 0)
775 goto fail;
776
777 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
778 pbc = &b.pub;
779
780 audio_element_id = ffio_read_leb(pbc);
781
782 for (int i = 0; i < c->nb_audio_elements; i++)
783 if (c->audio_elements[i]->audio_element_id == audio_element_id) {
784 av_log(s, AV_LOG_ERROR, "Duplicate audio_element_id %d\n", audio_element_id);
786 goto fail;
787 }
788
789 audio_element_type = avio_r8(pbc) >> 5;
790 if (audio_element_type > AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
791 av_log(s, AV_LOG_DEBUG, "Unknown audio_element_type referenced in an audio element. Ignoring\n");
792 ret = 0;
793 goto fail;
794 }
795
796 codec_config_id = ffio_read_leb(pbc);
797
798 codec_config = ff_iamf_get_codec_config(c, codec_config_id);
799 if (!codec_config) {
800 av_log(s, AV_LOG_ERROR, "Non existent codec config id %d referenced in an audio element\n", codec_config_id);
802 goto fail;
803 }
804
805 if (codec_config->codec_id == AV_CODEC_ID_NONE) {
806 av_log(s, AV_LOG_DEBUG, "Unknown codec id referenced in an audio element. Ignoring\n");
807 ret = 0;
808 goto fail;
809 }
810
811 tmp = av_realloc_array(c->audio_elements, c->nb_audio_elements + 1, sizeof(*c->audio_elements));
812 if (!tmp) {
813 ret = AVERROR(ENOMEM);
814 goto fail;
815 }
816 c->audio_elements = tmp;
817
818 audio_element = av_mallocz(sizeof(*audio_element));
819 if (!audio_element) {
820 ret = AVERROR(ENOMEM);
821 goto fail;
822 }
823
824 nb_substreams = ffio_read_leb(pbc);
825 /* Each substream consumes at least one byte (its leb128 id) from the
826 * remaining OBU buffer, so a count larger than that cannot be valid and
827 * would only serve to force an oversized allocation. */
828 if (nb_substreams > len - avio_tell(pbc) || !nb_substreams) {
830 goto fail;
831 }
832 audio_element->codec_config_id = codec_config_id;
833 audio_element->audio_element_id = audio_element_id;
834 audio_element->substreams = av_calloc(nb_substreams, sizeof(*audio_element->substreams));
835 if (!audio_element->substreams) {
836 ret = AVERROR(ENOMEM);
837 goto fail;
838 }
839 audio_element->nb_substreams = nb_substreams;
840
841 element = audio_element->element = av_iamf_audio_element_alloc();
842 if (!element) {
843 ret = AVERROR(ENOMEM);
844 goto fail;
845 }
846 audio_element->celement = element;
847
848 element->audio_element_type = audio_element_type;
849
850 for (int i = 0; i < audio_element->nb_substreams; i++) {
851 IAMFSubStream *substream = &audio_element->substreams[i];
852
853 substream->codecpar = avcodec_parameters_alloc();
854 if (!substream->codecpar) {
855 ret = AVERROR(ENOMEM);
856 goto fail;
857 }
858
859 substream->audio_substream_id = ffio_read_leb(pbc);
860
862 substream->codecpar->codec_id = codec_config->codec_id;
863 substream->codecpar->frame_size = codec_config->nb_samples;
864 substream->codecpar->sample_rate = codec_config->sample_rate;
865 substream->codecpar->seek_preroll = -codec_config->audio_roll_distance * codec_config->nb_samples;
866
867 switch(substream->codecpar->codec_id) {
868 case AV_CODEC_ID_AAC:
869 case AV_CODEC_ID_FLAC:
870 case AV_CODEC_ID_OPUS:
872 if (!substream->codecpar->extradata) {
873 ret = AVERROR(ENOMEM);
874 goto fail;
875 }
876 memcpy(substream->codecpar->extradata, codec_config->extradata, codec_config->extradata_size);
877 memset(substream->codecpar->extradata + codec_config->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
878 substream->codecpar->extradata_size = codec_config->extradata_size;
879 break;
880 }
881 }
882
883 num_parameters = ffio_read_leb(pbc);
884 if (num_parameters > 2 && audio_element_type == 0) {
885 av_log(s, AV_LOG_ERROR, "Audio Element parameter count %u is invalid"
886 " for Channel representations\n", num_parameters);
888 goto fail;
889 }
890 if (num_parameters && audio_element_type != 0) {
891 av_log(s, AV_LOG_ERROR, "Audio Element parameter count %u is invalid"
892 " for Scene representations\n", num_parameters);
894 goto fail;
895 }
896
897 for (int i = 0; i < num_parameters; i++) {
898 unsigned type;
899
900 type = ffio_read_leb(pbc);
904 if (element->demixing_info) {
906 goto fail;
907 }
908 ret = param_parse(s, c, pbc, type,
909 audio_element, codec_config,
910 &element->demixing_info);
912 if (element->recon_gain_info) {
914 goto fail;
915 }
916 ret = param_parse(s, c, pbc, type,
917 audio_element, codec_config,
918 &element->recon_gain_info);
919 } else {
920 unsigned param_definition_size = ffio_read_leb(pbc);
921 avio_skip(pbc, param_definition_size);
922 }
923 if (ret < 0)
924 goto fail;
925 }
926
927 if (audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL) {
928 ret = scalable_channel_layout_config(s, pbc, audio_element, codec_config);
929 if (ret < 0)
930 goto fail;
931 } else if (audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
932 ret = ambisonics_config(s, pbc, audio_element, codec_config);
933 if (ret < 0)
934 goto fail;
935 } else {
936 av_unreachable("audio_element_type should have been checked above");
937 }
938
939 c->audio_elements[c->nb_audio_elements++] = audio_element;
940
941 len -= avio_tell(pbc);
942 if (len)
943 av_log(s, AV_LOG_WARNING, "Underread in audio_element_obu. %d bytes left at the end\n", len);
944
945 ret = 0;
946fail:
947 av_free(buf);
948 if (ret < 0)
949 ff_iamf_free_audio_element(&audio_element);
950 return ret;
951}
952
953static int label_string(AVIOContext *pb, char **label)
954{
955 uint8_t buf[128];
956
957 avio_get_str(pb, sizeof(buf), buf, sizeof(buf));
958
959 if (pb->error)
960 return pb->error;
961 if (pb->eof_reached)
962 return AVERROR_INVALIDDATA;
963 *label = av_strdup(buf);
964 if (!*label)
965 return AVERROR(ENOMEM);
966
967 return 0;
968}
969
970static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
971{
973 const IAMFCodecConfig *codec_config = NULL;
974 IAMFMixPresentation **tmp, *mix_presentation = NULL;
976 AVIOContext *pbc;
977 uint8_t *buf;
978 unsigned nb_submixes, mix_presentation_id;
979 int ret;
980
981 buf = av_malloc(len);
982 if (!buf)
983 return AVERROR(ENOMEM);
984
985 ret = ffio_read_size(pb, buf, len);
986 if (ret < 0)
987 goto fail;
988
989 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
990 pbc = &b.pub;
991
992 mix_presentation_id = ffio_read_leb(pbc);
993
994 for (int i = 0; i < c->nb_mix_presentations; i++)
995 if (c->mix_presentations[i]->mix_presentation_id == mix_presentation_id) {
996 av_log(s, AV_LOG_ERROR, "Duplicate mix_presentation_id %d\n", mix_presentation_id);
998 goto fail;
999 }
1000
1001 tmp = av_realloc_array(c->mix_presentations, c->nb_mix_presentations + 1, sizeof(*c->mix_presentations));
1002 if (!tmp) {
1003 ret = AVERROR(ENOMEM);
1004 goto fail;
1005 }
1006 c->mix_presentations = tmp;
1007
1008 mix_presentation = av_mallocz(sizeof(*mix_presentation));
1009 if (!mix_presentation) {
1010 ret = AVERROR(ENOMEM);
1011 goto fail;
1012 }
1013
1014 mix_presentation->mix_presentation_id = mix_presentation_id;
1015 mix = mix_presentation->mix = av_iamf_mix_presentation_alloc();
1016 if (!mix) {
1017 ret = AVERROR(ENOMEM);
1018 goto fail;
1019 }
1020 mix_presentation->cmix = mix;
1021
1022 mix_presentation->count_label = ffio_read_leb(pbc);
1023 if (mix_presentation->count_label > len - avio_tell(pbc)) {
1024 mix_presentation->count_label = 0;
1026 goto fail;
1027 }
1028 mix_presentation->language_label = av_calloc(mix_presentation->count_label,
1029 sizeof(*mix_presentation->language_label));
1030 if (!mix_presentation->language_label) {
1031 mix_presentation->count_label = 0;
1032 ret = AVERROR(ENOMEM);
1033 goto fail;
1034 }
1035
1036 for (int i = 0; i < mix_presentation->count_label; i++) {
1037 ret = label_string(pbc, &mix_presentation->language_label[i]);
1038 if (ret < 0)
1039 goto fail;
1040 }
1041
1042 for (int i = 0; i < mix_presentation->count_label; i++) {
1043 char *annotation = NULL;
1044 ret = label_string(pbc, &annotation);
1045 if (ret < 0)
1046 goto fail;
1047 ret = av_dict_set(&mix->annotations, mix_presentation->language_label[i], annotation,
1049 if (ret < 0)
1050 goto fail;
1051 }
1052
1053 nb_submixes = ffio_read_leb(pbc);
1054 if (!nb_submixes) {
1055 av_log(s, AV_LOG_ERROR, "Mix presentation %u has no submixes\n", mix_presentation_id);
1057 goto fail;
1058 }
1059
1060 for (int i = 0; i < nb_submixes; i++) {
1061 AVIAMFSubmix *sub_mix;
1062 unsigned nb_elements, nb_layouts;
1063
1065 if (!sub_mix) {
1066 ret = AVERROR(ENOMEM);
1067 goto fail;
1068 }
1069
1070 nb_elements = ffio_read_leb(pbc);
1071 if (!nb_elements) {
1072 av_log(s, AV_LOG_ERROR, "Submix %d from Mix presentation %u has no audio elements\n",
1073 i, mix_presentation_id);
1075 goto fail;
1076 }
1077
1078 for (int j = 0; j < nb_elements; j++) {
1079 AVIAMFSubmixElement *submix_element;
1080 IAMFAudioElement *audio_element = NULL;
1081 const IAMFCodecConfig *config = NULL;
1082 unsigned int rendering_config_extension_size;
1083
1084 submix_element = av_iamf_submix_add_element(sub_mix);
1085 if (!submix_element) {
1086 ret = AVERROR(ENOMEM);
1087 goto fail;
1088 }
1089
1090 submix_element->audio_element_id = ffio_read_leb(pbc);
1091
1092 for (int k = 0; k < c->nb_audio_elements; k++)
1093 if (c->audio_elements[k]->audio_element_id == submix_element->audio_element_id) {
1094 audio_element = c->audio_elements[k];
1095 break;
1096 }
1097
1098 if (!audio_element) {
1099 av_log(s, AV_LOG_ERROR, "Invalid Audio Element with id %u referenced by Mix Parameters %u\n",
1100 submix_element->audio_element_id, mix_presentation_id);
1102 goto fail;
1103 }
1104 config = ff_iamf_get_codec_config(c, audio_element->codec_config_id);
1105
1106 for (int k = 0; k < mix_presentation->count_label; k++) {
1107 char *annotation = NULL;
1108 ret = label_string(pbc, &annotation);
1109 if (ret < 0)
1110 goto fail;
1111 ret = av_dict_set(&submix_element->annotations, mix_presentation->language_label[k], annotation,
1113 if (ret < 0)
1114 goto fail;
1115 }
1116
1117 submix_element->headphones_rendering_mode = avio_r8(pbc) >> 6;
1118
1119 rendering_config_extension_size = ffio_read_leb(pbc);
1120 avio_skip(pbc, rendering_config_extension_size);
1121
1123 audio_element, config,
1124 &submix_element->element_mix_config);
1125 if (ret < 0)
1126 goto fail;
1127 submix_element->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1128
1129 if (!codec_config || (config->nb_samples >
1130 av_rescale(codec_config->nb_samples,
1131 codec_config->sample_rate,
1132 config->sample_rate)))
1133 codec_config = config;
1134 }
1135
1137 NULL, codec_config,
1138 &sub_mix->output_mix_config);
1139 if (ret < 0)
1140 goto fail;
1141 sub_mix->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1142
1143 nb_layouts = ffio_read_leb(pbc);
1144 for (int j = 0; j < nb_layouts; j++) {
1145 AVIAMFSubmixLayout *submix_layout;
1146 int info_type;
1147 int byte = avio_r8(pbc);
1148
1149 submix_layout = av_iamf_submix_add_layout(sub_mix);
1150 if (!submix_layout) {
1151 ret = AVERROR(ENOMEM);
1152 goto fail;
1153 }
1154
1155 submix_layout->layout_type = byte >> 6;
1158 av_log(s, AV_LOG_ERROR, "Invalid Layout type %u in a submix from Mix Presentation %u\n",
1159 submix_layout->layout_type, mix_presentation_id);
1161 goto fail;
1162 }
1163 if (submix_layout->layout_type == 2) {
1164 int sound_system;
1165 sound_system = (byte >> 2) & 0xF;
1166 if (sound_system >= FF_ARRAY_ELEMS(ff_iamf_sound_system_map)) {
1168 goto fail;
1169 }
1170 av_channel_layout_copy(&submix_layout->sound_system, &ff_iamf_sound_system_map[sound_system].layout);
1171 } else
1173
1174 info_type = avio_r8(pbc);
1175 submix_layout->integrated_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1176 submix_layout->digital_peak = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1177
1178 if (info_type & 1)
1179 submix_layout->true_peak = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1180 if (info_type & 2) {
1181 unsigned int num_anchored_loudness = avio_r8(pbc);
1182
1183 for (int k = 0; k < num_anchored_loudness; k++) {
1184 unsigned int anchor_element = avio_r8(pbc);
1185 AVRational anchored_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1186 if (anchor_element == IAMF_ANCHOR_ELEMENT_DIALOGUE)
1187 submix_layout->dialogue_anchored_loudness = anchored_loudness;
1188 else if (anchor_element <= IAMF_ANCHOR_ELEMENT_ALBUM)
1189 submix_layout->album_anchored_loudness = anchored_loudness;
1190 else
1191 av_log(s, AV_LOG_DEBUG, "Unknown anchor_element. Ignoring\n");
1192 }
1193 }
1194
1195 if (info_type & 0xFC) {
1196 unsigned int info_type_size = ffio_read_leb(pbc);
1197 avio_skip(pbc, info_type_size);
1198 }
1199 }
1200 }
1201
1202 c->mix_presentations[c->nb_mix_presentations++] = mix_presentation;
1203
1204 len -= avio_tell(pbc);
1205 if (len)
1206 av_log(s, AV_LOG_WARNING, "Underread in mix_presentation_obu. %d bytes left at the end\n", len);
1207
1208 ret = 0;
1209fail:
1210 av_free(buf);
1211 if (ret < 0)
1212 ff_iamf_free_mix_presentation(&mix_presentation);
1213 return ret;
1214}
1215
1216int ff_iamf_parse_obu_header(const uint8_t *buf, int buf_size,
1217 unsigned *obu_size, int *start_pos, enum IAMF_OBU_Type *type,
1218 unsigned *skip_samples, unsigned *discard_padding)
1219{
1220 GetBitContext gb;
1221 int ret, extension_flag, trimming, start;
1222 unsigned skip = 0, discard = 0;
1223 unsigned size;
1224
1225 ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_IAMF_OBU_HEADER_SIZE));
1226 if (ret < 0)
1227 return ret;
1228
1229 *type = get_bits(&gb, 5);
1230 /*redundant =*/ get_bits1(&gb);
1231 trimming = get_bits1(&gb);
1232 extension_flag = get_bits1(&gb);
1233
1234 *obu_size = get_leb(&gb);
1235 if (*obu_size > INT_MAX)
1236 return AVERROR_INVALIDDATA;
1237
1238 start = get_bits_count(&gb) / 8;
1239
1240 if (trimming) {
1241 discard = get_leb(&gb); // num_samples_to_trim_at_end
1242 skip = get_leb(&gb); // num_samples_to_trim_at_start
1243 }
1244
1245 if (skip_samples)
1246 *skip_samples = skip;
1247 if (discard_padding)
1248 *discard_padding = discard;
1249
1250 if (extension_flag) {
1251 unsigned int extension_bytes;
1252 extension_bytes = get_leb(&gb);
1253 if (extension_bytes > INT_MAX / 8)
1254 return AVERROR_INVALIDDATA;
1255 skip_bits_long(&gb, extension_bytes * 8);
1256 }
1257
1258 if (get_bits_left(&gb) < 0)
1259 return AVERROR_INVALIDDATA;
1260
1261 size = *obu_size + start;
1262 if (size > INT_MAX)
1263 return AVERROR_INVALIDDATA;
1264
1265 *obu_size -= get_bits_count(&gb) / 8 - start;
1266 *start_pos = size - *obu_size;
1267
1268 return size;
1269}
1270
1272 int max_size, void *log_ctx)
1273{
1275 int ret;
1276
1277 while (1) {
1278 unsigned obu_size;
1279 enum IAMF_OBU_Type type;
1280 int start_pos, len, size;
1281
1282 if ((ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size))) < 0)
1283 return ret;
1285 if (size < 0)
1286 return size;
1288
1289 len = ff_iamf_parse_obu_header(header, size, &obu_size, &start_pos, &type, NULL, NULL);
1290 if (len < 0 || obu_size > max_size) {
1291 av_log(log_ctx, AV_LOG_ERROR, "Failed to read obu header\n");
1292 avio_seek(pb, -size, SEEK_CUR);
1293 return len;
1294 }
1295
1297 avio_seek(pb, -size, SEEK_CUR);
1298 break;
1299 }
1300
1301 avio_seek(pb, -(size - start_pos), SEEK_CUR);
1302 switch (type) {
1304 ret = codec_config_obu(log_ctx, c, pb, obu_size);
1305 break;
1307 ret = audio_element_obu(log_ctx, c, pb, obu_size);
1308 break;
1310 ret = mix_presentation_obu(log_ctx, c, pb, obu_size);
1311 break;
1312 default: {
1313 int64_t offset = avio_skip(pb, obu_size);
1314 if (offset < 0)
1315 ret = offset;
1316 break;
1317 }
1318 }
1319 if (ret < 0) {
1320 av_log(log_ctx, AV_LOG_ERROR, "Failed to read obu type %d\n", type);
1321 return ret;
1322 }
1323 max_size -= obu_size + start_pos;
1324 if (max_size < 0)
1325 return AVERROR_INVALIDDATA;
1326 if (!max_size)
1327 break;
1328 }
1329
1330 return 0;
1331}
1332
1334 int max_size, void *log_ctx)
1335{
1336 int ret = read_descriptors(c, pb, max_size, log_ctx);
1337
1338 if (ret < 0)
1340 return ret;
1341}
static FILE * out
channels
Definition aptx.h:31
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
unsigned int avio_rb16(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:507
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition aviobuf.c:321
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:615
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition aviobuf.c:836
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
Definition aviobuf.c:606
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition aviobuf.c:985
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Definition aviobuf.c:50
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition aviobuf.c:665
unsigned int ffio_read_leb(AVIOContext *s)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
Definition aviobuf.c:889
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
AVCodecParameters * avcodec_parameters_alloc(void)
Definition codec_par.c:57
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
static __device__ float floor(float a)
static CheckasmConfig cfg
Definition checkasm.c:74
static int64_t duration
Definition ffplay.c:359
int ret
Definition ffplay.c:391
const char * label
FLAC (Free Lossless Audio Codec) common stuff.
#define FLAC_STREAMINFO_SIZE
Definition flac.h:32
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition get_bits.h:424
static int get_bits_left(GetBitContext *gb)
Definition get_bits.h:688
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition get_bits.h:280
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static void skip_bits(GetBitContext *s, int n)
Definition get_bits.h:383
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
Definition get_bits.h:456
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition get_bits.h:544
static int get_bits_count(const GetBitContext *s)
Definition get_bits.h:254
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
#define fail
Definition test.h:479
#define AV_CH_LAYOUT_STEREO
#define AV_CH_SIDE_LEFT
#define AV_CH_TOP_FRONT_LEFT
#define AV_CH_FRONT_RIGHT_OF_CENTER
#define AV_CH_FRONT_LEFT_OF_CENTER
#define AV_CH_BACK_RIGHT
#define AV_CH_TOP_SIDE_RIGHT
#define AV_CH_FRONT_CENTER
#define AV_CH_TOP_BACK_RIGHT
#define AV_CH_SIDE_RIGHT
#define AV_CH_BACK_LEFT
#define AV_CH_TOP_SIDE_LEFT
#define AV_CH_TOP_BACK_LEFT
#define AV_CH_LOW_FREQUENCY
#define AV_CH_TOP_FRONT_RIGHT
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_PCM_S24BE
Definition codec_id.h:346
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:333
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_PCM_S16BE
Definition codec_id.h:334
@ AV_CODEC_ID_PCM_S24LE
Definition codec_id.h:345
@ AV_CODEC_ID_PCM_S32LE
Definition codec_id.h:341
@ AV_CODEC_ID_AAC
Definition codec_id.h:460
@ AV_CODEC_ID_FLAC
Definition codec_id.h:470
@ AV_CODEC_ID_PCM_S32BE
Definition codec_id.h:342
@ AV_CODEC_ID_OPUS
Definition codec_id.h:518
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define AV_CHANNEL_LAYOUT_BINAURAL
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_MONO
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, uint64_t mask)
Find out what channels from a given set are present in a channel layout, without regard for their pos...
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
@ AV_CHANNEL_ORDER_AMBISONIC
The audio is represented as the decomposition of the sound field into spherical harmonics.
@ AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_BACK_RIGHT
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_FRONT_LEFT
@ AV_CHAN_TOP_BACK_LEFT
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_FRONT_RIGHT
@ AV_CHAN_AMBISONIC_BASE
Range of channels between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END represent Ambisonic compon...
@ AV_CHAN_TOP_SIDE_RIGHT
@ AV_CHAN_FRONT_CENTER
@ AV_CHAN_SIDE_RIGHT
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_BACK_LEFT
@ AV_CHAN_SIDE_LEFT
@ AV_CHAN_TOP_FRONT_LEFT
@ AV_CHAN_TOP_BACK_RIGHT
@ AV_CHAN_TOP_SIDE_LEFT
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition dict.h:79
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:87
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition dict.h:81
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
AVIAMFLayer * av_iamf_audio_element_add_layer(AVIAMFAudioElement *audio_element)
Allocate a layer and add it to a given AVIAMFAudioElement.
#define AV_IAMF_LAYER_FLAG_RECON_GAIN
Recon gain information for the layer is present in AVIAMFReconGain.
Definition iamf.h:280
AVIAMFAudioElement * av_iamf_audio_element_alloc(void)
Allocates a AVIAMFAudioElement, and initializes its fields with default values.
Definition iamf.c:324
@ AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE
Definition iamf.h:349
@ AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL
Definition iamf.h:348
AVIAMFSubmixLayout * av_iamf_submix_add_layout(AVIAMFSubmix *submix)
Allocate a submix layout and add it to a given AVIAMFSubmix.
AVIAMFMixPresentation * av_iamf_mix_presentation_alloc(void)
Allocates a AVIAMFMixPresentation, and initializes its fields with default values.
Definition iamf.c:522
AVIAMFSubmix * av_iamf_mix_presentation_add_submix(AVIAMFMixPresentation *mix_presentation)
Allocate a submix and add it to a given AVIAMFMixPresentation.
AVIAMFSubmixElement * av_iamf_submix_add_element(AVIAMFSubmix *submix)
Allocate a submix element and add it to a given AVIAMFSubmix.
@ 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
static av_always_inline void * av_iamf_param_definition_get_subblock(const AVIAMFParamDefinition *par, unsigned int idx)
Get the subblock at the specified idx.
Definition iamf.h:260
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 ...
Definition iamf.c:159
@ AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN
Subblocks are of struct type AVIAMFReconGain.
Definition iamf.h:181
@ AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN
Subblocks are of struct type AVIAMFMixGain.
Definition iamf.h:173
@ AV_IAMF_PARAMETER_DEFINITION_DEMIXING
Subblocks are of struct type AVIAMFDemixingInfo.
Definition iamf.h:177
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition rational.h:71
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:318
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
static int read_descriptors(IAMFContext *c, AVIOContext *pb, int max_size, void *log_ctx)
static int ambisonics_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
Definition iamf_parse.c:527
int ff_iamf_parse_obu_header(const uint8_t *buf, int buf_size, unsigned *obu_size, int *start_pos, enum IAMF_OBU_Type *type, unsigned *skip_samples, unsigned *discard_padding)
static int codec_config_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
Definition iamf_parse.c:173
static int opus_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
Definition iamf_parse.c:36
static int parse_coupled_substream(AVChannelLayout *out, AVChannelLayout *in, int n)
Definition iamf_parse.c:357
static int update_extradata(AVCodecParameters *codecpar)
Definition iamf_parse.c:281
int ff_iamfdec_read_descriptors(IAMFContext *c, AVIOContext *pb, int max_size, void *log_ctx)
static int param_parse(void *s, IAMFContext *c, AVIOContext *pb, unsigned int type, const IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config, AVIAMFParamDefinition **out_param_definition)
Definition iamf_parse.c:616
static int flac_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
Definition iamf_parse.c:119
static int label_string(AVIOContext *pb, char **label)
Definition iamf_parse.c:953
static int aac_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len, void *logctx)
Definition iamf_parse.c:60
static int ipcm_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
Definition iamf_parse.c:149
static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
Definition iamf_parse.c:758
static int scalable_channel_layout_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
Definition iamf_parse.c:392
static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
Definition iamf_parse.c:970
static int param_definition(const IAMFContext *iamf, const IAMFParamDefinition *param_def, AVIOContext *dyn_bc, void *log_ctx)
#define b
Definition input.c:43
#define AV_RB16A(p)
#define AV_WL32A(p, v)
#define AV_WB8(p, d)
#define AV_WL16A(p, v)
#define AV_WB32A(p, v)
#define AV_RB24(x)
#define AV_RB32A(p)
int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag)
Definition isom.c:296
const AVCodecTag ff_mp4_obj_type[]
Definition isom.c:34
#define MP4DecConfigDescrTag
Definition isom.h:411
#define MP4DecSpecificDescrTag
Definition isom.h:412
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition j2kenc.c:154
uint32_t type
Definition jpegmpfenc.c:80
leb128 handling implementations
static unsigned get_leb(GetBitContext *s)
Read a unsigned integer coded as a variable number of up to eight little-endian bytes,...
Definition leb.h:35
unsigned offset
Definition libaomenc.c:763
static int mix(int c0, int c1)
Definition 4xm.c:717
void ff_iamf_uninit_context(IAMFContext *c)
Definition iamf.c:172
void ff_iamf_free_mix_presentation(IAMFMixPresentation **pmix_presentation)
Definition iamf.c:158
void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element)
Definition iamf.c:143
const AVChannelLayout ff_iamf_expanded_scalable_ch_layouts[13]
Definition iamf.c:48
const AVChannelLayout ff_iamf_scalable_ch_layouts[10]
Definition iamf.c:27
const struct IAMFSoundSystemMap ff_iamf_sound_system_map[14]
Definition iamf.c:120
#define MAX_IAMF_OBU_HEADER_SIZE
Definition iamf.h:34
@ IAMF_ANCHOR_ELEMENT_DIALOGUE
Definition iamf.h:141
@ IAMF_ANCHOR_ELEMENT_ALBUM
Definition iamf.h:142
static IAMFCodecConfig * ff_iamf_get_codec_config(const IAMFContext *c, unsigned int codec_config_id)
Definition iamf.h:172
IAMF_OBU_Type
Definition iamf.h:37
@ IAMF_OBU_IA_MIX_PRESENTATION
Definition iamf.h:40
@ IAMF_OBU_IA_PARAMETER_BLOCK
Definition iamf.h:41
@ IAMF_OBU_IA_AUDIO_ELEMENT
Definition iamf.h:39
@ IAMF_OBU_IA_SEQUENCE_HEADER
Definition iamf.h:63
@ IAMF_OBU_IA_CODEC_CONFIG
Definition iamf.h:38
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
Definition utils.c:143
Immersive Audio Model and Formats API header.
static const uint16_t mask[17]
Definition lzw.c:38
#define FFMIN(a, b)
Definition macros.h:49
#define MKBETAG(a, b, c, d)
Definition macros.h:56
static av_const int sign_extend(int val, unsigned bits)
Definition mathops.h:135
enum AVSampleFormat sample_format
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
uint32_t tag
Definition movenc.c:2128
int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx)
Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
Definition mpeg4audio.c:212
@ AOT_ESCAPE
Y Escape Value.
Definition mpeg4audio.h:103
#define av_strdup(s)
Definition ops_static.c:55
#define av_malloc(s)
Definition ops_static.c:52
bitstream writer API
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition put_bits.h:62
static int put_bits_left(PutBitContext *s)
Definition put_bits.h:135
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition put_bits.h:153
static void put_bits63(PutBitContext *s, int n, uint64_t value)
Write up to 63 bits into a bitstream.
Definition put_bits.h:344
static int put_bytes_output(const PutBitContext *s)
Definition put_bits.h:99
static av_unused void put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
Definition put_bits.h:301
static const uint8_t header[24]
Definition sdr2.c:68
#define FF_ARRAY_ELEMS(a)
enum AVChannel id
An AVChannelLayout holds information about the channel layout of audio data.
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
This struct describes the properties of an encoded stream.
Definition codec_par.h:49
int extradata_size
Size of the extradata content in bytes.
Definition codec_par.h:75
int frame_size
Audio frame size, if known.
Definition codec_par.h:227
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition codec_par.h:207
int seek_preroll
Number of audio samples to skip after a discontinuity.
Definition codec_par.h:256
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition codec_par.h:71
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
int sample_rate
The number of audio samples per second.
Definition codec_par.h:213
Information on how to combine one or more audio streams, as defined in section 3.6 of IAMF.
Definition iamf.h:359
enum AVIAMFAudioElementType audio_element_type
Audio element type as defined in section 3.6 of IAMF.
Definition iamf.h:391
AVIAMFParamDefinition * recon_gain_info
Recon gain information used to reconstruct a scalable channel audio representation.
Definition iamf.h:386
unsigned int default_w
Default weight value as defined in section 3.6 of IAMF.
Definition iamf.h:396
AVIAMFParamDefinition * demixing_info
Demixing information used to reconstruct a scalable channel audio representation.
Definition iamf.h:379
AVIAMFLayer ** layers
Definition iamf.h:362
Demixing Info Parameter Data as defined in section 3.8.2 of IAMF.
Definition iamf.h:128
unsigned int dmixp_mode
Pre-defined combination of demixing parameters.
Definition iamf.h:140
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
Definition iamf.h:136
A layer defining a Channel Layout in the Audio Element.
Definition iamf.h:294
unsigned int flags
A bitmask which may contain a combination of AV_IAMF_LAYER_FLAG_* flags.
Definition iamf.h:302
unsigned int output_gain_flags
Output gain channel flags as defined in section 3.6.2 of IAMF.
Definition iamf.h:310
enum AVIAMFAmbisonicsMode ambisonics_mode
Ambisonics mode as defined in section 3.6.3 of IAMF.
Definition iamf.h:328
unsigned int nb_demixing_matrix
The length of the Demixing matrix array.
Definition iamf.h:343
AVRational * demixing_matrix
Demixing matrix as defined in section 3.6.3 of IAMF.
Definition iamf.h:336
AVChannelLayout ch_layout
Definition iamf.h:297
AVRational output_gain
Output gain as defined in section 3.6.2 of IAMF.
Definition iamf.h:316
Mix Gain Parameter Data as defined in section 3.8.1 of IAMF.
Definition iamf.h:77
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
Definition iamf.h:616
Parameters as defined in section 3.6.1 of IAMF.
Definition iamf.h:193
unsigned int parameter_rate
Sample rate for the parameter substream.
Definition iamf.h:222
unsigned int duration
The accumulated duration of all blocks in this parameter definition, in units of 1 / parameter_rate.
Definition iamf.h:231
unsigned int constant_subblock_duration
The duration of every subblock in the case where all subblocks, with the optional exception of the la...
Definition iamf.h:238
unsigned int parameter_id
Identifier for the parameter substream.
Definition iamf.h:218
unsigned int nb_subblocks
Number of subblocks in the array.
Definition iamf.h:208
Recon Gain Info Parameter Data as defined in section 3.8.3 of IAMF.
Definition iamf.h:148
unsigned int subblock_duration
Duration for the given subblock, in units of 1 / parameter_rate.
Definition iamf.h:156
Submix element as defined in section 3.7 of IAMF.
Definition iamf.h:449
AVIAMFParamDefinition * element_mix_config
Information required required for applying any processing to the referenced and rendered Audio Elemen...
Definition iamf.h:464
unsigned int audio_element_id
The id of the Audio Element this submix element references.
Definition iamf.h:455
AVDictionary * annotations
A dictionary of strings describing the submix in different languages.
Definition iamf.h:493
enum AVIAMFHeadphonesMode headphones_rendering_mode
A value that indicates whether the referenced channel-based Audio Element shall be rendered to stereo...
Definition iamf.h:481
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with element_mix_config's par...
Definition iamf.h:472
Submix layout as defined in section 3.7.6 of IAMF.
Definition iamf.h:517
AVRational true_peak
The true peak of the audio signal, as defined in ITU-1770-4.
Definition iamf.h:542
AVRational digital_peak
The digital (sampled) peak value of the audio signal, as defined in ITU-1770-4.
Definition iamf.h:538
enum AVIAMFSubmixLayoutType layout_type
Definition iamf.h:520
AVRational dialogue_anchored_loudness
The Dialogue loudness information, as defined in ITU-1770-4.
Definition iamf.h:546
AVRational album_anchored_loudness
The Album loudness information, as defined in ITU-1770-4.
Definition iamf.h:550
AVRational integrated_loudness
The program integrated loudness information, as defined in ITU-1770-4.
Definition iamf.h:533
AVChannelLayout sound_system
Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus 7.1.2ch, 3....
Definition iamf.h:528
Submix layout as defined in section 3.7 of IAMF.
Definition iamf.h:559
AVRational default_mix_gain
Default mix gain value to apply when there are no AVIAMFParamDefinition with output_mix_config's para...
Definition iamf.h:606
AVIAMFParamDefinition * output_mix_config
Information required for post-processing the mixed audio signal to generate the audio signal for play...
Definition iamf.h:598
Bytestream IO Context.
Definition avio.h:160
int eof_reached
true if was unable to read due to error or eof
Definition avio.h:238
int error
contains the error code or 0 if no error happened
Definition avio.h:239
Rational number (pair of numerator and denominator).
Definition rational.h:58
unsigned int codec_config_id
Definition iamf.h:101
IAMFLayer * layers
Definition iamf.h:103
unsigned int audio_element_id
Definition iamf.h:96
const AVIAMFAudioElement * celement
Definition iamf.h:90
unsigned int nb_layers
Definition iamf.h:104
AVIAMFAudioElement * element
element backs celement iff the AVIAMFAudioElement is owned by this structure.
Definition iamf.h:95
unsigned int nb_substreams
Definition iamf.h:99
IAMFSubStream * substreams
Definition iamf.h:98
int sample_rate
Definition iamf.h:72
int audio_roll_distance
Definition iamf.h:71
int extradata_size
Definition iamf.h:73
enum AVCodecID codec_id
Definition iamf.h:68
unsigned nb_samples
Definition iamf.h:70
unsigned codec_config_id
Definition iamf.h:67
uint8_t * extradata
Definition iamf.h:74
unsigned int substream_count
Definition iamf.h:78
unsigned int coupled_substream_count
Definition iamf.h:79
AVIAMFMixPresentation * mix
mix backs cmix iff the AVIAMFMixPresentation is owned by this structure.
Definition iamf.h:113
unsigned int count_label
Definition iamf.h:117
char ** language_label
Definition iamf.h:118
const AVIAMFMixPresentation * cmix
Definition iamf.h:108
unsigned int mix_presentation_id
Definition iamf.h:114
AVCodecParameters * codecpar
Definition iamf.h:86
unsigned int audio_substream_id
Definition iamf.h:83
Definition swscale.c:71
#define av_free(p)
#define av_malloc_array(a, b)
#define av_mallocz(s)
#define avpriv_request_sample(...)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
int size
enum AVCodecID codec_id
int len
static double c[64]