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

Comparing ray/src/util/radcompare.c (file contents):
Revision 2.6 by greg, Mon Oct 15 22:38:31 2018 UTC vs.
Revision 2.9 by greg, Tue Oct 16 16:52:05 2018 UTC

# Line 82 | Line 82 | FILE           *f1in=NULL, *f2in=NULL;
82  
83                                  /* running real differences */
84   double  diff2sum = 0;
85 < int     nsum = 0;
85 > long    nsum = 0;
86  
87   /* Report usage and exit */
88   static void
# Line 92 | Line 92 | usage()
92          fputs(progname, stderr);
93          fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
94                          stderr);
95 <        exit(1);
95 >        exit(2);
96   }
97  
98   /* Get type ID from name (or 0 if not found) */
# Line 134 | Line 134 | real_check(double r1, double r2)
134          return(1);
135   }
136  
137 + /* Compare two color values for equivalence */
138 + static int
139 + color_check(COLOR c1, COLOR c2)
140 + {
141 +        int     p;
142 +
143 +        if (!real_check(colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU)*(1./3.),
144 +                        colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.))
145 +                return(0);
146 +
147 +        p = (colval(c1,GRN) > colval(c1,RED)) ? GRN : RED;
148 +        if (colval(c1,BLU) > colval(c1,p)) p = BLU;
149 +        
150 +        return(real_check(colval(c1,p), colval(c2,p)));
151 + }
152 +
153   /* Compare two strings for equivalence */
154   static int
155   equiv_string(char *s1, char *s2)
# Line 527 | Line 543 | compare_hdr()
543                          return(0);
544                  }
545                  for (x = 0; x < scanlen(&rs1); x++) {
546 <                        if (real_check(colval(scan1[x],RED),
531 <                                                colval(scan2[x],RED)) &
532 <                                        real_check(colval(scan1[x],GRN),
533 <                                                colval(scan2[x],GRN)) &
534 <                                        real_check(colval(scan1[x],BLU),
535 <                                                colval(scan2[x],BLU)))
546 >                        if (color_check(scan1[x], scan2[x]))
547                                  continue;
548                          if (report != REP_QUIET) {
549                                  printf(
# Line 568 | Line 579 | compare_float()
579  
580          if (report >= REP_VERBOSE) {
581                  fputs(progname, stdout);
582 <                fputs(": comparing inputs as 32-bit IEEE float\n", stdout);
582 >                fputs(": comparing inputs as 32-bit IEEE floats\n", stdout);
583          }
584          while (getbinary(&f1, sizeof(f1), 1, f1in)) {
585                  if (!getbinary(&f2, sizeof(f2), 1, f2in))
# Line 598 | Line 609 | compare_double()
609  
610          if (report >= REP_VERBOSE) {
611                  fputs(progname, stdout);
612 <                fputs(": comparing inputs as 64-bit IEEE double\n", stdout);
612 >                fputs(": comparing inputs as 64-bit IEEE doubles\n", stdout);
613          }
614          while (getbinary(&f1, sizeof(f1), 1, f1in)) {
615                  if (!getbinary(&f2, sizeof(f2), 1, f2in))
# Line 662 | Line 673 | main(int argc, char *argv[])
673                  }
674                  break;
675          }
676 <        if (a != argc-2)
676 >        if (a != argc-2)                        /* make sure of two inputs */
677                  usage();
678 <        if (!f1name) f1name = argv[a];
668 <        if (!f2name) f2name = argv[a+1];
669 <
670 <        if (!strcmp(f1name, f2name)) {          /* inputs are same? */
678 >        if (!strcmp(argv[a], argv[a+1])) {      /* inputs are same? */
679                  if (report >= REP_WARN)
680                          printf("%s: warning - identical inputs given\n",
681                                          progname);
682                  return(0);
683          }
684 +        if (!f1name) f1name = argv[a];
685 +        if (!f2name) f2name = argv[a+1];
686                                                  /* open inputs */
687          SET_FILE_BINARY(stdin);                 /* in case we're using it */
688          if (!f1in && !(f1in = fopen(f1name, "rb"))) {
689                  fprintf(stderr, "%s: cannot open for reading\n", f1name);
690 <                return(1);
690 >                return(2);
691          }
692          if (!strcmp(f2name, "-")) {
693                  f2in = stdin;
694                  f2name = stdin_name;
695          } else if (!(f2in = fopen(f2name, "rb"))) {
696                  fprintf(stderr, "%s: cannot open for reading\n", f2name);
697 <                return(1);
697 >                return(2);
698          }
699                                                  /* load headers */
700          if ((typ1 = identify_type(f1name, f1in, &hdr1)) < 0)
701 <                return(1);
701 >                return(2);
702          if ((typ2 = identify_type(f2name, f2in, &hdr2)) < 0)
703 <                return(1);
703 >                return(2);
704          if (typ1 != typ2) {
705                  if (report != REP_QUIET)
706                          printf("%s: '%s' is %s and '%s' is %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines