33 #define AA_MAGIC 1469084982 34 #define MAX_CODEC_SECOND_SIZE 3982 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")) {
74 int i, j, idx, largest_idx = -1;
75 uint32_t nkey, nval, toc_size, npairs, header_seed = 0, start;
76 char key[128],
val[128], codec_name[64] = {0};
78 int64_t largest_size = -1, current_size = -1, chapter_pos;
83 uint32_t header_key_part[4];
97 for (i = 0; i < toc_size; i++) {
106 for (i = 0; i < npairs; i++) {
107 memset(val, 0,
sizeof(val));
108 memset(key, 0,
sizeof(key));
114 if (!strcmp(key,
"codec")) {
116 strncpy(codec_name, val,
sizeof(codec_name) - 1);
117 }
else if (!strcmp(key,
"HeaderSeed")) {
119 header_seed = atoi(val);
120 }
else if (!strcmp(key,
"HeaderKey")) {
123 ret = sscanf(val,
"%"SCNu32
"%"SCNu32
"%"SCNu32
"%"SCNu32,
124 &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
128 for (idx = 0; idx < 4; idx++) {
129 AV_WB32(&header_key[idx * 4], header_key_part[idx]);
132 for (i = 0; i < 16; i++)
157 output[0] = output[1] = 0;
158 memcpy(output + 2, header_key, 16);
160 for (i = 0; i < 3; i++) {
162 AV_WB32(src + 4, header_seed + 1);
166 output[idx] = output[idx] ^ dst[j];
169 memcpy(c->
file_key, output + 2, 16);
171 for (i = 0; i < 16; i++)
182 if (!strcmp(codec_name,
"mp332")) {
188 }
else if (!strcmp(codec_name,
"acelp85")) {
196 }
else if (!strcmp(codec_name,
"acelp16")) {
207 for (i = 1; i < toc_size; i++) {
208 current_size = TOC[
i].size;
209 if (current_size > largest_size) {
211 largest_size = current_size;
214 start = TOC[largest_idx].offset;
226 if (chapter_size == 0)
break;
230 chapter_pos *
TIMEPREC, (chapter_pos + chapter_size) * TIMEPREC,
NULL))
282 for (i = 0; i < blocks; i++) {
292 if (trailing_bytes != 0) {
294 if (ret != trailing_bytes)
296 memcpy(buf + written, src, trailing_bytes);
297 written = written + trailing_bytes;
319 int stream_index, int64_t timestamp,
int flags)
323 int64_t chapter_pos, chapter_start, chapter_size;
330 while (chapter_idx < s->nb_chapters && timestamp >= s->
chapters[chapter_idx]->
end) {
336 if (chapter_idx < 0)
return -1;
348 if (chapter_pos >= chapter_size)
349 chapter_pos = chapter_size;
353 avio_seek(s->
pb, chapter_start + chapter_pos, SEEK_SET);
388 #define OFFSET(x) offsetof(AADemuxContext, x) unsigned int nb_chapters
Number of chapters in AVChapter array.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static int aa_read_packet(AVFormatContext *s, AVPacket *pkt)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
int current_codec_second_size
static int aa_probe(const AVProbeData *p)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
struct AVTEA * av_tea_alloc(void)
Allocate an AVTEA context To free the struct: av_free(ptr)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define MAX_CODEC_SECOND_SIZE
unsigned int avio_rb32(AVIOContext *s)
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
static const AVOption aa_options[]
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
enum AVStreamParseType need_parsing
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
AVInputFormat ff_aa_demuxer
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
static int aa_read_header(AVFormatContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int64_t current_chapter_size
int block_align
Audio only.
Public header for libavutil TEA algorithm.
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.
#define MAX_DICTIONARY_ENTRIES
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.
offset must point to a pointer immediately followed by an int for the length
static int read_header(FFV1Context *f)
static int aa_read_close(AVFormatContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t end
chapter start/end time in time_base units
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static int get_second_size(char *codec_name)
static const AVClass aa_class
This structure contains the data a format has to probe a file.
#define flags(name, subs,...)
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
void av_tea_init(AVTEA *ctx, const uint8_t key[16], int rounds)
Initialize an AVTEA context.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
#define CHAPTER_HEADER_SIZE
void * priv_data
Format private data.
static int aa_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
and forward the result(frame or status change) to the corresponding input.If nothing is possible
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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
static double val(void *priv, double ch)
This structure stores compressed data.