Commit 7dbc4aa1 authored by lorenm's avatar lorenm

tweak cabac. 0.5% faster h264.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@6106 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent b5df2630
...@@ -295,28 +295,30 @@ static inline void renorm_cabac_decoder(CABACContext *c){ ...@@ -295,28 +295,30 @@ static inline void renorm_cabac_decoder(CABACContext *c){
} }
static inline void renorm_cabac_decoder_once(CABACContext *c){ static inline void renorm_cabac_decoder_once(CABACContext *c){
int mask= (c->range - (0x200 << CABAC_BITS))>>31; int shift= (uint32_t)(c->range - (0x200 << CABAC_BITS))>>31;
c->range+= c->range&mask; c->range<<= shift;
c->low += c->low &mask; c->low <<= shift;
if(!(c->low & CABAC_MASK)) if(!(c->low & CABAC_MASK))
refill(c); refill(c);
} }
static inline int get_cabac(CABACContext *c, uint8_t * const state){ static inline int get_cabac(CABACContext *c, uint8_t * const state){
int RangeLPS= c->lps_range[*state][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); //FIXME gcc generates duplicate load/stores for c->low and c->range
int s = *state;
int RangeLPS= c->lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1);
int bit, lps_mask attribute_unused; int bit, lps_mask attribute_unused;
c->range -= RangeLPS; c->range -= RangeLPS;
#if 1 #if 1
if(c->low < c->range){ if(c->low < c->range){
bit= (*state)&1; bit= s&1;
*state= c->mps_state[*state]; *state= c->mps_state[s];
renorm_cabac_decoder_once(c); renorm_cabac_decoder_once(c);
}else{ }else{
// int shift= ff_h264_norm_shift[RangeLPS>>17]; // int shift= ff_h264_norm_shift[RangeLPS>>17];
bit= ((*state)&1)^1; bit= (s&1)^1;
c->low -= c->range; c->low -= c->range;
*state= c->lps_state[*state]; *state= c->lps_state[s];
c->range = RangeLPS; c->range = RangeLPS;
renorm_cabac_decoder(c); renorm_cabac_decoder(c);
/* c->range = RangeLPS<<shift; /* c->range = RangeLPS<<shift;
...@@ -331,8 +333,8 @@ static inline int get_cabac(CABACContext *c, uint8_t * const state){ ...@@ -331,8 +333,8 @@ static inline int get_cabac(CABACContext *c, uint8_t * const state){
c->low -= c->range & lps_mask; c->low -= c->range & lps_mask;
c->range += (RangeLPS - c->range) & lps_mask; c->range += (RangeLPS - c->range) & lps_mask;
bit= ((*state)^lps_mask)&1; bit= (s^lps_mask)&1;
*state= c->mps_state[(*state) - (128&lps_mask)]; *state= c->mps_state[s - (128&lps_mask)];
lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+2)]; lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+2)];
c->range<<= lps_mask; c->range<<= lps_mask;
......
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