Mercurial > libavcodec.hg
comparison cabac.h @ 4002:ec426fa57dfe libavcodec
adds some useful comments after some of the #else, #elseif,
#endif preprocessor directives to make it clearer which code
block depends on which #define xx
author | gpoirier |
---|---|
date | Thu, 12 Oct 2006 07:51:18 +0000 |
parents | 34fdffe98bd0 |
children | b636f3d59283 |
comparison
equal
deleted
inserted
replaced
4001:34fdffe98bd0 | 4002:ec426fa57dfe |
---|---|
447 :"=&a"(bit) //FIXME this is fragile gcc either runs out of registers or misscompiles it (for example if "+a"(bit) or "+m"(*state) is used | 447 :"=&a"(bit) //FIXME this is fragile gcc either runs out of registers or misscompiles it (for example if "+a"(bit) or "+m"(*state) is used |
448 :"r"(state), "r"(c) | 448 :"r"(state), "r"(c) |
449 : "%ecx", "%ebx", "%edx", "%esi" | 449 : "%ecx", "%ebx", "%edx", "%esi" |
450 ); | 450 ); |
451 bit&=1; | 451 bit&=1; |
452 #else | 452 #else /* BRANCHLESS_CABAC_DECODER */ |
453 asm volatile( | 453 asm volatile( |
454 "movzbl (%1), %%eax \n\t" | 454 "movzbl (%1), %%eax \n\t" |
455 "movl "RANGE "(%2), %%ebx \n\t" | 455 "movl "RANGE "(%2), %%ebx \n\t" |
456 "movl "RANGE "(%2), %%edx \n\t" | 456 "movl "RANGE "(%2), %%edx \n\t" |
457 "shrl $23, %%ebx \n\t" | 457 "shrl $23, %%ebx \n\t" |
465 "cmova %%edx, %%esi \n\t" | 465 "cmova %%edx, %%esi \n\t" |
466 "sbbl %%ecx, %%ecx \n\t" | 466 "sbbl %%ecx, %%ecx \n\t" |
467 "andl %%ecx, %%edx \n\t" | 467 "andl %%ecx, %%edx \n\t" |
468 "subl %%edx, %%ebx \n\t" | 468 "subl %%edx, %%ebx \n\t" |
469 "xorl %%ecx, %%eax \n\t" | 469 "xorl %%ecx, %%eax \n\t" |
470 #else | 470 #else /* CMOV_IS_FAST */ |
471 "movl %%edx, %%ecx \n\t" | 471 "movl %%edx, %%ecx \n\t" |
472 "subl %%ebx, %%edx \n\t" | 472 "subl %%ebx, %%edx \n\t" |
473 "sarl $31, %%edx \n\t" //lps_mask | 473 "sarl $31, %%edx \n\t" //lps_mask |
474 "subl %%ecx, %%esi \n\t" //RangeLPS - range | 474 "subl %%ecx, %%esi \n\t" //RangeLPS - range |
475 "andl %%edx, %%esi \n\t" //(RangeLPS - range)&lps_mask | 475 "andl %%edx, %%esi \n\t" //(RangeLPS - range)&lps_mask |
476 "addl %%ecx, %%esi \n\t" //new range | 476 "addl %%ecx, %%esi \n\t" //new range |
477 "andl %%edx, %%ecx \n\t" | 477 "andl %%edx, %%ecx \n\t" |
478 "subl %%ecx, %%ebx \n\t" | 478 "subl %%ecx, %%ebx \n\t" |
479 "xorl %%edx, %%eax \n\t" | 479 "xorl %%edx, %%eax \n\t" |
480 #endif | 480 #endif /* CMOV_IS_FAST */ |
481 | 481 |
482 //eax:state ebx:low edx:mask esi:range | 482 //eax:state ebx:low edx:mask esi:range |
483 "movzbl "MANGLE(ff_h264_mps_state)"(%%eax), %%ecx \n\t" | 483 "movzbl "MANGLE(ff_h264_mps_state)"(%%eax), %%ecx \n\t" |
484 "movb %%cl, (%1) \n\t" | 484 "movb %%cl, (%1) \n\t" |
485 | 485 |
517 :"=&a"(bit) | 517 :"=&a"(bit) |
518 :"r"(state), "r"(c) | 518 :"r"(state), "r"(c) |
519 : "%ecx", "%ebx", "%edx", "%esi" | 519 : "%ecx", "%ebx", "%edx", "%esi" |
520 ); | 520 ); |
521 bit&=1; | 521 bit&=1; |
522 #endif | 522 #endif /* BRANCHLESS_CABAC_DECODER */ |
523 #else | 523 #else /* ARCH_X86 */ |
524 int s = *state; | 524 int s = *state; |
525 int RangeLPS= ff_h264_lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); | 525 int RangeLPS= ff_h264_lps_range[s][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1); |
526 int bit, lps_mask attribute_unused; | 526 int bit, lps_mask attribute_unused; |
527 | 527 |
528 c->range -= RangeLPS; | 528 c->range -= RangeLPS; |
541 | 541 |
542 if(!(c->low & 0xFFFF)){ | 542 if(!(c->low & 0xFFFF)){ |
543 refill2(c); | 543 refill2(c); |
544 } | 544 } |
545 } | 545 } |
546 #else | 546 #else /* BRANCHLESS_CABAC_DECODER */ |
547 lps_mask= (c->range - c->low)>>31; | 547 lps_mask= (c->range - c->low)>>31; |
548 | 548 |
549 c->low -= c->range & lps_mask; | 549 c->low -= c->range & lps_mask; |
550 c->range += (RangeLPS - c->range) & lps_mask; | 550 c->range += (RangeLPS - c->range) & lps_mask; |
551 | 551 |
556 lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+3)]; | 556 lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+3)]; |
557 c->range<<= lps_mask; | 557 c->range<<= lps_mask; |
558 c->low <<= lps_mask; | 558 c->low <<= lps_mask; |
559 if(!(c->low & CABAC_MASK)) | 559 if(!(c->low & CABAC_MASK)) |
560 refill2(c); | 560 refill2(c); |
561 #endif | 561 #endif /* BRANCHLESS_CABAC_DECODER */ |
562 #endif | 562 #endif /* ARCH_X86 */ |
563 return bit; | 563 return bit; |
564 } | 564 } |
565 | 565 |
566 static int get_cabac_bypass(CABACContext *c){ | 566 static int get_cabac_bypass(CABACContext *c){ |
567 c->low += c->low; | 567 c->low += c->low; |