Optimize sign handling in get_symbol().
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 24 Apr 2009 00:26:49 +0000 (00:26 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 24 Apr 2009 00:26:49 +0000 (00:26 +0000)
Originally committed as revision 18672 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/ffv1.c
libavcodec/snow.c

index 9eef531..62b12ed 100644 (file)
@@ -258,10 +258,8 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
             a += a + get_rac(c, state+22 + i); //22..31
         }
 
-        if(is_signed && get_rac(c, state+11 + e)) //11..21
-            return -a;
-        else
-            return a;
+        e= -(is_signed && get_rac(c, state+11 + e)); //11..21
+        return (a^e)-e;
     }
 }
 
index 5d9577b..995c1a2 100644 (file)
@@ -665,10 +665,8 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
             a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
         }
 
-        if(is_signed && get_rac(c, state+11 + FFMIN(e,10))) //11..21
-            return -a;
-        else
-            return a;
+        e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
+        return (a^e)-e;
     }
 }