summaryrefslogtreecommitdiff
path: root/libavcodec/ituh263dec.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-08-31 20:30:04 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2014-09-01 19:41:20 +0200
commit2a00812d82c5f8a76328597c8b5ee1d4cd9c49dc (patch)
tree1a22cf6431c9c5d07463bfe50578e13033ec1c55 /libavcodec/ituh263dec.c
parent8d6ec6118698efaa662044a538e3dbc790d2f46b (diff)
h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.
3646 -> 3597 decicycles in inner loop when decoding vsynth1-flv. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/ituh263dec.c')
-rw-r--r--libavcodec/ituh263dec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index ad5a3cbc49..168ac7489f 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -481,6 +481,7 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block,
retry:
{
OPEN_READER(re, &s->gb);
+ i--; // offset by -1 to allow direct indexing of scan_table
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
@@ -529,9 +530,9 @@ retry:
SKIP_COUNTER(re, &s->gb, 1);
}
i += run;
- if (i > 64){
- // redo update without last flag
- i = i - run + ((run-1)&63);
+ if (i >= 64){
+ // redo update without last flag, revert -1 offset
+ i = i - run + ((run-1)&63) + 1;
if (i < 64) {
// only last marker, no overrun
block[scan_table[i]] = level;
@@ -549,7 +550,7 @@ retry:
av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
return -1;
}
- j = scan_table[i-1];
+ j = scan_table[i];
block[j] = level;
}
CLOSE_READER(re, &s->gb);