* the MS dshow demuxer */
AVFormatContext *sub_ctx;
- AVPacket sub_pkt;
+ AVPacket *sub_pkt;
AVBufferRef *sub_buffer;
int64_t seek_pos;
if (ast->sample_size)
return len;
else if (ast->dshow_block_align)
- return (len + ast->dshow_block_align - 1) / ast->dshow_block_align;
+ return (len + (int64_t)ast->dshow_block_align - 1) / ast->dshow_block_align;
else
return 1;
}
st->codecpar->codec_tag == MKTAG('H', '2', '6', '5'))
st->need_parsing = AVSTREAM_PARSE_FULL;
+ if (st->codecpar->codec_id == AV_CODEC_ID_AVRN &&
+ st->codecpar->codec_tag == MKTAG('A', 'V', 'R', 'n') &&
+ (st->codecpar->extradata_size < 31 ||
+ memcmp(&st->codecpar->extradata[28], "1:1", 3)))
+ st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
+
if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
st->codecpar->extradata_size < 1U << 30) {
st->codecpar->extradata_size += 9;
uint8_t desc[256];
int score = AVPROBE_SCORE_EXTENSION, ret;
AVIStream *ast = st->priv_data;
- ff_const59 AVInputFormat *sub_demuxer;
+ const AVInputFormat *sub_demuxer;
AVRational time_base;
int size;
AVProbeData pd;
if (strcmp(sub_demuxer->name, "srt") && strcmp(sub_demuxer->name, "ass"))
goto error;
+ if (!(ast->sub_pkt = av_packet_alloc()))
+ goto error;
+
if (!(ast->sub_ctx = avformat_alloc_context()))
goto error;
if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {
if (ast->sub_ctx->nb_streams != 1)
goto error;
- ff_read_packet(ast->sub_ctx, &ast->sub_pkt);
+ ff_read_packet(ast->sub_ctx, ast->sub_pkt);
avcodec_parameters_copy(st->codecpar, ast->sub_ctx->streams[0]->codecpar);
time_base = ast->sub_ctx->streams[0]->time_base;
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
return 1;
error:
+ av_packet_free(&ast->sub_pkt);
av_freep(&ast->sub_ctx);
avio_context_free(&pb);
}
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
ast = st->priv_data;
- if (st->discard < AVDISCARD_ALL && ast && ast->sub_pkt.data) {
- ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q);
+ if (st->discard < AVDISCARD_ALL && ast && ast->sub_pkt && ast->sub_pkt->data) {
+ ts = av_rescale_q(ast->sub_pkt->dts, st->time_base, AV_TIME_BASE_Q);
if (ts <= next_ts && ts < ts_min) {
ts_min = ts;
sub_st = st;
if (sub_st) {
ast = sub_st->priv_data;
- *pkt = ast->sub_pkt;
+ av_packet_move_ref(pkt, ast->sub_pkt);
pkt->stream_index = sub_st->index;
- if (ff_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0)
- ast->sub_pkt.data = NULL;
+ if (ff_read_packet(ast->sub_ctx, ast->sub_pkt) < 0)
+ ast->sub_pkt->data = NULL;
}
return sub_st;
}
AVStream *st1 = s->streams[1];
AVIStream *ast1 = st1->priv_data;
// workaround for broken small-file-bug402.avi
- if ( d[2] == 'w' && d[3] == 'b'
+ if (ast1 && d[2] == 'w' && d[3] == 'b'
&& n == 0
&& st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
&& st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
if (avi->stream_index >= 0) {
AVStream *st = s->streams[avi->stream_index];
AVIStream *ast = st->priv_data;
+ int dv_demux = CONFIG_DV_DEMUXER && avi->dv_demux;
int size, err;
if (get_subtitle_pkt(s, st, pkt))
return err;
size = err;
- if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2) {
+ if (ast->has_pal && pkt->size < (unsigned)INT_MAX / 2 && !dv_demux) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt,
AV_PKT_DATA_PALETTE,
}
}
- if (CONFIG_DV_DEMUXER && avi->dv_demux) {
+ if (CONFIG_DV_DEMUXER && dv_demux) {
AVBufferRef *avbuf = pkt->buf;
size = avpriv_dv_produce_packet(avi->dv_demux, pkt,
pkt->data, pkt->size, pkt->pos);
{
AVIStream *ast2 = st2->priv_data;
int64_t ts2 = av_rescale_q(timestamp, st->time_base, st2->time_base);
- av_packet_unref(&ast2->sub_pkt);
+ av_packet_unref(ast2->sub_pkt);
if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
- ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
+ ff_read_packet(ast2->sub_ctx, ast2->sub_pkt);
}
static int avi_read_seek(AVFormatContext *s, int stream_index,
avformat_close_input(&ast->sub_ctx);
}
av_buffer_unref(&ast->sub_buffer);
- av_packet_unref(&ast->sub_pkt);
+ av_packet_free(&ast->sub_pkt);
}
}
return 0;
}
-AVInputFormat ff_avi_demuxer = {
+const AVInputFormat ff_avi_demuxer = {
.name = "avi",
.long_name = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
.priv_data_size = sizeof(AVIContext),