FFmpeg: libavformat/iamfdec.c Source File
Go to the documentation of this file. 1 /*
2 * Immersive Audio Model and Formats demuxer
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
30
31 //return < 0 if we need more data
33 {
36 return 0;
37 *seq = 1;
38 return -1;
39 }
41 return *seq ? -1 : 0;
44 return 0;
45 }
46
48 {
49 unsigned obu_size;
51 int seq = 0, cnt = 0, start_pos;
53
54 while (1) {
56 &obu_size, &start_pos, &
type,
59 return 0;
60
62 p->buf_size - cnt - start_pos,
66
68 }
69 return 0;
70 }
71
73 {
77
81
85
86 if (!stg)
88
91 /* Transfer ownership */
94
98
99 if (!st)
101
105
109
116 }
117 }
118
123
124 if (!stg)
126
129 /* Transfer ownership */
132
133 for (
int j = 0; j <
mix->nb_submixes; j++) {
135
139
140 for (
int l = 0; l <
s->nb_stream_groups; l++)
143 audio_element =
s->stream_groups[l];
144 break;
145 }
147
148 for (
int l = 0; l < audio_element->
nb_streams; l++) {
152 }
153 }
154 }
155 }
156
159
160 return 0;
161 }
162
164 {
167
171
172 return 0;
173 }
174
176 {
178
180
181 return 0;
182 }
183
187 .p.extensions = "iamf",
195 };
AVIAMFSubmixElement ** elements
Array of submix elements.
int64_t id
Group type-specific group ID.
static int mix(int c0, int c1)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
unsigned int nb_substreams
int ff_iamf_read_packet(AVFormatContext *s, IAMFDemuxContext *c, AVIOContext *pb, int max_size, int stream_id_offset, AVPacket *pkt)
static int iamf_probe(const AVProbeData *p)
void av_iamf_mix_presentation_free(AVIAMFMixPresentation **pmix_presentation)
Free an AVIAMFMixPresentation and all its contents.
static int iamf_read_header(AVFormatContext *s)
const AVIAMFMixPresentation * cmix
union AVStreamGroup::@410 params
Group type-specific parameters.
void av_iamf_audio_element_free(AVIAMFAudioElement **paudio_element)
Free an AVIAMFAudioElement and all its contents.
static av_cold int read_close(AVFormatContext *ctx)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
AVIAMFAudioElement * element
element backs celement iff the AVIAMFAudioElement is owned by this structure.
IAMFAudioElement ** audio_elements
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
unsigned int audio_substream_id
unsigned int substream_count
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_iamfdec_read_descriptors(IAMFContext *c, AVIOContext *pb, int max_size, void *log_ctx)
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
unsigned int audio_element_id
static int iamf_read_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
This structure contains the data a format has to probe a file.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
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)
unsigned int audio_element_id
The id of the Audio Element this submix element references.
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Add an already allocated stream to a stream group.
Submix layout as defined in section 3.7 of IAMF.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define MKBETAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
struct AVIAMFAudioElement * iamf_audio_element
IAMFSubStream * substreams
static int read_header(FFV1Context *f, RangeCoder *c)
AVStream ** streams
A list of streams in the group.
struct AVIAMFMixPresentation * iamf_mix_presentation
#define i(width, name, range_min, range_max)
static int get_score(const uint8_t *buf, int buf_size, enum IAMF_OBU_Type type, int *seq)
Information on how to render and mix one or more AVIAMFAudioElement to generate the final audio outpu...
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
int id
Format-specific stream ID.
const FFInputFormat ff_iamf_demuxer
static int iamf_read_close(AVFormatContext *s)
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
unsigned int nb_elements
Number of elements in the submix.
static int read_probe(const AVProbeData *p)
IAMFMixPresentation ** mix_presentations
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
This structure stores compressed data.
Submix element as defined in section 3.7 of IAMF.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVIAMFMixPresentation * mix
mix backs cmix iff the AVIAMFMixPresentation is owned by this structure.
AVCodecParameters * codecpar
unsigned int mix_presentation_id
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
void ff_iamf_read_deinit(IAMFDemuxContext *c)
Generated on Sat Oct 18 2025 19:23:22 for FFmpeg by
doxygen
1.8.17