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" |
65 |
#include "utils/timer.h" |
#include "utils/timer.h" |
66 |
#include "bitstream/mbcoding.h" |
#include "bitstream/mbcoding.h" |
67 |
|
|
68 |
#if defined(ARCH_X86) && defined(EXPERIMENTAL_SSE2_CODE) |
#if defined(ARCH_X86) |
69 |
|
|
70 |
#ifdef WIN32 |
#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 WIN32 |
|
75 |
|
|
76 |
static jmp_buf mark; |
static jmp_buf mark; |
77 |
|
|
94 |
int |
int |
95 |
sigill_check(void (*func)()) |
sigill_check(void (*func)()) |
96 |
{ |
{ |
97 |
#ifdef WIN32 |
#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_X86) |
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_PPC) |
149 |
|
#if defined(ARCH_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 |
* |
* |
188 |
|
|
189 |
} else { |
} else { |
190 |
|
|
191 |
cpu_flags = check_cpu_features(); |
cpu_flags = detect_cpu_flags(); |
|
|
|
|
#if defined(ARCH_X86) && 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)) |
256 |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
257 |
|
|
258 |
/* reduced resoltuion */ |
/* reduced resoltuion */ |
|
|
|
259 |
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
260 |
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; |
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_C; |
|
#ifdef ARCH_X86 |
|
|
vfilter_31 = xvid_VFilter_31_x86; |
|
|
hfilter_31 = xvid_HFilter_31_x86; |
|
|
#else |
|
261 |
vfilter_31 = xvid_VFilter_31_C; |
vfilter_31 = xvid_VFilter_31_C; |
262 |
hfilter_31 = xvid_HFilter_31_C; |
hfilter_31 = xvid_HFilter_31_C; |
|
#endif |
|
263 |
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
264 |
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
265 |
|
|
317 |
|
|
318 |
// Halfpel8_Refine = Halfpel8_Refine_c; |
// Halfpel8_Refine = Halfpel8_Refine_c; |
319 |
|
|
320 |
#ifdef ARCH_X86 |
#if defined(ARCH_X86) |
321 |
|
|
322 |
|
if ((cpu_flags & XVID_CPU_ASM)) |
323 |
|
{ |
324 |
|
vfilter_31 = xvid_VFilter_31_x86; |
325 |
|
hfilter_31 = xvid_HFilter_31_x86; |
326 |
|
} |
327 |
|
|
328 |
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
329 |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
333 |
emms = emms_mmx; |
emms = emms_mmx; |
334 |
} |
} |
335 |
|
|
336 |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
if ((cpu_flags & XVID_CPU_MMX)) { |
337 |
|
|
338 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
339 |
fdct = fdct_mmx; |
fdct = fdct_mmx; |
403 |
sad8bi = sad8bi_mmx; |
sad8bi = sad8bi_mmx; |
404 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
405 |
sad16v = sad16v_mmx; |
sad16v = sad16v_mmx; |
|
|
|
406 |
} |
} |
407 |
|
|
408 |
/* these 3dnow functions are faster than mmx, but slower than xmm. */ |
/* these 3dnow functions are faster than mmx, but slower than xmm. */ |
409 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW)) { |
410 |
|
|
411 |
|
emms = emms_3dn; |
412 |
|
|
413 |
/* ME functions */ |
/* ME functions */ |
414 |
sad16bi = sad16bi_3dn; |
sad16bi = sad16bi_3dn; |
419 |
} |
} |
420 |
|
|
421 |
|
|
422 |
if ((cpu_flags & XVID_CPU_MMXEXT) > 0) { |
if ((cpu_flags & XVID_CPU_MMXEXT)) { |
423 |
|
|
424 |
/* Inverse DCT */ |
/* Inverse DCT */ |
425 |
idct = idct_xmm; |
idct = idct_xmm; |
434 |
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; |
add_upsampled_8x8_16to8 = xvid_Add_Upsampled_8x8_16To8_xmm; |
435 |
|
|
436 |
/* Quantization */ |
/* Quantization */ |
437 |
|
quant4_intra = quant4_intra_xmm; |
438 |
|
quant4_inter = quant4_inter_xmm; |
439 |
|
|
440 |
dequant_intra = dequant_intra_xmm; |
dequant_intra = dequant_intra_xmm; |
441 |
dequant_inter = dequant_inter_xmm; |
dequant_inter = dequant_inter_xmm; |
442 |
|
|
457 |
sad16v = sad16v_xmm; |
sad16v = sad16v_xmm; |
458 |
} |
} |
459 |
|
|
460 |
if ((cpu_flags & XVID_CPU_3DNOW) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOW)) { |
461 |
|
|
462 |
/* Interpolation */ |
/* Interpolation */ |
463 |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dn; |
465 |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dn; |
466 |
} |
} |
467 |
|
|
468 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOWEXT)) { |
469 |
#ifdef EXPERIMENTAL_SSE2_CODE |
|
470 |
|
/* Inverse DCT */ |
471 |
|
idct = idct_3dne; |
472 |
|
|
473 |
|
/* Buffer transfer */ |
474 |
|
transfer_8to16copy = transfer_8to16copy_3dne; |
475 |
|
transfer_16to8copy = transfer_16to8copy_3dne; |
476 |
|
transfer_8to16sub = transfer_8to16sub_3dne; |
477 |
|
transfer_8to16sub2 = transfer_8to16sub2_3dne; |
478 |
|
transfer_16to8add = transfer_16to8add_3dne; |
479 |
|
transfer8x8_copy = transfer8x8_copy_3dne; |
480 |
|
|
481 |
|
/* Quantization */ |
482 |
|
dequant4_intra = dequant4_intra_3dne; |
483 |
|
dequant4_inter = dequant4_inter_3dne; |
484 |
|
quant_intra = quant_intra_3dne; |
485 |
|
quant_inter = quant_inter_3dne; |
486 |
|
dequant_intra = dequant_intra_3dne; |
487 |
|
dequant_inter = dequant_inter_3dne; |
488 |
|
|
489 |
|
/* ME functions */ |
490 |
|
calc_cbp = calc_cbp_3dne; |
491 |
|
sad16 = sad16_3dne; |
492 |
|
sad8 = sad8_3dne; |
493 |
|
sad16bi = sad16bi_3dne; |
494 |
|
sad8bi = sad8bi_3dne; |
495 |
|
dev16 = dev16_3dne; |
496 |
|
|
497 |
|
/* Interpolation */ |
498 |
|
interpolate8x8_halfpel_h = interpolate8x8_halfpel_h_3dne; |
499 |
|
interpolate8x8_halfpel_v = interpolate8x8_halfpel_v_3dne; |
500 |
|
interpolate8x8_halfpel_hv = interpolate8x8_halfpel_hv_3dne; |
501 |
|
} |
502 |
|
|
503 |
|
|
504 |
|
if ((cpu_flags & XVID_CPU_SSE2)) { |
505 |
|
|
506 |
calc_cbp = calc_cbp_sse2; |
calc_cbp = calc_cbp_sse2; |
507 |
|
|
511 |
quant_inter = quant_inter_sse2; |
quant_inter = quant_inter_sse2; |
512 |
dequant_inter = dequant_inter_sse2; |
dequant_inter = dequant_inter_sse2; |
513 |
|
|
514 |
/* ME */ |
#if defined(EXPERIMENTAL_SSE2_CODE) |
515 |
|
/* ME; slower than xmm */ |
516 |
sad16 = sad16_sse2; |
sad16 = sad16_sse2; |
517 |
dev16 = dev16_sse2; |
dev16 = dev16_sse2; |
518 |
|
#endif |
519 |
/* Forward and Inverse DCT */ |
/* Forward and Inverse DCT */ |
520 |
idct = idct_sse2; |
idct = idct_sse2; |
521 |
fdct = fdct_sse2; |
fdct = fdct_sse2; |
|
#endif |
|
522 |
} |
} |
|
|
|
523 |
#endif |
#endif |
524 |
|
|
525 |
#ifdef ARCH_IA64 |
#if defined(ARCH_IA64) |
526 |
if ((cpu_flags & XVID_CPU_IA64) > 0) { //use assembler routines? |
if ((cpu_flags & XVID_CPU_ASM)) { //use assembler routines? |
527 |
idct_ia64_init(); |
idct_ia64_init(); |
528 |
fdct = fdct_ia64; |
fdct = fdct_ia64; |
529 |
idct = idct_ia64; //not yet working, crashes |
idct = idct_ia64; //not yet working, crashes |
549 |
} |
} |
550 |
#endif |
#endif |
551 |
|
|
552 |
#ifdef ARCH_PPC |
#if defined(ARCH_PPC) |
553 |
#ifdef ARCH_PPC_ALTIVEC |
if ((cpu_flags & XVID_CPU_ASM)) |
554 |
|
{ |
555 |
|
calc_cbp = calc_cbp_ppc; |
556 |
|
} |
557 |
|
|
558 |
|
if ((cpu_flags & XVID_CPU_ALTIVEC)) |
559 |
|
{ |
560 |
calc_cbp = calc_cbp_altivec; |
calc_cbp = calc_cbp_altivec; |
561 |
fdct = fdct_altivec; |
fdct = fdct_altivec; |
562 |
idct = idct_altivec; |
idct = idct_altivec; |
564 |
sad16 = sad16_altivec; |
sad16 = sad16_altivec; |
565 |
sad8 = sad8_altivec; |
sad8 = sad8_altivec; |
566 |
dev16 = dev16_altivec; |
dev16 = dev16_altivec; |
567 |
#else |
} |
|
calc_cbp = calc_cbp_ppc; |
|
|
#endif |
|
568 |
#endif |
#endif |
569 |
|
|
570 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
603 |
} |
} |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
void fill8(uint8_t * block, int size, int value) |
608 |
|
{ |
609 |
|
int i; |
610 |
|
for (i = 0; i < size; i++) |
611 |
|
block[i] = value; |
612 |
|
} |
613 |
|
|
614 |
|
void fill16(int16_t * block, int size, int value) |
615 |
|
{ |
616 |
|
int i; |
617 |
|
for (i = 0; i < size; i++) |
618 |
|
block[i] = value; |
619 |
|
} |
620 |
|
|
621 |
|
#define RANDOM(min,max) min + (rand() % (max-min)) |
622 |
|
|
623 |
|
void random8(uint8_t * block, int size, int min, int max) |
624 |
|
{ |
625 |
|
int i; |
626 |
|
for (i = 0; i < size; i++) |
627 |
|
block[i] = RANDOM(min,max); |
628 |
|
} |
629 |
|
|
630 |
|
void random16(int16_t * block, int size, int min, int max) |
631 |
|
{ |
632 |
|
int i; |
633 |
|
for (i = 0; i < size; i++) |
634 |
|
block[i] = RANDOM(min,max); |
635 |
|
} |
636 |
|
|
637 |
|
int compare16(const int16_t * blockA, const int16_t * blockB, int size) |
638 |
|
{ |
639 |
|
int i; |
640 |
|
for (i = 0; i < size; i++) |
641 |
|
if (blockA[i] != blockB[i]) |
642 |
|
return 1; |
643 |
|
|
644 |
|
return 0; |
645 |
|
} |
646 |
|
|
647 |
|
int diff16(const int16_t * blockA, const int16_t * blockB, int size) |
648 |
|
{ |
649 |
|
int i, diff = 0; |
650 |
|
for (i = 0; i < size; i++) |
651 |
|
diff += ABS(blockA[i]-blockB[i]); |
652 |
|
return diff; |
653 |
|
} |
654 |
|
|
655 |
|
|
656 |
|
#define XVID_TEST_RANDOM 0x00000001 /* random input data */ |
657 |
|
#define XVID_TEST_VERBOSE 0x00000002 /* verbose error output */ |
658 |
|
|
659 |
|
|
660 |
|
#define TEST_FORWARD 0x00000001 /* intra */ |
661 |
|
#define TEST_FDCT (TEST_FORWARD) |
662 |
|
#define TEST_IDCT (0) |
663 |
|
|
664 |
|
int test_transform(void * funcA, void * funcB, const char * nameB, |
665 |
|
int test, int flags) |
666 |
|
{ |
667 |
|
int i; |
668 |
|
int64_t timeSTART; |
669 |
|
int64_t timeA = 0; |
670 |
|
int64_t timeB = 0; |
671 |
|
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
672 |
|
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
673 |
|
int min, max; |
674 |
|
int count = 0; |
675 |
|
|
676 |
|
int tmp; |
677 |
|
int min_error = 0x10000*64; |
678 |
|
int max_error = 0; |
679 |
|
|
680 |
|
|
681 |
|
if ((test & TEST_FORWARD)) /* forward */ |
682 |
|
{ |
683 |
|
min = -256; |
684 |
|
max = 255; |
685 |
|
}else{ /* inverse */ |
686 |
|
min = -2048; |
687 |
|
max = 2047; |
688 |
|
} |
689 |
|
|
690 |
|
for (i = 0; i < 64*64; i++) |
691 |
|
{ |
692 |
|
if ((flags & XVID_TEST_RANDOM)) |
693 |
|
{ |
694 |
|
random16(arrayA, 64, min, max); |
695 |
|
}else{ |
696 |
|
fill16(arrayA, 64, i); |
697 |
|
} |
698 |
|
memcpy(arrayB, arrayA, 64*sizeof(int16_t)); |
699 |
|
|
700 |
|
if ((test & TEST_FORWARD)) |
701 |
|
{ |
702 |
|
timeSTART = read_counter(); |
703 |
|
((fdctFunc*)funcA)(arrayA); |
704 |
|
timeA += read_counter() - timeSTART; |
705 |
|
|
706 |
|
timeSTART = read_counter(); |
707 |
|
((fdctFunc*)funcB)(arrayB); |
708 |
|
timeB += read_counter() - timeSTART; |
709 |
|
} |
710 |
|
else |
711 |
|
{ |
712 |
|
timeSTART = read_counter(); |
713 |
|
((idctFunc*)funcA)(arrayA); |
714 |
|
timeA += read_counter() - timeSTART; |
715 |
|
|
716 |
|
timeSTART = read_counter(); |
717 |
|
((idctFunc*)funcB)(arrayB); |
718 |
|
timeB += read_counter() - timeSTART; |
719 |
|
} |
720 |
|
|
721 |
|
tmp = diff16(arrayA, arrayB, 64) / 64; |
722 |
|
if (tmp > max_error) |
723 |
|
max_error = tmp; |
724 |
|
if (tmp < min_error) |
725 |
|
min_error = tmp; |
726 |
|
|
727 |
|
count++; |
728 |
|
} |
729 |
|
|
730 |
|
/* print the "average difference" of best/worst transforms */ |
731 |
|
printf("%s:\t%i\t(min_error:%i, max_error:%i)\n", nameB, (int)(timeB / count), min_error, max_error); |
732 |
|
|
733 |
|
return 0; |
734 |
|
} |
735 |
|
|
736 |
|
|
737 |
|
#define TEST_QUANT 0x00000001 /* forward quantization */ |
738 |
|
#define TEST_INTRA 0x00000002 /* intra */ |
739 |
|
#define TEST_QUANT_INTRA (TEST_QUANT|TEST_INTRA) |
740 |
|
#define TEST_QUANT_INTER (TEST_QUANT) |
741 |
|
#define TEST_DEQUANT_INTRA (TEST_INTRA) |
742 |
|
#define TEST_DEQUANT_INTER (0) |
743 |
|
|
744 |
|
int test_quant(void * funcA, void * funcB, const char * nameB, |
745 |
|
int test, int flags) |
746 |
|
{ |
747 |
|
int q,i; |
748 |
|
int64_t timeSTART; |
749 |
|
int64_t timeA = 0; |
750 |
|
int64_t timeB = 0; |
751 |
|
int retA, retB; |
752 |
|
DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); |
753 |
|
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
754 |
|
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
755 |
|
int min, max; |
756 |
|
int count = 0; |
757 |
|
int errors = 0; |
758 |
|
|
759 |
|
if ((test & TEST_QUANT)) /* quant */ |
760 |
|
{ |
761 |
|
min = -2048; |
762 |
|
max = 2047; |
763 |
|
}else{ /* dequant */ |
764 |
|
min = -256; |
765 |
|
max = 255; |
766 |
|
} |
767 |
|
|
768 |
|
for (q = 1; q <= 31; q++) /* quantizer */ |
769 |
|
{ |
770 |
|
for (i = min; i < max; i++) /* input coeff */ |
771 |
|
{ |
772 |
|
if ((flags & XVID_TEST_RANDOM)) |
773 |
|
{ |
774 |
|
random16(arrayX, 64, min, max); |
775 |
|
}else{ |
776 |
|
fill16(arrayX, 64, i); |
777 |
|
} |
778 |
|
|
779 |
|
if ((test & TEST_INTRA)) /* intra */ |
780 |
|
{ |
781 |
|
timeSTART = read_counter(); |
782 |
|
((quanth263_intraFunc*)funcA)(arrayA, arrayX, q, q); |
783 |
|
timeA += read_counter() - timeSTART; |
784 |
|
|
785 |
|
timeSTART = read_counter(); |
786 |
|
((quanth263_intraFunc*)funcB)(arrayB, arrayX, q, q); |
787 |
|
timeB += read_counter() - timeSTART; |
788 |
|
} |
789 |
|
else /* inter */ |
790 |
|
{ |
791 |
|
timeSTART = read_counter(); |
792 |
|
retA = ((quanth263_interFunc*)funcA)(arrayA, arrayX, q); |
793 |
|
timeA += read_counter() - timeSTART; |
794 |
|
|
795 |
|
timeSTART = read_counter(); |
796 |
|
retB = ((quanth263_interFunc*)funcB)(arrayB, arrayX, q); |
797 |
|
timeB += read_counter() - timeSTART; |
798 |
|
} |
799 |
|
|
800 |
|
/* compare return value from quant_inter, and compare (de)quantiz'd arrays */ |
801 |
|
if ( ((test&TEST_QUANT) && !(test&TEST_INTRA) && retA != retB ) || |
802 |
|
compare16(arrayA, arrayB, 64)) |
803 |
|
{ |
804 |
|
errors++; |
805 |
|
if ((flags & XVID_TEST_VERBOSE)) |
806 |
|
printf("%s error: q=%i, i=%i\n", nameB, q, i); |
807 |
|
} |
808 |
|
|
809 |
|
count++; |
810 |
|
} |
811 |
|
} |
812 |
|
|
813 |
|
printf("%s:\t%i", nameB, (int)(timeB / count)); |
814 |
|
if (errors>0) |
815 |
|
printf("\t(%i errors out of %i)", errors, count); |
816 |
|
printf("\n"); |
817 |
|
|
818 |
|
return 0; |
819 |
|
} |
820 |
|
|
821 |
|
|
822 |
|
|
823 |
|
int xvid_init_test(int flags) |
824 |
|
{ |
825 |
|
int cpu_flags; |
826 |
|
|
827 |
|
srand(time(0)); |
828 |
|
|
829 |
|
printf("xvid_init_test\n"); |
830 |
|
|
831 |
|
#if defined(ARCH_X86) |
832 |
|
cpu_flags = detect_cpu_flags(); |
833 |
|
idct_int32_init(); |
834 |
|
emms_mmx(); |
835 |
|
|
836 |
|
printf("--- fdct ---\n"); |
837 |
|
test_transform(fdct_int32, fdct_int32, "c", TEST_FDCT, flags); |
838 |
|
if (cpu_flags & XVID_CPU_MMX) |
839 |
|
test_transform(fdct_int32, fdct_mmx, "mmx", TEST_FDCT, flags); |
840 |
|
if (cpu_flags & XVID_CPU_SSE2) |
841 |
|
test_transform(fdct_int32, fdct_sse2, "sse2", TEST_FDCT, flags); |
842 |
|
|
843 |
|
printf("\n--- idct ---\n"); |
844 |
|
test_transform(idct_int32, idct_int32, "c", TEST_IDCT, flags); |
845 |
|
if (cpu_flags & XVID_CPU_MMX) |
846 |
|
test_transform(idct_int32, idct_mmx, "mmx", TEST_IDCT, flags); |
847 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
848 |
|
test_transform(idct_int32, idct_xmm, "xmm", TEST_IDCT, flags); |
849 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
850 |
|
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
851 |
|
if (cpu_flags & XVID_CPU_SSE2) |
852 |
|
test_transform(idct_int32, idct_sse2, "sse2", TEST_IDCT, flags); |
853 |
|
|
854 |
|
printf("\n--- quant intra ---\n"); |
855 |
|
test_quant(quant_intra_c, quant_intra_c, "c", TEST_QUANT_INTRA, flags); |
856 |
|
if (cpu_flags & XVID_CPU_MMX) |
857 |
|
test_quant(quant_intra_c, quant_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
858 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
859 |
|
test_quant(quant_intra_c, quant_intra_3dne, "3dne", TEST_QUANT_INTRA, flags); |
860 |
|
if (cpu_flags & XVID_CPU_SSE2) |
861 |
|
test_quant(quant_intra_c, quant_intra_sse2, "sse2", TEST_QUANT_INTRA, flags); |
862 |
|
|
863 |
|
printf("\n--- quant inter ---\n"); |
864 |
|
test_quant(quant_inter_c, quant_inter_c, "c", TEST_QUANT_INTER, flags); |
865 |
|
if (cpu_flags & XVID_CPU_MMX) |
866 |
|
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
867 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
868 |
|
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
869 |
|
if (cpu_flags & XVID_CPU_SSE2) |
870 |
|
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
871 |
|
|
872 |
|
printf("\n--- dequant intra ---\n"); |
873 |
|
test_quant(dequant_intra_c, dequant_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
874 |
|
if (cpu_flags & XVID_CPU_MMX) |
875 |
|
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
876 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
877 |
|
test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags); |
878 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
879 |
|
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
880 |
|
if (cpu_flags & XVID_CPU_SSE2) |
881 |
|
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
882 |
|
|
883 |
|
printf("\n--- dequant inter ---\n"); |
884 |
|
test_quant(dequant_inter_c, dequant_inter_c, "c", TEST_DEQUANT_INTER, flags); |
885 |
|
if (cpu_flags & XVID_CPU_MMX) |
886 |
|
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
887 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
888 |
|
test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags); |
889 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
890 |
|
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
891 |
|
if (cpu_flags & XVID_CPU_SSE2) |
892 |
|
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
893 |
|
|
894 |
|
printf("\n--- quant4_intra ---\n"); |
895 |
|
test_quant(quant4_intra_c, quant4_intra_c, "c", TEST_QUANT_INTRA, flags); |
896 |
|
if (cpu_flags & XVID_CPU_MMX) |
897 |
|
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
898 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
899 |
|
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
900 |
|
|
901 |
|
printf("\n--- quant4_inter ---\n"); |
902 |
|
test_quant(quant4_inter_c, quant4_inter_c, "c", TEST_QUANT_INTER, flags); |
903 |
|
if (cpu_flags & XVID_CPU_MMX) |
904 |
|
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
905 |
|
if (cpu_flags & XVID_CPU_MMXEXT) |
906 |
|
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
907 |
|
|
908 |
|
printf("\n--- dequant4_intra ---\n"); |
909 |
|
test_quant(dequant4_intra_c, dequant4_intra_c, "c", TEST_DEQUANT_INTRA, flags); |
910 |
|
if (cpu_flags & XVID_CPU_MMX) |
911 |
|
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
912 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
913 |
|
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
914 |
|
|
915 |
|
printf("\n--- dequant4_inter ---\n"); |
916 |
|
test_quant(dequant4_inter_c, dequant4_inter_c, "c", TEST_DEQUANT_INTER, flags); |
917 |
|
if (cpu_flags & XVID_CPU_MMX) |
918 |
|
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
919 |
|
if (cpu_flags & XVID_CPU_3DNOWEXT) |
920 |
|
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
921 |
|
|
922 |
|
emms_mmx(); |
923 |
|
|
924 |
|
#endif |
925 |
|
|
926 |
|
return XVID_ERR_OK; |
927 |
|
} |
928 |
|
|
929 |
|
|
930 |
int |
int |
931 |
xvid_init(void *handle, |
xvid_init(void *handle, |
932 |
int opt, |
int opt, |
941 |
case XVID_INIT_CONVERT : |
case XVID_INIT_CONVERT : |
942 |
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
943 |
|
|
944 |
|
case XVID_INIT_TEST : |
945 |
|
return xvid_init_test((int)param1); |
946 |
|
|
947 |
default : |
default : |
948 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
949 |
} |
} |