162 |
const FRAMEINFO * const frame, |
const FRAMEINFO * const frame, |
163 |
int mbnum); |
int mbnum); |
164 |
|
|
165 |
|
/***************************************************************************** |
166 |
|
* Bitstream |
167 |
|
****************************************************************************/ |
168 |
|
|
169 |
|
/* Input buffer should be readable as full chunks of 8bytes, including |
170 |
|
the end of the buffer. Padding might be appropriate. If only chunks |
171 |
|
of 4bytes are applicable, define XVID_SAFE_BS_TAIL. Note that this will |
172 |
|
slow decoding, so consider this as a last-resort solution */ |
173 |
|
/* #define XVID_SAFE_BS_TAIL */ |
174 |
|
|
175 |
/* initialise bitstream structure */ |
/* initialise bitstream structure */ |
176 |
|
|
177 |
static void __inline |
static void __inline |
203 |
#endif |
#endif |
204 |
bs->bufb = tmp; |
bs->bufb = tmp; |
205 |
|
|
206 |
|
bs->pos = bs->initpos = bitpos*8; |
207 |
/* preserve the intervening bytes */ |
/* preserve the intervening bytes */ |
208 |
if (bs->initpos > 0) |
if (bs->initpos > 0) |
209 |
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
210 |
else |
else |
211 |
bs->buf = 0; |
bs->buf = 0; |
|
|
|
|
bs->pos = bs->initpos = bitpos*8; |
|
212 |
bs->length = length; |
bs->length = length; |
213 |
} |
} |
214 |
|
|
239 |
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
240 |
else |
else |
241 |
bs->buf = 0; |
bs->buf = 0; |
|
|
|
242 |
bs->pos = bs->initpos; |
bs->pos = bs->initpos; |
243 |
} |
} |
244 |
|
|
273 |
uint32_t tmp; |
uint32_t tmp; |
274 |
|
|
275 |
bs->bufa = bs->bufb; |
bs->bufa = bs->bufb; |
276 |
|
#if defined(XVID_SAFE_BS_TAIL) |
277 |
|
if (bs->tail<(bs->start+((bs->length+3)>>2))) |
278 |
|
#endif |
279 |
|
{ |
280 |
tmp = *((uint32_t *) bs->tail + 2); |
tmp = *((uint32_t *) bs->tail + 2); |
281 |
#ifndef ARCH_IS_BIG_ENDIAN |
#ifndef ARCH_IS_BIG_ENDIAN |
282 |
BSWAP(tmp); |
BSWAP(tmp); |
283 |
#endif |
#endif |
284 |
bs->bufb = tmp; |
bs->bufb = tmp; |
285 |
bs->tail++; |
bs->tail++; |
286 |
|
} |
287 |
|
#if defined(XVID_SAFE_BS_TAIL) |
288 |
|
else { |
289 |
|
bs->bufb = 0; |
290 |
|
} |
291 |
|
#endif |
292 |
bs->pos -= 32; |
bs->pos -= 32; |
293 |
} |
} |
294 |
} |
} |