31#define RPL_SIGNATURE "ARMovie\x0A"
32#define RPL_SIGNATURE_SIZE 8
35#define RPL_LINE_LENGTH 256
58 for (
i = 0;
i < bufsize - 1;
i++) {
74 unsigned long result = 0;
76 if (result > (0x7FFFFFFF - 9) / 10)
78 result = 10 * result + *
line -
'0';
105 if (num > (INT64_MAX - 9) / 10ULL || den > INT64_MAX / 10ULL)
107 num = 10 * num + (*
line -
'0');
129 int32_t video_format, audio_format, chunk_catalog_offset, number_of_chunks;
181 for (
i = 0;
i < 3;
i++)
203 ast->codecpar->codec_tag = audio_format;
205 if (ast->codecpar->sample_rate < 0)
213 ast->codecpar->ch_layout.nb_channels =
channels;
216 if (ast->codecpar->bits_per_coded_sample == 0)
217 ast->codecpar->bits_per_coded_sample = 4;
219 ast->codecpar->bit_rate = ast->codecpar->sample_rate *
220 (
int64_t)ast->codecpar->ch_layout.nb_channels;
221 if (ast->codecpar->bit_rate > INT64_MAX / ast->codecpar->bits_per_coded_sample)
223 ast->codecpar->bit_rate *= ast->codecpar->bits_per_coded_sample;
226 switch (audio_format) {
228 if (ast->codecpar->bits_per_coded_sample == 16) {
231 }
else if (ast->codecpar->bits_per_coded_sample == 8) {
248 if (ast->codecpar->bits_per_coded_sample == 8) {
252 }
else if (ast->codecpar->bits_per_coded_sample == 4) {
259 audio_format, audio_codec);
262 for (
i = 0;
i < 3;
i++)
266 if (
s->nb_streams == 0)
272 "Don't know how to split frames for video format %s. "
276 if (number_of_chunks == INT_MAX)
284 chunk_catalog_offset =
294 avio_seek(pb, chunk_catalog_offset, SEEK_SET);
295 total_audio_size = 0;
296 for (
i = 0; !
error &&
i < number_of_chunks;
i++) {
299 if (3 != sscanf(
line,
"%"SCNd64
" , %"SCNd64
" ; %"SCNd64,
300 &
offset, &video_size, &audio_size)) {
309 audio_size, audio_size * 8, 0);
310 if (total_audio_size/8 + (uint64_t)audio_size >= INT64_MAX/8)
312 total_audio_size += audio_size * 8;
360 if ((ret64 =
avio_seek(pb, -8, SEEK_CUR)) < 0)
382 if (ret != index_entry->
size)
392 pkt->duration = ret * 8;
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unsigned int avio_rl32(AVIOContext *s)
int avio_r8(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
static int read_header(FFV1Context *f, RangeCoder *c)
static const uint8_t frame_size[4]
@ AV_CODEC_ID_ADPCM_IMA_ESCAPE
@ AV_CODEC_ID_ADPCM_IMA_ACORN
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
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.
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 AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define av_fourcc2str(fourcc)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define RPL_LINE_LENGTH
256 is arbitrary, but should be big enough for any reasonable file.
static int read_line(AVIOContext *pb, char *line, int bufsize)
static int rpl_read_header(AVFormatContext *s)
static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
static int32_t read_int(const char *line, const char **endptr, int *error)
#define RPL_SIGNATURE_SIZE
static int32_t read_line_and_int(AVIOContext *pb, int *error)
static int rpl_probe(const AVProbeData *p)
static AVRational read_fps(const char *line, int *error)
Parsing for fps, which can be a fraction.
int height
The height of the video frame in pixels.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
#define avpriv_request_sample(...)
static void error(const char *err)