comparison cabac.h @ 8590:7a463923ecd1 libavcodec

Change semantic of CONFIG_*, HAVE_* and ARCH_*. They are now always defined to either 0 or 1.
author aurel
date Tue, 13 Jan 2009 23:44:16 +0000
parents eebc7209c47f
children e9d9d946f213
comparison
equal deleted inserted replaced
8589:a29b5b5c3c9d 8590:7a463923ecd1
268 #endif 268 #endif
269 c->low -= CABAC_MASK; 269 c->low -= CABAC_MASK;
270 c->bytestream+= CABAC_BITS/8; 270 c->bytestream+= CABAC_BITS/8;
271 } 271 }
272 272
273 #if ! ( defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) ) 273 #if ! ( ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) )
274 static void refill2(CABACContext *c){ 274 static void refill2(CABACContext *c){
275 int i, x; 275 int i, x;
276 276
277 x= c->low ^ (c->low-1); 277 x= c->low ^ (c->low-1);
278 i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)]; 278 i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
370 370
371 static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ 371 static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
372 //FIXME gcc generates duplicate load/stores for c->low and c->range 372 //FIXME gcc generates duplicate load/stores for c->low and c->range
373 #define LOW "0" 373 #define LOW "0"
374 #define RANGE "4" 374 #define RANGE "4"
375 #ifdef ARCH_X86_64 375 #if ARCH_X86_64
376 #define BYTESTART "16" 376 #define BYTESTART "16"
377 #define BYTE "24" 377 #define BYTE "24"
378 #define BYTEEND "32" 378 #define BYTEEND "32"
379 #else 379 #else
380 #define BYTESTART "12" 380 #define BYTESTART "12"
381 #define BYTE "16" 381 #define BYTE "16"
382 #define BYTEEND "20" 382 #define BYTEEND "20"
383 #endif 383 #endif
384 #if defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) 384 #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS)
385 int bit; 385 int bit;
386 386
387 #ifndef BRANCHLESS_CABAC_DECODER 387 #ifndef BRANCHLESS_CABAC_DECODER
388 __asm__ volatile( 388 __asm__ volatile(
389 "movzbl (%1), %0 \n\t" 389 "movzbl (%1), %0 \n\t"
465 ); 465 );
466 bit&=1; 466 bit&=1;
467 #else /* BRANCHLESS_CABAC_DECODER */ 467 #else /* BRANCHLESS_CABAC_DECODER */
468 468
469 469
470 #if defined HAVE_FAST_CMOV 470 #if HAVE_FAST_CMOV
471 #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ 471 #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
472 "mov "tmp" , %%ecx \n\t"\ 472 "mov "tmp" , %%ecx \n\t"\
473 "shl $17 , "tmp" \n\t"\ 473 "shl $17 , "tmp" \n\t"\
474 "cmp "low" , "tmp" \n\t"\ 474 "cmp "low" , "tmp" \n\t"\
475 "cmova %%ecx , "range" \n\t"\ 475 "cmova %%ecx , "range" \n\t"\
535 :"r"(state), "r"(c) 535 :"r"(state), "r"(c)
536 : "%"REG_c, "%ebx", "%edx", "%esi", "memory" 536 : "%"REG_c, "%ebx", "%edx", "%esi", "memory"
537 ); 537 );
538 bit&=1; 538 bit&=1;
539 #endif /* BRANCHLESS_CABAC_DECODER */ 539 #endif /* BRANCHLESS_CABAC_DECODER */
540 #else /* defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) */ 540 #else /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */
541 int s = *state; 541 int s = *state;
542 int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s]; 542 int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s];
543 int bit, lps_mask av_unused; 543 int bit, lps_mask av_unused;
544 544
545 c->range -= RangeLPS; 545 c->range -= RangeLPS;
574 c->range<<= lps_mask; 574 c->range<<= lps_mask;
575 c->low <<= lps_mask; 575 c->low <<= lps_mask;
576 if(!(c->low & CABAC_MASK)) 576 if(!(c->low & CABAC_MASK))
577 refill2(c); 577 refill2(c);
578 #endif /* BRANCHLESS_CABAC_DECODER */ 578 #endif /* BRANCHLESS_CABAC_DECODER */
579 #endif /* defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) */ 579 #endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */
580 return bit; 580 return bit;
581 } 581 }
582 582
583 static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){ 583 static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){
584 return get_cabac_inline(c,state); 584 return get_cabac_inline(c,state);
635 #endif 635 #endif
636 } 636 }
637 637
638 638
639 static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ 639 static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
640 #if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__)) 640 #if ARCH_X86 && !(defined(PIC) && defined(__GNUC__))
641 __asm__ volatile( 641 __asm__ volatile(
642 "movl "RANGE "(%1), %%ebx \n\t" 642 "movl "RANGE "(%1), %%ebx \n\t"
643 "movl "LOW "(%1), %%eax \n\t" 643 "movl "LOW "(%1), %%eax \n\t"
644 "shl $17, %%ebx \n\t" 644 "shl $17, %%ebx \n\t"
645 "add %%eax, %%eax \n\t" 645 "add %%eax, %%eax \n\t"