#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
-#include "libavutil/bswap.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "libavutil/internal.h"
static int avi_load_index(AVFormatContext *s);
static int guess_ni_flag(AVFormatContext *s);
-#define print_tag(str, tag, size) \
- av_log(NULL, AV_LOG_TRACE, "pos:%"PRIX64" %s: tag=%s size=0x%x\n", \
+#define print_tag(s, str, tag, size) \
+ av_log(s, AV_LOG_TRACE, "pos:%"PRIX64" %s: tag=%s size=0x%x\n", \
avio_tell(pb), str, av_fourcc2str(tag), size) \
static inline int get_duration(AVIStream *ast, int len)
value = av_malloc(size + 1);
if (!value)
return AVERROR(ENOMEM);
- if (avio_read(pb, value, size) != size)
+ if (avio_read(pb, value, size) != size) {
+ av_freep(&value);
return AVERROR_INVALIDDATA;
+ }
value[size] = 0;
AV_WL32(key, tag);
continue;
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
- if (bitrate <= INT_MAX && bitrate > 0) {
+ if (bitrate > 0) {
st->codecpar->bit_rate = bitrate;
}
}
tag = avio_rl32(pb);
size = avio_rl32(pb);
- print_tag("tag", tag, size);
+ print_tag(s, "tag", tag, size);
switch (tag) {
case MKTAG('L', 'I', 'S', 'T'):
/* Ignored, except at start of video packets. */
tag1 = avio_rl32(pb);
- print_tag("list", tag1, 0);
+ print_tag(s, "list", tag1, 0);
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
avi->movi_list = avio_tell(pb) - 4;
avi->movi_end = avi->movi_list + size + (size & 1);
else
avi->movi_end = avi->fsize;
- av_log(NULL, AV_LOG_TRACE, "movi end=%"PRIx64"\n", avi->movi_end);
+ av_log(s, AV_LOG_TRACE, "movi end=%"PRIx64"\n", avi->movi_end);
goto end_of_header;
} else if (tag1 == MKTAG('I', 'N', 'F', 'O'))
ff_read_riff_info(s, size - 4);
tag1 = stream_index ? MKTAG('a', 'u', 'd', 's')
: MKTAG('v', 'i', 'd', 's');
- print_tag("strh", tag1, -1);
+ print_tag(s, "strh", tag1, -1);
if (tag1 == MKTAG('i', 'a', 'v', 's') ||
tag1 == MKTAG('i', 'v', 'a', 's')) {
st->codecpar->extradata_size = size - 10 * 4;
if (st->codecpar->extradata) {
av_log(s, AV_LOG_WARNING, "New extradata in strf chunk, freeing previous one.\n");
- av_freep(&st->codecpar->extradata);
}
- if (ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0)
- return AVERROR(ENOMEM);
+ ret = ff_get_extradata(s, st->codecpar, pb,
+ st->codecpar->extradata_size);
+ if (ret < 0)
+ return ret;
}
// FIXME: check if the encoder really did this correctly
ast->has_pal = 1;
}
- print_tag("video", tag1, 0);
+ print_tag(s, "video", tag1, 0);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = tag1;
"mov tag found in avi (fourcc %s)\n",
av_fourcc2str(tag1));
}
+ if (!st->codecpar->codec_id)
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags_unofficial, tag1);
+
/* This is needed to get the pict type which is necessary
* for generating correct pts. */
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (size<(1<<30)) {
if (st->codecpar->extradata) {
av_log(s, AV_LOG_WARNING, "New extradata in strd chunk, freeing previous one.\n");
- av_freep(&st->codecpar->extradata);
}
- if (ff_get_extradata(s, st->codecpar, pb, size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0)
+ return ret;
}
if (st->codecpar->extradata_size & 1) //FIXME check if the encoder really did this correctly
uint8_t desc[256];
int score = AVPROBE_SCORE_EXTENSION, ret;
AVIStream *ast = st->priv_data;
- AVInputFormat *sub_demuxer;
+ ff_const59 AVInputFormat *sub_demuxer;
AVRational time_base;
int size;
AVIOContext *pb = avio_alloc_context(pkt->data + 7,
return 0;
}
-static int avi_probe(AVProbeData *p)
+static int avi_probe(const AVProbeData *p)
{
int i;