diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/cabac.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/cabac.c')
| -rw-r--r-- | ffmpeg/libavcodec/cabac.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/ffmpeg/libavcodec/cabac.c b/ffmpeg/libavcodec/cabac.c index 187b7dc..dff0a91 100644 --- a/ffmpeg/libavcodec/cabac.c +++ b/ffmpeg/libavcodec/cabac.c @@ -73,9 +73,6 @@ static const uint8_t lps_range[64][4]= { { 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2}, }; -static uint8_t h264_lps_state[2*64]; -static uint8_t h264_mps_state[2*64]; - static const uint8_t mps_state[64]= { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, @@ -140,33 +137,32 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){ void ff_init_cabac_states(void) { int i, j; + static int initialized = 0; + + if (initialized) + return; for(i=0; i<64; i++){ for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save ff_h264_lps_range[j*2*64+2*i+0]= ff_h264_lps_range[j*2*64+2*i+1]= lps_range[i][j]; } - - ff_h264_mlps_state[128+2*i+0]= - h264_mps_state[2 * i + 0] = 2 * mps_state[i] + 0; - ff_h264_mlps_state[128+2*i+1]= - h264_mps_state[2 * i + 1] = 2 * mps_state[i] + 1; + ff_h264_mlps_state[128 + 2 * i + 0] = 2 * mps_state[i] + 0; + ff_h264_mlps_state[128 + 2 * i + 1] = 2 * mps_state[i] + 1; if( i ){ - h264_lps_state[2*i+0]= ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0; - h264_lps_state[2*i+1]= ff_h264_mlps_state[128-2*i-2]= 2*lps_state[i]+1; }else{ - h264_lps_state[2*i+0]= ff_h264_mlps_state[128-2*i-1]= 1; - h264_lps_state[2*i+1]= ff_h264_mlps_state[128-2*i-2]= 0; } } for(i=0; i< 63; i++){ ff_h264_last_coeff_flag_offset_8x8[i] = last_coeff_flag_offset_8x8[i]; } + + initialized = 1; } #ifdef TEST @@ -174,7 +170,6 @@ void ff_init_cabac_states(void) #include "libavutil/lfg.h" #include "avcodec.h" -#include "cabac.h" static inline void put_cabac_bit(CABACContext *c, int b){ put_bits(&c->pb, 1, b); @@ -206,11 +201,11 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){ if(bit == ((*state)&1)){ c->range -= RangeLPS; - *state = h264_mps_state[*state]; + *state = ff_h264_mlps_state[128 + *state]; }else{ c->low += c->range - RangeLPS; c->range = RangeLPS; - *state= h264_lps_state[*state]; + *state= ff_h264_mlps_state[127 - *state]; } renorm_cabac_encoder(c); @@ -306,7 +301,7 @@ STOP_TIMER("get_cabac_bypass") for(i=0; i<SIZE; i++){ START_TIMER - if( (r[i]&1) != get_cabac(&c, state) ) + if( (r[i]&1) != get_cabac_noinline(&c, state) ) av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i); STOP_TIMER("get_cabac") } |
