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
107 ret = avpriv_mpeg4audio_get_config2(&cfg, codec_config->extradata,
108 codec_config->extradata_size, 1, logctx);
109 if (ret < 0)
110 return ret;
111
112 codec_config->sample_rate = cfg.sample_rate;
113
114 return 0;
115}
116
117static int flac_decoder_config(IAMFCodecConfig *codec_config,
118 AVIOContext *pb, int len)
119{
120 int ret, left;
121
122 if (codec_config->audio_roll_distance)
123 return AVERROR_INVALIDDATA;
124
125 avio_skip(pb, 4); // METADATA_BLOCK_HEADER
126
127 left = len - avio_tell(pb);
129 return AVERROR_INVALIDDATA;
130
131 codec_config->extradata = av_malloc(left);
132 if (!codec_config->extradata)
133 return AVERROR(ENOMEM);
134
135 ret = ffio_read_size(pb, codec_config->extradata, left);
136 if (ret < 0)
137 return ret;
138
139 codec_config->extradata_size = left;
140 codec_config->sample_rate = AV_RB24(codec_config->extradata + 10) >> 4;
141
142 return 0;
143}
144
145static int ipcm_decoder_config(IAMFCodecConfig *codec_config,
146 AVIOContext *pb, int len)
147{
148 static const enum AVCodecID sample_fmt[2][3] = {
151 };
152 int sample_format = avio_r8(pb); // 0 = BE, 1 = LE
153 int sample_size = (avio_r8(pb) / 8 - 2); // 16, 24, 32
154 if (sample_format > 1 || sample_size > 2U || codec_config->audio_roll_distance)
155 return AVERROR_INVALIDDATA;
156
157 codec_config->codec_id = sample_fmt[sample_format][sample_size];
158 codec_config->sample_rate = avio_rb32(pb);
159
160 if (len - avio_tell(pb))
161 return AVERROR_INVALIDDATA;
162
163 return 0;
164}
165
166static int codec_config_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
167{
168 IAMFCodecConfig **tmp, *codec_config = NULL;
170 AVIOContext *pbc;
171 uint8_t *buf;
172 enum AVCodecID avcodec_id;
173 unsigned codec_config_id, nb_samples, codec_id;
174 int16_t audio_roll_distance;
175 int ret;
176
177 buf = av_malloc(len);
178 if (!buf)
179 return AVERROR(ENOMEM);
180
181 ret = ffio_read_size(pb, buf, len);
182 if (ret < 0)
183 goto fail;
184
185 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
186 pbc = &b.pub;
187
188 codec_config_id = ffio_read_leb(pbc);
189 codec_id = avio_rb32(pbc);
190 nb_samples = ffio_read_leb(pbc);
191 audio_roll_distance = avio_rb16(pbc);
192
193 switch(codec_id) {
194 case MKBETAG('O','p','u','s'):
195 avcodec_id = AV_CODEC_ID_OPUS;
196 break;
197 case MKBETAG('m','p','4','a'):
198 avcodec_id = AV_CODEC_ID_AAC;
199 break;
200 case MKBETAG('f','L','a','C'):
201 avcodec_id = AV_CODEC_ID_FLAC;
202 break;
203 default:
204 avcodec_id = AV_CODEC_ID_NONE;
205 break;
206 }
207
208 for (int i = 0; i < c->nb_codec_configs; i++)
209 if (c->codec_configs[i]->codec_config_id == codec_config_id) {
211 goto fail;
212 }
213
214 tmp = av_realloc_array(c->codec_configs, c->nb_codec_configs + 1, sizeof(*c->codec_configs));
215 if (!tmp) {
216 ret = AVERROR(ENOMEM);
217 goto fail;
218 }
219 c->codec_configs = tmp;
220
221 codec_config = av_mallocz(sizeof(*codec_config));
222 if (!codec_config) {
223 ret = AVERROR(ENOMEM);
224 goto fail;
225 }
226
227 codec_config->codec_config_id = codec_config_id;
228 codec_config->codec_id = avcodec_id;
229 codec_config->nb_samples = nb_samples;
230 codec_config->audio_roll_distance = audio_roll_distance;
231
232 switch(codec_id) {
233 case MKBETAG('O','p','u','s'):
234 ret = opus_decoder_config(codec_config, pbc, len);
235 break;
236 case MKBETAG('m','p','4','a'):
237 ret = aac_decoder_config(codec_config, pbc, len, s);
238 break;
239 case MKBETAG('f','L','a','C'):
240 ret = flac_decoder_config(codec_config, pbc, len);
241 break;
242 case MKBETAG('i','p','c','m'):
243 ret = ipcm_decoder_config(codec_config, pbc, len);
244 break;
245 default:
246 break;
247 }
248 if (ret < 0)
249 goto fail;
250
251 if ((codec_config->nb_samples > INT_MAX) || codec_config->nb_samples <= 0 ||
252 (-codec_config->audio_roll_distance > INT_MAX / codec_config->nb_samples)) {
254 goto fail;
255 }
256
257 c->codec_configs[c->nb_codec_configs++] = codec_config;
258
259 len -= avio_tell(pbc);
260 if (len)
261 av_log(s, AV_LOG_WARNING, "Underread in codec_config_obu. %d bytes left at the end\n", len);
262
263 ret = 0;
264fail:
265 av_free(buf);
266 if (ret < 0) {
267 if (codec_config)
268 av_free(codec_config->extradata);
269 av_free(codec_config);
270 }
271 return ret;
272}
273
275{
276 GetBitContext gb;
277 PutBitContext pb;
278 int ret;
279
280 switch(codecpar->codec_id) {
281 case AV_CODEC_ID_OPUS:
282 AV_WB8(codecpar->extradata + 9, codecpar->ch_layout.nb_channels);
283 AV_WL16A(codecpar->extradata + 10, AV_RB16A(codecpar->extradata + 10)); // Byte swap pre-skip
284 AV_WL32A(codecpar->extradata + 12, AV_RB32A(codecpar->extradata + 12)); // Byte swap sample rate
285 AV_WL16A(codecpar->extradata + 16, AV_RB16A(codecpar->extradata + 16)); // Byte swap Output Gain
286 break;
287 case AV_CODEC_ID_AAC: {
288 uint8_t buf[6];
289 int size = FFMIN(codecpar->extradata_size, sizeof(buf));
290
291 init_put_bits(&pb, buf, sizeof(buf));
292 ret = init_get_bits8(&gb, codecpar->extradata, size);
293 if (ret < 0)
294 return ret;
295
296 ret = get_bits(&gb, 5);
297 put_bits(&pb, 5, ret);
298 if (ret == AOT_ESCAPE) // violates section 3.11.2, but better check for it
299 put_bits(&pb, 6, get_bits(&gb, 6));
300 ret = get_bits(&gb, 4);
301 put_bits(&pb, 4, ret);
302 if (ret == 0x0f)
303 put_bits(&pb, 24, get_bits(&gb, 24));
304
305 skip_bits(&gb, 4);
306 put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set channel config
307 ret = get_bits_left(&gb);
308 if (ret < 0)
309 return AVERROR_INVALIDDATA;
310 ret = FFMIN(ret, put_bits_left(&pb));
311 while (ret >= 32) {
312 put_bits32(&pb, get_bits_long(&gb, 32));
313 ret -= 32;
314 }
315 put_bits(&pb, ret, get_bits_long(&gb, ret));
316 flush_put_bits(&pb);
317
318 memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
319 break;
320 }
321 case AV_CODEC_ID_FLAC: {
322 uint8_t buf[13];
323 int size = FFMIN(codecpar->extradata_size, sizeof(buf));
324
325 init_put_bits(&pb, buf, sizeof(buf));
326 ret = init_get_bits8(&gb, codecpar->extradata, size);
327 if (ret < 0)
328 return ret;
329
330 put_bits32(&pb, get_bits_long(&gb, 32)); // min/max blocksize
331 put_bits63(&pb, 48, get_bits64(&gb, 48)); // min/max framesize
332 put_bits(&pb, 20, get_bits(&gb, 20)); // samplerate
333 skip_bits(&gb, 3);
334 put_bits(&pb, 3, codecpar->ch_layout.nb_channels - 1);
335 ret = get_bits_left(&gb);
336 if (ret < 0)
337 return AVERROR_INVALIDDATA;
338 ret = FFMIN(ret, put_bits_left(&pb));
339 put_bits(&pb, ret, get_bits(&gb, ret));
340 flush_put_bits(&pb);
341
342 memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
343 break;
344 }
345 }
346
347 return 0;
348}
349
351{
352 if (in->u.mask & AV_CH_LAYOUT_STEREO) {
353 out->u.map[n++].id = AV_CHAN_FRONT_LEFT;
354 out->u.map[n++].id = AV_CHAN_FRONT_RIGHT;
357 out->u.map[n++].id = AV_CHAN_FRONT_LEFT_OF_CENTER;
358 out->u.map[n++].id = AV_CHAN_FRONT_RIGHT_OF_CENTER;
360 } else if (in->u.mask & (AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)) {
361 out->u.map[n++].id = AV_CHAN_SIDE_LEFT;
362 out->u.map[n++].id = AV_CHAN_SIDE_RIGHT;
364 } else if (in->u.mask & (AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)) {
365 out->u.map[n++].id = AV_CHAN_BACK_LEFT;
366 out->u.map[n++].id = AV_CHAN_BACK_RIGHT;
369 out->u.map[n++].id = AV_CHAN_TOP_FRONT_LEFT;
370 out->u.map[n++].id = AV_CHAN_TOP_FRONT_RIGHT;
372 } else if (in->u.mask & (AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT)) {
373 out->u.map[n++].id = AV_CHAN_TOP_SIDE_LEFT;
374 out->u.map[n++].id = AV_CHAN_TOP_SIDE_RIGHT;
376 } else if (in->u.mask & (AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT)) {
377 out->u.map[n++].id = AV_CHAN_TOP_BACK_LEFT;
378 out->u.map[n++].id = AV_CHAN_TOP_BACK_RIGHT;
380 }
381
382 return n;
383}
384
386 IAMFAudioElement *audio_element,
387 const IAMFCodecConfig *codec_config)
388{
389 int nb_layers, k = 0;
390
391 nb_layers = avio_r8(pb) >> 5; // get_bits(&gb, 3);
392 // skip_bits(&gb, 5); //reserved
393
394 if (nb_layers > 6 || nb_layers == 0)
395 return AVERROR_INVALIDDATA;
396
397 audio_element->layers = av_calloc(nb_layers, sizeof(*audio_element->layers));
398 if (!audio_element->layers)
399 return AVERROR(ENOMEM);
400
401 audio_element->nb_layers = nb_layers;
402 for (int i = 0, n = 0; i < nb_layers; i++) {
403 AVChannelLayout ch_layout = { 0 };
404 AVIAMFLayer *layer;
405 int loudspeaker_layout, output_gain_is_present_flag;
406 int substream_count, coupled_substream_count;
407 int expanded_loudspeaker_layout = -1;
408 int ret, byte = avio_r8(pb);
409 int channels;
410
411 layer = av_iamf_audio_element_add_layer(audio_element->element);
412 if (!layer)
413 return AVERROR(ENOMEM);
414
415 loudspeaker_layout = byte >> 4; // get_bits(&gb, 4);
416 output_gain_is_present_flag = (byte >> 3) & 1; //get_bits1(&gb);
417 if ((byte >> 2) & 1)
419 substream_count = avio_r8(pb);
420 coupled_substream_count = avio_r8(pb);
421
422 if (!substream_count || coupled_substream_count > substream_count ||
423 substream_count + k > audio_element->nb_substreams)
424 return AVERROR_INVALIDDATA;
425
426 audio_element->layers[i].substream_count = substream_count;
427 audio_element->layers[i].coupled_substream_count = coupled_substream_count;
428 if (output_gain_is_present_flag) {
429 layer->output_gain_flags = avio_r8(pb) >> 2; // get_bits(&gb, 6);
430 layer->output_gain = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 8);
431 }
432
433 if (loudspeaker_layout == 15) {
434 if (i) {
435 av_log(s, AV_LOG_ERROR, "expanded_loudspeaker_layout set with more than one layer in Audio Element #%d\n",
436 audio_element->audio_element_id);
437 return AVERROR_INVALIDDATA;
438 }
439 expanded_loudspeaker_layout = avio_r8(pb);
440 }
441 if (expanded_loudspeaker_layout >= 0 && expanded_loudspeaker_layout < 13) {
442 av_channel_layout_copy(&ch_layout, &ff_iamf_expanded_scalable_ch_layouts[expanded_loudspeaker_layout]);
443 } else if (loudspeaker_layout < 10) {
444 av_channel_layout_copy(&ch_layout, &ff_iamf_scalable_ch_layouts[loudspeaker_layout]);
445 if (i) {
446 uint64_t mask = av_channel_layout_subset(&audio_element->element->layers[i-1]->ch_layout, UINT64_MAX);
447 // When the first layer is Mono, the second layer may not have the C channel (e.g. Stereo)
448 if (audio_element->element->layers[i-1]->ch_layout.nb_channels == 1)
449 n--;
450 else if ((ch_layout.u.mask & mask) != mask)
451 return AVERROR_INVALIDDATA;
452 ch_layout.u.mask &= ~mask;
453 }
454 } else {
455 if (expanded_loudspeaker_layout >= 0)
456 avpriv_request_sample(s, "expanded_loudspeaker_layout %d", expanded_loudspeaker_layout);
457 else
458 avpriv_request_sample(s, "loudspeaker_layout %d", loudspeaker_layout);
460 }
461
462 channels = ch_layout.nb_channels;
463 if (i) {
464 if (ch_layout.nb_channels <= audio_element->element->layers[i-1]->ch_layout.nb_channels)
465 return AVERROR_INVALIDDATA;
466 channels -= audio_element->element->layers[i-1]->ch_layout.nb_channels;
467 }
468 if (channels != substream_count + coupled_substream_count)
469 return AVERROR_INVALIDDATA;
470
471 for (int j = 0; j < substream_count; j++) {
472 IAMFSubStream *substream = &audio_element->substreams[k++];
473
474 substream->codecpar->ch_layout = coupled_substream_count-- > 0 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO :
476
477 ret = update_extradata(substream->codecpar);
478 if (ret < 0)
479 return ret;
480 }
481
482 ret = av_channel_layout_custom_init(&layer->ch_layout, ch_layout.nb_channels);
483 if (ret < 0)
484 return ret;
485 for (int j = 0; j < n; j++)
486 layer->ch_layout.u.map[j].id = av_channel_layout_channel_from_index(&audio_element->element->layers[i-1]->ch_layout, j);
487
488 coupled_substream_count = audio_element->layers[i].coupled_substream_count;
489 while (coupled_substream_count--) {
490 n = parse_coupled_substream(&layer->ch_layout, &ch_layout, n);
491 }
492
493 substream_count -= audio_element->layers[i].coupled_substream_count;
494 n = parse_coupled_substream(&layer->ch_layout, &ch_layout, n); // In case the first layer is Mono
495 while (substream_count--) {
496 if (ch_layout.u.mask & AV_CH_FRONT_CENTER) {
497 layer->ch_layout.u.map[n++].id = AV_CHAN_FRONT_CENTER;
498 ch_layout.u.mask &= ~AV_CH_FRONT_CENTER;
499 }
500 if (ch_layout.u.mask & AV_CH_LOW_FREQUENCY) {
501 layer->ch_layout.u.map[n++].id = AV_CHAN_LOW_FREQUENCY;
502 ch_layout.u.mask &= ~AV_CH_LOW_FREQUENCY;
503 }
504 }
505
506 if (n != ch_layout.nb_channels)
507 return AVERROR_INVALIDDATA;
508
510 if (ret < 0 && ret != AVERROR(ENOSYS))
511 return ret;
512 }
513
514 if (k != audio_element->nb_substreams)
515 return AVERROR_INVALIDDATA;
516
517 return 0;
518}
519
520static int ambisonics_config(void *s, AVIOContext *pb,
521 IAMFAudioElement *audio_element,
522 const IAMFCodecConfig *codec_config)
523{
524 AVIAMFLayer *layer;
525 unsigned ambisonics_mode;
526 int output_channel_count, substream_count, order;
527 int ret;
528
529 ambisonics_mode = ffio_read_leb(pb);
530 if (ambisonics_mode > 1)
531 return AVERROR_INVALIDDATA;
532
533 output_channel_count = avio_r8(pb); // C
534 substream_count = avio_r8(pb); // N
535 if (audio_element->nb_substreams != substream_count || output_channel_count == 0)
536 return AVERROR_INVALIDDATA;
537
538 order = floor(sqrt(output_channel_count - 1));
539 /* incomplete order - some harmonics are missing */
540 if ((order + 1) * (order + 1) != output_channel_count)
541 return AVERROR_INVALIDDATA;
542
543 audio_element->layers = av_mallocz(sizeof(*audio_element->layers));
544 if (!audio_element->layers)
545 return AVERROR(ENOMEM);
546
547 audio_element->nb_layers = 1;
548 audio_element->layers->substream_count = substream_count;
549
550 layer = av_iamf_audio_element_add_layer(audio_element->element);
551 if (!layer)
552 return AVERROR(ENOMEM);
553
554 layer->ambisonics_mode = ambisonics_mode;
555 if (ambisonics_mode == 0) {
556 for (int i = 0; i < substream_count; i++) {
557 IAMFSubStream *substream = &audio_element->substreams[i];
558
560
561 ret = update_extradata(substream->codecpar);
562 if (ret < 0)
563 return ret;
564 }
565
566 ret = av_channel_layout_custom_init(&layer->ch_layout, output_channel_count);
567 if (ret < 0)
568 return ret;
569
570 for (int i = 0; i < output_channel_count; i++)
572
574 if (ret < 0 && ret != AVERROR(ENOSYS))
575 return ret;
576 } else {
577 int coupled_substream_count = avio_r8(pb); // M
578 int count = substream_count + coupled_substream_count;
579 int nb_demixing_matrix = count * output_channel_count;
580
581 audio_element->layers->coupled_substream_count = coupled_substream_count;
582
583 layer->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = output_channel_count };
584 layer->demixing_matrix = av_malloc_array(nb_demixing_matrix, sizeof(*layer->demixing_matrix));
585 if (!layer->demixing_matrix)
586 return AVERROR(ENOMEM);
587
588 layer->nb_demixing_matrix = nb_demixing_matrix;
589
590 for (int i = 0; i < layer->nb_demixing_matrix; i++)
591 layer->demixing_matrix[i] = av_make_q(sign_extend(avio_rb16(pb), 16), 1 << 15);
592
593 for (int i = 0; i < substream_count; i++) {
594 IAMFSubStream *substream = &audio_element->substreams[i];
595
596 substream->codecpar->ch_layout = coupled_substream_count-- > 0 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO :
598
599
600 ret = update_extradata(substream->codecpar);
601 if (ret < 0)
602 return ret;
603 }
604 }
605
606 return 0;
607}
608
609static int param_parse(void *s, IAMFContext *c, AVIOContext *pb,
610 unsigned int type,
611 const IAMFAudioElement *audio_element,
612 const IAMFCodecConfig *codec_config,
613 AVIAMFParamDefinition **out_param_definition)
614{
617 unsigned int parameter_id, parameter_rate, mode;
618 unsigned int duration = 0, constant_subblock_duration = 0, nb_subblocks = 0;
619 unsigned int total_duration = 0;
620 size_t param_size;
621
622 parameter_id = ffio_read_leb(pb);
623
624 for (int i = 0; i < c->nb_param_definitions; i++)
625 if (c->param_definitions[i]->param->parameter_id == parameter_id) {
626 param_definition = c->param_definitions[i];
627 break;
628 }
629
630 parameter_rate = ffio_read_leb(pb);
631 mode = avio_r8(pb) >> 7;
632
633 if (mode == 0) {
635 if (!duration || duration > av_rescale(codec_config->nb_samples,
636 codec_config->sample_rate, parameter_rate)) {
637 av_log(s, AV_LOG_ERROR, "Invalid block duration in parameter_id %u\n", parameter_id);
638 return AVERROR_INVALIDDATA;
639 }
640 constant_subblock_duration = ffio_read_leb(pb);
641 if (constant_subblock_duration == 0)
642 nb_subblocks = ffio_read_leb(pb);
643 else {
644 if (constant_subblock_duration > duration) {
645 av_log(s, AV_LOG_ERROR, "Invalid block duration in parameter_id %u\n", parameter_id);
646 return AVERROR_INVALIDDATA;
647 }
648 nb_subblocks = duration / constant_subblock_duration;
649 total_duration = duration;
650 }
651 }
652
653 if (nb_subblocks > duration) {
654 av_log(s, AV_LOG_ERROR, "Invalid duration or subblock count in parameter_id %u\n", parameter_id);
655 return AVERROR_INVALIDDATA;
656 }
657
658 param = av_iamf_param_definition_alloc(type, nb_subblocks, &param_size);
659 if (!param)
660 return AVERROR(ENOMEM);
661
662 for (int i = 0; i < nb_subblocks; i++) {
663 void *subblock = av_iamf_param_definition_get_subblock(param, i);
664 unsigned int subblock_duration = constant_subblock_duration;
665
666 if (constant_subblock_duration == 0) {
667 subblock_duration = ffio_read_leb(pb);
668 if (subblock_duration > duration - total_duration) {
669 av_log(s, AV_LOG_ERROR, "Invalid subblock durations in parameter_id %u\n", parameter_id);
670 av_free(param);
671 return AVERROR_INVALIDDATA;
672 }
673 total_duration += subblock_duration;
674 } else if (i == nb_subblocks - 1)
675 subblock_duration = duration - i * constant_subblock_duration;
676
677 switch (type) {
679 AVIAMFMixGain *mix = subblock;
680 mix->subblock_duration = subblock_duration;
681 break;
682 }
684 AVIAMFDemixingInfo *demix = subblock;
685 demix->subblock_duration = subblock_duration;
686 // DefaultDemixingInfoParameterData
687 av_assert0(audio_element);
688 demix->dmixp_mode = avio_r8(pb) >> 5;
689 audio_element->element->default_w = avio_r8(pb) >> 4;
690 break;
691 }
693 AVIAMFReconGain *recon = subblock;
694 recon->subblock_duration = subblock_duration;
695 break;
696 }
697 default:
698 av_free(param);
699 return AVERROR_INVALIDDATA;
700 }
701 }
702
703 if (!mode && !constant_subblock_duration && total_duration != duration) {
704 av_log(s, AV_LOG_ERROR, "Invalid subblock durations in parameter_id %u\n", parameter_id);
705 av_free(param);
706 return AVERROR_INVALIDDATA;
707 }
708
709 param->parameter_id = parameter_id;
710 param->parameter_rate = parameter_rate;
711 param->duration = duration;
712 param->constant_subblock_duration = constant_subblock_duration;
713 param->nb_subblocks = nb_subblocks;
714
715 if (param_definition) {
716 if (param_definition->param_size != param_size || memcmp(param_definition->param, param, param_size)) {
717 av_log(s, AV_LOG_ERROR, "Inconsistent parameters for parameter_id %u\n", parameter_id);
718 av_free(param);
719 return AVERROR_INVALIDDATA;
720 }
721 } else {
722 IAMFParamDefinition **tmp = av_realloc_array(c->param_definitions, c->nb_param_definitions + 1,
723 sizeof(*c->param_definitions));
724 if (!tmp) {
725 av_free(param);
726 return AVERROR(ENOMEM);
727 }
728 c->param_definitions = tmp;
729
731 if (!param_definition) {
732 av_free(param);
733 return AVERROR(ENOMEM);
734 }
735 param_definition->param = param;
736 param_definition->mode = !mode;
737 param_definition->param_size = param_size;
738 param_definition->audio_element = audio_element;
739
740 c->param_definitions[c->nb_param_definitions++] = param_definition;
741 }
742
743 av_assert0(out_param_definition);
744 *out_param_definition = param;
745
746 return 0;
747}
748
749static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
750{
751 const IAMFCodecConfig *codec_config;
752 AVIAMFAudioElement *element;
753 IAMFAudioElement **tmp, *audio_element = NULL;
755 AVIOContext *pbc;
756 uint8_t *buf;
757 unsigned audio_element_id, nb_substreams, codec_config_id, num_parameters;
758 int audio_element_type, ret;
759
760 buf = av_malloc(len);
761 if (!buf)
762 return AVERROR(ENOMEM);
763
764 ret = ffio_read_size(pb, buf, len);
765 if (ret < 0)
766 goto fail;
767
768 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
769 pbc = &b.pub;
770
771 audio_element_id = ffio_read_leb(pbc);
772
773 for (int i = 0; i < c->nb_audio_elements; i++)
774 if (c->audio_elements[i]->audio_element_id == audio_element_id) {
775 av_log(s, AV_LOG_ERROR, "Duplicate audio_element_id %d\n", audio_element_id);
777 goto fail;
778 }
779
780 audio_element_type = avio_r8(pbc) >> 5;
781 if (audio_element_type > AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
782 av_log(s, AV_LOG_DEBUG, "Unknown audio_element_type referenced in an audio element. Ignoring\n");
783 ret = 0;
784 goto fail;
785 }
786
787 codec_config_id = ffio_read_leb(pbc);
788
789 codec_config = ff_iamf_get_codec_config(c, codec_config_id);
790 if (!codec_config) {
791 av_log(s, AV_LOG_ERROR, "Non existent codec config id %d referenced in an audio element\n", codec_config_id);
793 goto fail;
794 }
795
796 if (codec_config->codec_id == AV_CODEC_ID_NONE) {
797 av_log(s, AV_LOG_DEBUG, "Unknown codec id referenced in an audio element. Ignoring\n");
798 ret = 0;
799 goto fail;
800 }
801
802 tmp = av_realloc_array(c->audio_elements, c->nb_audio_elements + 1, sizeof(*c->audio_elements));
803 if (!tmp) {
804 ret = AVERROR(ENOMEM);
805 goto fail;
806 }
807 c->audio_elements = tmp;
808
809 audio_element = av_mallocz(sizeof(*audio_element));
810 if (!audio_element) {
811 ret = AVERROR(ENOMEM);
812 goto fail;
813 }
814
815 nb_substreams = ffio_read_leb(pbc);
816 /* Each substream consumes at least one byte (its leb128 id) from the
817 * remaining OBU buffer, so a count larger than that cannot be valid and
818 * would only serve to force an oversized allocation. */
819 if (nb_substreams > len - avio_tell(pbc) || !nb_substreams) {
821 goto fail;
822 }
823 audio_element->codec_config_id = codec_config_id;
824 audio_element->audio_element_id = audio_element_id;
825 audio_element->substreams = av_calloc(nb_substreams, sizeof(*audio_element->substreams));
826 if (!audio_element->substreams) {
827 ret = AVERROR(ENOMEM);
828 goto fail;
829 }
830 audio_element->nb_substreams = nb_substreams;
831
832 element = audio_element->element = av_iamf_audio_element_alloc();
833 if (!element) {
834 ret = AVERROR(ENOMEM);
835 goto fail;
836 }
837 audio_element->celement = element;
838
839 element->audio_element_type = audio_element_type;
840
841 for (int i = 0; i < audio_element->nb_substreams; i++) {
842 IAMFSubStream *substream = &audio_element->substreams[i];
843
844 substream->codecpar = avcodec_parameters_alloc();
845 if (!substream->codecpar) {
846 ret = AVERROR(ENOMEM);
847 goto fail;
848 }
849
850 substream->audio_substream_id = ffio_read_leb(pbc);
851
853 substream->codecpar->codec_id = codec_config->codec_id;
854 substream->codecpar->frame_size = codec_config->nb_samples;
855 substream->codecpar->sample_rate = codec_config->sample_rate;
856 substream->codecpar->seek_preroll = -codec_config->audio_roll_distance * codec_config->nb_samples;
857
858 switch(substream->codecpar->codec_id) {
859 case AV_CODEC_ID_AAC:
860 case AV_CODEC_ID_FLAC:
861 case AV_CODEC_ID_OPUS:
863 if (!substream->codecpar->extradata) {
864 ret = AVERROR(ENOMEM);
865 goto fail;
866 }
867 memcpy(substream->codecpar->extradata, codec_config->extradata, codec_config->extradata_size);
868 memset(substream->codecpar->extradata + codec_config->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
869 substream->codecpar->extradata_size = codec_config->extradata_size;
870 break;
871 }
872 }
873
874 num_parameters = ffio_read_leb(pbc);
875 if (num_parameters > 2 && audio_element_type == 0) {
876 av_log(s, AV_LOG_ERROR, "Audio Element parameter count %u is invalid"
877 " for Channel representations\n", num_parameters);
879 goto fail;
880 }
881 if (num_parameters && audio_element_type != 0) {
882 av_log(s, AV_LOG_ERROR, "Audio Element parameter count %u is invalid"
883 " for Scene representations\n", num_parameters);
885 goto fail;
886 }
887
888 for (int i = 0; i < num_parameters; i++) {
889 unsigned type;
890
891 type = ffio_read_leb(pbc);
895 if (element->demixing_info) {
897 goto fail;
898 }
899 ret = param_parse(s, c, pbc, type,
900 audio_element, codec_config,
901 &element->demixing_info);
903 if (element->recon_gain_info) {
905 goto fail;
906 }
907 ret = param_parse(s, c, pbc, type,
908 audio_element, codec_config,
909 &element->recon_gain_info);
910 } else {
911 unsigned param_definition_size = ffio_read_leb(pbc);
912 avio_skip(pbc, param_definition_size);
913 }
914 if (ret < 0)
915 goto fail;
916 }
917
918 if (audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL) {
919 ret = scalable_channel_layout_config(s, pbc, audio_element, codec_config);
920 if (ret < 0)
921 goto fail;
922 } else if (audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
923 ret = ambisonics_config(s, pbc, audio_element, codec_config);
924 if (ret < 0)
925 goto fail;
926 } else {
927 av_unreachable("audio_element_type should have been checked above");
928 }
929
930 c->audio_elements[c->nb_audio_elements++] = audio_element;
931
932 len -= avio_tell(pbc);
933 if (len)
934 av_log(s, AV_LOG_WARNING, "Underread in audio_element_obu. %d bytes left at the end\n", len);
935
936 ret = 0;
937fail:
938 av_free(buf);
939 if (ret < 0)
940 ff_iamf_free_audio_element(&audio_element);
941 return ret;
942}
943
944static int label_string(AVIOContext *pb, char **label)
945{
946 uint8_t buf[128];
947
948 avio_get_str(pb, sizeof(buf), buf, sizeof(buf));
949
950 if (pb->error)
951 return pb->error;
952 if (pb->eof_reached)
953 return AVERROR_INVALIDDATA;
954 *label = av_strdup(buf);
955 if (!*label)
956 return AVERROR(ENOMEM);
957
958 return 0;
959}
960
961static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
962{
964 const IAMFCodecConfig *codec_config = NULL;
965 IAMFMixPresentation **tmp, *mix_presentation = NULL;
967 AVIOContext *pbc;
968 uint8_t *buf;
969 unsigned nb_submixes, mix_presentation_id;
970 int ret;
971
972 buf = av_malloc(len);
973 if (!buf)
974 return AVERROR(ENOMEM);
975
976 ret = ffio_read_size(pb, buf, len);
977 if (ret < 0)
978 goto fail;
979
980 ffio_init_context(&b, buf, len, 0, NULL, NULL, NULL, NULL);
981 pbc = &b.pub;
982
983 mix_presentation_id = ffio_read_leb(pbc);
984
985 for (int i = 0; i < c->nb_mix_presentations; i++)
986 if (c->mix_presentations[i]->mix_presentation_id == mix_presentation_id) {
987 av_log(s, AV_LOG_ERROR, "Duplicate mix_presentation_id %d\n", mix_presentation_id);
989 goto fail;
990 }
991
992 tmp = av_realloc_array(c->mix_presentations, c->nb_mix_presentations + 1, sizeof(*c->mix_presentations));
993 if (!tmp) {
994 ret = AVERROR(ENOMEM);
995 goto fail;
996 }
997 c->mix_presentations = tmp;
998
999 mix_presentation = av_mallocz(sizeof(*mix_presentation));
1000 if (!mix_presentation) {
1001 ret = AVERROR(ENOMEM);
1002 goto fail;
1003 }
1004
1005 mix_presentation->mix_presentation_id = mix_presentation_id;
1006 mix = mix_presentation->mix = av_iamf_mix_presentation_alloc();
1007 if (!mix) {
1008 ret = AVERROR(ENOMEM);
1009 goto fail;
1010 }
1011 mix_presentation->cmix = mix;
1012
1013 mix_presentation->count_label = ffio_read_leb(pbc);
1014 if (mix_presentation->count_label > len - avio_tell(pbc)) {
1015 mix_presentation->count_label = 0;
1016 ret = AVERROR_INVALIDDATA;
1017 goto fail;
1018 }
1019 mix_presentation->language_label = av_calloc(mix_presentation->count_label,
1020 sizeof(*mix_presentation->language_label));
1021 if (!mix_presentation->language_label) {
1022 mix_presentation->count_label = 0;
1023 ret = AVERROR(ENOMEM);
1024 goto fail;
1025 }
1026
1027 for (int i = 0; i < mix_presentation->count_label; i++) {
1028 ret = label_string(pbc, &mix_presentation->language_label[i]);
1029 if (ret < 0)
1030 goto fail;
1031 }
1032
1033 for (int i = 0; i < mix_presentation->count_label; i++) {
1034 char *annotation = NULL;
1035 ret = label_string(pbc, &annotation);
1036 if (ret < 0)
1037 goto fail;
1038 ret = av_dict_set(&mix->annotations, mix_presentation->language_label[i], annotation,
1040 if (ret < 0)
1041 goto fail;
1042 }
1043
1044 nb_submixes = ffio_read_leb(pbc);
1045 if (!nb_submixes) {
1046 av_log(s, AV_LOG_ERROR, "Mix presentation %u has no submixes\n", mix_presentation_id);
1047 ret = AVERROR_INVALIDDATA;
1048 goto fail;
1049 }
1050
1051 for (int i = 0; i < nb_submixes; i++) {
1052 AVIAMFSubmix *sub_mix;
1053 unsigned nb_elements, nb_layouts;
1054
1056 if (!sub_mix) {
1057 ret = AVERROR(ENOMEM);
1058 goto fail;
1059 }
1060
1061 nb_elements = ffio_read_leb(pbc);
1062 if (!nb_elements) {
1063 av_log(s, AV_LOG_ERROR, "Submix %d from Mix presentation %u has no audio elements\n",
1064 i, mix_presentation_id);
1065 ret = AVERROR_INVALIDDATA;
1066 goto fail;
1067 }
1068
1069 for (int j = 0; j < nb_elements; j++) {
1070 AVIAMFSubmixElement *submix_element;
1071 IAMFAudioElement *audio_element = NULL;
1072 const IAMFCodecConfig *config = NULL;
1073 unsigned int rendering_config_extension_size;
1074
1075 submix_element = av_iamf_submix_add_element(sub_mix);
1076 if (!submix_element) {
1077 ret = AVERROR(ENOMEM);
1078 goto fail;
1079 }
1080
1081 submix_element->audio_element_id = ffio_read_leb(pbc);
1082
1083 for (int k = 0; k < c->nb_audio_elements; k++)
1084 if (c->audio_elements[k]->audio_element_id == submix_element->audio_element_id) {
1085 audio_element = c->audio_elements[k];
1086 break;
1087 }
1088
1089 if (!audio_element) {
1090 av_log(s, AV_LOG_ERROR, "Invalid Audio Element with id %u referenced by Mix Parameters %u\n",
1091 submix_element->audio_element_id, mix_presentation_id);
1092 ret = AVERROR_INVALIDDATA;
1093 goto fail;
1094 }
1095 config = ff_iamf_get_codec_config(c, audio_element->codec_config_id);
1096
1097 for (int k = 0; k < mix_presentation->count_label; k++) {
1098 char *annotation = NULL;
1099 ret = label_string(pbc, &annotation);
1100 if (ret < 0)
1101 goto fail;
1102 ret = av_dict_set(&submix_element->annotations, mix_presentation->language_label[k], annotation,
1104 if (ret < 0)
1105 goto fail;
1106 }
1107
1108 submix_element->headphones_rendering_mode = avio_r8(pbc) >> 6;
1109
1110 rendering_config_extension_size = ffio_read_leb(pbc);
1111 avio_skip(pbc, rendering_config_extension_size);
1112
1114 audio_element, config,
1115 &submix_element->element_mix_config);
1116 if (ret < 0)
1117 goto fail;
1118 submix_element->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1119
1120 if (!codec_config || (config->nb_samples >
1121 av_rescale(codec_config->nb_samples,
1122 codec_config->sample_rate,
1123 config->sample_rate)))
1124 codec_config = config;
1125 }
1126
1128 NULL, codec_config,
1129 &sub_mix->output_mix_config);
1130 if (ret < 0)
1131 goto fail;
1132 sub_mix->default_mix_gain = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1133
1134 nb_layouts = ffio_read_leb(pbc);
1135 for (int j = 0; j < nb_layouts; j++) {
1136 AVIAMFSubmixLayout *submix_layout;
1137 int info_type;
1138 int byte = avio_r8(pbc);
1139
1140 submix_layout = av_iamf_submix_add_layout(sub_mix);
1141 if (!submix_layout) {
1142 ret = AVERROR(ENOMEM);
1143 goto fail;
1144 }
1145
1146 submix_layout->layout_type = byte >> 6;
1149 av_log(s, AV_LOG_ERROR, "Invalid Layout type %u in a submix from Mix Presentation %u\n",
1150 submix_layout->layout_type, mix_presentation_id);
1151 ret = AVERROR_INVALIDDATA;
1152 goto fail;
1153 }
1154 if (submix_layout->layout_type == 2) {
1155 int sound_system;
1156 sound_system = (byte >> 2) & 0xF;
1157 if (sound_system >= FF_ARRAY_ELEMS(ff_iamf_sound_system_map)) {
1158 ret = AVERROR_INVALIDDATA;
1159 goto fail;
1160 }
1161 av_channel_layout_copy(&submix_layout->sound_system, &ff_iamf_sound_system_map[sound_system].layout);
1162 } else
1164
1165 info_type = avio_r8(pbc);
1166 submix_layout->integrated_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1167 submix_layout->digital_peak = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1168
1169 if (info_type & 1)
1170 submix_layout->true_peak = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1171 if (info_type & 2) {
1172 unsigned int num_anchored_loudness = avio_r8(pbc);
1173
1174 for (int k = 0; k < num_anchored_loudness; k++) {
1175 unsigned int anchor_element = avio_r8(pbc);
1176 AVRational anchored_loudness = av_make_q(sign_extend(avio_rb16(pbc), 16), 1 << 8);
1177 if (anchor_element == IAMF_ANCHOR_ELEMENT_DIALOGUE)
1178 submix_layout->dialogue_anchored_loudness = anchored_loudness;
1179 else if (anchor_element <= IAMF_ANCHOR_ELEMENT_ALBUM)
1180 submix_layout->album_anchored_loudness = anchored_loudness;
1181 else
1182 av_log(s, AV_LOG_DEBUG, "Unknown anchor_element. Ignoring\n");
1183 }
1184 }
1185
1186 if (info_type & 0xFC) {
1187 unsigned int info_type_size = ffio_read_leb(pbc);
1188 avio_skip(pbc, info_type_size);
1189 }
1190 }
1191 }
1192
1193 c->mix_presentations[c->nb_mix_presentations++] = mix_presentation;
1194
1195 len -= avio_tell(pbc);
1196 if (len)
1197 av_log(s, AV_LOG_WARNING, "Underread in mix_presentation_obu. %d bytes left at the end\n", len);
1198
1199 ret = 0;
1200fail:
1201 av_free(buf);
1202 if (ret < 0)
1203 ff_iamf_free_mix_presentation(&mix_presentation);
1204 return ret;
1205}
1206
1207int ff_iamf_parse_obu_header(const uint8_t *buf, int buf_size,
1208 unsigned *obu_size, int *start_pos, enum IAMF_OBU_Type *type,
1209 unsigned *skip_samples, unsigned *discard_padding)
1210{
1211 GetBitContext gb;
1212 int ret, extension_flag, trimming, start;
1213 unsigned skip = 0, discard = 0;
1214 unsigned size;
1215
1216 ret = init_get_bits8(&gb, buf, FFMIN(buf_size, MAX_IAMF_OBU_HEADER_SIZE));
1217 if (ret < 0)
1218 return ret;
1219
1220 *type = get_bits(&gb, 5);
1221 /*redundant =*/ get_bits1(&gb);
1222 trimming = get_bits1(&gb);
1223 extension_flag = get_bits1(&gb);
1224
1225 *obu_size = get_leb(&gb);
1226 if (*obu_size > INT_MAX)
1227 return AVERROR_INVALIDDATA;
1228
1229 start = get_bits_count(&gb) / 8;
1230
1231 if (trimming) {
1232 discard = get_leb(&gb); // num_samples_to_trim_at_end
1233 skip = get_leb(&gb); // num_samples_to_trim_at_start
1234 }
1235
1236 if (skip_samples)
1237 *skip_samples = skip;
1238 if (discard_padding)
1239 *discard_padding = discard;
1240
1241 if (extension_flag) {
1242 unsigned int extension_bytes;
1243 extension_bytes = get_leb(&gb);
1244 if (extension_bytes > INT_MAX / 8)
1245 return AVERROR_INVALIDDATA;
1246 skip_bits_long(&gb, extension_bytes * 8);
1247 }
1248
1249 if (get_bits_left(&gb) < 0)
1250 return AVERROR_INVALIDDATA;
1251
1252 size = *obu_size + start;
1253 if (size > INT_MAX)
1254 return AVERROR_INVALIDDATA;
1255
1256 *obu_size -= get_bits_count(&gb) / 8 - start;
1257 *start_pos = size - *obu_size;
1258
1259 return size;
1260}
1261
1263 int max_size, void *log_ctx)
1264{
1266 int ret;
1267
1268 while (1) {
1269 unsigned obu_size;
1270 enum IAMF_OBU_Type type;
1271 int start_pos, len, size;
1272
1273 if ((ret = ffio_ensure_seekback(pb, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, max_size))) < 0)
1274 return ret;
1276 if (size < 0)
1277 return size;
1279
1280 len = ff_iamf_parse_obu_header(header, size, &obu_size, &start_pos, &type, NULL, NULL);
1281 if (len < 0 || obu_size > max_size) {
1282 av_log(log_ctx, AV_LOG_ERROR, "Failed to read obu header\n");
1283 avio_seek(pb, -size, SEEK_CUR);
1284 return len;
1285 }
1286
1288 avio_seek(pb, -size, SEEK_CUR);
1289 break;
1290 }
1291
1292 avio_seek(pb, -(size - start_pos), SEEK_CUR);
1293 switch (type) {
1295 ret = codec_config_obu(log_ctx, c, pb, obu_size);
1296 break;
1298 ret = audio_element_obu(log_ctx, c, pb, obu_size);
1299 break;
1301 ret = mix_presentation_obu(log_ctx, c, pb, obu_size);
1302 break;
1303 default: {
1304 int64_t offset = avio_skip(pb, obu_size);
1305 if (offset < 0)
1306 ret = offset;
1307 break;
1308 }
1309 }
1310 if (ret < 0) {
1311 av_log(log_ctx, AV_LOG_ERROR, "Failed to read obu type %d\n", type);
1312 return ret;
1313 }
1314 max_size -= obu_size + start_pos;
1315 if (max_size < 0)
1316 return AVERROR_INVALIDDATA;
1317 if (!max_size)
1318 break;
1319 }
1320
1321 return 0;
1322}
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)
Definition aviobuf.c:749
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
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:869
unsigned int avio_rb32(AVIOContext *s)
Definition aviobuf.c:764
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:1026
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:930
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:330
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:343
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:330
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_PCM_S16BE
Definition codec_id.h:331
@ AV_CODEC_ID_PCM_S24LE
Definition codec_id.h:342
@ AV_CODEC_ID_PCM_S32LE
Definition codec_id.h:338
@ AV_CODEC_ID_AAC
Definition codec_id.h:455
@ AV_CODEC_ID_FLAC
Definition codec_id.h:465
@ AV_CODEC_ID_PCM_S32BE
Definition codec_id.h:339
@ AV_CODEC_ID_OPUS
Definition codec_id.h:513
#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:86
#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:217
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
cl_device_type type
static int ambisonics_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
Definition iamf_parse.c:520
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:166
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:350
static int update_extradata(AVCodecParameters *codecpar)
Definition iamf_parse.c:274
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:609
static int flac_decoder_config(IAMFCodecConfig *codec_config, AVIOContext *pb, int len)
Definition iamf_parse.c:117
static int label_string(AVIOContext *pb, char **label)
Definition iamf_parse.c:944
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:145
static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
Definition iamf_parse.c:749
static int scalable_channel_layout_config(void *s, AVIOContext *pb, IAMFAudioElement *audio_element, const IAMFCodecConfig *codec_config)
Definition iamf_parse.c:385
static int mix_presentation_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
Definition iamf_parse.c:961
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:404
#define MP4DecSpecificDescrTag
Definition isom.h:405
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition j2kenc.c:154
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_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:264
Memory handling functions.
uint32_t tag
Definition movenc.c:2073
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
static FILE * out
Definition movenc.c:55
int size
enum AVCodecID codec_id
int len
static double c[64]