Mercurial > libavcodec.hg
comparison common.c @ 20:907b67420d84 libavcodec
inlineing common case of get_bits() -> gives 2speedup. more optim coming soon...
author | arpi_esp |
---|---|
date | Fri, 03 Aug 2001 23:09:15 +0000 |
parents | 1b4461b5a7fb |
children | 08265a63313e |
comparison
equal
deleted
inserted
replaced
19:82d4c9be9873 | 20:907b67420d84 |
---|---|
197 s->bit_cnt += 8; | 197 s->bit_cnt += 8; |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 /* n must be >= 1 and <= 32 */ | 201 /* n must be >= 1 and <= 32 */ |
202 unsigned int get_bits(GetBitContext *s, int n) | 202 /* also true: n > s->bit_cnt */ |
203 unsigned int get_bits_long(GetBitContext *s, int n) | |
203 { | 204 { |
204 unsigned int val; | 205 unsigned int val; |
205 int bit_cnt; | 206 int bit_cnt; |
206 unsigned int bit_buf; | 207 unsigned int bit_buf; |
207 UINT8 *buf_ptr; | |
208 | 208 |
209 #ifdef STATS | 209 #ifdef STATS |
210 st_bit_counts[st_current_index] += n; | 210 st_bit_counts[st_current_index] += n; |
211 #endif | 211 #endif |
212 | 212 |
213 bit_cnt = s->bit_cnt; | |
214 bit_buf = s->bit_buf; | 213 bit_buf = s->bit_buf; |
214 bit_cnt = s->bit_cnt - n; | |
215 | 215 |
216 bit_cnt -= n; | 216 // if (bit_cnt >= 0) { |
217 if (bit_cnt >= 0) { | 217 // val = bit_buf >> (32 - n); |
218 /* most common case here */ | 218 // bit_buf <<= n; |
219 val = bit_buf >> (32 - n); | 219 // } else |
220 bit_buf <<= n; | 220 { |
221 } else { | 221 UINT8 *buf_ptr; |
222 val = bit_buf >> (32 - n); | 222 val = bit_buf >> (32 - n); |
223 buf_ptr = s->buf_ptr; | 223 buf_ptr = s->buf_ptr; |
224 buf_ptr += 4; | 224 buf_ptr += 4; |
225 /* handle common case: we can read everything */ | 225 /* handle common case: we can read everything */ |
226 if (buf_ptr <= s->buf_end) { | 226 if (buf_ptr <= s->buf_end) { |