📄 dctstub.c
字号:
//;***************************************************************************/
//;*
//;* Copyright (c) 1998 Intel Corporation.
//;* All rights reserved.
//;*
//;***************************************************************************/
//
//
//* dctstub.c
#include <stdio.h>
#include <math.h>
#include "emul.h"
extern void fct8x8_float(short* src_array, double *dst_array);
extern void dct8x8aan_xmm_accurate(short* src_array, short *dst_array);
extern void dct8x8aan_xmm(short* src_array, short *dst_array);
extern void dct8x8aan_mmx(short* src_array, short *dst_array);
extern void init_fdct(void);
extern void init_aan(void);
extern void postscale_transpose(short *v);
extern void transpose(short *v);
// Set N to the # of tests to be run
#define N 50000
short input_mmx[64];
short output_mmx[64];
short input_xmm[64];
short output_xmm[64];
short input_xmm_acc[64];
short output_xmm_acc[64];
short n[64];
short dctcoeffshort[64];
double dctcoeffdouble[64];
int index_mmx,index_xmm,index_xmm_acc;
main()
{
int j;
int error_mmx,error_xmm,error_xmm_acc;
int cnt_mmx[5]={0,0,0,0,0};
int cnt_xmm[5]={0,0,0,0,0};
int cnt_xmm_acc[5]={0,0,0,0,0};
int max_error_mmx=0,max_error_xmm=0,max_error_xmm_acc=0;
int failed_mmx=0,failed_xmm=0,failed_xmm_acc=0;
int iter;
FILE *out = fopen("ieee.out","a");
if( out==NULL )
out=stdout;
fprintf(out,"\n");
printf("Starting..\n");
init_fdct();
init_aan();
for(iter=0; iter<N; iter++)
{
// start with random 8x8 matrix in the color domain (+- 8bit)
random(n, 256, 256);
// Do fdct by IEEE standart.
fct8x8_float(n, dctcoeffdouble);
// Clip the fp result into 12bit integer.
// 'dctcoeffshort' is the referece we start from to compare MMX(tm) Technology code and calar code
// implementations vs. IEEE requirements
roundclip12bitd_s(dctcoeffdouble, dctcoeffshort);
for(j=0; j<64; j++)
input_mmx[j] = input_xmm[j] = input_xmm_acc[j] = n[j]; //duplicate n for different algorithms
// fdct - Streaming SIMD Extensions accurate version.
dct8x8aan_xmm_accurate(input_xmm_acc,output_xmm_acc);
// fdct - Streaming SIMD Extensions less accurate, but faster version.
dct8x8aan_xmm(input_xmm,output_xmm);
// fdct - MMX(tm) Technology version.
dct8x8aan_mmx(input_mmx,output_mmx);
_asm{ //issue emms
_emit 0fh
_emit 77h
}
//post scale and transpose, this can be part of the quantizer
postscale_transpose(output_mmx);
postscale_transpose(output_xmm);
postscale_transpose(output_xmm_acc);
// compare the 8 bit pixels of the MMX(tm) Technology code result and the IEEE reference result
for(j=0; j<64; j++){
error_mmx=abs (*(dctcoeffshort+j)-output_mmx[j]);
error_xmm=abs (*(dctcoeffshort+j)-output_xmm[j]);
error_xmm_acc=abs (*(dctcoeffshort+j)-output_xmm_acc[j]);
cnt_mmx[error_mmx]++;
cnt_xmm[error_xmm]++;
cnt_xmm_acc[error_xmm_acc]++;
if(error_mmx>max_error_mmx) {
max_error_mmx=error_mmx;
if (error_mmx>4) {
index_mmx = j;
fprintf(out,"DCTAAN_MMX(asm) failed: ppe (peak pixel error) =%d at idx=%d iter=%d\n",error_mmx,j,iter);
failed_mmx=1;
}
}
if(error_xmm>max_error_xmm) {
max_error_xmm=error_xmm;
if (error_xmm>4) {
index_xmm = j;
fprintf(out,"DCTAAN_XMM(asm) failed: ppe (peak pixel error) =%d at idx=%d iter=%d\n",error_xmm,j,iter);
failed_xmm=1;
}
}
if(error_xmm_acc>max_error_xmm_acc) {
max_error_xmm_acc=error_xmm_acc;
if (error_xmm_acc>2) {
index_xmm_acc = j;
fprintf(out,"DCTAAN_XMM_ACC(asm) failed: ppe (peak pixel error) =%d at idx=%d iter=%d\n",error_xmm_acc,j,iter);
failed_xmm_acc=1;
}
}
}
fprintf(stdout,"%d ",iter);
}
fprintf(stdout,"\n");
if (failed_mmx)
fprintf(stdout,"DCT MMX(tm) Technology failed: max_error is: %d at coeff %d\n",max_error_mmx,index_mmx);
else
fprintf(stdout,"DCT MMX(tm) Technology passed\n");
if (failed_xmm)
fprintf(stdout,"DCT Streaming SIMD Extensions failed: max_error is: %d at coeff %d\n",max_error_xmm,index_xmm);
else
fprintf(stdout,"DCT Streaming SIMD Extensions passed\n");
if (failed_xmm_acc)
fprintf(stdout,"DCT Streaming SIMD Extensions ACC failed: max_error is: %d at coeff %d\n",max_error_xmm_acc,index_xmm_acc);
else
fprintf(stdout,"DCT Streaming SIMD Extensions ACC passed\n");
fprintf(out,"\nSTATISTICAL ERROR DISTRIBUTAION\n");
fprintf(out,"MMX(tm) Technology : 0:%d 1:%d 2:%d 3:%d 4:%d\n",cnt_mmx[0],cnt_mmx[1],cnt_mmx[2],cnt_mmx[3],cnt_mmx[4]);
fprintf(out,"Streaming SIMD Extensions : 0:%d 1:%d 2:%d 3:%d 4:%d\n",cnt_xmm[0],cnt_xmm[1],cnt_xmm[2],cnt_xmm[3],cnt_xmm[4]);
fprintf(out,"Streaming SIMD Extensions ACC: 0:%d 1:%d 2:%d 3:%d 4:%d\n",cnt_xmm_acc[0],cnt_xmm_acc[1],cnt_xmm_acc[2],cnt_xmm_acc[3],cnt_xmm_acc[4]);
fclose(out);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -