#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
+ uint8_t lps_range[2*66][4]; ///< rangeTabLPS
+ uint8_t lps_state[2*65]; ///< transIdxLPS
+ uint8_t mps_state[2*65]; ///< transIdxMPS
const uint8_t *bytestream_start;
const uint8_t *bytestream;
const uint8_t *bytestream_end;
c->bytestream+= CABAC_BITS/8;
}
-#if 0 /* all use commented */
+#if 1 /* all use commented */
static void refill2(CABACContext *c){
int i, x;
x= c->low ^ (c->low-1);
- i= 8 - ff_h264_norm_shift[x>>(CABAC_BITS+1)];
+ i= 9 - ff_h264_norm_shift[x>>(CABAC_BITS+1)];
x= -CABAC_MASK;
- if(c->bytestream < c->bytestream_end)
+ if(c->bytestream <= c->bytestream_end)
#if CABAC_BITS == 16
x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
#else
#if 1
if(c->low < c->range){
bit= s&1;
- *state= c->mps_state[s];
+#ifdef ARCH_X86
+ //P3:627
+asm(
+ "addb $2, %b0 \n\t"
+ " js 1f \n\t"
+ "movb %b0, %1 \n\t"
+ "1: \n\t"
+ : "+q"(s), "=m"(*state)
+);
+#else
+ *state= c->mps_state[s]; //P3:655
+/* if(s<126) //P3:657
+ *state= s+2;*/
+ s+=2; //P3:631
+ if(s<128)
+ *state= s;
+#endif
renorm_cabac_decoder_once(c);
}else{
-// int shift= ff_h264_norm_shift[RangeLPS>>17];
- bit= (s&1)^1;
+ bit= ff_h264_norm_shift[RangeLPS>>17];
c->low -= c->range;
*state= c->lps_state[s];
- c->range = RangeLPS;
- renorm_cabac_decoder(c);
-/* c->range = RangeLPS<<shift;
- c->low <<= shift;
+// c->range = RangeLPS;
+// renorm_cabac_decoder(c);
+ c->range = RangeLPS<<bit;
+ c->low <<= bit;
+ bit= (s&1)^1;
+
if(!(c->low & 0xFFFF)){
refill2(c);
- }*/
+ }
}
#else
lps_mask= (c->range - c->low)>>31;