Rename AVPixFmtDescriptor.nb_channels to nb_components, the new name
[ffmpeg-lucabe.git] / libavcodec / get_bits.h
blob1863e7de4a7943cd86f2bbab637da77c5070ff3d
1 /*
2 * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of FFmpeg.
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.
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.
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
21 /**
22 * @file libavcodec/get_bits.h
23 * bitstream reader API header.
26 #ifndef AVCODEC_GET_BITS_H
27 #define AVCODEC_GET_BITS_H
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"
38 #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER)
39 # define ALT_BITSTREAM_READER
40 #endif
42 #if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
43 # if ARCH_ARM
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
52 #if ARCH_X86
53 // avoid +32 for shift optimization (gcc should do that ...)
54 static inline int32_t NEG_SSR32( int32_t a, int8_t s){
55 __asm__ ("sarl %1, %0\n\t"
56 : "+r" (a)
57 : "ic" ((uint8_t)(-s))
59 return a;
61 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
62 __asm__ ("shrl %1, %0\n\t"
63 : "+r" (a)
64 : "ic" ((uint8_t)(-s))
66 return a;
68 #else
69 # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
70 # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
71 #endif
73 /* bit input */
74 /* buffer, buffer_end and size_in_bits must be present and used by every reader */
75 typedef struct GetBitContext {
76 const uint8_t *buffer, *buffer_end;
77 #ifdef ALT_BITSTREAM_READER
78 int index;
79 #elif defined LIBMPEG2_BITSTREAM_READER
80 uint8_t *buffer_ptr;
81 uint32_t cache;
82 int bit_count;
83 #elif defined A32_BITSTREAM_READER
84 uint32_t *buffer_ptr;
85 uint32_t cache0;
86 uint32_t cache1;
87 int bit_count;
88 #endif
89 int size_in_bits;
90 } GetBitContext;
92 #define VLC_TYPE int16_t
94 typedef struct VLC {
95 int bits;
96 VLC_TYPE (*table)[2]; ///< code, bits
97 int table_size, table_allocated;
98 } VLC;
100 typedef struct RL_VLC_ELEM {
101 int16_t level;
102 int8_t len;
103 uint8_t run;
104 } RL_VLC_ELEM;
106 /* Bitstream reader API docs:
107 name
108 arbitrary name which is used as prefix for the internal variables
111 getbitcontext
113 OPEN_READER(name, gb)
114 loads gb into local variables
116 CLOSE_READER(name, gb)
117 stores local vars in gb
119 UPDATE_CACHE(name, gb)
120 refills the internal cache from the bitstream
121 after this call at least MIN_CACHE_BITS will be available,
123 GET_CACHE(name, gb)
124 will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
126 SHOW_UBITS(name, gb, num)
127 will return the next num bits
129 SHOW_SBITS(name, gb, num)
130 will return the next num bits and do sign extension
132 SKIP_BITS(name, gb, num)
133 will skip over the next num bits
134 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
136 SKIP_CACHE(name, gb, num)
137 will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
139 SKIP_COUNTER(name, gb, num)
140 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
142 LAST_SKIP_CACHE(name, gb, num)
143 will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
145 LAST_SKIP_BITS(name, gb, num)
146 is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
148 for examples see get_bits, show_bits, skip_bits, get_vlc
151 #ifdef ALT_BITSTREAM_READER
152 # define MIN_CACHE_BITS 25
154 # define OPEN_READER(name, gb)\
155 int name##_index= (gb)->index;\
156 int name##_cache= 0;\
158 # define CLOSE_READER(name, gb)\
159 (gb)->index= name##_index;\
161 # ifdef ALT_BITSTREAM_READER_LE
162 # define UPDATE_CACHE(name, gb)\
163 name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
165 # define SKIP_CACHE(name, gb, num)\
166 name##_cache >>= (num);
167 # else
168 # define UPDATE_CACHE(name, gb)\
169 name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
171 # define SKIP_CACHE(name, gb, num)\
172 name##_cache <<= (num);
173 # endif
175 // FIXME name?
176 # define SKIP_COUNTER(name, gb, num)\
177 name##_index += (num);\
179 # define SKIP_BITS(name, gb, num)\
181 SKIP_CACHE(name, gb, num)\
182 SKIP_COUNTER(name, gb, num)\
185 # define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
186 # define LAST_SKIP_CACHE(name, gb, num) ;
188 # ifdef ALT_BITSTREAM_READER_LE
189 # define SHOW_UBITS(name, gb, num)\
190 ((name##_cache) & (NEG_USR32(0xffffffff,num)))
192 # define SHOW_SBITS(name, gb, num)\
193 NEG_SSR32((name##_cache)<<(32-(num)), num)
194 # else
195 # define SHOW_UBITS(name, gb, num)\
196 NEG_USR32(name##_cache, num)
198 # define SHOW_SBITS(name, gb, num)\
199 NEG_SSR32(name##_cache, num)
200 # endif
202 # define GET_CACHE(name, gb)\
203 ((uint32_t)name##_cache)
205 static inline int get_bits_count(GetBitContext *s){
206 return s->index;
209 static inline void skip_bits_long(GetBitContext *s, int n){
210 s->index += n;
213 #elif defined LIBMPEG2_BITSTREAM_READER
214 //libmpeg2 like reader
216 # define MIN_CACHE_BITS 17
218 # define OPEN_READER(name, gb)\
219 int name##_bit_count=(gb)->bit_count;\
220 int name##_cache= (gb)->cache;\
221 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
223 # define CLOSE_READER(name, gb)\
224 (gb)->bit_count= name##_bit_count;\
225 (gb)->cache= name##_cache;\
226 (gb)->buffer_ptr= name##_buffer_ptr;\
228 # define UPDATE_CACHE(name, gb)\
229 if(name##_bit_count >= 0){\
230 name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \
231 name##_buffer_ptr+=2;\
232 name##_bit_count-= 16;\
235 # define SKIP_CACHE(name, gb, num)\
236 name##_cache <<= (num);\
238 # define SKIP_COUNTER(name, gb, num)\
239 name##_bit_count += (num);\
241 # define SKIP_BITS(name, gb, num)\
243 SKIP_CACHE(name, gb, num)\
244 SKIP_COUNTER(name, gb, num)\
247 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
248 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
250 # define SHOW_UBITS(name, gb, num)\
251 NEG_USR32(name##_cache, num)
253 # define SHOW_SBITS(name, gb, num)\
254 NEG_SSR32(name##_cache, num)
256 # define GET_CACHE(name, gb)\
257 ((uint32_t)name##_cache)
259 static inline int get_bits_count(GetBitContext *s){
260 return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
263 static inline void skip_bits_long(GetBitContext *s, int n){
264 OPEN_READER(re, s)
265 re_bit_count += n;
266 re_buffer_ptr += 2*(re_bit_count>>4);
267 re_bit_count &= 15;
268 re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count);
269 UPDATE_CACHE(re, s)
270 CLOSE_READER(re, s)
273 #elif defined A32_BITSTREAM_READER
275 # define MIN_CACHE_BITS 32
277 # define OPEN_READER(name, gb)\
278 int name##_bit_count=(gb)->bit_count;\
279 uint32_t name##_cache0= (gb)->cache0;\
280 uint32_t name##_cache1= (gb)->cache1;\
281 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
283 # define CLOSE_READER(name, gb)\
284 (gb)->bit_count= name##_bit_count;\
285 (gb)->cache0= name##_cache0;\
286 (gb)->cache1= name##_cache1;\
287 (gb)->buffer_ptr= name##_buffer_ptr;\
289 # define UPDATE_CACHE(name, gb)\
290 if(name##_bit_count > 0){\
291 const uint32_t next= be2me_32( *name##_buffer_ptr );\
292 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
293 name##_cache1 |= next<<name##_bit_count;\
294 name##_buffer_ptr++;\
295 name##_bit_count-= 32;\
298 #if ARCH_X86
299 # define SKIP_CACHE(name, gb, num)\
300 __asm__(\
301 "shldl %2, %1, %0 \n\t"\
302 "shll %2, %1 \n\t"\
303 : "+r" (name##_cache0), "+r" (name##_cache1)\
304 : "Ic" ((uint8_t)(num))\
306 #else
307 # define SKIP_CACHE(name, gb, num)\
308 name##_cache0 <<= (num);\
309 name##_cache0 |= NEG_USR32(name##_cache1,num);\
310 name##_cache1 <<= (num);
311 #endif
313 # define SKIP_COUNTER(name, gb, num)\
314 name##_bit_count += (num);\
316 # define SKIP_BITS(name, gb, num)\
318 SKIP_CACHE(name, gb, num)\
319 SKIP_COUNTER(name, gb, num)\
322 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
323 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
325 # define SHOW_UBITS(name, gb, num)\
326 NEG_USR32(name##_cache0, num)
328 # define SHOW_SBITS(name, gb, num)\
329 NEG_SSR32(name##_cache0, num)
331 # define GET_CACHE(name, gb)\
332 (name##_cache0)
334 static inline int get_bits_count(GetBitContext *s){
335 return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
338 static inline void skip_bits_long(GetBitContext *s, int n){
339 OPEN_READER(re, s)
340 re_bit_count += n;
341 re_buffer_ptr += re_bit_count>>5;
342 re_bit_count &= 31;
343 re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count;
344 re_cache1 = 0;
345 UPDATE_CACHE(re, s)
346 CLOSE_READER(re, s)
349 #endif
352 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
353 * if MSB not set it is negative
354 * @param n length in bits
355 * @author BERO
357 static inline int get_xbits(GetBitContext *s, int n){
358 register int sign;
359 register int32_t cache;
360 OPEN_READER(re, s)
361 UPDATE_CACHE(re, s)
362 cache = GET_CACHE(re,s);
363 sign=(~cache)>>31;
364 LAST_SKIP_BITS(re, s, n)
365 CLOSE_READER(re, s)
366 return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
369 static inline int get_sbits(GetBitContext *s, int n){
370 register int tmp;
371 OPEN_READER(re, s)
372 UPDATE_CACHE(re, s)
373 tmp= SHOW_SBITS(re, s, n);
374 LAST_SKIP_BITS(re, s, n)
375 CLOSE_READER(re, s)
376 return tmp;
380 * reads 1-17 bits.
381 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
383 static inline unsigned int get_bits(GetBitContext *s, int n){
384 register int tmp;
385 OPEN_READER(re, s)
386 UPDATE_CACHE(re, s)
387 tmp= SHOW_UBITS(re, s, n);
388 LAST_SKIP_BITS(re, s, n)
389 CLOSE_READER(re, s)
390 return tmp;
394 * shows 1-17 bits.
395 * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
397 static inline unsigned int show_bits(GetBitContext *s, int n){
398 register int tmp;
399 OPEN_READER(re, s)
400 UPDATE_CACHE(re, s)
401 tmp= SHOW_UBITS(re, s, n);
402 // CLOSE_READER(re, s)
403 return tmp;
406 static inline void skip_bits(GetBitContext *s, int n){
407 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
408 OPEN_READER(re, s)
409 UPDATE_CACHE(re, s)
410 LAST_SKIP_BITS(re, s, n)
411 CLOSE_READER(re, s)
414 static inline unsigned int get_bits1(GetBitContext *s){
415 #ifdef ALT_BITSTREAM_READER
416 int index= s->index;
417 uint8_t result= s->buffer[ index>>3 ];
418 #ifdef ALT_BITSTREAM_READER_LE
419 result>>= (index&0x07);
420 result&= 1;
421 #else
422 result<<= (index&0x07);
423 result>>= 8 - 1;
424 #endif
425 index++;
426 s->index= index;
428 return result;
429 #else
430 return get_bits(s, 1);
431 #endif
434 static inline unsigned int show_bits1(GetBitContext *s){
435 return show_bits(s, 1);
438 static inline void skip_bits1(GetBitContext *s){
439 skip_bits(s, 1);
443 * reads 0-32 bits.
445 static inline unsigned int get_bits_long(GetBitContext *s, int n){
446 if(n<=17) return get_bits(s, n);
447 else{
448 #ifdef ALT_BITSTREAM_READER_LE
449 int ret= get_bits(s, 16);
450 return ret | (get_bits(s, n-16) << 16);
451 #else
452 int ret= get_bits(s, 16) << (n-16);
453 return ret | get_bits(s, n-16);
454 #endif
459 * reads 0-32 bits as a signed integer.
461 static inline int get_sbits_long(GetBitContext *s, int n) {
462 return sign_extend(get_bits_long(s, n), n);
466 * shows 0-32 bits.
468 static inline unsigned int show_bits_long(GetBitContext *s, int n){
469 if(n<=17) return show_bits(s, n);
470 else{
471 GetBitContext gb= *s;
472 return get_bits_long(&gb, n);
476 static inline int check_marker(GetBitContext *s, const char *msg)
478 int bit= get_bits1(s);
479 if(!bit)
480 av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
482 return bit;
486 * init GetBitContext.
487 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
488 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
489 * @param bit_size the size of the buffer in bits
491 * While GetBitContext stores the buffer size, for performance reasons you are
492 * responsible for checking for the buffer end yourself (take advantage of the padding)!
494 static inline void init_get_bits(GetBitContext *s,
495 const uint8_t *buffer, int bit_size)
497 int buffer_size= (bit_size+7)>>3;
498 if(buffer_size < 0 || bit_size < 0) {
499 buffer_size = bit_size = 0;
500 buffer = NULL;
503 s->buffer= buffer;
504 s->size_in_bits= bit_size;
505 s->buffer_end= buffer + buffer_size;
506 #ifdef ALT_BITSTREAM_READER
507 s->index=0;
508 #elif defined LIBMPEG2_BITSTREAM_READER
509 s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
510 s->bit_count = 16 + 8*((intptr_t)buffer&1);
511 skip_bits_long(s, 0);
512 #elif defined A32_BITSTREAM_READER
513 s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
514 s->bit_count = 32 + 8*((intptr_t)buffer&3);
515 skip_bits_long(s, 0);
516 #endif
519 static inline void align_get_bits(GetBitContext *s)
521 int n= (-get_bits_count(s)) & 7;
522 if(n) skip_bits(s, n);
525 #define init_vlc(vlc, nb_bits, nb_codes,\
526 bits, bits_wrap, bits_size,\
527 codes, codes_wrap, codes_size,\
528 flags)\
529 init_vlc_sparse(vlc, nb_bits, nb_codes,\
530 bits, bits_wrap, bits_size,\
531 codes, codes_wrap, codes_size,\
532 NULL, 0, 0, flags)
534 int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
535 const void *bits, int bits_wrap, int bits_size,
536 const void *codes, int codes_wrap, int codes_size,
537 const void *symbols, int symbols_wrap, int symbols_size,
538 int flags);
539 #define INIT_VLC_LE 2
540 #define INIT_VLC_USE_NEW_STATIC 4
541 void free_vlc(VLC *vlc);
543 #define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\
545 static VLC_TYPE table[static_size][2];\
546 (vlc)->table= table;\
547 (vlc)->table_allocated= static_size;\
548 init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\
554 * if the vlc code is invalid and max_depth=1 than no bits will be removed
555 * if the vlc code is invalid and max_depth>1 than the number of bits removed
556 * is undefined
558 #define GET_VLC(code, name, gb, table, bits, max_depth)\
560 int n, index, nb_bits;\
562 index= SHOW_UBITS(name, gb, bits);\
563 code = table[index][0];\
564 n = table[index][1];\
566 if(max_depth > 1 && n < 0){\
567 LAST_SKIP_BITS(name, gb, bits)\
568 UPDATE_CACHE(name, gb)\
570 nb_bits = -n;\
572 index= SHOW_UBITS(name, gb, nb_bits) + code;\
573 code = table[index][0];\
574 n = table[index][1];\
575 if(max_depth > 2 && n < 0){\
576 LAST_SKIP_BITS(name, gb, nb_bits)\
577 UPDATE_CACHE(name, gb)\
579 nb_bits = -n;\
581 index= SHOW_UBITS(name, gb, nb_bits) + code;\
582 code = table[index][0];\
583 n = table[index][1];\
586 SKIP_BITS(name, gb, n)\
589 #define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
591 int n, index, nb_bits;\
593 index= SHOW_UBITS(name, gb, bits);\
594 level = table[index].level;\
595 n = table[index].len;\
597 if(max_depth > 1 && n < 0){\
598 SKIP_BITS(name, gb, bits)\
599 if(need_update){\
600 UPDATE_CACHE(name, gb)\
603 nb_bits = -n;\
605 index= SHOW_UBITS(name, gb, nb_bits) + level;\
606 level = table[index].level;\
607 n = table[index].len;\
609 run= table[index].run;\
610 SKIP_BITS(name, gb, n)\
615 * parses a vlc code, faster then get_vlc()
616 * @param bits is the number of bits which will be read at once, must be
617 * identical to nb_bits in init_vlc()
618 * @param max_depth is the number of times bits bits must be read to completely
619 * read the longest vlc code
620 * = (max_vlc_length + bits - 1) / bits
622 static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
623 int bits, int max_depth)
625 int code;
627 OPEN_READER(re, s)
628 UPDATE_CACHE(re, s)
630 GET_VLC(code, re, s, table, bits, max_depth)
632 CLOSE_READER(re, s)
633 return code;
636 //#define TRACE
638 #ifdef TRACE
639 static inline void print_bin(int bits, int n){
640 int i;
642 for(i=n-1; i>=0; i--){
643 av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
645 for(i=n; i<24; i++)
646 av_log(NULL, AV_LOG_DEBUG, " ");
649 static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
650 int r= get_bits(s, n);
652 print_bin(r, n);
653 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);
654 return r;
656 static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
657 int show= show_bits(s, 24);
658 int pos= get_bits_count(s);
659 int r= get_vlc2(s, table, bits, max_depth);
660 int len= get_bits_count(s) - pos;
661 int bits2= show>>(24-len);
663 print_bin(bits2, len);
665 av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
666 return r;
668 static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
669 int show= show_bits(s, n);
670 int r= get_xbits(s, n);
672 print_bin(show, n);
673 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);
674 return r;
677 #define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
678 #define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
679 #define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
680 #define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
681 #define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
683 #define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
685 #else //TRACE
686 #define tprintf(p, ...) {}
687 #endif
689 static inline int decode012(GetBitContext *gb){
690 int n;
691 n = get_bits1(gb);
692 if (n == 0)
693 return 0;
694 else
695 return get_bits1(gb) + 1;
698 static inline int decode210(GetBitContext *gb){
699 if (get_bits1(gb))
700 return 0;
701 else
702 return 2 - get_bits1(gb);
705 static inline int get_bits_left(GetBitContext *gb)
707 return gb->size_in_bits - get_bits_count(gb);
710 #endif /* AVCODEC_GET_BITS_H */