summaryrefslogtreecommitdiff
path: root/apps/codecs/libwmapro/get_bits.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwmapro/get_bits.h')
-rw-r--r--apps/codecs/libwmapro/get_bits.h692
1 files changed, 692 insertions, 0 deletions
diff --git a/apps/codecs/libwmapro/get_bits.h b/apps/codecs/libwmapro/get_bits.h
new file mode 100644
index 0000000000..ca84ea61c0
--- /dev/null
+++ b/apps/codecs/libwmapro/get_bits.h
@@ -0,0 +1,692 @@
1/*
2 * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavcodec/get_bits.h
23 * bitstream reader API header.
24 */
25
26#ifndef AVCODEC_GET_BITS_H
27#define AVCODEC_GET_BITS_H
28
29#include <stdint.h>
30#include <stdlib.h>
31#include <assert.h>
32#include "libavutil/bswap.h"
33#include "libavutil/common.h"
34#include "libavutil/intreadwrite.h"
35#include "libavutil/log.h"
36#include "mathops.h"
37
38#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER)
39# define ALT_BITSTREAM_READER
40#endif
41
42#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
43# if ARCH_ARM && !HAVE_FAST_UNALIGNED
44# define A32_BITSTREAM_READER
45# else
46# define ALT_BITSTREAM_READER
47//#define LIBMPEG2_BITSTREAM_READER
48//#define A32_BITSTREAM_READER
49# endif
50#endif
51
52/* bit input */
53/* buffer, buffer_end and size_in_bits must be present and used by every reader */
54typedef struct GetBitContext {
55 const uint8_t *buffer, *buffer_end;
56#ifdef ALT_BITSTREAM_READER
57 int index;
58#elif defined LIBMPEG2_BITSTREAM_READER
59 uint8_t *buffer_ptr;
60 uint32_t cache;
61 int bit_count;
62#elif defined A32_BITSTREAM_READER
63 uint32_t *buffer_ptr;
64 uint32_t cache0;
65 uint32_t cache1;
66 int bit_count;
67#endif
68 int size_in_bits;
69} GetBitContext;
70
71#define VLC_TYPE int16_t
72
73typedef struct VLC {
74 int bits;
75 VLC_TYPE (*table)[2]; ///< code, bits
76 int table_size, table_allocated;
77} VLC;
78
79typedef struct RL_VLC_ELEM {
80 int16_t level;
81 int8_t len;
82 uint8_t run;
83} RL_VLC_ELEM;
84
85/* Bitstream reader API docs:
86name
87 arbitrary name which is used as prefix for the internal variables
88
89gb
90 getbitcontext
91
92OPEN_READER(name, gb)
93 loads gb into local variables
94
95CLOSE_READER(name, gb)
96 stores local vars in gb
97
98UPDATE_CACHE(name, gb)
99 refills the internal cache from the bitstream
100 after this call at least MIN_CACHE_BITS will be available,
101
102GET_CACHE(name, gb)
103 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
104
105SHOW_UBITS(name, gb, num)
106 will return the next num bits
107
108SHOW_SBITS(name, gb, num)
109 will return the next num bits and do sign extension
110
111SKIP_BITS(name, gb, num)
112 will skip over the next num bits
113 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
114
115SKIP_CACHE(name, gb, num)
116 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
117
118SKIP_COUNTER(name, gb, num)
119 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
120
121LAST_SKIP_CACHE(name, gb, num)
122 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
123
124LAST_SKIP_BITS(name, gb, num)
125 is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
126
127for examples see get_bits, show_bits, skip_bits, get_vlc
128*/
129
130#ifdef ALT_BITSTREAM_READER
131# define MIN_CACHE_BITS 25
132
133# define OPEN_READER(name, gb)\
134 unsigned int name##_index= (gb)->index;\
135 int name##_cache= 0;\
136
137# define CLOSE_READER(name, gb)\
138 (gb)->index= name##_index;\
139
140# ifdef ALT_BITSTREAM_READER_LE
141# define UPDATE_CACHE(name, gb)\
142 name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
143
144# define SKIP_CACHE(name, gb, num)\
145 name##_cache >>= (num);
146# else
147# define UPDATE_CACHE(name, gb)\
148 name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
149
150# define SKIP_CACHE(name, gb, num)\
151 name##_cache <<= (num);
152# endif
153
154// FIXME name?
155# define SKIP_COUNTER(name, gb, num)\
156 name##_index += (num);\
157
158# define SKIP_BITS(name, gb, num)\
159 {\
160 SKIP_CACHE(name, gb, num)\
161 SKIP_COUNTER(name, gb, num)\
162 }\
163
164# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
165# define LAST_SKIP_CACHE(name, gb, num) ;
166
167# ifdef ALT_BITSTREAM_READER_LE
168# define SHOW_UBITS(name, gb, num)\
169 zero_extend(name##_cache, num)
170
171# define SHOW_SBITS(name, gb, num)\
172 sign_extend(name##_cache, num)
173# else
174# define SHOW_UBITS(name, gb, num)\
175 NEG_USR32(name##_cache, num)
176
177# define SHOW_SBITS(name, gb, num)\
178 NEG_SSR32(name##_cache, num)
179# endif
180
181# define GET_CACHE(name, gb)\
182 ((uint32_t)name##_cache)
183
184static inline int get_bits_count(const GetBitContext *s){
185 return s->index;
186}
187
188static inline void skip_bits_long(GetBitContext *s, int n){
189 s->index += n;
190}
191
192#elif defined LIBMPEG2_BITSTREAM_READER
193//libmpeg2 like reader
194
195# define MIN_CACHE_BITS 17
196
197# define OPEN_READER(name, gb)\
198 int name##_bit_count=(gb)->bit_count;\
199 int name##_cache= (gb)->cache;\
200 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
201
202# define CLOSE_READER(name, gb)\
203 (gb)->bit_count= name##_bit_count;\
204 (gb)->cache= name##_cache;\
205 (gb)->buffer_ptr= name##_buffer_ptr;\
206
207# define UPDATE_CACHE(name, gb)\
208 if(name##_bit_count >= 0){\
209 name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \
210 name##_buffer_ptr+=2;\
211 name##_bit_count-= 16;\
212 }\
213
214# define SKIP_CACHE(name, gb, num)\
215 name##_cache <<= (num);\
216
217# define SKIP_COUNTER(name, gb, num)\
218 name##_bit_count += (num);\
219
220# define SKIP_BITS(name, gb, num)\
221 {\
222 SKIP_CACHE(name, gb, num)\
223 SKIP_COUNTER(name, gb, num)\
224 }\
225
226# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
227# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
228
229# define SHOW_UBITS(name, gb, num)\
230 NEG_USR32(name##_cache, num)
231
232# define SHOW_SBITS(name, gb, num)\
233 NEG_SSR32(name##_cache, num)
234
235# define GET_CACHE(name, gb)\
236 ((uint32_t)name##_cache)
237
238static inline int get_bits_count(const GetBitContext *s){
239 return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
240}
241
242static inline void skip_bits_long(GetBitContext *s, int n){
243 OPEN_READER(re, s)
244 re_bit_count += n;
245 re_buffer_ptr += 2*(re_bit_count>>4);
246 re_bit_count &= 15;
247 re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count);
248 UPDATE_CACHE(re, s)
249 CLOSE_READER(re, s)
250}
251
252#elif defined A32_BITSTREAM_READER
253
254# define MIN_CACHE_BITS 32
255
256# define OPEN_READER(name, gb)\
257 int name##_bit_count=(gb)->bit_count;\
258 uint32_t name##_cache0= (gb)->cache0;\
259 uint32_t name##_cache1= (gb)->cache1;\
260 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
261
262# define CLOSE_READER(name, gb)\
263 (gb)->bit_count= name##_bit_count;\
264 (gb)->cache0= name##_cache0;\
265 (gb)->cache1= name##_cache1;\
266 (gb)->buffer_ptr= name##_buffer_ptr;\
267
268# define UPDATE_CACHE(name, gb)\
269 if(name##_bit_count > 0){\
270 const uint32_t next= be2me_32( *name##_buffer_ptr );\
271 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
272 name##_cache1 |= next<<name##_bit_count;\
273 name##_buffer_ptr++;\
274 name##_bit_count-= 32;\
275 }\
276
277#if ARCH_X86
278# define SKIP_CACHE(name, gb, num)\
279 __asm__(\
280 "shldl %2, %1, %0 \n\t"\
281 "shll %2, %1 \n\t"\
282 : "+r" (name##_cache0), "+r" (name##_cache1)\
283 : "Ic" ((uint8_t)(num))\
284 );
285#else
286# define SKIP_CACHE(name, gb, num)\
287 name##_cache0 <<= (num);\
288 name##_cache0 |= NEG_USR32(name##_cache1,num);\
289 name##_cache1 <<= (num);
290#endif
291
292# define SKIP_COUNTER(name, gb, num)\
293 name##_bit_count += (num);\
294
295# define SKIP_BITS(name, gb, num)\
296 {\
297 SKIP_CACHE(name, gb, num)\
298 SKIP_COUNTER(name, gb, num)\
299 }\
300
301# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
302# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
303
304# define SHOW_UBITS(name, gb, num)\
305 NEG_USR32(name##_cache0, num)
306
307# define SHOW_SBITS(name, gb, num)\
308 NEG_SSR32(name##_cache0, num)
309
310# define GET_CACHE(name, gb)\
311 (name##_cache0)
312
313static inline int get_bits_count(const GetBitContext *s){
314 return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
315}
316
317static inline void skip_bits_long(GetBitContext *s, int n){
318 OPEN_READER(re, s)
319 re_bit_count += n;
320 re_buffer_ptr += re_bit_count>>5;
321 re_bit_count &= 31;
322 re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count;
323 re_cache1 = 0;
324 UPDATE_CACHE(re, s)
325 CLOSE_READER(re, s)
326}
327
328#endif
329
330/**
331 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
332 * if MSB not set it is negative
333 * @param n length in bits
334 * @author BERO
335 */
336static inline int get_xbits(GetBitContext *s, int n){
337 register int sign;
338 register int32_t cache;
339 OPEN_READER(re, s)
340 UPDATE_CACHE(re, s)
341 cache = GET_CACHE(re,s);
342 sign=(~cache)>>31;
343 LAST_SKIP_BITS(re, s, n)
344 CLOSE_READER(re, s)
345 return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
346}
347
348static inline int get_sbits(GetBitContext *s, int n){
349 register int tmp;
350 OPEN_READER(re, s)
351 UPDATE_CACHE(re, s)
352 tmp= SHOW_SBITS(re, s, n);
353 LAST_SKIP_BITS(re, s, n)
354 CLOSE_READER(re, s)
355 return tmp;
356}
357
358/**
359 * reads 1-17 bits.
360 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
361 */
362static inline unsigned int get_bits(GetBitContext *s, int n){
363 register int tmp;
364 OPEN_READER(re, s)
365 UPDATE_CACHE(re, s)
366 tmp= SHOW_UBITS(re, s, n);
367 LAST_SKIP_BITS(re, s, n)
368 CLOSE_READER(re, s)
369 return tmp;
370}
371
372/**
373 * shows 1-17 bits.
374 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
375 */
376static inline unsigned int show_bits(GetBitContext *s, int n){
377 register int tmp;
378 OPEN_READER(re, s)
379 UPDATE_CACHE(re, s)
380 tmp= SHOW_UBITS(re, s, n);
381// CLOSE_READER(re, s)
382 return tmp;
383}
384
385static inline void skip_bits(GetBitContext *s, int n){
386 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
387 OPEN_READER(re, s)
388 UPDATE_CACHE(re, s)
389 LAST_SKIP_BITS(re, s, n)
390 CLOSE_READER(re, s)
391}
392
393static inline unsigned int get_bits1(GetBitContext *s){
394#ifdef ALT_BITSTREAM_READER
395 unsigned int index= s->index;
396 uint8_t result= s->buffer[ index>>3 ];
397#ifdef ALT_BITSTREAM_READER_LE
398 result>>= (index&0x07);
399 result&= 1;
400#else
401 result<<= (index&0x07);
402 result>>= 8 - 1;
403#endif
404 index++;
405 s->index= index;
406
407 return result;
408#else
409 return get_bits(s, 1);
410#endif
411}
412
413static inline unsigned int show_bits1(GetBitContext *s){
414 return show_bits(s, 1);
415}
416
417static inline void skip_bits1(GetBitContext *s){
418 skip_bits(s, 1);
419}
420
421/**
422 * reads 0-32 bits.
423 */
424static inline unsigned int get_bits_long(GetBitContext *s, int n){
425 if(n<=MIN_CACHE_BITS) return get_bits(s, n);
426 else{
427#ifdef ALT_BITSTREAM_READER_LE
428 int ret= get_bits(s, 16);
429 return ret | (get_bits(s, n-16) << 16);
430#else
431 int ret= get_bits(s, 16) << (n-16);
432 return ret | get_bits(s, n-16);
433#endif
434 }
435}
436#if 0
437/* mt : switched those off */
438/**
439 * reads 0-32 bits as a signed integer.
440 */
441static inline int get_sbits_long(GetBitContext *s, int n) {
442 return sign_extend(get_bits_long(s, n), n);
443}
444#endif
445/**
446 * shows 0-32 bits.
447 */
448static inline unsigned int show_bits_long(GetBitContext *s, int n){
449 if(n<=MIN_CACHE_BITS) return show_bits(s, n);
450 else{
451 GetBitContext gb= *s;
452 return get_bits_long(&gb, n);
453 }
454}
455
456static inline int check_marker(GetBitContext *s, const char *msg)
457{
458 int bit= get_bits1(s);
459 if(!bit)
460 av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
461
462 return bit;
463}
464
465/**
466 * init GetBitContext.
467 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
468 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
469 * @param bit_size the size of the buffer in bits
470 *
471 * While GetBitContext stores the buffer size, for performance reasons you are
472 * responsible for checking for the buffer end yourself (take advantage of the padding)!
473 */
474static inline void init_get_bits(GetBitContext *s,
475 const uint8_t *buffer, int bit_size)
476{
477 int buffer_size= (bit_size+7)>>3;
478 if(buffer_size < 0 || bit_size < 0) {
479 buffer_size = bit_size = 0;
480 buffer = NULL;
481 }
482
483 s->buffer= buffer;
484 s->size_in_bits= bit_size;
485 s->buffer_end= buffer + buffer_size;
486#ifdef ALT_BITSTREAM_READER
487 s->index=0;
488#elif defined LIBMPEG2_BITSTREAM_READER
489 s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
490 s->bit_count = 16 + 8*((intptr_t)buffer&1);
491 skip_bits_long(s, 0);
492#elif defined A32_BITSTREAM_READER
493 s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
494 s->bit_count = 32 + 8*((intptr_t)buffer&3);
495 skip_bits_long(s, 0);
496#endif
497}
498
499static inline void align_get_bits(GetBitContext *s)
500{
501 int n= (-get_bits_count(s)) & 7;
502 if(n) skip_bits(s, n);
503}
504
505#define init_vlc(vlc, nb_bits, nb_codes,\
506 bits, bits_wrap, bits_size,\
507 codes, codes_wrap, codes_size,\
508 flags)\
509 init_vlc_sparse(vlc, nb_bits, nb_codes,\
510 bits, bits_wrap, bits_size,\
511 codes, codes_wrap, codes_size,\
512 NULL, 0, 0, flags)
513
514int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
515 const void *bits, int bits_wrap, int bits_size,
516 const void *codes, int codes_wrap, int codes_size,
517 const void *symbols, int symbols_wrap, int symbols_size,
518 int flags);
519#define INIT_VLC_LE 2
520#define INIT_VLC_USE_NEW_STATIC 4
521void free_vlc(VLC *vlc);
522
523#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\
524{\
525 static VLC_TYPE table[static_size][2];\
526 (vlc)->table= table;\
527 (vlc)->table_allocated= static_size;\
528 init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\
529}
530
531
532/**
533 *
534 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
535 * If the vlc code is invalid and max_depth>1, then the number of bits removed
536 * is undefined.
537 */
538#define GET_VLC(code, name, gb, table, bits, max_depth)\
539{\
540 int n, nb_bits;\
541 unsigned int index;\
542\
543 index= SHOW_UBITS(name, gb, bits);\
544 code = table[index][0];\
545 n = table[index][1];\
546\
547 if(max_depth > 1 && n < 0){\
548 LAST_SKIP_BITS(name, gb, bits)\
549 UPDATE_CACHE(name, gb)\
550\
551 nb_bits = -n;\
552\
553 index= SHOW_UBITS(name, gb, nb_bits) + code;\
554 code = table[index][0];\
555 n = table[index][1];\
556 if(max_depth > 2 && n < 0){\
557 LAST_SKIP_BITS(name, gb, nb_bits)\
558 UPDATE_CACHE(name, gb)\
559\
560 nb_bits = -n;\
561\
562 index= SHOW_UBITS(name, gb, nb_bits) + code;\
563 code = table[index][0];\
564 n = table[index][1];\
565 }\
566 }\
567 SKIP_BITS(name, gb, n)\
568}
569
570#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
571{\
572 int n, nb_bits;\
573 unsigned int index;\
574\
575 index= SHOW_UBITS(name, gb, bits);\
576 level = table[index].level;\
577 n = table[index].len;\
578\
579 if(max_depth > 1 && n < 0){\
580 SKIP_BITS(name, gb, bits)\
581 if(need_update){\
582 UPDATE_CACHE(name, gb)\
583 }\
584\
585 nb_bits = -n;\
586\
587 index= SHOW_UBITS(name, gb, nb_bits) + level;\
588 level = table[index].level;\
589 n = table[index].len;\
590 }\
591 run= table[index].run;\
592 SKIP_BITS(name, gb, n)\
593}
594
595
596/**
597 * parses a vlc code, faster then get_vlc()
598 * @param bits is the number of bits which will be read at once, must be
599 * identical to nb_bits in init_vlc()
600 * @param max_depth is the number of times bits bits must be read to completely
601 * read the longest vlc code
602 * = (max_vlc_length + bits - 1) / bits
603 */
604static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
605 int bits, int max_depth)
606{
607 int code;
608
609 OPEN_READER(re, s)
610 UPDATE_CACHE(re, s)
611
612 GET_VLC(code, re, s, table, bits, max_depth)
613
614 CLOSE_READER(re, s)
615 return code;
616}
617
618//#define TRACE
619
620#ifdef TRACE
621static inline void print_bin(int bits, int n){
622 int i;
623
624 for(i=n-1; i>=0; i--){
625 av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
626 }
627 for(i=n; i<24; i++)
628 av_log(NULL, AV_LOG_DEBUG, " ");
629}
630
631static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
632 int r= get_bits(s, n);
633
634 print_bin(r, n);
635 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
636 return r;
637}
638static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
639 int show= show_bits(s, 24);
640 int pos= get_bits_count(s);
641 int r= get_vlc2(s, table, bits, max_depth);
642 int len= get_bits_count(s) - pos;
643 int bits2= show>>(24-len);
644
645 print_bin(bits2, len);
646
647 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
648 return r;
649}
650static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
651 int show= show_bits(s, n);
652 int r= get_xbits(s, n);
653
654 print_bin(show, n);
655 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
656 return r;
657}
658
659#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
660#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
661#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
662#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
663#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
664
665#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
666
667#else //TRACE
668#define tprintf(p, ...) {}
669#endif
670
671static inline int decode012(GetBitContext *gb){
672 int n;
673 n = get_bits1(gb);
674 if (n == 0)
675 return 0;
676 else
677 return get_bits1(gb) + 1;
678}
679
680static inline int decode210(GetBitContext *gb){
681 if (get_bits1(gb))
682 return 0;
683 else
684 return 2 - get_bits1(gb);
685}
686
687static inline int get_bits_left(GetBitContext *gb)
688{
689 return gb->size_in_bits - get_bits_count(gb);
690}
691
692#endif /* AVCODEC_GET_BITS_H */