Commit 1c6ccbf5 authored by Loren Merritt's avatar Loren Merritt

remove cabac byte-stuffing code, because it just wastes bits in lossless, and...

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
parent acee2d51
......@@ -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 )
......
......@@ -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;
......
......@@ -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
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment