35 |
|
|
36 |
#include <stdio.h> |
#include <stdio.h> |
37 |
#include <stdlib.h> |
#include <stdlib.h> |
38 |
#include <string.h> // for memset |
#include <string.h> /* for memset */ |
39 |
#include <assert.h> |
#include <assert.h> |
40 |
|
|
41 |
#ifndef WIN32 |
#ifndef WIN32 |
42 |
#include <sys/time.h> // for gettimeofday |
#include <sys/time.h> /* for gettimeofday */ |
43 |
#else |
#else |
44 |
#include <time.h> |
#include <time.h> |
45 |
#endif |
#endif |
67 |
#define M_PI 3.14159265358979323846 |
#define M_PI 3.14159265358979323846 |
68 |
#endif |
#endif |
69 |
|
|
70 |
const int speed_ref = 100; // on slow machines, decrease this value |
const int speed_ref = 100; /* on slow machines, decrease this value */ |
71 |
|
|
72 |
/********************************************************************* |
/********************************************************************* |
73 |
* misc |
* misc |
144 |
|
|
145 |
cpu_type = check_cpu_features() & cpu->cpu; |
cpu_type = check_cpu_features() & cpu->cpu; |
146 |
xinit.cpu_flags = cpu_type | XVID_CPU_FORCE; |
xinit.cpu_flags = cpu_type | XVID_CPU_FORCE; |
147 |
// xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; |
/* xinit.cpu_flags = XVID_CPU_MMX | XVID_CPU_FORCE; */ |
148 |
xerr = xvid_init(NULL, 0, &xinit, NULL); |
xerr = xvid_init(NULL, 0, &xinit, NULL); |
149 |
if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) { |
if (cpu->cpu>0 && (cpu_type==0 || xerr!=XVID_ERR_OK)) { |
150 |
printf( "%s - skipped...\n", cpu->name ); |
printf( "%s - skipped...\n", cpu->name ); |
302 |
const int nb_tests = 2000*speed_ref; |
const int nb_tests = 2000*speed_ref; |
303 |
CPU *cpu; |
CPU *cpu; |
304 |
const uint8_t Src0[16*9] = { |
const uint8_t Src0[16*9] = { |
305 |
// try to have every possible combinaison of rounding... |
/* try to have every possible combinaison of rounding... */ |
306 |
0, 0, 1, 0, 2, 0, 3, 0, 4 ,0,0,0, 0,0,0,0 |
0, 0, 1, 0, 2, 0, 3, 0, 4 ,0,0,0, 0,0,0,0 |
307 |
, 0, 1, 1, 1, 2, 1, 3, 1, 3 ,0,0,0, 0,0,0,0 |
, 0, 1, 1, 1, 2, 1, 3, 1, 3 ,0,0,0, 0,0,0,0 |
308 |
, 0, 2, 1, 2, 2, 2, 3, 2, 2 ,0,0,0, 0,0,0,0 |
, 0, 2, 1, 2, 2, 2, 3, 2, 2 ,0,0,0, 0,0,0,0 |
352 |
if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" ); |
if (iCrc!=8103) printf( "*** CRC ERROR! ***\n" ); |
353 |
|
|
354 |
|
|
355 |
// this is a new function, as of 06.06.2002 |
/* this is a new function, as of 06.06.2002 */ |
356 |
#if 0 |
#if 0 |
357 |
TEST_MB2(interpolate8x8_avrg); |
TEST_MB2(interpolate8x8_avrg); |
358 |
printf( "%s - interpolate8x8_c %.3f usec iCrc=%d\n", cpu->name, t, iCrc ); |
printf( "%s - interpolate8x8_c %.3f usec iCrc=%d\n", cpu->name, t, iCrc ); |
528 |
|
|
529 |
printf( "\n ===== test quant =====\n" ); |
printf( "\n ===== test quant =====\n" ); |
530 |
|
|
531 |
// we deliberately enfringe the norm's specified range [-127,127], |
/* we deliberately enfringe the norm's specified range [-127,127], */ |
532 |
// to test the robustness of the iquant module |
/* to test the robustness of the iquant module */ |
533 |
for(i=0; i<64; ++i) { |
for(i=0; i<64; ++i) { |
534 |
Src[i] = 1 + (i-32) * (i&6); |
Src[i] = 1 + (i-32) * (i&6); |
535 |
Dst[i] = 0; |
Dst[i] = 0; |
616 |
printf( "\n ===== test cbp =====\n" ); |
printf( "\n ===== test cbp =====\n" ); |
617 |
|
|
618 |
for(i=0; i<6*64; ++i) { |
for(i=0; i<6*64; ++i) { |
619 |
Src1[i] = (i*i*3/8192)&(i/64)&1; // 'random' |
Src1[i] = (i*i*3/8192)&(i/64)&1; /* 'random' */ |
620 |
Src2[i] = (i<3*64); // half-full |
Src2[i] = (i<3*64); /* half-full */ |
621 |
Src3[i] = ((i+32)>3*64); |
Src3[i] = ((i+32)>3*64); |
622 |
Src4[i] = (i==(3*64+2) || i==(5*64+9)); |
Src4[i] = (i==(3*64+2) || i==(5*64+9)); |
623 |
} |
} |
772 |
} |
} |
773 |
} |
} |
774 |
|
|
775 |
////////////////////////////////////////////////////////// |
///* ////////////////////////////////////////////////////// */ |
776 |
/* Pseudo-random generator specified by IEEE 1180 */ |
/* Pseudo-random generator specified by IEEE 1180 */ |
777 |
|
|
778 |
static long ieee_seed = 1; |
static long ieee_seed = 1; |
859 |
static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 }; |
static const double ILimits[5] = { 1., 0.06, 0.02, 0.015, 0.0015 }; |
860 |
int Loops = 10000; |
int Loops = 10000; |
861 |
int i, m, n; |
int i, m, n; |
862 |
short Blk0[64]; // reference |
short Blk0[64]; /* reference */ |
863 |
short Blk[64], iBlk[64]; |
short Blk[64], iBlk[64]; |
864 |
short Ref_FDCT[64]; |
short Ref_FDCT[64]; |
865 |
short Ref_IDCT[64]; |
short Ref_IDCT[64]; |
866 |
|
|
867 |
STATS_8x8 FStats; // forward dct stats |
STATS_8x8 FStats; /* forward dct stats */ |
868 |
STATS_8x8 IStats; // inverse dct stats |
STATS_8x8 IStats; /* inverse dct stats */ |
869 |
|
|
870 |
CPU *cpu; |
CPU *cpu; |
871 |
|
|
888 |
for(i=0; i<64; ++i) |
for(i=0; i<64; ++i) |
889 |
Blk0[i] = (short)ieee_rand(Min,Max) * Sign; |
Blk0[i] = (short)ieee_rand(Min,Max) * Sign; |
890 |
|
|
891 |
// hmm, I'm not quite sure this is exactly |
/* hmm, I'm not quite sure this is exactly */ |
892 |
// the tests described in the norm. check... |
/* the tests described in the norm. check... */ |
893 |
|
|
894 |
memcpy(Ref_FDCT, Blk0, 64*sizeof(short)); |
memcpy(Ref_FDCT, Blk0, 64*sizeof(short)); |
895 |
ref_fdct(Ref_FDCT); |
ref_fdct(Ref_FDCT); |
916 |
|
|
917 |
printf( "\n -- FDCT report --\n" ); |
printf( "\n -- FDCT report --\n" ); |
918 |
// print_stats(&FStats); |
// print_stats(&FStats); |
919 |
report_stats(&FStats, 0); // so far I know, IEEE1180 says nothing for fdct |
report_stats(&FStats, 0); /* so far I know, IEEE1180 says nothing for fdct */ |
920 |
|
|
921 |
for(i=0; i<64; i++) Blk[i] = 0; |
for(i=0; i<64; i++) Blk[i] = 0; |
922 |
emms(); fdct(Blk); emms(); |
emms(); fdct(Blk); emms(); |
938 |
|
|
939 |
void test_dct_saturation(int Min, int Max) |
void test_dct_saturation(int Min, int Max) |
940 |
{ |
{ |
941 |
// test behaviour on input range fringe |
/* test behaviour on input range fringe */ |
942 |
|
|
943 |
int i, n, p; |
int i, n, p; |
944 |
CPU *cpu; |
CPU *cpu; |
945 |
// const short IDCT_MAX = 2047; // 12bits input |
// const short IDCT_MAX = 2047; /* 12bits input */ |
946 |
// const short IDCT_MIN = -2048; |
// const short IDCT_MIN = -2048; |
947 |
// const short IDCT_OUT = 256; // 9bits ouput |
// const short IDCT_OUT = 256; /* 9bits ouput */ |
948 |
const int Partitions = 4; |
const int Partitions = 4; |
949 |
const int Loops = 10000 / Partitions; |
const int Loops = 10000 / Partitions; |
950 |
|
|
961 |
printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n", |
printf( "\n===== IEEE test for %s Min=%d Max=%d =====\n", |
962 |
cpu->name, Min, Max ); |
cpu->name, Min, Max ); |
963 |
|
|
964 |
// FDCT tests // |
/* FDCT tests // */ |
965 |
|
|
966 |
init_stats(&Stats); |
init_stats(&Stats); |
967 |
|
|
968 |
// test each computation channels separately |
/* test each computation channels separately */ |
969 |
for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0; |
for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? Max : 0; |
970 |
ref_fdct(Blk0); |
ref_fdct(Blk0); |
971 |
emms(); fdct(Blk); emms(); |
emms(); fdct(Blk); emms(); |
976 |
emms(); fdct(Blk); emms(); |
emms(); fdct(Blk); emms(); |
977 |
store_stats(&Stats, Blk, Blk0); |
store_stats(&Stats, Blk, Blk0); |
978 |
|
|
979 |
// randomly saturated inputs |
/* randomly saturated inputs */ |
980 |
for(p=0; p<Partitions; ++p) |
for(p=0; p<Partitions; ++p) |
981 |
{ |
{ |
982 |
for(n=0; n<Loops; ++n) |
for(n=0; n<Loops; ++n) |
992 |
report_stats(&Stats, 0); |
report_stats(&Stats, 0); |
993 |
|
|
994 |
|
|
995 |
// IDCT tests // |
/* IDCT tests // */ |
996 |
#if 0 |
#if 0 |
997 |
// no finished yet |
/* no finished yet */ |
998 |
|
|
999 |
init_stats(&Stats); |
init_stats(&Stats); |
1000 |
|
|
1001 |
// test each computation channel separately |
/* test each computation channel separately */ |
1002 |
for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0; |
for(i=0; i<64; i++) Blk[i] = Blk0[i] = ((i/8)==(i%8)) ? IDCT_MAX : 0; |
1003 |
ref_idct(Blk0); |
ref_idct(Blk0); |
1004 |
emms(); idct(Blk); emms(); |
emms(); idct(Blk); emms(); |
1011 |
for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); } |
for(i=0; i<64; i++) { CLAMP(Blk0[i], IDCT_OUT); CLAMP(Blk[i], IDCT_OUT); } |
1012 |
store_stats(&Stats, Blk, Blk0); |
store_stats(&Stats, Blk, Blk0); |
1013 |
|
|
1014 |
// randomly saturated inputs |
/* randomly saturated inputs */ |
1015 |
for(p=0; p<Partitions; ++p) |
for(p=0; p<Partitions; ++p) |
1016 |
{ |
{ |
1017 |
for(n=0; n<Loops; ++n) |
for(n=0; n<Loops; ++n) |
1080 |
} |
} |
1081 |
else printf( "Input size: %d\n", buf_size); |
else printf( "Input size: %d\n", buf_size); |
1082 |
|
|
1083 |
buf = malloc(buf_size); // should be enuf' |
buf = malloc(buf_size); /* should be enuf' */ |
1084 |
rgb_out = calloc(4, width*height); // <-room for _RGB24 |
rgb_out = calloc(4, width*height); /* <-room for _RGB24 */ |
1085 |
if (buf==0 || rgb_out==0) { |
if (buf==0 || rgb_out==0) { |
1086 |
printf( "malloc failed!\n" ); |
printf( "malloc failed!\n" ); |
1087 |
goto End; |
goto End; |