#include #include #include #include "idc.h" void usage(void); /******************************************************************************* *NOTICE: * *This code is believed by the author to be bug free. You are free to use and * *modify this code with the understanding that any use, either direct or * *derivative, must contain acknowledgement of its author and source. The author* *makes no warranty of any kind, expressed or implied, of merchantability or * *fitness for a particular purpose. The author shall not be held liable for any* *incidental or consequential damages in connection with or arising out of the * *furnishing, performance, or use of this software. This software is not * *authorized for use in life support devices or systems. * ********************************************************************************/ main(int argc, char *argv[]) { float mean, var, secmom, ave, std; float residual, sig, qerr, msqe, snr, sper; float reconstruction, output,resrec,prob[256], entropy; int numlev,numbits,label, ent_flag, end_flag, name_length; char infile[100], outfile[100], qfile[100], pfile[100]; float *bound, *recon, *pred, *xf, prediction, scale; int i, j, k, num, order, flag, size; int c; extern int optind; extern char *optarg; FILE *ofp,*qfp, *pfp; short *aufile; order = -1; numlev = -1; ent_flag = 0; ofp = stdout; scale = 1.0; strcpy(outfile,"standard out"); qfp = NULL; pfp = NULL; while((c=getopt(argc,argv,"i:o:q:p:s:eh"))!=EOF) { switch (c){ case 'i': strcpy(infile,optarg); break; case 'o': strcpy(outfile,optarg); if((ofp=fopen(outfile,"wb")) == NULL) { fprintf(stderr,"Unable to open file %s for write\n",outfile); exit(1); } break; case 'q': strcpy(qfile,optarg); if((qfp=fopen(qfile,"r")) == NULL) { fprintf(stderr,"Unable to open file %s for reading quantizer parameters\n",qfile); exit(2); } break; case 'p': strcpy(pfile,optarg); if((pfp=fopen(pfile,"r")) == NULL) { fprintf(stderr,"Unable to open file %s for reading predictor parameters\n",qfile); exit(3); } break; case 's': sscanf(optarg,"%f",&scale); break; case 'e': ent_flag++; break; case 'h': usage(); exit(4); break; } } if(qfp == NULL) { fprintf(stderr,"You need to enter the filename containing the quantizer\n"); fprintf(stderr,"parameters for this program to work. Please do so now.\n"); scanf("%s",&qfile); if((qfp=fopen(qfile,"r")) == NULL) { fprintf(stderr,"Unable to open file %s for reading quantizer parameters\n",qfile); exit(4); } } /* write quantizer file name to output file */ name_length = strlen(qfile); fwrite(&name_length,1,sizeof(int),ofp); fwrite(qfile,name_length+1,sizeof(char),ofp); fscanf(qfp,"%d",&numlev); fprintf(stderr," Number of levels: %d\n",numlev); bound = (float *) calloc((numlev+1),sizeof(float)); recon = (float *) calloc((numlev+1),sizeof(float)); for(i=0;i