Originally committed as revision 6655 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -51,8 +51,10 @@ static const uint8_t lps_range[64][4]= {
|
| 51 | 51 |
}; |
| 52 | 52 |
|
| 53 | 53 |
uint8_t ff_h264_lps_range[2*65][4]; |
| 54 |
+uint8_t ff_h264_lps_state[2*64]; |
|
| 55 |
+uint8_t ff_h264_mps_state[2*64]; |
|
| 54 | 56 |
|
| 55 |
-const uint8_t ff_h264_mps_state[64]= {
|
|
| 57 |
+static const uint8_t mps_state[64]= {
|
|
| 56 | 58 |
1, 2, 3, 4, 5, 6, 7, 8, |
| 57 | 59 |
9,10,11,12,13,14,15,16, |
| 58 | 60 |
17,18,19,20,21,22,23,24, |
| ... | ... |
@@ -63,7 +65,7 @@ const uint8_t ff_h264_mps_state[64]= {
|
| 63 | 63 |
57,58,59,60,61,62,62,63, |
| 64 | 64 |
}; |
| 65 | 65 |
|
| 66 |
-const uint8_t ff_h264_lps_state[64]= {
|
|
| 66 |
+static const uint8_t lps_state[64]= {
|
|
| 67 | 67 |
0, 0, 1, 2, 2, 4, 4, 5, |
| 68 | 68 |
6, 7, 8, 9, 9,11,11,12, |
| 69 | 69 |
13,13,15,15,16,16,18,18, |
| ... | ... |
@@ -121,32 +123,31 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
|
| 121 | 121 |
c->range= 0x1FE<<(CABAC_BITS + 1); |
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 |
-void ff_init_cabac_states(CABACContext *c, |
|
| 125 |
- uint8_t const *mps_state, uint8_t const *lps_state, int state_count){
|
|
| 124 |
+void ff_init_cabac_states(CABACContext *c){
|
|
| 126 | 125 |
int i, j; |
| 127 | 126 |
|
| 128 |
- for(i=0; i<state_count; i++){
|
|
| 127 |
+ for(i=0; i<64; i++){
|
|
| 129 | 128 |
for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save
|
| 130 | 129 |
ff_h264_lps_range[2*i+0][j+4]= |
| 131 | 130 |
ff_h264_lps_range[2*i+1][j+4]= lps_range[i][j]; |
| 132 | 131 |
} |
| 133 | 132 |
|
| 134 |
- c->mps_state[2*i+0]= 2*mps_state[i]+0; |
|
| 135 |
- c->mps_state[2*i+1]= 2*mps_state[i]+1; |
|
| 133 |
+ ff_h264_mps_state[2*i+0]= 2*mps_state[i]+0; |
|
| 134 |
+ ff_h264_mps_state[2*i+1]= 2*mps_state[i]+1; |
|
| 136 | 135 |
|
| 137 | 136 |
if( i ){
|
| 138 | 137 |
#ifdef BRANCHLESS_CABAC_DECODER |
| 139 |
- c->mps_state[-2*i-1]= 2*lps_state[i]+0; //FIXME yes this is not valid C but iam lazy, cleanup welcome |
|
| 140 |
- c->mps_state[-2*i-2]= 2*lps_state[i]+1; |
|
| 138 |
+ ff_h264_mps_state[-2*i-1]= 2*lps_state[i]+0; //FIXME yes this is not valid C but iam lazy, cleanup welcome |
|
| 139 |
+ ff_h264_mps_state[-2*i-2]= 2*lps_state[i]+1; |
|
| 141 | 140 |
}else{
|
| 142 |
- c->mps_state[-2*i-1]= 1; |
|
| 143 |
- c->mps_state[-2*i-2]= 0; |
|
| 141 |
+ ff_h264_mps_state[-2*i-1]= 1; |
|
| 142 |
+ ff_h264_mps_state[-2*i-2]= 0; |
|
| 144 | 143 |
#else |
| 145 |
- c->lps_state[2*i+0]= 2*lps_state[i]+0; |
|
| 146 |
- c->lps_state[2*i+1]= 2*lps_state[i]+1; |
|
| 144 |
+ ff_h264_lps_state[2*i+0]= 2*lps_state[i]+0; |
|
| 145 |
+ ff_h264_lps_state[2*i+1]= 2*lps_state[i]+1; |
|
| 147 | 146 |
}else{
|
| 148 |
- c->lps_state[2*i+0]= 1; |
|
| 149 |
- c->lps_state[2*i+1]= 0; |
|
| 147 |
+ ff_h264_lps_state[2*i+0]= 1; |
|
| 148 |
+ ff_h264_lps_state[2*i+1]= 0; |
|
| 150 | 149 |
#endif |
| 151 | 150 |
} |
| 152 | 151 |
} |
| ... | ... |
@@ -41,8 +41,6 @@ typedef struct CABACContext{
|
| 41 | 41 |
#ifdef STRICT_LIMITS |
| 42 | 42 |
int symCount; |
| 43 | 43 |
#endif |
| 44 |
- uint8_t lps_state[2*64]; ///< transIdxLPS |
|
| 45 |
- uint8_t mps_state[2*64]; ///< transIdxMPS |
|
| 46 | 44 |
const uint8_t *bytestream_start; |
| 47 | 45 |
const uint8_t *bytestream; |
| 48 | 46 |
const uint8_t *bytestream_end; |
| ... | ... |
@@ -50,15 +48,14 @@ typedef struct CABACContext{
|
| 50 | 50 |
}CABACContext; |
| 51 | 51 |
|
| 52 | 52 |
extern uint8_t ff_h264_lps_range[2*65][4]; ///< rangeTabLPS |
| 53 |
-extern const uint8_t ff_h264_mps_state[64]; |
|
| 54 |
-extern const uint8_t ff_h264_lps_state[64]; |
|
| 53 |
+extern uint8_t ff_h264_mps_state[2*64]; ///< transIdxMPS |
|
| 54 |
+extern uint8_t ff_h264_lps_state[2*64]; ///< transIdxLPS |
|
| 55 | 55 |
extern const uint8_t ff_h264_norm_shift[128]; |
| 56 | 56 |
|
| 57 | 57 |
|
| 58 | 58 |
void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size); |
| 59 | 59 |
void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size); |
| 60 |
-void ff_init_cabac_states(CABACContext *c, |
|
| 61 |
- uint8_t const *mps_state, uint8_t const *lps_state, int state_count); |
|
| 60 |
+void ff_init_cabac_states(CABACContext *c); |
|
| 62 | 61 |
|
| 63 | 62 |
|
| 64 | 63 |
static inline void put_cabac_bit(CABACContext *c, int b){
|
| ... | ... |
@@ -91,11 +88,11 @@ static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
|
| 91 | 91 |
|
| 92 | 92 |
if(bit == ((*state)&1)){
|
| 93 | 93 |
c->range -= RangeLPS; |
| 94 |
- *state= c->mps_state[*state]; |
|
| 94 |
+ *state= ff_h264_mps_state[*state]; |
|
| 95 | 95 |
}else{
|
| 96 | 96 |
c->low += c->range - RangeLPS; |
| 97 | 97 |
c->range = RangeLPS; |
| 98 |
- *state= c->lps_state[*state]; |
|
| 98 |
+ *state= ff_h264_lps_state[*state]; |
|
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
renorm_cabac_encoder(c); |
| ... | ... |
@@ -369,11 +366,9 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 369 | 369 |
|
| 370 | 370 |
#define LOW "0" |
| 371 | 371 |
#define RANGE "4" |
| 372 |
-#define LPS_STATE "12" |
|
| 373 |
-#define MPS_STATE "12+2*64" |
|
| 374 |
-#define BYTESTART "12+4*64" |
|
| 375 |
-#define BYTE "16+4*64" |
|
| 376 |
-#define BYTEEND "20+4*64" |
|
| 372 |
+#define BYTESTART "12" |
|
| 373 |
+#define BYTE "16" |
|
| 374 |
+#define BYTEEND "20" |
|
| 377 | 375 |
#ifndef BRANCHLESS_CABAC_DECODER |
| 378 | 376 |
asm volatile( |
| 379 | 377 |
"movzbl (%1), %%eax \n\t" |
| ... | ... |
@@ -391,7 +386,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 391 | 391 |
"setb %%cl \n\t" |
| 392 | 392 |
"shl %%cl, %%edx \n\t" |
| 393 | 393 |
"shl %%cl, %%ebx \n\t" |
| 394 |
- "movzbl "MPS_STATE"(%2, %%eax), %%ecx \n\t" |
|
| 394 |
+ "movzbl "MANGLE(ff_h264_mps_state)"(%%eax), %%ecx \n\t" |
|
| 395 | 395 |
"movb %%cl, (%1) \n\t" |
| 396 | 396 |
//eax:state ebx:low, edx:range, esi:RangeLPS |
| 397 | 397 |
"test %%bx, %%bx \n\t" |
| ... | ... |
@@ -413,7 +408,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 413 | 413 |
"movzbl " MANGLE(ff_h264_norm_shift) "(%%esi), %%ecx \n\t" |
| 414 | 414 |
"shll %%cl, %%ebx \n\t" |
| 415 | 415 |
"shll %%cl, %%edx \n\t" |
| 416 |
- "movzbl "LPS_STATE"(%2, %%eax), %%ecx \n\t" |
|
| 416 |
+ "movzbl "MANGLE(ff_h264_lps_state)"(%%eax), %%ecx \n\t" |
|
| 417 | 417 |
"movb %%cl, (%1) \n\t" |
| 418 | 418 |
"addl $1, %%eax \n\t" |
| 419 | 419 |
"test %%bx, %%bx \n\t" |
| ... | ... |
@@ -475,7 +470,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 475 | 475 |
#endif |
| 476 | 476 |
|
| 477 | 477 |
//eax:state ebx:low edx:mask esi:range |
| 478 |
- "movzbl "MPS_STATE"(%2, %%eax), %%ecx \n\t" |
|
| 478 |
+ "movzbl "MANGLE(ff_h264_mps_state)"(%%eax), %%ecx \n\t" |
|
| 479 | 479 |
"movb %%cl, (%1) \n\t" |
| 480 | 480 |
|
| 481 | 481 |
"movl %%esi, %%edx \n\t" |
| ... | ... |
@@ -523,12 +518,12 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 523 | 523 |
#ifndef BRANCHLESS_CABAC_DECODER |
| 524 | 524 |
if(c->low < c->range){
|
| 525 | 525 |
bit= s&1; |
| 526 |
- *state= c->mps_state[s]; |
|
| 526 |
+ *state= ff_h264_mps_state[s]; |
|
| 527 | 527 |
renorm_cabac_decoder_once(c); |
| 528 | 528 |
}else{
|
| 529 | 529 |
bit= ff_h264_norm_shift[RangeLPS>>19]; |
| 530 | 530 |
c->low -= c->range; |
| 531 |
- *state= c->lps_state[s]; |
|
| 531 |
+ *state= ff_h264_lps_state[s]; |
|
| 532 | 532 |
c->range = RangeLPS<<bit; |
| 533 | 533 |
c->low <<= bit; |
| 534 | 534 |
bit= (s&1)^1; |
| ... | ... |
@@ -544,7 +539,7 @@ static int get_cabac(CABACContext *c, uint8_t * const state){
|
| 544 | 544 |
c->range += (RangeLPS - c->range) & lps_mask; |
| 545 | 545 |
|
| 546 | 546 |
s^=lps_mask; |
| 547 |
- *state= c->mps_state[s]; |
|
| 547 |
+ *state= ff_h264_mps_state[s]; |
|
| 548 | 548 |
bit= s&1; |
| 549 | 549 |
|
| 550 | 550 |
lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+3)]; |
| ... | ... |
@@ -7388,7 +7388,7 @@ static int decode_slice(H264Context *h){
|
| 7388 | 7388 |
align_get_bits( &s->gb ); |
| 7389 | 7389 |
|
| 7390 | 7390 |
/* init cabac */ |
| 7391 |
- ff_init_cabac_states( &h->cabac, ff_h264_mps_state, ff_h264_lps_state, 64 ); |
|
| 7391 |
+ ff_init_cabac_states( &h->cabac); |
|
| 7392 | 7392 |
ff_init_cabac_decoder( &h->cabac, |
| 7393 | 7393 |
s->gb.buffer + get_bits_count(&s->gb)/8, |
| 7394 | 7394 |
( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8); |