Mercurial > libavcodec.hg
comparison common.c @ 1257:6defe392d5d2 libavcodec
libmpeg2 style bitstream reader fixes
author | michaelni |
---|---|
date | Wed, 14 May 2003 10:55:59 +0000 |
parents | 604661d34c68 |
children | 9fce515e9894 |
comparison
equal
deleted
inserted
replaced
1256:b8e1c17b8d7d | 1257:6defe392d5d2 |
---|---|
138 s->size_in_bits= bit_size; | 138 s->size_in_bits= bit_size; |
139 s->buffer_end= buffer + buffer_size; | 139 s->buffer_end= buffer + buffer_size; |
140 #ifdef ALT_BITSTREAM_READER | 140 #ifdef ALT_BITSTREAM_READER |
141 s->index=0; | 141 s->index=0; |
142 #elif defined LIBMPEG2_BITSTREAM_READER | 142 #elif defined LIBMPEG2_BITSTREAM_READER |
143 #ifdef LIBMPEG2_BITSTREAM_HACK | 143 #ifdef LIBMPEG2_BITSTREAM_READER_HACK |
144 if ((int)buffer&1) { | 144 if ((int)buffer&1) { |
145 /* word alignment */ | 145 /* word alignment */ |
146 s->cache = (*buffer++)<<24; | 146 s->cache = (*buffer++)<<24; |
147 s->buffer_ptr = buffer; | 147 s->buffer_ptr = buffer; |
148 s->bit_count = 16-8; | 148 s->bit_count = 16-8; |
166 CLOSE_READER(re, s) | 166 CLOSE_READER(re, s) |
167 } | 167 } |
168 #ifdef A32_BITSTREAM_READER | 168 #ifdef A32_BITSTREAM_READER |
169 s->cache1 = 0; | 169 s->cache1 = 0; |
170 #endif | 170 #endif |
171 } | |
172 | |
173 /** | |
174 * reads 0-32 bits. | |
175 */ | |
176 unsigned int get_bits_long(GetBitContext *s, int n){ | |
177 if(n<=17) return get_bits(s, n); | |
178 else{ | |
179 int ret= get_bits(s, 16) << (n-16); | |
180 return ret | get_bits(s, n-16); | |
181 } | |
182 } | |
183 | |
184 /** | |
185 * shows 0-32 bits. | |
186 */ | |
187 unsigned int show_bits_long(GetBitContext *s, int n){ | |
188 if(n<=17) return show_bits(s, n); | |
189 else{ | |
190 GetBitContext gb= *s; | |
191 int ret= get_bits_long(s, n); | |
192 *s= gb; | |
193 return ret; | |
194 } | |
171 } | 195 } |
172 | 196 |
173 void align_get_bits(GetBitContext *s) | 197 void align_get_bits(GetBitContext *s) |
174 { | 198 { |
175 int n= (-get_bits_count(s)) & 7; | 199 int n= (-get_bits_count(s)) & 7; |