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_bench.c,v 1.36 2008-11-14 15:43:27 Isibaar Exp $ |
* $Id: xvid_bench.c,v 1.37 2008-11-26 09:31:06 Isibaar Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
115 |
|
|
116 |
CPU cpu_list[] = { |
CPU cpu_list[] = { |
117 |
{ "PLAINC ", 0 }, |
{ "PLAINC ", 0 }, |
118 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
119 |
{ "MMX ", XVID_CPU_MMX }, |
{ "MMX ", XVID_CPU_MMX }, |
120 |
{ "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX }, |
{ "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX }, |
121 |
{ "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX }, |
{ "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX }, |
127 |
#ifdef ARCH_IS_PPC |
#ifdef ARCH_IS_PPC |
128 |
{ "ALTIVEC", XVID_CPU_ALTIVEC }, |
{ "ALTIVEC", XVID_CPU_ALTIVEC }, |
129 |
#endif |
#endif |
|
#ifdef ARCH_IS_X86_64 |
|
|
{ "X86_64 ", XVID_CPU_ASM}, |
|
|
#endif |
|
130 |
#ifdef ARCH_IS_IA64 |
#ifdef ARCH_IS_IA64 |
131 |
// { "IA64 ", XVID_CPU_IA64 }, |
// { "IA64 ", XVID_CPU_IA64 }, |
132 |
#endif |
#endif |
730 |
set_intra_matrix( mpeg_quant_matrices, Quant ); \ |
set_intra_matrix( mpeg_quant_matrices, Quant ); \ |
731 |
emms(); \ |
emms(); \ |
732 |
for(q=1; q<=max_Q; ++q) { \ |
for(q=1; q<=max_Q; ++q) { \ |
733 |
|
init_intra_matrix( mpeg_quant_matrices, q ); \ |
734 |
for(tst=0; tst<nb_tests; ++tst) \ |
for(tst=0; tst<nb_tests; ++tst) \ |
735 |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
736 |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
741 |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
742 |
|
|
743 |
#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \ |
#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \ |
744 |
{ int i,q,s;\ |
{ int32_t i,q,s;\ |
745 |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
746 |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
747 |
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
773 |
|
|
774 |
void test_quant() |
void test_quant() |
775 |
{ |
{ |
776 |
const int nb_tests = 1*speed_ref; |
const int32_t nb_tests = 1*speed_ref; |
777 |
const int max_Q = 31; |
const int32_t max_Q = 31; |
778 |
DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16); |
DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16); |
779 |
|
|
780 |
int i, qm; |
int32_t i, qm; |
781 |
CPU *cpu; |
CPU *cpu; |
782 |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
783 |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
796 |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
797 |
{ |
{ |
798 |
double t, overhead; |
double t, overhead; |
799 |
int tst, q; |
int32_t tst, q; |
800 |
uint32_t s; |
uint32_t s; |
801 |
|
|
802 |
if (!init_cpu(cpu)) |
if (!init_cpu(cpu)) |
820 |
TEST_QUANT2(quant_mpeg_intra, Dst, Src); |
TEST_QUANT2(quant_mpeg_intra, Dst, Src); |
821 |
printf("%s - quant_mpeg_intra %.3f usec crc32=0x%08x %s\n", |
printf("%s - quant_mpeg_intra %.3f usec crc32=0x%08x %s\n", |
822 |
cpu->name, t, s, |
cpu->name, t, s, |
823 |
(s!=0xfd6a21a4)? "| ERROR": ""); |
(s!=0x3b999af6)? "| ERROR": ""); |
824 |
|
|
825 |
TEST_QUANT(quant_mpeg_inter, Dst, Src); |
TEST_QUANT(quant_mpeg_inter, Dst, Src); |
826 |
printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", |
printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", |
1721 |
t = (gettime_usec() - t) / nb_tests; \ |
t = (gettime_usec() - t) / nb_tests; \ |
1722 |
iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL) |
iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL) |
1723 |
|
|
1724 |
#define TEST_YUYV(FUNC, S) \ |
#define TEST_YUYV(FUNC, S, FLIP) \ |
1725 |
ENTER \ |
ENTER \ |
1726 |
for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, 0); \ |
for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, (FLIP)); \ |
1727 |
LEAVE |
LEAVE |
1728 |
|
|
1729 |
|
static const int yuv_CRCs[6][2] = { |
1730 |
|
{0x0f4fb96b,0x780b6a68} |
1731 |
|
, {0xa986b289,0x65e49b76} |
1732 |
|
, {0x7f19c152,0xd539b86e} |
1733 |
|
, {0x0f4fb96b,0x780b6a68} |
1734 |
|
, {0xa986b289,0x65e49b76} |
1735 |
|
, {0x36ab8b57,0x1cd92fee} |
1736 |
|
}; |
1737 |
|
|
1738 |
#define WIDTH 128 |
#define WIDTH 128 |
1739 |
#define HEIGHT 32 |
#define HEIGHT 32 |
1740 |
void test_yuv() |
void test_yuv() |
1743 |
CPU *cpu; |
CPU *cpu; |
1744 |
uint8_t Src0[3][WIDTH*HEIGHT]; |
uint8_t Src0[3][WIDTH*HEIGHT]; |
1745 |
uint8_t Dst0[4][WIDTH*HEIGHT]; |
uint8_t Dst0[4][WIDTH*HEIGHT]; |
1746 |
int i, j; |
int i, j, with_flip; |
1747 |
double t; |
double t; |
1748 |
int tst, iCrc; |
int tst, iCrc; |
1749 |
|
|
1754 |
|
|
1755 |
printf( "\n === test YUV ===\n" ); |
printf( "\n === test YUV ===\n" ); |
1756 |
|
|
1757 |
|
for(with_flip=0; with_flip<=1; ++with_flip) { |
1758 |
|
|
1759 |
init_cpu(&cpu_list[0]); |
init_cpu(&cpu_list[0]); |
1760 |
TEST_YUYV(yv12_to_yuyv_c, 4); |
TEST_YUYV(yv12_to_yuyv_c, 4, with_flip); |
1761 |
printf(" yv12_to_yuyv_c %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_yuyv_c %.3f usec crc32=0x%08x %s\n", |
1762 |
t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[0][with_flip])?"| ERROR": "" ); |
1763 |
TEST_YUYV(yv12_to_uyvy_c, 4); |
TEST_YUYV(yv12_to_uyvy_c, 4, with_flip); |
1764 |
printf(" yv12_to_uyvy_c %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_uyvy_c %.3f usec crc32=0x%08x %s\n", |
1765 |
t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[1][with_flip])?"| ERROR": "" ); |
1766 |
|
|
1767 |
|
TEST_YUYV(yv12_to_bgra_c, 4, with_flip); |
1768 |
|
printf(" yv12_to_bgra_c %.3f usec crc32=0x%08x %s\n", |
1769 |
|
t, iCrc, (iCrc!=yuv_CRCs[2][with_flip])?"| ERROR": "" ); |
1770 |
|
|
1771 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
1772 |
init_cpu(&cpu_list[1]); |
init_cpu(&cpu_list[1]); |
1773 |
TEST_YUYV(yv12_to_yuyv_mmx, 4); |
TEST_YUYV(yv12_to_yuyv_mmx, 4, with_flip); |
1774 |
printf(" yv12_to_yuyv_mmx %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_yuyv_mmx %.3f usec crc32=0x%08x %s\n", |
1775 |
t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" ); |
1776 |
|
|
1777 |
TEST_YUYV(yv12_to_uyvy_mmx, 4); |
TEST_YUYV(yv12_to_uyvy_mmx, 4, with_flip); |
1778 |
printf(" yv12_to_uyvy_mmx %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_uyvy_mmx %.3f usec crc32=0x%08x %s\n", |
1779 |
t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" ); |
1780 |
|
|
1781 |
|
TEST_YUYV(yv12_to_bgra_mmx, 4, with_flip); |
1782 |
|
printf(" yv12_to_bgra_mmx %.3f usec crc32=0x%08x %s\n", |
1783 |
|
t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" ); |
1784 |
|
|
1785 |
#endif |
#endif |
1786 |
|
|
1787 |
#ifdef ARCH_IS_PPC |
#ifdef ARCH_IS_PPC |
1788 |
init_cpu(&cpu_list[1]); |
init_cpu(&cpu_list[1]); |
1789 |
TEST_YUYV(yv12_to_yuyv_altivec_c, 4); |
TEST_YUYV(yv12_to_yuyv_altivec_c, 4, with_flip); |
1790 |
printf(" yv12_to_yuyv_altivec_c %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_yuyv_altivec_c %.3f usec crc32=0x%08x %s\n", |
1791 |
t, iCrc, (iCrc!=0xeb1a0b0a)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" ); |
1792 |
|
|
1793 |
TEST_YUYV(yv12_to_uyvy_altivec_c, 4); |
TEST_YUYV(yv12_to_uyvy_altivec_c, 4, with_flip); |
1794 |
printf(" yv12_to_uyvy_altivec_c %.3f usec crc32=0x%08x %s\n", |
printf(" yv12_to_uyvy_altivec_c %.3f usec crc32=0x%08x %s\n", |
1795 |
t, iCrc, (iCrc!=0x6e82f55b)?"| ERROR": "" ); |
t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" ); |
1796 |
|
|
1797 |
|
TEST_YUYV(yv12_to_bgra_altivec_c, 4, with_flip); |
1798 |
|
printf(" yv12_to_bgra_altivec_c %.3f usec crc32=0x%08x %s\n", |
1799 |
|
t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" ); |
1800 |
#endif |
#endif |
1801 |
|
} |
1802 |
printf( " --- \n" ); |
printf( " --- \n" ); |
1803 |
} |
} |
1804 |
|
|
1847 |
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1848 |
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
1849 |
|
|
1850 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
1851 |
init_cpu(&cpu_list[1]); |
init_cpu(&cpu_list[1]); |
1852 |
TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip); |
TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip); |
1853 |
printf(" yv12_to_yv12_mmx %.3f usec \tcrc32=0x%08x %s\n", |
printf(" yv12_to_yv12_mmx %.3f usec \tcrc32=0x%08x %s\n", |
2085 |
lum8x8 = lum_8x8_c; |
lum8x8 = lum_8x8_c; |
2086 |
lum2x8 = lum_2x8_c; |
lum2x8 = lum_2x8_c; |
2087 |
csim = consim_c; |
csim = consim_c; |
2088 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
2089 |
if (cpu->cpu & XVID_CPU_MMX){ |
if (cpu->cpu & XVID_CPU_MMX){ |
2090 |
lum8x8 = lum_8x8_mmx; |
lum8x8 = lum_8x8_mmx; |
2091 |
csim = consim_mmx; |
csim = consim_mmx; |
2282 |
" may appear to be slow.\n"); |
" may appear to be slow.\n"); |
2283 |
} |
} |
2284 |
|
|
2285 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
2286 |
if (what == 0 || what == 5) { |
if (what == 0 || what == 5) { |
2287 |
printf("\n" |
printf("\n" |
2288 |
"NB: MMX mpeg4 quantization is known to have very small errors (+/-1 magnitude)\n" |
"NB: MMX mpeg4 quantization is known to have very small errors (+/-1 magnitude)\n" |