3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Bitstream reader/writer inlined functions and constants- |
* - Bitstream reader/writer inlined functions and constants- |
5 |
* |
* |
6 |
* Copyright (C) 2001-2002 - Peter Ross <pross@cs.rmit.edu.au> |
* Copyright (C) 2001-2002 - Peter Ross <pross@xvid.org> |
7 |
* |
* |
8 |
* This program is an implementation of a part of one or more MPEG-4 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
|
|
* to use this software module in hardware or software products are |
|
|
* advised that its use may infringe existing patents or copyrights, and |
|
|
* any such use would be at such party's own risk. The original |
|
|
* developer of this software module and his/her company, and subsequent |
|
|
* editors and their companies, will have no liability for use of this |
|
|
* software or modifications or derivatives thereof. |
|
9 |
* |
* |
10 |
* This program is free software ; you can redistribute it and/or modify |
* XviD is free software; you can redistribute it and/or modify it |
11 |
* it under the terms of the GNU General Public License as published by |
* under the terms of the GNU General Public License as published by |
12 |
* the Free Software Foundation ; either version 2 of the License, or |
* the Free Software Foundation ; either version 2 of the License, or |
13 |
* (at your option) any later version. |
* (at your option) any later version. |
14 |
* |
* |
21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: bitstream.h,v 1.12 2002-09-10 22:52:12 edgomez Exp $ |
* Under section 8 of the GNU General Public License, the copyright |
25 |
|
* holders of XVID explicitly forbid distribution in the following |
26 |
|
* countries: |
27 |
|
* |
28 |
|
* - Japan |
29 |
|
* - United States of America |
30 |
|
* |
31 |
|
* Linking XviD statically or dynamically with other modules is making a |
32 |
|
* combined work based on XviD. Thus, the terms and conditions of the |
33 |
|
* GNU General Public License cover the whole combination. |
34 |
|
* |
35 |
|
* As a special exception, the copyright holders of XviD give you |
36 |
|
* permission to link XviD with independent modules that communicate with |
37 |
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
38 |
|
* license terms of these independent modules, and to copy and distribute |
39 |
|
* the resulting combined work under terms of your choice, provided that |
40 |
|
* every copy of the combined work is accompanied by a complete copy of |
41 |
|
* the source code of XviD (the version of XviD used to produce the |
42 |
|
* combined work), being distributed under the terms of the GNU General |
43 |
|
* Public License plus this exception. An independent module is a module |
44 |
|
* which is not derived from or based on XviD. |
45 |
|
* |
46 |
|
* Note that people who make modified versions of XviD are not obligated |
47 |
|
* to grant this special exception for their modified versions; it is |
48 |
|
* their choice whether to do so. The GNU General Public License gives |
49 |
|
* permission to release a modified version without this exception; this |
50 |
|
* exception also makes it possible to release a modified version which |
51 |
|
* carries forward this exception. |
52 |
|
* |
53 |
|
* $Id: bitstream.h,v 1.15 2002-11-26 23:44:10 edgomez Exp $ |
54 |
* |
* |
55 |
****************************************************************************/ |
****************************************************************************/ |
56 |
|
|
66 |
* Constants |
* Constants |
67 |
****************************************************************************/ |
****************************************************************************/ |
68 |
|
|
69 |
// comment any #defs we dont use |
/* comment any #defs we dont use */ |
70 |
|
|
71 |
#define VIDOBJ_START_CODE 0x00000100 /* ..0x0000011f */ |
#define VIDOBJ_START_CODE 0x00000100 /* ..0x0000011f */ |
72 |
#define VIDOBJLAY_START_CODE 0x00000120 /* ..0x0000012f */ |
#define VIDOBJLAY_START_CODE 0x00000120 /* ..0x0000012f */ |
74 |
#define VISOBJSEQ_STOP_CODE 0x000001b1 /* ??? */ |
#define VISOBJSEQ_STOP_CODE 0x000001b1 /* ??? */ |
75 |
#define USERDATA_START_CODE 0x000001b2 |
#define USERDATA_START_CODE 0x000001b2 |
76 |
#define GRPOFVOP_START_CODE 0x000001b3 |
#define GRPOFVOP_START_CODE 0x000001b3 |
77 |
//#define VIDSESERR_ERROR_CODE 0x000001b4 |
/*#define VIDSESERR_ERROR_CODE 0x000001b4 */ |
78 |
#define VISOBJ_START_CODE 0x000001b5 |
#define VISOBJ_START_CODE 0x000001b5 |
79 |
//#define SLICE_START_CODE 0x000001b7 |
/*#define SLICE_START_CODE 0x000001b7 */ |
80 |
//#define EXT_START_CODE 0x000001b8 |
/*#define EXT_START_CODE 0x000001b8 */ |
81 |
|
|
82 |
|
|
83 |
#define VISOBJ_TYPE_VIDEO 1 |
#define VISOBJ_TYPE_VIDEO 1 |
84 |
//#define VISOBJ_TYPE_STILLTEXTURE 2 |
/*#define VISOBJ_TYPE_STILLTEXTURE 2 */ |
85 |
//#define VISOBJ_TYPE_MESH 3 |
/*#define VISOBJ_TYPE_MESH 3 */ |
86 |
//#define VISOBJ_TYPE_FBA 4 |
/*#define VISOBJ_TYPE_FBA 4 */ |
87 |
//#define VISOBJ_TYPE_3DMESH 5 |
/*#define VISOBJ_TYPE_3DMESH 5 */ |
88 |
|
|
89 |
|
|
90 |
#define VIDOBJLAY_TYPE_SIMPLE 1 |
#define VIDOBJLAY_TYPE_SIMPLE 1 |
91 |
//#define VIDOBJLAY_TYPE_SIMPLE_SCALABLE 2 |
/*#define VIDOBJLAY_TYPE_SIMPLE_SCALABLE 2 */ |
92 |
#define VIDOBJLAY_TYPE_CORE 3 |
#define VIDOBJLAY_TYPE_CORE 3 |
93 |
#define VIDOBJLAY_TYPE_MAIN 4 |
#define VIDOBJLAY_TYPE_MAIN 4 |
94 |
|
|
95 |
|
|
96 |
//#define VIDOBJLAY_AR_SQUARE 1 |
/*#define VIDOBJLAY_AR_SQUARE 1 */ |
97 |
//#define VIDOBJLAY_AR_625TYPE_43 2 |
/*#define VIDOBJLAY_AR_625TYPE_43 2 */ |
98 |
//#define VIDOBJLAY_AR_525TYPE_43 3 |
/*#define VIDOBJLAY_AR_525TYPE_43 3 */ |
99 |
//#define VIDOBJLAY_AR_625TYPE_169 8 |
/*#define VIDOBJLAY_AR_625TYPE_169 8 */ |
100 |
//#define VIDOBJLAY_AR_525TYPE_169 9 |
/*#define VIDOBJLAY_AR_525TYPE_169 9 */ |
101 |
#define VIDOBJLAY_AR_EXTPAR 15 |
#define VIDOBJLAY_AR_EXTPAR 15 |
102 |
|
|
103 |
|
|
113 |
#define READ_MARKER() BitstreamSkip(bs, 1) |
#define READ_MARKER() BitstreamSkip(bs, 1) |
114 |
#define WRITE_MARKER() BitstreamPutBit(bs, 1) |
#define WRITE_MARKER() BitstreamPutBit(bs, 1) |
115 |
|
|
116 |
// vop coding types |
/* vop coding types */ |
117 |
// intra, prediction, backward, sprite, not_coded |
/* intra, prediction, backward, sprite, not_coded */ |
118 |
#define I_VOP 0 |
#define I_VOP 0 |
119 |
#define P_VOP 1 |
#define P_VOP 1 |
120 |
#define B_VOP 2 |
#define B_VOP 2 |
121 |
#define S_VOP 3 |
#define S_VOP 3 |
122 |
#define N_VOP 4 |
#define N_VOP 4 |
123 |
|
|
124 |
// resync-specific |
/* resync-specific */ |
125 |
#define NUMBITS_VP_RESYNC_MARKER 17 |
#define NUMBITS_VP_RESYNC_MARKER 17 |
126 |
#define RESYNC_MARKER 1 |
#define RESYNC_MARKER 1 |
127 |
|
|
134 |
read_video_packet_header(Bitstream *bs, const int addbits, int * quant); |
read_video_packet_header(Bitstream *bs, const int addbits, int * quant); |
135 |
|
|
136 |
|
|
137 |
// header stuff |
/* header stuff */ |
138 |
int BitstreamReadHeaders(Bitstream * bs, |
int BitstreamReadHeaders(Bitstream * bs, |
139 |
DECODER * dec, |
DECODER * dec, |
140 |
uint32_t * rounding, |
uint32_t * rounding, |
253 |
} |
} |
254 |
|
|
255 |
|
|
256 |
// number of bits to next byte alignment |
/* number of bits to next byte alignment */ |
257 |
static uint32_t __inline |
static uint32_t __inline |
258 |
BitstreamNumBitsToByteAlign(Bitstream *bs) |
BitstreamNumBitsToByteAlign(Bitstream *bs) |
259 |
{ |
{ |
262 |
} |
} |
263 |
|
|
264 |
|
|
265 |
// show nbits from next byte alignment |
/* show nbits from next byte alignment */ |
266 |
static uint32_t __inline |
static uint32_t __inline |
267 |
BitstreamShowBitsFromByteAlign(Bitstream *bs, int bits) |
BitstreamShowBitsFromByteAlign(Bitstream *bs, int bits) |
268 |
{ |
{ |