/* * Immersive Audio Model and Formats parsing * Copyright (c) 2023 James Almer * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVFORMAT_IAMF_PARSE_H #define AVFORMAT_IAMF_PARSE_H #include #include "avio.h" #define MAX_IAMF_OBU_HEADER_SIZE (1 + 8 * 3) // OBU types (section 3.2). enum IAMF_OBU_Type { IAMF_OBU_IA_CODEC_CONFIG = 0, IAMF_OBU_IA_AUDIO_ELEMENT = 1, IAMF_OBU_IA_MIX_PRESENTATION = 2, IAMF_OBU_IA_PARAMETER_BLOCK = 3, IAMF_OBU_IA_TEMPORAL_DELIMITER = 4, IAMF_OBU_IA_AUDIO_FRAME = 5, IAMF_OBU_IA_AUDIO_FRAME_ID0 = 6, IAMF_OBU_IA_AUDIO_FRAME_ID1 = 7, IAMF_OBU_IA_AUDIO_FRAME_ID2 = 8, IAMF_OBU_IA_AUDIO_FRAME_ID3 = 9, IAMF_OBU_IA_AUDIO_FRAME_ID4 = 10, IAMF_OBU_IA_AUDIO_FRAME_ID5 = 11, IAMF_OBU_IA_AUDIO_FRAME_ID6 = 12, IAMF_OBU_IA_AUDIO_FRAME_ID7 = 13, IAMF_OBU_IA_AUDIO_FRAME_ID8 = 14, IAMF_OBU_IA_AUDIO_FRAME_ID9 = 15, IAMF_OBU_IA_AUDIO_FRAME_ID10 = 16, IAMF_OBU_IA_AUDIO_FRAME_ID11 = 17, IAMF_OBU_IA_AUDIO_FRAME_ID12 = 18, IAMF_OBU_IA_AUDIO_FRAME_ID13 = 19, IAMF_OBU_IA_AUDIO_FRAME_ID14 = 20, IAMF_OBU_IA_AUDIO_FRAME_ID15 = 21, IAMF_OBU_IA_AUDIO_FRAME_ID16 = 22, IAMF_OBU_IA_AUDIO_FRAME_ID17 = 23, // 24~30 reserved. IAMF_OBU_IA_SEQUENCE_HEADER = 31, }; typedef struct IAMFCodecConfig { unsigned codec_config_id; enum AVCodecID codec_id; uint32_t codec_tag; unsigned nb_samples; int audio_roll_distance; int sample_rate; int extradata_size; uint8_t *extradata; } IAMFCodecConfig; typedef struct IAMFContext { IAMFCodecConfig **codec_configs; int nb_codec_configs; } IAMFContext; 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); int ff_iamfdec_read_descriptors(IAMFContext *c, AVIOContext *pb, int size, void *log_ctx); void ff_iamf_uninit_context(IAMFContext *c); #endif /* AVFORMAT_IAMF_PARSE_H */