FFmpeg
aadec.c
Go to the documentation of this file.
1 /*
2  * Audible AA demuxer
3  * Copyright (c) 2015 Vesselin Bontchev
4  *
5  * Header parsing is borrowed from https://github.com/jteeuwen/audible project.
6  * Copyright (c) 2001-2014, Jim Teeuwen
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "avformat.h"
27 #include "internal.h"
28 #include "libavutil/avstring.h"
29 #include "libavutil/dict.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/tea.h"
32 #include "libavutil/opt.h"
33 
34 #define AA_MAGIC 1469084982 /* this identifies an audible .aa file */
35 #define MAX_CODEC_SECOND_SIZE 3982
36 #define MAX_TOC_ENTRIES 16
37 #define MAX_DICTIONARY_ENTRIES 128
38 #define TEA_BLOCK_SIZE 8
39 #define CHAPTER_HEADER_SIZE 8
40 #define TIMEPREC 1000
41 #define MP3_FRAME_SIZE 104
42 
43 typedef struct AADemuxContext {
44  AVClass *class;
45  uint8_t *aa_fixed_key;
50  struct AVTEA *tea_ctx;
51  uint8_t file_key[16];
53  int64_t content_start;
54  int64_t content_end;
57 
58 static int get_second_size(char *codec_name)
59 {
60  int result = -1;
61 
62  if (!strcmp(codec_name, "mp332")) {
63  result = 3982;
64  } else if (!strcmp(codec_name, "acelp16")) {
65  result = 2000;
66  } else if (!strcmp(codec_name, "acelp85")) {
67  result = 1045;
68  }
69 
70  return result;
71 }
72 
74 {
75  int i, j, idx, largest_idx = -1;
76  uint32_t toc_size, npairs, header_seed = 0, start;
77  char codec_name[64] = {0};
78  uint8_t output[24], dst[8], src[8];
79  int64_t largest_size = -1, current_size = -1, chapter_pos;
80  struct toc_entry {
81  uint32_t offset;
82  uint32_t size;
83  } TOC[MAX_TOC_ENTRIES];
84  uint32_t header_key_part[4];
85  uint8_t header_key[16] = {0};
86  AADemuxContext *c = s->priv_data;
87  AVIOContext *pb = s->pb;
88  AVStream *st;
89  FFStream *sti;
90  int ret;
91 
92  /* parse .aa header */
93  avio_skip(pb, 4); // file size
94  avio_skip(pb, 4); // magic string
95  toc_size = avio_rb32(pb); // TOC size
96  avio_skip(pb, 4); // unidentified integer
97  if (toc_size > MAX_TOC_ENTRIES || toc_size < 2)
98  return AVERROR_INVALIDDATA;
99  for (i = 0; i < toc_size; i++) { // read TOC
100  avio_skip(pb, 4); // TOC entry index
101  TOC[i].offset = avio_rb32(pb); // block offset
102  TOC[i].size = avio_rb32(pb); // block size
103  }
104  avio_skip(pb, 24); // header termination block (ignored)
105  npairs = avio_rb32(pb); // read dictionary entries
106  if (npairs > MAX_DICTIONARY_ENTRIES)
107  return AVERROR_INVALIDDATA;
108  for (i = 0; i < npairs; i++) {
109  char key[128], val[128];
110  uint32_t nkey, nval;
111 
112  avio_skip(pb, 1); // unidentified integer
113  nkey = avio_rb32(pb); // key string length
114  nval = avio_rb32(pb); // value string length
115  avio_get_str(pb, nkey, key, sizeof(key));
116  avio_get_str(pb, nval, val, sizeof(val));
117  if (!strcmp(key, "codec")) {
118  av_log(s, AV_LOG_DEBUG, "Codec is <%s>\n", val);
119  av_strlcpy(codec_name, val, sizeof(codec_name));
120  } else if (!strcmp(key, "HeaderSeed")) {
121  av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val);
122  header_seed = atoi(val);
123  } else if (!strcmp(key, "HeaderKey")) { // this looks like "1234567890 1234567890 1234567890 1234567890"
124  av_log(s, AV_LOG_DEBUG, "HeaderKey is <%s>\n", val);
125 
126  ret = sscanf(val, "%"SCNu32"%"SCNu32"%"SCNu32"%"SCNu32,
127  &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
128  if (ret != 4)
129  return AVERROR_INVALIDDATA;
130 
131  for (idx = 0; idx < 4; idx++) {
132  AV_WB32(&header_key[idx * 4], header_key_part[idx]); // convert each part to BE!
133  }
134  av_log(s, AV_LOG_DEBUG, "Processed HeaderKey is ");
135  for (i = 0; i < 16; i++)
136  av_log(s, AV_LOG_DEBUG, "%02x", header_key[i]);
137  av_log(s, AV_LOG_DEBUG, "\n");
138  } else {
139  av_dict_set(&s->metadata, key, val, 0);
140  }
141  }
142 
143  /* verify fixed key */
144  if (c->aa_fixed_key_len != 16) {
145  av_log(s, AV_LOG_ERROR, "aa_fixed_key value needs to be 16 bytes!\n");
146  return AVERROR(EINVAL);
147  }
148 
149  /* verify codec */
150  if ((c->codec_second_size = get_second_size(codec_name)) == -1) {
151  av_log(s, AV_LOG_ERROR, "unknown codec <%s>!\n", codec_name);
152  return AVERROR(EINVAL);
153  }
154 
155  /* decryption key derivation */
156  c->tea_ctx = av_tea_alloc();
157  if (!c->tea_ctx)
158  return AVERROR(ENOMEM);
159  av_tea_init(c->tea_ctx, c->aa_fixed_key, 16);
160  output[0] = output[1] = 0; // purely for padding purposes
161  memcpy(output + 2, header_key, 16);
162  idx = 0;
163  for (i = 0; i < 3; i++) { // TEA CBC with weird mixed endianness
164  AV_WB32(src, header_seed);
165  AV_WB32(src + 4, header_seed + 1);
166  header_seed += 2;
167  av_tea_crypt(c->tea_ctx, dst, src, 1, NULL, 0); // TEA ECB encrypt
168  for (j = 0; j < TEA_BLOCK_SIZE && idx < 18; j+=1, idx+=1) {
169  output[idx] = output[idx] ^ dst[j];
170  }
171  }
172  memcpy(c->file_key, output + 2, 16); // skip first 2 bytes of output
173  av_log(s, AV_LOG_DEBUG, "File key is ");
174  for (i = 0; i < 16; i++)
175  av_log(s, AV_LOG_DEBUG, "%02x", c->file_key[i]);
176  av_log(s, AV_LOG_DEBUG, "\n");
177 
178  /* decoder setup */
179  st = avformat_new_stream(s, NULL);
180  if (!st)
181  return AVERROR(ENOMEM);
182  sti = ffstream(st);
184  if (!strcmp(codec_name, "mp332")) {
186  st->codecpar->sample_rate = 22050;
188  avpriv_set_pts_info(st, 64, 8, 32000 * TIMEPREC);
189  // encoded audio frame is MP3_FRAME_SIZE bytes (+1 with padding, unlikely)
190  } else if (!strcmp(codec_name, "acelp85")) {
192  st->codecpar->block_align = 19;
193  st->codecpar->channels = 1;
194  st->codecpar->sample_rate = 8500;
195  st->codecpar->bit_rate = 8500;
197  avpriv_set_pts_info(st, 64, 8, 8500 * TIMEPREC);
198  } else if (!strcmp(codec_name, "acelp16")) {
200  st->codecpar->block_align = 20;
201  st->codecpar->channels = 1;
202  st->codecpar->sample_rate = 16000;
203  st->codecpar->bit_rate = 16000;
205  avpriv_set_pts_info(st, 64, 8, 16000 * TIMEPREC);
206  }
207 
208  /* determine, and jump to audio start offset */
209  for (i = 1; i < toc_size; i++) { // skip the first entry!
210  current_size = TOC[i].size;
211  if (current_size > largest_size) {
212  largest_idx = i;
213  largest_size = current_size;
214  }
215  }
216  start = TOC[largest_idx].offset;
217  avio_seek(pb, start, SEEK_SET);
218 
219  // extract chapter positions. since all formats have constant bit rate, use it
220  // as time base in bytes/s, for easy stream position <-> timestamp conversion
221  st->start_time = 0;
222  c->content_start = start;
223  c->content_end = start + largest_size;
224 
225  while ((chapter_pos = avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
226  unsigned chapter_idx = s->nb_chapters;
227  uint32_t chapter_size = avio_rb32(pb);
228  if (chapter_size == 0 || avio_feof(pb))
229  break;
230  chapter_pos -= start + CHAPTER_HEADER_SIZE * chapter_idx;
231  avio_skip(pb, 4 + chapter_size);
232  if (!avpriv_new_chapter(s, chapter_idx, st->time_base,
233  chapter_pos * TIMEPREC,
234  (chapter_pos + chapter_size) * TIMEPREC, NULL))
235  return AVERROR(ENOMEM);
236  }
237 
238  st->duration = (largest_size - CHAPTER_HEADER_SIZE * s->nb_chapters) * TIMEPREC;
239 
240  avpriv_update_cur_dts(s, st, 0);
241  avio_seek(pb, start, SEEK_SET);
242  c->current_chapter_size = 0;
243  c->seek_offset = 0;
244 
245  return 0;
246 }
247 
249 {
250  uint8_t dst[TEA_BLOCK_SIZE];
251  uint8_t src[TEA_BLOCK_SIZE];
252  int i;
253  int trailing_bytes;
254  int blocks;
255  uint8_t buf[MAX_CODEC_SECOND_SIZE * 2];
256  int written = 0;
257  int ret;
258  AADemuxContext *c = s->priv_data;
259  uint64_t pos = avio_tell(s->pb);
260 
261  // are we at the end of the audio content?
262  if (pos >= c->content_end) {
263  return AVERROR_EOF;
264  }
265 
266  // are we at the start of a chapter?
267  if (c->current_chapter_size == 0) {
268  c->current_chapter_size = avio_rb32(s->pb);
269  if (c->current_chapter_size == 0) {
270  return AVERROR_EOF;
271  }
272  av_log(s, AV_LOG_DEBUG, "Chapter %d (%" PRId64 " bytes)\n", c->chapter_idx, c->current_chapter_size);
273  c->chapter_idx = c->chapter_idx + 1;
274  avio_skip(s->pb, 4); // data start offset
275  pos += 8;
276  c->current_codec_second_size = c->codec_second_size;
277  }
278 
279  // is this the last block in this chapter?
280  if (c->current_chapter_size / c->current_codec_second_size == 0) {
281  c->current_codec_second_size = c->current_chapter_size % c->current_codec_second_size;
282  }
283 
284  // decrypt c->current_codec_second_size bytes
285  blocks = c->current_codec_second_size / TEA_BLOCK_SIZE;
286  for (i = 0; i < blocks; i++) {
287  ret = avio_read(s->pb, src, TEA_BLOCK_SIZE);
288  if (ret != TEA_BLOCK_SIZE)
289  return (ret < 0) ? ret : AVERROR_EOF;
290  av_tea_init(c->tea_ctx, c->file_key, 16);
291  av_tea_crypt(c->tea_ctx, dst, src, 1, NULL, 1);
292  memcpy(buf + written, dst, TEA_BLOCK_SIZE);
293  written = written + TEA_BLOCK_SIZE;
294  }
295  trailing_bytes = c->current_codec_second_size % TEA_BLOCK_SIZE;
296  if (trailing_bytes != 0) { // trailing bytes are left unencrypted!
297  ret = avio_read(s->pb, src, trailing_bytes);
298  if (ret != trailing_bytes)
299  return (ret < 0) ? ret : AVERROR_EOF;
300  memcpy(buf + written, src, trailing_bytes);
301  written = written + trailing_bytes;
302  }
303 
304  // update state
305  c->current_chapter_size = c->current_chapter_size - c->current_codec_second_size;
306  if (c->current_chapter_size <= 0)
307  c->current_chapter_size = 0;
308 
309  if (c->seek_offset > written)
310  c->seek_offset = 0; // ignore wrong estimate
311 
312  ret = av_new_packet(pkt, written - c->seek_offset);
313  if (ret < 0)
314  return ret;
315  memcpy(pkt->data, buf + c->seek_offset, written - c->seek_offset);
316  pkt->pos = pos;
317 
318  c->seek_offset = 0;
319  return 0;
320 }
321 
323  int stream_index, int64_t timestamp, int flags)
324 {
325  AADemuxContext *c = s->priv_data;
326  AVChapter *ch;
327  int64_t chapter_pos, chapter_start, chapter_size;
328  int chapter_idx = 0;
329 
330  // find chapter containing seek timestamp
331  if (timestamp < 0)
332  timestamp = 0;
333 
334  while (chapter_idx < s->nb_chapters && timestamp >= s->chapters[chapter_idx]->end) {
335  ++chapter_idx;
336  }
337 
338  if (chapter_idx >= s->nb_chapters) {
339  chapter_idx = s->nb_chapters - 1;
340  if (chapter_idx < 0) return -1; // there is no chapter.
341  timestamp = s->chapters[chapter_idx]->end;
342  }
343 
344  ch = s->chapters[chapter_idx];
345 
346  // sync by clamping timestamp to nearest valid block position in its chapter
347  chapter_size = ch->end / TIMEPREC - ch->start / TIMEPREC;
348  chapter_pos = av_rescale_rnd((timestamp - ch->start) / TIMEPREC,
349  1, c->codec_second_size,
351  * c->codec_second_size;
352  if (chapter_pos >= chapter_size)
353  chapter_pos = chapter_size;
354  chapter_start = c->content_start + (ch->start / TIMEPREC) + CHAPTER_HEADER_SIZE * (1 + chapter_idx);
355 
356  // reinit read state
357  avio_seek(s->pb, chapter_start + chapter_pos, SEEK_SET);
358  c->current_codec_second_size = c->codec_second_size;
359  c->current_chapter_size = chapter_size - chapter_pos;
360  c->chapter_idx = 1 + chapter_idx;
361 
362  // for unaligned frames, estimate offset of first frame in block (assume no padding)
363  if (s->streams[0]->codecpar->codec_id == AV_CODEC_ID_MP3) {
364  c->seek_offset = (MP3_FRAME_SIZE - chapter_pos % MP3_FRAME_SIZE) % MP3_FRAME_SIZE;
365  }
366 
367  avpriv_update_cur_dts(s, s->streams[0], ch->start + (chapter_pos + c->seek_offset) * TIMEPREC);
368 
369  return 1;
370 }
371 
372 static int aa_probe(const AVProbeData *p)
373 {
374  uint8_t *buf = p->buf;
375 
376  // first 4 bytes are file size, next 4 bytes are the magic
377  if (AV_RB32(buf+4) != AA_MAGIC)
378  return 0;
379 
380  return AVPROBE_SCORE_MAX / 2;
381 }
382 
384 {
385  AADemuxContext *c = s->priv_data;
386 
387  av_freep(&c->tea_ctx);
388 
389  return 0;
390 }
391 
392 #define OFFSET(x) offsetof(AADemuxContext, x)
393 static const AVOption aa_options[] = {
394  { "aa_fixed_key", // extracted from libAAX_SDK.so and AAXSDKWin.dll files!
395  "Fixed key used for handling Audible AA files", OFFSET(aa_fixed_key),
396  AV_OPT_TYPE_BINARY, {.str="77214d4b196a87cd520045fd2a51d673"},
397  .flags = AV_OPT_FLAG_DECODING_PARAM },
398  { NULL },
399 };
400 
401 static const AVClass aa_class = {
402  .class_name = "aa",
403  .item_name = av_default_item_name,
404  .option = aa_options,
405  .version = LIBAVUTIL_VERSION_INT,
406 };
407 
409  .name = "aa",
410  .long_name = NULL_IF_CONFIG_SMALL("Audible AA format files"),
411  .priv_class = &aa_class,
412  .priv_data_size = sizeof(AADemuxContext),
413  .extensions = "aa",
414  .read_probe = aa_probe,
420  .flags_internal = FF_FMT_INIT_CLEANUP,
421 };
AADemuxContext::content_end
int64_t content_end
Definition: aadec.c:54
AVFMT_NO_BYTE_SEEK
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition: avformat.h:475
FF_FMT_INIT_CLEANUP
#define FF_FMT_INIT_CLEANUP
For an AVInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition: internal.h:48
AVERROR
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
opt.h
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:760
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
aa_read_packet
static int aa_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: aadec.c:248
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
TIMEPREC
#define TIMEPREC
Definition: aadec.c:40
AVPacket::data
uint8_t * data
Definition: packet.h:373
AVOption
AVOption.
Definition: opt.h:247
AVChapter::start
int64_t start
Definition: avformat.h:1150
aa_read_seek
static int aa_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: aadec.c:322
av_tea_crypt
void av_tea_crypt(AVTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
Definition: tea.c:95
aa_read_close
static int aa_read_close(AVFormatContext *s)
Definition: aadec.c:383
aa_class
static const AVClass aa_class
Definition: aadec.c:401
AADemuxContext::tea_ctx
struct AVTEA * tea_ctx
Definition: aadec.c:50
AADemuxContext::aa_fixed_key
uint8_t * aa_fixed_key
Definition: aadec.c:45
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
AADemuxContext::aa_fixed_key_len
int aa_fixed_key_len
Definition: aadec.c:46
AADemuxContext::codec_second_size
int codec_second_size
Definition: aadec.c:47
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
MAX_DICTIONARY_ENTRIES
#define MAX_DICTIONARY_ENTRIES
Definition: aadec.c:37
AV_OPT_TYPE_BINARY
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:230
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:434
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:149
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:141
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:504
AVChapter
Definition: avformat.h:1147
val
static double val(void *priv, double ch)
Definition: aeval.c:76
AV_ROUND_UP
@ AV_ROUND_UP
Round toward +infinity.
Definition: mathematics.h:83
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:424
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:973
AV_CODEC_ID_SIPR
@ AV_CODEC_ID_SIPR
Definition: codec_id.h:464
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:790
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVInputFormat
Definition: avformat.h:638
tea.h
Public header for libavutil TEA algorithm.
AVChapter::end
int64_t end
chapter start/end time in time_base units
Definition: avformat.h:1150
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:99
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:643
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AA_MAGIC
#define AA_MAGIC
Definition: aadec.c:34
key
const char * key
Definition: hwcontext_opencl.c:168
aa_options
static const AVOption aa_options[]
Definition: aadec.c:393
aa_probe
static int aa_probe(const AVProbeData *p)
Definition: aadec.c:372
FFStream::need_parsing
enum AVStreamParseType need_parsing
Definition: internal.h:407
AVFormatContext
Format I/O context.
Definition: avformat.h:1188
avpriv_update_cur_dts
void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
Update cur_dts of all streams based on the given timestamp and AVStream.
Definition: seek.c:32
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1083
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVSEEK_FLAG_BACKWARD
#define AVSEEK_FLAG_BACKWARD
Definition: avformat.h:2250
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:953
NULL
#define NULL
Definition: coverity.c:32
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
src
#define src
Definition: vp8dsp.c:255
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
c
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
Definition: undefined.txt:32
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:57
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
MAX_CODEC_SECOND_SIZE
#define MAX_CODEC_SECOND_SIZE
Definition: aadec.c:35
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
get_second_size
static int get_second_size(char *codec_name)
Definition: aadec.c:58
FFStream
Definition: internal.h:196
avio_get_str
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition: aviobuf.c:895
size
int size
Definition: twinvq_data.h:10344
AV_RB32
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
Definition: bytestream.h:96
MP3_FRAME_SIZE
#define MP3_FRAME_SIZE
Definition: aadec.c:41
offset
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
Definition: writing_filters.txt:86
AADemuxContext::current_chapter_size
int64_t current_chapter_size
Definition: aadec.c:52
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
TEA_BLOCK_SIZE
#define TEA_BLOCK_SIZE
Definition: aadec.c:38
AVCodecParameters::block_align
int block_align
Audio only.
Definition: codec_par.h:177
aa_read_header
static int aa_read_header(AVFormatContext *s)
Definition: aadec.c:73
OFFSET
#define OFFSET(x)
Definition: aadec.c:392
AV_ROUND_DOWN
@ AV_ROUND_DOWN
Round toward -infinity.
Definition: mathematics.h:82
MAX_TOC_ENTRIES
#define MAX_TOC_ENTRIES
Definition: aadec.c:36
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:278
avpriv_new_chapter
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
Definition: utils.c:875
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:923
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:260
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
av_tea_init
void av_tea_init(AVTEA *ctx, const uint8_t key[16], int rounds)
Initialize an AVTEA context.
Definition: tea.c:42
pos
unsigned int pos
Definition: spdifenc.c:412
avformat.h
dict.h
AADemuxContext::chapter_idx
int chapter_idx
Definition: aadec.c:49
av_tea_alloc
struct AVTEA * av_tea_alloc(void)
Allocate an AVTEA context To free the struct: av_free(ptr)
Definition: tea.c:35
AVFMT_NOGENSEARCH
#define AVFMT_NOGENSEARCH
Format does not allow to fall back on generic search.
Definition: avformat.h:474
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:641
AVSTREAM_PARSE_FULL_RAW
@ AVSTREAM_PARSE_FULL_RAW
full parsing and repack with timestamp and position generation by parser for raw this assumes that ea...
Definition: avformat.h:784
AADemuxContext::seek_offset
int seek_offset
Definition: aadec.c:55
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:1186
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:347
AADemuxContext::file_key
uint8_t file_key[16]
Definition: aadec.c:51
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_set
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:70
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:393
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_strlcpy
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:83
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AVStream::start_time
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Definition: avformat.h:963
avstring.h
AADemuxContext::content_start
int64_t content_start
Definition: aadec.c:53
CHAPTER_HEADER_SIZE
#define CHAPTER_HEADER_SIZE
Definition: aadec.c:39
AADemuxContext::current_codec_second_size
int current_codec_second_size
Definition: aadec.c:48
AADemuxContext
Definition: aadec.c:43
AVTEA
Definition: tea.c:30
ff_aa_demuxer
const AVInputFormat ff_aa_demuxer
Definition: aadec.c:408
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:375