# HG changeset patch # User darkshikari # Date 1277939927 0 # Node ID 572c81b3be1932ae39b9e5dda2adab2ce8ea9c9a # Parent 5578dcdf030c4f22b85db89030581b8ece875f41 CMOV-ify vp56 arithcoder This incantation causes gcc 4.3 to generate cmov on x86, a vastly better option than a completely unpredictable branch. Hopefully this carries over to newer versions and other CPUs with conditionals. ~5 cycles saved per call on a Core i7. diff -r 5578dcdf030c -r 572c81b3be19 vp56.h --- a/vp56.h Wed Jun 30 23:15:25 2010 +0000 +++ b/vp56.h Wed Jun 30 23:18:47 2010 +0000 @@ -199,12 +199,8 @@ int bit = c->code_word >= low_shift; int shift; - if (bit) { - c->high -= low; - c->code_word -= low_shift; - } else { - c->high = low; - } + c->high = bit ? c->high - low : low; + c->code_word = bit ? c->code_word - low_shift : c->code_word; /* normalize */ shift = ff_h264_norm_shift[c->high] - 1;