// Tarkin 'fixed' demo code // // Sample fixed-length encoding top layer. Limited to 1 block of 32 // frames. A lot of work will need to be done here in order to make // a nice, tidy interface that'll convert .avi's, .mov's or whatever // else... for the time being, it only converts a series of 32 .pgm // files named "0.pgm" "1.pgm" .. "31.pgm". // // Usage: tarkin [percentage] (where percentage is % of DWT vectors to retain) // // $Id: tarkin.c,v 1.1 2001/02/13 01:06:24 giles Exp $ // // $Log: tarkin.c,v $ // Revision 1.1 2001/02/13 01:06:24 giles // Initial revision // #include "tarkin.h" // Global Definitions #define FRAMES 32 // Global Variables tarkindata td; // Function declarations int sortfunc(const unsigned int *a, const unsigned int *b); void dieusage(); int main(int argc, char **argv) { uint *sortarr; int a, d, x, y, z; float percent; unsigned char ln[256], *data; FILE *fi; oggpack_buffer o; ulong bytes, dims[3]; // Future home of options processing here if(argc<2) dieusage(); if(!(percent = (float)atof(argv[1]))) dieusage(); // For this code, we're using .pgms. Take the image dimensions from the first // frame and set up the tarkindata struct, then grab image data to populate the // workspace. if(!(fi = fopen("0.pgm", "r"))) { perror("Can't open file 0.pgm"); exit(1); } for(a=0;a<3;a++) { fgets(ln, 255, fi); if(*ln == '#') a--; else { if(!a && strncmp("P5", ln, 2)) { fprintf(stderr, "Error: Need PGM file for input\n"); exit(0); } if(a==1) { ln[20] = 0; sscanf(ln, "%ld %ld", &(td.x_dim), &(td.y_dim)); } } } td.z_dim = FRAMES; for(a=0,d=1;d