3 * bitstream api header.
9 //#define ALT_BITSTREAM_WRITER
10 //#define ALIGNED_BITSTREAM_WRITER
12 #define ALT_BITSTREAM_READER
13 //#define LIBMPEG2_BITSTREAM_READER
14 //#define A32_BITSTREAM_READER
15 #define LIBMPEG2_BITSTREAM_READER_HACK //add BERO
17 extern const uint8_t ff_reverse
[256];
19 #if defined(ARCH_X86) || defined(ARCH_X86_64)
20 // avoid +32 for shift optimization (gcc should do that ...)
21 static inline int32_t NEG_SSR32( int32_t a
, int8_t s
){
22 asm ("sarl %1, %0\n\t"
24 : "ic" ((uint8_t)(-s
))
28 static inline uint32_t NEG_USR32(uint32_t a
, int8_t s
){
29 asm ("shrl %1, %0\n\t"
31 : "ic" ((uint8_t)(-s
))
36 # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
37 # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
42 /* buf and buf_end must be present and used by every alternative writer. */
43 typedef struct PutBitContext
{
44 #ifdef ALT_BITSTREAM_WRITER
45 uint8_t *buf
, *buf_end
;
50 uint8_t *buf
, *buf_ptr
, *buf_end
;
54 static inline void init_put_bits(PutBitContext
*s
, uint8_t *buffer
, int buffer_size
)
57 s
->buf_end
= s
->buf
+ buffer_size
;
58 #ifdef ALT_BITSTREAM_WRITER
60 ((uint32_t*)(s
->buf
))[0]=0;
61 // memset(buffer, 0, buffer_size);
69 /* return the number of bits output */
70 static inline int put_bits_count(PutBitContext
*s
)
72 #ifdef ALT_BITSTREAM_WRITER
75 return (s
->buf_ptr
- s
->buf
) * 8 + 32 - s
->bit_left
;
79 /* pad the end of the output stream with zeros */
80 static inline void flush_put_bits(PutBitContext
*s
)
82 #ifdef ALT_BITSTREAM_WRITER
85 s
->bit_buf
<<= s
->bit_left
;
86 while (s
->bit_left
< 32) {
87 /* XXX: should test end of buffer */
88 *s
->buf_ptr
++=s
->bit_buf
>> 24;
97 void align_put_bits(PutBitContext
*s
);
98 void put_string(PutBitContext
* pbc
, char *s
, int put_zero
);
101 /* buffer, buffer_end and size_in_bits must be present and used by every reader */
102 typedef struct GetBitContext
{
103 const uint8_t *buffer
, *buffer_end
;
104 #ifdef ALT_BITSTREAM_READER
106 #elif defined LIBMPEG2_BITSTREAM_READER
110 #elif defined A32_BITSTREAM_READER
111 uint32_t *buffer_ptr
;
119 #define VLC_TYPE int16_t
123 VLC_TYPE (*table
)[2]; ///< code, bits
124 int table_size
, table_allocated
;
127 typedef struct RL_VLC_ELEM
{
133 #if defined(ARCH_SPARC) || defined(ARCH_ARMV4L)
134 #define UNALIGNED_STORES_ARE_BAD
137 /* used to avoid missaligned exceptions on some archs (alpha, ...) */
138 #if defined(ARCH_X86) || defined(ARCH_X86_64)
139 # define unaligned32(a) (*(const uint32_t*)(a))
142 static inline uint32_t unaligned32(const void *v
) {
145 } __attribute__((packed
));
147 return ((const struct Unaligned
*) v
)->i
;
149 # elif defined(__DECC)
150 static inline uint32_t unaligned32(const void *v
) {
151 return *(const __unaligned
uint32_t *) v
;
154 static inline uint32_t unaligned32(const void *v
) {
155 return *(const uint32_t *) v
;
160 #ifndef ALT_BITSTREAM_WRITER
161 static inline void put_bits(PutBitContext
*s
, int n
, unsigned int value
)
163 unsigned int bit_buf
;
167 st_out_bit_counts
[st_current_index
] += n
;
169 // printf("put_bits=%d %x\n", n, value);
170 assert(n
== 32 || value
< (1U << n
));
172 bit_buf
= s
->bit_buf
;
173 bit_left
= s
->bit_left
;
175 // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
178 bit_buf
= (bit_buf
<<n
) | value
;
182 bit_buf
|= value
>> (n
- bit_left
);
183 #ifdef UNALIGNED_STORES_ARE_BAD
184 if (3 & (intptr_t) s
->buf_ptr
) {
185 s
->buf_ptr
[0] = bit_buf
>> 24;
186 s
->buf_ptr
[1] = bit_buf
>> 16;
187 s
->buf_ptr
[2] = bit_buf
>> 8;
188 s
->buf_ptr
[3] = bit_buf
;
191 *(uint32_t *)s
->buf_ptr
= be2me_32(bit_buf
);
192 //printf("bitbuf = %08x\n", bit_buf);
198 s
->bit_buf
= bit_buf
;
199 s
->bit_left
= bit_left
;
204 #ifdef ALT_BITSTREAM_WRITER
205 static inline void put_bits(PutBitContext
*s
, int n
, unsigned int value
)
207 # ifdef ALIGNED_BITSTREAM_WRITER
208 # if defined(ARCH_X86) || defined(ARCH_X86_64)
210 "movl %0, %%ecx \n\t"
211 "xorl %%eax, %%eax \n\t"
212 "shrdl %%cl, %1, %%eax \n\t"
214 "movl %0, %%ecx \n\t"
215 "shrl $3, %%ecx \n\t"
216 "andl $0xFFFFFFFC, %%ecx \n\t"
218 "orl %1, (%2, %%ecx) \n\t"
221 "movl %%eax, 4(%2, %%ecx) \n\t"
222 : "=&r" (s
->index
), "=&r" (value
)
223 : "r" (s
->buf
), "r" (n
), "0" (s
->index
), "1" (value
<<(-n
))
228 uint32_t *ptr
= ((uint32_t *)s
->buf
)+(index
>>5);
232 ptr
[0] |= be2me_32(value
>>(index
&31));
233 ptr
[1] = be2me_32(value
<<(32-(index
&31)));
234 //if(n>24) printf("%d %d\n", n, value);
238 # else //ALIGNED_BITSTREAM_WRITER
239 # if defined(ARCH_X86) || defined(ARCH_X86_64)
241 "movl $7, %%ecx \n\t"
242 "andl %0, %%ecx \n\t"
243 "addl %3, %%ecx \n\t"
247 "movl %0, %%ecx \n\t"
248 "shrl $3, %%ecx \n\t"
249 "orl %1, (%%ecx, %2) \n\t"
251 "movl $0, 4(%%ecx, %2) \n\t"
252 : "=&r" (s
->index
), "=&r" (value
)
253 : "r" (s
->buf
), "r" (n
), "0" (s
->index
), "1" (value
)
258 uint32_t *ptr
= (uint32_t*)(((uint8_t *)s
->buf
)+(index
>>3));
260 ptr
[0] |= be2me_32(value
<<(32-n
-(index
&7) ));
262 //if(n>24) printf("%d %d\n", n, value);
266 # endif //!ALIGNED_BITSTREAM_WRITER
271 static inline uint8_t* pbBufPtr(PutBitContext
*s
)
273 #ifdef ALT_BITSTREAM_WRITER
274 return s
->buf
+ (s
->index
>>3);
282 * PutBitContext must be flushed & aligned to a byte boundary before calling this.
284 static inline void skip_put_bytes(PutBitContext
*s
, int n
){
285 assert((put_bits_count(s
)&7)==0);
286 #ifdef ALT_BITSTREAM_WRITER
287 FIXME may need some cleaning of the buffer
290 assert(s
->bit_left
==32);
296 * skips the given number of bits.
297 * must only be used if the actual values in the bitstream dont matter
299 static inline void skip_put_bits(PutBitContext
*s
, int n
){
300 #ifdef ALT_BITSTREAM_WRITER
304 s
->buf_ptr
-= s
->bit_left
>>5;
310 * Changes the end of the buffer.
312 static inline void set_put_bits_buffer_size(PutBitContext
*s
, int size
){
313 s
->buf_end
= s
->buf
+ size
;
316 /* Bitstream reader API docs:
318 abritary name which is used as prefix for the internal variables
323 OPEN_READER(name, gb)
324 loads gb into local variables
326 CLOSE_READER(name, gb)
327 stores local vars in gb
329 UPDATE_CACHE(name, gb)
330 refills the internal cache from the bitstream
331 after this call at least MIN_CACHE_BITS will be available,
334 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
336 SHOW_UBITS(name, gb, num)
337 will return the next num bits
339 SHOW_SBITS(name, gb, num)
340 will return the next num bits and do sign extension
342 SKIP_BITS(name, gb, num)
343 will skip over the next num bits
344 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
346 SKIP_CACHE(name, gb, num)
347 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
349 SKIP_COUNTER(name, gb, num)
350 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
352 LAST_SKIP_CACHE(name, gb, num)
353 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
355 LAST_SKIP_BITS(name, gb, num)
356 is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER
358 for examples see get_bits, show_bits, skip_bits, get_vlc
361 static inline int unaligned32_be(const void *v
)
365 return (((p
[0]<<8) | p
[1])<<16) | (p
[2]<<8) | (p
[3]);
367 return be2me_32( unaligned32(v
)); //original
371 static inline int unaligned32_le(const void *v
)
375 return (((p
[3]<<8) | p
[2])<<16) | (p
[1]<<8) | (p
[0]);
377 return le2me_32( unaligned32(v
)); //original
381 #ifdef ALT_BITSTREAM_READER
382 # define MIN_CACHE_BITS 25
384 # define OPEN_READER(name, gb)\
385 int name##_index= (gb)->index;\
386 int name##_cache= 0;\
388 # define CLOSE_READER(name, gb)\
389 (gb)->index= name##_index;\
391 # ifdef ALT_BITSTREAM_READER_LE
392 # define UPDATE_CACHE(name, gb)\
393 name##_cache= unaligned32_le( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
395 # define SKIP_CACHE(name, gb, num)\
396 name##_cache >>= (num);
398 # define UPDATE_CACHE(name, gb)\
399 name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
401 # define SKIP_CACHE(name, gb, num)\
402 name##_cache <<= (num);
406 # define SKIP_COUNTER(name, gb, num)\
407 name##_index += (num);\
409 # define SKIP_BITS(name, gb, num)\
411 SKIP_CACHE(name, gb, num)\
412 SKIP_COUNTER(name, gb, num)\
415 # define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
416 # define LAST_SKIP_CACHE(name, gb, num) ;
418 # ifdef ALT_BITSTREAM_READER_LE
419 # define SHOW_UBITS(name, gb, num)\
420 ((name##_cache) & (NEG_USR32(0xffffffff,num)))
422 # define SHOW_UBITS(name, gb, num)\
423 NEG_USR32(name##_cache, num)
426 # define SHOW_SBITS(name, gb, num)\
427 NEG_SSR32(name##_cache, num)
429 # define GET_CACHE(name, gb)\
430 ((uint32_t)name##_cache)
432 static inline int get_bits_count(GetBitContext
*s
){
435 #elif defined LIBMPEG2_BITSTREAM_READER
436 //libmpeg2 like reader
438 # define MIN_CACHE_BITS 17
440 # define OPEN_READER(name, gb)\
441 int name##_bit_count=(gb)->bit_count;\
442 int name##_cache= (gb)->cache;\
443 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
445 # define CLOSE_READER(name, gb)\
446 (gb)->bit_count= name##_bit_count;\
447 (gb)->cache= name##_cache;\
448 (gb)->buffer_ptr= name##_buffer_ptr;\
450 #ifdef LIBMPEG2_BITSTREAM_READER_HACK
452 # define UPDATE_CACHE(name, gb)\
453 if(name##_bit_count >= 0){\
454 name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\
455 name##_buffer_ptr += 2;\
456 name##_bit_count-= 16;\
461 # define UPDATE_CACHE(name, gb)\
462 if(name##_bit_count >= 0){\
463 name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\
464 name##_buffer_ptr+=2;\
465 name##_bit_count-= 16;\
470 # define SKIP_CACHE(name, gb, num)\
471 name##_cache <<= (num);\
473 # define SKIP_COUNTER(name, gb, num)\
474 name##_bit_count += (num);\
476 # define SKIP_BITS(name, gb, num)\
478 SKIP_CACHE(name, gb, num)\
479 SKIP_COUNTER(name, gb, num)\
482 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
483 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
485 # define SHOW_UBITS(name, gb, num)\
486 NEG_USR32(name##_cache, num)
488 # define SHOW_SBITS(name, gb, num)\
489 NEG_SSR32(name##_cache, num)
491 # define GET_CACHE(name, gb)\
492 ((uint32_t)name##_cache)
494 static inline int get_bits_count(GetBitContext
*s
){
495 return (s
->buffer_ptr
- s
->buffer
)*8 - 16 + s
->bit_count
;
498 #elif defined A32_BITSTREAM_READER
500 # define MIN_CACHE_BITS 32
502 # define OPEN_READER(name, gb)\
503 int name##_bit_count=(gb)->bit_count;\
504 uint32_t name##_cache0= (gb)->cache0;\
505 uint32_t name##_cache1= (gb)->cache1;\
506 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
508 # define CLOSE_READER(name, gb)\
509 (gb)->bit_count= name##_bit_count;\
510 (gb)->cache0= name##_cache0;\
511 (gb)->cache1= name##_cache1;\
512 (gb)->buffer_ptr= name##_buffer_ptr;\
514 # define UPDATE_CACHE(name, gb)\
515 if(name##_bit_count > 0){\
516 const uint32_t next= be2me_32( *name##_buffer_ptr );\
517 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
518 name##_cache1 |= next<<name##_bit_count;\
519 name##_buffer_ptr++;\
520 name##_bit_count-= 32;\
523 #if defined(ARCH_X86) || defined(ARCH_X86_64)
524 # define SKIP_CACHE(name, gb, num)\
526 "shldl %2, %1, %0 \n\t"\
528 : "+r" (name##_cache0), "+r" (name##_cache1)\
529 : "Ic" ((uint8_t)num)\
532 # define SKIP_CACHE(name, gb, num)\
533 name##_cache0 <<= (num);\
534 name##_cache0 |= NEG_USR32(name##_cache1,num);\
535 name##_cache1 <<= (num);
538 # define SKIP_COUNTER(name, gb, num)\
539 name##_bit_count += (num);\
541 # define SKIP_BITS(name, gb, num)\
543 SKIP_CACHE(name, gb, num)\
544 SKIP_COUNTER(name, gb, num)\
547 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
548 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
550 # define SHOW_UBITS(name, gb, num)\
551 NEG_USR32(name##_cache0, num)
553 # define SHOW_SBITS(name, gb, num)\
554 NEG_SSR32(name##_cache0, num)
556 # define GET_CACHE(name, gb)\
559 static inline int get_bits_count(GetBitContext
*s
){
560 return ((uint8_t*)s
->buffer_ptr
- s
->buffer
)*8 - 32 + s
->bit_count
;
566 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
567 * if MSB not set it is negative
568 * @param n length in bits
571 static inline int get_xbits(GetBitContext
*s
, int n
){
573 register int32_t cache
;
576 cache
= GET_CACHE(re
,s
);
577 if ((int32_t)cache
<0) { //MSB=1
578 tmp
= NEG_USR32(cache
,n
);
580 // tmp = (-1<<n) | NEG_USR32(cache,n) + 1; mpeg12.c algo
581 // tmp = - (NEG_USR32(cache,n) ^ ((1 << n) - 1)); h263.c algo
582 tmp
= - NEG_USR32(~cache
,n
);
584 LAST_SKIP_BITS(re
, s
, n
)
589 static inline int get_sbits(GetBitContext
*s
, int n
){
593 tmp
= SHOW_SBITS(re
, s
, n
);
594 LAST_SKIP_BITS(re
, s
, n
)
601 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
603 static inline unsigned int get_bits(GetBitContext
*s
, int n
){
607 tmp
= SHOW_UBITS(re
, s
, n
);
608 LAST_SKIP_BITS(re
, s
, n
)
613 unsigned int get_bits_long(GetBitContext
*s
, int n
);
617 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
619 static inline unsigned int show_bits(GetBitContext
*s
, int n
){
623 tmp
= SHOW_UBITS(re
, s
, n
);
624 // CLOSE_READER(re, s)
628 unsigned int show_bits_long(GetBitContext
*s
, int n
);
630 static inline void skip_bits(GetBitContext
*s
, int n
){
631 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
634 LAST_SKIP_BITS(re
, s
, n
)
638 static inline unsigned int get_bits1(GetBitContext
*s
){
639 #ifdef ALT_BITSTREAM_READER
641 uint8_t result
= s
->buffer
[ index
>>3 ];
642 #ifdef ALT_BITSTREAM_READER_LE
643 result
>>= (index
&0x07);
646 result
<<= (index
&0x07);
654 return get_bits(s
, 1);
658 static inline unsigned int show_bits1(GetBitContext
*s
){
659 return show_bits(s
, 1);
662 static inline void skip_bits1(GetBitContext
*s
){
667 * init GetBitContext.
668 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
669 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
670 * @param bit_size the size of the buffer in bits
672 static inline void init_get_bits(GetBitContext
*s
,
673 const uint8_t *buffer
, int bit_size
)
675 const int buffer_size
= (bit_size
+7)>>3;
678 s
->size_in_bits
= bit_size
;
679 s
->buffer_end
= buffer
+ buffer_size
;
680 #ifdef ALT_BITSTREAM_READER
682 #elif defined LIBMPEG2_BITSTREAM_READER
683 #ifdef LIBMPEG2_BITSTREAM_READER_HACK
686 s
->cache
= (*buffer
++)<<24;
687 s
->buffer_ptr
= buffer
;
692 s
->buffer_ptr
= buffer
;
696 #elif defined A32_BITSTREAM_READER
697 s
->buffer_ptr
= (uint32_t*)buffer
;
708 #ifdef A32_BITSTREAM_READER
713 int check_marker(GetBitContext
*s
, const char *msg
);
714 void align_get_bits(GetBitContext
*s
);
715 int init_vlc(VLC
*vlc
, int nb_bits
, int nb_codes
,
716 const void *bits
, int bits_wrap
, int bits_size
,
717 const void *codes
, int codes_wrap
, int codes_size
,
719 #define INIT_VLC_USE_STATIC 1
720 #define INIT_VLC_LE 2
721 void free_vlc(VLC
*vlc
);
725 * if the vlc code is invalid and max_depth=1 than no bits will be removed
726 * if the vlc code is invalid and max_depth>1 than the number of bits removed
729 #define GET_VLC(code, name, gb, table, bits, max_depth)\
731 int n, index, nb_bits;\
733 index= SHOW_UBITS(name, gb, bits);\
734 code = table[index][0];\
735 n = table[index][1];\
737 if(max_depth > 1 && n < 0){\
738 LAST_SKIP_BITS(name, gb, bits)\
739 UPDATE_CACHE(name, gb)\
743 index= SHOW_UBITS(name, gb, nb_bits) + code;\
744 code = table[index][0];\
745 n = table[index][1];\
746 if(max_depth > 2 && n < 0){\
747 LAST_SKIP_BITS(name, gb, nb_bits)\
748 UPDATE_CACHE(name, gb)\
752 index= SHOW_UBITS(name, gb, nb_bits) + code;\
753 code = table[index][0];\
754 n = table[index][1];\
757 SKIP_BITS(name, gb, n)\
760 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
762 int n, index, nb_bits;\
764 index= SHOW_UBITS(name, gb, bits);\
765 level = table[index].level;\
766 n = table[index].len;\
768 if(max_depth > 1 && n < 0){\
769 SKIP_BITS(name, gb, bits)\
771 UPDATE_CACHE(name, gb)\
776 index= SHOW_UBITS(name, gb, nb_bits) + level;\
777 level = table[index].level;\
778 n = table[index].len;\
780 run= table[index].run;\
781 SKIP_BITS(name, gb, n)\
784 // deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly
785 static inline int get_vlc(GetBitContext
*s
, VLC
*vlc
)
788 VLC_TYPE (*table
)[2]= vlc
->table
;
793 GET_VLC(code
, re
, s
, table
, vlc
->bits
, 3)
800 * parses a vlc code, faster then get_vlc()
801 * @param bits is the number of bits which will be read at once, must be
802 * identical to nb_bits in init_vlc()
803 * @param max_depth is the number of times bits bits must be readed to completly
804 * read the longest vlc code
805 * = (max_vlc_length + bits - 1) / bits
807 static always_inline
int get_vlc2(GetBitContext
*s
, VLC_TYPE (*table
)[2],
808 int bits
, int max_depth
)
815 GET_VLC(code
, re
, s
, table
, bits
, max_depth
)
825 static inline void print_bin(int bits
, int n
){
828 for(i
=n
-1; i
>=0; i
--){
829 av_log(NULL
, AV_LOG_DEBUG
, "%d", (bits
>>i
)&1);
832 av_log(NULL
, AV_LOG_DEBUG
, " ");
835 static inline int get_bits_trace(GetBitContext
*s
, int n
, char *file
, const char *func
, int line
){
836 int r
= get_bits(s
, n
);
839 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
);
842 static inline int get_vlc_trace(GetBitContext
*s
, VLC_TYPE (*table
)[2], int bits
, int max_depth
, char *file
, const char *func
, int line
){
843 int show
= show_bits(s
, 24);
844 int pos
= get_bits_count(s
);
845 int r
= get_vlc2(s
, table
, bits
, max_depth
);
846 int len
= get_bits_count(s
) - pos
;
847 int bits2
= show
>>(24-len
);
849 print_bin(bits2
, len
);
851 av_log(NULL
, AV_LOG_DEBUG
, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2
, len
, r
, pos
, file
, func
, line
);
854 static inline int get_xbits_trace(GetBitContext
*s
, int n
, char *file
, const char *func
, int line
){
855 int show
= show_bits(s
, n
);
856 int r
= get_xbits(s
, n
);
859 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
);
863 #define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
864 #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
865 #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
866 #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
867 #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
869 #define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
872 #define tprintf(...) {}
875 static inline int decode012(GetBitContext
*gb
){
881 return get_bits1(gb
) + 1;
884 #endif /* BITSTREAM_H */