changeset 3239:d92263225a77 libavcodec

avoid hard to predict branch (idea by arpi)
author michael
date Fri, 31 Mar 2006 16:50:43 +0000
parents 21ba2e68ce03
children 5fab2409bf8d
files mjpeg.c
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mjpeg.c	Fri Mar 31 13:06:24 2006 +0000
+++ b/mjpeg.c	Fri Mar 31 16:50:43 2006 +0000
@@ -1288,11 +1288,10 @@
             code &= 0xf;
 
             UPDATE_CACHE(re, &s->gb)
-
-            if ((int32_t)GET_CACHE(re,&s->gb)<0) { //MSB=1
-                level =   NEG_USR32( GET_CACHE(re,&s->gb),code);
-            } else {
-                level = - NEG_USR32(~GET_CACHE(re,&s->gb),code);
+            {
+                int cache=GET_CACHE(re,gb);
+                int sign=(~cache)>>31;
+                level = (NEG_USR32(sign ^ cache,code) ^ sign) + (sign&1) ;
             }
 
             LAST_SKIP_BITS(re, &s->gb, code)