[x264-devel] commit: Remove some pointless error handling code in cabac/cavlc ( Jason Garrett-Glaser )

git version control git at videolan.org
Sun May 24 21:27:58 CEST 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri May 22 20:40:27 2009 -0700| [be17f0306ec42c2fc6e572a50d16c3717c7991ce] | committer: Jason Garrett-Glaser 

Remove some pointless error handling code in cabac/cavlc

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=be17f0306ec42c2fc6e572a50d16c3717c7991ce
---

 encoder/cabac.c |   13 ++-----------
 encoder/cavlc.c |   33 ++++-----------------------------
 2 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/encoder/cabac.c b/encoder/cabac.c
index 284aabd..ac6827c 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -120,7 +120,7 @@ static void x264_cabac_mb_type( x264_t *h, x264_cabac_t *cb )
             x264_cabac_mb_type_intra( h, cb, i_mb_type, 17+0, 17+1, 17+2, 17+2, 17+3, 17+3 );
         }
     }
-    else if( h->sh.i_type == SLICE_TYPE_B )
+    else //if( h->sh.i_type == SLICE_TYPE_B )
     {
         int ctx = 0;
         if( h->mb.i_mb_type_left >= 0 && h->mb.i_mb_type_left != B_SKIP && h->mb.i_mb_type_left != B_DIRECT )
@@ -189,10 +189,6 @@ static void x264_cabac_mb_type( x264_t *h, x264_cabac_t *cb )
                 x264_cabac_encode_decision( cb, 27+5, i_mb_bits[idx][i] );
         }
     }
-    else
-    {
-        x264_log(h, X264_LOG_ERROR, "unknown SLICE_TYPE unsupported in x264_macroblock_write_cabac\n" );
-    }
 }
 
 static void x264_cabac_mb_intra4x4_pred_mode( x264_cabac_t *cb, int i_pred, int i_mode )
@@ -1052,16 +1048,11 @@ static void x264_partition_size_cabac( x264_t *h, x264_cabac_t *cb, int i8, int
         if( x264_mb_type_list_table[ i_mb_type ][0][!!i8] ) x264_cabac_mb_mvd( h, cb, 0, 4*i8, 4>>b_8x16, 2<<b_8x16 );
         if( x264_mb_type_list_table[ i_mb_type ][1][!!i8] ) x264_cabac_mb_mvd( h, cb, 1, 4*i8, 4>>b_8x16, 2<<b_8x16 );
     }
-    else if( i_mb_type == B_8x8 )
+    else //if( i_mb_type == B_8x8 )
     {
         x264_cabac_mb8x8_mvd( h, cb, 0, i8 );
         x264_cabac_mb8x8_mvd( h, cb, 1, i8 );
     }
-    else
-    {
-        x264_log(h, X264_LOG_ERROR, "invalid/unhandled mb_type %d\n",i_mb_type );
-        return;
-    }
 
     for( j = (i_pixel < PIXEL_8x8); j >= 0; j-- )
     {
diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index 5fe246d..1b0b5d1 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -291,7 +291,8 @@ static inline void x264_macroblock_luma_write_cavlc( x264_t *h, bs_t *s, int i8s
 void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
 {
     const int i_mb_type = h->mb.i_type;
-    int i_mb_i_offset;
+    static const int i_offsets[3] = {5,23,0};
+    int i_mb_i_offset = i_offsets[h->sh.i_type];
     int i;
 
 #if !RDO_SKIP_BS
@@ -299,22 +300,6 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
     int       i_mb_pos_tex;
 #endif
 
-    switch( h->sh.i_type )
-    {
-        case SLICE_TYPE_I:
-            i_mb_i_offset = 0;
-            break;
-        case SLICE_TYPE_P:
-            i_mb_i_offset = 5;
-            break;
-        case SLICE_TYPE_B:
-            i_mb_i_offset = 23;
-            break;
-        default:
-            x264_log(h, X264_LOG_ERROR, "internal error or slice unsupported\n" );
-            return;
-    }
-
     if( h->sh.b_mbaff
         && (!(h->mb.i_mb_y & 1) || IS_SKIP(h->mb.type[h->mb.i_mb_xy - h->mb.i_mb_stride])) )
     {
@@ -559,13 +544,8 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
             }
         }
     }
-    else if( i_mb_type == B_DIRECT )
+    else //if( i_mb_type == B_DIRECT )
         bs_write1( s, 1 );
-    else
-    {
-        x264_log(h, X264_LOG_ERROR, "invalid/unhandled mb_type\n" );
-        return;
-    }
 
 #if !RDO_SKIP_BS
     i_mb_pos_tex = bs_pos( s );
@@ -639,16 +619,11 @@ static int x264_partition_size_cavlc( x264_t *h, int i8, int i_pixel )
         if( x264_mb_type_list_table[ i_mb_type ][0][!!i8] ) cavlc_mb_mvd( h, &h->out.bs, 0, 4*i8, 4>>b_8x16 );
         if( x264_mb_type_list_table[ i_mb_type ][1][!!i8] ) cavlc_mb_mvd( h, &h->out.bs, 1, 4*i8, 4>>b_8x16 );
     }
-    else if( i_mb_type == B_8x8 )
+    else //if( i_mb_type == B_8x8 )
     {
         cavlc_mb8x8_mvd( h, &h->out.bs, 0, i8 );
         cavlc_mb8x8_mvd( h, &h->out.bs, 1, i8 );
     }
-    else
-    {
-        x264_log(h, X264_LOG_ERROR, "invalid/unhandled mb_type\n" );
-        return 0;
-    }
 
     for( j = (i_pixel < PIXEL_8x8); j >= 0; j-- )
     {



More information about the x264-devel mailing list