112 |
unsigned int cpu; |
unsigned int cpu; |
113 |
} CPU; |
} CPU; |
114 |
|
|
115 |
CPU cpu_list[] = |
CPU cpu_list[] = { |
116 |
{ { "PLAINC", 0 } |
{ "PLAINC ", 0 }, |
117 |
#ifdef ARCH_IS_IA32 |
#ifdef ARCH_IS_IA32 |
118 |
, { "MMX ", XVID_CPU_MMX } |
{ "MMX ", XVID_CPU_MMX }, |
119 |
, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } |
{ "MMXEXT ", XVID_CPU_MMXEXT | XVID_CPU_MMX }, |
120 |
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
{ "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX }, |
121 |
, { "3DNOW ", XVID_CPU_3DNOW } |
{ "3DNOW ", XVID_CPU_3DNOW }, |
122 |
, { "3DNOWE", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT } |
{ "3DNOWE ", XVID_CPU_3DNOW | XVID_CPU_3DNOWEXT }, |
123 |
#endif |
#endif |
124 |
#ifdef ARCH_IS_PPC |
#ifdef ARCH_IS_PPC |
125 |
, { "ALTIVEC", XVID_CPU_ALTIVEC } |
{ "ALTIVEC", XVID_CPU_ALTIVEC }, |
126 |
#endif |
#endif |
127 |
#ifdef ARCH_IS_X86_64 |
#ifdef ARCH_IS_X86_64 |
128 |
, { "X86_64", XVID_CPU_ASM} |
{ "X86_64 ", XVID_CPU_ASM}, |
129 |
#endif |
#endif |
130 |
//, { "IA64 ", XVID_CPU_IA64 } |
#ifdef ARCH_IS_IA64 |
131 |
//, { "TSC ", XVID_CPU_TSC } |
// { "IA64 ", XVID_CPU_IA64 }, |
|
, { 0, 0 } }; |
|
|
|
|
|
CPU cpu_short_list[] = |
|
|
{ { "PLAINC", 0 } |
|
|
#ifdef ARCH_IS_IA32 |
|
|
, { "MMX ", XVID_CPU_MMX } |
|
|
//, { "MMXEXT", XVID_CPU_MMXEXT | XVID_CPU_MMX } |
|
|
#endif |
|
|
//, { "IA64 ", XVID_CPU_IA64 } |
|
|
, { 0, 0 } }; |
|
|
|
|
|
CPU cpu_short_list2[] = |
|
|
{ { "PLAINC", 0 } |
|
|
#ifdef ARCH_IS_IA32 |
|
|
, { "MMX ", XVID_CPU_MMX } |
|
|
, { "SSE2 ", XVID_CPU_SSE2 | XVID_CPU_MMX } |
|
132 |
#endif |
#endif |
133 |
, { 0, 0 } }; |
// { "TSC ", XVID_CPU_TSC }, |
134 |
|
{ 0, 0 } |
135 |
|
}; |
136 |
|
|
137 |
|
|
138 |
int init_cpu(CPU *cpu) |
int init_cpu(CPU *cpu) |
260 |
return crc; |
return crc; |
261 |
} |
} |
262 |
|
|
263 |
|
void byte_swap(uint8_t *mem, int len, int element_size) { |
264 |
|
#ifdef ARCH_IS_BIG_ENDIAN |
265 |
|
int i; |
266 |
|
|
267 |
|
if(element_size == 1) { |
268 |
|
/* No need to swap */ |
269 |
|
} else if(element_size == 2) { |
270 |
|
uint8_t temp[2]; |
271 |
|
|
272 |
|
for(i=0; i < (len/2); i++ ) { |
273 |
|
temp[0] = mem[0]; |
274 |
|
temp[1] = mem[1]; |
275 |
|
mem[0] = temp[1]; |
276 |
|
mem[1] = temp[0]; |
277 |
|
|
278 |
|
mem += 2; |
279 |
|
} |
280 |
|
} else if(element_size == 4) { |
281 |
|
uint8_t temp[4]; |
282 |
|
|
283 |
|
for(i=0; i < (len/4); i++ ) { |
284 |
|
temp[0] = mem[0]; |
285 |
|
temp[1] = mem[1]; |
286 |
|
temp[2] = mem[2]; |
287 |
|
temp[3] = mem[3]; |
288 |
|
mem[0] = temp[3]; |
289 |
|
mem[1] = temp[2]; |
290 |
|
mem[2] = temp[1]; |
291 |
|
mem[3] = temp[0]; |
292 |
|
|
293 |
|
mem += 4; |
294 |
|
} |
295 |
|
} else { |
296 |
|
printf("ERROR: byte_swap unsupported element_size(%u)\n", element_size); |
297 |
|
} |
298 |
|
#endif |
299 |
|
} |
300 |
|
|
301 |
/********************************************************************* |
/********************************************************************* |
302 |
* test DCT |
* test DCT |
303 |
*********************************************************************/ |
*********************************************************************/ |
551 |
} \ |
} \ |
552 |
emms(); \ |
emms(); \ |
553 |
t = (gettime_usec()-t -overhead) / nb_tests;\ |
t = (gettime_usec()-t -overhead) / nb_tests;\ |
554 |
|
byte_swap((uint8_t*)(DST), 8*32*sizeof((DST)[0]), sizeof((DST)[0])); \ |
555 |
s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL) |
s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL) |
556 |
|
|
557 |
#define TEST_TRANSFER(FUNC, DST, SRC) \ |
#define TEST_TRANSFER(FUNC, DST, SRC) \ |
578 |
} \ |
} \ |
579 |
emms(); \ |
emms(); \ |
580 |
t = (gettime_usec()-t -overhead) / nb_tests;\ |
t = (gettime_usec()-t -overhead) / nb_tests;\ |
581 |
|
byte_swap((uint8_t*)(DST), 8*32*sizeof((DST)[0]), sizeof((DST)[0])); \ |
582 |
s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL) |
s = calc_crc((uint8_t*)(DST), 8*32*sizeof((DST)[0]), CRC32_INITIAL) |
583 |
|
|
584 |
#define TEST_TRANSFER2(FUNC, DST, SRC, R1) \ |
#define TEST_TRANSFER2(FUNC, DST, SRC, R1) \ |
668 |
for(q=1; q<=max_Q; ++q) { \ |
for(q=1; q<=max_Q; ++q) { \ |
669 |
for(tst=0; tst<nb_tests; ++tst) \ |
for(tst=0; tst<nb_tests; ++tst) \ |
670 |
(FUNC)((DST), (SRC), q, mpeg_quant_matrices); \ |
(FUNC)((DST), (SRC), q, mpeg_quant_matrices); \ |
671 |
s = calc_crc((uint8_t*)(DST), 64*sizeof(int16_t), s); \ |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
672 |
|
s = calc_crc((uint8_t*)(DST), 64*sizeof((DST)[0]), s); \ |
673 |
} \ |
} \ |
674 |
emms(); \ |
emms(); \ |
675 |
} \ |
} \ |
684 |
for(q=1; q<=max_Q; ++q) { \ |
for(q=1; q<=max_Q; ++q) { \ |
685 |
for(tst=0; tst<nb_tests; ++tst) \ |
for(tst=0; tst<nb_tests; ++tst) \ |
686 |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
(FUNC)((DST), (SRC), q, q, mpeg_quant_matrices); \ |
687 |
s = calc_crc((uint8_t*)(DST), 64*sizeof(int16_t), s); \ |
byte_swap((uint8_t*)(DST), 64*sizeof((DST)[0]), sizeof((DST)[0])); \ |
688 |
|
s = calc_crc((uint8_t*)(DST), 64*sizeof((DST)[0]), s); \ |
689 |
} \ |
} \ |
690 |
emms(); \ |
emms(); \ |
691 |
} \ |
} \ |
905 |
* test non-zero AC counting |
* test non-zero AC counting |
906 |
*********************************************************************/ |
*********************************************************************/ |
907 |
|
|
908 |
#define TEST_CBP(FUNC, SRC) \ |
#define TEST_CBP(FUNC, SRC, NB) \ |
909 |
t = gettime_usec(); \ |
t = gettime_usec(); \ |
910 |
emms(); \ |
emms(); \ |
911 |
for(tst=0; tst<nb_tests; ++tst) { \ |
for(tst=0; tst<NB; ++tst) { \ |
912 |
cbp = (FUNC)((SRC)); \ |
cbp = (FUNC)((SRC)); \ |
913 |
} \ |
} \ |
914 |
emms(); \ |
emms(); \ |
917 |
void test_cbp() |
void test_cbp() |
918 |
{ |
{ |
919 |
const int nb_tests = 10000*speed_ref; |
const int nb_tests = 10000*speed_ref; |
920 |
int i; |
int i, n, m; |
921 |
CPU *cpu; |
CPU *cpu; |
922 |
DECLARE_ALIGNED_MATRIX(Src1, 6, 64, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src1, 6, 64, int16_t, 16); |
923 |
DECLARE_ALIGNED_MATRIX(Src2, 6, 64, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src2, 6, 64, int16_t, 16); |
924 |
DECLARE_ALIGNED_MATRIX(Src3, 6, 64, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src3, 6, 64, int16_t, 16); |
925 |
DECLARE_ALIGNED_MATRIX(Src4, 6, 64, int16_t, 16); |
DECLARE_ALIGNED_MATRIX(Src4, 6, 64, int16_t, 16); |
926 |
|
DECLARE_ALIGNED_MATRIX(Src5, 6, 64, int16_t, 16); |
927 |
|
|
928 |
printf( "\n ===== test cbp =====\n" ); |
printf( "\n ===== test cbp =====\n" ); |
929 |
|
|
932 |
Src2[i] = (i<3*64); /* half-full */ |
Src2[i] = (i<3*64); /* half-full */ |
933 |
Src3[i] = ((i+32)>3*64); |
Src3[i] = ((i+32)>3*64); |
934 |
Src4[i] = (i==(3*64+2) || i==(5*64+9)); |
Src4[i] = (i==(3*64+2) || i==(5*64+9)); |
935 |
|
Src5[i] = ieee_rand(0,1) ? -1 : 1; /* +/- test */ |
936 |
} |
} |
937 |
|
|
938 |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
for(cpu = cpu_list; cpu->name!=0; ++cpu) |
943 |
if (!init_cpu(cpu)) |
if (!init_cpu(cpu)) |
944 |
continue; |
continue; |
945 |
|
|
946 |
TEST_CBP(calc_cbp, Src1); |
TEST_CBP(calc_cbp, Src1, nb_tests); |
947 |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n", |
printf("%s - calc_cbp#1 %.3f usec cbp=0x%02x %s\n", |
948 |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x15)?"| ERROR": ""); |
949 |
TEST_CBP(calc_cbp, Src2); |
TEST_CBP(calc_cbp, Src2, nb_tests); |
950 |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x %s\n", |
printf("%s - calc_cbp#2 %.3f usec cbp=0x%02x %s\n", |
951 |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
cpu->name, t, cbp, (cbp!=0x38)?"| ERROR": ""); |
952 |
TEST_CBP(calc_cbp, Src3); |
TEST_CBP(calc_cbp, Src3, nb_tests); |
953 |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x %s\n", |
printf("%s - calc_cbp#3 %.3f usec cbp=0x%02x %s\n", |
954 |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x0f)?"| ERROR": "" ); |
955 |
TEST_CBP(calc_cbp, Src4); |
TEST_CBP(calc_cbp, Src4, nb_tests); |
956 |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
957 |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
cpu->name, t, cbp, (cbp!=0x05)?"| ERROR": "" ); |
958 |
|
TEST_CBP(calc_cbp, Src5, nb_tests); |
959 |
|
printf("%s - calc_cbp#4 %.3f usec cbp=0x%02x %s\n", |
960 |
|
cpu->name, t, cbp, (cbp!=0x3f)?"| ERROR": "" ); |
961 |
printf( " --- \n" ); |
printf( " --- \n" ); |
962 |
} |
} |
963 |
|
|
964 |
|
for(cpu = cpu_list; cpu->name!=0; ++cpu) /* bench suggested by Carlo (carlo dot bramix at libero dot it) */ |
965 |
|
{ |
966 |
|
double t; |
967 |
|
int tst, cbp, err; |
968 |
|
|
969 |
|
if (!init_cpu(cpu)) |
970 |
|
continue; |
971 |
|
|
972 |
|
err = 0; |
973 |
|
for(n=0; n<6; ++n) |
974 |
|
{ |
975 |
|
for(m=0; m<64; ++m) |
976 |
|
{ |
977 |
|
for(i=0; i<6*64; ++i) |
978 |
|
Src1[i] = (i== (m + n*64)); |
979 |
|
|
980 |
|
TEST_CBP(calc_cbp, Src1, 1); |
981 |
|
if (cbp!= (((m!=0)<<(5-n)))) |
982 |
|
{ |
983 |
|
printf( "%s - calc_cbp#5: ERROR at pos %d / %d!\n", cpu->name, n, m); |
984 |
|
err = 1; |
985 |
|
break; |
986 |
|
} |
987 |
|
} |
988 |
|
} |
989 |
|
if (!err) |
990 |
|
printf( " %s - calc_cbp#5 : OK\n", cpu->name ); |
991 |
|
|
992 |
|
} |
993 |
} |
} |
994 |
|
|
995 |
/********************************************************************* |
/********************************************************************* |
1452 |
xframe.bitstream = buf + pos; |
xframe.bitstream = buf + pos; |
1453 |
xframe.length = buf_size - pos; |
xframe.length = buf_size - pos; |
1454 |
xframe.output.plane[0] = (uint8_t*)(((size_t)yuv_out + 15) & ~15); |
xframe.output.plane[0] = (uint8_t*)(((size_t)yuv_out + 15) & ~15); |
1455 |
xframe.output.plane[1] = xframe.output.plane[0] + bps*height; |
xframe.output.plane[1] = (uint8_t*)xframe.output.plane[0] + bps*height; |
1456 |
xframe.output.plane[2] = xframe.output.plane[1] + bps/2; |
xframe.output.plane[2] = (uint8_t*)xframe.output.plane[1] + bps/2; |
1457 |
xframe.output.stride[0] = bps; |
xframe.output.stride[0] = bps; |
1458 |
xframe.output.stride[1] = bps; |
xframe.output.stride[1] = bps; |
1459 |
xframe.output.stride[2] = bps; |
xframe.output.stride[2] = bps; |
1471 |
nb++; |
nb++; |
1472 |
|
|
1473 |
for(y=0; y<height/2; ++y) { |
for(y=0; y<height/2; ++y) { |
1474 |
chksum = calc_crc(xframe.output.plane[0] + (2*y+0)*bps, width, chksum); |
chksum = calc_crc((uint8_t*)xframe.output.plane[0] + (2*y+0)*bps, width, chksum); |
1475 |
chksum = calc_crc(xframe.output.plane[0] + (2*y+1)*bps, width, chksum); |
chksum = calc_crc((uint8_t*)xframe.output.plane[0] + (2*y+1)*bps, width, chksum); |
1476 |
chksum = calc_crc(xframe.output.plane[1] + y*bps, width/2, chksum); |
chksum = calc_crc((uint8_t*)xframe.output.plane[1] + y*bps, width/2, chksum); |
1477 |
chksum = calc_crc(xframe.output.plane[2] + y*bps, width/2, chksum); |
chksum = calc_crc((uint8_t*)xframe.output.plane[2] + y*bps, width/2, chksum); |
1478 |
} |
} |
1479 |
if (pos==buf_size) |
if (pos==buf_size) |
1480 |
break; |
break; |