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 |
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 |
#define WIDTH 64 |
static const int yuv_CRCs[6][2] = { |
1730 |
#define HEIGHT 64 |
{0x0f4fb96b,0x780b6a68} |
1731 |
|
, {0xa986b289,0x65e49b76} |
1732 |
|
, {0x7f19c152,0xd539b86e} |
1733 |
|
, {0x0f4fb96b,0x780b6a68} |
1734 |
|
, {0xa986b289,0x65e49b76} |
1735 |
|
, {0x36ab8b57,0x1cd92fee} |
1736 |
|
}; |
1737 |
|
|
1738 |
|
#define WIDTH 128 |
1739 |
|
#define HEIGHT 32 |
1740 |
void test_yuv() |
void test_yuv() |
1741 |
{ |
{ |
1742 |
const int nb_tests = 200*speed_ref; |
const int nb_tests = 200*speed_ref; |
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 |
|
|
1750 |
colorspace_init(); |
colorspace_init(); |
1751 |
ieee_reseed(1); |
ieee_reseed(1); |
1752 |
for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255); |
for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255); |
1753 |
|
for(i=0; i<(int)sizeof(Dst0); ++i) Dst0[0][i] = 0x5a; |
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 |
|
|
1805 |
|
#define TEST_YV2(FUNC, WITH_UV, WITH_FLIP) \ |
1806 |
|
ENTER \ |
1807 |
|
for(tst=0; tst<nb_tests; ++tst) (FUNC)(Dst0[0], Dst0[1], Dst0[2], WIDTH, WIDTH, \ |
1808 |
|
Src0[0], (WITH_UV) ? Src0[1] : 0, (WITH_UV) ? Src0[2] : 0, WIDTH, WIDTH, \ |
1809 |
|
WIDTH-2, HEIGHT-2, WITH_FLIP); \ |
1810 |
|
LEAVE |
1811 |
|
|
1812 |
|
#define PRINT_NxN(DATA,W,H,STR) { \ |
1813 |
|
int i,j; \ |
1814 |
|
for(j=0; j<(H); ++j) { \ |
1815 |
|
for(i=0; i<(W); ++i) printf( "0x%.2x ", (DATA)[i+j*(STR)] );\ |
1816 |
|
printf("\n"); \ |
1817 |
|
} \ |
1818 |
|
printf("---\n"); \ |
1819 |
|
} |
1820 |
|
|
1821 |
|
static const int yv12_CRCs[2][2] = { |
1822 |
|
{0x5cab7cf0,0xdab46541} |
1823 |
|
, {0xe8bae865,0x1faf77b7} |
1824 |
|
}; |
1825 |
|
|
1826 |
|
void test_yuv2() |
1827 |
|
{ |
1828 |
|
const int nb_tests = 800*speed_ref; |
1829 |
|
CPU *cpu; |
1830 |
|
uint8_t Src0[3][WIDTH*HEIGHT]; |
1831 |
|
uint8_t Dst0[3][WIDTH*HEIGHT]; |
1832 |
|
int with_uv, with_flip; |
1833 |
|
int i, j; |
1834 |
|
double t; |
1835 |
|
int tst, iCrc; |
1836 |
|
|
1837 |
|
colorspace_init(); |
1838 |
|
ieee_reseed(1); |
1839 |
|
for(i=0; i<(int)sizeof(Src0); ++i) Src0[0][i] = ieee_rand(0,255); |
1840 |
|
|
1841 |
|
printf( "\n === test YV2 ===\n" ); |
1842 |
|
for(with_flip=0; with_flip<=1; ++with_flip) { |
1843 |
|
for(with_uv=0; with_uv<=1; ++with_uv) { |
1844 |
|
init_cpu(&cpu_list[0]); |
1845 |
|
TEST_YV2(yv12_to_yv12_c, with_uv, with_flip); |
1846 |
|
printf(" yv12_to_yv12_c %.3f usec \tcrc32=0x%08x %s\n", |
1847 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1848 |
|
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
1849 |
|
|
1850 |
|
#if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) |
1851 |
|
init_cpu(&cpu_list[1]); |
1852 |
|
TEST_YV2(yv12_to_yv12_mmx, with_uv, with_flip); |
1853 |
|
printf(" yv12_to_yv12_mmx %.3f usec \tcrc32=0x%08x %s\n", |
1854 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1855 |
|
/* if (!with_uv) PRINT_NxN(Dst0[1], WIDTH/2, HEIGHT/2, WIDTH ); */ |
1856 |
|
|
1857 |
|
TEST_YV2(yv12_to_yv12_xmm, with_uv, with_flip); |
1858 |
|
printf(" yv12_to_yv12_xmm %.3f usec \tcrc32=0x%08x %s\n", |
1859 |
|
t, iCrc, (iCrc!=yv12_CRCs[with_flip][with_uv])?"| ERROR": "" ); |
1860 |
|
#endif |
1861 |
|
} |
1862 |
|
|
1863 |
|
printf( " --- \n" ); |
1864 |
|
} |
1865 |
|
printf( " ===== \n" ); |
1866 |
|
} |
1867 |
|
|
1868 |
#undef WIDTH |
#undef WIDTH |
1869 |
#undef HEIGHT |
#undef HEIGHT |
1870 |
#undef ENTER |
#undef ENTER |
2035 |
printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" ); |
printf( "ERROR! please post your platform/compiler specs to xvid-devel@xvid.org !\n" ); |
2036 |
} |
} |
2037 |
} |
} |
2038 |
|
|
2039 |
/********************************************************************* |
/********************************************************************* |
2040 |
* test SSIM functions |
* test SSIM functions |
2041 |
*********************************************************************/ |
*********************************************************************/ |
2046 |
extern int lum_8x8_c(uint8_t* ptr, int stride); |
extern int lum_8x8_c(uint8_t* ptr, int stride); |
2047 |
extern int lum_8x8_mmx(uint8_t* ptr, int stride); |
extern int lum_8x8_mmx(uint8_t* ptr, int stride); |
2048 |
extern int lum_2x8_c(uint8_t* ptr, int stride); |
extern int lum_2x8_c(uint8_t* ptr, int stride); |
2049 |
extern void iconsim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2050 |
extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_mmx(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2051 |
extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
extern void consim_sse2(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr); |
2052 |
|
|
2084 |
continue; |
continue; |
2085 |
lum8x8 = lum_8x8_c; |
lum8x8 = lum_8x8_c; |
2086 |
lum2x8 = lum_2x8_c; |
lum2x8 = lum_2x8_c; |
2087 |
csim = iconsim_c; |
csim = consim_c; |
2088 |
|
#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; |
2093 |
if (cpu->cpu & XVID_CPU_MMX){ |
if (cpu->cpu & XVID_CPU_MMX){ |
2094 |
csim = consim_sse2; |
csim = consim_sse2; |
2095 |
} |
} |
2096 |
|
#endif |
2097 |
t = gettime_usec(); |
t = gettime_usec(); |
2098 |
emms(); |
emms(); |
2099 |
for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16); |
for(tst=0; tst<nb_tests; ++tst) m = lum8x8(Ref1, 16); |
2105 |
|
|
2106 |
t = gettime_usec(); |
t = gettime_usec(); |
2107 |
emms(); |
emms(); |
2108 |
for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1, 16); |
for(tst=0; tst<nb_tests; ++tst) m = lum2x8(Ref1+8, 16); |
2109 |
emms(); |
emms(); |
2110 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |
2111 |
printf("%s - ssim-lum2x8 %.3f usec m=%d %s\n", |
printf("%s - ssim-lum2x8 %.3f usec m=%d %s\n", |
2112 |
cpu->name, t, m, |
cpu->name, t, m, |
2113 |
(m!=-841)?"| ERROR": "" ); |
(m!=681)?"| ERROR": "" ); |
2114 |
|
|
2115 |
t = gettime_usec(); |
t = gettime_usec(); |
2116 |
emms(); |
emms(); |
2117 |
for(tst=0; tst<nb_tests; ++tst) csim(Ref1, Ref2, 16, lumo, lumc, devs+0, devs+1, devs+2); |
for(tst=0; tst<nb_tests; ++tst) csim(Ref1, Ref2, 16, lumo, lumc, devs+0, devs+1, devs+2); |
2118 |
emms(); |
emms(); |
2119 |
t = (gettime_usec() - t) / nb_tests; |
t = (gettime_usec() - t) / nb_tests; |
2120 |
printf("%s - ssim-lum2x8 %.3f usec devs=[0x%x 0x%x 0x%x] %s\n", |
printf("%s - ssim-consim %.3f usec devs=[0x%x 0x%x 0x%x] %s\n", |
2121 |
cpu->name, t, devs[0], devs[1], devs[2], |
cpu->name, t, devs[0], devs[1], devs[2], |
2122 |
(devs[0]!=0xeba80 || devs[1]!=0x1053e7 || devs[2]!=0x51215)?"| ERROR": "" ); |
(devs[0]!=0x1bdf0f || devs[1]!=0x137258 || devs[2]!=0xcdb13)?"| ERROR": "" ); |
|
|
|
2123 |
printf( " --- \n" ); |
printf( " --- \n" ); |
2124 |
} |
} |
2125 |
} |
} |
2126 |
|
|
2127 |
/********************************************************************* |
/********************************************************************* |
2128 |
|
* test bitstream functions |
2129 |
|
*********************************************************************/ |
2130 |
|
|
2131 |
|
#define BIT_BUF_SIZE 2000 |
2132 |
|
|
2133 |
|
static void test_bits() |
2134 |
|
{ |
2135 |
|
const int nb_tests = 50*speed_ref; |
2136 |
|
int tst; |
2137 |
|
uint32_t Crc; |
2138 |
|
uint8_t Buf[BIT_BUF_SIZE]; |
2139 |
|
uint32_t Extracted[BIT_BUF_SIZE*8]; /* worst case: bits read 1 by 1 */ |
2140 |
|
int Lens[BIT_BUF_SIZE*8]; |
2141 |
|
double t1; |
2142 |
|
|
2143 |
|
|
2144 |
|
printf( "\n === test bitstream ===\n" ); |
2145 |
|
ieee_reseed(1); |
2146 |
|
Crc = 0; |
2147 |
|
|
2148 |
|
t1 = gettime_usec(); |
2149 |
|
for(tst=0; tst<nb_tests; ++tst) { |
2150 |
|
Bitstream bs; |
2151 |
|
int m, m2, l, l2; |
2152 |
|
|
2153 |
|
for(l=0; l<BIT_BUF_SIZE; ++l) |
2154 |
|
Buf[l] = (uint8_t)ieee_rand(0,255); |
2155 |
|
|
2156 |
|
l = BIT_BUF_SIZE - ieee_rand(1,BIT_BUF_SIZE/10); |
2157 |
|
BitstreamInit(&bs, (void*)(Buf+BIT_BUF_SIZE-l), l); |
2158 |
|
|
2159 |
|
|
2160 |
|
BitstreamReset(&bs); |
2161 |
|
for(l2=l*8, m=0; l2>0; m++) { |
2162 |
|
const int b = ieee_rand(1,32); |
2163 |
|
Lens[m] = b; |
2164 |
|
l2 -= b; |
2165 |
|
if (l2<0) break; |
2166 |
|
Extracted[m] = BitstreamShowBits(&bs, b); |
2167 |
|
BitstreamSkip(&bs, b); |
2168 |
|
// printf( "<= %d: %d 0x%x\n", m, b, Extracted[m]); |
2169 |
|
} |
2170 |
|
|
2171 |
|
BitstreamReset(&bs); |
2172 |
|
for(m2=0; m2<m; ++m2) { |
2173 |
|
const int b = Lens[m2]; |
2174 |
|
const uint32_t v = BitstreamGetBits(&bs, b); |
2175 |
|
Crc |= (v!=Extracted[m2]); |
2176 |
|
// printf( "=> %d: %d 0x%x %c\n", m2, b, v, " *"[Crc]); |
2177 |
|
} |
2178 |
|
} |
2179 |
|
t1 = (gettime_usec() - t1) / nb_tests; |
2180 |
|
printf(" test_bits %.3f usec %s\n", t1, (Crc!=0)?"| ERROR": "" ); |
2181 |
|
} |
2182 |
|
|
2183 |
|
/********************************************************************* |
2184 |
* main |
* main |
2185 |
*********************************************************************/ |
*********************************************************************/ |
2186 |
|
|
2205 |
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; |
2206 |
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; |
2207 |
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; |
2208 |
|
else if (!strcmp(argv[c], "-sse3")) cpu_mask = XVID_CPU_SSE3 | XVID_CPU_SSE2 | XVID_CPU_MMXEXT | XVID_CPU_MMX | XVID_CPU_FORCE; |
2209 |
|
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; |
2210 |
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; |
2211 |
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; |
2212 |
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; |
2253 |
if (what==0 || what==13) test_compiler(); |
if (what==0 || what==13) test_compiler(); |
2254 |
if (what==0 || what==14) test_yuv(); |
if (what==0 || what==14) test_yuv(); |
2255 |
if (what==0 || what==15) test_SSIM(); |
if (what==0 || what==15) test_SSIM(); |
2256 |
|
if (what==0 || what==16) test_yuv2(); |
2257 |
|
if (what==0 || what==17) test_bits(); |
2258 |
|
|
2259 |
if (what==7) { |
if (what==7) { |
2260 |
test_IEEE1180_compliance(-256, 255, 1); |
test_IEEE1180_compliance(-256, 255, 1); |
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" |