From 85aa3a8d381ac980b49699d49234e4df051813e5 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Mon, 9 Jul 2007 10:53:56 +0000 Subject: Code reorganisation - move the vlc functions back to common.c/common.h (where they originally were in the ffmpeg source). This code is still identical to the ffmpeg source. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13830 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libwma/common.h | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'apps/codecs/libwma/common.h') diff --git a/apps/codecs/libwma/common.h b/apps/codecs/libwma/common.h index b627bfb710..0efecf0571 100644 --- a/apps/codecs/libwma/common.h +++ b/apps/codecs/libwma/common.h @@ -22,6 +22,14 @@ typedef struct GetBitContext { static inline int get_bits_count(GetBitContext *s); +#define VLC_TYPE int16_t + +typedef struct VLC { + int bits; + VLC_TYPE (*table)[2]; ///< code, bits + int table_size, table_allocated; +} VLC; + /* used to avoid missaligned exceptions on some archs (alpha, ...) */ static inline uint32_t unaligned32(const void *v) { struct Unaligned { @@ -191,6 +199,59 @@ void init_get_bits(GetBitContext *s, int check_marker(GetBitContext *s, const char *msg); void align_get_bits(GetBitContext *s); +int init_vlc(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size); + +#define GET_VLC(code, name, gb, table, bits, max_depth)\ +{\ + int n, index, nb_bits;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + code = table[index][0];\ + n = table[index][1];\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + if(max_depth > 2 && n < 0){\ + LAST_SKIP_BITS(name, gb, nb_bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + }\ + }\ + SKIP_BITS(name, gb, n)\ +} + + +// deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly +static inline int get_vlc(GetBitContext *s, VLC *vlc) +{ + int code; + VLC_TYPE (*table)[2]= vlc->table; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, vlc->bits, 3) + + CLOSE_READER(re, s) + return code; +} + + + //#define TRACE -- cgit v1.2.3