--- ray/src/util/radcompare.c 2018/10/16 00:20:52 2.7 +++ ray/src/util/radcompare.c 2018/10/16 16:52:05 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: radcompare.c,v 2.7 2018/10/16 00:20:52 greg Exp $"; +static const char RCSid[] = "$Id: radcompare.c,v 2.9 2018/10/16 16:52:05 greg Exp $"; #endif /* * Compare Radiance files for significant differences @@ -82,7 +82,7 @@ FILE *f1in=NULL, *f2in=NULL; /* running real differences */ double diff2sum = 0; -int nsum = 0; +long nsum = 0; /* Report usage and exit */ static void @@ -92,7 +92,7 @@ usage() fputs(progname, stderr); fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n", stderr); - exit(1); + exit(2); } /* Get type ID from name (or 0 if not found) */ @@ -134,6 +134,22 @@ real_check(double r1, double r2) return(1); } +/* Compare two color values for equivalence */ +static int +color_check(COLOR c1, COLOR c2) +{ + int p; + + if (!real_check(colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU)*(1./3.), + colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.)) + return(0); + + p = (colval(c1,GRN) > colval(c1,RED)) ? GRN : RED; + if (colval(c1,BLU) > colval(c1,p)) p = BLU; + + return(real_check(colval(c1,p), colval(c2,p))); +} + /* Compare two strings for equivalence */ static int equiv_string(char *s1, char *s2) @@ -527,12 +543,7 @@ compare_hdr() return(0); } for (x = 0; x < scanlen(&rs1); x++) { - if (real_check(colval(scan1[x],RED), - colval(scan2[x],RED)) & - real_check(colval(scan1[x],GRN), - colval(scan2[x],GRN)) & - real_check(colval(scan1[x],BLU), - colval(scan2[x],BLU))) + if (color_check(scan1[x], scan2[x])) continue; if (report != REP_QUIET) { printf( @@ -676,20 +687,20 @@ main(int argc, char *argv[]) SET_FILE_BINARY(stdin); /* in case we're using it */ if (!f1in && !(f1in = fopen(f1name, "rb"))) { fprintf(stderr, "%s: cannot open for reading\n", f1name); - return(1); + return(2); } if (!strcmp(f2name, "-")) { f2in = stdin; f2name = stdin_name; } else if (!(f2in = fopen(f2name, "rb"))) { fprintf(stderr, "%s: cannot open for reading\n", f2name); - return(1); + return(2); } /* load headers */ if ((typ1 = identify_type(f1name, f1in, &hdr1)) < 0) - return(1); + return(2); if ((typ2 = identify_type(f2name, f2in, &hdr2)) < 0) - return(1); + return(2); if (typ1 != typ2) { if (report != REP_QUIET) printf("%s: '%s' is %s and '%s' is %s\n",