35 #include "libavutil/intreadwrite.h"
36 #include "libavutil/mathematics.h"
40 #define EXTRADATA1_SIZE (6 + 256 * 3)
42 #define FORM_TAG MKBETAG('F', 'O', 'R', 'M')
43 #define RLV2_TAG MKBETAG('R', 'L', 'V', '2')
44 #define RLV3_TAG MKBETAG('R', 'L', 'V', '3')
79 unsigned int audio_frame_counter = 0;
80 unsigned int video_frame_counter = 0;
81 unsigned int back_size;
82 unsigned short sound_rate;
84 unsigned short channels;
85 unsigned short def_sound_size;
87 unsigned int pts_den = 11025;
88 unsigned int pts_num = 1103;
89 unsigned int* chunk_offset = NULL;
90 int* chunk_size = NULL;
102 if(back_size > INT_MAX/2 || frame_count > INT_MAX /
sizeof(uint32_t))
125 if(signature ==
RLV3_TAG && back_size > 0)
137 if (!channels || channels > 42) {
142 pts_num = def_sound_size;
163 chunk_size =
av_malloc(frame_count *
sizeof(uint32_t));
164 audio_size =
av_malloc(frame_count *
sizeof(uint32_t));
165 chunk_offset =
av_malloc(frame_count *
sizeof(uint32_t));
167 if(!chunk_size || !audio_size || !chunk_offset){
184 if(chunk_size[i] < 0 || audio_size[i] > chunk_size[i]){
189 if(sound_rate && audio_size[i]){
192 audio_frame_counter += audio_size[i] / channels;
196 ++video_frame_counter;
222 int64_t pos = INT64_MAX;
244 if(ret != sample->
size){
void av_free_packet(AVPacket *pkt)
Free a packet.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static int64_t audio_size
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
AVCodecContext * codec
Codec context associated with this stream.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static const char signature[]
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
void * priv_data
Format private data.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
unsigned int nb_streams
A list of all streams in the file.
int bit_rate
the average bitrate
int width
picture width / height.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int read_header(FFV1Context *f)
enum AVMediaType codec_type
int sample_rate
samples per second
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
This structure contains the data a format has to probe a file.
unsigned int index_pos[2]
indexes in the sample tables
#define AVERROR_INVALIDDATA
int channels
number of audio channels
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...