1 |
|
/***************************************************************************** |
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 |
|
* $Id: divx4.h,v 1.8 2003-02-17 23:15:48 edgomez Exp $ |
23 |
|
* |
24 |
|
****************************************************************************/ |
25 |
|
|
26 |
#ifndef _DIVX4_H_ |
#ifndef _DIVX4_H_ |
27 |
#define _DIVX4_H_ |
#define _DIVX4_H_ |
28 |
|
|
30 |
extern "C" { |
extern "C" { |
31 |
#endif |
#endif |
32 |
|
|
33 |
#if ((! defined(ARCH_IS_BIG_ENDIAN)) && (! defined (WIN32)) && (! defined (LINUX)) ) |
/***************************************************************************** |
34 |
#define ARCH_IS_BIG_ENDIAN |
* Decoder part |
35 |
#endif |
****************************************************************************/ |
|
|
|
|
|
|
|
/********************************************************************************* |
|
|
* Decoder part * |
|
|
*********************************************************************************/ |
|
36 |
|
|
37 |
/* decore commands */ |
/* decore commands */ |
38 |
#define DEC_OPT_MEMORY_REQS 0 |
#define DEC_OPT_MEMORY_REQS 0 |
81 |
void *v; |
void *v; |
82 |
int stride_y; |
int stride_y; |
83 |
int stride_uv; |
int stride_uv; |
84 |
} DEC_PICTURE; |
} |
85 |
|
DEC_PICTURE; |
86 |
|
|
87 |
typedef struct |
typedef struct |
88 |
{ |
{ |
94 |
unsigned long mp4_tables_size; |
unsigned long mp4_tables_size; |
95 |
unsigned long mp4_stream_size; |
unsigned long mp4_stream_size; |
96 |
unsigned long mp4_reference_size; |
unsigned long mp4_reference_size; |
97 |
} DEC_MEM_REQS; |
} |
98 |
|
DEC_MEM_REQS; |
99 |
|
|
100 |
typedef struct |
typedef struct |
101 |
{ |
{ |
107 |
void * mp4_tables; |
void * mp4_tables; |
108 |
void * mp4_stream; |
void * mp4_stream; |
109 |
void * mp4_reference; |
void * mp4_reference; |
110 |
} DEC_BUFFERS; |
} |
111 |
|
DEC_BUFFERS; |
112 |
|
|
113 |
typedef struct |
typedef struct |
114 |
{ |
{ |
117 |
int output_format; |
int output_format; |
118 |
int time_incr; |
int time_incr; |
119 |
DEC_BUFFERS buffers; |
DEC_BUFFERS buffers; |
120 |
} DEC_PARAM; |
} |
121 |
|
DEC_PARAM; |
122 |
|
|
123 |
typedef struct |
typedef struct |
124 |
{ |
{ |
127 |
long length; /* length of bitstream */ |
long length; /* length of bitstream */ |
128 |
int render_flag; |
int render_flag; |
129 |
unsigned int stride; |
unsigned int stride; |
130 |
} DEC_FRAME; |
} |
131 |
|
DEC_FRAME; |
132 |
|
|
133 |
typedef struct |
typedef struct |
134 |
{ |
{ |
135 |
int intra; |
int intra; |
136 |
int *quant_store; |
int *quant_store; |
137 |
int quant_stride; |
int quant_stride; |
138 |
} DEC_FRAME_INFO; |
} |
139 |
|
DEC_FRAME_INFO; |
140 |
|
|
141 |
/* configure postprocessing */ |
/* configure postprocessing */ |
142 |
typedef struct |
typedef struct |
143 |
{ |
{ |
144 |
int postproc_level; /* ranging from 0 to 100 */ |
int postproc_level; /* ranging from 0 to 100 */ |
145 |
} DEC_SET; |
} |
146 |
|
DEC_SET; |
147 |
|
|
148 |
int decore( unsigned long handle, unsigned long dec_opt, void* param1, void* param2); |
int decore(unsigned long handle, |
149 |
|
unsigned long dec_opt, |
150 |
|
void *param1, |
151 |
|
void *param2); |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
/********************************************************************************* |
/***************************************************************************** |
156 |
* Encoder part * |
* Encoder part |
157 |
*********************************************************************************/ |
****************************************************************************/ |
158 |
|
|
159 |
/** |
/** |
160 |
Structure passed as an argument when creating encoder. |
Structure passed as an argument when creating encoder. |
167 |
**/ |
**/ |
168 |
typedef struct _ENC_PARAM_ |
typedef struct _ENC_PARAM_ |
169 |
{ |
{ |
170 |
int x_dim; // the x dimension of the frames to be encoded |
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 |
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 |
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 |
int bitrate; /* the bitrate of the target encoded stream, in bits/second */ |
174 |
int rc_period; // the intended rate control averaging period |
int rc_period; /* the intended rate control averaging period */ |
175 |
int rc_reaction_period; // the reaction period for rate control |
int rc_reaction_period; /* the reaction period for rate control */ |
176 |
int rc_reaction_ratio; // the ratio for down/up rate control |
int rc_reaction_ratio; /* the ratio for down/up rate control */ |
177 |
int max_quantizer; // the upper limit of the quantizer |
int max_quantizer; /* the upper limit of the quantizer */ |
178 |
int min_quantizer; // the lower limit of the quantizer |
int min_quantizer; /* the lower limit of the quantizer */ |
179 |
int max_key_interval; // the maximum interval between key frames |
int max_key_interval; /* the maximum interval between key frames */ |
180 |
int use_bidirect; // use bidirectional coding |
int use_bidirect; /* use bidirectional coding */ |
181 |
int deinterlace; // fast deinterlace |
int deinterlace; /* fast deinterlace */ |
182 |
int quality; // the quality of compression ( 1 - fastest, 5 - best ) |
int quality; /* the quality of compression ( 1 - fastest, 5 - best ) */ |
183 |
int obmc; // flag to enable overlapped block motion compensation mode |
int obmc; /* flag to enable overlapped block motion compensation mode */ |
184 |
void *handle; // will be filled by encore |
void *handle; /* will be filled by encore */ |
185 |
} |
} |
186 |
ENC_PARAM; |
ENC_PARAM; |
187 |
|
|
188 |
|
|
189 |
// encore2 |
/* encore2 */ |
190 |
|
|
191 |
|
|
192 |
/** |
/** |
202 |
**/ |
**/ |
203 |
typedef struct _ENC_FRAME_ |
typedef struct _ENC_FRAME_ |
204 |
{ |
{ |
205 |
void *image; // the image frame to be encoded |
void *image; /* the image frame to be encoded */ |
206 |
void *bitstream; // the buffer for encoded bitstream |
void *bitstream; /* the buffer for encoded bitstream */ |
207 |
int length; // the length of the encoded bitstream |
int length; /* the length of the encoded bitstream */ |
208 |
int colorspace; // the format of image frame |
int colorspace; /* the format of image frame */ |
209 |
int quant; // quantizer for this frame; only used in VBR modes |
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 |
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 |
void *mvs; /* optional pointer to array of motion vectors */ |
212 |
} |
} |
213 |
ENC_FRAME; |
ENC_FRAME; |
214 |
|
|
219 |
**/ |
**/ |
220 |
typedef struct _ENC_RESULT_ |
typedef struct _ENC_RESULT_ |
221 |
{ |
{ |
222 |
int is_key_frame; // the current frame is encoded as a key frame |
int is_key_frame; /* the current frame is encoded as a key frame */ |
223 |
int quantizer; // the quantizer used for this frame |
int quantizer; /* the quantizer used for this frame */ |
224 |
int texture_bits; // amount of bits spent on coding DCT coeffs |
int texture_bits; /* amount of bits spent on coding DCT coeffs */ |
225 |
int motion_bits; // amount of bits spend on coding motion |
int motion_bits; /* amount of bits spend on coding motion */ |
226 |
int total_bits; // sum of two previous fields |
int total_bits; /* sum of two previous fields */ |
227 |
} |
} |
228 |
ENC_RESULT; |
ENC_RESULT; |
229 |
|
|
230 |
// the prototype of the encore() - main encode engine entrance |
/* the prototype of the encore() - main encode engine entrance */ |
231 |
int encore(void *handle, // handle - the handle of the calling entity, must be unique |
int encore(void *handle, /* handle - the handle of the calling entity, must be unique */ |
232 |
int enc_opt, // enc_opt - the option for encoding, see below |
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 |
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 |
void *param2); /* param2 - the parameter 2 (its actually meaning depends on enc_opt */ |
235 |
|
|
236 |
// encore options (the enc_opt parameter of encore()) |
/* encore options (the enc_opt parameter of encore()) */ |
237 |
#define ENC_OPT_INIT 0 // initialize the encoder, return a handle |
#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 |
#define ENC_OPT_RELEASE 1 /* release all the resource associated with the handle */ |
239 |
#define ENC_OPT_ENCODE 2 // encode a single frame |
#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 |
#define ENC_OPT_ENCODE_VBR 3 /* encode a single frame, not using internal rate control algorithm */ |
241 |
#define ENC_OPT_VERSION 4 |
#define ENC_OPT_VERSION 4 |
242 |
|
|
243 |
#define ENCORE_VERSION 20010807 |
#define ENCORE_VERSION 20010807 |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
// return code of encore() |
/* return code of encore() */ |
248 |
#define ENC_FAIL -1 |
#define ENC_FAIL -1 |
249 |
#define ENC_OK 0 |
#define ENC_OK 0 |
250 |
#define ENC_MEMORY 1 |
#define ENC_MEMORY 1 |
274 |
} |
} |
275 |
#endif |
#endif |
276 |
|
|
277 |
#endif // _DIVX4_H_ |
#endif /* _DIVX4_H_ */ |