Go to the documentation of this file.
36 #define AA_MAGIC 1469084982
37 #define MAX_TOC_ENTRIES 16
38 #define MAX_DICTIONARY_ENTRIES 128
39 #define TEA_BLOCK_SIZE 8
40 #define CHAPTER_HEADER_SIZE 8
42 #define MP3_FRAME_SIZE 104
63 if (!strcmp(codec_name,
"mp332")) {
65 }
else if (!strcmp(codec_name,
"acelp16")) {
67 }
else if (!strcmp(codec_name,
"acelp85")) {
77 uint32_t toc_size, npairs, header_seed = 0, start;
78 char codec_name[64] = {0};
80 int64_t largest_size = -1, current_size = -1, chapter_pos;
85 uint8_t header_key[16] = {0};
87 char file_key[2 *
sizeof(
c->file_key) + 1];
100 for (uint32_t
i = 0;
i < toc_size;
i++) {
109 for (uint32_t
i = 0;
i < npairs;
i++) {
118 if (!strcmp(
key,
"codec")) {
121 }
else if (!strcmp(
key,
"HeaderSeed")) {
123 header_seed = atoi(
val);
124 }
else if (!strcmp(
key,
"HeaderKey")) {
125 uint32_t header_key_part[4];
128 ret = sscanf(
val,
"%"SCNu32
"%"SCNu32
"%"SCNu32
"%"SCNu32,
129 &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
133 for (
int idx = 0; idx < 4; idx++)
134 AV_WB32(&header_key[idx * 4], header_key_part[idx]);
143 if (
c->aa_fixed_key_len != 16) {
159 for (
int i = 0;
i < 6;
i++)
174 if (!strcmp(codec_name,
"mp332")) {
180 }
else if (!strcmp(codec_name,
"acelp85")) {
188 }
else if (!strcmp(codec_name,
"acelp16")) {
199 for (uint32_t
i = 1;
i < toc_size;
i++) {
200 current_size = TOC[
i].size;
201 if (current_size > largest_size) {
203 largest_size = current_size;
206 start = TOC[largest_idx].offset;
212 c->content_start = start;
213 c->content_end = start + largest_size;
215 while ((chapter_pos =
avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
216 unsigned chapter_idx =
s->nb_chapters;
232 c->current_chapter_size = 0;
245 if (
pos >=
c->content_end) {
250 if (
c->current_chapter_size == 0) {
252 if (
c->current_chapter_size == 0) {
255 av_log(
s,
AV_LOG_DEBUG,
"Chapter %d (%" PRId64
" bytes)\n",
c->chapter_idx,
c->current_chapter_size);
256 c->chapter_idx =
c->chapter_idx + 1;
258 c->current_codec_second_size =
c->codec_second_size;
262 if (
c->current_chapter_size /
c->current_codec_second_size == 0) {
263 c->current_codec_second_size =
c->current_chapter_size %
c->current_codec_second_size;
267 if (
ret !=
c->current_codec_second_size)
276 c->current_chapter_size =
c->current_chapter_size -
c->current_codec_second_size;
277 if (
c->current_chapter_size <= 0)
278 c->current_chapter_size = 0;
280 if (
c->seek_offset >
c->current_codec_second_size)
294 int64_t chapter_pos, chapter_start, chapter_size;
301 while (chapter_idx < s->nb_chapters && timestamp >=
s->chapters[chapter_idx]->end) {
305 if (chapter_idx >=
s->nb_chapters) {
306 chapter_idx =
s->nb_chapters - 1;
307 if (chapter_idx < 0)
return -1;
308 timestamp =
s->chapters[chapter_idx]->end;
311 ch =
s->chapters[chapter_idx];
316 1,
c->codec_second_size,
318 *
c->codec_second_size;
319 if (chapter_pos >= chapter_size)
320 chapter_pos = chapter_size;
324 avio_seek(
s->pb, chapter_start + chapter_pos, SEEK_SET);
325 c->current_codec_second_size =
c->codec_second_size;
326 c->current_chapter_size = chapter_size - chapter_pos;
327 c->chapter_idx = 1 + chapter_idx;
341 uint8_t *buf = p->
buf;
359 #define OFFSET(x) offsetof(AADemuxContext, x)
362 "Fixed key used for handling Audible AA files",
OFFSET(aa_fixed_key),
379 .p.extensions =
"aa",
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.
@ AV_ROUND_UP
Round toward +infinity.
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
enum AVMediaType codec_type
General type of the encoded data.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#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.
int nb_channels
Number of channels in this layout.
static int aa_read_close(AVFormatContext *s)
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.
static const AVClass aa_class
#define MAX_DICTIONARY_ENTRIES
@ AV_OPT_TYPE_BINARY
Underlying C type is a uint8_t* that is either NULL or points to an array allocated with the av_mallo...
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_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.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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)
#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...
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.
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.
@ AV_ROUND_DOWN
Round toward -infinity.
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)
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)
const FFInputFormat ff_aa_demuxer
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
static int read_probe(const AVProbeData *p)
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
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.