annotate get_bits.h @ 11211:dfeaae916502 libavcodec

Since WavPack chunk can contain more samples than FFmpeg is guaranteed to hold, decode it in several iterations outputting as many samples as possible.
author kostya
date Fri, 19 Feb 2010 14:05:41 +0000
parents cd8a77473dd1
children 5401fc245167
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)
10703
3be801dcc8a1 ARM: use ALT_BITSTREAM_READER on cores with fast unaligned access
mru
parents: 10504
diff changeset
43 # if ARCH_ARM && !HAVE_FAST_UNALIGNED
9428
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 /* bit input */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
53 /* 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
54 typedef struct GetBitContext {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
55 const uint8_t *buffer, *buffer_end;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
56 #ifdef ALT_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
57 int index;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
58 #elif defined LIBMPEG2_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
59 uint8_t *buffer_ptr;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
60 uint32_t cache;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
61 int bit_count;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
62 #elif defined A32_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
63 uint32_t *buffer_ptr;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
64 uint32_t cache0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
65 uint32_t cache1;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
66 int bit_count;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
67 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
68 int size_in_bits;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
69 } GetBitContext;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
70
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
71 #define VLC_TYPE int16_t
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
72
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
73 typedef struct VLC {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
74 int bits;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
75 VLC_TYPE (*table)[2]; ///< code, bits
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
76 int table_size, table_allocated;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
77 } VLC;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
78
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
79 typedef struct RL_VLC_ELEM {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
80 int16_t level;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
81 int8_t len;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
82 uint8_t run;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
83 } RL_VLC_ELEM;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
84
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
85 /* Bitstream reader API docs:
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
86 name
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
87 arbitrary name which is used as prefix for the internal variables
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
88
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
89 gb
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
90 getbitcontext
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
91
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
92 OPEN_READER(name, gb)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
93 loads gb into local variables
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
94
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
95 CLOSE_READER(name, gb)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
96 stores local vars in gb
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
97
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
98 UPDATE_CACHE(name, gb)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
99 refills the internal cache from the bitstream
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
100 after this call at least MIN_CACHE_BITS will be available,
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 GET_CACHE(name, gb)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
103 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
104
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
105 SHOW_UBITS(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
106 will return the next num bits
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 SHOW_SBITS(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
109 will return the next num bits and do sign extension
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
110
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
111 SKIP_BITS(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
112 will skip over the next num bits
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
113 note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
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 SKIP_CACHE(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
116 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
117
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
118 SKIP_COUNTER(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
119 will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
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 LAST_SKIP_CACHE(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
122 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
123
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
124 LAST_SKIP_BITS(name, gb, num)
10163
24c03529ccbe Fix a typo in the documentation.
benoit
parents: 10148
diff changeset
125 is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
126
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
127 for examples see get_bits, show_bits, skip_bits, get_vlc
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
128 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
129
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
130 #ifdef ALT_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
131 # define MIN_CACHE_BITS 25
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
132
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
133 # define OPEN_READER(name, gb)\
10997
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
134 unsigned int name##_index= (gb)->index;\
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
135 int name##_cache= 0;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
136
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
137 # define CLOSE_READER(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
138 (gb)->index= name##_index;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
139
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
140 # ifdef ALT_BITSTREAM_READER_LE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
141 # define UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
142 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
143
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
144 # define SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
145 name##_cache >>= (num);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
146 # else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
147 # define UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
148 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
149
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
150 # define SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
151 name##_cache <<= (num);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
152 # endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
153
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
154 // FIXME name?
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
155 # define SKIP_COUNTER(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
156 name##_index += (num);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
157
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
158 # define SKIP_BITS(name, gb, num)\
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 SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
161 SKIP_COUNTER(name, gb, num)\
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
164 # define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
165 # define LAST_SKIP_CACHE(name, gb, num) ;
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 # ifdef ALT_BITSTREAM_READER_LE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
168 # define SHOW_UBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
169 ((name##_cache) & (NEG_USR32(0xffffffff,num)))
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
170
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
171 # define SHOW_SBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
172 NEG_SSR32((name##_cache)<<(32-(num)), num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
173 # else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
174 # define SHOW_UBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
175 NEG_USR32(name##_cache, num)
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 # define SHOW_SBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
178 NEG_SSR32(name##_cache, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
179 # endif
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 GET_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
182 ((uint32_t)name##_cache)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
183
10986
4289d95e5022 Added missing const to get_bits_count().
fenrir
parents: 10703
diff changeset
184 static inline int get_bits_count(const GetBitContext *s){
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
185 return s->index;
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
188 static inline void skip_bits_long(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
189 s->index += n;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
190 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
191
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
192 #elif defined LIBMPEG2_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
193 //libmpeg2 like reader
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
194
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
195 # define MIN_CACHE_BITS 17
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
196
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
197 # define OPEN_READER(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
198 int name##_bit_count=(gb)->bit_count;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
199 int name##_cache= (gb)->cache;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
200 uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
201
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
202 # define CLOSE_READER(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
203 (gb)->bit_count= name##_bit_count;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
204 (gb)->cache= name##_cache;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
205 (gb)->buffer_ptr= name##_buffer_ptr;\
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 # define UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
208 if(name##_bit_count >= 0){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
209 name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
210 name##_buffer_ptr+=2;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
211 name##_bit_count-= 16;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
212 }\
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 # define SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
215 name##_cache <<= (num);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
216
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
217 # define SKIP_COUNTER(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
218 name##_bit_count += (num);\
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 SKIP_BITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
221 {\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
222 SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
223 SKIP_COUNTER(name, gb, num)\
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
226 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
227 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
228
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
229 # define SHOW_UBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
230 NEG_USR32(name##_cache, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
231
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
232 # define SHOW_SBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
233 NEG_SSR32(name##_cache, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
234
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
235 # define GET_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
236 ((uint32_t)name##_cache)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
237
10986
4289d95e5022 Added missing const to get_bits_count().
fenrir
parents: 10703
diff changeset
238 static inline int get_bits_count(const GetBitContext *s){
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
239 return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
240 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
241
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
242 static inline void skip_bits_long(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
243 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
244 re_bit_count += n;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
245 re_buffer_ptr += 2*(re_bit_count>>4);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
246 re_bit_count &= 15;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
247 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
248 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
249 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
250 }
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 #elif defined A32_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
253
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
254 # define MIN_CACHE_BITS 32
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
255
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
256 # define OPEN_READER(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
257 int name##_bit_count=(gb)->bit_count;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
258 uint32_t name##_cache0= (gb)->cache0;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
259 uint32_t name##_cache1= (gb)->cache1;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
260 uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
261
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
262 # define CLOSE_READER(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
263 (gb)->bit_count= name##_bit_count;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
264 (gb)->cache0= name##_cache0;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
265 (gb)->cache1= name##_cache1;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
266 (gb)->buffer_ptr= name##_buffer_ptr;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
267
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
268 # define UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
269 if(name##_bit_count > 0){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
270 const uint32_t next= be2me_32( *name##_buffer_ptr );\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
271 name##_cache0 |= NEG_USR32(next,name##_bit_count);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
272 name##_cache1 |= next<<name##_bit_count;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
273 name##_buffer_ptr++;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
274 name##_bit_count-= 32;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
275 }\
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 #if ARCH_X86
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
278 # define SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
279 __asm__(\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
280 "shldl %2, %1, %0 \n\t"\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
281 "shll %2, %1 \n\t"\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
282 : "+r" (name##_cache0), "+r" (name##_cache1)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
283 : "Ic" ((uint8_t)(num))\
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 #else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
286 # define SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
287 name##_cache0 <<= (num);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
288 name##_cache0 |= NEG_USR32(name##_cache1,num);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
289 name##_cache1 <<= (num);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
290 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
291
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
292 # define SKIP_COUNTER(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
293 name##_bit_count += (num);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
294
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
295 # define SKIP_BITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
296 {\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
297 SKIP_CACHE(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
298 SKIP_COUNTER(name, gb, num)\
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
301 # define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
302 # define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
303
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
304 # define SHOW_UBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
305 NEG_USR32(name##_cache0, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
306
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
307 # define SHOW_SBITS(name, gb, num)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
308 NEG_SSR32(name##_cache0, num)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
309
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
310 # define GET_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
311 (name##_cache0)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
312
10986
4289d95e5022 Added missing const to get_bits_count().
fenrir
parents: 10703
diff changeset
313 static inline int get_bits_count(const GetBitContext *s){
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
314 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
315 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
316
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
317 static inline void skip_bits_long(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
318 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
319 re_bit_count += n;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
320 re_buffer_ptr += re_bit_count>>5;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
321 re_bit_count &= 31;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
322 re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
323 re_cache1 = 0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
324 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
325 CLOSE_READER(re, s)
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
328 #endif
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 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
331 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
332 * if MSB not set it is negative
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
333 * @param n length in bits
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
334 * @author BERO
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_xbits(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
337 register int sign;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
338 register int32_t cache;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
339 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
340 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
341 cache = GET_CACHE(re,s);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
342 sign=(~cache)>>31;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
343 LAST_SKIP_BITS(re, s, n)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
344 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
345 return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
346 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
347
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
348 static inline int get_sbits(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
349 register int tmp;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
350 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
351 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
352 tmp= SHOW_SBITS(re, s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
353 LAST_SKIP_BITS(re, s, n)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
354 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
355 return tmp;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
356 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
357
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 * reads 1-17 bits.
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
360 * 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
361 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
362 static inline unsigned int get_bits(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
363 register int tmp;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
364 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
365 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
366 tmp= SHOW_UBITS(re, s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
367 LAST_SKIP_BITS(re, s, n)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
368 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
369 return tmp;
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
372 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
373 * shows 1-17 bits.
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
374 * 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
375 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
376 static inline unsigned int show_bits(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
377 register int tmp;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
378 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
379 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
380 tmp= SHOW_UBITS(re, s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
381 // CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
382 return tmp;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
383 }
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 void skip_bits(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
386 //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
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 LAST_SKIP_BITS(re, s, n)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
390 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
391 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
392
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
393 static inline unsigned int get_bits1(GetBitContext *s){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
394 #ifdef ALT_BITSTREAM_READER
10997
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
395 unsigned int index= s->index;
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
396 uint8_t result= s->buffer[ index>>3 ];
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
397 #ifdef ALT_BITSTREAM_READER_LE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
398 result>>= (index&0x07);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
399 result&= 1;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
400 #else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
401 result<<= (index&0x07);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
402 result>>= 8 - 1;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
403 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
404 index++;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
405 s->index= index;
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 return result;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
408 #else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
409 return get_bits(s, 1);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
410 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
411 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
412
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
413 static inline unsigned int show_bits1(GetBitContext *s){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
414 return show_bits(s, 1);
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
417 static inline void skip_bits1(GetBitContext *s){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
418 skip_bits(s, 1);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
419 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
420
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
421 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
422 * reads 0-32 bits.
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
423 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
424 static inline unsigned int get_bits_long(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
425 if(n<=17) return get_bits(s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
426 else{
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
427 #ifdef ALT_BITSTREAM_READER_LE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
428 int ret= get_bits(s, 16);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
429 return ret | (get_bits(s, n-16) << 16);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
430 #else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
431 int ret= get_bits(s, 16) << (n-16);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
432 return ret | get_bits(s, n-16);
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
437 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
438 * reads 0-32 bits as a signed integer.
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 int get_sbits_long(GetBitContext *s, int n) {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
441 return sign_extend(get_bits_long(s, n), n);
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 * shows 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 show_bits_long(GetBitContext *s, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
448 if(n<=17) return show_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 GetBitContext gb= *s;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
451 return get_bits_long(&gb, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
452 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
453 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
454
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
455 static inline int check_marker(GetBitContext *s, const char *msg)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
456 {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
457 int bit= get_bits1(s);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
458 if(!bit)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
459 av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
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 return bit;
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
464 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
465 * init GetBitContext.
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
466 * @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
467 * 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
468 * @param bit_size the size of the buffer in bits
10148
732dfbf67524 Try to clarify that anyone using get_bits must check for buffer overrun
reimar
parents: 9428
diff changeset
469 *
732dfbf67524 Try to clarify that anyone using get_bits must check for buffer overrun
reimar
parents: 9428
diff changeset
470 * While GetBitContext stores the buffer size, for performance reasons you are
732dfbf67524 Try to clarify that anyone using get_bits must check for buffer overrun
reimar
parents: 9428
diff changeset
471 * responsible for checking for the buffer end yourself (take advantage of the padding)!
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
472 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
473 static inline void init_get_bits(GetBitContext *s,
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
474 const uint8_t *buffer, int bit_size)
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 int buffer_size= (bit_size+7)>>3;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
477 if(buffer_size < 0 || bit_size < 0) {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
478 buffer_size = bit_size = 0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
479 buffer = NULL;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
480 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
481
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
482 s->buffer= buffer;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
483 s->size_in_bits= bit_size;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
484 s->buffer_end= buffer + buffer_size;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
485 #ifdef ALT_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
486 s->index=0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
487 #elif defined LIBMPEG2_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
488 s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
489 s->bit_count = 16 + 8*((intptr_t)buffer&1);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
490 skip_bits_long(s, 0);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
491 #elif defined A32_BITSTREAM_READER
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
492 s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
493 s->bit_count = 32 + 8*((intptr_t)buffer&3);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
494 skip_bits_long(s, 0);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
495 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
496 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
497
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
498 static inline void align_get_bits(GetBitContext *s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
499 {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
500 int n= (-get_bits_count(s)) & 7;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
501 if(n) skip_bits(s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
502 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
503
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
504 #define init_vlc(vlc, nb_bits, nb_codes,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
505 bits, bits_wrap, bits_size,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
506 codes, codes_wrap, codes_size,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
507 flags)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
508 init_vlc_sparse(vlc, nb_bits, nb_codes,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
509 bits, bits_wrap, bits_size,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
510 codes, codes_wrap, codes_size,\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
511 NULL, 0, 0, flags)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
512
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
513 int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
514 const void *bits, int bits_wrap, int bits_size,
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
515 const void *codes, int codes_wrap, int codes_size,
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
516 const void *symbols, int symbols_wrap, int symbols_size,
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
517 int flags);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
518 #define INIT_VLC_LE 2
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
519 #define INIT_VLC_USE_NEW_STATIC 4
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
520 void free_vlc(VLC *vlc);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
521
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
522 #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
523 {\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
524 static VLC_TYPE table[static_size][2];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
525 (vlc)->table= table;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
526 (vlc)->table_allocated= static_size;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
527 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
528 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
529
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
530
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
531 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
532 *
11197
87bcae769ee7 get_bits: Fix spelling and grammar in GET_VLC() comment.
alexc
parents: 10997
diff changeset
533 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
87bcae769ee7 get_bits: Fix spelling and grammar in GET_VLC() comment.
alexc
parents: 10997
diff changeset
534 * If the vlc code is invalid and max_depth>1, then the number of bits removed
87bcae769ee7 get_bits: Fix spelling and grammar in GET_VLC() comment.
alexc
parents: 10997
diff changeset
535 * is undefined.
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
536 */
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
537 #define GET_VLC(code, name, gb, table, bits, max_depth)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
538 {\
10997
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
539 int n, nb_bits;\
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
540 unsigned int index;\
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
541 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
542 index= SHOW_UBITS(name, gb, bits);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
543 code = table[index][0];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
544 n = table[index][1];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
545 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
546 if(max_depth > 1 && n < 0){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
547 LAST_SKIP_BITS(name, gb, bits)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
548 UPDATE_CACHE(name, gb)\
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 nb_bits = -n;\
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 index= SHOW_UBITS(name, gb, nb_bits) + code;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
553 code = table[index][0];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
554 n = table[index][1];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
555 if(max_depth > 2 && n < 0){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
556 LAST_SKIP_BITS(name, gb, nb_bits)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
557 UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
558 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
559 nb_bits = -n;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
560 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
561 index= SHOW_UBITS(name, gb, nb_bits) + code;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
562 code = table[index][0];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
563 n = table[index][1];\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
564 }\
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 SKIP_BITS(name, gb, n)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
567 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
568
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
569 #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
570 {\
10997
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
571 int n, nb_bits;\
9bd48e510bef Mark index as unsigend so gcc knows it doesnt need a sign extension on x86_64.
michael
parents: 10986
diff changeset
572 unsigned int index;\
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
573 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
574 index= SHOW_UBITS(name, gb, bits);\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
575 level = table[index].level;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
576 n = table[index].len;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
577 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
578 if(max_depth > 1 && n < 0){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
579 SKIP_BITS(name, gb, bits)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
580 if(need_update){\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
581 UPDATE_CACHE(name, gb)\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
582 }\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
583 \
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
584 nb_bits = -n;\
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 index= SHOW_UBITS(name, gb, nb_bits) + level;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
587 level = table[index].level;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
588 n = table[index].len;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
589 }\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
590 run= table[index].run;\
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
591 SKIP_BITS(name, gb, n)\
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
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
594
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
595 /**
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
596 * parses a vlc code, faster then get_vlc()
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
597 * @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
598 * identical to nb_bits in init_vlc()
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
599 * @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
600 * read the longest vlc code
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
601 * = (max_vlc_length + bits - 1) / bits
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 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
604 int bits, int max_depth)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
605 {
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
606 int code;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
607
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
608 OPEN_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
609 UPDATE_CACHE(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
610
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
611 GET_VLC(code, re, s, table, bits, max_depth)
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 CLOSE_READER(re, s)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
614 return code;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
615 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
616
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
617 //#define TRACE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
618
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
619 #ifdef TRACE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
620 static inline void print_bin(int bits, int n){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
621 int i;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
622
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
623 for(i=n-1; i>=0; i--){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
624 av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
625 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
626 for(i=n; i<24; i++)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
627 av_log(NULL, AV_LOG_DEBUG, " ");
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
628 }
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 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
631 int r= get_bits(s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
632
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
633 print_bin(r, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
634 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
635 return r;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
636 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
637 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
638 int show= show_bits(s, 24);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
639 int pos= get_bits_count(s);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
640 int r= get_vlc2(s, table, bits, max_depth);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
641 int len= get_bits_count(s) - pos;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
642 int bits2= show>>(24-len);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
643
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
644 print_bin(bits2, len);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
645
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
646 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
647 return r;
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_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
650 int show= show_bits(s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
651 int r= get_xbits(s, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
652
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
653 print_bin(show, n);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
654 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
655 return r;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
656 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
657
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
658 #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
659 #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
660 #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
661 #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
662 #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
663
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
664 #define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
665
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
666 #else //TRACE
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
667 #define tprintf(p, ...) {}
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
668 #endif
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
669
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
670 static inline int decode012(GetBitContext *gb){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
671 int n;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
672 n = get_bits1(gb);
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
673 if (n == 0)
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
674 return 0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
675 else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
676 return get_bits1(gb) + 1;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
677 }
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
678
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
679 static inline int decode210(GetBitContext *gb){
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
680 if (get_bits1(gb))
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
681 return 0;
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
682 else
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
683 return 2 - get_bits1(gb);
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
10504
9f16f997c41b Make get_bits_left() available for use in libavcodec (was previously held
rbultje
parents: 10501
diff changeset
686 static inline int get_bits_left(GetBitContext *gb)
9f16f997c41b Make get_bits_left() available for use in libavcodec (was previously held
rbultje
parents: 10501
diff changeset
687 {
9f16f997c41b Make get_bits_left() available for use in libavcodec (was previously held
rbultje
parents: 10501
diff changeset
688 return gb->size_in_bits - get_bits_count(gb);
9f16f997c41b Make get_bits_left() available for use in libavcodec (was previously held
rbultje
parents: 10501
diff changeset
689 }
9f16f997c41b Make get_bits_left() available for use in libavcodec (was previously held
rbultje
parents: 10501
diff changeset
690
9428
0dce4fe6e6f3 Rename bitstream.h to get_bits.h.
stefano
parents:
diff changeset
691 #endif /* AVCODEC_GET_BITS_H */