#include #include #include #include #include "dct.h" #define USE_INTMETHOD #define TIMING_ //#define NEWDCT void print_mat(short *data,int width) { for(int i=0; i < 8; i++) printf("%hd %hd %hd %hd %hd %hd %hd %hd\n", data[i*width], data[i*width+1], data[i*width+2], data[i*width+3], data[i*width+4], data[i*width+5], data[i*width+6], data[i*width+7]); } int main(void) { struct timeval tvstart, tvend; short *data = new short[4096]; #ifdef NEWDCT int width = 8; #else int width = 352; #endif for(int i=0; i < 8; i++) for(int j=0; j < 8; j++) { data[i*width+j] = short((rand() >> 22) - 256); } printf("width = %d\n", width); print_mat(data,width); // 2376 is number of blocks per frame // 71280 is number of blocks per 30 frames #ifdef TIMING_ gettimeofday(&tvstart, 0); for(int i=0; i < 71280; i++) { #ifdef NEWDCT shortdct(data); qnt(data,1,1); #else dct(data, width); qnt(data, 8,1,1); #endif } gettimeofday(&tvend, 0); printf("time taken = %f seconds\n", float(tvend.tv_sec-tvstart.tv_sec) + 1.0E-6 * float(tvend.tv_usec - tvstart.tv_usec)); #else #ifdef NEWDCT shortdct(data); // qnt(data,1,1); #else dct(data,width); // qnt(data,8, 1, 1); #endif print_mat(data, width); #ifdef NEWDCT // iqnt(data,1,1); idct(data); #else // iqnt(data,8,1,1); idct(data,width); #endif print_mat(data, width); #endif }