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

Annotation of /xvidcore/src/xvid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45.2.7 - (view) (download)

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

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