[FFmpeg-cvslog] vble: use LUT for vble_read_reverse_unary()

Michael Niedermayer git at videolan.org
Sat Nov 12 03:23:42 CET 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Nov 12 01:40:37 2011 +0100| [35fd7b2968834c5994bfd2a93edfbf0dea5e667e] | committer: Michael Niedermayer

vble: use LUT for vble_read_reverse_unary()
slightly faster

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

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

 libavcodec/vble.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index b758e23..5f78e6a 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -40,11 +40,21 @@ typedef struct {
 
 static uint8_t vble_read_reverse_unary(GetBitContext *gb)
 {
+    static const uint8_t LUT[256] = {
+        8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+        5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
+    };
     /* At most we need to read 9 bits total to get indices up to 8 */
     int val = show_bits(gb, 8);
 
     if (val) {
-        val = 7 - av_log2_16bit(av_reverse[val]);
+        val = LUT[val];
         skip_bits(gb, val + 1);
         return val;
     } else {



More information about the ffmpeg-cvslog mailing list