[svn] / branches / dev-api-4 / xvidcore / src / xvid.c Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (view) (download)

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

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