comparison cabac.h @ 3956:0910f2844f9a libavcodec

branchless renormalization (1% faster get_cabac) old branchless renormalization wasnt faster because gcc was scared of the shift variable (missusing bit variable now)
author michael
date Sun, 08 Oct 2006 13:20:22 +0000
parents 051a9c8b257f
children 2acfc35c3075
comparison
equal deleted inserted replaced
3955:051a9c8b257f 3956:0910f2844f9a
264 #endif 264 #endif
265 c->low -= CABAC_MASK; 265 c->low -= CABAC_MASK;
266 c->bytestream+= CABAC_BITS/8; 266 c->bytestream+= CABAC_BITS/8;
267 } 267 }
268 268
269 #if 0 /* all use commented */ 269 #if 1 /* all use commented */
270 static void refill2(CABACContext *c){ 270 static void refill2(CABACContext *c){
271 int i, x; 271 int i, x;
272 272
273 x= c->low ^ (c->low-1); 273 x= c->low ^ (c->low-1);
274 i= 8 - ff_h264_norm_shift[x>>(CABAC_BITS+1)]; 274 i= 9 - ff_h264_norm_shift[x>>(CABAC_BITS+1)];
275 275
276 x= -CABAC_MASK; 276 x= -CABAC_MASK;
277 277
278 if(c->bytestream < c->bytestream_end) 278 if(c->bytestream <= c->bytestream_end)
279 #if CABAC_BITS == 16 279 #if CABAC_BITS == 16
280 x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1); 280 x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
281 #else 281 #else
282 x+= c->bytestream[0]<<1; 282 x+= c->bytestream[0]<<1;
283 #endif 283 #endif
393 if(s<128) 393 if(s<128)
394 *state= s; 394 *state= s;
395 #endif 395 #endif
396 renorm_cabac_decoder_once(c); 396 renorm_cabac_decoder_once(c);
397 }else{ 397 }else{
398 // int shift= ff_h264_norm_shift[RangeLPS>>17]; 398 bit= ff_h264_norm_shift[RangeLPS>>17];
399 bit= (s&1)^1;
400 c->low -= c->range; 399 c->low -= c->range;
401 *state= c->lps_state[s]; 400 *state= c->lps_state[s];
402 c->range = RangeLPS; 401 // c->range = RangeLPS;
403 renorm_cabac_decoder(c); 402 // renorm_cabac_decoder(c);
404 /* c->range = RangeLPS<<shift; 403 c->range = RangeLPS<<bit;
405 c->low <<= shift; 404 c->low <<= bit;
405 bit= (s&1)^1;
406
406 if(!(c->low & 0xFFFF)){ 407 if(!(c->low & 0xFFFF)){
407 refill2(c); 408 refill2(c);
408 }*/ 409 }
409 } 410 }
410 #else 411 #else
411 lps_mask= (c->range - c->low)>>31; 412 lps_mask= (c->range - c->low)>>31;
412 413
413 c->low -= c->range & lps_mask; 414 c->low -= c->range & lps_mask;