FFmpeg: libavformat/aaxdec.c Source File
Go to the documentation of this file. 1 /*
2 * AAX demuxer
3 * Copyright (c) 2020 Paul B Mahol
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
27
35
40
54
56
60
62 {
64 return 0;
66 return 0;
68 return 0;
70 return 0;
71
73 }
74
80 };
81
97 };
98
100 {
103
104 for (
int seg = 0; seg <
a->current_segment; seg++)
105 pts += (
a->segments[seg].end -
a->segments[seg].start) /
size;
106
107 pts += ((
pos -
a->segments[
a->current_segment].start) /
size);
108
110 }
111
113 {
118 int64_t column_offset = 0;
119 int ret, extradata_size;
120 char *codec;
121 int64_t ret64;
122
133
134 if (
a->nb_segments < 1)
136
137 a->schema_offset = 0x20;
138 a->strings_size =
a->data_offset -
a->strings_offset;
139
140 if (
a->rows_offset >
a->table_size ||
141 a->strings_offset >
a->table_size ||
142 a->data_offset >
a->table_size)
144 if (
a->strings_size <= 0 ||
a->name_offset >=
a->strings_size ||
145 a->strings_size > UINT16_MAX)
149
150 a->segments =
av_calloc(
a->nb_segments,
sizeof(*
a->segments));
153
154 a->xcolumns =
av_calloc(
a->columns,
sizeof(*
a->xcolumns));
157
158 a->string_table =
av_calloc(
a->strings_size + 1,
sizeof(*
a->string_table));
159 if (!
a->string_table)
161
162 for (
int c = 0;
c <
a->columns;
c++) {
165 int value_size;
166
169
170 a->xcolumns[
c].flag =
info >> 4;
171 a->xcolumns[
c].type =
info & 0x0F;
172
173 switch (
a->xcolumns[
c].type) {
176 value_size = 0x01;
177 break;
180 value_size = 0x02;
181 break;
186 value_size = 0x04;
187 break;
189 value_size = 0x08;
190 break;
192 value_size = 0x10;
193 break;
194 default:
196 }
197
198 a->xcolumns[
c].size = value_size;
199
201 a->xcolumns[
c].name =
a->string_table +
offset;
202
204 /* data is found relative to columns start */
205 a->xcolumns[
c].offset =
avio_tell(pb) -
a->schema_offset;
207 }
208
210 /* data is found relative to row start */
211 a->xcolumns[
c].offset = column_offset;
212 column_offset += value_size;
213 }
214 }
215
217 if (ret64 < 0)
219
223
224 for (
int c = 0;
c <
a->columns;
c++) {
225 int64_t data_offset = 0;
226 int64_t col_offset;
228
229 if (!
a->xcolumns[
c].name || strcmp(
a->xcolumns[
c].name,
"data"))
230 continue;
231
232 type =
a->xcolumns[
c].type;
233 flag =
a->xcolumns[
c].flag;
234 col_offset =
a->xcolumns[
c].offset;
235
236 for (uint64_t
r = 0;
r <
a->nb_segments;
r++) {
238 data_offset =
a->schema_offset + col_offset;
240 data_offset =
a->rows_offset +
r *
a->row_width + col_offset;
241 } else
243
245 if (ret64 < 0)
247
250
255 a->segments[
r].start = start +
a->data_offset;
256 a->segments[
r].end =
a->segments[
r].start +
size;
258 a->segments[
r].start <
a->segments[
r-1].end &&
259 a->segments[
r].end >
a->segments[
r-1].start)
261 } else
263 }
264 }
265
266 if (!
a->segments[0].end)
268
270 if (!st)
273 par =
s->streams[0]->codecpar;
275
276 codec =
a->string_table +
a->name_offset;
277 if (!strcmp(codec, "AAX")) {
279 ret64 =
avio_seek(pb,
a->segments[0].start, SEEK_SET);
280 if (ret64 < 0 ||
avio_rb16(pb) != 0x8000)
283 if (extradata_size < 12)
293
295 /*} else if (!strcmp(codec, "HCA") ){
296 par->codec_id = AV_CODEC_ID_HCA;*/
297 } else {
299 }
300
301 return 0;
302 }
303
305 {
310 int ret, extradata_size = 0;
311 uint8_t *extradata =
NULL;
312 int skip = 0;
313
316
318
319 for (uint32_t seg = 0; seg <
a->nb_segments; seg++) {
320 int64_t start =
a->segments[seg].start;
321 int64_t end =
a->segments[seg].end;
322
324 a->current_segment = seg;
326 skip = (end - start) - ((end - start) /
size) *
size;
327 break;
328 }
329 }
330
331 if (
pkt->
pos >=
a->segments[
a->current_segment].end - skip) {
332 if (
a->current_segment + 1 ==
a->nb_segments)
334 a->current_segment++;
335 avio_seek(pb,
a->segments[
a->current_segment].start, SEEK_SET);
336
342 if (extradata_size < 12)
345 if (!extradata)
347 if (
avio_read(pb, extradata, extradata_size) != extradata_size) {
350 }
352 }
353 }
354
359 }
363
364 if (extradata) {
369 }
370 }
371
373 }
374
376 {
378
382
383 return 0;
384 }
385
395 .extensions = "aax",
397 };
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
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 AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
This struct describes the properties of an encoded stream.
#define AVERROR_EOF
End of file.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int aax_probe(const AVProbeData *p)
int nb_channels
Number of channels in this layout.
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
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
static int aax_read_packet(AVFormatContext *s, AVPacket *pkt)
static int aax_read_close(AVFormatContext *s)
unsigned int avio_rb32(AVIOContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int read_header(FFV1Context *f)
static int64_t get_pts(AVFormatContext *s, int64_t pos, int size)
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
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.
#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
int avio_r8(AVIOContext *s)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
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 offset
const AVInputFormat ff_aax_demuxer
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void * av_calloc(size_t nmemb, size_t size)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int avio_rb16(AVIOContext *s)
#define AV_INPUT_BUFFER_PADDING_SIZE
static int aax_read_header(AVFormatContext *s)
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
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_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL AV_RB8
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
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_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Wed Aug 24 2022 21:42:12 for FFmpeg by
doxygen
1.8.17