58 |
#include "utils/timer.h" |
#include "utils/timer.h" |
59 |
#include "quant/quant_matrix.c" |
#include "quant/quant_matrix.c" |
60 |
#include "bitstream/cbp.h" |
#include "bitstream/cbp.h" |
61 |
|
#include "bitstream/bitstream.h" |
62 |
|
|
63 |
#include <math.h> |
#include <math.h> |
64 |
|
|
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 }, |
122 |
|
{ "SSE3 ", XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMX }, |
123 |
|
{ "SSE41 ", XVID_CPU_SSE41| XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMX }, |
124 |
{ "3DNOW ", XVID_CPU_3DNOW }, |
{ "3DNOW ", XVID_CPU_3DNOW }, |
125 |
{ "3DNOWE ", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT }, |
{ "3DNOWE ", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT }, |
126 |
#endif |
#endif |
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 |
413 |
|
|
414 |
t = gettime_usec(); |
t = gettime_usec(); |
415 |
emms(); |
emms(); |
416 |
|
for(tst=0; tst<nb_tests; ++tst) s = sad8bi(Cur, Ref1, Ref2, 8); |
417 |
|
emms(); |
418 |
|
t = (gettime_usec() - t) / nb_tests; |
419 |
|
printf( "%s - sad8bi %.3f usec sad=%d %s\n", |
420 |
|
cpu->name, t, s, |
421 |
|
(s!=4002)?"| ERROR": "" ); |
422 |
|
|
423 |
|
t = gettime_usec(); |
424 |
|
emms(); |
425 |
for(tst=0; tst<nb_tests; ++tst) s = dev16(Cur, 16); |
for(tst=0; tst<nb_tests; ++tst) s = dev16(Cur, 16); |
426 |
emms(); |
emms(); |
427 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |
527 |
(iCrc!=8107)?"| ERROR": "" ); |
(iCrc!=8107)?"| ERROR": "" ); |
528 |
#endif |
#endif |
529 |
|
|
530 |
|
/* New functions for field prediction by CK 1.10.2005 */ |
531 |
|
#pragma NEW8X4 |
532 |
|
TEST_MB(interpolate8x4_halfpel_h, 0); |
533 |
|
printf("%s - interpfield-h -round0 %.3f usec crc32=0x%08x %s\n", |
534 |
|
cpu->name, t, iCrc, |
535 |
|
(iCrc!=0x9538d6df)?"| ERROR": "" ); |
536 |
|
|
537 |
|
TEST_MB(interpolate8x4_halfpel_h, 1); |
538 |
|
printf("%s - round1 %.3f usec crc32=0x%08x %s\n", |
539 |
|
cpu->name, t, iCrc, |
540 |
|
(iCrc!=0xde5f1db4)?"| ERROR": "" ); |
541 |
|
|
542 |
|
|
543 |
|
TEST_MB(interpolate8x4_halfpel_v, 0); |
544 |
|
printf("%s - interpfield- v-round0 %.3f usec crc32=0x%08x %s\n", |
545 |
|
cpu->name, t, iCrc, |
546 |
|
(iCrc!=0xea5a69ef)?"| ERROR": "" ); |
547 |
|
|
548 |
|
TEST_MB(interpolate8x4_halfpel_v, 1); |
549 |
|
printf("%s - round1 %.3f usec crc32=0x%08x %s\n", |
550 |
|
cpu->name, t, iCrc, |
551 |
|
(iCrc!=0x4f10ec0f)?"| ERROR": "" ); |
552 |
|
|
553 |
|
|
554 |
|
TEST_MB(interpolate8x4_halfpel_hv, 0); |
555 |
|
printf("%s - interpfield-hv-round0 %.3f usec crc32=0x%08x %s\n", |
556 |
|
cpu->name, t, iCrc, |
557 |
|
(iCrc!=0xf97ee367)?"| ERROR": "" ); |
558 |
|
|
559 |
|
TEST_MB(interpolate8x4_halfpel_hv, 1); |
560 |
|
printf("%s - round1 %.3f usec crc32=0x%08x %s\n", |
561 |
|
cpu->name, t, iCrc, |
562 |
|
(iCrc!=0xb6a9f581)?"| ERROR": "" ); |
563 |
|
/* End of 8x4 functions */ |
564 |
|
|
565 |
printf( " --- \n" ); |
printf( " --- \n" ); |
566 |
} |
} |
567 |
} |
} |
568 |
|
|
569 |
|
#undef ENTER |
570 |
|
#undef LEAVE |
571 |
|
#undef TEST_MB |
572 |
|
#undef TEST_MB2 |
573 |
|
|
574 |
/********************************************************************* |
/********************************************************************* |
575 |
* test transfer |
* test transfer |
576 |
*********************************************************************/ |
*********************************************************************/ |
674 |
cpu->name, t, s, |
cpu->name, t, s, |
675 |
(s!=0xee7ccbb4)?"| ERROR": ""); |
(s!=0xee7ccbb4)?"| ERROR": ""); |
676 |
|
|
677 |
|
/* New functions for field prediction by CK 1.10.2005 */ |
678 |
|
#pragma NEW8X4 |
679 |
|
TEST_TRANSFER(transfer8x4_copy, Dst8, Src8); |
680 |
|
printf("%s - 8to4 %.3f usec crc32=0x%08x %s\n", |
681 |
|
cpu->name, t, s, |
682 |
|
(s!=0xbb9c3db5)?"| ERROR": ""); |
683 |
|
/* End of new functions */ |
684 |
|
|
685 |
TEST_TRANSFER(transfer8x8_copy, Dst8, Src8); |
TEST_TRANSFER(transfer8x8_copy, Dst8, Src8); |
686 |
printf("%s - 8to8 %.3f usec crc32=0x%08x %s\n", |
printf("%s - 8to8 %.3f usec crc32=0x%08x %s\n", |
687 |
cpu->name, t, s, |
cpu->name, t, s, |
739 |
set_intra_matrix( mpeg_quant_matrices, Quant ); \ |
set_intra_matrix( mpeg_quant_matrices, Quant ); \ |
740 |
emms(); \ |
emms(); \ |
741 |
for(q=1; q<=max_Q; ++q) { \ |
for(q=1; q<=max_Q; ++q) { \ |
742 |
|
init_intra_matrix( mpeg_quant_matrices, q ); \ |
743 |
for(tst=0; tst<nb_tests; ++tst) \ |
for(tst=0; tst<nb_tests; ++tst) \ |
744 |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
745 |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
750 |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
t = (gettime_usec()-t-overhead)/nb_tests/qm |
751 |
|
|
752 |
#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \ |
#define TEST_INTRA(REFFUNC, NEWFUNC, RANGE) \ |
753 |
{ int i,q,s;\ |
{ int32_t i,q,s;\ |
754 |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); \ |
755 |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); \ |
756 |
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
DECLARE_ALIGNED_MATRIX(Dst2,8, 8, int16_t, 16); \ |
782 |
|
|
783 |
void test_quant() |
void test_quant() |
784 |
{ |
{ |
785 |
const int nb_tests = 1*speed_ref; |
const int32_t nb_tests = 1*speed_ref; |
786 |
const int max_Q = 31; |
const int32_t max_Q = 31; |
787 |
DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16); |
DECLARE_ALIGNED_MATRIX(mpeg_quant_matrices, 8, 64, uint16_t, 16); |
788 |
|
|
789 |
int i, qm; |
int32_t i, qm; |
790 |
CPU *cpu; |
CPU *cpu; |
791 |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src, 8, 8, int16_t, 16); |
792 |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Dst, 8, 8, int16_t, 16); |
805 |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
806 |
{ |
{ |
807 |
double t, overhead; |
double t, overhead; |
808 |
int tst, q; |
int32_t tst, q; |
809 |
uint32_t s; |
uint32_t s; |
810 |
|
|
811 |
if (!init_cpu(cpu)) |
if (!init_cpu(cpu)) |
829 |
TEST_QUANT2(quant_mpeg_intra, Dst, Src); |
TEST_QUANT2(quant_mpeg_intra, Dst, Src); |
830 |
printf("%s - quant_mpeg_intra %.3f usec crc32=0x%08x %s\n", |
printf("%s - quant_mpeg_intra %.3f usec crc32=0x%08x %s\n", |
831 |
cpu->name, t, s, |
cpu->name, t, s, |
832 |
(s!=0xfd6a21a4)? "| ERROR": ""); |
(s!=0x3b999af6)? "| ERROR": ""); |
833 |
|
|
834 |
TEST_QUANT(quant_mpeg_inter, Dst, Src); |
TEST_QUANT(quant_mpeg_inter, Dst, Src); |
835 |
printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", |
printf("%s - quant_mpeg_inter %.3f usec crc32=0x%08x %s\n", |
1715 |
} |
} |
1716 |
#endif |
#endif |
1717 |
} |
} |
1718 |
|
|
1719 |
|
/********************************************************************* |
1720 |
|
* test some YUV func |
1721 |
|
*********************************************************************/ |
1722 |
|
|
1723 |
|
#define ENTER \ |
1724 |
|
for(i=0; i<(int)sizeof(Dst0); ++i) Dst0[0][i] = 0; \ |
1725 |
|
t = gettime_usec(); \ |
1726 |
|
emms(); |
1727 |
|
|
1728 |
|
#define LEAVE \ |
1729 |
|
emms(); \ |
1730 |
|
t = (gettime_usec() - t) / nb_tests; \ |
1731 |
|
iCrc = calc_crc((uint8_t*)Dst0, sizeof(Dst0), CRC32_INITIAL) |
1732 |
|
|
1733 |
|
#define TEST_YUYV(FUNC, S, FLIP) \ |
1734 |
|
ENTER \ |
1735 |
|
for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], S*WIDTH, Src0[0], Src0[1], Src0[2], WIDTH, WIDTH/2, WIDTH, HEIGHT, (FLIP)); \ |
1736 |
|
LEAVE |
1737 |
|
|
1738 |
|
static const int yuv_CRCs[6][2] = { |
1739 |
|
{0x0f4fb96b,0x780b6a68} |
1740 |
|
, {0xa986b289,0x65e49b76} |
1741 |
|
, {0x7f19c152,0xd539b86e} |
1742 |
|
, {0x0f4fb96b,0x780b6a68} |
1743 |
|
, {0xa986b289,0x65e49b76} |
1744 |
|
, {0x36ab8b57,0x1cd92fee} |
1745 |
|
}; |
1746 |
|
|
1747 |
|
#define WIDTH 128 |
1748 |
|
#define HEIGHT 32 |
1749 |
|
void test_yuv() |
1750 |
|
{ |
1751 |
|
const int nb_tests = 200*speed_ref; |
1752 |
|
CPU *cpu; |
1753 |
|
uint8_t Src0[3][WIDTH*HEIGHT]; |
1754 |
|
uint8_t Dst0[4][WIDTH*HEIGHT]; |
1755 |
|
int i, j, with_flip; |
1756 |
|
double t; |
1757 |
|
int tst, iCrc; |
1758 |
|
|
1759 |
|
colorspace_init(); |
1760 |
|
ieee_reseed(1); |
1761 |
|
for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255); |
1762 |
|
for(i=0; i<(int)sizeof(Dst0); ++i) Dst0[0][i] = 0x5a; |
1763 |
|
|
1764 |
|
printf( "\n === test YUV ===\n" ); |
1765 |
|
|
1766 |
|
for(with_flip=0; with_flip<=1; ++with_flip) { |
1767 |
|
|
1768 |
|
init_cpu(&cpu_list[0]); |
1769 |
|
TEST_YUYV(yv12_to_yuyv_c, 4, with_flip); |
1770 |
|
printf(" yv12_to_yuyv_c %.3f usec crc32=0x%08x %s\n", |
1771 |
|
t, iCrc, (iCrc!=yuv_CRCs[0][with_flip])?"| ERROR": "" ); |
1772 |
|
TEST_YUYV(yv12_to_uyvy_c, 4, with_flip); |
1773 |
|
printf(" yv12_to_uyvy_c %.3f usec crc32=0x%08x %s\n", |
1774 |
|
t, iCrc, (iCrc!=yuv_CRCs[1][with_flip])?"| ERROR": "" ); |
1775 |
|
|
1776 |
|
TEST_YUYV(yv12_to_bgra_c, 4, with_flip); |
1777 |
|
printf(" yv12_to_bgra_c %.3f usec crc32=0x%08x %s\n", |
1778 |
|
t, iCrc, (iCrc!=yuv_CRCs[2][with_flip])?"| ERROR": "" ); |
1779 |
|
|
1780 |
|
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
1781 |
|
init_cpu(&cpu_list[1]); |
1782 |
|
TEST_YUYV(yv12_to_yuyv_mmx, 4, with_flip); |
1783 |
|
printf(" yv12_to_yuyv_mmx %.3f usec crc32=0x%08x %s\n", |
1784 |
|
t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" ); |
1785 |
|
|
1786 |
|
TEST_YUYV(yv12_to_uyvy_mmx, 4, with_flip); |
1787 |
|
printf(" yv12_to_uyvy_mmx %.3f usec crc32=0x%08x %s\n", |
1788 |
|
t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" ); |
1789 |
|
|
1790 |
|
TEST_YUYV(yv12_to_bgra_mmx, 4, with_flip); |
1791 |
|
printf(" yv12_to_bgra_mmx %.3f usec crc32=0x%08x %s\n", |
1792 |
|
t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" ); |
1793 |
|
|
1794 |
|
#endif |
1795 |
|
|
1796 |
|
#ifdef ARCH_IS_PPC |
1797 |
|
init_cpu(&cpu_list[1]); |
1798 |
|
TEST_YUYV(yv12_to_yuyv_altivec_c, 4, with_flip); |
1799 |
|
printf(" yv12_to_yuyv_altivec_c %.3f usec crc32=0x%08x %s\n", |
1800 |
|
t, iCrc, (iCrc!=yuv_CRCs[3][with_flip])?"| ERROR": "" ); |
1801 |
|
|
1802 |
|
TEST_YUYV(yv12_to_uyvy_altivec_c, 4, with_flip); |
1803 |
|
printf(" yv12_to_uyvy_altivec_c %.3f usec crc32=0x%08x %s\n", |
1804 |
|
t, iCrc, (iCrc!=yuv_CRCs[4][with_flip])?"| ERROR": "" ); |
1805 |
|
|
1806 |
|
TEST_YUYV(yv12_to_bgra_altivec_c, 4, with_flip); |
1807 |
|
printf(" yv12_to_bgra_altivec_c %.3f usec crc32=0x%08x %s\n", |
1808 |
|
t, iCrc, (iCrc!=yuv_CRCs[5][with_flip])?"| ERROR": "" ); |
1809 |
|
#endif |
1810 |
|
} |
1811 |
|
printf( " --- \n" ); |
1812 |
|
} |
1813 |
|
|
1814 |
|
#define TEST_YV2(FUNC, WITH_UV, WITH_FLIP) \ |
1815 |
|
ENTER \ |
1816 |
|
for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], Dst0[1], Dst0[2], WIDTH, WIDTH, \ |
1817 |
|
Src0[0], (WITH_UV) ? Src0[1] : 0, (WITH_UV) ? Src0[2] : 0, WIDTH, WIDTH, \ |
1818 |
|
WIDTH-2, HEIGHT-2, WITH_FLIP); \ |
1819 |
|
LEAVE |
1820 |
|
|
1821 |
|
#define PRINT_NxN(DATA,W,H,STR) { \ |
1822 |
|
int i,j; \ |
1823 |
|
for(j=0; j<(H); ++j) { \ |
1824 |
|
for(i=0; i<(W); ++i) printf( "0x%.2x ", (DATA)[i+j*(STR)] );\ |
1825 |
|
printf("\n"); \ |
1826 |
|
} \ |
1827 |
|
printf("---\n"); \ |
1828 |
|
} |
1829 |
|
|
1830 |
|
static const int yv12_CRCs[2][2] = { |
1831 |
|
{0x5cab7cf0,0xdab46541} |
1832 |
|
, {0xe8bae865,0x1faf77b7} |
1833 |
|
}; |
1834 |
|
|
1835 |
|
void test_yuv2() |
1836 |
|
{ |
1837 |
|
const int nb_tests = 800*speed_ref; |
1838 |
|
CPU *cpu; |
1839 |
|
uint8_t Src0[3][WIDTH*HEIGHT]; |
1840 |
|
uint8_t Dst0[3][WIDTH*HEIGHT]; |
1841 |
|
int with_uv, with_flip; |
1842 |
|
int i, j; |
1843 |
|
double t; |
1844 |
|
int tst, iCrc; |
1845 |
|
|
1846 |
|
colorspace_init(); |
1847 |
|
ieee_reseed(1); |
1848 |
|
for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255); |
1849 |
|
|
1850 |
|
printf( "\n === test YV2 ===\n" ); |
1851 |
|
for(with_flip=0; with_flip<=1; ++with_flip) { |
1852 |
|
for(with_uv=0; with_uv<=1; ++with_uv) { |
1853 |
|
init_cpu(&cpu_list[0]); |
1854 |
|
TEST_YV2(yv12_to_yv12_c, with_uv, with_flip); |
1855 |
|
printf(" yv12_to_yv12_c %.3f usec \tcrc32=0x%08x %s\n", |
1856 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1857 |
|
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
1858 |
|
|
1859 |
|
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
1860 |
|
init_cpu(&cpu_list[1]); |
1861 |
|
TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip); |
1862 |
|
printf(" yv12_to_yv12_mmx %.3f usec \tcrc32=0x%08x %s\n", |
1863 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1864 |
|
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
1865 |
|
|
1866 |
|
TEST_YV2(yv12_to_yv12_xmm, with_uv, with_flip); |
1867 |
|
printf(" yv12_to_yv12_xmm %.3f usec \tcrc32=0x%08x %s\n", |
1868 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1869 |
|
#endif |
1870 |
|
} |
1871 |
|
|
1872 |
|
printf( " --- \n" ); |
1873 |
|
} |
1874 |
|
printf( " ===== \n" ); |
1875 |
|
} |
1876 |
|
|
1877 |
|
#undef WIDTH |
1878 |
|
#undef HEIGHT |
1879 |
|
#undef ENTER |
1880 |
|
#undef LEAVE |
1881 |
|
|
1882 |
/*********************************************************************/ |
/*********************************************************************/ |
1883 |
|
|
1884 |
static uint32_t __inline log2bin_v1(uint32_t value) |
static uint32_t __inline log2bin_v1(uint32_t value) |
2001 |
} |
} |
2002 |
|
|
2003 |
/********************************************************************* |
/********************************************************************* |
2004 |
|
* test compiler |
2005 |
|
*********************************************************************/ |
2006 |
|
|
2007 |
|
void test_compiler() { |
2008 |
|
int nb_err = 0; |
2009 |
|
int32_t v; |
2010 |
|
if (sizeof(uint16_t)<2) { |
2011 |
|
printf( "ERROR: sizeof(uint16_t)<2 !!\n" ); |
2012 |
|
nb_err++; |
2013 |
|
} |
2014 |
|
if (sizeof(int16_t)<2) { |
2015 |
|
printf( "ERROR: sizeof(int16_t)<2 !!\n" ); |
2016 |
|
nb_err++; |
2017 |
|
} |
2018 |
|
if (sizeof(uint8_t)!=1) { |
2019 |
|
printf( "ERROR: sizeof(uint8_t)!=1 !!\n" ); |
2020 |
|
nb_err++; |
2021 |
|
} |
2022 |
|
if (sizeof(int8_t)!=1) { |
2023 |
|
printf( "ERROR: sizeof(int8_t)!=1 !!\n" ); |
2024 |
|
nb_err++; |
2025 |
|
} |
2026 |
|
if (sizeof(uint32_t)<4) { |
2027 |
|
printf( "ERROR: sizeof(uint32_t)<4 !!\n" ); |
2028 |
|
nb_err++; |
2029 |
|
} |
2030 |
|
if (sizeof(int32_t)<4) { |
2031 |
|
printf( "ERROR: sizeof(int32_t)<4 !!\n" ); |
2032 |
|
nb_err++; |
2033 |
|
} |
2034 |
|
/* yes, i know, this test is silly. But better be safe than sorry. :) */ |
2035 |
|
for(v=1000; v>=0; v--) { |
2036 |
|
if ( (v>>2) != v/4) |
2037 |
|
nb_err++; |
2038 |
|
} |
2039 |
|
for(v=-1000; v!=-1; v++) { |
2040 |
|
if ( (v>>2) != (v/4)-!!(v%4)) |
2041 |
|
nb_err++; |
2042 |
|
} |
2043 |
|
if (nb_err!=0) { |
2044 |
|
printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" ); |
2045 |
|
} |
2046 |
|
} |
2047 |
|
|
2048 |
|
/********************************************************************* |
2049 |
|
* test SSIM functions |
2050 |
|
*********************************************************************/ |
2051 |
|
|
2052 |
|
typedef int (*lumfunc)(uint8_t* ptr, int stride); |
2053 |
|
typedef void (*csfunc)(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2054 |
|
|
2055 |
|
extern int lum_8x8_c(uint8_t* ptr, int stride); |
2056 |
|
extern int lum_8x8_mmx(uint8_t* ptr, int stride); |
2057 |
|
extern int lum_2x8_c(uint8_t* ptr, int stride); |
2058 |
|
extern void consim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2059 |
|
extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2060 |
|
extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2061 |
|
|
2062 |
|
void test_SSIM() |
2063 |
|
{ |
2064 |
|
const int nb_tests = 3000*speed_ref; |
2065 |
|
int tst; |
2066 |
|
CPU *cpu; |
2067 |
|
int i; |
2068 |
|
int devs[3]; |
2069 |
|
long lumo, lumc; |
2070 |
|
DECLARE_ALIGNED_MATRIX(Ref1, 16, 16, uint8_t, 16); |
2071 |
|
DECLARE_ALIGNED_MATRIX(Ref2, 16, 16, uint8_t, 16); |
2072 |
|
lumfunc lum8x8; |
2073 |
|
lumfunc lum2x8; |
2074 |
|
csfunc csim; |
2075 |
|
|
2076 |
|
ieee_reseed(1); |
2077 |
|
printf( "\n ====== test SSIM ======\n" ); |
2078 |
|
for(i=0; i<16*16;++i) { |
2079 |
|
long v1, v2; |
2080 |
|
v1 = ieee_rand(-256, 511); |
2081 |
|
v2 = ieee_rand(-256, 511); |
2082 |
|
Ref1[i] = (v1<0) ? 0 : (v1>255) ? 255 : v1; |
2083 |
|
Ref2[i] = (v2<0) ? 0 : (v2>255) ? 255 : v2; |
2084 |
|
} |
2085 |
|
lumc = ieee_rand(0, 255); |
2086 |
|
lumo = ieee_rand(0, 255); |
2087 |
|
|
2088 |
|
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
2089 |
|
{ |
2090 |
|
double t; |
2091 |
|
int m; |
2092 |
|
if (!init_cpu(cpu)) |
2093 |
|
continue; |
2094 |
|
lum8x8 = lum_8x8_c; |
2095 |
|
lum2x8 = lum_2x8_c; |
2096 |
|
csim = consim_c; |
2097 |
|
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
2098 |
|
if (cpu->cpu & XVID_CPU_MMX){ |
2099 |
|
lum8x8 = lum_8x8_mmx; |
2100 |
|
csim = consim_mmx; |
2101 |
|
} |
2102 |
|
if (cpu->cpu & XVID_CPU_MMX){ |
2103 |
|
csim = consim_sse2; |
2104 |
|
} |
2105 |
|
#endif |
2106 |
|
t = gettime_usec(); |
2107 |
|
emms(); |
2108 |
|
for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16); |
2109 |
|
emms(); |
2110 |
|
t = (gettime_usec() - t) / nb_tests; |
2111 |
|
printf("%s - ssim-lum8x8 %.3f usec m=%d %s\n", |
2112 |
|
cpu->name, t, m, |
2113 |
|
(m!=8230)?"| ERROR": "" ); |
2114 |
|
|
2115 |
|
t = gettime_usec(); |
2116 |
|
emms(); |
2117 |
|
for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1+8, 16); |
2118 |
|
emms(); |
2119 |
|
t = (gettime_usec() - t) / nb_tests; |
2120 |
|
printf("%s - ssim-lum2x8 %.3f usec m=%d %s\n", |
2121 |
|
cpu->name, t, m, |
2122 |
|
(m!=681)?"| ERROR": "" ); |
2123 |
|
|
2124 |
|
t = gettime_usec(); |
2125 |
|
emms(); |
2126 |
|
for(tst=0; tst<nb_tests; ++tst) csim(Ref1, Ref2, 16, lumo, lumc, devs+0, devs+1, devs+2); |
2127 |
|
emms(); |
2128 |
|
t = (gettime_usec() - t) / nb_tests; |
2129 |
|
printf("%s - ssim-consim %.3f usec devs=[0x%x 0x%x 0x%x] %s\n", |
2130 |
|
cpu->name, t, devs[0], devs[1], devs[2], |
2131 |
|
(devs[0]!=0x1bdf0f || devs[1]!=0x137258 || devs[2]!=0xcdb13)?"| ERROR": "" ); |
2132 |
|
printf( " --- \n" ); |
2133 |
|
} |
2134 |
|
} |
2135 |
|
|
2136 |
|
/********************************************************************* |
2137 |
|
* test bitstream functions |
2138 |
|
*********************************************************************/ |
2139 |
|
|
2140 |
|
#define BIT_BUF_SIZE 2000 |
2141 |
|
|
2142 |
|
static void test_bits() |
2143 |
|
{ |
2144 |
|
const int nb_tests = 50*speed_ref; |
2145 |
|
int tst; |
2146 |
|
uint32_t Crc; |
2147 |
|
uint8_t Buf[BIT_BUF_SIZE]; |
2148 |
|
uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */ |
2149 |
|
int Lens[BIT_BUF_SIZE*8]; |
2150 |
|
double t1; |
2151 |
|
|
2152 |
|
|
2153 |
|
printf( "\n === test bitstream ===\n" ); |
2154 |
|
ieee_reseed(1); |
2155 |
|
Crc = 0; |
2156 |
|
|
2157 |
|
t1 = gettime_usec(); |
2158 |
|
for(tst=0; tst<nb_tests; ++tst) { |
2159 |
|
Bitstream bs; |
2160 |
|
int m, m2, l, l2; |
2161 |
|
|
2162 |
|
for(l=0; l<BIT_BUF_SIZE; ++l) |
2163 |
|
Buf[l] = (uint8_t)ieee_rand(0,255); |
2164 |
|
|
2165 |
|
l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10); |
2166 |
|
BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l); |
2167 |
|
|
2168 |
|
|
2169 |
|
BitstreamReset(&bs); |
2170 |
|
for(l2=l*8, m=0; l2>0; m++) { |
2171 |
|
const int b = ieee_rand(1,32); |
2172 |
|
Lens[m] = b; |
2173 |
|
l2 -= b; |
2174 |
|
if (l2<0) break; |
2175 |
|
Extracted[m] = BitstreamShowBits(&bs, b); |
2176 |
|
BitstreamSkip(&bs, b); |
2177 |
|
// printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]); |
2178 |
|
} |
2179 |
|
|
2180 |
|
BitstreamReset(&bs); |
2181 |
|
for(m2=0; m2<m; ++m2) { |
2182 |
|
const int b = Lens[m2]; |
2183 |
|
const uint32_t v = BitstreamGetBits(&bs, b); |
2184 |
|
Crc |= (v!=Extracted[m2]); |
2185 |
|
// printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]); |
2186 |
|
} |
2187 |
|
} |
2188 |
|
t1 = (gettime_usec() - t1) / nb_tests; |
2189 |
|
printf(" test_bits %.3f usec %s\n", t1, (Crc!=0)?"| ERROR": "" ); |
2190 |
|
} |
2191 |
|
|
2192 |
|
/********************************************************************* |
2193 |
* main |
* main |
2194 |
*********************************************************************/ |
*********************************************************************/ |
2195 |
|
|
2214 |
else if (!strcmp(argv[c], "-mmx")) cpu_mask = XVID_CPU_MMX | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-mmx")) cpu_mask = XVID_CPU_MMX | XVID_CPU_FORCE; |
2215 |
else if (!strcmp(argv[c], "-mmxext")) cpu_mask = XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-mmxext")) cpu_mask = XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
2216 |
else if (!strcmp(argv[c], "-sse2")) cpu_mask = XVID_CPU_SSE2 | XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-sse2")) cpu_mask = XVID_CPU_SSE2 | XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
2217 |
|
else if (!strcmp(argv[c], "-sse3")) cpu_mask = XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
2218 |
|
else if (!strcmp(argv[c], "-sse4")) cpu_mask = XVID_CPU_SSE41 | XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
2219 |
else if (!strcmp(argv[c], "-3dnow")) cpu_mask = XVID_CPU_3DNOW | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-3dnow")) cpu_mask = XVID_CPU_3DNOW | XVID_CPU_FORCE; |
2220 |
else if (!strcmp(argv[c], "-3dnowe")) cpu_mask = XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-3dnowe")) cpu_mask = XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT | XVID_CPU_FORCE; |
2221 |
else if (!strcmp(argv[c], "-altivec")) cpu_mask = XVID_CPU_ALTIVEC | XVID_CPU_FORCE; |
else if (!strcmp(argv[c], "-altivec")) cpu_mask = XVID_CPU_ALTIVEC | XVID_CPU_FORCE; |
2259 |
if (what==0 || what==10) test_sse(); |
if (what==0 || what==10) test_sse(); |
2260 |
if (what==0 || what==11) test_log2bin(); |
if (what==0 || what==11) test_log2bin(); |
2261 |
if (what==0 || what==12) test_gcd(); |
if (what==0 || what==12) test_gcd(); |
2262 |
|
if (what==0 || what==13) test_compiler(); |
2263 |
|
if (what==0 || what==14) test_yuv(); |
2264 |
|
if (what==0 || what==15) test_SSIM(); |
2265 |
|
if (what==0 || what==16) test_yuv2(); |
2266 |
|
if (what==0 || what==17) test_bits(); |
2267 |
|
|
2268 |
if (what==7) { |
if (what==7) { |
2269 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |
2291 |
" may appear to be slow.\n"); |
" may appear to be slow.\n"); |
2292 |
} |
} |
2293 |
|
|
2294 |
#ifdef ARCH_IS_IA32 |
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
2295 |
if (what == 0 || what == 5) { |
if (what == 0 || what == 5) { |
2296 |
printf("\n" |
printf("\n" |
2297 |
"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" |