28 #define RPL_SIGNATURE "ARMovie\x0A"
29 #define RPL_SIGNATURE_SIZE 8
32 #define RPL_LINE_LENGTH 256
55 for (i = 0; i < bufsize - 1; i++) {
69 static int32_t
read_int(
const char*
line,
const char** endptr,
int* error)
71 unsigned long result = 0;
72 for (; *line>=
'0' && *line<=
'9'; line++) {
73 if (result > (0x7FFFFFFF - 9) / 10)
75 result = 10 * result + *line -
'0';
85 *error |=
read_line(pb, line,
sizeof(line));
86 return read_int(line, &endptr, error);
100 for (; *line>=
'0' && *line<=
'9'; line++) {
104 num = 10 * num + *line -
'0';
118 int total_audio_size;
123 int32_t audio_format, chunk_catalog_offset, number_of_chunks;
134 error |=
read_line(pb, line,
sizeof(line));
135 error |=
read_line(pb, line,
sizeof(line));
137 error |=
read_line(pb, line,
sizeof(line));
139 error |=
read_line(pb, line,
sizeof(line));
151 error |=
read_line(pb, line,
sizeof(line));
174 "RPL video format %i not supported yet!\n",
189 ast->codec->codec_tag = audio_format;
195 if (ast->codec->bits_per_coded_sample == 0)
196 ast->codec->bits_per_coded_sample = 4;
198 ast->codec->bit_rate = ast->codec->sample_rate *
199 ast->codec->bits_per_coded_sample *
200 ast->codec->channels;
203 switch (audio_format) {
205 if (ast->codec->bits_per_coded_sample == 16) {
214 if (ast->codec->bits_per_coded_sample == 8) {
219 }
else if (ast->codec->bits_per_coded_sample == 4) {
227 "RPL audio format %i not supported yet!\n",
232 for (i = 0; i < 3; i++)
233 error |=
read_line(pb, line,
sizeof(line));
239 "Don't know how to split frames for video format %i. "
246 error |=
read_line(pb, line,
sizeof(line));
247 error |=
read_line(pb, line,
sizeof(line));
248 chunk_catalog_offset =
250 error |=
read_line(pb, line,
sizeof(line));
251 error |=
read_line(pb, line,
sizeof(line));
252 error |=
read_line(pb, line,
sizeof(line));
255 avio_seek(pb, chunk_catalog_offset, SEEK_SET);
256 total_audio_size = 0;
257 for (i = 0; i < number_of_chunks; i++) {
259 error |=
read_line(pb, line,
sizeof(line));
260 if (3 != sscanf(line,
"%"PRId64
" , %"PRId64
" ; %"PRId64,
261 &offset, &video_size, &audio_size))
267 audio_size, audio_size * 8, 0);
268 total_audio_size += audio_size * 8;
271 if (error)
return AVERROR(EIO);
312 if (ret != frame_size) {
327 if (ret != index_entry->
size) {
static AVRational read_fps(const char *line, int *error)
Parsing for fps, which can be a fraction.
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int read_line(AVIOContext *pb, char *line, int bufsize)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int read_header(FFV1Context *f)
void av_free_packet(AVPacket *pkt)
Free a packet.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
struct RPLContext RPLContext
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
int flags
A combination of AV_PKT_FLAG values.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
static int rpl_probe(AVProbeData *p)
static int32_t read_int(const char *line, const char **endptr, int *error)
static int64_t audio_size
int width
picture width / height.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int read_probe(AVProbeData *p)
AVInputFormat ff_rpl_demuxer
static int rpl_read_header(AVFormatContext *s, AVFormatParameters *ap)
enum AVMediaType codec_type
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
rational number numerator/denominator
This structure contains the data a format has to probe a file.
static int32_t read_line_and_int(AVIOContext *pb, int *error)
static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
static int64_t video_size
void * priv_data
Format private data.
#define RPL_LINE_LENGTH
256 is arbitrary, but should be big enough for any reasonable file.
#define RPL_SIGNATURE_SIZE
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...