[FFmpeg-cvslog] avcodec/mpeg12dec: Redesign index checks for mpeg2_fast_decode_block_intra

Michael Niedermayer git at videolan.org
Sun Jan 26 03:18:11 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jan 26 02:53:17 2014 +0100| [6a92598e149bcc2b5ec0a6c0cd940ef19b9ae86f] | committer: Michael Niedermayer

avcodec/mpeg12dec: Redesign index checks for mpeg2_fast_decode_block_intra

This fixes the speed regression from 20626f53e9f41cb3db82329ed3db7d773cfa3a8f
and still checks sufficiently to prevent out of allocated memory accesses
due to the index

Before:
1681 decicycles in mpeg2_fast_decode_block_intra, 4194238 runs, 66 skips
After:
1658 decicycles in mpeg2_fast_decode_block_intra, 4194248 runs, 56 skips

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a92598e149bcc2b5ec0a6c0cd940ef19b9ae86f
---

 libavcodec/mpeg12dec.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 2d6bada..f1899e0 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -628,11 +628,10 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *bloc
             UPDATE_CACHE(re, &s->gb);
             GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
 
-            if (level >= 64) {
+            if (level >= 64 || i > 63) {
                 break;
             } else if (level != 0) {
                 i += run;
-                check_scantable_index(s, i);
                 j  = scantable[i];
                 level = (level * qscale * quant_matrix[j]) >> 4;
                 level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
@@ -643,7 +642,6 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, int16_t *bloc
                 UPDATE_CACHE(re, &s->gb);
                 level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
                 i += run;
-                check_scantable_index(s, i);
                 j  = scantable[i];
                 if (level < 0) {
                     level = (-level * qscale * quant_matrix[j]) >> 4;



More information about the ffmpeg-cvslog mailing list