Parent Directory
|
Revision Log
Revision 1.9 - (view) (download)
1 : | edgomez | 1.7 | /***************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VIDEO CODEC | ||
4 : | * - DivX 4.0 Compatibility API - | ||
5 : | * | ||
6 : | * This file is part of XviD, a free MPEG-4 video encoder/decoder | ||
7 : | * | ||
8 : | * This program is free software; you can redistribute it and/or modify | ||
9 : | * it under the terms of the GNU General Public License as published by | ||
10 : | * the Free Software Foundation; either version 2 of the License, or | ||
11 : | * (at your option) any later version. | ||
12 : | * | ||
13 : | * This program is distributed in the hope that it will be useful, | ||
14 : | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 : | * GNU General Public License for more details. | ||
17 : | * | ||
18 : | * You should have received a copy of the GNU General Public License | ||
19 : | * along with this program; if not, write to the Free Software | ||
20 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 : | * | ||
22 : | edgomez | 1.9 | * $Id: divx4.h,v 1.8 2003/02/17 23:15:48 edgomez Exp $ |
23 : | edgomez | 1.7 | * |
24 : | ****************************************************************************/ | ||
25 : | |||
26 : | Isibaar | 1.1 | #ifndef _DIVX4_H_ |
27 : | #define _DIVX4_H_ | ||
28 : | |||
29 : | #ifdef __cplusplus | ||
30 : | edgomez | 1.7 | extern "C" { |
31 : | edgomez | 1.2 | #endif |
32 : | Isibaar | 1.1 | |
33 : | edgomez | 1.7 | /***************************************************************************** |
34 : | * Decoder part | ||
35 : | ****************************************************************************/ | ||
36 : | Isibaar | 1.1 | |
37 : | /* decore commands */ | ||
38 : | #define DEC_OPT_MEMORY_REQS 0 | ||
39 : | #define DEC_OPT_INIT 1 | ||
40 : | #define DEC_OPT_RELEASE 2 | ||
41 : | edgomez | 1.2 | #define DEC_OPT_SETPP 3 |
42 : | #define DEC_OPT_SETOUT 4 | ||
43 : | Isibaar | 1.1 | #define DEC_OPT_FRAME 5 |
44 : | #define DEC_OPT_FRAME_311 6 | ||
45 : | #define DEC_OPT_SETPP2 7 | ||
46 : | #define DEC_OPT_VERSION 8 | ||
47 : | |||
48 : | /* return values */ | ||
49 : | #define DEC_OK 0 | ||
50 : | #define DEC_MEMORY 1 | ||
51 : | #define DEC_BAD_FORMAT 2 | ||
52 : | #define DEC_EXIT 3 | ||
53 : | |||
54 : | /* yuv colour formats */ | ||
55 : | #define DEC_YUY2 1 | ||
56 : | #define DEC_YUV2 DEC_YUY2 | ||
57 : | #define DEC_UYVY 2 | ||
58 : | #define DEC_420 3 | ||
59 : | #define DEC_YV12 13 | ||
60 : | |||
61 : | /* rgb colour formats */ | ||
62 : | edgomez | 1.2 | #define DEC_RGB32 4 |
63 : | #define DEC_RGB24 5 | ||
64 : | #define DEC_RGB555 6 | ||
65 : | #define DEC_RGB565 7 | ||
66 : | Isibaar | 1.1 | |
67 : | #define DEC_RGB32_INV 8 | ||
68 : | #define DEC_RGB24_INV 9 | ||
69 : | #define DEC_RGB555_INV 10 | ||
70 : | #define DEC_RGB565_INV 11 | ||
71 : | |||
72 : | /* return pointers to initial buffers | ||
73 : | edgomez | 1.2 | equivalent to XVID_CSP_USER */ |
74 : | Isibaar | 1.1 | #define DEC_USER 12 |
75 : | |||
76 : | /* output structure for DEC_USER */ | ||
77 : | edgomez | 1.2 | typedef struct |
78 : | { | ||
79 : | void *y; | ||
80 : | void *u; | ||
81 : | void *v; | ||
82 : | int stride_y; | ||
83 : | int stride_uv; | ||
84 : | } | ||
85 : | DEC_PICTURE; | ||
86 : | |||
87 : | typedef struct | ||
88 : | { | ||
89 : | unsigned long mp4_edged_ref_buffers_size; | ||
90 : | unsigned long mp4_edged_for_buffers_size; | ||
91 : | unsigned long mp4_edged_back_buffers_size; | ||
92 : | unsigned long mp4_display_buffers_size; | ||
93 : | unsigned long mp4_state_size; | ||
94 : | unsigned long mp4_tables_size; | ||
95 : | unsigned long mp4_stream_size; | ||
96 : | unsigned long mp4_reference_size; | ||
97 : | } | ||
98 : | DEC_MEM_REQS; | ||
99 : | |||
100 : | typedef struct | ||
101 : | { | ||
102 : | void *mp4_edged_ref_buffers; | ||
103 : | void *mp4_edged_for_buffers; | ||
104 : | void *mp4_edged_back_buffers; | ||
105 : | void *mp4_display_buffers; | ||
106 : | void *mp4_state; | ||
107 : | void *mp4_tables; | ||
108 : | void *mp4_stream; | ||
109 : | void *mp4_reference; | ||
110 : | } | ||
111 : | DEC_BUFFERS; | ||
112 : | |||
113 : | typedef struct | ||
114 : | { | ||
115 : | int x_dim; /* frame width */ | ||
116 : | int y_dim; /* frame height */ | ||
117 : | int output_format; | ||
118 : | int time_incr; | ||
119 : | DEC_BUFFERS buffers; | ||
120 : | } | ||
121 : | DEC_PARAM; | ||
122 : | |||
123 : | typedef struct | ||
124 : | { | ||
125 : | void *bmp; /* pointer to output buffer */ | ||
126 : | void *bitstream; /* input bit stream */ | ||
127 : | long length; /* length of bitstream */ | ||
128 : | int render_flag; | ||
129 : | unsigned int stride; | ||
130 : | } | ||
131 : | DEC_FRAME; | ||
132 : | |||
133 : | typedef struct | ||
134 : | { | ||
135 : | int intra; | ||
136 : | int *quant_store; | ||
137 : | int quant_stride; | ||
138 : | } | ||
139 : | DEC_FRAME_INFO; | ||
140 : | Isibaar | 1.1 | |
141 : | /* configure postprocessing */ | ||
142 : | edgomez | 1.2 | typedef struct |
143 : | { | ||
144 : | int postproc_level; /* ranging from 0 to 100 */ | ||
145 : | } | ||
146 : | DEC_SET; | ||
147 : | |||
148 : | int decore(unsigned long handle, | ||
149 : | unsigned long dec_opt, | ||
150 : | void *param1, | ||
151 : | void *param2); | ||
152 : | Isibaar | 1.1 | |
153 : | |||
154 : | |||
155 : | edgomez | 1.7 | /***************************************************************************** |
156 : | * Encoder part | ||
157 : | ****************************************************************************/ | ||
158 : | Isibaar | 1.1 | |
159 : | /** | ||
160 : | Structure passed as an argument when creating encoder. | ||
161 : | You have to initialize at least x_dim and y_dim ( valid range: | ||
162 : | 0<x_dim<=1920, 0<y_dim<=1280, both dimensions should be even ). | ||
163 : | You can set all other values to 0, in which case they'll be initialized | ||
164 : | to default values, or specify them directly. | ||
165 : | On success 'handle' member will contain non-zero handle to initialized | ||
166 : | encoder. | ||
167 : | **/ | ||
168 : | edgomez | 1.2 | typedef struct _ENC_PARAM_ |
169 : | { | ||
170 : | edgomez | 1.7 | int x_dim; /* the x dimension of the frames to be encoded */ |
171 : | int y_dim; /* the y dimension of the frames to be encoded */ | ||
172 : | float framerate; /* the frame rate of the sequence to be encoded, in frames/second */ | ||
173 : | int bitrate; /* the bitrate of the target encoded stream, in bits/second */ | ||
174 : | int rc_period; /* the intended rate control averaging period */ | ||
175 : | int rc_reaction_period; /* the reaction period for rate control */ | ||
176 : | int rc_reaction_ratio; /* the ratio for down/up rate control */ | ||
177 : | int max_quantizer; /* the upper limit of the quantizer */ | ||
178 : | int min_quantizer; /* the lower limit of the quantizer */ | ||
179 : | int max_key_interval; /* the maximum interval between key frames */ | ||
180 : | int use_bidirect; /* use bidirectional coding */ | ||
181 : | int deinterlace; /* fast deinterlace */ | ||
182 : | int quality; /* the quality of compression ( 1 - fastest, 5 - best ) */ | ||
183 : | int obmc; /* flag to enable overlapped block motion compensation mode */ | ||
184 : | void *handle; /* will be filled by encore */ | ||
185 : | edgomez | 1.2 | } |
186 : | ENC_PARAM; | ||
187 : | Isibaar | 1.1 | |
188 : | |||
189 : | edgomez | 1.7 | /* encore2 */ |
190 : | Isibaar | 1.1 | |
191 : | |||
192 : | /** | ||
193 : | Structure passed as a first argument when encoding a frame. | ||
194 : | Both pointers should be non-NULL. You are responsible for allocation | ||
195 : | of bitstream buffer, its size should be large enough to hold a frame. | ||
196 : | Checks for buffer overflow are too expensive and it will be almost | ||
197 : | impossible to recover from such overflow. Thus, no checks for buffer | ||
198 : | overflow will be done. | ||
199 : | Theoretical upper limit of frame size is around 6 bytes/pixel | ||
200 : | or 2.5 Mb for 720x576 frame. | ||
201 : | On success 'length' will contain number of bytes written into the stream. | ||
202 : | **/ | ||
203 : | edgomez | 1.2 | typedef struct _ENC_FRAME_ |
204 : | { | ||
205 : | edgomez | 1.7 | void *image; /* the image frame to be encoded */ |
206 : | void *bitstream; /* the buffer for encoded bitstream */ | ||
207 : | int length; /* the length of the encoded bitstream */ | ||
208 : | int colorspace; /* the format of image frame */ | ||
209 : | int quant; /* quantizer for this frame; only used in VBR modes */ | ||
210 : | int intra; /* force this frame to be intra/inter; only used in VBR 2-pass */ | ||
211 : | void *mvs; /* optional pointer to array of motion vectors */ | ||
212 : | edgomez | 1.2 | } |
213 : | ENC_FRAME; | ||
214 : | Isibaar | 1.1 | |
215 : | /** | ||
216 : | Structure passed as a second optional argument when encoding a frame. | ||
217 : | On successful return its members are filled with parameters of encoded | ||
218 : | stream. | ||
219 : | **/ | ||
220 : | edgomez | 1.2 | typedef struct _ENC_RESULT_ |
221 : | { | ||
222 : | edgomez | 1.7 | int is_key_frame; /* the current frame is encoded as a key frame */ |
223 : | int quantizer; /* the quantizer used for this frame */ | ||
224 : | int texture_bits; /* amount of bits spent on coding DCT coeffs */ | ||
225 : | int motion_bits; /* amount of bits spend on coding motion */ | ||
226 : | int total_bits; /* sum of two previous fields */ | ||
227 : | edgomez | 1.2 | } |
228 : | ENC_RESULT; | ||
229 : | Isibaar | 1.1 | |
230 : | edgomez | 1.7 | /* the prototype of the encore() - main encode engine entrance */ |
231 : | edgomez | 1.8 | int encore(void *handle, /* handle - the handle of the calling entity, must be unique */ |
232 : | edgomez | 1.7 | int enc_opt, /* enc_opt - the option for encoding, see below */ |
233 : | void *param1, /* param1 - the parameter 1 (its actually meaning depends on enc_opt */ | ||
234 : | void *param2); /* param2 - the parameter 2 (its actually meaning depends on enc_opt */ | ||
235 : | |||
236 : | /* encore options (the enc_opt parameter of encore()) */ | ||
237 : | #define ENC_OPT_INIT 0 /* initialize the encoder, return a handle */ | ||
238 : | #define ENC_OPT_RELEASE 1 /* release all the resource associated with the handle */ | ||
239 : | #define ENC_OPT_ENCODE 2 /* encode a single frame */ | ||
240 : | #define ENC_OPT_ENCODE_VBR 3 /* encode a single frame, not using internal rate control algorithm */ | ||
241 : | Isibaar | 1.1 | #define ENC_OPT_VERSION 4 |
242 : | |||
243 : | #define ENCORE_VERSION 20010807 | ||
244 : | edgomez | 1.2 | |
245 : | |||
246 : | Isibaar | 1.1 | |
247 : | edgomez | 1.7 | /* return code of encore() */ |
248 : | Isibaar | 1.1 | #define ENC_FAIL -1 |
249 : | #define ENC_OK 0 | ||
250 : | #define ENC_MEMORY 1 | ||
251 : | #define ENC_BAD_FORMAT 2 | ||
252 : | |||
253 : | /** Common 24-bit RGB, order of components b-g-r **/ | ||
254 : | #define ENC_CSP_RGB24 0 | ||
255 : | |||
256 : | /** Planar YUV, U & V subsampled by 2 in both directions, | ||
257 : | average 12 bit per pixel; order of components y-v-u **/ | ||
258 : | #define ENC_CSP_YV12 1 | ||
259 : | |||
260 : | /** Packed YUV, U and V subsampled by 2 horizontally, | ||
261 : | average 16 bit per pixel; order of components y-u-y-v **/ | ||
262 : | #define ENC_CSP_YUY2 2 | ||
263 : | |||
264 : | /** Same as above, but order of components is u-y-v-y **/ | ||
265 : | #define ENC_CSP_UYVY 3 | ||
266 : | |||
267 : | /** Same as ENC_CSP_YV12, but chroma components are swapped ( order y-u-v ) **/ | ||
268 : | #define ENC_CSP_I420 4 | ||
269 : | |||
270 : | /** Same as above **/ | ||
271 : | #define ENC_CSP_IYUV ENC_CSP_I420 | ||
272 : | |||
273 : | #ifdef __cplusplus | ||
274 : | } | ||
275 : | edgomez | 1.2 | #endif |
276 : | Isibaar | 1.1 | |
277 : | edgomez | 1.7 | #endif /* _DIVX4_H_ */ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |