| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
#include <stdlib.h> |
| 11 |
– |
#include <math.h> |
| 11 |
|
#include <ctype.h> |
| 12 |
+ |
#include "rtmath.h" |
| 13 |
|
#include "platform.h" |
| 14 |
|
#include "rtio.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
|
#include "color.h" |
| 17 |
+ |
#include "depthcodec.h" |
| 18 |
+ |
#include "normcodec.h" |
| 19 |
|
#include "lookup.h" |
| 20 |
|
/* Reporting levels */ |
| 21 |
|
#define REP_QUIET 0 /* no reporting */ |
| 47 |
|
"ascii", |
| 48 |
|
COLRFMT, |
| 49 |
|
CIEFMT, |
| 50 |
+ |
DEPTH16FMT, |
| 51 |
+ |
NORMAL32FMT, |
| 52 |
|
"float", |
| 53 |
|
"double", |
| 54 |
|
"BSDF_RBFmesh", |
| 55 |
|
"Radiance_octree", |
| 56 |
|
"Radiance_tmesh", |
| 57 |
+ |
"8-bit_indexed_name", |
| 58 |
+ |
"16-bit_indexed_name", |
| 59 |
+ |
"24-bit_indexed_name", |
| 60 |
|
"BINARY_unknown", |
| 61 |
|
NULL /* terminator */ |
| 62 |
|
}; |
| 63 |
|
/* keep consistent with above */ |
| 64 |
< |
enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE, TYP_FLOAT, |
| 65 |
< |
TYP_DOUBLE, TYP_RBFMESH, TYP_OCTREE, TYP_TMESH, TYP_BINARY}; |
| 64 |
> |
enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE, |
| 65 |
> |
TYP_DEPTH, TYP_NORM, TYP_FLOAT, TYP_DOUBLE, |
| 66 |
> |
TYP_RBFMESH, TYP_OCTREE, TYP_TMESH, |
| 67 |
> |
TYP_ID8, TYP_ID16, TYP_ID24, TYP_BINARY}; |
| 68 |
|
|
| 69 |
|
#define has_header(t) (!( 1L<<(t) & (1L<<TYP_TEXT | 1L<<TYP_BINARY) )) |
| 70 |
|
|
| 73 |
|
"SOFTWARE", |
| 74 |
|
"CAPDATE", |
| 75 |
|
"GMT", |
| 76 |
+ |
"FRAME", |
| 77 |
|
NULL /* terminator */ |
| 78 |
|
}; |
| 79 |
|
/* header variable settings */ |
| 84 |
|
#define adv_linecnt(htp) (lin1cnt += (htp == &hdr1), \ |
| 85 |
|
lin2cnt += (htp == &hdr2)) |
| 86 |
|
|
| 87 |
+ |
typedef struct { /* dynamic line buffer */ |
| 88 |
+ |
char *str; |
| 89 |
+ |
int len; |
| 90 |
+ |
int siz; |
| 91 |
+ |
} LINEBUF; |
| 92 |
+ |
|
| 93 |
+ |
#define init_line(bp) ((bp)->str = NULL, (bp)->siz = 0) |
| 94 |
+ |
/* 100 MByte limit on line buffer */ |
| 95 |
+ |
#define MAXBUF (100L<<20) |
| 96 |
+ |
|
| 97 |
|
/* input files */ |
| 98 |
|
char *progname = NULL; |
| 99 |
|
const char stdin_name[] = "<stdin>"; |
| 100 |
|
const char *f1name=NULL, *f2name=NULL; |
| 101 |
|
FILE *f1in=NULL, *f2in=NULL; |
| 102 |
+ |
int f1swap=0, f2swap=0; |
| 103 |
|
|
| 104 |
|
/* running real differences */ |
| 105 |
|
double diff2sum = 0; |
| 113 |
|
fputs(progname, stderr); |
| 114 |
|
fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n", |
| 115 |
|
stderr); |
| 116 |
< |
exit(1); |
| 116 |
> |
exit(2); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
+ |
/* Read a text line, increasing buffer size as necessary */ |
| 120 |
+ |
static int |
| 121 |
+ |
read_line(LINEBUF *bp, FILE *fp) |
| 122 |
+ |
{ |
| 123 |
+ |
static int doneWarn = 0; |
| 124 |
+ |
|
| 125 |
+ |
bp->len = 0; |
| 126 |
+ |
if (!bp->str) { |
| 127 |
+ |
bp->str = (char *)malloc(bp->siz = 512); |
| 128 |
+ |
if (!bp->str) |
| 129 |
+ |
goto memerr; |
| 130 |
+ |
} |
| 131 |
+ |
while (fgets(bp->str + bp->len, bp->siz - bp->len, fp)) { |
| 132 |
+ |
bp->len += strlen(bp->str + bp->len); |
| 133 |
+ |
if (bp->str[bp->len-1] == '\n') |
| 134 |
+ |
break; /* found EOL */ |
| 135 |
+ |
if (bp->len < bp->siz - 4) |
| 136 |
+ |
continue; /* at EOF? */ |
| 137 |
+ |
if (bp->siz >= MAXBUF) { |
| 138 |
+ |
if ((report >= REP_WARN) & !doneWarn) { |
| 139 |
+ |
fprintf(stderr, |
| 140 |
+ |
"%s: warning - input line(s) past %ld MByte limit\n", |
| 141 |
+ |
progname, MAXBUF>>20); |
| 142 |
+ |
doneWarn++; |
| 143 |
+ |
} |
| 144 |
+ |
break; /* return MAXBUF partial line */ |
| 145 |
+ |
} |
| 146 |
+ |
if ((bp->siz += bp->siz/2) > MAXBUF) |
| 147 |
+ |
bp->siz = MAXBUF; |
| 148 |
+ |
bp->str = (char *)realloc(bp->str, bp->siz); |
| 149 |
+ |
if (!bp->str) |
| 150 |
+ |
goto memerr; |
| 151 |
+ |
} |
| 152 |
+ |
return(bp->len); |
| 153 |
+ |
memerr: |
| 154 |
+ |
fprintf(stderr, |
| 155 |
+ |
"%s: out of memory in read_line() allocating %d byte buffer\n", |
| 156 |
+ |
progname, bp->siz); |
| 157 |
+ |
exit(2); |
| 158 |
+ |
} |
| 159 |
+ |
|
| 160 |
+ |
/* Free line buffer */ |
| 161 |
+ |
static void |
| 162 |
+ |
free_line(LINEBUF *bp) |
| 163 |
+ |
{ |
| 164 |
+ |
if (bp->str) free(bp->str); |
| 165 |
+ |
init_line(bp); |
| 166 |
+ |
} |
| 167 |
+ |
|
| 168 |
|
/* Get type ID from name (or 0 if not found) */ |
| 169 |
|
static int |
| 170 |
|
xlate_type(const char *nm) |
| 210 |
|
{ |
| 211 |
|
int p; |
| 212 |
|
|
| 213 |
< |
if (!real_check(colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU)*(1./3.), |
| 214 |
< |
colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.)) |
| 213 |
> |
if (!real_check((colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU))*(1./3.), |
| 214 |
> |
(colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.))) |
| 215 |
|
return(0); |
| 216 |
|
|
| 217 |
|
p = (colval(c1,GRN) > colval(c1,RED)) ? GRN : RED; |
| 220 |
|
return(real_check(colval(c1,p), colval(c2,p))); |
| 221 |
|
} |
| 222 |
|
|
| 223 |
+ |
/* Compare two normal directions for equivalence */ |
| 224 |
+ |
static int |
| 225 |
+ |
norm_check(FVECT nv1, FVECT nv2) |
| 226 |
+ |
{ |
| 227 |
+ |
double max2 = nv1[2]*nv1[2]; |
| 228 |
+ |
int imax = 2; |
| 229 |
+ |
int i = 2; |
| 230 |
+ |
/* identify largest component */ |
| 231 |
+ |
while (i--) { |
| 232 |
+ |
double tm2 = nv1[i]*nv1[i]; |
| 233 |
+ |
if (tm2 > max2) { |
| 234 |
+ |
imax = i; |
| 235 |
+ |
max2 = tm2; |
| 236 |
+ |
} |
| 237 |
+ |
} |
| 238 |
+ |
i = 3; /* compare smaller components */ |
| 239 |
+ |
while (i--) { |
| 240 |
+ |
if (i == imax) |
| 241 |
+ |
continue; |
| 242 |
+ |
if (!real_check(nv1[i], nv2[i])) |
| 243 |
+ |
return(0); |
| 244 |
+ |
} |
| 245 |
+ |
return(1); |
| 246 |
+ |
} |
| 247 |
+ |
|
| 248 |
|
/* Compare two strings for equivalence */ |
| 249 |
|
static int |
| 250 |
|
equiv_string(char *s1, char *s2) |
| 326 |
|
adv_linecnt(htp); /* side-effect is to count lines */ |
| 327 |
|
if (!isalpha(*val)) /* key must start line */ |
| 328 |
|
return(0); |
| 329 |
+ |
/* check if we need to swap binary data */ |
| 330 |
+ |
if ((n = isbigendian(val)) >= 0) { |
| 331 |
+ |
if (nativebigendian() == n) |
| 332 |
+ |
return(0); |
| 333 |
+ |
f1swap += (htp == &hdr1); |
| 334 |
+ |
f2swap += (htp == &hdr2); |
| 335 |
+ |
return(0); |
| 336 |
+ |
} |
| 337 |
|
key = val++; |
| 338 |
|
while (*val && !isspace(*val) & (*val != '=')) |
| 339 |
|
val++; |
| 394 |
|
|
| 395 |
|
/* Compare two sets of header variables */ |
| 396 |
|
static int |
| 397 |
< |
headers_match(LUTAB *hp1, LUTAB *hp2) |
| 397 |
> |
headers_match() |
| 398 |
|
{ |
| 399 |
< |
int ne = lu_doall(hp1, match_val, hp2); |
| 399 |
> |
int ne = lu_doall(&hdr1, match_val, &hdr2); |
| 400 |
|
if (ne < 0) |
| 401 |
|
return(0); /* something didn't match! */ |
| 402 |
|
/* non-fatal if second header has extra */ |
| 403 |
< |
if (report >= REP_WARN && (ne = lu_doall(hp2, NULL, NULL) - ne)) |
| 403 |
> |
if (report >= REP_WARN && (ne = lu_doall(&hdr2, NULL, NULL) - ne)) |
| 404 |
|
printf("%s: warning - '%s' has %d extra header setting(s)\n", |
| 405 |
|
progname, f2name, ne); |
| 406 |
|
return(1); /* good match */ |
| 548 |
|
static int |
| 549 |
|
compare_text() |
| 550 |
|
{ |
| 551 |
< |
char l1buf[4096], l2buf[4096]; |
| 551 |
> |
LINEBUF l1buf, l2buf; |
| 552 |
|
|
| 553 |
|
if (report >= REP_VERBOSE) { |
| 554 |
|
fputs(progname, stdout); |
| 555 |
|
fputs(": comparing inputs as ASCII text\n", stdout); |
| 556 |
|
} |
| 557 |
< |
/* compare a line at a time */ |
| 558 |
< |
while (fgets(l1buf, sizeof(l1buf), f1in)) { |
| 557 |
> |
init_line(&l1buf); init_line(&l2buf); /* compare a line at a time */ |
| 558 |
> |
while (read_line(&l1buf, f1in)) { |
| 559 |
|
lin1cnt++; |
| 560 |
< |
if (!*sskip2(l1buf,0)) |
| 560 |
> |
if (!*sskip2(l1buf.str,0)) |
| 561 |
|
continue; /* ignore empty lines */ |
| 562 |
< |
while (fgets(l2buf, sizeof(l2buf), f2in)) { |
| 562 |
> |
|
| 563 |
> |
while (read_line(&l2buf, f2in)) { |
| 564 |
|
lin2cnt++; |
| 565 |
< |
if (*sskip2(l2buf,0)) |
| 565 |
> |
if (*sskip2(l2buf.str,0)) |
| 566 |
|
break; /* found other non-empty line */ |
| 567 |
|
} |
| 568 |
< |
if (feof(f2in)) { |
| 568 |
> |
if (!l2buf.len) { /* input 2 EOF? */ |
| 569 |
|
if (report != REP_QUIET) { |
| 570 |
|
fputs(f2name, stdout); |
| 571 |
|
fputs(": unexpected end-of-file\n", stdout); |
| 572 |
|
} |
| 573 |
+ |
free_line(&l1buf); free_line(&l2buf); |
| 574 |
|
return(0); |
| 575 |
|
} |
| 576 |
|
/* compare non-empty lines */ |
| 577 |
< |
if (!equiv_string(l1buf, l2buf)) { |
| 577 |
> |
if (!equiv_string(l1buf.str, l2buf.str)) { |
| 578 |
|
if (report != REP_QUIET) { |
| 579 |
|
printf("%s: inputs '%s' and '%s' differ at line %d|%d\n", |
| 580 |
|
progname, f1name, f2name, |
| 581 |
|
lin1cnt, lin2cnt); |
| 582 |
< |
if (report >= REP_VERBOSE) { |
| 582 |
> |
if ( report >= REP_VERBOSE && |
| 583 |
> |
(l1buf.len < 256) & |
| 584 |
> |
(l2buf.len < 256) ) { |
| 585 |
|
fputs("------------- Mismatch -------------\n", stdout); |
| 586 |
|
printf("%s@%d:\t%s", f1name, |
| 587 |
< |
lin1cnt, l1buf); |
| 587 |
> |
lin1cnt, l1buf.str); |
| 588 |
|
printf("%s@%d:\t%s", f2name, |
| 589 |
< |
lin2cnt, l2buf); |
| 589 |
> |
lin2cnt, l2buf.str); |
| 590 |
|
} |
| 591 |
|
} |
| 592 |
+ |
free_line(&l1buf); free_line(&l2buf); |
| 593 |
|
return(0); |
| 594 |
|
} |
| 595 |
|
} |
| 596 |
< |
/* check for EOF on input 2 */ |
| 597 |
< |
while (fgets(l2buf, sizeof(l2buf), f2in)) { |
| 598 |
< |
if (!*sskip2(l2buf,0)) |
| 596 |
> |
free_line(&l1buf); /* check for EOF on input 2 */ |
| 597 |
> |
while (read_line(&l2buf, f2in)) { |
| 598 |
> |
if (!*sskip2(l2buf.str,0)) |
| 599 |
|
continue; |
| 600 |
|
if (report != REP_QUIET) { |
| 601 |
|
fputs(f1name, stdout); |
| 602 |
|
fputs(": unexpected end-of-file\n", stdout); |
| 603 |
|
} |
| 604 |
+ |
free_line(&l2buf); |
| 605 |
|
return(0); |
| 606 |
|
} |
| 607 |
+ |
free_line(&l2buf); |
| 608 |
|
return(good_RMS()); /* final check for reals */ |
| 609 |
|
} |
| 610 |
|
|
| 611 |
+ |
/* Check image/map resolutions */ |
| 612 |
+ |
static int |
| 613 |
+ |
check_resolu(const char *class, RESOLU *r1p, RESOLU *r2p) |
| 614 |
+ |
{ |
| 615 |
+ |
if (r1p->rt != r2p->rt) { |
| 616 |
+ |
if (report != REP_QUIET) |
| 617 |
+ |
printf( |
| 618 |
+ |
"%s: %ss '%s' and '%s' have different pixel ordering\n", |
| 619 |
+ |
progname, class, f1name, f2name); |
| 620 |
+ |
return(0); |
| 621 |
+ |
} |
| 622 |
+ |
if ((r1p->xr != r2p->xr) | (r1p->yr != r2p->yr)) { |
| 623 |
+ |
if (report != REP_QUIET) |
| 624 |
+ |
printf( |
| 625 |
+ |
"%s: %ss '%s' and '%s' are different sizes\n", |
| 626 |
+ |
progname, class, f1name, f2name); |
| 627 |
+ |
return(0); |
| 628 |
+ |
} |
| 629 |
+ |
return(1); |
| 630 |
+ |
} |
| 631 |
+ |
|
| 632 |
|
/* Compare two inputs that are known to be RGBE or XYZE images */ |
| 633 |
|
static int |
| 634 |
|
compare_hdr() |
| 643 |
|
} |
| 644 |
|
fgetsresolu(&rs1, f1in); |
| 645 |
|
fgetsresolu(&rs2, f2in); |
| 646 |
< |
if (rs1.rt != rs2.rt) { |
| 516 |
< |
if (report != REP_QUIET) |
| 517 |
< |
printf( |
| 518 |
< |
"%s: Images '%s' and '%s' have different pixel ordering\n", |
| 519 |
< |
progname, f1name, f2name); |
| 646 |
> |
if (!check_resolu("HDR image", &rs1, &rs2)) |
| 647 |
|
return(0); |
| 521 |
– |
} |
| 522 |
– |
if ((rs1.xr != rs2.xr) | (rs1.yr != rs2.yr)) { |
| 523 |
– |
if (report != REP_QUIET) |
| 524 |
– |
printf( |
| 525 |
– |
"%s: Images '%s' and '%s' are different sizes\n", |
| 526 |
– |
progname, f1name, f2name); |
| 527 |
– |
return(0); |
| 528 |
– |
} |
| 648 |
|
scan1 = (COLOR *)malloc(scanlen(&rs1)*sizeof(COLOR)); |
| 649 |
|
scan2 = (COLOR *)malloc(scanlen(&rs2)*sizeof(COLOR)); |
| 650 |
|
if (!scan1 | !scan2) { |
| 689 |
|
return(good_RMS()); /* final check of RMS */ |
| 690 |
|
} |
| 691 |
|
|
| 692 |
+ |
/* Set reference depth based on header variable */ |
| 693 |
+ |
static int |
| 694 |
+ |
set_refdepth(DEPTHCODEC *dcp, LUTAB *htp) |
| 695 |
+ |
{ |
| 696 |
+ |
static char depthvar[] = DEPTHSTR; |
| 697 |
+ |
const char *drval; |
| 698 |
+ |
|
| 699 |
+ |
depthvar[LDEPTHSTR] = '\0'; |
| 700 |
+ |
drval = (const char *)lu_find(htp, depthvar)->data; |
| 701 |
+ |
if (!drval) |
| 702 |
+ |
return(0); |
| 703 |
+ |
dcp->refdepth = atof(drval); |
| 704 |
+ |
if (dcp->refdepth <= 0) { |
| 705 |
+ |
if (report != REP_QUIET) { |
| 706 |
+ |
fputs(dcp->inpname, stderr); |
| 707 |
+ |
fputs(": bad reference depth '", stderr); |
| 708 |
+ |
fputs(drval, stderr); |
| 709 |
+ |
fputs("'\n", stderr); |
| 710 |
+ |
} |
| 711 |
+ |
return(-1); |
| 712 |
+ |
} |
| 713 |
+ |
return(1); |
| 714 |
+ |
} |
| 715 |
+ |
|
| 716 |
+ |
/* Compare two encoded depth maps */ |
| 717 |
+ |
static int |
| 718 |
+ |
compare_depth() |
| 719 |
+ |
{ |
| 720 |
+ |
long nread = 0; |
| 721 |
+ |
DEPTHCODEC dc1, dc2; |
| 722 |
+ |
|
| 723 |
+ |
if (report >= REP_VERBOSE) { |
| 724 |
+ |
fputs(progname, stdout); |
| 725 |
+ |
fputs(": comparing inputs as depth maps\n", stdout); |
| 726 |
+ |
} |
| 727 |
+ |
set_dc_defaults(&dc1); |
| 728 |
+ |
dc1.hdrflags = HF_RESIN; |
| 729 |
+ |
dc1.finp = f1in; |
| 730 |
+ |
dc1.inpname = f1name; |
| 731 |
+ |
set_dc_defaults(&dc2); |
| 732 |
+ |
dc2.hdrflags = HF_RESIN; |
| 733 |
+ |
dc2.finp = f2in; |
| 734 |
+ |
dc2.inpname = f2name; |
| 735 |
+ |
if (report != REP_QUIET) { |
| 736 |
+ |
dc1.hdrflags |= HF_STDERR; |
| 737 |
+ |
dc2.hdrflags |= HF_STDERR; |
| 738 |
+ |
} |
| 739 |
+ |
if (!process_dc_header(&dc1, 0, NULL)) |
| 740 |
+ |
return(0); |
| 741 |
+ |
if (!process_dc_header(&dc2, 0, NULL)) |
| 742 |
+ |
return(0); |
| 743 |
+ |
if (!check_resolu("Depth map", &dc1.res, &dc2.res)) |
| 744 |
+ |
return(0); |
| 745 |
+ |
if (set_refdepth(&dc1, &hdr1) < 0) |
| 746 |
+ |
return(0); |
| 747 |
+ |
if (set_refdepth(&dc2, &hdr2) < 0) |
| 748 |
+ |
return(0); |
| 749 |
+ |
while (nread < dc1.res.xr*dc1.res.yr) { |
| 750 |
+ |
double d1 = decode_depth_next(&dc1); |
| 751 |
+ |
double d2 = decode_depth_next(&dc2); |
| 752 |
+ |
if ((d1 < 0) | (d2 < 0)) { |
| 753 |
+ |
if (report != REP_QUIET) |
| 754 |
+ |
printf("%s: unexpected end-of-file\n", |
| 755 |
+ |
progname); |
| 756 |
+ |
return(0); |
| 757 |
+ |
} |
| 758 |
+ |
++nread; |
| 759 |
+ |
if (real_check(d1, d2)) |
| 760 |
+ |
continue; |
| 761 |
+ |
if (report != REP_QUIET) |
| 762 |
+ |
printf("%s: %ld%s depth values differ\n", |
| 763 |
+ |
progname, nread, num_sfx(nread)); |
| 764 |
+ |
return(0); |
| 765 |
+ |
} |
| 766 |
+ |
return(good_RMS()); /* final check of RMS */ |
| 767 |
+ |
} |
| 768 |
+ |
|
| 769 |
+ |
/* Compare two encoded normal maps */ |
| 770 |
+ |
static int |
| 771 |
+ |
compare_norm() |
| 772 |
+ |
{ |
| 773 |
+ |
long nread = 0; |
| 774 |
+ |
NORMCODEC nc1, nc2; |
| 775 |
+ |
|
| 776 |
+ |
if (report >= REP_VERBOSE) { |
| 777 |
+ |
fputs(progname, stdout); |
| 778 |
+ |
fputs(": comparing inputs as normal maps\n", stdout); |
| 779 |
+ |
} |
| 780 |
+ |
set_nc_defaults(&nc1); |
| 781 |
+ |
nc1.hdrflags = HF_RESIN; |
| 782 |
+ |
nc1.finp = f1in; |
| 783 |
+ |
nc1.inpname = f1name; |
| 784 |
+ |
set_nc_defaults(&nc2); |
| 785 |
+ |
nc2.hdrflags = HF_RESIN; |
| 786 |
+ |
nc2.finp = f2in; |
| 787 |
+ |
nc2.inpname = f2name; |
| 788 |
+ |
if (report != REP_QUIET) { |
| 789 |
+ |
nc1.hdrflags |= HF_STDERR; |
| 790 |
+ |
nc2.hdrflags |= HF_STDERR; |
| 791 |
+ |
} |
| 792 |
+ |
if (!process_nc_header(&nc1, 0, NULL)) |
| 793 |
+ |
return(0); |
| 794 |
+ |
if (!process_nc_header(&nc2, 0, NULL)) |
| 795 |
+ |
return(0); |
| 796 |
+ |
if (!check_resolu("Normal map", &nc1.res, &nc2.res)) |
| 797 |
+ |
return(0); |
| 798 |
+ |
while (nread < nc1.res.xr*nc1.res.yr) { |
| 799 |
+ |
FVECT nv1, nv2; |
| 800 |
+ |
int rv1 = decode_normal_next(nv1, &nc1); |
| 801 |
+ |
int rv2 = decode_normal_next(nv2, &nc2); |
| 802 |
+ |
if ((rv1 < 0) | (rv2 < 0)) { |
| 803 |
+ |
if (report != REP_QUIET) |
| 804 |
+ |
printf("%s: unexpected end-of-file\n", |
| 805 |
+ |
progname); |
| 806 |
+ |
return(0); |
| 807 |
+ |
} |
| 808 |
+ |
++nread; |
| 809 |
+ |
if (rv1 == rv2 && (!rv1 || norm_check(nv1, nv2))) |
| 810 |
+ |
continue; |
| 811 |
+ |
if (report != REP_QUIET) |
| 812 |
+ |
printf("%s: %ld%s normal vectors differ\n", |
| 813 |
+ |
progname, nread, num_sfx(nread)); |
| 814 |
+ |
return(0); |
| 815 |
+ |
} |
| 816 |
+ |
return(good_RMS()); /* final check of RMS */ |
| 817 |
+ |
} |
| 818 |
+ |
|
| 819 |
|
/* Compare two inputs that are known to be 32-bit floating-point data */ |
| 820 |
|
static int |
| 821 |
|
compare_float() |
| 831 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 832 |
|
goto badeof; |
| 833 |
|
++nread; |
| 834 |
+ |
if (f1swap) swap32((char *)&f1, 1); |
| 835 |
+ |
if (f2swap) swap32((char *)&f2, 1); |
| 836 |
|
if (real_check(f1, f2)) |
| 837 |
|
continue; |
| 838 |
|
if (report != REP_QUIET) |
| 863 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 864 |
|
goto badeof; |
| 865 |
|
++nread; |
| 866 |
+ |
if (f1swap) swap64((char *)&f1, 1); |
| 867 |
+ |
if (f2swap) swap64((char *)&f2, 1); |
| 868 |
|
if (real_check(f1, f2)) |
| 869 |
|
continue; |
| 870 |
|
if (report != REP_QUIET) |
| 937 |
|
SET_FILE_BINARY(stdin); /* in case we're using it */ |
| 938 |
|
if (!f1in && !(f1in = fopen(f1name, "rb"))) { |
| 939 |
|
fprintf(stderr, "%s: cannot open for reading\n", f1name); |
| 940 |
< |
return(1); |
| 940 |
> |
return(2); |
| 941 |
|
} |
| 942 |
|
if (!strcmp(f2name, "-")) { |
| 943 |
|
f2in = stdin; |
| 944 |
|
f2name = stdin_name; |
| 945 |
|
} else if (!(f2in = fopen(f2name, "rb"))) { |
| 946 |
|
fprintf(stderr, "%s: cannot open for reading\n", f2name); |
| 947 |
< |
return(1); |
| 947 |
> |
return(2); |
| 948 |
|
} |
| 949 |
|
/* load headers */ |
| 950 |
|
if ((typ1 = identify_type(f1name, f1in, &hdr1)) < 0) |
| 951 |
< |
return(1); |
| 951 |
> |
return(2); |
| 952 |
|
if ((typ2 = identify_type(f2name, f2in, &hdr2)) < 0) |
| 953 |
< |
return(1); |
| 953 |
> |
return(2); |
| 954 |
|
if (typ1 != typ2) { |
| 955 |
|
if (report != REP_QUIET) |
| 956 |
|
printf("%s: '%s' is %s and '%s' is %s\n", |
| 959 |
|
return(1); |
| 960 |
|
} |
| 961 |
|
ign_header |= !has_header(typ1); /* check headers if indicated */ |
| 962 |
< |
if (!ign_header && !headers_match(&hdr1, &hdr2)) |
| 962 |
> |
if (!ign_header && !headers_match()) |
| 963 |
|
return(1); |
| 714 |
– |
lu_done(&hdr1); lu_done(&hdr2); |
| 964 |
|
if (!ign_header & (report >= REP_WARN)) { |
| 716 |
– |
if (typ1 == TYP_UNKNOWN) |
| 717 |
– |
printf("%s: warning - unrecognized format, comparing as binary\n", |
| 718 |
– |
progname); |
| 965 |
|
if (lin1cnt != lin2cnt) |
| 966 |
|
printf("%s: warning - headers are different lengths\n", |
| 967 |
|
progname); |
| 968 |
+ |
if (typ1 == TYP_UNKNOWN) |
| 969 |
+ |
printf("%s: warning - unrecognized format\n", |
| 970 |
+ |
progname); |
| 971 |
|
} |
| 972 |
|
if (report >= REP_VERBOSE) |
| 973 |
|
printf("%s: input file type is %s\n", |
| 978 |
|
case TYP_TMESH: |
| 979 |
|
case TYP_OCTREE: |
| 980 |
|
case TYP_RBFMESH: |
| 981 |
+ |
case TYP_ID8: |
| 982 |
+ |
case TYP_ID16: |
| 983 |
+ |
case TYP_ID24: |
| 984 |
|
case TYP_UNKNOWN: |
| 985 |
|
return( !compare_binary() ); |
| 986 |
|
case TYP_TEXT: |
| 989 |
|
case TYP_RGBE: |
| 990 |
|
case TYP_XYZE: |
| 991 |
|
return( !compare_hdr() ); |
| 992 |
+ |
case TYP_DEPTH: |
| 993 |
+ |
return( !compare_depth() ); |
| 994 |
+ |
case TYP_NORM: |
| 995 |
+ |
return( !compare_norm() ); |
| 996 |
|
case TYP_FLOAT: |
| 997 |
|
return( !compare_float() ); |
| 998 |
|
case TYP_DOUBLE: |