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