comparison cabac.h @ 3928:987fffdf6ae7 libavcodec

don't try to inline cabac functions. gcc ignored the hint anyway, and forcing it would make h264 slower.
author lorenm
date Wed, 04 Oct 2006 07:16:10 +0000
parents 0efda682253c
children 811a9b0d9f32
comparison
equal deleted inserted replaced
3927:f44a3341bfdf 3928:987fffdf6ae7
81 c->range+= c->range; 81 c->range+= c->range;
82 c->low += c->low; 82 c->low += c->low;
83 } 83 }
84 } 84 }
85 85
86 static inline void put_cabac(CABACContext *c, uint8_t * const state, int bit){ 86 static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
87 int RangeLPS= c->lps_range[*state][c->range>>6]; 87 int RangeLPS= c->lps_range[*state][c->range>>6];
88 88
89 if(bit == ((*state)&1)){ 89 if(bit == ((*state)&1)){
90 c->range -= RangeLPS; 90 c->range -= RangeLPS;
91 *state= c->mps_state[*state]; 91 *state= c->mps_state[*state];
100 #ifdef STRICT_LIMITS 100 #ifdef STRICT_LIMITS
101 c->symCount++; 101 c->symCount++;
102 #endif 102 #endif
103 } 103 }
104 104
105 static inline void put_cabac_static(CABACContext *c, int RangeLPS, int bit){ 105 static void put_cabac_static(CABACContext *c, int RangeLPS, int bit){
106 assert(c->range > RangeLPS); 106 assert(c->range > RangeLPS);
107 107
108 if(!bit){ 108 if(!bit){
109 c->range -= RangeLPS; 109 c->range -= RangeLPS;
110 }else{ 110 }else{
120 } 120 }
121 121
122 /** 122 /**
123 * @param bit 0 -> write zero bit, !=0 write one bit 123 * @param bit 0 -> write zero bit, !=0 write one bit
124 */ 124 */
125 static inline void put_cabac_bypass(CABACContext *c, int bit){ 125 static void put_cabac_bypass(CABACContext *c, int bit){
126 c->low += c->low; 126 c->low += c->low;
127 127
128 if(bit){ 128 if(bit){
129 c->low += c->range; 129 c->low += c->range;
130 } 130 }
146 146
147 /** 147 /**
148 * 148 *
149 * @return the number of bytes written 149 * @return the number of bytes written
150 */ 150 */
151 static inline int put_cabac_terminate(CABACContext *c, int bit){ 151 static int put_cabac_terminate(CABACContext *c, int bit){
152 c->range -= 2; 152 c->range -= 2;
153 153
154 if(!bit){ 154 if(!bit){
155 renorm_cabac_encoder(c); 155 renorm_cabac_encoder(c);
156 }else{ 156 }else{
174 } 174 }
175 175
176 /** 176 /**
177 * put (truncated) unary binarization. 177 * put (truncated) unary binarization.
178 */ 178 */
179 static inline void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){ 179 static void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){
180 int i; 180 int i;
181 181
182 assert(v <= max); 182 assert(v <= max);
183 183
184 #if 1 184 #if 1
209 } 209 }
210 210
211 /** 211 /**
212 * put unary exp golomb k-th order binarization. 212 * put unary exp golomb k-th order binarization.
213 */ 213 */
214 static inline void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){ 214 static void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){
215 int i; 215 int i;
216 216
217 if(v==0) 217 if(v==0)
218 put_cabac(c, state, 0); 218 put_cabac(c, state, 0);
219 else{ 219 else{
300 c->low <<= shift; 300 c->low <<= shift;
301 if(!(c->low & CABAC_MASK)) 301 if(!(c->low & CABAC_MASK))
302 refill(c); 302 refill(c);
303 } 303 }
304 304
305 static inline int get_cabac(CABACContext *c, uint8_t * const state){ 305 static int get_cabac(CABACContext *c, uint8_t * const state){
306 //FIXME gcc generates duplicate load/stores for c->low and c->range 306 //FIXME gcc generates duplicate load/stores for c->low and c->range
307 int s = *state; 307 int s = *state;
308 int RangeLPS= c->lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); 308 int RangeLPS= c->lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1);
309 int bit, lps_mask attribute_unused; 309 int bit, lps_mask attribute_unused;
310 310
344 #endif 344 #endif
345 345
346 return bit; 346 return bit;
347 } 347 }
348 348
349 static inline int get_cabac_bypass(CABACContext *c){ 349 static int get_cabac_bypass(CABACContext *c){
350 c->low += c->low; 350 c->low += c->low;
351 351
352 if(!(c->low & CABAC_MASK)) 352 if(!(c->low & CABAC_MASK))
353 refill(c); 353 refill(c);
354 354
362 362
363 /** 363 /**
364 * 364 *
365 * @return the number of bytes read or 0 if no end 365 * @return the number of bytes read or 0 if no end
366 */ 366 */
367 static inline int get_cabac_terminate(CABACContext *c){ 367 static int get_cabac_terminate(CABACContext *c){
368 c->range -= 4<<CABAC_BITS; 368 c->range -= 4<<CABAC_BITS;
369 if(c->low < c->range){ 369 if(c->low < c->range){
370 renorm_cabac_decoder_once(c); 370 renorm_cabac_decoder_once(c);
371 return 0; 371 return 0;
372 }else{ 372 }else{
375 } 375 }
376 376
377 /** 377 /**
378 * get (truncated) unnary binarization. 378 * get (truncated) unnary binarization.
379 */ 379 */
380 static inline int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){ 380 static int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
381 int i; 381 int i;
382 382
383 for(i=0; i<max; i++){ 383 for(i=0; i<max; i++){
384 if(get_cabac(c, state)==0) 384 if(get_cabac(c, state)==0)
385 return i; 385 return i;
391 } 391 }
392 392
393 /** 393 /**
394 * get unary exp golomb k-th order binarization. 394 * get unary exp golomb k-th order binarization.
395 */ 395 */
396 static inline int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){ 396 static int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
397 int i, v; 397 int i, v;
398 int m= 1<<k; 398 int m= 1<<k;
399 399
400 if(get_cabac(c, state)==0) 400 if(get_cabac(c, state)==0)
401 return 0; 401 return 0;