Commit 42c8f92e authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Vittorio Giovara

wmv2: Return meaningful error codes

parent f3e04526
......@@ -86,7 +86,7 @@ static int decode_ext_header(Wmv2Context *w)
int code;
if (s->avctx->extradata_size < 4)
return -1;
return AVERROR_INVALIDDATA;
init_get_bits(&gb, s->avctx->extradata, 32);
......@@ -101,7 +101,7 @@ static int decode_ext_header(Wmv2Context *w)
code = get_bits(&gb, 3);
if (code == 0)
return -1;
return AVERROR_INVALIDDATA;
s->slice_height = s->mb_height / code;
......@@ -131,7 +131,7 @@ int ff_wmv2_decode_picture_header(MpegEncContext *s)
}
s->chroma_qscale = s->qscale = get_bits(&s->gb, 5);
if (s->qscale <= 0)
return -1;
return AVERROR_INVALIDDATA;
return 0;
}
......@@ -242,7 +242,7 @@ static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr)
ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
if (ret < 0)
return -1;
return ret;
if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
w->hshift = get_bits1(&s->gb);
......@@ -302,7 +302,7 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block,
{
MpegEncContext *const s = &w->s;
static const int sub_cbp_table[3] = { 2, 3, 1 };
int sub_cbp;
int sub_cbp, ret;
if (!cbp) {
s->block_last_index[n] = -1;
......@@ -321,12 +321,12 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block,
sub_cbp = sub_cbp_table[decode012(&s->gb)];
if (sub_cbp & 1)
if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
return -1;
if ((ret = ff_msmpeg4_decode_block(s, block, n, 1, scantable)) < 0)
return ret;
if (sub_cbp & 2)
if (ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0)
return -1;
if ((ret = ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable)) < 0)
return ret;
s->block_last_index[n] = 63;
......@@ -340,7 +340,7 @@ static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block,
int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
{
Wmv2Context *const w = (Wmv2Context *) s;
int cbp, code, i;
int cbp, code, i, ret;
uint8_t *coded_val;
if (w->j_type)
......@@ -364,7 +364,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
MB_NON_INTRA_VLC_BITS, 3);
if (code < 0)
return -1;
return AVERROR_INVALIDDATA;
s->mb_intra = (~code & 0x40) >> 6;
cbp = code & 0x3f;
......@@ -374,7 +374,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
return -1;
return AVERROR_INVALIDDATA;
}
/* predict coded block pattern */
cbp = 0;
......@@ -408,8 +408,8 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
w->per_block_abt = 0;
}
if (wmv2_decode_motion(w, &mx, &my) < 0)
return -1;
if ((ret = wmv2_decode_motion(w, &mx, &my)) < 0)
return ret;
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
......@@ -417,11 +417,11 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
s->mv[0][0][1] = my;
for (i = 0; i < 6; i++) {
if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0) {
if ((ret = wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"\nerror while decoding inter block: %d x %d (%d)\n",
s->mb_x, s->mb_y, i);
return -1;
return ret;
}
}
} else {
......@@ -444,11 +444,11 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
s->bdsp.clear_blocks(s->block[0]);
for (i = 0; i < 6; i++) {
if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) {
if ((ret = ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL)) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"\nerror while decoding intra block: %d x %d (%d)\n",
s->mb_x, s->mb_y, i);
return -1;
return ret;
}
}
}
......@@ -459,9 +459,10 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
static av_cold int wmv2_decode_init(AVCodecContext *avctx)
{
Wmv2Context *const w = avctx->priv_data;
int ret;
if (ff_msmpeg4_decode_init(avctx) < 0)
return -1;
if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
return ret;
ff_wmv2_common_init(w);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment