#include #include "dct.h" #define ENCODE 0 #define DECODE 1 #define MAXROWS 1024 #define MAXCOLS 768 unsigned char Image1[MAXCOLS*3*MAXROWS]; int main(int argc, char *argv[]) { int retval, i; int workspace[DCTSIZE_BLOCK]; int type; int x, y, offset, depth; char *fileIn, *fileOut; FILE *fI, *fO; unsigned char ch, mrgb[3]; /* Just for testing on the PC */ if(argc != 4) { printf("need more arguments"); return 0; } type = atoi(argv[1]); fileIn = argv[2]; fileOut = argv[3]; if (NULL == (fI = fopen(fileIn, "rb"))){ printf("unable to open the file to read from (%s)",fileIn); return 0; } if ((fO = fopen(fileOut,"wb")) == NULL) { printf("unable to open the file to write (%s)",fileOut); return 0; } switch(type) { case ENCODE: fseek(fI, 10L, SEEK_SET); fread(mrgb, 1, 4, fI); offset = mrgb[3]; offset <<= 8; offset += mrgb[2]; offset <<= 8; offset += mrgb[1]; offset <<= 8; offset += mrgb[0]; fseek(fI, 18L, SEEK_SET); fread(mrgb, 1, 4, fI); x = ((int)mrgb[3] << 24) + ((int)mrgb[2] << 16) + ((int)mrgb[1] << 8) + mrgb[0]; fseek(fI, 22L, SEEK_SET); fread(mrgb, 1, 4, fI); y = ((int)mrgb[3] << 24) + ((int)mrgb[2] << 16) + ((int)mrgb[1] << 8) + mrgb[0]; fseek(fI, 28L, SEEK_SET); fread(mrgb, 1, 2, fI); depth = ((int)mrgb[1] << 8) + mrgb[0]; printf("Image Resolution: %d x %d x %i \n", x, y, depth); fseek(fI, offset, SEEK_SET); fread(Image1, sizeof(unsigned char), (x*y*(depth/3)), fI); break; case DECODE: break; } /* End for just for testing on the PC */ retval = 0; type = ENCODE; switch(type) { case ENCODE: // RGB -> YUV // Convert to 8x8 // DCT fdct(workspace); // ZZ // Q // VLC (huffman) break; case DECODE: // VLD (huffman) // IQ // ZZ // IDCT //idct(workspace); // Convert 8x8 to lines // YUV -> RGB break; } return retval; }