19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: bitstream.h,v 1.21 2005-05-17 21:03:32 Skal Exp $ |
* $Id$ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
137 |
|
|
138 |
void BitstreamWriteVolHeader(Bitstream * const bs, |
void BitstreamWriteVolHeader(Bitstream * const bs, |
139 |
const MBParam * pParam, |
const MBParam * pParam, |
140 |
const FRAMEINFO * const frame); |
const FRAMEINFO * const frame, |
141 |
|
const int num_slices); |
142 |
|
|
143 |
void BitstreamWriteVopHeader(Bitstream * const bs, |
void BitstreamWriteVopHeader(Bitstream * const bs, |
144 |
const MBParam * pParam, |
const MBParam * pParam, |
147 |
unsigned int quant); |
unsigned int quant); |
148 |
|
|
149 |
void BitstreamWriteUserData(Bitstream * const bs, |
void BitstreamWriteUserData(Bitstream * const bs, |
150 |
uint8_t * data, |
const char *data, |
151 |
const int length); |
const unsigned int length); |
152 |
|
|
153 |
void |
void |
154 |
BitstreamWriteEndOfSequence(Bitstream * const bs); |
BitstreamWriteEndOfSequence(Bitstream * const bs); |
155 |
|
|
163 |
const FRAMEINFO * const frame, |
const FRAMEINFO * const frame, |
164 |
int mbnum); |
int mbnum); |
165 |
|
|
166 |
|
/***************************************************************************** |
167 |
|
* Bitstream |
168 |
|
****************************************************************************/ |
169 |
|
|
170 |
|
/* Input buffer should be readable as full chunks of 8bytes, including |
171 |
|
the end of the buffer. Padding might be appropriate. If only chunks |
172 |
|
of 4bytes are applicable, define XVID_SAFE_BS_TAIL. Note that this will |
173 |
|
slow decoding, so consider this as a last-resort solution */ |
174 |
|
#ifndef XVID_HAVE_PADDED_BS_BUFFER |
175 |
|
#define XVID_SAFE_BS_TAIL |
176 |
|
#endif |
177 |
|
|
178 |
/* initialise bitstream structure */ |
/* initialise bitstream structure */ |
179 |
|
|
180 |
static void __inline |
static void __inline |
206 |
#endif |
#endif |
207 |
bs->bufb = tmp; |
bs->bufb = tmp; |
208 |
|
|
209 |
|
bs->pos = bs->initpos = (uint32_t) bitpos*8; |
210 |
|
/* preserve the intervening bytes */ |
211 |
|
if (bs->initpos > 0) |
212 |
|
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
213 |
|
else |
214 |
bs->buf = 0; |
bs->buf = 0; |
|
bs->pos = bs->initpos = bitpos*8; |
|
215 |
bs->length = length; |
bs->length = length; |
216 |
} |
} |
217 |
|
|
237 |
#endif |
#endif |
238 |
bs->bufb = tmp; |
bs->bufb = tmp; |
239 |
|
|
240 |
|
/* preserve the intervening bytes */ |
241 |
|
if (bs->initpos > 0) |
242 |
|
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
243 |
|
else |
244 |
bs->buf = 0; |
bs->buf = 0; |
245 |
bs->pos = bs->initpos; |
bs->pos = bs->initpos; |
246 |
} |
} |
276 |
uint32_t tmp; |
uint32_t tmp; |
277 |
|
|
278 |
bs->bufa = bs->bufb; |
bs->bufa = bs->bufb; |
279 |
|
#if defined(XVID_SAFE_BS_TAIL) |
280 |
|
if (bs->tail<(bs->start+((bs->length+3)>>2))) |
281 |
|
#endif |
282 |
|
{ |
283 |
tmp = *((uint32_t *) bs->tail + 2); |
tmp = *((uint32_t *) bs->tail + 2); |
284 |
#ifndef ARCH_IS_BIG_ENDIAN |
#ifndef ARCH_IS_BIG_ENDIAN |
285 |
BSWAP(tmp); |
BSWAP(tmp); |
286 |
#endif |
#endif |
287 |
bs->bufb = tmp; |
bs->bufb = tmp; |
288 |
bs->tail++; |
bs->tail++; |
289 |
|
} |
290 |
|
#if defined(XVID_SAFE_BS_TAIL) |
291 |
|
else { |
292 |
|
bs->bufb = 0; |
293 |
|
} |
294 |
|
#endif |
295 |
bs->pos -= 32; |
bs->pos -= 32; |
296 |
} |
} |
297 |
} |
} |