changeset 2163:b25df257eab0 libavcodec

segfault fix
author michael
date Tue, 03 Aug 2004 01:50:52 +0000
parents 6173c83664a5
children cbac56a6244f
files h264.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/h264.c	Tue Aug 03 01:07:19 2004 +0000
+++ b/h264.c	Tue Aug 03 01:50:52 2004 +0000
@@ -738,6 +738,9 @@
     static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
     static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
     
+    if(mode < 0 || mode > 6)
+        return -1;
+    
     if(!(h->top_samples_available&0x8000)){
         mode= top[ mode ];
         if(mode<0){
@@ -5136,13 +5139,13 @@
             int ret = decode_mb_cabac(h);
             int eos = get_cabac_terminate( &h->cabac ); /* End of Slice flag */
 
-            hl_decode_mb(h);
+            if(ret>=0) hl_decode_mb(h);
 
             /* XXX: useless as decode_mb_cabac it doesn't support that ... */
             if( ret >= 0 && h->sps.mb_aff ) { //FIXME optimal? or let mb_decode decode 16x32 ?
                 s->mb_y++;
 
-                ret = decode_mb_cabac(h);
+                if(ret>=0) ret = decode_mb_cabac(h);
                 eos = get_cabac_terminate( &h->cabac );
 
                 hl_decode_mb(h);
@@ -5180,13 +5183,13 @@
         for(;;){
             int ret = decode_mb_cavlc(h);
 
-            hl_decode_mb(h);
+            if(ret>=0) hl_decode_mb(h);
 
             if(ret>=0 && h->sps.mb_aff){ //FIXME optimal? or let mb_decode decode 16x32 ?
                 s->mb_y++;
                 ret = decode_mb_cavlc(h);
 
-                hl_decode_mb(h);
+                if(ret>=0) hl_decode_mb(h);
                 s->mb_y--;
             }