summaryrefslogtreecommitdiff
path: root/libavcodec/mjpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-03-31 16:50:43 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-03-31 16:50:43 +0000
commitac2549b583f88d488326ad65b3d2f4539b1ae732 (patch)
treec6bccfd06726acae26a227e492d33e38746a5bcc /libavcodec/mjpeg.c
parent9296d45d29d0b747d54c824a7073cfbcb4cc7b96 (diff)
avoid hard to predict branch (idea by arpi)
Originally committed as revision 5252 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mjpeg.c')
-rw-r--r--libavcodec/mjpeg.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index 7a86482874..dbcbaed61d 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -1288,11 +1288,10 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
code &= 0xf;
UPDATE_CACHE(re, &s->gb)
-
- if ((int32_t)GET_CACHE(re,&s->gb)<0) { //MSB=1
- level = NEG_USR32( GET_CACHE(re,&s->gb),code);
- } else {
- level = - NEG_USR32(~GET_CACHE(re,&s->gb),code);
+ {
+ int cache=GET_CACHE(re,gb);
+ int sign=(~cache)>>31;
+ level = (NEG_USR32(sign ^ cache,code) ^ sign) + (sign&1) ;
}
LAST_SKIP_BITS(re, &s->gb, code)