]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wmv2dec.c
Merge commit '31d2039cb42668ebcf08248bc48bbad44aa05f49'
[ffmpeg] / libavcodec / wmv2dec.c
index b1bcd092b06c2ce285b4c5d1e08ebc496e78005d..bb14d5610dbf74be3120ec713c8dc09af07e390b 100644 (file)
@@ -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;
 }
@@ -233,7 +233,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);
@@ -293,7 +293,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;
@@ -312,12 +312,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;
 
@@ -331,7 +331,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)
@@ -355,7 +355,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;
@@ -365,7 +365,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;
@@ -399,8 +399,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;
@@ -408,11 +408,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 {
@@ -435,11 +435,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;
             }
         }
     }
@@ -450,11 +450,12 @@ 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;
 
     avctx->flags |= CODEC_FLAG_EMU_EDGE;
 
-    if (ff_msmpeg4_decode_init(avctx) < 0)
-        return -1;
+    if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
+        return ret;
 
     ff_wmv2_common_init(w);