[cvs] / xvidcore / src / xvid.c Repository:
ViewVC logotype

Annotation of /xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.46 - (view) (download)

1 : edgomez 1.16 /*****************************************************************************
2 : edgomez 1.17 *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * - Native API implementation -
5 :     *
6 : edgomez 1.41 * This program is free software ; you can redistribute it and/or modify
7 :     * it under the terms of the GNU General Public License as published by
8 :     * the Free Software Foundation ; either version 2 of the License, or
9 : edgomez 1.17 * (at your option) any later version.
10 :     *
11 :     * This program is distributed in the hope that it will be useful,
12 : edgomez 1.41 * but WITHOUT ANY WARRANTY ; without even the implied warranty of
13 : edgomez 1.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 :     * GNU General Public License for more details.
15 :     *
16 :     * You should have received a copy of the GNU General Public License
17 : edgomez 1.41 * along with this program ; if not, write to the Free Software
18 : edgomez 1.17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 :     *
20 : Isibaar 1.46 * $Id: xvid.c,v 1.45 2003/02/21 00:00:57 edgomez Exp $
21 : edgomez 1.36 *
22 : edgomez 1.17 ****************************************************************************/
23 : chenm001 1.29
24 : edgomez 1.41 #include <stdio.h>
25 :     #include <stdlib.h>
26 :     #include <string.h>
27 :     #include <time.h>
28 :    
29 : Isibaar 1.1 #include "xvid.h"
30 :     #include "decoder.h"
31 :     #include "encoder.h"
32 :     #include "bitstream/cbp.h"
33 :     #include "dct/idct.h"
34 :     #include "dct/fdct.h"
35 :     #include "image/colorspace.h"
36 :     #include "image/interpolate8x8.h"
37 : edgomez 1.41 #include "image/reduced.h"
38 : Isibaar 1.1 #include "utils/mem_transfer.h"
39 : edgomez 1.41 #include "utils/mbfunctions.h"
40 : Isibaar 1.1 #include "quant/quant_h263.h"
41 :     #include "quant/quant_mpeg4.h"
42 : ia64p 1.30 #include "motion/motion.h"
43 : Isibaar 1.1 #include "motion/sad.h"
44 :     #include "utils/emms.h"
45 :     #include "utils/timer.h"
46 : Isibaar 1.9 #include "bitstream/mbcoding.h"
47 : Isibaar 1.1
48 : edgomez 1.41 #if defined(ARCH_IS_IA32)
49 : suxen_drol 1.31
50 : edgomez 1.41 #if defined(_MSC_VER)
51 :     # include <windows.h>
52 : suxen_drol 1.31 #else
53 : edgomez 1.41 # include <signal.h>
54 :     # include <setjmp.h>
55 : suxen_drol 1.31
56 : edgomez 1.41 static jmp_buf mark;
57 : suxen_drol 1.31
58 : edgomez 1.41 static void
59 :     sigill_handler(int signal)
60 :     {
61 :     longjmp(mark, 1);
62 :     }
63 : suxen_drol 1.31 #endif
64 :    
65 :    
66 :     /*
67 : edgomez 1.43 * Calls the funcptr, and returns whether SIGILL (illegal instruction) was
68 :     * signalled
69 :     *
70 :     * Return values:
71 :     * -1 : could not determine
72 :     * 0 : SIGILL was *not* signalled
73 :     * 1 : SIGILL was signalled
74 :     */
75 : suxen_drol 1.31
76 :     int
77 :     sigill_check(void (*func)())
78 :     {
79 : edgomez 1.41 #if defined(_MSC_VER)
80 : suxen_drol 1.31 _try {
81 :     func();
82 :     }
83 :     _except(EXCEPTION_EXECUTE_HANDLER) {
84 :    
85 :     if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
86 :     return 1;
87 :     }
88 :     return 0;
89 :     #else
90 :     void * old_handler;
91 :     int jmpret;
92 :    
93 :    
94 :     old_handler = signal(SIGILL, sigill_handler);
95 :     if (old_handler == SIG_ERR)
96 :     {
97 :     return -1;
98 :     }
99 :    
100 :     jmpret = setjmp(mark);
101 :     if (jmpret == 0)
102 :     {
103 :     func();
104 :     }
105 :    
106 :     signal(SIGILL, old_handler);
107 :    
108 :     return jmpret;
109 :     #endif
110 :     }
111 :     #endif
112 :    
113 : edgomez 1.41
114 :     /* detect cpu flags */
115 :     static unsigned int
116 :     detect_cpu_flags()
117 :     {
118 :     /* enable native assembly optimizations by default */
119 :     unsigned int cpu_flags = XVID_CPU_ASM;
120 :    
121 :     #if defined(ARCH_IS_IA32)
122 :     cpu_flags |= check_cpu_features();
123 :     if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger))
124 :     cpu_flags &= ~XVID_CPU_SSE;
125 :    
126 :     if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger))
127 :     cpu_flags &= ~XVID_CPU_SSE2;
128 :     #endif
129 :    
130 :     #if defined(ARCH_IS_PPC)
131 :     #if defined(ARCH_IS_PPC_ALTIVEC)
132 :     cpu_flags |= XVID_CPU_ALTIVEC;
133 :     #endif
134 :     #endif
135 :    
136 :     return cpu_flags;
137 :     }
138 :    
139 :    
140 : edgomez 1.16 /*****************************************************************************
141 :     * XviD Init Entry point
142 :     *
143 :     * Well this function initialize all internal function pointers according
144 :     * to the CPU features forced by the library client or autodetected (depending
145 :     * on the XVID_CPU_FORCE flag). It also initializes vlc coding tables and all
146 :     * image colorspace transformation tables.
147 :     *
148 :     * Returned value : XVID_ERR_OK
149 :     * + API_VERSION in the input XVID_INIT_PARAM structure
150 :     * + core build " " " " "
151 :     *
152 :     ****************************************************************************/
153 :    
154 : edgomez 1.41
155 :     static
156 :     int xvid_init_init(XVID_INIT_PARAM * init_param)
157 : Isibaar 1.1 {
158 :     int cpu_flags;
159 :    
160 : suxen_drol 1.21 /* Inform the client the API version */
161 :     init_param->api_version = API_VERSION;
162 :    
163 :     /* Inform the client the core build - unused because we're still alpha */
164 :     init_param->core_build = 1000;
165 :    
166 : suxen_drol 1.31 /* Do we have to force CPU features ? */
167 :     if ((init_param->cpu_flags & XVID_CPU_FORCE)) {
168 : suxen_drol 1.21
169 : Isibaar 1.1 cpu_flags = init_param->cpu_flags;
170 : suxen_drol 1.31
171 : edgomez 1.16 } else {
172 : Isibaar 1.1
173 : edgomez 1.41 cpu_flags = detect_cpu_flags();
174 : suxen_drol 1.31 }
175 :    
176 :     if ((init_param->cpu_flags & XVID_CPU_CHKONLY))
177 :     {
178 : Isibaar 1.1 init_param->cpu_flags = cpu_flags;
179 : suxen_drol 1.31 return XVID_ERR_OK;
180 : Isibaar 1.1 }
181 : suxen_drol 1.31
182 :     init_param->cpu_flags = cpu_flags;
183 :    
184 : Isibaar 1.1
185 : edgomez 1.16 /* Initialize the function pointers */
186 : Isibaar 1.1 idct_int32_init();
187 : Isibaar 1.9 init_vlc_tables();
188 :    
189 : edgomez 1.16 /* Fixed Point Forward/Inverse DCT transformations */
190 : Isibaar 1.1 fdct = fdct_int32;
191 :     idct = idct_int32;
192 :    
193 : edgomez 1.16 /* Only needed on PPC Altivec archs */
194 : canard 1.10 sadInit = 0;
195 : edgomez 1.15
196 : edgomez 1.16 /* Restore FPU context : emms_c is a nop functions */
197 : Isibaar 1.1 emms = emms_c;
198 :    
199 : edgomez 1.16 /* Quantization functions */
200 :     quant_intra = quant_intra_c;
201 : Isibaar 1.1 dequant_intra = dequant_intra_c;
202 : edgomez 1.16 quant_inter = quant_inter_c;
203 : Isibaar 1.1 dequant_inter = dequant_inter_c;
204 :    
205 : edgomez 1.16 quant4_intra = quant4_intra_c;
206 : Isibaar 1.1 dequant4_intra = dequant4_intra_c;
207 : edgomez 1.16 quant4_inter = quant4_inter_c;
208 : Isibaar 1.1 dequant4_inter = dequant4_inter_c;
209 :    
210 : edgomez 1.16 /* Block transfer related functions */
211 : Isibaar 1.1 transfer_8to16copy = transfer_8to16copy_c;
212 :     transfer_16to8copy = transfer_16to8copy_c;
213 : edgomez 1.16 transfer_8to16sub = transfer_8to16sub_c;
214 : edgomez 1.41 transfer_8to16subro = transfer_8to16subro_c;
215 : suxen_drol 1.11 transfer_8to16sub2 = transfer_8to16sub2_c;
216 : edgomez 1.16 transfer_16to8add = transfer_16to8add_c;
217 :     transfer8x8_copy = transfer8x8_copy_c;
218 : Isibaar 1.1
219 : edgomez 1.41 /* Interlacing functions */
220 :     MBFieldTest = MBFieldTest_c;
221 :    
222 : edgomez 1.16 /* Image interpolation related functions */
223 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c;
224 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c;
225 : Isibaar 1.1 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c;
226 :    
227 : edgomez 1.41 interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c;
228 :     interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c;
229 :     interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c;
230 :    
231 :     interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c;
232 :     interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c;
233 :     interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c;
234 :    
235 :     interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c;
236 :     interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c;
237 :    
238 :     interpolate8x8_avg2 = interpolate8x8_avg2_c;
239 :     interpolate8x8_avg4 = interpolate8x8_avg4_c;
240 :    
241 :     /* reduced resoltuion */
242 :     copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C;
243 :     add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C;
244 :     vfilter_31 = xvid_VFilter_31_C;
245 :     hfilter_31 = xvid_HFilter_31_C;
246 :     filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C;
247 :     filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C;
248 :    
249 : edgomez 1.16 /* Initialize internal colorspace transformation tables */
250 : Isibaar 1.1 colorspace_init();
251 :    
252 : edgomez 1.16 /* All colorspace transformation functions User Format->YV12 */
253 : edgomez 1.41 yv12_to_yv12 = yv12_to_yv12_c;
254 :     rgb555_to_yv12 = rgb555_to_yv12_c;
255 :     rgb565_to_yv12 = rgb565_to_yv12_c;
256 :     bgr_to_yv12 = bgr_to_yv12_c;
257 :     bgra_to_yv12 = bgra_to_yv12_c;
258 :     abgr_to_yv12 = abgr_to_yv12_c;
259 :     rgba_to_yv12 = rgba_to_yv12_c;
260 :     yuyv_to_yv12 = yuyv_to_yv12_c;
261 :     uyvy_to_yv12 = uyvy_to_yv12_c;
262 :    
263 :     rgb555i_to_yv12 = rgb555i_to_yv12_c;
264 :     rgb565i_to_yv12 = rgb565i_to_yv12_c;
265 :     bgri_to_yv12 = bgri_to_yv12_c;
266 :     bgrai_to_yv12 = bgrai_to_yv12_c;
267 :     abgri_to_yv12 = abgri_to_yv12_c;
268 :     rgbai_to_yv12 = rgbai_to_yv12_c;
269 :     yuyvi_to_yv12 = yuyvi_to_yv12_c;
270 :     uyvyi_to_yv12 = uyvyi_to_yv12_c;
271 :    
272 : Isibaar 1.1
273 : edgomez 1.16 /* All colorspace transformation functions YV12->User format */
274 : edgomez 1.41 yv12_to_rgb555 = yv12_to_rgb555_c;
275 :     yv12_to_rgb565 = yv12_to_rgb565_c;
276 :     yv12_to_bgr = yv12_to_bgr_c;
277 :     yv12_to_bgra = yv12_to_bgra_c;
278 :     yv12_to_abgr = yv12_to_abgr_c;
279 :     yv12_to_rgba = yv12_to_rgba_c;
280 :     yv12_to_yuyv = yv12_to_yuyv_c;
281 :     yv12_to_uyvy = yv12_to_uyvy_c;
282 :    
283 :     yv12_to_rgb555i = yv12_to_rgb555i_c;
284 :     yv12_to_rgb565i = yv12_to_rgb565i_c;
285 :     yv12_to_bgri = yv12_to_bgri_c;
286 :     yv12_to_bgrai = yv12_to_bgrai_c;
287 :     yv12_to_abgri = yv12_to_abgri_c;
288 :     yv12_to_rgbai = yv12_to_rgbai_c;
289 :     yv12_to_yuyvi = yv12_to_yuyvi_c;
290 :     yv12_to_uyvyi = yv12_to_uyvyi_c;
291 : Isibaar 1.1
292 : edgomez 1.16 /* Functions used in motion estimation algorithms */
293 : Isibaar 1.1 calc_cbp = calc_cbp_c;
294 : edgomez 1.16 sad16 = sad16_c;
295 : suxen_drol 1.33 sad8 = sad8_c;
296 : edgomez 1.16 sad16bi = sad16bi_c;
297 : suxen_drol 1.33 sad8bi = sad8bi_c;
298 : edgomez 1.16 dev16 = dev16_c;
299 : edgomez 1.41 sad16v = sad16v_c;
300 : suxen_drol 1.33
301 : edgomez 1.43 /* Halfpel8_Refine = Halfpel8_Refine_c; */
302 : Isibaar 1.1
303 : edgomez 1.41 #if defined(ARCH_IS_IA32)
304 :    
305 :     if ((cpu_flags & XVID_CPU_ASM))
306 :     {
307 :     vfilter_31 = xvid_VFilter_31_x86;
308 :     hfilter_31 = xvid_HFilter_31_x86;
309 :     }
310 :    
311 :     if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) ||
312 :     (cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) ||
313 :     (cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2))
314 :     {
315 :     /* Restore FPU context : emms_c is a nop functions */
316 :     emms = emms_mmx;
317 :     }
318 :    
319 :     if ((cpu_flags & XVID_CPU_MMX)) {
320 : edgomez 1.16
321 :     /* Forward and Inverse Discrete Cosine Transformation functions */
322 : Isibaar 1.1 fdct = fdct_mmx;
323 : Isibaar 1.46 idct = simple_idct_mmx; /* use simple idct by default */
324 : Isibaar 1.1
325 : edgomez 1.16 /* Quantization related functions */
326 :     quant_intra = quant_intra_mmx;
327 : Isibaar 1.1 dequant_intra = dequant_intra_mmx;
328 : edgomez 1.16 quant_inter = quant_inter_mmx;
329 : Isibaar 1.1 dequant_inter = dequant_inter_mmx;
330 :    
331 : edgomez 1.16 quant4_intra = quant4_intra_mmx;
332 : Isibaar 1.1 dequant4_intra = dequant4_intra_mmx;
333 : edgomez 1.16 quant4_inter = quant4_inter_mmx;
334 : Isibaar 1.1 dequant4_inter = dequant4_inter_mmx;
335 :    
336 : edgomez 1.16 /* Block related functions */
337 : Isibaar 1.1 transfer_8to16copy = transfer_8to16copy_mmx;
338 :     transfer_16to8copy = transfer_16to8copy_mmx;
339 : edgomez 1.16 transfer_8to16sub = transfer_8to16sub_mmx;
340 : edgomez 1.41 transfer_8to16subro = transfer_8to16subro_mmx;
341 : edgomez 1.22 transfer_8to16sub2 = transfer_8to16sub2_mmx;
342 : edgomez 1.16 transfer_16to8add = transfer_16to8add_mmx;
343 :     transfer8x8_copy = transfer8x8_copy_mmx;
344 : edgomez 1.22
345 : edgomez 1.41 /* Interlacing Functions */
346 :     MBFieldTest = MBFieldTest_mmx;
347 : edgomez 1.16
348 :     /* Image Interpolation related functions */
349 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx;
350 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx;
351 : Isibaar 1.1 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx;
352 :    
353 : edgomez 1.41 interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx;
354 :     interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx;
355 :    
356 :     interpolate8x8_avg2 = interpolate8x8_avg2_mmx;
357 :     interpolate8x8_avg4 = interpolate8x8_avg4_mmx;
358 :    
359 :     /* reduced resolution */
360 :     copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx;
361 :     add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx;
362 :     hfilter_31 = xvid_HFilter_31_mmx;
363 :     filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx;
364 :     filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx;
365 :    
366 :     /* image input xxx_to_yv12 related functions */
367 :     yv12_to_yv12 = yv12_to_yv12_mmx;
368 :     bgr_to_yv12 = bgr_to_yv12_mmx;
369 :     bgra_to_yv12 = bgra_to_yv12_mmx;
370 : edgomez 1.16 yuyv_to_yv12 = yuyv_to_yv12_mmx;
371 :     uyvy_to_yv12 = uyvy_to_yv12_mmx;
372 : Isibaar 1.1
373 : edgomez 1.41 /* image output yv12_to_xxx related functions */
374 :     yv12_to_bgr = yv12_to_bgr_mmx;
375 :     yv12_to_bgra = yv12_to_bgra_mmx;
376 : edgomez 1.16 yv12_to_yuyv = yv12_to_yuyv_mmx;
377 :     yv12_to_uyvy = yv12_to_uyvy_mmx;
378 : edgomez 1.41
379 :     yv12_to_yuyvi = yv12_to_yuyvi_mmx;
380 :     yv12_to_uyvyi = yv12_to_uyvyi_mmx;
381 : Isibaar 1.1
382 : edgomez 1.16 /* Motion estimation related functions */
383 : Isibaar 1.1 calc_cbp = calc_cbp_mmx;
384 : edgomez 1.16 sad16 = sad16_mmx;
385 :     sad8 = sad8_mmx;
386 : suxen_drol 1.33 sad16bi = sad16bi_mmx;
387 :     sad8bi = sad8bi_mmx;
388 : edgomez 1.16 dev16 = dev16_mmx;
389 : edgomez 1.41 sad16v = sad16v_mmx;
390 : Isibaar 1.1 }
391 :    
392 : suxen_drol 1.33 /* these 3dnow functions are faster than mmx, but slower than xmm. */
393 : edgomez 1.41 if ((cpu_flags & XVID_CPU_3DNOW)) {
394 :    
395 :     emms = emms_3dn;
396 : suxen_drol 1.33
397 :     /* ME functions */
398 :     sad16bi = sad16bi_3dn;
399 :     sad8bi = sad8bi_3dn;
400 : edgomez 1.41
401 :     yuyv_to_yv12 = yuyv_to_yv12_3dn;
402 :     uyvy_to_yv12 = uyvy_to_yv12_3dn;
403 : suxen_drol 1.33 }
404 :    
405 :    
406 : edgomez 1.41 if ((cpu_flags & XVID_CPU_MMXEXT)) {
407 : edgomez 1.16
408 :     /* Inverse DCT */
409 : Isibaar 1.46 /* idct = idct_xmm; Don't use Walken idct anymore! */
410 : edgomez 1.16
411 :     /* Interpolation */
412 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_xmm;
413 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm;
414 : h 1.3 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm;
415 : Isibaar 1.25
416 : edgomez 1.41 /* reduced resolution */
417 :     copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm;
418 :     add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm;
419 :    
420 : chenm001 1.29 /* Quantization */
421 : edgomez 1.41 quant4_intra = quant4_intra_xmm;
422 :     quant4_inter = quant4_inter_xmm;
423 :    
424 : chenm001 1.29 dequant_intra = dequant_intra_xmm;
425 :     dequant_inter = dequant_inter_xmm;
426 :    
427 : edgomez 1.19 /* Buffer transfer */
428 :     transfer_8to16sub2 = transfer_8to16sub2_xmm;
429 : edgomez 1.16
430 :     /* Colorspace transformation */
431 : edgomez 1.41 yv12_to_yv12 = yv12_to_yv12_xmm;
432 :     yuyv_to_yv12 = yuyv_to_yv12_xmm;
433 :     uyvy_to_yv12 = uyvy_to_yv12_xmm;
434 : Isibaar 1.1
435 : edgomez 1.16 /* ME functions */
436 : Isibaar 1.1 sad16 = sad16_xmm;
437 : suxen_drol 1.33 sad8 = sad8_xmm;
438 : chenm001 1.29 sad16bi = sad16bi_xmm;
439 : suxen_drol 1.33 sad8bi = sad8bi_xmm;
440 : Isibaar 1.1 dev16 = dev16_xmm;
441 : edgomez 1.41 sad16v = sad16v_xmm;
442 : Isibaar 1.1 }
443 :    
444 : edgomez 1.41 if ((cpu_flags & XVID_CPU_3DNOW)) {
445 : edgomez 1.16
446 :     /* Interpolation */
447 : Isibaar 1.1 interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn;
448 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dn;
449 : h 1.4 interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn;
450 : Isibaar 1.1 }
451 :    
452 : edgomez 1.41 if ((cpu_flags & XVID_CPU_3DNOWEXT)) {
453 :    
454 :     /* Inverse DCT */
455 : Isibaar 1.46 /* idct = idct_3dne; Don't use Walken idct anymore */
456 : edgomez 1.41
457 :     /* Buffer transfer */
458 :     transfer_8to16copy = transfer_8to16copy_3dne;
459 :     transfer_16to8copy = transfer_16to8copy_3dne;
460 :     transfer_8to16sub = transfer_8to16sub_3dne;
461 :     transfer_8to16subro = transfer_8to16subro_3dne;
462 :     transfer_8to16sub2 = transfer_8to16sub2_3dne;
463 :     transfer_16to8add = transfer_16to8add_3dne;
464 :     transfer8x8_copy = transfer8x8_copy_3dne;
465 :    
466 :     /* Quantization */
467 :     dequant4_intra = dequant4_intra_3dne;
468 :     dequant4_inter = dequant4_inter_3dne;
469 :     quant_intra = quant_intra_3dne;
470 :     quant_inter = quant_inter_3dne;
471 :     dequant_intra = dequant_intra_3dne;
472 :     dequant_inter = dequant_inter_3dne;
473 :    
474 :     /* ME functions */
475 :     calc_cbp = calc_cbp_3dne;
476 :     sad16 = sad16_3dne;
477 :     sad8 = sad8_3dne;
478 :     sad16bi = sad16bi_3dne;
479 :     sad8bi = sad8bi_3dne;
480 :     dev16 = dev16_3dne;
481 :    
482 :     /* Interpolation */
483 :     interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne;
484 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne;
485 :     interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne;
486 :     }
487 :    
488 :    
489 :     if ((cpu_flags & XVID_CPU_SSE2)) {
490 : edgomez 1.16
491 : chenm001 1.29 calc_cbp = calc_cbp_sse2;
492 :    
493 : edgomez 1.16 /* Quantization */
494 :     quant_intra = quant_intra_sse2;
495 : Isibaar 1.14 dequant_intra = dequant_intra_sse2;
496 : edgomez 1.16 quant_inter = quant_inter_sse2;
497 : Isibaar 1.14 dequant_inter = dequant_inter_sse2;
498 : h 1.13
499 : edgomez 1.41 #if defined(EXPERIMENTAL_SSE2_CODE)
500 :     /* ME; slower than xmm */
501 : edgomez 1.16 sad16 = sad16_sse2;
502 :     dev16 = dev16_sse2;
503 : edgomez 1.41 #endif
504 : edgomez 1.16 /* Forward and Inverse DCT */
505 : Isibaar 1.46 /* idct = idct_sse2;
506 :     /* fdct = fdct_sse2; Both are none to be unprecise - better deactivate for now */
507 : h 1.12 }
508 : Isibaar 1.1 #endif
509 : Isibaar 1.18
510 : edgomez 1.41 #if defined(ARCH_IS_IA64)
511 : edgomez 1.43 if ((cpu_flags & XVID_CPU_ASM)) { /* use assembler routines? */
512 : Isibaar 1.18 idct_ia64_init();
513 :     fdct = fdct_ia64;
514 : edgomez 1.43 idct = idct_ia64; /*not yet working, crashes */
515 : Isibaar 1.18 interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64;
516 :     interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64;
517 :     interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64;
518 :     sad16 = sad16_ia64;
519 :     sad16bi = sad16bi_ia64;
520 :     sad8 = sad8_ia64;
521 :     dev16 = dev16_ia64;
522 : edgomez 1.43 /* Halfpel8_Refine = Halfpel8_Refine_ia64; */
523 : Isibaar 1.18 quant_intra = quant_intra_ia64;
524 :     dequant_intra = dequant_intra_ia64;
525 :     quant_inter = quant_inter_ia64;
526 :     dequant_inter = dequant_inter_ia64;
527 :     transfer_8to16copy = transfer_8to16copy_ia64;
528 :     transfer_16to8copy = transfer_16to8copy_ia64;
529 :     transfer_8to16sub = transfer_8to16sub_ia64;
530 :     transfer_8to16sub2 = transfer_8to16sub2_ia64;
531 :     transfer_16to8add = transfer_16to8add_ia64;
532 :     transfer8x8_copy = transfer8x8_copy_ia64;
533 : edgomez 1.43 DPRINTF(DPRINTF_DEBUG, "Using IA-64 assembler routines.");
534 : Isibaar 1.18 }
535 :     #endif
536 : edgomez 1.16
537 : edgomez 1.41 #if defined(ARCH_IS_PPC)
538 :     if ((cpu_flags & XVID_CPU_ASM))
539 :     {
540 :     calc_cbp = calc_cbp_ppc;
541 :     }
542 :    
543 :     if ((cpu_flags & XVID_CPU_ALTIVEC))
544 :     {
545 :     calc_cbp = calc_cbp_altivec;
546 :     fdct = fdct_altivec;
547 :     idct = idct_altivec;
548 :     sadInit = sadInit_altivec;
549 :     sad16 = sad16_altivec;
550 :     sad8 = sad8_altivec;
551 :     dev16 = dev16_altivec;
552 :     }
553 : canard 1.6 #endif
554 : edgomez 1.41
555 :     return XVID_ERR_OK;
556 :     }
557 :    
558 :    
559 :    
560 :     static int
561 :     xvid_init_convert(XVID_INIT_CONVERTINFO* convert)
562 :     {
563 : edgomez 1.43 /*
564 :     const int flip1 =
565 :     (convert->input.colorspace & XVID_CSP_VFLIP) ^
566 :     (convert->output.colorspace & XVID_CSP_VFLIP);
567 :     */
568 : edgomez 1.41 const int width = convert->width;
569 :     const int height = convert->height;
570 :     const int width2 = convert->width/2;
571 :     const int height2 = convert->height/2;
572 :     IMAGE img;
573 :    
574 :     switch (convert->input.colorspace & ~XVID_CSP_VFLIP)
575 :     {
576 :     case XVID_CSP_YV12 :
577 :     img.y = convert->input.y;
578 :     img.v = (uint8_t*)convert->input.y + width*height;
579 :     img.u = (uint8_t*)convert->input.y + width*height + width2*height2;
580 :     image_output(&img, width, height, width,
581 :     convert->output.y, convert->output.y_stride,
582 :     convert->output.colorspace, convert->interlacing);
583 :     break;
584 :    
585 :     default :
586 :     return XVID_ERR_FORMAT;
587 :     }
588 :    
589 :    
590 :     emms();
591 :     return XVID_ERR_OK;
592 :     }
593 :    
594 :    
595 :    
596 :     void fill8(uint8_t * block, int size, int value)
597 :     {
598 :     int i;
599 :     for (i = 0; i < size; i++)
600 :     block[i] = value;
601 :     }
602 :    
603 :     void fill16(int16_t * block, int size, int value)
604 :     {
605 :     int i;
606 :     for (i = 0; i < size; i++)
607 :     block[i] = value;
608 :     }
609 :    
610 :     #define RANDOM(min,max) min + (rand() % (max-min))
611 :    
612 :     void random8(uint8_t * block, int size, int min, int max)
613 :     {
614 :     int i;
615 :     for (i = 0; i < size; i++)
616 :     block[i] = RANDOM(min,max);
617 :     }
618 :    
619 :     void random16(int16_t * block, int size, int min, int max)
620 :     {
621 :     int i;
622 :     for (i = 0; i < size; i++)
623 :     block[i] = RANDOM(min,max);
624 :     }
625 :    
626 :     int compare16(const int16_t * blockA, const int16_t * blockB, int size)
627 :     {
628 :     int i;
629 :     for (i = 0; i < size; i++)
630 :     if (blockA[i] != blockB[i])
631 :     return 1;
632 :    
633 :     return 0;
634 :     }
635 :    
636 :     int diff16(const int16_t * blockA, const int16_t * blockB, int size)
637 :     {
638 :     int i, diff = 0;
639 :     for (i = 0; i < size; i++)
640 :     diff += ABS(blockA[i]-blockB[i]);
641 :     return diff;
642 :     }
643 :    
644 :    
645 :     #define XVID_TEST_RANDOM 0x00000001 /* random input data */
646 :     #define XVID_TEST_VERBOSE 0x00000002 /* verbose error output */
647 :    
648 :    
649 :     #define TEST_FORWARD 0x00000001 /* intra */
650 :     #define TEST_FDCT (TEST_FORWARD)
651 :     #define TEST_IDCT (0)
652 :    
653 : suxen_drol 1.42 static int test_transform(void * funcA, void * funcB, const char * nameB,
654 : edgomez 1.41 int test, int flags)
655 :     {
656 :     int i;
657 :     int64_t timeSTART;
658 :     int64_t timeA = 0;
659 :     int64_t timeB = 0;
660 :     DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
661 :     DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
662 :     int min, max;
663 :     int count = 0;
664 :    
665 :     int tmp;
666 :     int min_error = 0x10000*64;
667 :     int max_error = 0;
668 :    
669 :    
670 :     if ((test & TEST_FORWARD)) /* forward */
671 :     {
672 :     min = -256;
673 :     max = 255;
674 :     }else{ /* inverse */
675 :     min = -2048;
676 :     max = 2047;
677 :     }
678 :    
679 :     for (i = 0; i < 64*64; i++)
680 :     {
681 :     if ((flags & XVID_TEST_RANDOM))
682 :     {
683 :     random16(arrayA, 64, min, max);
684 :     }else{
685 :     fill16(arrayA, 64, i);
686 :     }
687 :     memcpy(arrayB, arrayA, 64*sizeof(int16_t));
688 :    
689 :     if ((test & TEST_FORWARD))
690 :     {
691 :     timeSTART = read_counter();
692 :     ((fdctFunc*)funcA)(arrayA);
693 :     timeA += read_counter() - timeSTART;
694 :    
695 :     timeSTART = read_counter();
696 :     ((fdctFunc*)funcB)(arrayB);
697 :     timeB += read_counter() - timeSTART;
698 :     }
699 :     else
700 :     {
701 :     timeSTART = read_counter();
702 :     ((idctFunc*)funcA)(arrayA);
703 :     timeA += read_counter() - timeSTART;
704 :    
705 :     timeSTART = read_counter();
706 :     ((idctFunc*)funcB)(arrayB);
707 :     timeB += read_counter() - timeSTART;
708 :     }
709 :    
710 :     tmp = diff16(arrayA, arrayB, 64) / 64;
711 :     if (tmp > max_error)
712 :     max_error = tmp;
713 :     if (tmp < min_error)
714 :     min_error = tmp;
715 :    
716 :     count++;
717 :     }
718 :    
719 :     /* print the "average difference" of best/worst transforms */
720 :     printf("%s:\t%i\t(min_error:%i, max_error:%i)\n", nameB, (int)(timeB / count), min_error, max_error);
721 :    
722 :     return 0;
723 :     }
724 :    
725 :    
726 :     #define TEST_QUANT 0x00000001 /* forward quantization */
727 :     #define TEST_INTRA 0x00000002 /* intra */
728 :     #define TEST_QUANT_INTRA (TEST_QUANT|TEST_INTRA)
729 :     #define TEST_QUANT_INTER (TEST_QUANT)
730 :     #define TEST_DEQUANT_INTRA (TEST_INTRA)
731 :     #define TEST_DEQUANT_INTER (0)
732 :    
733 : suxen_drol 1.42 static int test_quant(void * funcA, void * funcB, const char * nameB,
734 : edgomez 1.41 int test, int flags)
735 :     {
736 :     int q,i;
737 :     int64_t timeSTART;
738 :     int64_t timeA = 0;
739 :     int64_t timeB = 0;
740 : edgomez 1.43 int retA = 0, retB = 0;
741 : edgomez 1.41 DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE);
742 :     DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE);
743 :     DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE);
744 :     int min, max;
745 :     int count = 0;
746 :     int errors = 0;
747 :    
748 :     if ((test & TEST_QUANT)) /* quant */
749 :     {
750 :     min = -2048;
751 :     max = 2047;
752 :     }else{ /* dequant */
753 :     min = -256;
754 :     max = 255;
755 :     }
756 :    
757 :     for (q = 1; q <= 31; q++) /* quantizer */
758 :     {
759 :     for (i = min; i < max; i++) /* input coeff */
760 :     {
761 :     if ((flags & XVID_TEST_RANDOM))
762 :     {
763 :     random16(arrayX, 64, min, max);
764 :     }else{
765 :     fill16(arrayX, 64, i);
766 :     }
767 :    
768 :     if ((test & TEST_INTRA)) /* intra */
769 :     {
770 :     timeSTART = read_counter();
771 :     ((quanth263_intraFunc*)funcA)(arrayA, arrayX, q, q);
772 :     timeA += read_counter() - timeSTART;
773 :    
774 :     timeSTART = read_counter();
775 :     ((quanth263_intraFunc*)funcB)(arrayB, arrayX, q, q);
776 :     timeB += read_counter() - timeSTART;
777 :     }
778 :     else /* inter */
779 :     {
780 :     timeSTART = read_counter();
781 :     retA = ((quanth263_interFunc*)funcA)(arrayA, arrayX, q);
782 :     timeA += read_counter() - timeSTART;
783 :    
784 :     timeSTART = read_counter();
785 :     retB = ((quanth263_interFunc*)funcB)(arrayB, arrayX, q);
786 :     timeB += read_counter() - timeSTART;
787 :     }
788 :    
789 :     /* compare return value from quant_inter, and compare (de)quantiz'd arrays */
790 :     if ( ((test&TEST_QUANT) && !(test&TEST_INTRA) && retA != retB ) ||
791 :     compare16(arrayA, arrayB, 64))
792 :     {
793 :     errors++;
794 :     if ((flags & XVID_TEST_VERBOSE))
795 :     printf("%s error: q=%i, i=%i\n", nameB, q, i);
796 :     }
797 :    
798 :     count++;
799 :     }
800 :     }
801 :    
802 :     printf("%s:\t%i", nameB, (int)(timeB / count));
803 :     if (errors>0)
804 :     printf("\t(%i errors out of %i)", errors, count);
805 :     printf("\n");
806 :    
807 :     return 0;
808 :     }
809 :    
810 :    
811 :    
812 :     int xvid_init_test(int flags)
813 :     {
814 : edgomez 1.45 #if defined(ARCH_IS_IA32)
815 :     int cpu_flags;
816 :     #endif
817 : edgomez 1.41
818 : edgomez 1.44 printf("XviD tests\n\n");
819 : edgomez 1.41
820 : edgomez 1.44 #if defined(ARCH_IS_IA32)
821 : edgomez 1.41 cpu_flags = detect_cpu_flags();
822 : edgomez 1.44 #endif
823 :    
824 : edgomez 1.41 idct_int32_init();
825 : edgomez 1.44 emms();
826 : edgomez 1.45
827 :     srand(time(0));
828 : edgomez 1.41
829 : edgomez 1.44 /* fDCT test */
830 : edgomez 1.41 printf("--- fdct ---\n");
831 :     test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags);
832 : edgomez 1.44
833 :     #if defined(ARCH_IS_IA32)
834 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
835 :     test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags);
836 :     if (cpu_flags & XVID_CPU_SSE2)
837 :     test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags);
838 : edgomez 1.44 #endif
839 : edgomez 1.41
840 : edgomez 1.44 /* iDCT test */
841 : edgomez 1.41 printf("\n--- idct ---\n");
842 :     test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags);
843 : edgomez 1.44
844 :     #if defined(ARCH_IS_IA32)
845 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
846 :     test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags);
847 :     if (cpu_flags & XVID_CPU_MMXEXT)
848 :     test_transform(idct_int32, idct_xmm, "xmm", TEST_IDCT, flags);
849 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
850 :     test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags);
851 :     if (cpu_flags & XVID_CPU_SSE2)
852 :     test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags);
853 : edgomez 1.44 #endif
854 : edgomez 1.41
855 : edgomez 1.44 /* Intra quantization test */
856 : edgomez 1.41 printf("\n--- quant intra ---\n");
857 :     test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags);
858 : edgomez 1.44
859 :     #if defined(ARCH_IS_IA32)
860 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
861 :     test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags);
862 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
863 :     test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags);
864 :     if (cpu_flags & XVID_CPU_SSE2)
865 :     test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags);
866 : edgomez 1.44 #endif
867 : edgomez 1.41
868 : edgomez 1.44 /* Inter quantization test */
869 : edgomez 1.41 printf("\n--- quant inter ---\n");
870 :     test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags);
871 : edgomez 1.44
872 :     #if defined(ARCH_IS_IA32)
873 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
874 :     test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags);
875 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
876 :     test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags);
877 :     if (cpu_flags & XVID_CPU_SSE2)
878 :     test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags);
879 : edgomez 1.44 #endif
880 : edgomez 1.41
881 : edgomez 1.44 /* Intra dequantization test */
882 : edgomez 1.41 printf("\n--- dequant intra ---\n");
883 :     test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags);
884 : edgomez 1.44
885 :     #if defined(ARCH_IS_IA32)
886 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
887 :     test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags);
888 :     if (cpu_flags & XVID_CPU_MMXEXT)
889 :     test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags);
890 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
891 :     test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags);
892 :     if (cpu_flags & XVID_CPU_SSE2)
893 :     test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags);
894 : edgomez 1.44 #endif
895 : edgomez 1.41
896 : edgomez 1.44 /* Inter dequantization test */
897 : edgomez 1.41 printf("\n--- dequant inter ---\n");
898 :     test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags);
899 : edgomez 1.44
900 :     #if defined(ARCH_IS_IA32)
901 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
902 :     test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags);
903 :     if (cpu_flags & XVID_CPU_MMXEXT)
904 :     test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags);
905 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
906 :     test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags);
907 :     if (cpu_flags & XVID_CPU_SSE2)
908 :     test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags);
909 : edgomez 1.44 #endif
910 : edgomez 1.41
911 : edgomez 1.44 /* Intra quantization test */
912 :     printf("\n--- quant4 intra ---\n");
913 : edgomez 1.41 test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags);
914 : edgomez 1.44
915 :     #if defined(ARCH_IS_IA32)
916 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
917 :     test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags);
918 :     if (cpu_flags & XVID_CPU_MMXEXT)
919 :     test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags);
920 : edgomez 1.44 #endif
921 : edgomez 1.41
922 : edgomez 1.44 /* Inter quantization test */
923 :     printf("\n--- quant4 inter ---\n");
924 : edgomez 1.41 test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags);
925 : edgomez 1.44
926 :     #if defined(ARCH_IS_IA32)
927 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
928 :     test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags);
929 :     if (cpu_flags & XVID_CPU_MMXEXT)
930 :     test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags);
931 : edgomez 1.44 #endif
932 : edgomez 1.41
933 : edgomez 1.44 /* Intra dequantization test */
934 :     printf("\n--- dequant4 intra ---\n");
935 : edgomez 1.41 test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags);
936 : edgomez 1.44
937 :     #if defined(ARCH_IS_IA32)
938 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
939 :     test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags);
940 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
941 :     test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags);
942 : edgomez 1.44 #endif
943 : edgomez 1.41
944 : edgomez 1.44 /* Inter dequantization test */
945 :     printf("\n--- dequant4 inter ---\n");
946 : edgomez 1.41 test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags);
947 : edgomez 1.44
948 :     #if defined(ARCH_IS_IA32)
949 : edgomez 1.41 if (cpu_flags & XVID_CPU_MMX)
950 :     test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags);
951 :     if (cpu_flags & XVID_CPU_3DNOWEXT)
952 :     test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags);
953 : edgomez 1.44 #endif
954 : edgomez 1.41
955 : edgomez 1.44 emms();
956 : Isibaar 1.1
957 :     return XVID_ERR_OK;
958 :     }
959 :    
960 : edgomez 1.41
961 :     int
962 :     xvid_init(void *handle,
963 :     int opt,
964 :     void *param1,
965 :     void *param2)
966 :     {
967 :     switch(opt)
968 :     {
969 :     case XVID_INIT_INIT :
970 :     return xvid_init_init((XVID_INIT_PARAM*)param1);
971 :    
972 :     case XVID_INIT_CONVERT :
973 :     return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1);
974 :    
975 :     case XVID_INIT_TEST :
976 : edgomez 1.44 {
977 :     ptr_t flags = (ptr_t)param1;
978 :     return xvid_init_test((int)flags);
979 :     }
980 : edgomez 1.41 default :
981 :     return XVID_ERR_FAIL;
982 :     }
983 :     }
984 :    
985 : edgomez 1.16 /*****************************************************************************
986 :     * XviD Native decoder entry point
987 :     *
988 :     * This function is just a wrapper to all the option cases.
989 :     *
990 :     * Returned values : XVID_ERR_FAIL when opt is invalid
991 :     * else returns the wrapped function result
992 :     *
993 :     ****************************************************************************/
994 :    
995 : edgomez 1.15 int
996 :     xvid_decore(void *handle,
997 :     int opt,
998 :     void *param1,
999 :     void *param2)
1000 : Isibaar 1.1 {
1001 : edgomez 1.15 switch (opt) {
1002 :     case XVID_DEC_DECODE:
1003 : edgomez 1.41 return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2);
1004 : edgomez 1.15
1005 :     case XVID_DEC_CREATE:
1006 : chenm001 1.29 return decoder_create((XVID_DEC_PARAM *) param1);
1007 : edgomez 1.15
1008 :     case XVID_DEC_DESTROY:
1009 :     return decoder_destroy((DECODER *) handle);
1010 : Isibaar 1.1
1011 :     default:
1012 : edgomez 1.15 return XVID_ERR_FAIL;
1013 :     }
1014 : Isibaar 1.1 }
1015 :    
1016 : edgomez 1.16
1017 :     /*****************************************************************************
1018 :     * XviD Native encoder entry point
1019 :     *
1020 :     * This function is just a wrapper to all the option cases.
1021 :     *
1022 :     * Returned values : XVID_ERR_FAIL when opt is invalid
1023 :     * else returns the wrapped function result
1024 :     *
1025 :     ****************************************************************************/
1026 : Isibaar 1.1
1027 : edgomez 1.15 int
1028 :     xvid_encore(void *handle,
1029 :     int opt,
1030 :     void *param1,
1031 :     void *param2)
1032 : Isibaar 1.1 {
1033 : edgomez 1.15 switch (opt) {
1034 :     case XVID_ENC_ENCODE:
1035 : edgomez 1.41
1036 :     if (((Encoder *) handle)->mbParam.max_bframes >= 0)
1037 : edgomez 1.44 return encoder_encode_bframes((Encoder *) handle,
1038 :     (XVID_ENC_FRAME *) param1,
1039 :     (XVID_ENC_STATS *) param2);
1040 : edgomez 1.41 else
1041 : edgomez 1.44 return encoder_encode((Encoder *) handle,
1042 :     (XVID_ENC_FRAME *) param1,
1043 :     (XVID_ENC_STATS *) param2);
1044 : edgomez 1.15
1045 :     case XVID_ENC_CREATE:
1046 :     return encoder_create((XVID_ENC_PARAM *) param1);
1047 :    
1048 :     case XVID_ENC_DESTROY:
1049 :     return encoder_destroy((Encoder *) handle);
1050 : Isibaar 1.1
1051 :     default:
1052 : edgomez 1.15 return XVID_ERR_FAIL;
1053 :     }
1054 : Isibaar 1.1 }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4