From: Fiona Glaser Date: Sat, 23 May 2009 03:40:27 +0000 (-0700) Subject: Remove some pointless error handling code in cabac/cavlc X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4078e4be9a3640c9f5b33a6734071c7009cf96f7;p=libx264 Remove some pointless error handling code in cabac/cavlc --- diff --git a/encoder/cabac.c b/encoder/cabac.c index 82025826..1ffd28b2 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, 2<= 0; j-- ) { diff --git a/encoder/cavlc.c b/encoder/cavlc.c index 9789af24..f20a8a3c 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-- ) {