3 |
* XVID MPEG-4 VIDEO CODEC |
* XVID MPEG-4 VIDEO CODEC |
4 |
* - Native API implementation - |
* - Native API implementation - |
5 |
* |
* |
6 |
* Copyright(C) 2001-2002 Peter Ross <pross@xvid.org> |
* This program is an implementation of a part of one or more MPEG-4 |
7 |
|
* Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
8 |
|
* to use this software module in hardware or software products are |
9 |
|
* advised that its use may infringe existing patents or copyrights, and |
10 |
|
* any such use would be at such party's own risk. The original |
11 |
|
* developer of this software module and his/her company, and subsequent |
12 |
|
* editors and their companies, will have no liability for use of this |
13 |
|
* software or modifications or derivatives thereof. |
14 |
* |
* |
15 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder |
* This program is free software ; you can redistribute it and/or modify |
16 |
* |
* it under the terms of the GNU General Public License as published by |
|
* XviD is free software; you can redistribute it and/or modify it |
|
|
* under the terms of the GNU General Public License as published by |
|
17 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
18 |
* (at your option) any later version. |
* (at your option) any later version. |
19 |
* |
* |
26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* Under section 8 of the GNU General Public License, the copyright |
****************************************************************************/ |
30 |
* holders of XVID explicitly forbid distribution in the following |
|
31 |
* countries: |
/***************************************************************************** |
32 |
* |
* |
33 |
* - Japan |
* History |
34 |
* - United States of America |
* |
35 |
* |
* - 23.06.2002 added XVID_CPU_CHKONLY |
36 |
* Linking XviD statically or dynamically with other modules is making a |
* - 17.03.2002 Added interpolate8x8_halfpel_hv_xmm |
37 |
* combined work based on XviD. Thus, the terms and conditions of the |
* - 22.12.2001 API change: added xvid_init() - Isibaar |
38 |
* GNU General Public License cover the whole combination. |
* - 16.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
* |
|
|
* As a special exception, the copyright holders of XviD give you |
|
|
* permission to link XviD with independent modules that communicate with |
|
|
* XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
* license terms of these independent modules, and to copy and distribute |
|
|
* the resulting combined work under terms of your choice, provided that |
|
|
* every copy of the combined work is accompanied by a complete copy of |
|
|
* the source code of XviD (the version of XviD used to produce the |
|
|
* combined work), being distributed under the terms of the GNU General |
|
|
* Public License plus this exception. An independent module is a module |
|
|
* which is not derived from or based on XviD. |
|
|
* |
|
|
* Note that people who make modified versions of XviD are not obligated |
|
|
* to grant this special exception for their modified versions; it is |
|
|
* their choice whether to do so. The GNU General Public License gives |
|
|
* permission to release a modified version without this exception; this |
|
|
* exception also makes it possible to release a modified version which |
|
|
* carries forward this exception. |
|
39 |
* |
* |
40 |
* $Id$ |
* $Id$ |
41 |
* |
* |
42 |
****************************************************************************/ |
****************************************************************************/ |
43 |
|
|
44 |
|
#include <stdio.h> |
45 |
|
#include <stdlib.h> |
46 |
|
#include <string.h> |
47 |
|
#include <time.h> |
48 |
|
|
49 |
#include "xvid.h" |
#include "xvid.h" |
50 |
#include "decoder.h" |
#include "decoder.h" |
51 |
#include "encoder.h" |
#include "encoder.h" |
54 |
#include "dct/fdct.h" |
#include "dct/fdct.h" |
55 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
56 |
#include "image/interpolate8x8.h" |
#include "image/interpolate8x8.h" |
57 |
|
#include "image/reduced.h" |
58 |
#include "utils/mem_transfer.h" |
#include "utils/mem_transfer.h" |
59 |
|
#include "utils/mbfunctions.h" |
60 |
#include "quant/quant_h263.h" |
#include "quant/quant_h263.h" |
61 |
#include "quant/quant_mpeg4.h" |
#include "quant/quant_mpeg4.h" |
62 |
#include "motion/motion.h" |
#include "motion/motion.h" |
65 |
#include "utils/timer.h" |
#include "utils/timer.h" |
66 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
67 |
|
|
68 |
#if defined(ARCH_IS_IA32) && defined(EXPERIMENTAL_SSE2_CODE) |
#if defined(ARCH_IS_IA32) |
69 |
|
|
70 |
#ifdef _MSC_VER |
#if defined(_MSC_VER) |
71 |
#include <windows.h> |
#include <windows.h> |
72 |
#else |
#else |
73 |
#include <signal.h> |
#include <signal.h> |
74 |
#include <setjmp.h> |
#include <setjmp.h> |
|
#endif |
|
|
|
|
|
|
|
|
#ifndef _MSC_VER |
|
75 |
|
|
76 |
static jmp_buf mark; |
static jmp_buf mark; |
77 |
|
|
84 |
|
|
85 |
|
|
86 |
/* |
/* |
87 |
* Calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled |
calls the funcptr, and returns whether SIGILL (illegal instruction) was signalled |
88 |
* Return values: |
return values: |
89 |
* -1 : could not determine |
-1 : could not determine |
90 |
* 0 : SIGILL was *not* signalled |
0 : SIGILL was *not* signalled |
91 |
* 1 : SIGILL was signalled |
1 : SIGILL was signalled |
92 |
*/ |
*/ |
93 |
|
|
94 |
int |
int |
95 |
sigill_check(void (*func)()) |
sigill_check(void (*func)()) |
96 |
{ |
{ |
97 |
#ifdef _MSC_VER |
#if defined(_MSC_VER) |
98 |
_try { |
_try { |
99 |
func(); |
func(); |
100 |
} |
} |
128 |
} |
} |
129 |
#endif |
#endif |
130 |
|
|
131 |
|
|
132 |
|
/* detect cpu flags */ |
133 |
|
static unsigned int |
134 |
|
detect_cpu_flags() |
135 |
|
{ |
136 |
|
/* enable native assembly optimizations by default */ |
137 |
|
unsigned int cpu_flags = XVID_CPU_ASM; |
138 |
|
|
139 |
|
#if defined(ARCH_IS_IA32) |
140 |
|
cpu_flags |= check_cpu_features(); |
141 |
|
if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) |
142 |
|
cpu_flags &= ~XVID_CPU_SSE; |
143 |
|
|
144 |
|
if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) |
145 |
|
cpu_flags &= ~XVID_CPU_SSE2; |
146 |
|
#endif |
147 |
|
|
148 |
|
#if defined(ARCH_IS_PPC) |
149 |
|
#if defined(ARCH_IS_PPC_ALTIVEC) |
150 |
|
cpu_flags |= XVID_CPU_ALTIVEC; |
151 |
|
#endif |
152 |
|
#endif |
153 |
|
|
154 |
|
return cpu_flags; |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
/***************************************************************************** |
/***************************************************************************** |
159 |
* XviD Init Entry point |
* XviD Init Entry point |
160 |
* |
* |
169 |
* |
* |
170 |
****************************************************************************/ |
****************************************************************************/ |
171 |
|
|
172 |
int |
|
173 |
xvid_init(void *handle, |
static |
174 |
int opt, |
int xvid_init_init(XVID_INIT_PARAM * init_param) |
|
void *param1, |
|
|
void *param2) |
|
175 |
{ |
{ |
176 |
int cpu_flags; |
int cpu_flags; |
|
XVID_INIT_PARAM *init_param; |
|
|
|
|
|
init_param = (XVID_INIT_PARAM *) param1; |
|
177 |
|
|
178 |
/* Inform the client the API version */ |
/* Inform the client the API version */ |
179 |
init_param->api_version = API_VERSION; |
init_param->api_version = API_VERSION; |
188 |
|
|
189 |
} else { |
} else { |
190 |
|
|
191 |
cpu_flags = check_cpu_features(); |
cpu_flags = detect_cpu_flags(); |
|
|
|
|
#if defined(ARCH_IS_IA32) && defined(EXPERIMENTAL_SSE2_CODE) |
|
|
if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) |
|
|
cpu_flags &= ~XVID_CPU_SSE; |
|
|
|
|
|
if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) |
|
|
cpu_flags &= ~XVID_CPU_SSE2; |
|
|
#endif |
|
192 |
} |
} |
193 |
|
|
194 |
if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) |
if ((init_param->cpu_flags & XVID_CPU_CHKONLY)) |
229 |
transfer_8to16copy = transfer_8to16copy_c; |
transfer_8to16copy = transfer_8to16copy_c; |
230 |
transfer_16to8copy = transfer_16to8copy_c; |
transfer_16to8copy = transfer_16to8copy_c; |
231 |
transfer_8to16sub = transfer_8to16sub_c; |
transfer_8to16sub = transfer_8to16sub_c; |
232 |
|
transfer_8to16subro = transfer_8to16subro_c; |
233 |
transfer_8to16sub2 = transfer_8to16sub2_c; |
transfer_8to16sub2 = transfer_8to16sub2_c; |
234 |
transfer_16to8add = transfer_16to8add_c; |
transfer_16to8add = transfer_16to8add_c; |
235 |
transfer8x8_copy = transfer8x8_copy_c; |
transfer8x8_copy = transfer8x8_copy_c; |
236 |
|
|
237 |
|
/* Interlacing functions */ |
238 |
|
MBFieldTest = MBFieldTest_c; |
239 |
|
|
240 |
/* Image interpolation related functions */ |
/* Image interpolation related functions */ |
241 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_c; |
242 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_c; |
243 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_c; |
244 |
|
|
245 |
|
interpolate16x16_lowpass_h = interpolate16x16_lowpass_h_c; |
246 |
|
interpolate16x16_lowpass_v = interpolate16x16_lowpass_v_c; |
247 |
|
interpolate16x16_lowpass_hv = interpolate16x16_lowpass_hv_c; |
248 |
|
|
249 |
|
interpolate8x8_lowpass_h = interpolate8x8_lowpass_h_c; |
250 |
|
interpolate8x8_lowpass_v = interpolate8x8_lowpass_v_c; |
251 |
|
interpolate8x8_lowpass_hv = interpolate8x8_lowpass_hv_c; |
252 |
|
|
253 |
|
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_c; |
254 |
|
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_c; |
255 |
|
|
256 |
|
interpolate8x8_avg2 = interpolate8x8_avg2_c; |
257 |
|
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
258 |
|
|
259 |
|
/* reduced resoltuion */ |
260 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
261 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; |
262 |
|
vfilter_31 = xvid_VFilter_31_C; |
263 |
|
hfilter_31 = xvid_HFilter_31_C; |
264 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
265 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
266 |
|
|
267 |
/* Initialize internal colorspace transformation tables */ |
/* Initialize internal colorspace transformation tables */ |
268 |
colorspace_init(); |
colorspace_init(); |
269 |
|
|
270 |
/* All colorspace transformation functions User Format->YV12 */ |
/* All colorspace transformation functions User Format->YV12 */ |
271 |
|
yv12_to_yv12 = yv12_to_yv12_c; |
272 |
rgb555_to_yv12 = rgb555_to_yv12_c; |
rgb555_to_yv12 = rgb555_to_yv12_c; |
273 |
rgb565_to_yv12 = rgb565_to_yv12_c; |
rgb565_to_yv12 = rgb565_to_yv12_c; |
274 |
rgb24_to_yv12 = rgb24_to_yv12_c; |
bgr_to_yv12 = bgr_to_yv12_c; |
275 |
rgb32_to_yv12 = rgb32_to_yv12_c; |
bgra_to_yv12 = bgra_to_yv12_c; |
276 |
yuv_to_yv12 = yuv_to_yv12_c; |
abgr_to_yv12 = abgr_to_yv12_c; |
277 |
|
rgba_to_yv12 = rgba_to_yv12_c; |
278 |
yuyv_to_yv12 = yuyv_to_yv12_c; |
yuyv_to_yv12 = yuyv_to_yv12_c; |
279 |
uyvy_to_yv12 = uyvy_to_yv12_c; |
uyvy_to_yv12 = uyvy_to_yv12_c; |
280 |
|
|
281 |
|
rgb555i_to_yv12 = rgb555i_to_yv12_c; |
282 |
|
rgb565i_to_yv12 = rgb565i_to_yv12_c; |
283 |
|
bgri_to_yv12 = bgri_to_yv12_c; |
284 |
|
bgrai_to_yv12 = bgrai_to_yv12_c; |
285 |
|
abgri_to_yv12 = abgri_to_yv12_c; |
286 |
|
rgbai_to_yv12 = rgbai_to_yv12_c; |
287 |
|
yuyvi_to_yv12 = yuyvi_to_yv12_c; |
288 |
|
uyvyi_to_yv12 = uyvyi_to_yv12_c; |
289 |
|
|
290 |
|
|
291 |
/* All colorspace transformation functions YV12->User format */ |
/* All colorspace transformation functions YV12->User format */ |
292 |
yv12_to_rgb555 = yv12_to_rgb555_c; |
yv12_to_rgb555 = yv12_to_rgb555_c; |
293 |
yv12_to_rgb565 = yv12_to_rgb565_c; |
yv12_to_rgb565 = yv12_to_rgb565_c; |
294 |
yv12_to_rgb24 = yv12_to_rgb24_c; |
yv12_to_bgr = yv12_to_bgr_c; |
295 |
yv12_to_rgb32 = yv12_to_rgb32_c; |
yv12_to_bgra = yv12_to_bgra_c; |
296 |
yv12_to_yuv = yv12_to_yuv_c; |
yv12_to_abgr = yv12_to_abgr_c; |
297 |
|
yv12_to_rgba = yv12_to_rgba_c; |
298 |
yv12_to_yuyv = yv12_to_yuyv_c; |
yv12_to_yuyv = yv12_to_yuyv_c; |
299 |
yv12_to_uyvy = yv12_to_uyvy_c; |
yv12_to_uyvy = yv12_to_uyvy_c; |
300 |
|
|
301 |
|
yv12_to_rgb555i = yv12_to_rgb555i_c; |
302 |
|
yv12_to_rgb565i = yv12_to_rgb565i_c; |
303 |
|
yv12_to_bgri = yv12_to_bgri_c; |
304 |
|
yv12_to_bgrai = yv12_to_bgrai_c; |
305 |
|
yv12_to_abgri = yv12_to_abgri_c; |
306 |
|
yv12_to_rgbai = yv12_to_rgbai_c; |
307 |
|
yv12_to_yuyvi = yv12_to_yuyvi_c; |
308 |
|
yv12_to_uyvyi = yv12_to_uyvyi_c; |
309 |
|
|
310 |
/* Functions used in motion estimation algorithms */ |
/* Functions used in motion estimation algorithms */ |
311 |
calc_cbp = calc_cbp_c; |
calc_cbp = calc_cbp_c; |
312 |
sad16 = sad16_c; |
sad16 = sad16_c; |
314 |
sad16bi = sad16bi_c; |
sad16bi = sad16bi_c; |
315 |
sad8bi = sad8bi_c; |
sad8bi = sad8bi_c; |
316 |
dev16 = dev16_c; |
dev16 = dev16_c; |
317 |
|
sad16v = sad16v_c; |
318 |
|
|
319 |
Halfpel8_Refine = Halfpel8_Refine_c; |
// Halfpel8_Refine = Halfpel8_Refine_c; |
320 |
|
|
321 |
|
#if defined(ARCH_IS_IA32) |
322 |
|
|
323 |
|
if ((cpu_flags & XVID_CPU_ASM)) |
324 |
|
{ |
325 |
|
vfilter_31 = xvid_VFilter_31_x86; |
326 |
|
hfilter_31 = xvid_HFilter_31_x86; |
327 |
|
} |
328 |
|
|
329 |
|
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
330 |
|
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
331 |
|
(cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2)) |
332 |
|
{ |
333 |
|
/* Restore FPU context : emms_c is a nop functions */ |
334 |
|
emms = emms_mmx; |
335 |
|
} |
336 |
|
|
337 |
#ifdef ARCH_IS_IA32 |
if ((cpu_flags & XVID_CPU_MMX)) { |
|
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
|
338 |
|
|
339 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
340 |
fdct = fdct_mmx; |
fdct = fdct_mmx; |
341 |
idct = idct_mmx; |
idct = idct_mmx; |
342 |
|
|
|
/* To restore FPU context after mmx use */ |
|
|
emms = emms_mmx; |
|
|
|
|
343 |
/* Quantization related functions */ |
/* Quantization related functions */ |
344 |
quant_intra = quant_intra_mmx; |
quant_intra = quant_intra_mmx; |
345 |
dequant_intra = dequant_intra_mmx; |
dequant_intra = dequant_intra_mmx; |
355 |
transfer_8to16copy = transfer_8to16copy_mmx; |
transfer_8to16copy = transfer_8to16copy_mmx; |
356 |
transfer_16to8copy = transfer_16to8copy_mmx; |
transfer_16to8copy = transfer_16to8copy_mmx; |
357 |
transfer_8to16sub = transfer_8to16sub_mmx; |
transfer_8to16sub = transfer_8to16sub_mmx; |
358 |
|
transfer_8to16subro = transfer_8to16subro_mmx; |
359 |
transfer_8to16sub2 = transfer_8to16sub2_mmx; |
transfer_8to16sub2 = transfer_8to16sub2_mmx; |
360 |
transfer_16to8add = transfer_16to8add_mmx; |
transfer_16to8add = transfer_16to8add_mmx; |
361 |
transfer8x8_copy = transfer8x8_copy_mmx; |
transfer8x8_copy = transfer8x8_copy_mmx; |
362 |
|
|
363 |
|
/* Interlacing Functions */ |
364 |
|
MBFieldTest = MBFieldTest_mmx; |
365 |
|
|
366 |
/* Image Interpolation related functions */ |
/* Image Interpolation related functions */ |
367 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_mmx; |
368 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_mmx; |
369 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_mmx; |
370 |
|
|
371 |
/* Image RGB->YV12 related functions */ |
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_mmx; |
372 |
rgb24_to_yv12 = rgb24_to_yv12_mmx; |
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_mmx; |
373 |
rgb32_to_yv12 = rgb32_to_yv12_mmx; |
|
374 |
yuv_to_yv12 = yuv_to_yv12_mmx; |
interpolate8x8_avg2 = interpolate8x8_avg2_mmx; |
375 |
|
interpolate8x8_avg4 = interpolate8x8_avg4_mmx; |
376 |
|
|
377 |
|
/* reduced resolution */ |
378 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_mmx; |
379 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_mmx; |
380 |
|
hfilter_31 = xvid_HFilter_31_mmx; |
381 |
|
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_mmx; |
382 |
|
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_mmx; |
383 |
|
|
384 |
|
/* image input xxx_to_yv12 related functions */ |
385 |
|
yv12_to_yv12 = yv12_to_yv12_mmx; |
386 |
|
bgr_to_yv12 = bgr_to_yv12_mmx; |
387 |
|
bgra_to_yv12 = bgra_to_yv12_mmx; |
388 |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
389 |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
390 |
|
|
391 |
/* Image YV12->RGB related functions */ |
/* image output yv12_to_xxx related functions */ |
392 |
yv12_to_rgb24 = yv12_to_rgb24_mmx; |
yv12_to_bgr = yv12_to_bgr_mmx; |
393 |
yv12_to_rgb32 = yv12_to_rgb32_mmx; |
yv12_to_bgra = yv12_to_bgra_mmx; |
394 |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
yv12_to_yuyv = yv12_to_yuyv_mmx; |
395 |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
yv12_to_uyvy = yv12_to_uyvy_mmx; |
396 |
|
|
397 |
|
yv12_to_yuyvi = yv12_to_yuyvi_mmx; |
398 |
|
yv12_to_uyvyi = yv12_to_uyvyi_mmx; |
399 |
|
|
400 |
/* Motion estimation related functions */ |
/* Motion estimation related functions */ |
401 |
calc_cbp = calc_cbp_mmx; |
calc_cbp = calc_cbp_mmx; |
402 |
sad16 = sad16_mmx; |
sad16 = sad16_mmx; |
404 |
sad16bi = sad16bi_mmx; |
sad16bi = sad16bi_mmx; |
405 |
sad8bi = sad8bi_mmx; |
sad8bi = sad8bi_mmx; |
406 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
407 |
|
sad16v = sad16v_mmx; |
408 |
} |
} |
409 |
|
|
410 |
/* these 3dnow functions are faster than mmx, but slower than xmm. */ |
/* these 3dnow functions are faster than mmx, but slower than xmm. */ |
411 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW)) { |
412 |
|
|
413 |
|
emms = emms_3dn; |
414 |
|
|
415 |
/* ME functions */ |
/* ME functions */ |
416 |
sad16bi = sad16bi_3dn; |
sad16bi = sad16bi_3dn; |
417 |
sad8bi = sad8bi_3dn; |
sad8bi = sad8bi_3dn; |
418 |
|
|
419 |
|
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
420 |
|
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
421 |
} |
} |
422 |
|
|
423 |
|
|
424 |
if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
if ((cpu_flags & XVID_CPU_MMXEXT)) { |
425 |
|
|
426 |
/* Inverse DCT */ |
/* Inverse DCT */ |
427 |
idct = idct_xmm; |
idct = idct_xmm; |
431 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_xmm; |
432 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_xmm; |
433 |
|
|
434 |
|
/* reduced resolution */ |
435 |
|
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_xmm; |
436 |
|
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; |
437 |
|
|
438 |
/* Quantization */ |
/* Quantization */ |
439 |
|
quant4_intra = quant4_intra_xmm; |
440 |
|
quant4_inter = quant4_inter_xmm; |
441 |
|
|
442 |
dequant_intra = dequant_intra_xmm; |
dequant_intra = dequant_intra_xmm; |
443 |
dequant_inter = dequant_inter_xmm; |
dequant_inter = dequant_inter_xmm; |
444 |
|
|
446 |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
transfer_8to16sub2 = transfer_8to16sub2_xmm; |
447 |
|
|
448 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
449 |
yuv_to_yv12 = yuv_to_yv12_xmm; |
yv12_to_yv12 = yv12_to_yv12_xmm; |
450 |
|
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
451 |
|
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
452 |
|
|
453 |
/* ME functions */ |
/* ME functions */ |
454 |
sad16 = sad16_xmm; |
sad16 = sad16_xmm; |
456 |
sad16bi = sad16bi_xmm; |
sad16bi = sad16bi_xmm; |
457 |
sad8bi = sad8bi_xmm; |
sad8bi = sad8bi_xmm; |
458 |
dev16 = dev16_xmm; |
dev16 = dev16_xmm; |
459 |
|
sad16v = sad16v_xmm; |
460 |
} |
} |
461 |
|
|
462 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW)) { |
463 |
|
|
464 |
/* Interpolation */ |
/* Interpolation */ |
465 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
467 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
468 |
} |
} |
469 |
|
|
470 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOWEXT)) { |
471 |
#ifdef EXPERIMENTAL_SSE2_CODE |
|
472 |
|
/* Inverse DCT */ |
473 |
|
idct = idct_3dne; |
474 |
|
|
475 |
|
/* Buffer transfer */ |
476 |
|
transfer_8to16copy = transfer_8to16copy_3dne; |
477 |
|
transfer_16to8copy = transfer_16to8copy_3dne; |
478 |
|
transfer_8to16sub = transfer_8to16sub_3dne; |
479 |
|
transfer_8to16subro = transfer_8to16subro_3dne; |
480 |
|
transfer_8to16sub2 = transfer_8to16sub2_3dne; |
481 |
|
transfer_16to8add = transfer_16to8add_3dne; |
482 |
|
transfer8x8_copy = transfer8x8_copy_3dne; |
483 |
|
|
484 |
|
/* Quantization */ |
485 |
|
dequant4_intra = dequant4_intra_3dne; |
486 |
|
dequant4_inter = dequant4_inter_3dne; |
487 |
|
quant_intra = quant_intra_3dne; |
488 |
|
quant_inter = quant_inter_3dne; |
489 |
|
dequant_intra = dequant_intra_3dne; |
490 |
|
dequant_inter = dequant_inter_3dne; |
491 |
|
|
492 |
|
/* ME functions */ |
493 |
|
calc_cbp = calc_cbp_3dne; |
494 |
|
sad16 = sad16_3dne; |
495 |
|
sad8 = sad8_3dne; |
496 |
|
sad16bi = sad16bi_3dne; |
497 |
|
sad8bi = sad8bi_3dne; |
498 |
|
dev16 = dev16_3dne; |
499 |
|
|
500 |
|
/* Interpolation */ |
501 |
|
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne; |
502 |
|
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne; |
503 |
|
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne; |
504 |
|
} |
505 |
|
|
506 |
|
|
507 |
|
if ((cpu_flags & XVID_CPU_SSE2)) { |
508 |
|
|
509 |
calc_cbp = calc_cbp_sse2; |
calc_cbp = calc_cbp_sse2; |
510 |
|
|
514 |
quant_inter = quant_inter_sse2; |
quant_inter = quant_inter_sse2; |
515 |
dequant_inter = dequant_inter_sse2; |
dequant_inter = dequant_inter_sse2; |
516 |
|
|
517 |
/* ME */ |
#if defined(EXPERIMENTAL_SSE2_CODE) |
518 |
|
/* ME; slower than xmm */ |
519 |
sad16 = sad16_sse2; |
sad16 = sad16_sse2; |
520 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
521 |
|
#endif |
522 |
/* Forward and Inverse DCT */ |
/* Forward and Inverse DCT */ |
523 |
idct = idct_sse2; |
idct = idct_sse2; |
524 |
fdct = fdct_sse2; |
fdct = fdct_sse2; |
|
#endif |
|
525 |
} |
} |
|
|
|
526 |
#endif |
#endif |
527 |
|
|
528 |
#ifdef ARCH_IS_IA64 |
#if defined(ARCH_IS_IA64) |
529 |
if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? |
if ((cpu_flags & XVID_CPU_ASM)) { //use assembler routines? |
530 |
idct_ia64_init(); |
idct_ia64_init(); |
531 |
fdct = fdct_ia64; |
fdct = fdct_ia64; |
532 |
idct = idct_ia64; |
idct = idct_ia64; //not yet working, crashes |
533 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_ia64; |
534 |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; |
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_ia64; |
535 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_ia64; |
537 |
sad16bi = sad16bi_ia64; |
sad16bi = sad16bi_ia64; |
538 |
sad8 = sad8_ia64; |
sad8 = sad8_ia64; |
539 |
dev16 = dev16_ia64; |
dev16 = dev16_ia64; |
540 |
Halfpel8_Refine = Halfpel8_Refine_ia64; |
// Halfpel8_Refine = Halfpel8_Refine_ia64; |
541 |
quant_intra = quant_intra_ia64; |
quant_intra = quant_intra_ia64; |
542 |
dequant_intra = dequant_intra_ia64; |
dequant_intra = dequant_intra_ia64; |
543 |
quant_inter = quant_inter_ia64; |
quant_inter = quant_inter_ia64; |
548 |
transfer_8to16sub2 = transfer_8to16sub2_ia64; |
transfer_8to16sub2 = transfer_8to16sub2_ia64; |
549 |
transfer_16to8add = transfer_16to8add_ia64; |
transfer_16to8add = transfer_16to8add_ia64; |
550 |
transfer8x8_copy = transfer8x8_copy_ia64; |
transfer8x8_copy = transfer8x8_copy_ia64; |
551 |
// DEBUG("Using IA-64 assembler routines.\n"); |
DEBUG("Using IA-64 assembler routines.\n"); |
552 |
} |
} |
553 |
#endif |
#endif |
554 |
|
|
555 |
#ifdef ARCH_IS_PPC |
#if defined(ARCH_IS_PPC) |
556 |
#ifdef ARCH_IS_PPC_ALTIVEC |
if ((cpu_flags & XVID_CPU_ASM)) |
557 |
|
{ |
558 |
|
calc_cbp = calc_cbp_ppc; |
559 |
|
} |
560 |
|
|
561 |
|
if ((cpu_flags & XVID_CPU_ALTIVEC)) |
562 |
|
{ |
563 |
calc_cbp = calc_cbp_altivec; |
calc_cbp = calc_cbp_altivec; |
564 |
fdct = fdct_altivec; |
fdct = fdct_altivec; |
565 |
idct = idct_altivec; |
idct = idct_altivec; |
567 |
sad16 = sad16_altivec; |
sad16 = sad16_altivec; |
568 |
sad8 = sad8_altivec; |
sad8 = sad8_altivec; |
569 |
dev16 = dev16_altivec; |
dev16 = dev16_altivec; |
570 |
#else |
} |
|
calc_cbp = calc_cbp_ppc; |
|
571 |
#endif |
#endif |
572 |
|
|
573 |
|
return XVID_ERR_OK; |
574 |
|
} |
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
static int |
579 |
|
xvid_init_convert(XVID_INIT_CONVERTINFO* convert) |
580 |
|
{ |
581 |
|
// const int flip1 = (convert->input.colorspace & XVID_CSP_VFLIP) ^ (convert->output.colorspace & XVID_CSP_VFLIP); |
582 |
|
const int width = convert->width; |
583 |
|
const int height = convert->height; |
584 |
|
const int width2 = convert->width/2; |
585 |
|
const int height2 = convert->height/2; |
586 |
|
IMAGE img; |
587 |
|
|
588 |
|
switch (convert->input.colorspace & ~XVID_CSP_VFLIP) |
589 |
|
{ |
590 |
|
case XVID_CSP_YV12 : |
591 |
|
img.y = convert->input.y; |
592 |
|
img.v = (uint8_t*)convert->input.y + width*height; |
593 |
|
img.u = (uint8_t*)convert->input.y + width*height + width2*height2; |
594 |
|
image_output(&img, width, height, width, |
595 |
|
convert->output.y, convert->output.y_stride, |
596 |
|
convert->output.colorspace, convert->interlacing); |
597 |
|
break; |
598 |
|
|
599 |
|
default : |
600 |
|
return XVID_ERR_FORMAT; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
emms(); |
605 |
|
return XVID_ERR_OK; |
606 |
|
} |
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
void fill8(uint8_t * block, int size, int value) |
611 |
|
{ |
612 |
|
int i; |
613 |
|
for (i = 0; i < size; i++) |
614 |
|
block[i] = value; |
615 |
|
} |
616 |
|
|
617 |
|
void fill16(int16_t * block, int size, int value) |
618 |
|
{ |
619 |
|
int i; |
620 |
|
for (i = 0; i < size; i++) |
621 |
|
block[i] = value; |
622 |
|
} |
623 |
|
|
624 |
|
#define RANDOM(min,max) min + (rand() % (max-min)) |
625 |
|
|
626 |
|
void random8(uint8_t * block, int size, int min, int max) |
627 |
|
{ |
628 |
|
int i; |
629 |
|
for (i = 0; i < size; i++) |
630 |
|
block[i] = RANDOM(min,max); |
631 |
|
} |
632 |
|
|
633 |
|
void random16(int16_t * block, int size, int min, int max) |
634 |
|
{ |
635 |
|
int i; |
636 |
|
for (i = 0; i < size; i++) |
637 |
|
block[i] = RANDOM(min,max); |
638 |
|
} |
639 |
|
|
640 |
|
int compare16(const int16_t * blockA, const int16_t * blockB, int size) |
641 |
|
{ |
642 |
|
int i; |
643 |
|
for (i = 0; i < size; i++) |
644 |
|
if (blockA[i] != blockB[i]) |
645 |
|
return 1; |
646 |
|
|
647 |
|
return 0; |
648 |
|
} |
649 |
|
|
650 |
|
int diff16(const int16_t * blockA, const int16_t * blockB, int size) |
651 |
|
{ |
652 |
|
int i, diff = 0; |
653 |
|
for (i = 0; i < size; i++) |
654 |
|
diff += ABS(blockA[i]-blockB[i]); |
655 |
|
return diff; |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
|
#define XVID_TEST_RANDOM 0x00000001 /* random input data */ |
660 |
|
#define XVID_TEST_VERBOSE 0x00000002 /* verbose error output */ |
661 |
|
|
662 |
|
|
663 |
|
#define TEST_FORWARD 0x00000001 /* intra */ |
664 |
|
#define TEST_FDCT (TEST_FORWARD) |
665 |
|
#define TEST_IDCT (0) |
666 |
|
|
667 |
|
int test_transform(void * funcA, void * funcB, const char * nameB, |
668 |
|
int test, int flags) |
669 |
|
{ |
670 |
|
int i; |
671 |
|
int64_t timeSTART; |
672 |
|
int64_t timeA = 0; |
673 |
|
int64_t timeB = 0; |
674 |
|
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
675 |
|
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
676 |
|
int min, max; |
677 |
|
int count = 0; |
678 |
|
|
679 |
|
int tmp; |
680 |
|
int min_error = 0x10000*64; |
681 |
|
int max_error = 0; |
682 |
|
|
683 |
|
|
684 |
|
if ((test & TEST_FORWARD)) /* forward */ |
685 |
|
{ |
686 |
|
min = -256; |
687 |
|
max = 255; |
688 |
|
}else{ /* inverse */ |
689 |
|
min = -2048; |
690 |
|
max = 2047; |
691 |
|
} |
692 |
|
|
693 |
|
for (i = 0; i < 64*64; i++) |
694 |
|
{ |
695 |
|
if ((flags & XVID_TEST_RANDOM)) |
696 |
|
{ |
697 |
|
random16(arrayA, 64, min, max); |
698 |
|
}else{ |
699 |
|
fill16(arrayA, 64, i); |
700 |
|
} |
701 |
|
memcpy(arrayB, arrayA, 64*sizeof(int16_t)); |
702 |
|
|
703 |
|
if ((test & TEST_FORWARD)) |
704 |
|
{ |
705 |
|
timeSTART = read_counter(); |
706 |
|
((fdctFunc*)funcA)(arrayA); |
707 |
|
timeA += read_counter() - timeSTART; |
708 |
|
|
709 |
|
timeSTART = read_counter(); |
710 |
|
((fdctFunc*)funcB)(arrayB); |
711 |
|
timeB += read_counter() - timeSTART; |
712 |
|
} |
713 |
|
else |
714 |
|
{ |
715 |
|
timeSTART = read_counter(); |
716 |
|
((idctFunc*)funcA)(arrayA); |
717 |
|
timeA += read_counter() - timeSTART; |
718 |
|
|
719 |
|
timeSTART = read_counter(); |
720 |
|
((idctFunc*)funcB)(arrayB); |
721 |
|
timeB += read_counter() - timeSTART; |
722 |
|
} |
723 |
|
|
724 |
|
tmp = diff16(arrayA, arrayB, 64) / 64; |
725 |
|
if (tmp > max_error) |
726 |
|
max_error = tmp; |
727 |
|
if (tmp < min_error) |
728 |
|
min_error = tmp; |
729 |
|
|
730 |
|
count++; |
731 |
|
} |
732 |
|
|
733 |
|
/* print the "average difference" of best/worst transforms */ |
734 |
|
printf("%s:\t%i\t(min_error:%i, max_error:%i)\n", nameB, (int)(timeB / count), min_error, max_error); |
735 |
|
|
736 |
|
return 0; |
737 |
|
} |
738 |
|
|
739 |
|
|
740 |
|
#define TEST_QUANT 0x00000001 /* forward quantization */ |
741 |
|
#define TEST_INTRA 0x00000002 /* intra */ |
742 |
|
#define TEST_QUANT_INTRA (TEST_QUANT|TEST_INTRA) |
743 |
|
#define TEST_QUANT_INTER (TEST_QUANT) |
744 |
|
#define TEST_DEQUANT_INTRA (TEST_INTRA) |
745 |
|
#define TEST_DEQUANT_INTER (0) |
746 |
|
|
747 |
|
int test_quant(void * funcA, void * funcB, const char * nameB, |
748 |
|
int test, int flags) |
749 |
|
{ |
750 |
|
int q,i; |
751 |
|
int64_t timeSTART; |
752 |
|
int64_t timeA = 0; |
753 |
|
int64_t timeB = 0; |
754 |
|
int retA, retB; |
755 |
|
DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); |
756 |
|
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
757 |
|
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
758 |
|
int min, max; |
759 |
|
int count = 0; |
760 |
|
int errors = 0; |
761 |
|
|
762 |
|
if ((test & TEST_QUANT)) /* quant */ |
763 |
|
{ |
764 |
|
min = -2048; |
765 |
|
max = 2047; |
766 |
|
}else{ /* dequant */ |
767 |
|
min = -256; |
768 |
|
max = 255; |
769 |
|
} |
770 |
|
|
771 |
|
for (q = 1; q <= 31; q++) /* quantizer */ |
772 |
|
{ |
773 |
|
for (i = min; i < max; i++) /* input coeff */ |
774 |
|
{ |
775 |
|
if ((flags & XVID_TEST_RANDOM)) |
776 |
|
{ |
777 |
|
random16(arrayX, 64, min, max); |
778 |
|
}else{ |
779 |
|
fill16(arrayX, 64, i); |
780 |
|
} |
781 |
|
|
782 |
|
if ((test & TEST_INTRA)) /* intra */ |
783 |
|
{ |
784 |
|
timeSTART = read_counter(); |
785 |
|
((quanth263_intraFunc*)funcA)(arrayA, arrayX, q, q); |
786 |
|
timeA += read_counter() - timeSTART; |
787 |
|
|
788 |
|
timeSTART = read_counter(); |
789 |
|
((quanth263_intraFunc*)funcB)(arrayB, arrayX, q, q); |
790 |
|
timeB += read_counter() - timeSTART; |
791 |
|
} |
792 |
|
else /* inter */ |
793 |
|
{ |
794 |
|
timeSTART = read_counter(); |
795 |
|
retA = ((quanth263_interFunc*)funcA)(arrayA, arrayX, q); |
796 |
|
timeA += read_counter() - timeSTART; |
797 |
|
|
798 |
|
timeSTART = read_counter(); |
799 |
|
retB = ((quanth263_interFunc*)funcB)(arrayB, arrayX, q); |
800 |
|
timeB += read_counter() - timeSTART; |
801 |
|
} |
802 |
|
|
803 |
|
/* compare return value from quant_inter, and compare (de)quantiz'd arrays */ |
804 |
|
if ( ((test&TEST_QUANT) && !(test&TEST_INTRA) && retA != retB ) || |
805 |
|
compare16(arrayA, arrayB, 64)) |
806 |
|
{ |
807 |
|
errors++; |
808 |
|
if ((flags & XVID_TEST_VERBOSE)) |
809 |
|
printf("%s error: q=%i, i=%i\n", nameB, q, i); |
810 |
|
} |
811 |
|
|
812 |
|
count++; |
813 |
|
} |
814 |
|
} |
815 |
|
|
816 |
|
printf("%s:\t%i", nameB, (int)(timeB / count)); |
817 |
|
if (errors>0) |
818 |
|
printf("\t(%i errors out of %i)", errors, count); |
819 |
|
printf("\n"); |
820 |
|
|
821 |
|
return 0; |
822 |
|
} |
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
int xvid_init_test(int flags) |
827 |
|
{ |
828 |
|
int cpu_flags; |
829 |
|
|
830 |
|
srand(time(0)); |
831 |
|
|
832 |
|
printf("xvid_init_test\n"); |
833 |
|
|
834 |
|
#if defined(ARCH_X86) |
835 |
|
cpu_flags = detect_cpu_flags(); |
836 |
|
idct_int32_init(); |
837 |
|
emms_mmx(); |
838 |
|
|
839 |
|
printf("--- fdct ---\n"); |
840 |
|
test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags); |
841 |
|
if (cpu_flags & XVID_CPU_MMX) |
842 |
|
test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags); |
843 |
|
if (cpu_flags & XVID_CPU_SSE2) |
844 |
|
test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags); |
845 |
|
|
846 |
|
printf("\n--- idct ---\n"); |
847 |
|
test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags); |
848 |
|
if (cpu_flags & XVID_CPU_MMX) |
849 |
|
test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags); |
850 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
851 |
|
test_transform(idct_int32, idct_xmm, "xmm", TEST_IDCT, flags); |
852 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
853 |
|
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
854 |
|
if (cpu_flags & XVID_CPU_SSE2) |
855 |
|
test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags); |
856 |
|
|
857 |
|
printf("\n--- quant intra ---\n"); |
858 |
|
test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags); |
859 |
|
if (cpu_flags & XVID_CPU_MMX) |
860 |
|
test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
861 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
862 |
|
test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags); |
863 |
|
if (cpu_flags & XVID_CPU_SSE2) |
864 |
|
test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags); |
865 |
|
|
866 |
|
printf("\n--- quant inter ---\n"); |
867 |
|
test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags); |
868 |
|
if (cpu_flags & XVID_CPU_MMX) |
869 |
|
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
870 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
871 |
|
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
872 |
|
if (cpu_flags & XVID_CPU_SSE2) |
873 |
|
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
874 |
|
|
875 |
|
printf("\n--- dequant intra ---\n"); |
876 |
|
test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
877 |
|
if (cpu_flags & XVID_CPU_MMX) |
878 |
|
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
879 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
880 |
|
test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags); |
881 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
882 |
|
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
883 |
|
if (cpu_flags & XVID_CPU_SSE2) |
884 |
|
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
885 |
|
|
886 |
|
printf("\n--- dequant inter ---\n"); |
887 |
|
test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags); |
888 |
|
if (cpu_flags & XVID_CPU_MMX) |
889 |
|
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
890 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
891 |
|
test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags); |
892 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
893 |
|
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
894 |
|
if (cpu_flags & XVID_CPU_SSE2) |
895 |
|
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
896 |
|
|
897 |
|
printf("\n--- quant4_intra ---\n"); |
898 |
|
test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags); |
899 |
|
if (cpu_flags & XVID_CPU_MMX) |
900 |
|
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
901 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
902 |
|
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
903 |
|
|
904 |
|
printf("\n--- quant4_inter ---\n"); |
905 |
|
test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags); |
906 |
|
if (cpu_flags & XVID_CPU_MMX) |
907 |
|
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
908 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
909 |
|
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
910 |
|
|
911 |
|
printf("\n--- dequant4_intra ---\n"); |
912 |
|
test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
913 |
|
if (cpu_flags & XVID_CPU_MMX) |
914 |
|
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
915 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
916 |
|
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
917 |
|
|
918 |
|
printf("\n--- dequant4_inter ---\n"); |
919 |
|
test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags); |
920 |
|
if (cpu_flags & XVID_CPU_MMX) |
921 |
|
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
922 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
923 |
|
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
924 |
|
|
925 |
|
emms_mmx(); |
926 |
|
|
927 |
#endif |
#endif |
928 |
|
|
929 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
930 |
} |
} |
931 |
|
|
932 |
|
|
933 |
|
int |
934 |
|
xvid_init(void *handle, |
935 |
|
int opt, |
936 |
|
void *param1, |
937 |
|
void *param2) |
938 |
|
{ |
939 |
|
switch(opt) |
940 |
|
{ |
941 |
|
case XVID_INIT_INIT : |
942 |
|
return xvid_init_init((XVID_INIT_PARAM*)param1); |
943 |
|
|
944 |
|
case XVID_INIT_CONVERT : |
945 |
|
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
946 |
|
|
947 |
|
case XVID_INIT_TEST : |
948 |
|
return xvid_init_test((int)param1); |
949 |
|
|
950 |
|
default : |
951 |
|
return XVID_ERR_FAIL; |
952 |
|
} |
953 |
|
} |
954 |
|
|
955 |
/***************************************************************************** |
/***************************************************************************** |
956 |
* XviD Native decoder entry point |
* XviD Native decoder entry point |
957 |
* |
* |
970 |
{ |
{ |
971 |
switch (opt) { |
switch (opt) { |
972 |
case XVID_DEC_DECODE: |
case XVID_DEC_DECODE: |
973 |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1); |
return decoder_decode((DECODER *) handle, (XVID_DEC_FRAME *) param1, (XVID_DEC_STATS*) param2); |
974 |
|
|
975 |
case XVID_DEC_CREATE: |
case XVID_DEC_CREATE: |
976 |
return decoder_create((XVID_DEC_PARAM *) param1); |
return decoder_create((XVID_DEC_PARAM *) param1); |
1002 |
{ |
{ |
1003 |
switch (opt) { |
switch (opt) { |
1004 |
case XVID_ENC_ENCODE: |
case XVID_ENC_ENCODE: |
1005 |
|
|
1006 |
|
if (((Encoder *) handle)->mbParam.max_bframes >= 0) |
1007 |
|
return encoder_encode_bframes((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
1008 |
|
(XVID_ENC_STATS *) param2); |
1009 |
|
else |
1010 |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
return encoder_encode((Encoder *) handle, (XVID_ENC_FRAME *) param1, |
1011 |
(XVID_ENC_STATS *) param2); |
(XVID_ENC_STATS *) param2); |
1012 |
|
|