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)) |
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; |
257 |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
interpolate8x8_avg4 = interpolate8x8_avg4_c; |
258 |
|
|
259 |
/* reduced resoltuion */ |
/* reduced resoltuion */ |
|
|
|
260 |
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
copy_upsampled_8x8_16to8 = xvid_Copy_Upsampled_8x8_16To8_C; |
261 |
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 |
|
262 |
vfilter_31 = xvid_VFilter_31_C; |
vfilter_31 = xvid_VFilter_31_C; |
263 |
hfilter_31 = xvid_HFilter_31_C; |
hfilter_31 = xvid_HFilter_31_C; |
|
#endif |
|
264 |
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
filter_18x18_to_8x8 = xvid_Filter_18x18_To_8x8_C; |
265 |
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
filter_diff_18x18_to_8x8 = xvid_Filter_Diff_18x18_To_8x8_C; |
266 |
|
|
318 |
|
|
319 |
// Halfpel8_Refine = Halfpel8_Refine_c; |
// Halfpel8_Refine = Halfpel8_Refine_c; |
320 |
|
|
321 |
#ifdef ARCH_X86 |
#if defined(ARCH_X86) |
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) || |
if ((cpu_flags & XVID_CPU_MMX) || (cpu_flags & XVID_CPU_MMXEXT) || |
330 |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
(cpu_flags & XVID_CPU_3DNOW) || (cpu_flags & XVID_CPU_3DNOWEXT) || |
334 |
emms = emms_mmx; |
emms = emms_mmx; |
335 |
} |
} |
336 |
|
|
337 |
if ((cpu_flags & XVID_CPU_MMX) > 0) { |
if ((cpu_flags & XVID_CPU_MMX)) { |
338 |
|
|
339 |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
/* Forward and Inverse Discrete Cosine Transformation functions */ |
340 |
fdct = fdct_mmx; |
fdct = fdct_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; |
405 |
sad8bi = sad8bi_mmx; |
sad8bi = sad8bi_mmx; |
406 |
dev16 = dev16_mmx; |
dev16 = dev16_mmx; |
407 |
sad16v = sad16v_mmx; |
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; |
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; |
459 |
sad16v = sad16v_xmm; |
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_3DNOWEXT) > 0) { |
if ((cpu_flags & XVID_CPU_3DNOWEXT)) { |
471 |
|
|
472 |
/* Inverse DCT */ |
/* Inverse DCT */ |
473 |
idct = idct_3dne; |
idct = idct_3dne; |
476 |
transfer_8to16copy = transfer_8to16copy_3dne; |
transfer_8to16copy = transfer_8to16copy_3dne; |
477 |
transfer_16to8copy = transfer_16to8copy_3dne; |
transfer_16to8copy = transfer_16to8copy_3dne; |
478 |
transfer_8to16sub = transfer_8to16sub_3dne; |
transfer_8to16sub = transfer_8to16sub_3dne; |
479 |
|
transfer_8to16subro = transfer_8to16subro_3dne; |
480 |
transfer_8to16sub2 = transfer_8to16sub2_3dne; |
transfer_8to16sub2 = transfer_8to16sub2_3dne; |
481 |
transfer_16to8add = transfer_16to8add_3dne; |
transfer_16to8add = transfer_16to8add_3dne; |
482 |
transfer8x8_copy = transfer8x8_copy_3dne; |
transfer8x8_copy = transfer8x8_copy_3dne; |
504 |
} |
} |
505 |
|
|
506 |
|
|
507 |
if ((cpu_flags & XVID_CPU_SSE2) > 0) { |
if ((cpu_flags & XVID_CPU_SSE2)) { |
|
#ifdef EXPERIMENTAL_SSE2_CODE |
|
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_IA64 |
#if defined(ARCH_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; //not yet working, crashes |
idct = idct_ia64; //not yet working, crashes |
552 |
} |
} |
553 |
#endif |
#endif |
554 |
|
|
555 |
#ifdef ARCH_PPC |
#if defined(ARCH_PPC) |
556 |
#ifdef ARCH_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; |
|
|
#endif |
|
571 |
#endif |
#endif |
572 |
|
|
573 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
647 |
return 0; |
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 |
int test_h263_intra(quanth263_intraFunc * funcA, quanth263_intraFunc * funcB, |
|
663 |
const char * nameA, const char * nameB, |
#define TEST_FORWARD 0x00000001 /* intra */ |
664 |
int min, int max) |
#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 q,i; |
int i; |
671 |
int64_t timeSTART; |
int64_t timeSTART; |
672 |
int64_t timeA = 0; |
int64_t timeA = 0; |
673 |
int64_t timeB = 0; |
int64_t timeB = 0; |
|
DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); |
|
674 |
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
675 |
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
676 |
|
int min, max; |
677 |
|
int count = 0; |
678 |
|
|
679 |
for (q = 1; q <= 31; q++) /* quantizer */ |
int tmp; |
680 |
|
int min_error = 0x10000*64; |
681 |
|
int max_error = 0; |
682 |
|
|
683 |
|
|
684 |
|
if ((test & TEST_FORWARD)) /* forward */ |
685 |
{ |
{ |
686 |
for (i = min; i < max; i++) /* input coeff */ |
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 |
fill16(arrayX, 64, i); |
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(); |
timeSTART = read_counter(); |
706 |
funcA(arrayA, arrayX, q, q); |
((fdctFunc*)funcA)(arrayA); |
707 |
timeA += read_counter() - timeSTART; |
timeA += read_counter() - timeSTART; |
708 |
|
|
709 |
timeSTART = read_counter(); |
timeSTART = read_counter(); |
710 |
funcB(arrayB, arrayX, q, q); |
((fdctFunc*)funcB)(arrayB); |
711 |
timeB += read_counter() - timeSTART; |
timeB += read_counter() - timeSTART; |
|
|
|
|
if (compare16(arrayA, arrayB, 64)) |
|
|
{ |
|
|
printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i); |
|
|
return 0; |
|
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 |
if (nameA) printf("%s:\t%I64i\n", nameA, timeA); |
/* print the "average difference" of best/worst transforms */ |
734 |
if (nameB) printf("%s:\t%I64i\n", nameB, timeB); |
printf("%s:\t%i\t(min_error:%i, max_error:%i)\n", nameB, (int)(timeB / count), min_error, max_error); |
735 |
|
|
736 |
return 0; |
return 0; |
737 |
} |
} |
738 |
|
|
739 |
int test_h263_inter(quanth263_interFunc * funcA, quanth263_interFunc * funcB, |
|
740 |
const char * nameA, const char * nameB, |
#define TEST_QUANT 0x00000001 /* forward quantization */ |
741 |
int min, int max) |
#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; |
int q,i; |
751 |
int64_t timeSTART; |
int64_t timeSTART; |
752 |
int64_t timeA = 0; |
int64_t timeA = 0; |
753 |
int64_t timeB = 0; |
int64_t timeB = 0; |
754 |
|
int retA, retB; |
755 |
DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(arrayX, 1, 64, int16_t, CACHE_LINE); |
756 |
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
DECLARE_ALIGNED_MATRIX(arrayA, 1, 64, int16_t, CACHE_LINE); |
757 |
DECLARE_ALIGNED_MATRIX(arrayB, 1, 64, int16_t, CACHE_LINE); |
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 */ |
for (q = 1; q <= 31; q++) /* quantizer */ |
772 |
{ |
{ |
773 |
for (i = min; i < max; i++) /* input coeff */ |
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); |
fill16(arrayX, 64, i); |
780 |
|
} |
781 |
|
|
782 |
|
if ((test & TEST_INTRA)) /* intra */ |
783 |
|
{ |
784 |
timeSTART = read_counter(); |
timeSTART = read_counter(); |
785 |
funcA(arrayA, arrayX, q); |
((quanth263_intraFunc*)funcA)(arrayA, arrayX, q, q); |
786 |
timeA += read_counter() - timeSTART; |
timeA += read_counter() - timeSTART; |
787 |
|
|
788 |
timeSTART = read_counter(); |
timeSTART = read_counter(); |
789 |
funcB(arrayB, arrayX, q); |
((quanth263_intraFunc*)funcB)(arrayB, arrayX, q, q); |
790 |
timeB += read_counter() - timeSTART; |
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 |
if (compare16(arrayA, arrayB, 64)) |
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 |
printf("%s/%s error: q=%i, i=%i\n", nameA?nameA:"?", nameB?nameB:"?", q, i); |
errors++; |
808 |
return 0; |
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 |
if (nameA) printf("%s:\t%I64i\n", nameA, timeA); |
printf("%s:\t%i", nameB, (int)(timeB / count)); |
817 |
if (nameB) printf("%s:\t%I64i\n", nameB, timeB); |
if (errors>0) |
818 |
|
printf("\t(%i errors out of %i)", errors, count); |
819 |
|
printf("\n"); |
820 |
|
|
821 |
return 0; |
return 0; |
822 |
} |
} |
823 |
|
|
824 |
|
|
825 |
|
|
826 |
int xvid_init_test() |
int xvid_init_test(int flags) |
827 |
{ |
{ |
828 |
int cpu_flags; |
int cpu_flags; |
829 |
|
|
830 |
|
srand(time(0)); |
831 |
|
|
832 |
printf("xvid_init_test\n"); |
printf("xvid_init_test\n"); |
833 |
|
|
834 |
#if defined(ARCH_X86) |
#if defined(ARCH_X86) |
835 |
cpu_flags = check_cpu_features(); |
cpu_flags = detect_cpu_flags(); |
836 |
|
idct_int32_init(); |
837 |
emms_mmx(); |
emms_mmx(); |
838 |
|
|
839 |
printf("--- quant intra ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
849 |
test_h263_intra(quant_intra_c, quant_intra_mmx, "c", "mmx", -2048, 2047); |
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) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
853 |
test_h263_intra(quant_intra_c, quant_intra_3dne, NULL, "3dne", -2048, 2047); |
test_transform(idct_int32, idct_3dne, "3dne", TEST_IDCT, flags); |
854 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
855 |
test_h263_intra(quant_intra_c, quant_intra_sse2, NULL, "sse2", -2048, 2047); |
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"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
869 |
test_h263_inter(quant_inter_c, quant_inter_mmx, "c", "mmx", -2048, 2047); |
test_quant(quant_inter_c, quant_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
870 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
871 |
test_h263_inter(quant_inter_c, quant_inter_3dne, NULL, "3dne", -2048, 2047); |
test_quant(quant_inter_c, quant_inter_3dne, "3dne", TEST_QUANT_INTER, flags); |
872 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
873 |
test_h263_inter(quant_inter_c, quant_inter_sse2, NULL, "sse2", -2048, 2047); |
test_quant(quant_inter_c, quant_inter_sse2, "sse2", TEST_QUANT_INTER, flags); |
874 |
|
|
875 |
printf("\n--- dequan intra ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
878 |
test_h263_intra(dequant_intra_c, dequant_intra_mmx, "c", "mmx", -256, 255); |
test_quant(dequant_intra_c, dequant_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
879 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
880 |
test_h263_intra(dequant_intra_c, dequant_intra_xmm, NULL, "xmm", -256, 255); |
test_quant(dequant_intra_c, dequant_intra_xmm, "xmm", TEST_DEQUANT_INTRA, flags); |
881 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
882 |
test_h263_intra(dequant_intra_c, dequant_intra_3dne, NULL, "3dne", -256, 255); |
test_quant(dequant_intra_c, dequant_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
883 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
884 |
test_h263_intra(dequant_intra_c, dequant_intra_sse2, NULL, "sse2", -256, 255); |
test_quant(dequant_intra_c, dequant_intra_sse2, "sse2", TEST_DEQUANT_INTRA, flags); |
885 |
|
|
886 |
printf("\n--- dequant inter ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
889 |
test_h263_inter((quanth263_interFunc*)dequant_inter_c, |
test_quant(dequant_inter_c, dequant_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant_inter_mmx, "c", "mmx", -256, 255); |
|
|
|
|
890 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
891 |
test_h263_inter((quanth263_interFunc*)dequant_inter_c, |
test_quant(dequant_inter_c, dequant_inter_xmm, "xmm", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant_inter_xmm, NULL, "xmm", -256, 255); |
|
892 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
893 |
test_h263_inter((quanth263_interFunc*)dequant_inter_c, |
test_quant(dequant_inter_c, dequant_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant_inter_3dne, NULL, "3dne", -256, 255); |
|
894 |
if (cpu_flags & XVID_CPU_SSE2) |
if (cpu_flags & XVID_CPU_SSE2) |
895 |
test_h263_inter((quanth263_interFunc*)dequant_inter_c, |
test_quant(dequant_inter_c, dequant_inter_sse2, "sse2", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant_inter_sse2, NULL, "sse2", -256, 255); |
|
896 |
|
|
897 |
printf("\n--- quant4_intra ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
900 |
test_h263_intra((quanth263_intraFunc*)quant4_intra_c, |
test_quant(quant4_intra_c, quant4_intra_mmx, "mmx", TEST_QUANT_INTRA, flags); |
|
(quanth263_intraFunc*)quant4_intra_mmx, "c", "mmx", -2048, 2047); |
|
901 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
902 |
test_h263_intra((quanth263_intraFunc*)quant4_intra_c, |
test_quant(quant4_intra_c, quant4_intra_xmm, "xmm", TEST_QUANT_INTRA, flags); |
|
(quanth263_intraFunc*)quant4_intra_xmm, NULL, "xmm", -2048, 2047); |
|
903 |
|
|
904 |
printf("\n--- quant4_inter ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
907 |
test_h263_inter((quanth263_interFunc*)quant4_inter_c, |
test_quant(quant4_inter_c, quant4_inter_mmx, "mmx", TEST_QUANT_INTER, flags); |
|
(quanth263_interFunc*)quant4_inter_mmx, "c", "mmx", -2048, 2047); |
|
908 |
if (cpu_flags & XVID_CPU_MMXEXT) |
if (cpu_flags & XVID_CPU_MMXEXT) |
909 |
test_h263_inter((quanth263_interFunc*)quant4_inter_c, |
test_quant(quant4_inter_c, quant4_inter_xmm, "xmm", TEST_QUANT_INTER, flags); |
|
(quanth263_interFunc*)quant4_inter_xmm, NULL, "xmm", -2048, 2047); |
|
|
|
|
910 |
|
|
911 |
printf("\n--- dequant4_intra ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
914 |
test_h263_intra((quanth263_intraFunc*)dequant4_intra_c, |
test_quant(dequant4_intra_c, dequant4_intra_mmx, "mmx", TEST_DEQUANT_INTRA, flags); |
|
(quanth263_intraFunc*)dequant4_intra_mmx, "c", "mmx", -256, 255); |
|
915 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
916 |
test_h263_intra((quanth263_intraFunc*)dequant4_intra_c, |
test_quant(dequant4_intra_c, dequant4_intra_3dne, "3dne", TEST_DEQUANT_INTRA, flags); |
|
(quanth263_intraFunc*)dequant4_intra_3dne, NULL, "sse2", -256, 255); |
|
917 |
|
|
918 |
printf("\n--- dequant4_inter ---\n"); |
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) |
if (cpu_flags & XVID_CPU_MMX) |
921 |
test_h263_inter((quanth263_interFunc*)dequant4_inter_c, |
test_quant(dequant4_inter_c, dequant4_inter_mmx, "mmx", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant4_inter_mmx, "c", "mmx", -256, 255); |
|
922 |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
if (cpu_flags & XVID_CPU_3DNOWEXT) |
923 |
test_h263_inter((quanth263_interFunc*)dequant4_inter_c, |
test_quant(dequant4_inter_c, dequant4_inter_3dne, "3dne", TEST_DEQUANT_INTER, flags); |
|
(quanth263_interFunc*)dequant4_inter_3dne, NULL, "sse2", -256, 255); |
|
924 |
|
|
925 |
emms_mmx(); |
emms_mmx(); |
926 |
|
|
945 |
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
return xvid_init_convert((XVID_INIT_CONVERTINFO*)param1); |
946 |
|
|
947 |
case XVID_INIT_TEST : |
case XVID_INIT_TEST : |
948 |
return xvid_init_test(); |
return xvid_init_test((int)param1); |
949 |
|
|
950 |
default : |
default : |
951 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |