From: Loren Merritt Date: Sun, 9 Oct 2005 03:32:56 +0000 (+0000) Subject: remove cabac byte-stuffing code, because it just wastes bits in lossless, and does... X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=1c6ccbf543ac7725e46f94bdb24fa6784d315962;p=x264.git remove cabac byte-stuffing code, because it just wastes bits in lossless, and does nothing at all at sane bitrates. git-svn-id: svn://svn.videolan.org/x264/trunk@321 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/cabac.c b/common/cabac.c index bd443593..99bce82f 100644 --- a/common/cabac.c +++ b/common/cabac.c @@ -971,7 +971,6 @@ void x264_cabac_encode_init( x264_cabac_t *cb, bs_t *s ) cb->i_range = 0x01FE; cb->b_first_bit= 1; cb->i_bits_outstanding = 0; - cb->i_sym_cnt = 0; cb->s = s; } @@ -1056,8 +1055,6 @@ void x264_cabac_encode_decision( x264_cabac_t *cb, int i_ctx, int b ) cb->ctxstate[i_ctx].i_count++; x264_cabac_encode_renorm( cb ); - - cb->i_sym_cnt++; } void x264_cabac_encode_bypass( x264_cabac_t *cb, int b ) @@ -1089,7 +1086,6 @@ void x264_cabac_encode_bypass( x264_cabac_t *cb, int b ) cb->i_bits_outstanding++; } } - cb->i_sym_cnt++; } void x264_cabac_encode_terminal( x264_cabac_t *cb, int b ) @@ -1105,8 +1101,6 @@ void x264_cabac_encode_terminal( x264_cabac_t *cb, int b ) cb->i_range = 2; } x264_cabac_encode_renorm( cb ); - - cb->i_sym_cnt++; } void x264_cabac_encode_flush( x264_cabac_t *cb ) diff --git a/common/cabac.h b/common/cabac.h index db15ee09..251922d2 100644 --- a/common/cabac.h +++ b/common/cabac.h @@ -46,8 +46,6 @@ typedef struct int i_low; int i_range; - int i_sym_cnt; - /* bit stream */ int b_first_bit; int i_bits_outstanding; diff --git a/encoder/encoder.c b/encoder/encoder.c index a34dfa8b..dec9ad45 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -1051,16 +1051,25 @@ static int x264_slice_write( x264_t *h ) if( h->param.b_cabac ) { - int i_cabac_word; x264_cabac_encode_flush( &h->cabac ); - /* TODO cabac stuffing things (p209) */ - i_cabac_word = (((3 * h->cabac.i_sym_cnt - 3 * 96 * h->sps->i_mb_width * h->sps->i_mb_height)/32) - bs_pos( &h->out.bs)/8)/3; + +#if 0 + /* The standard doesn't explain why one should perform cabac byte stuffing, + * and I see no possible reason. Decoding works fine without it; + * JM and libavcodec don't even check whether it's present. + * Stuffing can cost up to 25% of the total bitrate and 3% of encode time + * in lossless mode. */ + + int i_cabac_word = ((h->cabac.i_sym_cnt + - 96 * h->sps->i_mb_width * h->sps->i_mb_height) * 3/32 + - bs_pos(&h->out.bs)/8)/3; while( i_cabac_word > 0 ) { bs_write( &h->out.bs, 16, 0x0000 ); i_cabac_word--; } +#endif } else {