aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg12.c
diff options
context:
space:
mode:
authorBERO <bero@geocities.co.jp>2003-05-14 01:08:02 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-05-14 01:08:02 +0000
commit05858889b2261fc3a98c19e25219b435ea0f6154 (patch)
tree2f1281f4b777f720da8423fac5665cfa9ba19bca /libavcodec/mpeg12.c
parentd8e00c099731b8499a8c377469ac5796f5bd186c (diff)
downloadffmpeg-05858889b2261fc3a98c19e25219b435ea0f6154.tar.gz
decode motion & modulo optimize patch by (BERO <bero at geocities dot co dot jp>)
Originally committed as revision 1872 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r--libavcodec/mpeg12.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 32d3057831..2186b5799e 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1176,7 +1176,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
/* as h263, but only 17 codes */
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
{
- int code, sign, val, m, l, shift;
+ int code, sign, val, l, shift;
code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
if (code == 0) {
@@ -1188,22 +1188,19 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
sign = get_bits1(&s->gb);
shift = fcode - 1;
- val = (code - 1) << shift;
- if (shift > 0)
+ val = code;
+ if (shift) {
+ val = (val - 1) << shift;
val |= get_bits(&s->gb, shift);
- val++;
+ val++;
+ }
if (sign)
val = -val;
val += pred;
/* modulo decoding */
l = 1 << (shift+4);
- m = 2 * l;
- if (val < -l) {
- val += m;
- } else if (val >= l) {
- val -= m;
- }
+ val = ((val + l)&(l*2-1)) - l;
return val;
}