diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-10-11 13:21:42 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-10-11 13:21:42 +0000 |
commit | 0fa352c7e6f208605b54f21b6d5859054b0c95ea (patch) | |
tree | 005a0045192c7ebfb6cc45555a919c4de61da15f | |
parent | 3650b43959cdd2fbe6fa9cff3208c2e953c9faee (diff) | |
download | ffmpeg-0fa352c7e6f208605b54f21b6d5859054b0c95ea.tar.gz |
make lps_range a global table its constant anyway (saves 1 addition for accessing it)
Originally committed as revision 6653 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/cabac.c | 10 | ||||
-rw-r--r-- | libavcodec/cabac.h | 26 | ||||
-rw-r--r-- | libavcodec/h264.c | 2 |
3 files changed, 18 insertions, 20 deletions
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index f2744a39bb..89e7e99c7d 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -31,7 +31,7 @@ #include "bitstream.h" #include "cabac.h" -const uint8_t ff_h264_lps_range[64][4]= { +static const uint8_t lps_range[64][4]= { {128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205}, {116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166}, { 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135}, @@ -50,6 +50,8 @@ const uint8_t ff_h264_lps_range[64][4]= { { 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2}, }; +uint8_t ff_h264_lps_range[2*65][4]; + const uint8_t ff_h264_mps_state[64]= { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, @@ -119,14 +121,14 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){ c->range= 0x1FE<<(CABAC_BITS + 1); } -void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], +void ff_init_cabac_states(CABACContext *c, uint8_t const *mps_state, uint8_t const *lps_state, int state_count){ int i, j; for(i=0; i<state_count; i++){ for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save - c->lps_range[2*i+0][j+4]= - c->lps_range[2*i+1][j+4]= lps_range[i][j]; + ff_h264_lps_range[2*i+0][j+4]= + ff_h264_lps_range[2*i+1][j+4]= lps_range[i][j]; } c->mps_state[2*i+0]= 2*mps_state[i]+0; diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h index f5e4e03e99..1ec1e50877 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h @@ -41,7 +41,6 @@ typedef struct CABACContext{ #ifdef STRICT_LIMITS int symCount; #endif - uint8_t lps_range[2*65][4]; ///< rangeTabLPS uint8_t lps_state[2*64]; ///< transIdxLPS uint8_t mps_state[2*64]; ///< transIdxMPS const uint8_t *bytestream_start; @@ -50,7 +49,7 @@ typedef struct CABACContext{ PutBitContext pb; }CABACContext; -extern const uint8_t ff_h264_lps_range[64][4]; +extern uint8_t ff_h264_lps_range[2*65][4]; ///< rangeTabLPS extern const uint8_t ff_h264_mps_state[64]; extern const uint8_t ff_h264_lps_state[64]; extern const uint8_t ff_h264_norm_shift[128]; @@ -58,7 +57,7 @@ extern const uint8_t ff_h264_norm_shift[128]; void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size); void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size); -void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], +void ff_init_cabac_states(CABACContext *c, uint8_t const *mps_state, uint8_t const *lps_state, int state_count); @@ -88,7 +87,7 @@ static inline void renorm_cabac_encoder(CABACContext *c){ } static void put_cabac(CABACContext *c, uint8_t * const state, int bit){ - int RangeLPS= c->lps_range[*state][c->range>>6]; + int RangeLPS= ff_h264_lps_range[*state][c->range>>6]; if(bit == ((*state)&1)){ c->range -= RangeLPS; @@ -370,20 +369,18 @@ static int get_cabac(CABACContext *c, uint8_t * const state){ #define LOW "0" #define RANGE "4" -#define LPS_RANGE "12" -#define LPS_STATE "12+2*65*4" -#define MPS_STATE "12+2*65*4+2*64" -#define BYTESTART "12+2*65*4+4*64" -#define BYTE "16+2*65*4+4*64" -#define BYTEEND "20+2*65*4+4*64" +#define LPS_STATE "12" +#define MPS_STATE "12+2*64" +#define BYTESTART "12+4*64" +#define BYTE "16+4*64" +#define BYTEEND "20+4*64" #ifndef BRANCHLESS_CABAC_DECODER asm volatile( "movzbl (%1), %%eax \n\t" "movl "RANGE "(%2), %%ebx \n\t" "movl "RANGE "(%2), %%edx \n\t" "shrl $23, %%ebx \n\t" - "leal "LPS_RANGE"(%2, %%eax, 4), %%esi \n\t" - "movzbl (%%ebx, %%esi), %%esi \n\t" + "movzbl ff_h264_lps_range(%%ebx, %%eax, 4), %%esi\n\t" "shll $17, %%esi \n\t" "movl "LOW "(%2), %%ebx \n\t" //eax:state ebx:low, edx:range, esi:RangeLPS @@ -453,8 +450,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){ "movl "RANGE "(%2), %%ebx \n\t" "movl "RANGE "(%2), %%edx \n\t" "shrl $23, %%ebx \n\t" - "leal "LPS_RANGE"(%2, %%eax, 4), %%esi \n\t" - "movzbl (%%ebx, %%esi), %%esi \n\t" + "movzbl ff_h264_lps_range(%%ebx, %%eax, 4), %%esi\n\t" "shll $17, %%esi \n\t" "movl "LOW "(%2), %%ebx \n\t" //eax:state ebx:low, edx:range, esi:RangeLPS @@ -520,7 +516,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){ #endif #else int s = *state; - int RangeLPS= c->lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); + int RangeLPS= ff_h264_lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); int bit, lps_mask attribute_unused; c->range -= RangeLPS; diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 210005a828..0d38ac4322 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -7388,7 +7388,7 @@ static int decode_slice(H264Context *h){ align_get_bits( &s->gb ); /* init cabac */ - ff_init_cabac_states( &h->cabac, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64 ); + ff_init_cabac_states( &h->cabac, ff_h264_mps_state, ff_h264_lps_state, 64 ); ff_init_cabac_decoder( &h->cabac, s->gb.buffer + get_bits_count(&s->gb)/8, ( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8); |