diff options
Diffstat (limited to 'apps/codecs/libwma/common.h')
-rw-r--r-- | apps/codecs/libwma/common.h | 61 |
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 | ||
23 | static inline int get_bits_count(GetBitContext *s); | 23 | static inline int get_bits_count(GetBitContext *s); |
24 | 24 | ||
25 | #define VLC_TYPE int16_t | ||
26 | |||
27 | typedef 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, ...) */ |
26 | static inline uint32_t unaligned32(const void *v) { | 34 | static 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 | ||
192 | int check_marker(GetBitContext *s, const char *msg); | 200 | int check_marker(GetBitContext *s, const char *msg); |
193 | void align_get_bits(GetBitContext *s); | 201 | void align_get_bits(GetBitContext *s); |
202 | int 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 | ||
239 | static 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 | ||