3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Native API implementation - |
* - Native API implementation - |
5 |
* |
* |
|
* This program is an implementation of a part of one or more MPEG-4 |
|
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
|
|
* to use this software module in hardware or software products are |
|
|
* advised that its use may infringe existing patents or copyrights, and |
|
|
* any such use would be at such party's own risk. The original |
|
|
* developer of this software module and his/her company, and subsequent |
|
|
* editors and their companies, will have no liability for use of this |
|
|
* software or modifications or derivatives thereof. |
|
|
* |
|
6 |
* This program is free software ; you can redistribute it and/or modify |
* 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 |
* 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 |
* the Free Software Foundation ; either version 2 of the License, or |
17 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
* |
* |
20 |
****************************************************************************/ |
* $Id: xvid.c,v 1.43 2003-02-19 21:13:00 edgomez Exp $ |
|
/***************************************************************************** |
|
|
* |
|
|
* History |
|
|
* |
|
|
* - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
|
|
* - 22.12.2001 API change: added xvid_init() - Isibaar |
|
|
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
* |
|
|
* $Id: xvid.c,v 1.19 2002-06-16 19:53:44 edgomez Exp $ |
|
21 |
* |
* |
22 |
****************************************************************************/ |
****************************************************************************/ |
23 |
|
|
24 |
|
#include <stdio.h> |
25 |
|
#include <stdlib.h> |
26 |
|
#include <string.h> |
27 |
|
#include <time.h> |
28 |
|
|
29 |
#include "xvid.h" |
#include "xvid.h" |
30 |
#include "decoder.h" |
#include "decoder.h" |
31 |
#include "encoder.h" |
#include "encoder.h" |
34 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
35 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
36 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
37 |
|
#include "image/reduced.h" |
38 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
39 |
|
#include "utils/mbfunctions.h" |
40 |
#include "quant/quant_h263.h" |
#include "quant/quant_h263.h" |
41 |
#include "quant/quant_mpeg4.h" |
#include "quant/quant_mpeg4.h" |
42 |
|
#include "motion/motion.h" |
43 |
#include "motion/sad.h" |
#include "motion/sad.h" |
44 |
#include "utils/emms.h" |
#include "utils/emms.h" |
45 |
#include "utils/timer.h" |
#include "utils/timer.h" |
46 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
47 |
|
|
48 |
|
#if defined(ARCH_IS_IA32) |
49 |
|
|
50 |
|
#if defined(_MSC_VER) |
51 |
|
# include <windows.h> |
52 |
|
#else |
53 |
|
# include <signal.h> |
54 |
|
# include <setjmp.h> |
55 |
|
|
56 |
|
static jmp_buf mark; |
57 |
|
|
58 |
|
static void |
59 |
|
sigill_handler(int signal) |
60 |
|
{ |
61 |
|
longjmp(mark, 1); |
62 |
|
} |
63 |
|
#endif |
64 |
|
|
65 |
|
|
66 |
|
/* |
67 |
|
* 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 |
|
|
76 |
|
int |
77 |
|
sigill_check(void (*func)()) |
78 |
|
{ |
79 |
|
#if defined(_MSC_VER) |
80 |
|
_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 |
|
|
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 |
/***************************************************************************** |
/***************************************************************************** |
141 |
* XviD Init Entry point |
* XviD Init Entry point |
142 |
* |
* |
151 |
* |
* |
152 |
****************************************************************************/ |
****************************************************************************/ |
153 |
|
|
154 |
int |
|
155 |
xvid_init(void *handle, |
static |
156 |
int opt, |
int xvid_init_init(XVID_INIT_PARAM * init_param) |
|
void *param1, |
|
|
void *param2) |
|
157 |
{ |
{ |
158 |
int cpu_flags; |
int cpu_flags; |
|
XVID_INIT_PARAM *init_param; |
|
159 |
|
|
160 |
init_param = (XVID_INIT_PARAM *) param1; |
/* 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 |
/* Do we have to force CPU features ? */ |
/* Do we have to force CPU features ? */ |
167 |
if ((init_param->cpu_flags & XVID_CPU_FORCE) > 0) { |
if ((init_param->cpu_flags & XVID_CPU_FORCE)) { |
168 |
|
|
169 |
cpu_flags = init_param->cpu_flags; |
cpu_flags = init_param->cpu_flags; |
170 |
|
|
171 |
} else { |
} else { |
172 |
|
|
173 |
#ifdef ARCH_X86 |
cpu_flags = detect_cpu_flags(); |
174 |
cpu_flags = check_cpu_features(); |
} |
175 |
#else |
|
176 |
cpu_flags = 0; |
if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) |
177 |
#endif |
{ |
178 |
init_param->cpu_flags = cpu_flags; |
init_param->cpu_flags = cpu_flags; |
179 |
|
return XVID_ERR_OK; |
180 |
} |
} |
181 |
|
|
182 |
|
init_param->cpu_flags = cpu_flags; |
183 |
|
|
184 |
|
|
185 |
/* Initialize the function pointers */ |
/* Initialize the function pointers */ |
186 |
idct_int32_init(); |
idct_int32_init(); |
187 |
init_vlc_tables(); |
init_vlc_tables(); |
211 |
transfer_8to16copy = transfer_8to16copy_c; |
transfer_8to16copy = transfer_8to16copy_c; |
212 |
transfer_16to8copy = transfer_16to8copy_c; |
transfer_16to8copy = transfer_16to8copy_c; |
213 |
transfer_8to16sub = transfer_8to16sub_c; |
transfer_8to16sub = transfer_8to16sub_c; |
214 |
|
transfer_8to16subro = transfer_8to16subro_c; |
215 |
transfer_8to16sub2 = transfer_8to16sub2_c; |
transfer_8to16sub2 = transfer_8to16sub2_c; |
216 |
transfer_16to8add = transfer_16to8add_c; |
transfer_16to8add = transfer_16to8add_c; |
217 |
transfer8x8_copy = transfer8x8_copy_c; |
transfer8x8_copy = transfer8x8_copy_c; |
218 |
|
|
219 |
|
/* Interlacing functions */ |
220 |
|
MBFieldTest = MBFieldTest_c; |
221 |
|
|
222 |
/* Image interpolation related functions */ |
/* Image interpolation related functions */ |
223 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
224 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
225 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
226 |
|
|
227 |
|
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 |
/* Initialize internal colorspace transformation tables */ |
/* Initialize internal colorspace transformation tables */ |
250 |
colorspace_init(); |
colorspace_init(); |
251 |
|
|
252 |
/* All colorspace transformation functions User Format->YV12 */ |
/* All colorspace transformation functions User Format->YV12 */ |
253 |
|
yv12_to_yv12 = yv12_to_yv12_c; |
254 |
rgb555_to_yv12 = rgb555_to_yv12_c; |
rgb555_to_yv12 = rgb555_to_yv12_c; |
255 |
rgb565_to_yv12 = rgb565_to_yv12_c; |
rgb565_to_yv12 = rgb565_to_yv12_c; |
256 |
rgb24_to_yv12 = rgb24_to_yv12_c; |
bgr_to_yv12 = bgr_to_yv12_c; |
257 |
rgb32_to_yv12 = rgb32_to_yv12_c; |
bgra_to_yv12 = bgra_to_yv12_c; |
258 |
yuv_to_yv12 = yuv_to_yv12_c; |
abgr_to_yv12 = abgr_to_yv12_c; |
259 |
|
rgba_to_yv12 = rgba_to_yv12_c; |
260 |
yuyv_to_yv12 = yuyv_to_yv12_c; |
yuyv_to_yv12 = yuyv_to_yv12_c; |
261 |
uyvy_to_yv12 = uyvy_to_yv12_c; |
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 |
|
|
273 |
/* All colorspace transformation functions YV12->User format */ |
/* All colorspace transformation functions YV12->User format */ |
274 |
yv12_to_rgb555 = yv12_to_rgb555_c; |
yv12_to_rgb555 = yv12_to_rgb555_c; |
275 |
yv12_to_rgb565 = yv12_to_rgb565_c; |
yv12_to_rgb565 = yv12_to_rgb565_c; |
276 |
yv12_to_rgb24 = yv12_to_rgb24_c; |
yv12_to_bgr = yv12_to_bgr_c; |
277 |
yv12_to_rgb32 = yv12_to_rgb32_c; |
yv12_to_bgra = yv12_to_bgra_c; |
278 |
yv12_to_yuv = yv12_to_yuv_c; |
yv12_to_abgr = yv12_to_abgr_c; |
279 |
|
yv12_to_rgba = yv12_to_rgba_c; |
280 |
yv12_to_yuyv = yv12_to_yuyv_c; |
yv12_to_yuyv = yv12_to_yuyv_c; |
281 |
yv12_to_uyvy = yv12_to_uyvy_c; |
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 |
|
|
292 |
/* Functions used in motion estimation algorithms */ |
/* Functions used in motion estimation algorithms */ |
293 |
calc_cbp = calc_cbp_c; |
calc_cbp = calc_cbp_c; |
294 |
sad16 = sad16_c; |
sad16 = sad16_c; |
|
sad16bi = sad16bi_c; |
|
295 |
sad8 = sad8_c; |
sad8 = sad8_c; |
296 |
|
sad16bi = sad16bi_c; |
297 |
|
sad8bi = sad8bi_c; |
298 |
dev16 = dev16_c; |
dev16 = dev16_c; |
299 |
|
sad16v = sad16v_c; |
300 |
|
|
301 |
|
/* Halfpel8_Refine = Halfpel8_Refine_c; */ |
302 |
|
|
303 |
|
#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 |
#ifdef ARCH_X86 |
if ((cpu_flags & XVID_CPU_MMX)) { |
|
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
|
320 |
|
|
321 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
322 |
fdct = fdct_mmx; |
fdct = fdct_mmx; |
323 |
idct = idct_mmx; |
idct = idct_mmx; |
324 |
|
|
|
/* To restore FPU context after mmx use */ |
|
|
emms = emms_mmx; |
|
|
|
|
325 |
/* Quantization related functions */ |
/* Quantization related functions */ |
326 |
quant_intra = quant_intra_mmx; |
quant_intra = quant_intra_mmx; |
327 |
dequant_intra = dequant_intra_mmx; |
dequant_intra = dequant_intra_mmx; |
337 |
transfer_8to16copy = transfer_8to16copy_mmx; |
transfer_8to16copy = transfer_8to16copy_mmx; |
338 |
transfer_16to8copy = transfer_16to8copy_mmx; |
transfer_16to8copy = transfer_16to8copy_mmx; |
339 |
transfer_8to16sub = transfer_8to16sub_mmx; |
transfer_8to16sub = transfer_8to16sub_mmx; |
340 |
|
transfer_8to16subro = transfer_8to16subro_mmx; |
341 |
|
transfer_8to16sub2 = transfer_8to16sub2_mmx; |
342 |
transfer_16to8add = transfer_16to8add_mmx; |
transfer_16to8add = transfer_16to8add_mmx; |
343 |
transfer8x8_copy = transfer8x8_copy_mmx; |
transfer8x8_copy = transfer8x8_copy_mmx; |
344 |
|
|
345 |
|
/* Interlacing Functions */ |
346 |
|
MBFieldTest = MBFieldTest_mmx; |
347 |
|
|
348 |
/* Image Interpolation related functions */ |
/* Image Interpolation related functions */ |
349 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
350 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
351 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
352 |
|
|
353 |
/* Image RGB->YV12 related functions */ |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
354 |
rgb24_to_yv12 = rgb24_to_yv12_mmx; |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
355 |
rgb32_to_yv12 = rgb32_to_yv12_mmx; |
|
356 |
yuv_to_yv12 = yuv_to_yv12_mmx; |
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 |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
371 |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
372 |
|
|
373 |
/* Image YV12->RGB related functions */ |
/* image output yv12_to_xxx related functions */ |
374 |
yv12_to_rgb24 = yv12_to_rgb24_mmx; |
yv12_to_bgr = yv12_to_bgr_mmx; |
375 |
yv12_to_rgb32 = yv12_to_rgb32_mmx; |
yv12_to_bgra = yv12_to_bgra_mmx; |
376 |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
377 |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
378 |
|
|
379 |
|
yv12_to_yuyvi = yv12_to_yuyvi_mmx; |
380 |
|
yv12_to_uyvyi = yv12_to_uyvyi_mmx; |
381 |
|
|
382 |
/* Motion estimation related functions */ |
/* Motion estimation related functions */ |
383 |
calc_cbp = calc_cbp_mmx; |
calc_cbp = calc_cbp_mmx; |
384 |
sad16 = sad16_mmx; |
sad16 = sad16_mmx; |
385 |
sad8 = sad8_mmx; |
sad8 = sad8_mmx; |
386 |
|
sad16bi = sad16bi_mmx; |
387 |
|
sad8bi = sad8bi_mmx; |
388 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
389 |
|
sad16v = sad16v_mmx; |
390 |
|
} |
391 |
|
|
392 |
|
/* these 3dnow functions are faster than mmx, but slower than xmm. */ |
393 |
|
if ((cpu_flags & XVID_CPU_3DNOW)) { |
394 |
|
|
395 |
|
emms = emms_3dn; |
396 |
|
|
397 |
|
/* ME functions */ |
398 |
|
sad16bi = sad16bi_3dn; |
399 |
|
sad8bi = sad8bi_3dn; |
400 |
|
|
401 |
|
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
402 |
|
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
403 |
} |
} |
404 |
|
|
405 |
if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
|
406 |
|
if ((cpu_flags & XVID_CPU_MMXEXT)) { |
407 |
|
|
408 |
/* Inverse DCT */ |
/* Inverse DCT */ |
409 |
idct = idct_xmm; |
idct = idct_xmm; |
413 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
414 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
415 |
|
|
416 |
|
/* 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 |
|
/* Quantization */ |
421 |
|
quant4_intra = quant4_intra_xmm; |
422 |
|
quant4_inter = quant4_inter_xmm; |
423 |
|
|
424 |
|
dequant_intra = dequant_intra_xmm; |
425 |
|
dequant_inter = dequant_inter_xmm; |
426 |
|
|
427 |
/* Buffer transfer */ |
/* Buffer transfer */ |
428 |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
429 |
|
|
430 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
431 |
yuv_to_yv12 = yuv_to_yv12_xmm; |
yv12_to_yv12 = yv12_to_yv12_xmm; |
432 |
|
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
433 |
|
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
434 |
|
|
435 |
/* ME functions */ |
/* ME functions */ |
436 |
sad16 = sad16_xmm; |
sad16 = sad16_xmm; |
437 |
sad8 = sad8_xmm; |
sad8 = sad8_xmm; |
438 |
|
sad16bi = sad16bi_xmm; |
439 |
|
sad8bi = sad8bi_xmm; |
440 |
dev16 = dev16_xmm; |
dev16 = dev16_xmm; |
441 |
|
sad16v = sad16v_xmm; |
442 |
} |
} |
443 |
|
|
444 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW)) { |
445 |
|
|
446 |
/* Interpolation */ |
/* Interpolation */ |
447 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
449 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
450 |
} |
} |
451 |
|
|
452 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOWEXT)) { |
453 |
#ifdef EXPERIMENTAL_SSE2_CODE |
|
454 |
|
/* Inverse DCT */ |
455 |
|
idct = idct_3dne; |
456 |
|
|
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 |
|
|
491 |
|
calc_cbp = calc_cbp_sse2; |
492 |
|
|
493 |
/* Quantization */ |
/* Quantization */ |
494 |
quant_intra = quant_intra_sse2; |
quant_intra = quant_intra_sse2; |
496 |
quant_inter = quant_inter_sse2; |
quant_inter = quant_inter_sse2; |
497 |
dequant_inter = dequant_inter_sse2; |
dequant_inter = dequant_inter_sse2; |
498 |
|
|
499 |
/* ME */ |
#if defined(EXPERIMENTAL_SSE2_CODE) |
500 |
calc_cbp = calc_cbp_sse2; |
/* ME; slower than xmm */ |
501 |
sad16 = sad16_sse2; |
sad16 = sad16_sse2; |
502 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
503 |
|
#endif |
504 |
/* Forward and Inverse DCT */ |
/* Forward and Inverse DCT */ |
505 |
idct = idct_sse2; |
idct = idct_sse2; |
506 |
fdct = fdct_sse2; |
fdct = fdct_sse2; |
|
#endif |
|
507 |
} |
} |
|
|
|
508 |
#endif |
#endif |
509 |
|
|
510 |
#ifdef ARCH_IA64 |
#if defined(ARCH_IS_IA64) |
511 |
if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? |
if ((cpu_flags & XVID_CPU_ASM)) { /* use assembler routines? */ |
512 |
idct_ia64_init(); |
idct_ia64_init(); |
513 |
fdct = fdct_ia64; |
fdct = fdct_ia64; |
514 |
idct = idct_ia64; //not yet working, crashes |
idct = idct_ia64; /*not yet working, crashes */ |
515 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; |
516 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; |
517 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; |
519 |
sad16bi = sad16bi_ia64; |
sad16bi = sad16bi_ia64; |
520 |
sad8 = sad8_ia64; |
sad8 = sad8_ia64; |
521 |
dev16 = dev16_ia64; |
dev16 = dev16_ia64; |
522 |
|
/* Halfpel8_Refine = Halfpel8_Refine_ia64; */ |
523 |
quant_intra = quant_intra_ia64; |
quant_intra = quant_intra_ia64; |
524 |
dequant_intra = dequant_intra_ia64; |
dequant_intra = dequant_intra_ia64; |
525 |
quant_inter = quant_inter_ia64; |
quant_inter = quant_inter_ia64; |
530 |
transfer_8to16sub2 = transfer_8to16sub2_ia64; |
transfer_8to16sub2 = transfer_8to16sub2_ia64; |
531 |
transfer_16to8add = transfer_16to8add_ia64; |
transfer_16to8add = transfer_16to8add_ia64; |
532 |
transfer8x8_copy = transfer8x8_copy_ia64; |
transfer8x8_copy = transfer8x8_copy_ia64; |
533 |
DEBUG("Using IA-64 assembler routines.\n"); |
DPRINTF(DPRINTF_DEBUG, "Using IA-64 assembler routines."); |
534 |
} |
} |
535 |
#endif |
#endif |
536 |
|
|
537 |
#ifdef ARCH_PPC |
#if defined(ARCH_IS_PPC) |
538 |
#ifdef ARCH_PPC_ALTIVEC |
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; |
calc_cbp = calc_cbp_altivec; |
546 |
fdct = fdct_altivec; |
fdct = fdct_altivec; |
547 |
idct = idct_altivec; |
idct = idct_altivec; |
549 |
sad16 = sad16_altivec; |
sad16 = sad16_altivec; |
550 |
sad8 = sad8_altivec; |
sad8 = sad8_altivec; |
551 |
dev16 = dev16_altivec; |
dev16 = dev16_altivec; |
552 |
#else |
} |
|
calc_cbp = calc_cbp_ppc; |
|
|
#endif |
|
553 |
#endif |
#endif |
554 |
|
|
555 |
/* Inform the client the API version */ |
return XVID_ERR_OK; |
556 |
init_param->api_version = API_VERSION; |
} |
557 |
|
|
|
/* Inform the client the core build - unused because we're still alpha */ |
|
|
init_param->core_build = 1000; |
|
558 |
|
|
559 |
|
|
560 |
|
static int |
561 |
|
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
562 |
|
{ |
563 |
|
/* |
564 |
|
const int flip1 = |
565 |
|
(convert->input.colorspace & XVID_CSP_VFLIP) ^ |
566 |
|
(convert->output.colorspace & XVID_CSP_VFLIP); |
567 |
|
*/ |
568 |
|
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; |
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 |
|
static int test_transform(void * funcA, void * funcB, const char * nameB, |
654 |
|
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 |
|
static int test_quant(void * funcA, void * funcB, const char * nameB, |
734 |
|
int test, int flags) |
735 |
|
{ |
736 |
|
int q,i; |
737 |
|
int64_t timeSTART; |
738 |
|
int64_t timeA = 0; |
739 |
|
int64_t timeB = 0; |
740 |
|
int retA = 0, retB = 0; |
741 |
|
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 |
|
int cpu_flags; |
815 |
|
|
816 |
|
srand(time(0)); |
817 |
|
|
818 |
|
printf("xvid_init_test\n"); |
819 |
|
|
820 |
|
#if defined(ARCH_IS_IA32) |
821 |
|
cpu_flags = detect_cpu_flags(); |
822 |
|
idct_int32_init(); |
823 |
|
emms_mmx(); |
824 |
|
|
825 |
|
printf("--- fdct ---\n"); |
826 |
|
test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags); |
827 |
|
if (cpu_flags & XVID_CPU_MMX) |
828 |
|
test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags); |
829 |
|
if (cpu_flags & XVID_CPU_SSE2) |
830 |
|
test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags); |
831 |
|
|
832 |
|
printf("\n--- idct ---\n"); |
833 |
|
test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags); |
834 |
|
if (cpu_flags & XVID_CPU_MMX) |
835 |
|
test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags); |
836 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
837 |
|
test_transform(idct_int32, idct_xmm, "xmm", TEST_IDCT, flags); |
838 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
839 |
|
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
840 |
|
if (cpu_flags & XVID_CPU_SSE2) |
841 |
|
test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags); |
842 |
|
|
843 |
|
printf("\n--- quant intra ---\n"); |
844 |
|
test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags); |
845 |
|
if (cpu_flags & XVID_CPU_MMX) |
846 |
|
test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
847 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
848 |
|
test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags); |
849 |
|
if (cpu_flags & XVID_CPU_SSE2) |
850 |
|
test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags); |
851 |
|
|
852 |
|
printf("\n--- quant inter ---\n"); |
853 |
|
test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags); |
854 |
|
if (cpu_flags & XVID_CPU_MMX) |
855 |
|
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
856 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
857 |
|
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
858 |
|
if (cpu_flags & XVID_CPU_SSE2) |
859 |
|
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
860 |
|
|
861 |
|
printf("\n--- dequant intra ---\n"); |
862 |
|
test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
863 |
|
if (cpu_flags & XVID_CPU_MMX) |
864 |
|
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
865 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
866 |
|
test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags); |
867 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
868 |
|
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
869 |
|
if (cpu_flags & XVID_CPU_SSE2) |
870 |
|
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
871 |
|
|
872 |
|
printf("\n--- dequant inter ---\n"); |
873 |
|
test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags); |
874 |
|
if (cpu_flags & XVID_CPU_MMX) |
875 |
|
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
876 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
877 |
|
test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags); |
878 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
879 |
|
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
880 |
|
if (cpu_flags & XVID_CPU_SSE2) |
881 |
|
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
882 |
|
|
883 |
|
printf("\n--- quant4_intra ---\n"); |
884 |
|
test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags); |
885 |
|
if (cpu_flags & XVID_CPU_MMX) |
886 |
|
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
887 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
888 |
|
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
889 |
|
|
890 |
|
printf("\n--- quant4_inter ---\n"); |
891 |
|
test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags); |
892 |
|
if (cpu_flags & XVID_CPU_MMX) |
893 |
|
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
894 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
895 |
|
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
896 |
|
|
897 |
|
printf("\n--- dequant4_intra ---\n"); |
898 |
|
test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
899 |
|
if (cpu_flags & XVID_CPU_MMX) |
900 |
|
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
901 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
902 |
|
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
903 |
|
|
904 |
|
printf("\n--- dequant4_inter ---\n"); |
905 |
|
test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags); |
906 |
|
if (cpu_flags & XVID_CPU_MMX) |
907 |
|
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
908 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
909 |
|
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
910 |
|
|
911 |
|
emms_mmx(); |
912 |
|
|
913 |
|
#endif |
914 |
|
|
915 |
|
return XVID_ERR_OK; |
916 |
|
} |
917 |
|
|
918 |
|
|
919 |
|
int |
920 |
|
xvid_init(void *handle, |
921 |
|
int opt, |
922 |
|
void *param1, |
923 |
|
void *param2) |
924 |
|
{ |
925 |
|
switch(opt) |
926 |
|
{ |
927 |
|
case XVID_INIT_INIT : |
928 |
|
return xvid_init_init((XVID_INIT_PARAM*)param1); |
929 |
|
|
930 |
|
case XVID_INIT_CONVERT : |
931 |
|
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
932 |
|
|
933 |
|
case XVID_INIT_TEST : |
934 |
|
return xvid_init_test((int)param1); |
935 |
|
|
936 |
|
default : |
937 |
|
return XVID_ERR_FAIL; |
938 |
|
} |
939 |
|
} |
940 |
|
|
941 |
/***************************************************************************** |
/***************************************************************************** |
942 |
* XviD Native decoder entry point |
* XviD Native decoder entry point |
943 |
* |
* |
956 |
{ |
{ |
957 |
switch (opt) { |
switch (opt) { |
958 |
case XVID_DEC_DECODE: |
case XVID_DEC_DECODE: |
959 |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1); |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
960 |
|
|
961 |
case XVID_DEC_CREATE: |
case XVID_DEC_CREATE: |
962 |
return decoder_create((XVID_DEC_PARAM *) param1); |
return decoder_create((XVID_DEC_PARAM *) param1); |
988 |
{ |
{ |
989 |
switch (opt) { |
switch (opt) { |
990 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
991 |
|
|
992 |
|
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
993 |
|
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
994 |
|
(XVID_ENC_STATS *) param2); |
995 |
|
else |
996 |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
997 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
998 |
|
|