[FFmpeg-soc] [soc]: r1240 - rv40/rv40.c

kostya subversion at mplayerhq.hu
Wed Aug 29 19:17:02 CEST 2007


Author: kostya
Date: Wed Aug 29 19:17:01 2007
New Revision: 1240

Log:
Better error handling

Modified:
   rv40/rv40.c

Modified: rv40/rv40.c
==============================================================================
--- rv40/rv40.c	(original)
+++ rv40/rv40.c	Wed Aug 29 19:17:01 2007
@@ -630,12 +630,24 @@ static int rv30_decode_intra_types(RV40D
         ptr = dst;
         for(j = 0; j < 4; j+= 2){
             code = (get_omega(gb) - 1) << 1;
+            if(code >= 81*2){
+                av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n");
+                return -1;
+            }
             A = ptr[-r->intra_types_stride] + 1;
             B = ptr[-1] + 1;
             *ptr++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + 0]];
+            if(ptr[-1] == 9){
+                av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n");
+                return -1;
+            }
             A = ptr[-r->intra_types_stride] + 1;
             B = ptr[-1] + 1;
             *ptr++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + 1]];
+            if(ptr[-1] == 9){
+                av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n");
+                return -1;
+            }
         }
     }
     return 0;
@@ -765,6 +777,10 @@ static int rv30_decode_mb_info(RV40DecCo
     int code;
 
     code = get_omega(gb) - 1;
+    if(code > 11){
+        av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
+        return -1;
+    }
     if(code > 5){
         av_log(NULL,0, "dquant needed\n");
         code -= 6;
@@ -1521,6 +1537,8 @@ static int rv40_decode_mb_header(RV40Dec
         r->block_type = r->is16 ? RV40_MB_TYPE_INTRA16x16 : RV40_MB_TYPE_INTRA;
     }else{
         r->block_type = r->rv30 ? rv30_decode_mb_info(r) : rv40_decode_mb_info(r);
+        if(r->block_type == -1)
+            return -1;
         s->current_picture_ptr->mb_type[mb_pos] = rv40_mb_type_to_lavc[r->block_type];
         r->mb_type[mb_pos] = r->block_type;
         if(s->pict_type == P_TYPE && r->block_type == RV40_MB_SKIP)
@@ -1539,10 +1557,13 @@ static int rv40_decode_mb_header(RV40Dec
     }
     if(IS_INTRA(s->current_picture_ptr->mb_type[mb_pos])){
         if(!r->is16){
-            if(r->rv30)
-                rv30_decode_intra_types(r, gb, intra_types);
-            else
-                rv40_decode_intra_types(r, gb, intra_types);
+            if(r->rv30){
+                if(rv30_decode_intra_types(r, gb, intra_types) < 0)
+                    return -1;
+            }else{
+                if(rv40_decode_intra_types(r, gb, intra_types) < 0)
+                    return -1;
+            }
             r->chroma_vlc = 0;
             r->luma_vlc   = 1;
         }else{
@@ -1605,6 +1626,9 @@ static int rv40_decode_macroblock(RV40De
 
     cbp = cbp2 = rv40_decode_mb_header(r, intra_types);
 
+    if(cbp == -1)
+        return -1;
+
     if(r->is16){
         memset(block16, 0, sizeof(block16));
         rv40_decode_block(block16, gb, r->cur_vlcs, 3, 0);



More information about the FFmpeg-soc mailing list