Go to the documentation of this file.
35 #define AA_MAGIC 1469084982
36 #define MAX_TOC_ENTRIES 16
37 #define MAX_DICTIONARY_ENTRIES 128
38 #define TEA_BLOCK_SIZE 8
39 #define CHAPTER_HEADER_SIZE 8
41 #define MP3_FRAME_SIZE 104
62 if (!strcmp(codec_name,
"mp332")) {
64 }
else if (!strcmp(codec_name,
"acelp16")) {
66 }
else if (!strcmp(codec_name,
"acelp85")) {
76 uint32_t toc_size, npairs, header_seed = 0, start;
77 char codec_name[64] = {0};
79 int64_t largest_size = -1, current_size = -1, chapter_pos;
84 uint8_t header_key[16] = {0};
86 char file_key[2 *
sizeof(
c->file_key) + 1];
99 for (uint32_t
i = 0;
i < toc_size;
i++) {
108 for (uint32_t
i = 0;
i < npairs;
i++) {
117 if (!strcmp(
key,
"codec")) {
120 }
else if (!strcmp(
key,
"HeaderSeed")) {
122 header_seed = atoi(
val);
123 }
else if (!strcmp(
key,
"HeaderKey")) {
124 uint32_t header_key_part[4];
127 ret = sscanf(
val,
"%"SCNu32
"%"SCNu32
"%"SCNu32
"%"SCNu32,
128 &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
132 for (
int idx = 0; idx < 4; idx++)
133 AV_WB32(&header_key[idx * 4], header_key_part[idx]);
142 if (
c->aa_fixed_key_len != 16) {
158 for (
int i = 0;
i < 6;
i++)
173 if (!strcmp(codec_name,
"mp332")) {
179 }
else if (!strcmp(codec_name,
"acelp85")) {
187 }
else if (!strcmp(codec_name,
"acelp16")) {
198 for (uint32_t
i = 1;
i < toc_size;
i++) {
199 current_size = TOC[
i].size;
200 if (current_size > largest_size) {
202 largest_size = current_size;
205 start = TOC[largest_idx].offset;
211 c->content_start = start;
212 c->content_end = start + largest_size;
214 while ((chapter_pos =
avio_tell(pb)) >= 0 && chapter_pos < c->content_end) {
215 unsigned chapter_idx =
s->nb_chapters;
231 c->current_chapter_size = 0;
244 if (
pos >=
c->content_end) {
249 if (
c->current_chapter_size == 0) {
251 if (
c->current_chapter_size == 0) {
254 av_log(
s,
AV_LOG_DEBUG,
"Chapter %d (%" PRId64
" bytes)\n",
c->chapter_idx,
c->current_chapter_size);
255 c->chapter_idx =
c->chapter_idx + 1;
257 c->current_codec_second_size =
c->codec_second_size;
261 if (
c->current_chapter_size /
c->current_codec_second_size == 0) {
262 c->current_codec_second_size =
c->current_chapter_size %
c->current_codec_second_size;
266 if (
ret !=
c->current_codec_second_size)
275 c->current_chapter_size =
c->current_chapter_size -
c->current_codec_second_size;
276 if (
c->current_chapter_size <= 0)
277 c->current_chapter_size = 0;
279 if (
c->seek_offset >
c->current_codec_second_size)
289 int stream_index, int64_t timestamp,
int flags)
293 int64_t chapter_pos, chapter_start, chapter_size;
300 while (chapter_idx < s->nb_chapters && timestamp >=
s->chapters[chapter_idx]->end) {
304 if (chapter_idx >=
s->nb_chapters) {
305 chapter_idx =
s->nb_chapters - 1;
306 if (chapter_idx < 0)
return -1;
307 timestamp =
s->chapters[chapter_idx]->end;
310 ch =
s->chapters[chapter_idx];
315 1,
c->codec_second_size,
317 *
c->codec_second_size;
318 if (chapter_pos >= chapter_size)
319 chapter_pos = chapter_size;
323 avio_seek(
s->pb, chapter_start + chapter_pos, SEEK_SET);
324 c->current_codec_second_size =
c->codec_second_size;
325 c->current_chapter_size = chapter_size - chapter_pos;
326 c->chapter_idx = 1 + chapter_idx;
340 uint8_t *buf = p->
buf;
358 #define OFFSET(x) offsetof(AADemuxContext, x)
361 "Fixed key used for handling Audible AA files",
OFFSET(aa_fixed_key),
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.
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.
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
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.
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.
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.