[FFmpeg-cvslog] avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codes
Andreas Rheinhardt
git at videolan.org
Sat Oct 10 05:46:44 EEST 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Oct 8 21:45:21 2020 +0200| [fe9bc1cc45e2bebba1efa7b9a20b0d66679bf2d5] | committer: Andreas Rheinhardt
avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codes
Said escape code is only six bits long, so that one has at least 25 - 6
bits in the bitstream reader's cache after reading it; therefore the
whole following 18 bits (containing the actual code) are already in the
bitstream reader's cache, making it unnecessary to reload the cache.
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe9bc1cc45e2bebba1efa7b9a20b0d66679bf2d5
---
libavcodec/mpeg12dec.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 2494226aa3..1cccfd1742 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -526,10 +526,9 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6) + 1;
- LAST_SKIP_BITS(re, &s->gb, 6);
- UPDATE_CACHE(re, &s->gb);
+ SKIP_BITS(re, &s->gb, 6);
level = SHOW_SBITS(re, &s->gb, 12);
- SKIP_BITS(re, &s->gb, 12);
+ LAST_SKIP_BITS(re, &s->gb, 12);
i += run;
if (i > MAX_INDEX)
break;
@@ -610,10 +609,9 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
} else {
/* escape */
run = SHOW_UBITS(re, &s->gb, 6) + 1;
- LAST_SKIP_BITS(re, &s->gb, 6);
- UPDATE_CACHE(re, &s->gb);
+ SKIP_BITS(re, &s->gb, 6);
level = SHOW_SBITS(re, &s->gb, 12);
- SKIP_BITS(re, &s->gb, 12);
+ LAST_SKIP_BITS(re, &s->gb, 12);
i += run;
j = scantable[i];
if (level < 0) {
More information about the ffmpeg-cvslog
mailing list