Go to the documentation of this file.
34 #define AA_MAGIC 1469084982
35 #define MAX_TOC_ENTRIES 16
36 #define MAX_DICTIONARY_ENTRIES 128
37 #define TEA_BLOCK_SIZE 8
38 #define CHAPTER_HEADER_SIZE 8
40 #define MP3_FRAME_SIZE 104
61 if (!strcmp(codec_name,
"mp332")) {
63 }
else if (!strcmp(codec_name,
"acelp16")) {
65 }
else if (!strcmp(codec_name,
"acelp85")) {
75 uint32_t toc_size, npairs, header_seed = 0, start;
76 char codec_name[64] = {0};
78 int64_t largest_size = -1, current_size = -1, chapter_pos;
83 uint8_t header_key[16] = {0};
85 char file_key[2 *
sizeof(
c->file_key) + 1];
98 for (uint32_t
i = 0;
i < toc_size;
i++) {
107 for (uint32_t
i = 0;
i < npairs;
i++) {
116 if (!strcmp(
key,
"codec")) {
119 }
else if (!strcmp(
key,
"HeaderSeed")) {
121 header_seed = atoi(
val);
122 }
else if (!strcmp(
key,
"HeaderKey")) {
123 uint32_t header_key_part[4];
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]);
131 for (
int idx = 0; idx < 4; idx++)
132 AV_WB32(&header_key[idx * 4], header_key_part[idx]);
141 if (
c->aa_fixed_key_len != 16) {
157 for (
int i = 0;
i < 6;
i++)
172 if (!strcmp(codec_name,
"mp332")) {
178 }
else if (!strcmp(codec_name,
"acelp85")) {
186 }
else if (!strcmp(codec_name,
"acelp16")) {
197 for (uint32_t
i = 1;
i < toc_size;
i++) {
198 current_size = TOC[
i].size;
199 if (current_size > largest_size) {
201 largest_size = current_size;
204 start = TOC[largest_idx].offset;
210 c->content_start = start;
211 c->content_end = start + largest_size;
213 while ((chapter_pos =
avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
214 unsigned chapter_idx =
s->nb_chapters;
230 c->current_chapter_size = 0;
243 if (
pos >=
c->content_end) {
248 if (
c->current_chapter_size == 0) {
250 if (
c->current_chapter_size == 0) {
253 av_log(
s,
AV_LOG_DEBUG,
"Chapter %d (%" PRId64
" bytes)\n",
c->chapter_idx,
c->current_chapter_size);
254 c->chapter_idx =
c->chapter_idx + 1;
256 c->current_codec_second_size =
c->codec_second_size;
260 if (
c->current_chapter_size /
c->current_codec_second_size == 0) {
261 c->current_codec_second_size =
c->current_chapter_size %
c->current_codec_second_size;
265 if (
ret !=
c->current_codec_second_size)
274 c->current_chapter_size =
c->current_chapter_size -
c->current_codec_second_size;
275 if (
c->current_chapter_size <= 0)
276 c->current_chapter_size = 0;
278 if (
c->seek_offset >
c->current_codec_second_size)
288 int stream_index, int64_t timestamp,
int flags)
292 int64_t chapter_pos, chapter_start, chapter_size;
299 while (chapter_idx < s->nb_chapters && timestamp >=
s->chapters[chapter_idx]->end) {
303 if (chapter_idx >=
s->nb_chapters) {
304 chapter_idx =
s->nb_chapters - 1;
305 if (chapter_idx < 0)
return -1;
306 timestamp =
s->chapters[chapter_idx]->end;
309 ch =
s->chapters[chapter_idx];
314 1,
c->codec_second_size,
316 *
c->codec_second_size;
317 if (chapter_pos >= chapter_size)
318 chapter_pos = chapter_size;
322 avio_seek(
s->pb, chapter_start + chapter_pos, SEEK_SET);
323 c->current_codec_second_size =
c->codec_second_size;
324 c->current_chapter_size = chapter_size - chapter_pos;
325 c->chapter_idx = 1 + chapter_idx;
339 uint8_t *buf = p->
buf;
357 #define OFFSET(x) offsetof(AADemuxContext, x)
360 "Fixed key used for handling Audible AA files",
OFFSET(aa_fixed_key),
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.
#define AVERROR_EOF
End of file.
static int aa_read_packet(AVFormatContext *s, AVPacket *pkt)
static int aa_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
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.
static int aa_read_close(AVFormatContext *s)
static const AVClass aa_class
#define MAX_DICTIONARY_ENTRIES
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static double val(void *priv, double ch)
@ AV_ROUND_UP
Round toward +infinity.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Public header for libavutil TEA algorithm.
int64_t end
chapter start/end time in time_base units
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const AVOption aa_options[]
static int aa_probe(const AVProbeData *p)
enum AVStreamParseType need_parsing
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
const char * av_default_item_name(void *ptr)
Return the context name.
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.
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int get_second_size(char *codec_name)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb 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_RB32
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
int64_t current_chapter_size
#define i(width, name, range_min, range_max)
int block_align
Audio only.
static int aa_read_header(AVFormatContext *s)
@ AV_ROUND_DOWN
Round toward -infinity.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
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.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_tea_init(AVTEA *ctx, const uint8_t key[16], int rounds)
Initialize an AVTEA context.
struct AVTEA * av_tea_alloc(void)
Allocate an AVTEA context To free the struct: av_free(ptr)
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.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define flags(name, subs,...)
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.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
#define CHAPTER_HEADER_SIZE
int current_codec_second_size
const AVInputFormat ff_aa_demuxer
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.