diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2002-09-27 15:38:54 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-09-27 15:38:54 +0000 |
commit | a9c6830605ed6aacb6f49fcdc00df2d7bb6bea02 (patch) | |
tree | 9133eb97902068e2e9283f688dd20efd1edecf6a /libavcodec | |
parent | 202ef8b8196a107df242b29ebee8cbbd72549057 (diff) | |
download | ffmpeg-a9c6830605ed6aacb6f49fcdc00df2d7bb6bea02.tar.gz |
minor optimization of h263_encode_motion()
Originally committed as revision 976 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h263.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 6a59906a08..b8bfc85e12 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -1079,7 +1079,7 @@ INT16 *h263_pred_motion(MpegEncContext * s, int block, 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) { /* zero vector */ @@ -1090,12 +1090,20 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code) range = 1 << bit_size; /* modulo encoding */ 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) { - val += m; + val += 2*l; } else if (val >= l) { - val -= m; + val -= 2*l; } + assert(val>=-l && val<l); if (val >= 0) { @@ -1104,6 +1112,7 @@ static void h263_encode_motion(MpegEncContext * s, int val, int f_code) val = -val; sign = 1; } +#endif val--; code = (val >> bit_size) + 1; bits = val & (range - 1); |