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.20 2004-12-05 13:56:13 syskin Exp $ |
* $Id: bitstream.h,v 1.25 2010-12-18 16:02:00 Isibaar Exp $ |
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 |
154 |
|
BitstreamWriteEndOfSequence(Bitstream * const bs); |
155 |
|
|
156 |
|
void |
157 |
|
BitstreamWriteGroupOfVopHeader(Bitstream * const bs, |
158 |
|
const MBParam * pParam, |
159 |
|
uint32_t is_closed_gov); |
160 |
|
|
161 |
|
void write_video_packet_header(Bitstream * const bs, |
162 |
|
const MBParam * pParam, |
163 |
|
const FRAMEINFO * const frame, |
164 |
|
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 |
|
/* #define XVID_SAFE_BS_TAIL */ |
175 |
|
|
176 |
/* initialise bitstream structure */ |
/* initialise bitstream structure */ |
177 |
|
|
204 |
#endif |
#endif |
205 |
bs->bufb = tmp; |
bs->bufb = tmp; |
206 |
|
|
|
bs->buf = 0; |
|
207 |
bs->pos = bs->initpos = bitpos*8; |
bs->pos = bs->initpos = bitpos*8; |
208 |
|
/* preserve the intervening bytes */ |
209 |
|
if (bs->initpos > 0) |
210 |
|
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
211 |
|
else |
212 |
|
bs->buf = 0; |
213 |
bs->length = length; |
bs->length = length; |
214 |
} |
} |
215 |
|
|
235 |
#endif |
#endif |
236 |
bs->bufb = tmp; |
bs->bufb = tmp; |
237 |
|
|
238 |
|
/* preserve the intervening bytes */ |
239 |
|
if (bs->initpos > 0) |
240 |
|
bs->buf = bs->bufa & (0xffffffff << (32 - bs->initpos)); |
241 |
|
else |
242 |
bs->buf = 0; |
bs->buf = 0; |
243 |
bs->pos = bs->initpos; |
bs->pos = bs->initpos; |
244 |
} |
} |
274 |
uint32_t tmp; |
uint32_t tmp; |
275 |
|
|
276 |
bs->bufa = bs->bufb; |
bs->bufa = bs->bufb; |
277 |
|
#if defined(XVID_SAFE_BS_TAIL) |
278 |
|
if (bs->tail<(bs->start+((bs->length+3)>>2))) |
279 |
|
#endif |
280 |
|
{ |
281 |
tmp = *((uint32_t *) bs->tail + 2); |
tmp = *((uint32_t *) bs->tail + 2); |
282 |
#ifndef ARCH_IS_BIG_ENDIAN |
#ifndef ARCH_IS_BIG_ENDIAN |
283 |
BSWAP(tmp); |
BSWAP(tmp); |
284 |
#endif |
#endif |
285 |
bs->bufb = tmp; |
bs->bufb = tmp; |
286 |
bs->tail++; |
bs->tail++; |
287 |
|
} |
288 |
|
#if defined(XVID_SAFE_BS_TAIL) |
289 |
|
else { |
290 |
|
bs->bufb = 0; |
291 |
|
} |
292 |
|
#endif |
293 |
bs->pos -= 32; |
bs->pos -= 32; |
294 |
} |
} |
295 |
} |
} |