annotate get_bits.h @ 9649:2d4718adf588 libavcodec

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