{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
+ int ret;
av_dlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
mb_type = s->current_picture.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1];
if (IS_INTRA(mb_type)) {
av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->current_picture.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
mb_type | MB_TYPE_SKIP;
av_log(s->avctx, AV_LOG_ERROR,
"invalid mb type in I Frame at %d %d\n",
s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
} else {
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
mb_type = ptype2mb_type[mb_type];
break;
if (mb_type < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
mb_type = btype2mb_type[mb_type];
break;
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
} else {
for (i = 0; i < mb_block_count; i++)
- if (mpeg2_decode_block_intra(s, *s->pblocks[i], i) < 0)
- return -1;
+ if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0)
+ return ret;
}
} else {
for (i = 0; i < 6; i++)
- if (mpeg1_decode_block_intra(s, *s->pblocks[i], i) < 0)
- return -1;
+ if ((ret = mpeg1_decode_block_intra(s, *s->pblocks[i], i)) < 0)
+ return ret;
}
} else {
if (mb_type & MB_TYPE_ZERO_MV) {
case MT_DMV:
if (s->progressive_sequence){
av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->mv_type = MV_TYPE_DMV;
for (i = 0; i < 2; i++) {
default:
av_log(s->avctx, AV_LOG_ERROR,
"00 motion_type at %d %d\n", s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
if (cbp <= 0) {
av_log(s->avctx, AV_LOG_ERROR,
"invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
// if 1, we memcpy blocks in xvmcvideo
for (i = 0; i < mb_block_count; i++) {
if (cbp & (1 << 11)) {
- if (mpeg2_decode_block_non_intra(s, *s->pblocks[i], i) < 0)
- return -1;
+ if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0)
+ return ret;
} else {
s->block_last_index[i] = -1;
}
} else {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
- if (mpeg1_decode_block_inter(s, *s->pblocks[i], i) < 0)
- return -1;
+ if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0)
+ return ret;
} else {
s->block_last_index[i] = -1;
}
MpegEncContext *s2 = &s->mpeg_enc_ctx;
ff_mpv_decode_defaults(s2);
+
+ if ( avctx->codec_tag != AV_RL32("VCR2")
+ && avctx->codec_tag != AV_RL32("BW10"))
+ avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
ff_mpv_decode_init(s2, avctx);
s->mpeg_enc_ctx.avctx = avctx;
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
// MPEG-1 fps
- avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num;
- avctx->time_base.num = ff_mpeg12_frame_rate_tab[s->frame_rate_index].den;
+ avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
// MPEG-1 aspect
avctx->sample_aspect_ratio = av_d2q(1.0 / ff_mpeg1_aspect[s->aspect_ratio_info], 255);
avctx->ticks_per_frame = 1;
} else { // MPEG-2
// MPEG-2 fps
- av_reduce(&s->avctx->time_base.den,
- &s->avctx->time_base.num,
- ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num * 2,
+ av_reduce(&s->avctx->framerate.num,
+ &s->avctx->framerate.den,
+ ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
ref = get_bits(&s->gb, 10); /* temporal ref */
s->pict_type = get_bits(&s->gb, 3);
if (s->pict_type == 0 || s->pict_type > 3)
- return -1;
+ return AVERROR_INVALIDDATA;
vbv_delay = get_bits(&s->gb, 16);
s->vbv_delay = vbv_delay;
s->full_pel[0] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
- return -1;
+ return AVERROR_INVALIDDATA;
f_code += !f_code;
s->mpeg_f_code[0][0] = f_code;
s->mpeg_f_code[0][1] = f_code;
s->full_pel[1] = get_bits1(&s->gb);
f_code = get_bits(&s->gb, 3);
if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
- return -1;
+ return AVERROR_INVALIDDATA;
f_code += !f_code;
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
int v = get_bits(&s->gb, 8);
if (v == 0) {
av_log(s->avctx, AV_LOG_ERROR, "matrix damaged\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (intra && i == 0 && v != 8) {
av_log(s->avctx, AV_LOG_DEBUG, "intra matrix specifies invalid DC quantizer %d, ignoring\n", v);
{
AVCodecContext *avctx = s->avctx;
Mpeg1Context *s1 = (Mpeg1Context *) s;
+ int ret;
/* start frame decoding */
if (s->first_field || s->picture_structure == PICT_FRAME) {
AVFrameSideData *pan_scan;
- if (ff_mpv_frame_start(s, avctx) < 0)
- return -1;
+ if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
+ return ret;
ff_mpeg_er_frame_start(s);
}
if (avctx->hwaccel) {
- if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
- return -1;
+ if ((ret = avctx->hwaccel->start_frame(avctx, buf, buf_size)) < 0)
+ return ret;
}
return 0;
AVCodecContext *avctx = s->avctx;
const int lowres = s->avctx->lowres;
const int field_pic = s->picture_structure != PICT_FRAME;
+ int ret;
s->resync_mb_x =
s->resync_mb_y = -1;
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* extra slice info */
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33)
if (s->mb_x >= (unsigned) s->mb_width) {
av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (avctx->hwaccel && avctx->hwaccel->decode_slice) {
if ((CONFIG_MPEG1_XVMC_HWACCEL || CONFIG_MPEG2_XVMC_HWACCEL) && s->pack_pblocks)
ff_xvmc_init_block(s); // set s->block
- if (mpeg_decode_mb(s, s->block) < 0)
- return -1;
+ if ((ret = mpeg_decode_mb(s, s->block)) < 0)
+ return ret;
// Note motion_val is normally NULL unless we want to extract the MVs.
if (s->current_picture.motion_val[0] && !s->encoding) {
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33) {
if (s->pict_type == AV_PICTURE_TYPE_I) {
av_log(s->avctx, AV_LOG_ERROR,
"skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* skip mb */
if (s->aspect_ratio_info == 0) {
av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
- return -1;
+ return AVERROR_INVALIDDATA;
}
s->frame_rate_index = get_bits(&s->gb, 4);
- if (s->frame_rate_index == 0 || s->frame_rate_index > 13)
- return -1;
+ if (s->frame_rate_index == 0 || s->frame_rate_index > 13) {
+ av_log(avctx, AV_LOG_WARNING, "frame_rate_index %d is invalid\n", s->frame_rate_index);
+ s->frame_rate_index = 1;
+ }
s->bit_rate = get_bits(&s->gb, 18) * 400;
- if (get_bits1(&s->gb) == 0) /* marker */
- return -1;
+ if (get_bits1(&s->gb) == 0) { /* marker */
+ av_log(avctx, AV_LOG_ERROR, "Marker in sequence header missing\n");
+ return AVERROR_INVALIDDATA;
+ }
s->width = width;
s->height = height;
if (show_bits(&s->gb, 23) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* We set MPEG-2 parameters so that it emulates MPEG-1. */
s->low_delay = 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d\n",
- s->avctx->rc_buffer_size, s->bit_rate);
+ av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d, aspect_ratio_info: %d \n",
+ s->avctx->rc_buffer_size, s->bit_rate, s->aspect_ratio_info);
return 0;
}
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int i, v;
+ int ret;
/* start new MPEG-1 context decoding */
s->out_format = FMT_MPEG1;
setup_hwaccel_for_pixfmt(avctx);
ff_mpv_idct_init(s);
- if (ff_mpv_common_init(s) < 0)
- return -1;
+ if ((ret = ff_mpv_common_init(s)) < 0)
+ return ret;
s1->mpeg_enc_ctx_allocated = 1;
for (i = 0; i < 64; i++) {
if (mb_y >= s2->mb_height) {
av_log(s2->avctx, AV_LOG_ERROR,
"slice below image (%d >= %d)\n", mb_y, s2->mb_height);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (!s2->last_picture_ptr) {
if (s->first_slice) {
skip_frame = 0;
s->first_slice = 0;
- if (mpeg_field_start(s2, buf, buf_size) < 0)
- return -1;
+ if ((ret = mpeg_field_start(s2, buf, buf_size)) < 0)
+ return ret;
}
if (!s2->current_picture_ptr) {
av_log(avctx, AV_LOG_ERROR,