19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: xvid.c,v 1.65 2005-11-22 10:23:01 suxen_drol Exp $ |
* $Id: xvid.c,v 1.76 2008-11-27 00:47:03 Isibaar Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
40 |
#include "utils/mbfunctions.h" |
#include "utils/mbfunctions.h" |
41 |
#include "quant/quant.h" |
#include "quant/quant.h" |
42 |
#include "motion/motion.h" |
#include "motion/motion.h" |
43 |
|
#include "motion/gmc.h" |
44 |
#include "motion/sad.h" |
#include "motion/sad.h" |
45 |
#include "utils/emms.h" |
#include "utils/emms.h" |
46 |
#include "utils/timer.h" |
#include "utils/timer.h" |
137 |
if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) |
if ((cpu_flags & XVID_CPU_SSE) && sigill_check(sse_os_trigger)) |
138 |
cpu_flags &= ~XVID_CPU_SSE; |
cpu_flags &= ~XVID_CPU_SSE; |
139 |
|
|
140 |
if ((cpu_flags & XVID_CPU_SSE2) && sigill_check(sse2_os_trigger)) |
if ((cpu_flags & (XVID_CPU_SSE2|XVID_CPU_SSE3|XVID_CPU_SSE41)) && sigill_check(sse2_os_trigger)) |
141 |
cpu_flags &= ~XVID_CPU_SSE2; |
cpu_flags &= ~(XVID_CPU_SSE2|XVID_CPU_SSE3|XVID_CPU_SSE41); |
142 |
#endif |
#endif |
143 |
|
|
144 |
#if defined(ARCH_IS_PPC) |
#if defined(ARCH_IS_PPC) |
257 |
yv12_to_yv12 = yv12_to_yv12_c; |
yv12_to_yv12 = yv12_to_yv12_c; |
258 |
rgb555_to_yv12 = rgb555_to_yv12_c; |
rgb555_to_yv12 = rgb555_to_yv12_c; |
259 |
rgb565_to_yv12 = rgb565_to_yv12_c; |
rgb565_to_yv12 = rgb565_to_yv12_c; |
260 |
|
rgb_to_yv12 = rgb_to_yv12_c; |
261 |
bgr_to_yv12 = bgr_to_yv12_c; |
bgr_to_yv12 = bgr_to_yv12_c; |
262 |
bgra_to_yv12 = bgra_to_yv12_c; |
bgra_to_yv12 = bgra_to_yv12_c; |
263 |
abgr_to_yv12 = abgr_to_yv12_c; |
abgr_to_yv12 = abgr_to_yv12_c; |
279 |
/* All colorspace transformation functions YV12->User format */ |
/* All colorspace transformation functions YV12->User format */ |
280 |
yv12_to_rgb555 = yv12_to_rgb555_c; |
yv12_to_rgb555 = yv12_to_rgb555_c; |
281 |
yv12_to_rgb565 = yv12_to_rgb565_c; |
yv12_to_rgb565 = yv12_to_rgb565_c; |
282 |
|
yv12_to_rgb = yv12_to_rgb_c; |
283 |
yv12_to_bgr = yv12_to_bgr_c; |
yv12_to_bgr = yv12_to_bgr_c; |
284 |
yv12_to_bgra = yv12_to_bgra_c; |
yv12_to_bgra = yv12_to_bgra_c; |
285 |
yv12_to_abgr = yv12_to_abgr_c; |
yv12_to_abgr = yv12_to_abgr_c; |
309 |
sse8_16bit = sse8_16bit_c; |
sse8_16bit = sse8_16bit_c; |
310 |
sse8_8bit = sse8_8bit_c; |
sse8_8bit = sse8_8bit_c; |
311 |
|
|
312 |
#if defined(ARCH_IS_IA32) |
init_GMC(cpu_flags); |
313 |
|
|
314 |
|
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
315 |
|
|
316 |
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
317 |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
318 |
(cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2)) |
(cpu_flags & XVID_CPU_SSE) || (cpu_flags & XVID_CPU_SSE2) || |
319 |
|
(cpu_flags & XVID_CPU_SSE3) || (cpu_flags & XVID_CPU_SSE41)) |
320 |
{ |
{ |
321 |
/* Restore FPU context : emms_c is a nop functions */ |
/* Restore FPU context : emms_c is a nop functions */ |
322 |
emms = emms_mmx; |
emms = emms_mmx; |
337 |
quant_h263_inter = quant_h263_inter_mmx; |
quant_h263_inter = quant_h263_inter_mmx; |
338 |
dequant_h263_intra = dequant_h263_intra_mmx; |
dequant_h263_intra = dequant_h263_intra_mmx; |
339 |
dequant_h263_inter = dequant_h263_inter_mmx; |
dequant_h263_inter = dequant_h263_inter_mmx; |
|
|
|
340 |
quant_mpeg_intra = quant_mpeg_intra_mmx; |
quant_mpeg_intra = quant_mpeg_intra_mmx; |
341 |
quant_mpeg_inter = quant_mpeg_inter_mmx; |
quant_mpeg_inter = quant_mpeg_inter_mmx; |
342 |
dequant_mpeg_intra = dequant_mpeg_intra_mmx; |
dequant_mpeg_intra = dequant_mpeg_intra_mmx; |
343 |
dequant_mpeg_inter = dequant_mpeg_inter_mmx; |
dequant_mpeg_inter = dequant_mpeg_inter_mmx; |
344 |
|
|
345 |
|
|
346 |
/* Block related functions */ |
/* Block related functions */ |
347 |
transfer_8to16copy = transfer_8to16copy_mmx; |
transfer_8to16copy = transfer_8to16copy_mmx; |
348 |
transfer_16to8copy = transfer_16to8copy_mmx; |
transfer_16to8copy = transfer_16to8copy_mmx; |
380 |
image_brightness = image_brightness_mmx; |
image_brightness = image_brightness_mmx; |
381 |
|
|
382 |
/* image input xxx_to_yv12 related functions */ |
/* image input xxx_to_yv12 related functions */ |
383 |
|
|
384 |
yv12_to_yv12 = yv12_to_yv12_mmx; |
yv12_to_yv12 = yv12_to_yv12_mmx; |
385 |
|
|
386 |
bgr_to_yv12 = bgr_to_yv12_mmx; |
bgr_to_yv12 = bgr_to_yv12_mmx; |
387 |
|
rgb_to_yv12 = rgb_to_yv12_mmx; |
388 |
bgra_to_yv12 = bgra_to_yv12_mmx; |
bgra_to_yv12 = bgra_to_yv12_mmx; |
389 |
|
rgba_to_yv12 = rgba_to_yv12_mmx; |
390 |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
yuyv_to_yv12 = yuyv_to_yv12_mmx; |
391 |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
uyvy_to_yv12 = uyvy_to_yv12_mmx; |
392 |
|
|
422 |
|
|
423 |
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
yuyv_to_yv12 = yuyv_to_yv12_3dn; |
424 |
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
uyvy_to_yv12 = uyvy_to_yv12_3dn; |
425 |
|
|
426 |
} |
} |
427 |
|
|
428 |
|
|
447 |
interpolate8x8_halfpel_hv_add = interpolate8x8_halfpel_hv_add_xmm; |
interpolate8x8_halfpel_hv_add = interpolate8x8_halfpel_hv_add_xmm; |
448 |
|
|
449 |
/* Quantization */ |
/* Quantization */ |
|
quant_mpeg_intra = quant_mpeg_intra_xmm; |
|
450 |
quant_mpeg_inter = quant_mpeg_inter_xmm; |
quant_mpeg_inter = quant_mpeg_inter_xmm; |
451 |
|
|
452 |
dequant_h263_intra = dequant_h263_intra_xmm; |
dequant_h263_intra = dequant_h263_intra_xmm; |
457 |
transfer_8to16sub2ro = transfer_8to16sub2ro_xmm; |
transfer_8to16sub2ro = transfer_8to16sub2ro_xmm; |
458 |
|
|
459 |
/* Colorspace transformation */ |
/* Colorspace transformation */ |
460 |
yv12_to_yv12 = yv12_to_yv12_xmm; |
/* yv12_to_yv12 = yv12_to_yv12_xmm; */ /* appears to be slow on many machines */ |
461 |
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
yuyv_to_yv12 = yuyv_to_yv12_xmm; |
462 |
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
uyvy_to_yv12 = uyvy_to_yv12_xmm; |
463 |
|
|
518 |
dequant_h263_inter = dequant_h263_inter_3dne; |
dequant_h263_inter = dequant_h263_inter_3dne; |
519 |
|
|
520 |
/* ME functions */ |
/* ME functions */ |
|
calc_cbp = calc_cbp_3dne; |
|
|
|
|
521 |
sad16 = sad16_3dne; |
sad16 = sad16_3dne; |
522 |
sad8 = sad8_3dne; |
sad8 = sad8_3dne; |
523 |
sad16bi = sad16bi_3dne; |
sad16bi = sad16bi_3dne; |
542 |
|
|
543 |
/* DCT operators */ |
/* DCT operators */ |
544 |
fdct = fdct_sse2_skal; |
fdct = fdct_sse2_skal; |
545 |
/* idct = idct_sse2_skal; */ /* Is now IEEE1180 and Walken compliant. Disabled until fully tested. */ |
idct = idct_sse2_skal; /* Is now IEEE1180 and Walken compliant. */ |
546 |
|
|
547 |
/* postprocessing */ |
/* postprocessing */ |
548 |
image_brightness = image_brightness_sse2; |
image_brightness = image_brightness_sse2; |
549 |
|
|
550 |
|
} |
551 |
|
|
552 |
|
if ((cpu_flags & XVID_CPU_SSE3)) { |
553 |
|
|
554 |
|
/* SAD operators */ |
555 |
|
sad16 = sad16_sse3; |
556 |
|
dev16 = dev16_sse3; |
557 |
} |
} |
558 |
|
|
559 |
#endif /* ARCH_IS_IA32 */ |
#endif /* ARCH_IS_IA32 */ |
560 |
|
|
561 |
#if defined(ARCH_IS_IA64) |
#if defined(ARCH_IS_IA64) |
646 |
} |
} |
647 |
#endif |
#endif |
648 |
|
|
|
#if defined(ARCH_IS_X86_64) |
|
|
/* For now, only XVID_CPU_ASM is looked for, so user can still |
|
|
* disable asm usage the usual way. When Intel EMT64 cpus will |
|
|
* be out, maybe we'll have to check more precisely what cpu |
|
|
* features there really are. */ |
|
|
if (cpu_flags & XVID_CPU_ASM) { |
|
|
/* SIMD state flusher */ |
|
|
emms = emms_3dn; |
|
|
|
|
|
/* DCT operators */ |
|
|
fdct = fdct_skal_x86_64; |
|
|
idct = idct_x86_64; |
|
|
|
|
|
/* SAD operators */ |
|
|
sad16 = sad16_x86_64; |
|
|
sad8 = sad8_x86_64; |
|
|
sad16bi = sad16bi_x86_64; |
|
|
sad8bi = sad8bi_x86_64; |
|
|
dev16 = dev16_x86_64; |
|
|
sad16v = sad16v_x86_64; |
|
|
sse8_16bit = sse8_16bit_x86_64; |
|
|
sse8_8bit = sse8_8bit_x86_64; |
|
|
|
|
|
/* Interpolation operators */ |
|
|
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_x86_64; |
|
|
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_x86_64; |
|
|
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_x86_64; |
|
|
|
|
|
interpolate8x8_halfpel_add = interpolate8x8_halfpel_add_x86_64; |
|
|
interpolate8x8_halfpel_h_add = interpolate8x8_halfpel_h_add_x86_64; |
|
|
interpolate8x8_halfpel_v_add = interpolate8x8_halfpel_v_add_x86_64; |
|
|
interpolate8x8_halfpel_hv_add = interpolate8x8_halfpel_hv_add_x86_64; |
|
|
|
|
|
interpolate8x8_6tap_lowpass_h = interpolate8x8_6tap_lowpass_h_x86_64; |
|
|
interpolate8x8_6tap_lowpass_v = interpolate8x8_6tap_lowpass_v_x86_64; |
|
|
|
|
|
interpolate8x8_avg2 = interpolate8x8_avg2_x86_64; |
|
|
interpolate8x8_avg4 = interpolate8x8_avg4_x86_64; |
|
|
|
|
|
/* Quantization related functions */ |
|
|
quant_h263_intra = quant_h263_intra_x86_64; |
|
|
quant_h263_inter = quant_h263_inter_x86_64; |
|
|
dequant_h263_intra = dequant_h263_intra_x86_64; |
|
|
dequant_h263_inter = dequant_h263_inter_x86_64; |
|
|
quant_mpeg_intra = quant_mpeg_intra_x86_64; |
|
|
quant_mpeg_inter = quant_mpeg_inter_x86_64; |
|
|
dequant_mpeg_intra = dequant_mpeg_intra_x86_64; |
|
|
dequant_mpeg_inter = dequant_mpeg_inter_x86_64; |
|
|
|
|
|
/* Block related functions */ |
|
|
transfer_8to16copy = transfer_8to16copy_x86_64; |
|
|
transfer_16to8copy = transfer_16to8copy_x86_64; |
|
|
transfer_8to16sub = transfer_8to16sub_x86_64; |
|
|
transfer_8to16subro = transfer_8to16subro_x86_64; |
|
|
transfer_8to16sub2 = transfer_8to16sub2_x86_64; |
|
|
transfer_8to16sub2ro= transfer_8to16sub2ro_x86_64; |
|
|
transfer_16to8add = transfer_16to8add_x86_64; |
|
|
transfer8x8_copy = transfer8x8_copy_x86_64; |
|
|
|
|
|
/* Qpel stuff */ |
|
|
xvid_QP_Funcs = &xvid_QP_Funcs_x86_64; |
|
|
xvid_QP_Add_Funcs = &xvid_QP_Add_Funcs_x86_64; |
|
|
|
|
|
/* Interlacing Functions */ |
|
|
MBFieldTest = MBFieldTest_x86_64; |
|
|
} |
|
|
#endif |
|
|
|
|
649 |
#if defined(_DEBUG) |
#if defined(_DEBUG) |
650 |
xvid_debug = init->debug; |
xvid_debug = init->debug; |
651 |
#endif |
#endif |
661 |
return XVID_ERR_VERSION; |
return XVID_ERR_VERSION; |
662 |
|
|
663 |
info->actual_version = XVID_VERSION; |
info->actual_version = XVID_VERSION; |
664 |
info->build = "xvid-1.1.0-beta2"; |
info->build = "xvid-1.2.0-dev"; |
665 |
info->cpu_flags = detect_cpu_flags(); |
info->cpu_flags = detect_cpu_flags(); |
666 |
|
info->num_threads = 0; |
667 |
|
|
668 |
#if defined(_SMP) && defined(WIN32) |
#if defined(_WIN32) |
669 |
info->num_threads = pthread_num_processors_np();; |
{ |
670 |
|
DWORD dwProcessAffinityMask, dwSystemAffinityMask; |
671 |
|
if (GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR) &dwProcessAffinityMask, (PDWORD_PTR) &dwSystemAffinityMask)) { |
672 |
|
int i; |
673 |
|
for(i=0; i<32; i++) { |
674 |
|
if ((dwProcessAffinityMask & (1<<i))) |
675 |
|
info->num_threads++; |
676 |
|
} |
677 |
|
} |
678 |
|
} |
679 |
#else |
#else |
680 |
info->num_threads = 0; |
|
681 |
|
#include <unistd.h> |
682 |
|
info->num_threads = sysconf(_SC_NPROCESSORS_CONF); |
683 |
|
|
684 |
#endif |
#endif |
685 |
|
|
686 |
return 0; |
return 0; |