[FFmpeg-cvslog] h261dec: Optimize new RL_VLC based decoding.

Reimar Döffinger git at videolan.org
Sun Aug 31 20:17:47 CEST 2014


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sun Aug 31 15:41:13 2014 +0200| [c0d32686ddc1184e57b21802838d4654f2fd5389] | committer: Reimar Döffinger

h261dec: Optimize new RL_VLC based decoding.

Together with the switch to RL_VLC this results in about
10% speedup for this inner loop.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

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

 libavcodec/h261dec.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 5f0eb59..f286d23 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -318,27 +318,25 @@ static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
             /* The remaining combinations of (run, level) are encoded with a
              * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
              * level. */
-            run   = SHOW_UBITS(re, &s->gb, 6);
+            run   = SHOW_UBITS(re, &s->gb, 6) + 1;
             SKIP_CACHE(re, &s->gb, 6);
             level = SHOW_SBITS(re, &s->gb, 8);
             SKIP_COUNTER(re, &s->gb, 6 + 8);
         } else if (level == 0) {
             break;
         } else {
-            run--;
             if (SHOW_UBITS(re, &s->gb, 1))
                 level = -level;
             SKIP_COUNTER(re, &s->gb, 1);
         }
         i += run;
-        if (i >= 64) {
+        if (i > 64) {
             av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
                    s->mb_x, s->mb_y);
             return -1;
         }
-        j        = scan_table[i];
+        j        = scan_table[i-1];
         block[j] = level;
-        i++;
     }
     CLOSE_READER(re, &s->gb);
     }



More information about the ffmpeg-cvslog mailing list