41 |
* * |
* * |
42 |
* Revision history: * |
* Revision history: * |
43 |
* * |
* * |
44 |
* 26.03.2002 interlacing support - modified putvol/vopheaders paramters |
* 28.06.2002 addded BitstreamNumBitsToByteAlign() * |
45 |
|
* BitstreamShowBitsFromByteAlign() * |
46 |
|
* 26.03.2002 interlacing support - modified putvol/vopheaders paramters * |
47 |
* 04.03.2002 putbits speedup (Isibaar) * |
* 04.03.2002 putbits speedup (Isibaar) * |
48 |
* 03.03.2002 merged BITREADER and BITWRITER (Isibaar) * |
* 03.03.2002 merged BITREADER and BITWRITER (Isibaar) * |
49 |
* 16.12.2001 inital version * |
* 16.12.2001 inital version * |
82 |
//#define VIDOBJLAY_TYPE_SIMPLE_SCALABLE 2 |
//#define VIDOBJLAY_TYPE_SIMPLE_SCALABLE 2 |
83 |
#define VIDOBJLAY_TYPE_CORE 3 |
#define VIDOBJLAY_TYPE_CORE 3 |
84 |
#define VIDOBJLAY_TYPE_MAIN 4 |
#define VIDOBJLAY_TYPE_MAIN 4 |
85 |
|
//#define VIDOBJLAY_TYPE_NBIT 5 |
86 |
|
//#define VIDOBJLAY_TYPE_ANIM_TEXT 6 |
87 |
|
//#define VIDOBJLAY_TYPE_ANIM_MESH 7 |
88 |
|
//#define VIDOBJLAY_TYPE_SIMPLE_FACE 8 |
89 |
|
//#define VIDOBJLAY_TYPE_STILL_SCALABLE 9 |
90 |
|
#define VIDOBJLAY_TYPE_ART_SIMPLE 10 |
91 |
|
//#define VIDOBJLAY_TYPE_CORE_SCALABLE 11 |
92 |
|
#define VIDOBJLAY_TYPE_ACE 12 |
93 |
|
//#define VIDOBJLAY_TYPE_SIMPLE_FBA 13 |
94 |
|
|
95 |
|
|
96 |
//#define VIDOBJLAY_AR_SQUARE 1 |
//#define VIDOBJLAY_AR_SQUARE 1 |
106 |
#define VIDOBJLAY_SHAPE_BINARY_ONLY 2 |
#define VIDOBJLAY_SHAPE_BINARY_ONLY 2 |
107 |
#define VIDOBJLAY_SHAPE_GRAYSCALE 3 |
#define VIDOBJLAY_SHAPE_GRAYSCALE 3 |
108 |
|
|
109 |
|
|
110 |
|
#define SPRITE_NONE 0 |
111 |
|
#define SPRITE_STATIC 1 |
112 |
|
#define SPRITE_GMC 2 |
113 |
|
|
114 |
|
|
115 |
#define VO_START_CODE 0x8 |
#define VO_START_CODE 0x8 |
116 |
#define VOL_START_CODE 0x12 |
#define VOL_START_CODE 0x12 |
117 |
#define VOP_START_CODE 0x1b6 |
#define VOP_START_CODE 0x1b6 |
127 |
#define S_VOP 3 |
#define S_VOP 3 |
128 |
#define N_VOP 4 |
#define N_VOP 4 |
129 |
|
|
130 |
|
// resync-specific |
131 |
|
#define NUMBITS_VP_RESYNC_MARKER 17 |
132 |
|
#define RESYNC_MARKER 1 |
133 |
|
|
134 |
|
|
135 |
|
int read_video_packet_header(Bitstream *bs, |
136 |
|
DECODER * dec, |
137 |
|
const int addbits, |
138 |
|
int * quant, |
139 |
|
int * fcode_forward, |
140 |
|
int * fcode_backward, |
141 |
|
int * intra_dc_threshold); |
142 |
|
|
143 |
|
|
144 |
// header stuff |
// header stuff |
145 |
int BitstreamReadHeaders(Bitstream * bs, |
int BitstreamReadHeaders(Bitstream * bs, |
146 |
DECODER * dec, |
DECODER * dec, |
147 |
uint32_t * rounding, |
uint32_t * rounding, |
148 |
|
uint32_t * reduced_resolution, |
149 |
uint32_t * quant, |
uint32_t * quant, |
150 |
uint32_t * fcode_forward, |
uint32_t * fcode_forward, |
151 |
uint32_t * fcode_backward, |
uint32_t * fcode_backward, |
152 |
uint32_t * intra_dc_threshold); |
uint32_t * intra_dc_threshold, |
153 |
|
VECTOR * gmc_mv); |
154 |
|
|
155 |
|
|
156 |
void BitstreamWriteVolHeader(Bitstream * const bs, |
void BitstreamWriteVolHeader(Bitstream * const bs, |
157 |
const MBParam * pParam, |
const MBParam * pParam, |
158 |
const FRAMEINFO * frame); |
const FRAMEINFO * const frame); |
159 |
|
|
160 |
void BitstreamWriteVopHeader(Bitstream * const bs, |
void BitstreamWriteVopHeader(Bitstream * const bs, |
161 |
const MBParam * pParam, |
const MBParam * pParam, |
162 |
const FRAMEINFO * frame); |
const FRAMEINFO * const frame, |
163 |
|
int vop_coded); |
164 |
|
|
165 |
|
void BitstreamWriteUserData(Bitstream * const bs, |
166 |
|
uint8_t * data, |
167 |
|
const int length); |
168 |
|
|
169 |
/* initialise bitstream structure */ |
/* initialise bitstream structure */ |
170 |
|
|
262 |
} |
} |
263 |
|
|
264 |
|
|
265 |
|
// number of bits to next byte alignment |
266 |
|
static __inline uint32_t |
267 |
|
BitstreamNumBitsToByteAlign(Bitstream *bs) |
268 |
|
{ |
269 |
|
uint32_t n = (32 - bs->pos) % 8; |
270 |
|
return n == 0 ? 8 : n; |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
// show nbits from next byte alignment |
275 |
|
static __inline uint32_t |
276 |
|
BitstreamShowBitsFromByteAlign(Bitstream *bs, int bits) |
277 |
|
{ |
278 |
|
int bspos = bs->pos + BitstreamNumBitsToByteAlign(bs); |
279 |
|
int nbit = (bits + bspos) - 32; |
280 |
|
|
281 |
|
if (bspos >= 32) { |
282 |
|
return bs->bufb >> (32 - nbit); |
283 |
|
} else if (nbit > 0) { |
284 |
|
return ((bs->bufa & (0xffffffff >> bspos)) << nbit) | (bs-> |
285 |
|
bufb >> (32 - |
286 |
|
nbit)); |
287 |
|
} else { |
288 |
|
return (bs->bufa & (0xffffffff >> bspos)) >> (32 - bspos - bits); |
289 |
|
} |
290 |
|
|
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
/* move forward to the next byte boundary */ |
/* move forward to the next byte boundary */ |
296 |
|
|
297 |
static __inline void |
static __inline void |
359 |
} |
} |
360 |
|
|
361 |
|
|
|
/* pad bitstream to the next byte boundary */ |
|
|
|
|
|
static void __inline |
|
|
BitstreamPad(Bitstream * const bs) |
|
|
{ |
|
|
uint32_t remainder = bs->pos % 8; |
|
|
|
|
|
if (remainder) { |
|
|
BitstreamForward(bs, 8 - remainder); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
362 |
/* read n bits from bitstream */ |
/* read n bits from bitstream */ |
363 |
|
|
364 |
static uint32_t __inline |
static uint32_t __inline |
421 |
} |
} |
422 |
} |
} |
423 |
|
|
424 |
|
|
425 |
|
static const int stuffing_codes[8] = |
426 |
|
{ |
427 |
|
/* nbits stuffing code */ |
428 |
|
0, /* 1 0 */ |
429 |
|
1, /* 2 01 */ |
430 |
|
3, /* 3 011 */ |
431 |
|
7, /* 4 0111 */ |
432 |
|
0xf, /* 5 01111 */ |
433 |
|
0x1f, /* 6 011111 */ |
434 |
|
0x3f, /* 7 0111111 */ |
435 |
|
0x7f, /* 8 01111111 */ |
436 |
|
}; |
437 |
|
|
438 |
|
/* pad bitstream to the next byte boundary */ |
439 |
|
|
440 |
|
static void __inline |
441 |
|
BitstreamPad(Bitstream * const bs) |
442 |
|
{ |
443 |
|
int bits = 8 - (bs->pos % 8); |
444 |
|
if (bits < 8) |
445 |
|
{ |
446 |
|
BitstreamPutBits(bs, stuffing_codes[bits - 1], bits); |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
|
/* pad bitstream to the next byte boundary |
452 |
|
alway pad: even if currently at the byte boundary */ |
453 |
|
|
454 |
|
static void __inline |
455 |
|
BitstreamPadAlways(Bitstream * const bs) |
456 |
|
{ |
457 |
|
int bits = 8 - (bs->pos % 8); |
458 |
|
BitstreamPutBits(bs, stuffing_codes[bits - 1], bits); |
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
#endif /* _BITSTREAM_H_ */ |
#endif /* _BITSTREAM_H_ */ |