ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pinterp.c
(Generate patch)

Comparing ray/src/px/pinterp.c (file contents):
Revision 2.36 by schorsch, Mon Jul 21 22:30:18 2003 UTC vs.
Revision 2.40 by schorsch, Fri Jan 2 12:47:01 2004 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   #include <ctype.h>
13   #include <string.h>
14  
15 + #include "platform.h"
16   #include "standard.h"
17   #include "rtprocess.h" /* Windows: must come before color.h */
18   #include "view.h"
# Line 27 | Line 28 | static const char      RCSid[] = "$Id$";
28   #define averaging       (ourweigh != NULL)
29   #define blurring        (ourbpict != NULL)
30   #define usematrix       (hasmatrix & !averaging)
31 < #define zisnorm         (!usematrix | ourview.type != VT_PER)
31 > #define zisnorm         ((!usematrix) | (ourview.type != VT_PER))
32  
33   #define MAXWT           1000.           /* maximum pixel weight (averaging) */
34  
# Line 93 | Line 94 | int    queuesiz = 0;                   /* number of pixels pending */
94  
95   extern double   movepixel();
96  
97 + static gethfunc headline;
98  
99 +
100   main(argc, argv)                        /* interpolate pictures */
101   int     argc;
102   char    *argv[];
# Line 233 | Line 236 | char   *argv[];
236          if (doavg < 0)
237                  doavg = (argc-an) > 2;
238          if (expcomp != NULL) {
239 <                if (expcomp[0] == '+' | expcomp[0] == '-') {
239 >                if ((expcomp[0] == '+') | (expcomp[0] == '-')) {
240                          expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5);
241                          if (doavg | doblur)
242                                  rexpadj = pow(2.0, atof(expcomp));
# Line 259 | Line 262 | char   *argv[];
262          if (doavg) {
263                  ourspict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR));
264                  ourweigh = (float *)bmalloc(hresolu*vresolu*sizeof(float));
265 <                if (ourspict == NULL | ourweigh == NULL)
265 >                if ((ourspict == NULL) | (ourweigh == NULL))
266                          syserror(progname);
267          } else {
268                  ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR));
# Line 299 | Line 302 | char   *argv[];
302                  fprintview(&avgview, stdout);
303                  putc('\n', stdout);
304          }
305 <        if (pixaspect < .99 | pixaspect > 1.01)
305 >        if ((pixaspect < .99) | (pixaspect > 1.01))
306                  fputaspect(pixaspect, stdout);
307          if (ourexp > 0)
308                  ourexp *= rexpadj;
309          else
310                  ourexp = rexpadj;
311 <        if (ourexp < .995 | ourexp > 1.005)
311 >        if ((ourexp < .995) | (ourexp > 1.005))
312                  fputexpos(ourexp, stdout);
313          if (strcmp(ourfmt, PICFMT))             /* print format if known */
314                  fputformat(ourfmt, stdout);
# Line 326 | Line 329 | userr:
329   }
330  
331  
332 < int
333 < headline(s)                             /* process header string */
334 < char    *s;
332 > static int
333 > headline(                               /* process header string */
334 >        char    *s,
335 >        void    *p
336 > )
337   {
338          char    fmt[32];
339  
# Line 448 | Line 453 | char   *pfile, *zspec;
453                  ourexp = theirexp;
454          else if (ABS(theirexp-ourexp) > .01*ourexp)
455                  fprintf(stderr, "%s: different exposure (warning)\n", pfile);
456 <        if (err = setview(&theirview)) {
456 >        if ( (err = setview(&theirview)) ) {
457                  fprintf(stderr, "%s: %s\n", pfile, err);
458                  exit(1);
459          }
# Line 482 | Line 487 | char   *pfile, *zspec;
487          scanin = (COLR *)malloc(scanlen(&tresolu)*sizeof(COLR));
488          plast = (struct position *)calloc(scanlen(&tresolu),
489                          sizeof(struct position));
490 <        if (scanin == NULL | plast == NULL)
490 >        if ((scanin == NULL) | (plast == NULL))
491                  syserror(progname);
492                                          /* skip to starting point */
493          for (y = 0; y < ylim.min; y++)
# Line 491 | Line 496 | char   *pfile, *zspec;
496                          exit(1);
497                  }
498          if (zfd != -1 && lseek(zfd,
499 <                        (off_t)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
499 >                        (off_t)ylim.min*scanlen(&tresolu)*sizeof(float),
500 >                        SEEK_SET) < 0)
501                  syserror(zspec);
502                                          /* load image */
503          for (y = ylim.min; y <= ylim.max; y++) {
# Line 522 | Line 528 | register VIEW  *vw1, *vw2;
528   {
529          double  m4t[4][4];
530  
531 <        if (vw1->type != VT_PER & vw1->type != VT_PAR)
531 >        if ((vw1->type != VT_PER) & (vw1->type != VT_PAR))
532                  return(0);
533 <        if (vw2->type != VT_PER & vw2->type != VT_PAR)
533 >        if ((vw2->type != VT_PER) & (vw2->type != VT_PAR))
534                  return(0);
535          setident4(xfmat);
536          xfmat[0][0] = vw1->hvec[0];
# Line 608 | Line 614 | double z;
614                  s1x = p1->x - p0->x;
615                  s1y = p1->y - p0->y;
616                  l1 = ABS(s1x);
617 <                if (p1isy = (ABS(s1y) > l1))
617 >                if ( (p1isy = (ABS(s1y) > l1)) )
618                          l1 = ABS(s1y);
619                  else if (l1 < 1)
620                          l1 = 1;
# Line 641 | Line 647 | double z;
647                  y1 = p0->y + c1*s1y/l1;
648                  for (c2 = l2; c2-- > 0; ) {
649                          x = x1 + c2*s2x/l2;
650 <                        if (x < 0 | x >= hresolu)
650 >                        if ((x < 0) | (x >= hresolu))
651                                  continue;
652                          y = y1 + c2*s2y/l2;
653 <                        if (y < 0 | y >= vresolu)
653 >                        if ((y < 0) | (y >= vresolu))
654                                  continue;
655                          if (averaging) {
656                                  if (zscan(y)[x] <= 0 || zscan(y)[x]-z
# Line 678 | Line 684 | register FVECT pos;
684          if (usematrix) {
685                  pos[0] += theirview.hoff - .5;
686                  pos[1] += theirview.voff - .5;
687 <                if (normdist & theirview.type == VT_PER)
687 >                if (normdist & (theirview.type == VT_PER))
688                          d = sqrt(1. + pos[0]*pos[0]*theirview.hn2
689                                          + pos[1]*pos[1]*theirview.vn2);
690                  else
# Line 702 | Line 708 | register FVECT pos;
708          } else {
709                  if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY)
710                          return(0);
711 <                if (!normdist & theirview.type == VT_PER)       /* adjust */
711 >                if ((!normdist) & (theirview.type == VT_PER))   /* adjust */
712                          pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2
713                                          + pos[1]*pos[1]*theirview.vn2);
714                  pt[0] += tdir[0]*pos[2];
# Line 712 | Line 718 | register FVECT pos;
718                  if (pos[2] <= 0)
719                          return(0);
720          }
721 <        if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY)
721 >        if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | (pos[1] < 0) | (pos[1] >= 1-FTINY))
722                  return(0);
723          if (!averaging)
724                  return(1);
# Line 759 | Line 765 | int    zfd;
765          for (y = step - 1; y < numscans(&tresolu); y += step) {
766                  if (zfd != -1) {
767                          if (lseek(zfd, (off_t)y*scanlen(&tresolu)*sizeof(float),
768 <                                        0) < 0)
768 >                                        SEEK_SET) < 0)
769                                  syserror("lseek");
770                          if (read(zfd, (char *)zline,
771                                          scanlen(&tresolu)*sizeof(float))
# Line 940 | Line 946 | int    (*fill)();
946   clipaft()                       /* perform aft clipping as indicated */
947   {
948          register int    x, y;
949 <        int     adjtest = ourview.type == VT_PER & zisnorm;
949 >        int     adjtest = (ourview.type == VT_PER) & zisnorm;
950          double  tstdist;
951          double  yzn2, vx;
952  
# Line 1048 | Line 1054 | writedistance(fname)                   /* write out z file (alters buf
1054   char    *fname;
1055   {
1056          int     donorm = normdist & !zisnorm ? 1 :
1057 <                        ourview.type == VT_PER & !normdist & zisnorm ? -1 : 0;
1057 >                        (ourview.type == VT_PER) & !normdist & zisnorm ? -1 : 0;
1058          int     fd;
1059          int     y;
1060  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines