summaryrefslogtreecommitdiff
path: root/libavcodec/cabac.h
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/cabac.h')
-rw-r--r--libavcodec/cabac.h70
1 files changed, 35 insertions, 35 deletions
diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
index 15ec88d925..1e97275e6d 100644
--- a/libavcodec/cabac.h
+++ b/libavcodec/cabac.h
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-
+
/**
* @file cabac.h
* Context Adaptive Binary Arithmetic Coder.
@@ -54,13 +54,13 @@ extern const uint8_t ff_h264_norm_shift[256];
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 (*lps_range)[4],
uint8_t const *mps_state, uint8_t const *lps_state, int state_count);
static inline void put_cabac_bit(CABACContext *c, int b){
- put_bits(&c->pb, 1, b);
- for(;c->outstanding_count; c->outstanding_count--){
+ put_bits(&c->pb, 1, b);
+ for(;c->outstanding_count; c->outstanding_count--){
put_bits(&c->pb, 1, 1-b);
}
}
@@ -77,7 +77,7 @@ static inline void renorm_cabac_encoder(CABACContext *c){
put_cabac_bit(c, 1);
c->low -= 0x200;
}
-
+
c->range+= c->range;
c->low += c->low;
}
@@ -85,7 +85,7 @@ static inline void renorm_cabac_encoder(CABACContext *c){
static inline void put_cabac(CABACContext *c, uint8_t * const state, int bit){
int RangeLPS= c->lps_range[*state][c->range>>6];
-
+
if(bit == ((*state)&1)){
c->range -= RangeLPS;
*state= c->mps_state[*state];
@@ -94,7 +94,7 @@ static inline void put_cabac(CABACContext *c, uint8_t * const state, int bit){
c->range = RangeLPS;
*state= c->lps_state[*state];
}
-
+
renorm_cabac_encoder(c);
#ifdef STRICT_LIMITS
@@ -138,7 +138,7 @@ static inline void put_cabac_bypass(CABACContext *c, int bit){
put_cabac_bit(c, 1);
c->low -= 0x400;
}
-
+
#ifdef STRICT_LIMITS
c->symCount++;
#endif
@@ -156,16 +156,16 @@ static inline int put_cabac_terminate(CABACContext *c, int bit){
}else{
c->low += c->range;
c->range= 2;
-
+
renorm_cabac_encoder(c);
assert(c->low <= 0x1FF);
put_cabac_bit(c, c->low>>9);
put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
-
+
flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
}
-
+
#ifdef STRICT_LIMITS
c->symCount++;
#endif
@@ -178,9 +178,9 @@ static inline int put_cabac_terminate(CABACContext *c, int bit){
*/
static inline void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){
int i;
-
+
assert(v <= max);
-
+
#if 1
for(i=0; i<v; i++){
put_cabac(c, state, 1);
@@ -213,14 +213,14 @@ static inline void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max,
*/
static inline void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){
int i;
-
+
if(v==0)
put_cabac(c, state, 0);
else{
const int sign= v < 0;
-
+
if(is_signed) v= ABS(v);
-
+
if(v<max){
for(i=0; i<v; i++){
put_cabac(c, state, 1);
@@ -272,14 +272,14 @@ static void refill2(CABACContext *c){
i= 8 - ff_h264_norm_shift[x>>(CABAC_BITS+1)];
x= -CABAC_MASK;
-
+
if(c->bytestream < c->bytestream_end)
#if CABAC_BITS == 16
x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
#else
x+= c->bytestream[0]<<1;
#endif
-
+
c->low += x<<i;
c->bytestream+= CABAC_BITS/8;
}
@@ -305,7 +305,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
static inline int get_cabac(CABACContext *c, uint8_t * const state){
int RangeLPS= c->lps_range[*state][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1);
int bit, lps_mask attribute_unused;
-
+
c->range -= RangeLPS;
#if 1
if(c->low < c->range){
@@ -327,13 +327,13 @@ static inline int get_cabac(CABACContext *c, uint8_t * const state){
}
#else
lps_mask= (c->range - c->low)>>31;
-
+
c->low -= c->range & lps_mask;
c->range += (RangeLPS - c->range) & lps_mask;
-
+
bit= ((*state)^lps_mask)&1;
*state= c->mps_state[(*state) - (128&lps_mask)];
-
+
lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+2)];
c->range<<= lps_mask;
c->low <<= lps_mask;
@@ -341,7 +341,7 @@ static inline int get_cabac(CABACContext *c, uint8_t * const state){
refill2(c);
#endif
- return bit;
+ return bit;
}
static inline int get_cabac_bypass(CABACContext *c){
@@ -349,7 +349,7 @@ static inline int get_cabac_bypass(CABACContext *c){
if(!(c->low & CABAC_MASK))
refill(c);
-
+
if(c->low < c->range){
return 0;
}else{
@@ -369,7 +369,7 @@ static inline int get_cabac_terminate(CABACContext *c){
return 0;
}else{
return c->bytestream - c->bytestream_start;
- }
+ }
}
/**
@@ -377,11 +377,11 @@ static inline int get_cabac_terminate(CABACContext *c){
*/
static inline int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
int i;
-
- for(i=0; i<max; i++){
+
+ for(i=0; i<max; i++){
if(get_cabac(c, state)==0)
return i;
-
+
if(i< max_index) state++;
}
@@ -394,13 +394,13 @@ static inline int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max
static inline int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
int i, v;
int m= 1<<k;
-
- if(get_cabac(c, state)==0)
+
+ if(get_cabac(c, state)==0)
return 0;
-
+
if(0 < max_index) state++;
-
- for(i=1; i<max; i++){
+
+ for(i=1; i<max; i++){
if(get_cabac(c, state)==0){
if(is_signed && get_cabac_bypass(c)){
return -i;
@@ -410,12 +410,12 @@ static inline int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int i
if(i < max_index) state++;
}
-
+
while(get_cabac_bypass(c)){
i+= m;
m+= m;
}
-
+
v=0;
while(m>>=1){
v+= v + get_cabac_bypass(c);