From 35fd7b2968834c5994bfd2a93edfbf0dea5e667e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 12 Nov 2011 01:40:37 +0100 Subject: [PATCH] vble: use LUT for vble_read_reverse_unary() slightly faster Signed-off-by: Michael Niedermayer --- libavcodec/vble.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavcodec/vble.c b/libavcodec/vble.c index b758e23d61..5f78e6a198 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 {