Annotation of researchv10no/cmd/view2d/viewtd.c, revision 1.1

1.1     ! root        1: /*  convert from view2d to td format  */
        !             2: 
        !             3: #include <stdio.h>
        !             4: #include "view2d.h"
        !             5: char *progname;
        !             6: 
        !             7: short timewarp;
        !             8: double ts, te;
        !             9: extern Rd2d rd;
        !            10: int verbose;
        !            11: 
        !            12: typedef struct Frame {
        !            13:   double time;
        !            14:   short *p;
        !            15: } Frame;
        !            16: Frame frame;
        !            17: Frame *here;
        !            18: 
        !            19: short nx, ny;  /* input grid */
        !            20: 
        !            21: main(argc, argv)
        !            22:   int argc;
        !            23:   char **argv;
        !            24: {
        !            25:   int i, j;
        !            26:   int fd;
        !            27:   char *Malloc();
        !            28: 
        !            29:   timewarp = 0;
        !            30:   verbose = 0;
        !            31:   progname = argv[0];
        !            32:   here = &frame;
        !            33: 
        !            34:   for(argc--, argv++; *argv; argv++){
        !            35:     if(**argv == '-' ){
        !            36:       switch(argv[0][1]) {
        !            37:       case 'v':
        !            38:         verbose++;
        !            39:         break;
        !            40:       }
        !            41:     }else{
        !            42:       if(fd) error("can only read one file");
        !            43:       fd = Open(*argv,0);
        !            44:     }
        !            45:   }
        !            46: 
        !            47:   rd2dh(fd,&nx,&ny);
        !            48:   if((timewarp>0)&&(verbose))
        !            49:      fprintf(stderr,"timewarp=%d ts=%g te=%g\n",timewarp,ts,te);
        !            50:   if( nx != ny ) error("picture must be square");
        !            51:   i = nx*ny*sizeof(short);
        !            52:   here->p = (short *)Malloc(i);
        !            53: 
        !            54:   rd2di(&here->time,here->p);
        !            55:   wrframe(here->time,here->p);
        !            56: 
        !            57:   exit(0);
        !            58: }
        !            59: 
        !            60: 
        !            61: wrframe(t,p)
        !            62:   double t;
        !            63:   short *p;
        !            64: {
        !            65:   float *b;
        !            66:   short r;
        !            67:   int i,j,s;
        !            68:   char *malloc();
        !            69:   s = nx*ny*sizeof(float);
        !            70:   b = (float *)malloc(s);
        !            71:   if(!b){fprintf(stderr,"no memory\n");exit(1);}
        !            72:   for(j=0; j<ny; j++){
        !            73:     for(i=0; i<nx; i++){
        !            74:        r = *p++;
        !            75:        if(r < -BIG) r=rd.pmin-1;
        !            76:        b[i*ny+j] = r;
        !            77:     }
        !            78:   }
        !            79:   write(1,b,s);
        !            80:   free((char *)b);
        !            81: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.