3 * bitstream api header.
9 //#define ALT_BITSTREAM_WRITER
10 //#define ALIGNED_BITSTREAM_WRITER
11 #if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
12 #define ALT_BITSTREAM_READER
13 //#define LIBMPEG2_BITSTREAM_READER
14 //#define A32_BITSTREAM_READER
16 #define LIBMPEG2_BITSTREAM_READER_HACK //add BERO
18 extern const uint8_t ff_reverse[256];
20 #if defined(ARCH_X86) || defined(ARCH_X86_64)
21 // avoid +32 for shift optimization (gcc should do that ...)
22 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
23 asm ("sarl %1, %0\n\t"
25 : "ic" ((uint8_t)(-s))
29 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
30 asm ("shrl %1, %0\n\t"
32 : "ic" ((uint8_t)(-s))
37 # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
38 # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
43 /* buf and buf_end must be present and used by every alternative writer. */
44 typedef struct PutBitContext {
45 #ifdef ALT_BITSTREAM_WRITER
46 uint8_t *buf, *buf_end;
51 uint8_t *buf, *buf_ptr, *buf_end;
55 static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
63 s->buf_end = s->buf + buffer_size;
64 #ifdef ALT_BITSTREAM_WRITER
66 ((uint32_t*)(s->buf))[0]=0;
67 // memset(buffer, 0, buffer_size);
75 /* return the number of bits output */
76 static inline int put_bits_count(PutBitContext *s)
78 #ifdef ALT_BITSTREAM_WRITER
81 return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
85 /* pad the end of the output stream with zeros */
86 static inline void flush_put_bits(PutBitContext *s)
88 #ifdef ALT_BITSTREAM_WRITER
91 s->bit_buf<<= s->bit_left;
92 while (s->bit_left < 32) {
93 /* XXX: should test end of buffer */
94 *s->buf_ptr++=s->bit_buf >> 24;
103 void align_put_bits(PutBitContext *s);
104 void ff_put_string(PutBitContext * pbc, char *s, int put_zero);
107 /* buffer, buffer_end and size_in_bits must be present and used by every reader */
108 typedef struct GetBitContext {
109 const uint8_t *buffer, *buffer_end;
110 #ifdef ALT_BITSTREAM_READER
112 #elif defined LIBMPEG2_BITSTREAM_READER
116 #elif defined A32_BITSTREAM_READER
117 uint32_t *buffer_ptr;
125 #define VLC_TYPE int16_t
129 VLC_TYPE (*table)[2]; ///< code, bits
130 int table_size, table_allocated;
133 typedef struct RL_VLC_ELEM {
139 #if defined(ARCH_SPARC) || defined(ARCH_ARMV4L) || defined(ARCH_MIPS)
140 #define UNALIGNED_STORES_ARE_BAD
143 /* used to avoid missaligned exceptions on some archs (alpha, ...) */
144 #if defined(ARCH_X86) || defined(ARCH_X86_64)
145 # define unaligned16(a) (*(const uint16_t*)(a))
146 # define unaligned32(a) (*(const uint32_t*)(a))
147 # define unaligned64(a) (*(const uint64_t*)(a))
150 # define unaligned(x) \
151 static inline uint##x##_t unaligned##x(const void *v) { \
154 } __attribute__((packed)); \
156 return ((const struct Unaligned *) v)->i; \
158 # elif defined(__DECC)
159 # define unaligned(x) \
160 static inline uint##x##_t unaligned##x##(const void *v) { \
161 return *(const __unaligned uint##x##_t *) v; \
164 # define unaligned(x) \
165 static inline uint##x##_t unaligned##x##(const void *v) { \
166 return *(const uint##x##_t *) v; \
175 #ifndef ALT_BITSTREAM_WRITER
176 static inline void put_bits(PutBitContext *s, int n, unsigned int value)
178 unsigned int bit_buf;
181 // printf("put_bits=%d %x\n", n, value);
182 assert(n == 32 || value < (1U << n));
184 bit_buf = s->bit_buf;
185 bit_left = s->bit_left;
187 // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
190 bit_buf = (bit_buf<<n) | value;
194 bit_buf |= value >> (n - bit_left);
195 #ifdef UNALIGNED_STORES_ARE_BAD
196 if (3 & (intptr_t) s->buf_ptr) {
197 s->buf_ptr[0] = bit_buf >> 24;
198 s->buf_ptr[1] = bit_buf >> 16;
199 s->buf_ptr[2] = bit_buf >> 8;
200 s->buf_ptr[3] = bit_buf ;
203 *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
204 //printf("bitbuf = %08x\n", bit_buf);
210 s->bit_buf = bit_buf;
211 s->bit_left = bit_left;
216 #ifdef ALT_BITSTREAM_WRITER
217 static inline void put_bits(PutBitContext *s, int n, unsigned int value)
219 # ifdef ALIGNED_BITSTREAM_WRITER
220 # if defined(ARCH_X86) || defined(ARCH_X86_64)
222 "movl %0, %%ecx \n\t"
223 "xorl %%eax, %%eax \n\t"
224 "shrdl %%cl, %1, %%eax \n\t"
226 "movl %0, %%ecx \n\t"
227 "shrl $3, %%ecx \n\t"
228 "andl $0xFFFFFFFC, %%ecx \n\t"
230 "orl %1, (%2, %%ecx) \n\t"
233 "movl %%eax, 4(%2, %%ecx) \n\t"
234 : "=&r" (s->index), "=&r" (value)
235 : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n))
240 uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5);
244 ptr[0] |= be2me_32(value>>(index&31));
245 ptr[1] = be2me_32(value<<(32-(index&31)));
246 //if(n>24) printf("%d %d\n", n, value);
250 # else //ALIGNED_BITSTREAM_WRITER
251 # if defined(ARCH_X86) || defined(ARCH_X86_64)
253 "movl $7, %%ecx \n\t"
254 "andl %0, %%ecx \n\t"
255 "addl %3, %%ecx \n\t"
259 "movl %0, %%ecx \n\t"
260 "shrl $3, %%ecx \n\t"
261 "orl %1, (%%ecx, %2) \n\t"
263 "movl $0, 4(%%ecx, %2) \n\t"
264 : "=&r" (s->index), "=&r" (value)
265 : "r" (s->buf), "r" (n), "0" (s->index), "1" (value)
270 uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3));
272 ptr[0] |= be2me_32(value<<(32-n-(index&7) ));
274 //if(n>24) printf("%d %d\n", n, value);
278 # endif //!ALIGNED_BITSTREAM_WRITER
283 static inline uint8_t* pbBufPtr(PutBitContext *s)
285 #ifdef ALT_BITSTREAM_WRITER
286 return s->buf + (s->index>>3);
294 * PutBitContext must be flushed & aligned to a byte boundary before calling this.
296 static inline void skip_put_bytes(PutBitContext *s, int n){
297 assert((put_bits_count(s)&7)==0);
298 #ifdef ALT_BITSTREAM_WRITER
299 FIXME may need some cleaning of the buffer
302 assert(s->bit_left==32);
308 * skips the given number of bits.
309 * must only be used if the actual values in the bitstream dont matter
311 static inline void skip_put_bits(PutBitContext *s, int n){
312 #ifdef ALT_BITSTREAM_WRITER
316 s->buf_ptr-= s->bit_left>>5;
322 * Changes the end of the buffer.
324 static inline void set_put_bits_buffer_size(PutBitContext *s, int size){
325 s->buf_end= s->buf + size;
328 /* Bitstream reader API docs:
330 abritary name which is used as prefix for the internal variables
335 OPEN_READER(name, gb)
336 loads gb into local variables
338 CLOSE_READER(name, gb)
339 stores local vars in gb
341 UPDATE_CACHE(name, gb)
342 refills the internal cache from the bitstream
343 after this call at least MIN_CACHE_BITS will be available,
346 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
348 SHOW_UBITS(name, gb, num)
349 will return the next num bits
351 SHOW_SBITS(name, gb, num)
352 will return the next num bits and do sign extension
354 SKIP_BITS(name, gb, num)
355 will skip over the next num bits
356 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
358 SKIP_CACHE(name, gb, num)
359 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
361 SKIP_COUNTER(name, gb, num)
362 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
364 LAST_SKIP_CACHE(name, gb, num)
365 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
367 LAST_SKIP_BITS(name, gb, num)
368 is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER
370 for examples see get_bits, show_bits, skip_bits, get_vlc
373 static inline int unaligned32_be(const void *v)
377 return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
379 return be2me_32( unaligned32(v)); //original
383 static inline int unaligned32_le(const void *v)
387 return (((p[3]<<8) | p[2])<<16) | (p[1]<<8) | (p[0]);
389 return le2me_32( unaligned32(v)); //original
393 #ifdef ALT_BITSTREAM_READER
394 # define MIN_CACHE_BITS 25
396 # define OPEN_READER(name, gb)\
397 int name##_index= (gb)->index;\
398 int name##_cache= 0;\
400 # define CLOSE_READER(name, gb)\
401 (gb)->index= name##_index;\
403 # ifdef ALT_BITSTREAM_READER_LE
404 # define UPDATE_CACHE(name, gb)\
405 name##_cache= unaligned32_le( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
407 # define SKIP_CACHE(name, gb, num)\
408 name##_cache >>= (num);
410 # define UPDATE_CACHE(name, gb)\
411 name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
413 # define SKIP_CACHE(name, gb, num)\
414 name##_cache <<= (num);
418 # define SKIP_COUNTER(name, gb, num)\
419 name##_index += (num);\
421 # define SKIP_BITS(name, gb, num)\
423 SKIP_CACHE(name, gb, num)\
424 SKIP_COUNTER(name, gb, num)\
427 # define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
428 # define LAST_SKIP_CACHE(name, gb, num) ;
430 # ifdef ALT_BITSTREAM_READER_LE
431 # define SHOW_UBITS(name, gb, num)\
432 ((name##_cache) & (NEG_USR32(0xffffffff,num)))
434 # define SHOW_UBITS(name, gb, num)\
435 NEG_USR32(name##_cache, num)
438 # define SHOW_SBITS(name, gb, num)\
439 NEG_SSR32(name##_cache, num)
441 # define GET_CACHE(name, gb)\
442 ((uint32_t)name##_cache)
444 static inline int get_bits_count(GetBitContext *s){
448 static inline void skip_bits_long(GetBitContext *s, int n){
452 #elif defined LIBMPEG2_BITSTREAM_READER
453 //libmpeg2 like reader
455 # define MIN_CACHE_BITS 17
457 # define OPEN_READER(name, gb)\
458 int name##_bit_count=(gb)->bit_count;\
459 int name##_cache= (gb)->cache;\
460 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
462 # define CLOSE_READER(name, gb)\
463 (gb)->bit_count= name##_bit_count;\
464 (gb)->cache= name##_cache;\
465 (gb)->buffer_ptr= name##_buffer_ptr;\
467 #ifdef LIBMPEG2_BITSTREAM_READER_HACK
469 # define UPDATE_CACHE(name, gb)\
470 if(name##_bit_count >= 0){\
471 name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\
472 name##_buffer_ptr += 2;\
473 name##_bit_count-= 16;\
478 # define UPDATE_CACHE(name, gb)\
479 if(name##_bit_count >= 0){\
480 name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\
481 name##_buffer_ptr+=2;\
482 name##_bit_count-= 16;\
487 # define SKIP_CACHE(name, gb, num)\
488 name##_cache <<= (num);\
490 # define SKIP_COUNTER(name, gb, num)\
491 name##_bit_count += (num);\
493 # define SKIP_BITS(name, gb, num)\
495 SKIP_CACHE(name, gb, num)\
496 SKIP_COUNTER(name, gb, num)\
499 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
500 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
502 # define SHOW_UBITS(name, gb, num)\
503 NEG_USR32(name##_cache, num)
505 # define SHOW_SBITS(name, gb, num)\
506 NEG_SSR32(name##_cache, num)
508 # define GET_CACHE(name, gb)\
509 ((uint32_t)name##_cache)
511 static inline int get_bits_count(GetBitContext *s){
512 return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
515 static inline void skip_bits_long(GetBitContext *s, int n){
518 re_buffer_ptr += 2*(re_bit_count>>4);
520 re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count);
525 #elif defined A32_BITSTREAM_READER
527 # define MIN_CACHE_BITS 32
529 # define OPEN_READER(name, gb)\
530 int name##_bit_count=(gb)->bit_count;\
531 uint32_t name##_cache0= (gb)->cache0;\
532 uint32_t name##_cache1= (gb)->cache1;\
533 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
535 # define CLOSE_READER(name, gb)\
536 (gb)->bit_count= name##_bit_count;\
537 (gb)->cache0= name##_cache0;\
538 (gb)->cache1= name##_cache1;\
539 (gb)->buffer_ptr= name##_buffer_ptr;\
541 # define UPDATE_CACHE(name, gb)\
542 if(name##_bit_count > 0){\
543 const uint32_t next= be2me_32( *name##_buffer_ptr );\
544 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
545 name##_cache1 |= next<<name##_bit_count;\
546 name##_buffer_ptr++;\
547 name##_bit_count-= 32;\
550 #if defined(ARCH_X86) || defined(ARCH_X86_64)
551 # define SKIP_CACHE(name, gb, num)\
553 "shldl %2, %1, %0 \n\t"\
555 : "+r" (name##_cache0), "+r" (name##_cache1)\
556 : "Ic" ((uint8_t)(num))\
559 # define SKIP_CACHE(name, gb, num)\
560 name##_cache0 <<= (num);\
561 name##_cache0 |= NEG_USR32(name##_cache1,num);\
562 name##_cache1 <<= (num);
565 # define SKIP_COUNTER(name, gb, num)\
566 name##_bit_count += (num);\
568 # define SKIP_BITS(name, gb, num)\
570 SKIP_CACHE(name, gb, num)\
571 SKIP_COUNTER(name, gb, num)\
574 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
575 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
577 # define SHOW_UBITS(name, gb, num)\
578 NEG_USR32(name##_cache0, num)
580 # define SHOW_SBITS(name, gb, num)\
581 NEG_SSR32(name##_cache0, num)
583 # define GET_CACHE(name, gb)\
586 static inline int get_bits_count(GetBitContext *s){
587 return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
590 static inline void skip_bits_long(GetBitContext *s, int n){
593 re_buffer_ptr += re_bit_count>>5;
595 re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count;
604 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
605 * if MSB not set it is negative
606 * @param n length in bits
609 static inline int get_xbits(GetBitContext *s, int n){
611 register int32_t cache;
614 cache = GET_CACHE(re,s);
616 LAST_SKIP_BITS(re, s, n)
618 return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
621 static inline int get_sbits(GetBitContext *s, int n){
625 tmp= SHOW_SBITS(re, s, n);
626 LAST_SKIP_BITS(re, s, n)
633 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
635 static inline unsigned int get_bits(GetBitContext *s, int n){
639 tmp= SHOW_UBITS(re, s, n);
640 LAST_SKIP_BITS(re, s, n)
645 unsigned int get_bits_long(GetBitContext *s, int n);
649 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
651 static inline unsigned int show_bits(GetBitContext *s, int n){
655 tmp= SHOW_UBITS(re, s, n);
656 // CLOSE_READER(re, s)
660 unsigned int show_bits_long(GetBitContext *s, int n);
662 static inline void skip_bits(GetBitContext *s, int n){
663 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
666 LAST_SKIP_BITS(re, s, n)
670 static inline unsigned int get_bits1(GetBitContext *s){
671 #ifdef ALT_BITSTREAM_READER
673 uint8_t result= s->buffer[ index>>3 ];
674 #ifdef ALT_BITSTREAM_READER_LE
675 result>>= (index&0x07);
678 result<<= (index&0x07);
686 return get_bits(s, 1);
690 static inline unsigned int show_bits1(GetBitContext *s){
691 return show_bits(s, 1);
694 static inline void skip_bits1(GetBitContext *s){
699 * init GetBitContext.
700 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
701 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
702 * @param bit_size the size of the buffer in bits
704 static inline void init_get_bits(GetBitContext *s,
705 const uint8_t *buffer, int bit_size)
707 int buffer_size= (bit_size+7)>>3;
708 if(buffer_size < 0 || bit_size < 0) {
709 buffer_size = bit_size = 0;
714 s->size_in_bits= bit_size;
715 s->buffer_end= buffer + buffer_size;
716 #ifdef ALT_BITSTREAM_READER
718 #elif defined LIBMPEG2_BITSTREAM_READER
719 s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
720 s->bit_count = 16 + 8*((intptr_t)buffer&1);
721 skip_bits_long(s, 0);
722 #elif defined A32_BITSTREAM_READER
723 s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
724 s->bit_count = 32 + 8*((intptr_t)buffer&3);
725 skip_bits_long(s, 0);
729 static void align_get_bits(GetBitContext *s)
731 int n= (-get_bits_count(s)) & 7;
732 if(n) skip_bits(s, n);
735 int check_marker(GetBitContext *s, const char *msg);
736 int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
737 const void *bits, int bits_wrap, int bits_size,
738 const void *codes, int codes_wrap, int codes_size,
740 #define INIT_VLC_USE_STATIC 1
741 #define INIT_VLC_LE 2
742 void free_vlc(VLC *vlc);
746 * if the vlc code is invalid and max_depth=1 than no bits will be removed
747 * if the vlc code is invalid and max_depth>1 than the number of bits removed
750 #define GET_VLC(code, name, gb, table, bits, max_depth)\
752 int n, index, nb_bits;\
754 index= SHOW_UBITS(name, gb, bits);\
755 code = table[index][0];\
756 n = table[index][1];\
758 if(max_depth > 1 && n < 0){\
759 LAST_SKIP_BITS(name, gb, bits)\
760 UPDATE_CACHE(name, gb)\
764 index= SHOW_UBITS(name, gb, nb_bits) + code;\
765 code = table[index][0];\
766 n = table[index][1];\
767 if(max_depth > 2 && n < 0){\
768 LAST_SKIP_BITS(name, gb, nb_bits)\
769 UPDATE_CACHE(name, gb)\
773 index= SHOW_UBITS(name, gb, nb_bits) + code;\
774 code = table[index][0];\
775 n = table[index][1];\
778 SKIP_BITS(name, gb, n)\
781 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
783 int n, index, nb_bits;\
785 index= SHOW_UBITS(name, gb, bits);\
786 level = table[index].level;\
787 n = table[index].len;\
789 if(max_depth > 1 && n < 0){\
790 SKIP_BITS(name, gb, bits)\
792 UPDATE_CACHE(name, gb)\
797 index= SHOW_UBITS(name, gb, nb_bits) + level;\
798 level = table[index].level;\
799 n = table[index].len;\
801 run= table[index].run;\
802 SKIP_BITS(name, gb, n)\
807 * parses a vlc code, faster then get_vlc()
808 * @param bits is the number of bits which will be read at once, must be
809 * identical to nb_bits in init_vlc()
810 * @param max_depth is the number of times bits bits must be readed to completly
811 * read the longest vlc code
812 * = (max_vlc_length + bits - 1) / bits
814 static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
815 int bits, int max_depth)
822 GET_VLC(code, re, s, table, bits, max_depth)
832 static inline void print_bin(int bits, int n){
835 for(i=n-1; i>=0; i--){
836 av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
839 av_log(NULL, AV_LOG_DEBUG, " ");
842 static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
843 int r= get_bits(s, n);
846 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);
849 static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
850 int show= show_bits(s, 24);
851 int pos= get_bits_count(s);
852 int r= get_vlc2(s, table, bits, max_depth);
853 int len= get_bits_count(s) - pos;
854 int bits2= show>>(24-len);
856 print_bin(bits2, len);
858 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
861 static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
862 int show= show_bits(s, n);
863 int r= get_xbits(s, n);
866 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);
870 #define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
871 #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
872 #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
873 #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
874 #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
876 #define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
879 #define tprintf(...) {}
882 static inline int decode012(GetBitContext *gb){
888 return get_bits1(gb) + 1;
891 #endif /* BITSTREAM_H */