changeset 12032:572c81b3be19 libavcodec

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.
author darkshikari
date Wed, 30 Jun 2010 23:18:47 +0000
parents 5578dcdf030c
children 5de2b84a1fc3
files vp56.h
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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;