Mercurial > libavcodec.hg
comparison cabac.c @ 3991:72bae00a317f libavcodec
make lps_range a global table its constant anyway (saves 1 addition for accessing it)
| author | michael |
|---|---|
| date | Wed, 11 Oct 2006 13:21:42 +0000 |
| parents | bb186452e7da |
| children | 8b7c59b7af01 |
comparison
equal
deleted
inserted
replaced
| 3990:746a60ba3177 | 3991:72bae00a317f |
|---|---|
| 29 | 29 |
| 30 #include "common.h" | 30 #include "common.h" |
| 31 #include "bitstream.h" | 31 #include "bitstream.h" |
| 32 #include "cabac.h" | 32 #include "cabac.h" |
| 33 | 33 |
| 34 const uint8_t ff_h264_lps_range[64][4]= { | 34 static const uint8_t lps_range[64][4]= { |
| 35 {128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205}, | 35 {128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205}, |
| 36 {116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166}, | 36 {116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166}, |
| 37 { 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135}, | 37 { 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135}, |
| 38 { 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110}, | 38 { 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110}, |
| 39 { 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89}, | 39 { 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89}, |
| 48 { 10, 12, 14, 16}, { 9, 11, 13, 15}, { 9, 11, 12, 14}, { 8, 10, 12, 14}, | 48 { 10, 12, 14, 16}, { 9, 11, 13, 15}, { 9, 11, 12, 14}, { 8, 10, 12, 14}, |
| 49 { 8, 9, 11, 13}, { 7, 9, 11, 12}, { 7, 9, 10, 12}, { 7, 8, 10, 11}, | 49 { 8, 9, 11, 13}, { 7, 9, 11, 12}, { 7, 9, 10, 12}, { 7, 8, 10, 11}, |
| 50 { 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2}, | 50 { 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2}, |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 uint8_t ff_h264_lps_range[2*65][4]; | |
| 54 | |
| 53 const uint8_t ff_h264_mps_state[64]= { | 55 const uint8_t ff_h264_mps_state[64]= { |
| 54 1, 2, 3, 4, 5, 6, 7, 8, | 56 1, 2, 3, 4, 5, 6, 7, 8, |
| 55 9,10,11,12,13,14,15,16, | 57 9,10,11,12,13,14,15,16, |
| 56 17,18,19,20,21,22,23,24, | 58 17,18,19,20,21,22,23,24, |
| 57 25,26,27,28,29,30,31,32, | 59 25,26,27,28,29,30,31,32, |
| 117 #endif | 119 #endif |
| 118 c->low+= ((*c->bytestream++)<<2) + 2; | 120 c->low+= ((*c->bytestream++)<<2) + 2; |
| 119 c->range= 0x1FE<<(CABAC_BITS + 1); | 121 c->range= 0x1FE<<(CABAC_BITS + 1); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], | 124 void ff_init_cabac_states(CABACContext *c, |
| 123 uint8_t const *mps_state, uint8_t const *lps_state, int state_count){ | 125 uint8_t const *mps_state, uint8_t const *lps_state, int state_count){ |
| 124 int i, j; | 126 int i, j; |
| 125 | 127 |
| 126 for(i=0; i<state_count; i++){ | 128 for(i=0; i<state_count; i++){ |
| 127 for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save | 129 for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save |
| 128 c->lps_range[2*i+0][j+4]= | 130 ff_h264_lps_range[2*i+0][j+4]= |
| 129 c->lps_range[2*i+1][j+4]= lps_range[i][j]; | 131 ff_h264_lps_range[2*i+1][j+4]= lps_range[i][j]; |
| 130 } | 132 } |
| 131 | 133 |
| 132 c->mps_state[2*i+0]= 2*mps_state[i]+0; | 134 c->mps_state[2*i+0]= 2*mps_state[i]+0; |
| 133 c->mps_state[2*i+1]= 2*mps_state[i]+1; | 135 c->mps_state[2*i+1]= 2*mps_state[i]+1; |
| 134 | 136 |
