Commit a9c68306 authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

minor optimization of h263_encode_motion()

Originally committed as revision 976 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 202ef8b8
...@@ -1079,7 +1079,7 @@ INT16 *h263_pred_motion(MpegEncContext * s, int block, ...@@ -1079,7 +1079,7 @@ INT16 *h263_pred_motion(MpegEncContext * s, int block,
static void h263_encode_motion(MpegEncContext * s, int val, int f_code) static void h263_encode_motion(MpegEncContext * s, int val, int f_code)
{ {
int range, l, m, bit_size, sign, code, bits; int range, l, bit_size, sign, code, bits;
if (val == 0) { if (val == 0) {
/* zero vector */ /* zero vector */
...@@ -1090,12 +1090,20 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code) ...@@ -1090,12 +1090,20 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code)
range = 1 << bit_size; range = 1 << bit_size;
/* modulo encoding */ /* modulo encoding */
l = range * 32; l = range * 32;
m = 2 * l; #if 1
val+= l;
val&= 2*l-1;
val-= l;
sign = val>>31;
val= (val^sign)-sign;
sign&=1;
#else
if (val < -l) { if (val < -l) {
val += m; val += 2*l;
} else if (val >= l) { } else if (val >= l) {
val -= m; val -= 2*l;
} }
assert(val>=-l && val<l); assert(val>=-l && val<l);
if (val >= 0) { if (val >= 0) {
...@@ -1104,6 +1112,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code) ...@@ -1104,6 +1112,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code)
val = -val; val = -val;
sign = 1; sign = 1;
} }
#endif
val--; val--;
code = (val >> bit_size) + 1; code = (val >> bit_size) + 1;
bits = val & (range - 1); bits = val & (range - 1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment