summaryrefslogtreecommitdiff
path: root/apps/codecs/libwma/common.h
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-07-09 10:53:56 +0000
committerDave Chapman <dave@dchapman.com>2007-07-09 10:53:56 +0000
commit85aa3a8d381ac980b49699d49234e4df051813e5 (patch)
treeb2d3a06b6e26bdd84882e9e81c0be12b71d0fc68 /apps/codecs/libwma/common.h
parent2e6723bcd27a8c6392004a9e37c0f3a2c73b5893 (diff)
downloadrockbox-85aa3a8d381ac980b49699d49234e4df051813e5.tar.gz
rockbox-85aa3a8d381ac980b49699d49234e4df051813e5.zip
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
Diffstat (limited to 'apps/codecs/libwma/common.h')
-rw-r--r--apps/codecs/libwma/common.h61
1 files changed, 61 insertions, 0 deletions
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 {
22 22
23static inline int get_bits_count(GetBitContext *s); 23static inline int get_bits_count(GetBitContext *s);
24 24
25#define VLC_TYPE int16_t
26
27typedef struct VLC {
28 int bits;
29 VLC_TYPE (*table)[2]; ///< code, bits
30 int table_size, table_allocated;
31} VLC;
32
25/* used to avoid missaligned exceptions on some archs (alpha, ...) */ 33/* used to avoid missaligned exceptions on some archs (alpha, ...) */
26static inline uint32_t unaligned32(const void *v) { 34static inline uint32_t unaligned32(const void *v) {
27 struct Unaligned { 35 struct Unaligned {
@@ -191,6 +199,59 @@ void init_get_bits(GetBitContext *s,
191 199
192int check_marker(GetBitContext *s, const char *msg); 200int check_marker(GetBitContext *s, const char *msg);
193void align_get_bits(GetBitContext *s); 201void align_get_bits(GetBitContext *s);
202int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
203 const void *bits, int bits_wrap, int bits_size,
204 const void *codes, int codes_wrap, int codes_size);
205
206#define GET_VLC(code, name, gb, table, bits, max_depth)\
207{\
208 int n, index, nb_bits;\
209\
210 index= SHOW_UBITS(name, gb, bits);\
211 code = table[index][0];\
212 n = table[index][1];\
213\
214 if(max_depth > 1 && n < 0){\
215 LAST_SKIP_BITS(name, gb, bits)\
216 UPDATE_CACHE(name, gb)\
217\
218 nb_bits = -n;\
219\
220 index= SHOW_UBITS(name, gb, nb_bits) + code;\
221 code = table[index][0];\
222 n = table[index][1];\
223 if(max_depth > 2 && n < 0){\
224 LAST_SKIP_BITS(name, gb, nb_bits)\
225 UPDATE_CACHE(name, gb)\
226\
227 nb_bits = -n;\
228\
229 index= SHOW_UBITS(name, gb, nb_bits) + code;\
230 code = table[index][0];\
231 n = table[index][1];\
232 }\
233 }\
234 SKIP_BITS(name, gb, n)\
235}
236
237
238// deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly
239static inline int get_vlc(GetBitContext *s, VLC *vlc)
240{
241 int code;
242 VLC_TYPE (*table)[2]= vlc->table;
243
244 OPEN_READER(re, s)
245 UPDATE_CACHE(re, s)
246
247 GET_VLC(code, re, s, table, vlc->bits, 3)
248
249 CLOSE_READER(re, s)
250 return code;
251}
252
253
254
194 255
195//#define TRACE 256//#define TRACE
196 257