aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h263.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-06-25 14:11:44 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-06-25 14:11:44 +0000
commit0ff93477be92f76608d816361bb5efe35d663ae1 (patch)
tree52003029142fab2a51e2260a6d36187f8ffd6632 /libavcodec/h263.c
parent4c99f2cdbed8bb7e6c40cf9a057aa6569d6a33eb (diff)
downloadffmpeg-0ff93477be92f76608d816361bb5efe35d663ae1.tar.gz
optimization
Originally committed as revision 3249 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h263.c')
-rw-r--r--libavcodec/h263.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index b89119004d..8c26634de4 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -1630,30 +1630,12 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
bit_size = f_code - 1;
range = 1 << bit_size;
/* modulo encoding */
- l = range * 32;
-#if 1
- val+= l;
- val&= 2*l-1;
- val-= l;
+ l= INT_BIT - 6 - bit_size;
+ val = (val<<l)>>l;
sign = val>>31;
val= (val^sign)-sign;
sign&=1;
-#else
- if (val < -l) {
- val += 2*l;
- } else if (val >= l) {
- val -= 2*l;
- }
-
- assert(val>=-l && val<l);
- if (val >= 0) {
- sign = 0;
- } else {
- val = -val;
- sign = 1;
- }
-#endif
val--;
code = (val >> bit_size) + 1;
bits = val & (range - 1);
@@ -4375,8 +4357,8 @@ static int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
/* modulo decoding */
if (!s->h263_long_vectors) {
- l = 1 << (f_code + 4);
- val = ((val + l)&(l*2-1)) - l;
+ l = INT_BIT - 5 - f_code;
+ val = (val<<l)>>l;
} else {
/* horrible h263 long vector mode */
if (pred < -31 && val < -63)