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.11 by greg, Fri Oct 19 20:32:16 2018 UTC vs.
Revision 2.32 by greg, Wed Mar 8 19:59:48 2023 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
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 */
# Line 25 | Line 27 | int    report = REP_WARN;      /* reporting level */
27  
28   int     ign_header = 0;         /* ignore header differences? */
29  
30 + int     escape_newlines = 0;    /* allow backslash to skip newlines */
31 +
32   double  rel_min = 1e-5;         /* positive for relative comparisons */
33  
34   double  rms_lim = 0.01;         /* RMS difference limit */
# Line 33 | Line 37 | double max_lim = 0.25;         /* difference limit if non-neg
37  
38   int     lin1cnt=0, lin2cnt=0;   /* file line position */
39  
40 + int     comment_c = '\0';       /* comment delimiter for text files */
41 +
42   const char      nsuffix[10][3] = {              /* 1st, 2nd, 3rd, etc. */
43                          "th","st","nd","rd","th","th","th","th","th","th"
44                  };
# Line 45 | Line 51 | const char     *file_type[] = {
51                          "ascii",
52                          COLRFMT,
53                          CIEFMT,
54 +                        DEPTH16FMT,
55 +                        NORMAL32FMT,
56                          "float",
57                          "double",
58                          "BSDF_RBFmesh",
59                          "Radiance_octree",
60                          "Radiance_tmesh",
61 +                        "8-bit_indexed_name",
62 +                        "16-bit_indexed_name",
63 +                        "24-bit_indexed_name",
64                          "BINARY_unknown",
65                          NULL    /* terminator */
66                  };
67                                  /* keep consistent with above */
68 < enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE, TYP_FLOAT,
69 <                TYP_DOUBLE, TYP_RBFMESH, TYP_OCTREE, TYP_TMESH, TYP_BINARY};
68 > enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE,
69 >                TYP_DEPTH, TYP_NORM, TYP_FLOAT, TYP_DOUBLE,
70 >                TYP_RBFMESH, TYP_OCTREE, TYP_TMESH,
71 >                TYP_ID8, TYP_ID16, TYP_ID24, TYP_BINARY};
72                  
73   #define has_header(t)   (!( 1L<<(t) & (1L<<TYP_TEXT | 1L<<TYP_BINARY) ))
74  
# Line 64 | Line 77 | const char     *hdr_ignkey[] = {
77                          "SOFTWARE",
78                          "CAPDATE",
79                          "GMT",
80 +                        "FRAME",
81                          NULL    /* terminator */
82                  };
83                                  /* header variable settings */
# Line 74 | Line 88 | LUTAB  hdr2 = LU_SINIT(free,free);
88   #define adv_linecnt(htp)        (lin1cnt += (htp == &hdr1), \
89                                          lin2cnt += (htp == &hdr2))
90  
91 + typedef struct {                /* dynamic line buffer */
92 +        char    *str;
93 +        int     len;
94 +        int     siz;
95 + } LINEBUF;
96 +
97 + #define init_line(bp)   ((bp)->str = NULL, (bp)->siz = 0)
98 +                                /* 100 MByte limit on line buffer */
99 + #define MAXBUF          (100L<<20)
100 +
101                                  /* input files */
102   char            *progname = NULL;
103   const char      stdin_name[] = "<stdin>";
104   const char      *f1name=NULL, *f2name=NULL;
105   FILE            *f1in=NULL, *f2in=NULL;
106 + int             f1swap=0, f2swap=0;
107  
108                                  /* running real differences */
109   double  diff2sum = 0;
# Line 90 | Line 115 | usage()
115   {
116          fputs("Usage: ", stderr);
117          fputs(progname, stderr);
118 <        fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
118 >        fputs(" [-h][-c#][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
119                          stderr);
120          exit(2);
121   }
122  
123 + /* Read a text line, increasing buffer size as necessary */
124 + static int
125 + read_line(LINEBUF *bp, FILE *fp)
126 + {
127 +        static int      doneWarn = 0;
128 +
129 +        bp->len = 0;
130 +        if (!bp->str) {
131 +                bp->str = (char *)malloc(bp->siz = 512);
132 +                if (!bp->str)
133 +                        goto memerr;
134 +        }
135 +        while (fgets(bp->str + bp->len, bp->siz - bp->len, fp)) {
136 +                bp->len += strlen(bp->str + bp->len);
137 +                if (bp->str[bp->len-1] == '\n') {
138 +                        if (bp->len > 1 && bp->str[bp->len-2] == '\r') {
139 +                                bp->str[--bp->len] = '\0';
140 +                                bp->str[bp->len-1] = '\n';
141 +                        }
142 +                        if (escape_newlines && bp->len > 1 &&
143 +                                        bp->str[bp->len-2] == '\\') {
144 +                                bp->str[--bp->len] = '\0';
145 +                                bp->str[bp->len-1] = ' ';
146 +                                continue;
147 +                        }
148 +                        break;          /* found EOL */
149 +                }
150 +                if (bp->len < bp->siz - 4)
151 +                        continue;       /* at EOF? */
152 +                if (bp->siz >= MAXBUF) {
153 +                        if ((report >= REP_WARN) & !doneWarn) {
154 +                                fprintf(stderr,
155 +                        "%s: warning - input line(s) past %ld MByte limit\n",
156 +                                        progname, MAXBUF>>20);
157 +                                doneWarn++;
158 +                        }
159 +                        break;          /* return MAXBUF partial line */
160 +                }
161 +                if ((bp->siz += bp->siz/2) > MAXBUF)
162 +                        bp->siz = MAXBUF;
163 +                bp->str = (char *)realloc(bp->str, bp->siz);
164 +                if (!bp->str)
165 +                        goto memerr;
166 +        }
167 +        if (comment_c) {                /* elide comment? */
168 +                char    *cp = sskip2(bp->str,0);
169 +                if (*cp == comment_c) {
170 +                        *cp++ = '\n';
171 +                        *cp = '\0';
172 +                        bp->len = cp - bp->str;
173 +                }
174 +        }
175 +        return(bp->len);
176 + memerr:
177 +        fprintf(stderr,
178 +                "%s: out of memory in read_line() allocating %d byte buffer\n",
179 +                        progname, bp->siz);
180 +        exit(2);
181 + }
182 +
183 + /* Free line buffer */
184 + static void
185 + free_line(LINEBUF *bp)
186 + {
187 +        if (bp->str) free(bp->str);
188 +        init_line(bp);
189 + }
190 +
191   /* Get type ID from name (or 0 if not found) */
192   static int
193   xlate_type(const char *nm)
# Line 117 | Line 210 | real_check(double r1, double r2)
210  
211          if (rel_min > 0) {      /* doing relative differences? */
212                  double  av2 = .25*(r1*r1 + 2.*fabs(r1*r2) + r2*r2);
213 <                if (av2 > rel_min*rel_min)
214 <                        diff2 /= av2;
213 >                if (av2 < rel_min*rel_min)
214 >                        av2 = rel_min*rel_min;
215 >                diff2 /= av2;
216          }
217          if (max_lim >= 0 && diff2 > max_lim*max_lim) {
218                  if (report != REP_QUIET)
# Line 140 | Line 234 | color_check(COLOR c1, COLOR c2)
234   {
235          int     p;
236  
237 <        if (!real_check(colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU)*(1./3.),
238 <                        colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.))
237 >        if (!real_check((colval(c1,RED)+colval(c1,GRN)+colval(c1,BLU))*(1./3.),
238 >                        (colval(c2,RED)+colval(c2,GRN)+colval(c2,BLU))*(1./3.)))
239                  return(0);
240  
241          p = (colval(c1,GRN) > colval(c1,RED)) ? GRN : RED;
# Line 150 | Line 244 | color_check(COLOR c1, COLOR c2)
244          return(real_check(colval(c1,p), colval(c2,p)));
245   }
246  
247 + /* Compare two normal directions for equivalence */
248 + static int
249 + norm_check(FVECT nv1, FVECT nv2)
250 + {
251 +        double  max2 = nv1[2]*nv2[2];
252 +        int     imax = 2;
253 +        int     i = 2;
254 +                                        /* identify largest component */
255 +        while (i--) {
256 +                double  tm2 = nv1[i]*nv2[i];
257 +                if (tm2 > max2) {
258 +                        imax = i;
259 +                        max2 = tm2;
260 +                }
261 +        }
262 +        i = 3;                          /* compare smaller components */
263 +        while (i--) {
264 +                if (i == imax)
265 +                        continue;
266 +                if (!real_check(nv1[i], nv2[i]))
267 +                        return(0);
268 +        }
269 +        return(1);
270 + }
271 +
272   /* Compare two strings for equivalence */
273   static int
274   equiv_string(char *s1, char *s2)
# Line 222 | Line 341 | equiv_string(char *s1, char *s2)
341   static int
342   setheadvar(char *val, void *p)
343   {
344 +        char    newval[128];
345          LUTAB   *htp = (LUTAB *)p;
346          LUENT   *tep;
347          char    *key;
# Line 231 | Line 351 | setheadvar(char *val, void *p)
351          adv_linecnt(htp);       /* side-effect is to count lines */
352          if (!isalpha(*val))     /* key must start line */
353                  return(0);
354 +                                /* check if we need to swap binary data */
355 +        if ((n = isbigendian(val)) >= 0) {
356 +                if (nativebigendian() == n)
357 +                        return(0);
358 +                f1swap += (htp == &hdr1);
359 +                f2swap += (htp == &hdr2);
360 +                return(0);
361 +        }
362          key = val++;
363          while (*val && !isspace(*val) & (*val != '='))
364                  val++;
# Line 256 | Line 384 | setheadvar(char *val, void *p)
384                  return(-1);     /* memory allocation error */
385          if (!tep->key)
386                  tep->key = strcpy(malloc(kln+1), key);
387 <        if (tep->data)
387 >        if (tep->data) {        /* check for special cases */
388 >                if (!strcmp(key, "EXPOSURE")) {
389 >                        sprintf(newval, "%.6e", atof(tep->data)*atof(val));
390 >                        vln = strlen(val = newval);
391 >                }
392                  free(tep->data);
393 +        }
394          tep->data = strcpy(malloc(vln+1), val);
395          return(1);
396   }
# Line 366 | Line 499 | identify_type(const char *name, FILE *fin, LUTAB *htp)
499          }
500          if (c)
501                  return(TYP_BINARY);
369        SET_FILE_TEXT(fin);                     /* originally set to binary */
502          return(TYP_TEXT);
503   badeof:
504          if (report != REP_QUIET) {
# Line 441 | Line 573 | compare_binary()
573          return(0);
574   }
575  
444 /* If line is continued (no newline), then back up to word boundary if one */
445 static int
446 leftover(char *buf)
447 {
448        int     minlen = strlen(buf);
449        char    *bend = buf + minlen;
450        char    *cp = bend-1;
451
452        if (*cp == '\r') *cp = '\n';            /* AARG Windoze! */
453        if (*cp == '\n')                        /* complete line? */
454                return(0);
455
456        minlen >>= 2;                           /* back over partial word */
457        while (!isspace(*cp))
458                if (--cp <= buf+minlen)
459                        return(0);
460        *cp++ = '\0';                           /* break line here */
461        return(bend - cp);
462 }
463
576   /* Compare two inputs as generic text files */
577   static int
578   compare_text()
579   {
580 <        char    l1buf[4096], l2buf[4096];
469 <        int     l1over=0, l2over=0;
580 >        LINEBUF l1buf, l2buf;
581  
582          if (report >= REP_VERBOSE) {
583                  fputs(progname, stdout);
584 <                fputs(": comparing inputs as ASCII text\n", stdout);
584 >                fputs(": comparing inputs as ASCII text", stdout);
585 >                if (escape_newlines)
586 >                        fputs(", allowing escaped newlines", stdout);
587 >                if (comment_c) {
588 >                        fputs(", ignoring comments starting with '", stdout);
589 >                        fputc(comment_c, stdout);
590 >                        fputc('\'', stdout);
591 >                }
592 >                fputc('\n', stdout);
593          }
594 <                                                /* compare a line at a time */
595 <        while (fgets(l1buf+l1over, sizeof(l1buf)-l1over, f1in)) {
596 <                lin1cnt += !(l1over = leftover(l1buf));
597 <                if (!*sskip2(l1buf,0)) {
598 <                        memmove(l1buf, l1buf+sizeof(l1buf)-l1over, l1over);
594 >        SET_FILE_TEXT(f1in);                    /* originally set to binary */
595 >        SET_FILE_TEXT(f2in);
596 >        init_line(&l1buf); init_line(&l2buf);   /* compare a line at a time */
597 >        while (read_line(&l1buf, f1in)) {
598 >                lin1cnt++;
599 >                if (!*sskip2(l1buf.str,0))
600                          continue;               /* ignore empty lines */
601 <                }
602 <                while (fgets(l2buf+l2over, sizeof(l2buf)-l2over, f2in)) {
603 <                        lin2cnt += !(l2over = leftover(l2buf));
604 <                        if (*sskip2(l2buf,0))
601 >
602 >                while (read_line(&l2buf, f2in)) {
603 >                        lin2cnt++;
604 >                        if (*sskip2(l2buf.str,0))
605                                  break;          /* found other non-empty line */
486                        memmove(l2buf, l2buf+sizeof(l2buf)-l2over, l2over);
606                  }
607 <                if (feof(f2in)) {
607 >                if (!l2buf.len) {               /* input 2 EOF? */
608                          if (report != REP_QUIET) {
609                                  fputs(f2name, stdout);
610                                  fputs(": unexpected end-of-file\n", stdout);
611                          }
612 +                        free_line(&l1buf); free_line(&l2buf);
613                          return(0);
614                  }
615                                                  /* compare non-empty lines */
616 <                if (!equiv_string(l1buf, l2buf)) {
616 >                if (!equiv_string(l1buf.str, l2buf.str)) {
617                          if (report != REP_QUIET) {
618 <                                printf("%s: inputs '%s' and '%s' differ at line %d|%d\n",
619 <                                                progname, f1name, f2name,
620 <                                                lin1cnt, lin2cnt);
621 <                                if (report >= REP_VERBOSE) {
618 >                                printf("%s: inputs '%s' and '%s' differ at line %d",
619 >                                                progname, f1name, f2name, lin1cnt);
620 >                                if (lin1cnt != lin2cnt)
621 >                                        printf("|%d\n", lin2cnt);
622 >                                else
623 >                                        putchar('\n');
624 >                                if ( report >= REP_VERBOSE &&
625 >                                                (l1buf.len < 256) &
626 >                                                (l2buf.len < 256) ) {
627                                          fputs("------------- Mismatch -------------\n", stdout);
628                                          printf("%s@%d:\t%s", f1name,
629 <                                                        lin1cnt, l1buf);
629 >                                                        lin1cnt, l1buf.str);
630                                          printf("%s@%d:\t%s", f2name,
631 <                                                        lin2cnt, l2buf);
631 >                                                        lin2cnt, l2buf.str);
632                                  }
633                          }
634 +                        free_line(&l1buf); free_line(&l2buf);
635                          return(0);
636                  }
511                if (l1over) memmove(l1buf, l1buf+sizeof(l1buf)-l1over, l1over);
512                if (l2over) memmove(l2buf, l2buf+sizeof(l2buf)-l2over, l2over);
637          }
638 <                                                /* check for EOF on input 2 */
639 <        while (fgets(l2buf, sizeof(l2buf), f2in)) {
640 <                if (!*sskip2(l2buf,0))
638 >        free_line(&l1buf);                      /* check for EOF on input 2 */
639 >        while (read_line(&l2buf, f2in)) {
640 >                if (!*sskip2(l2buf.str,0))
641                          continue;
642                  if (report != REP_QUIET) {
643                          fputs(f1name, stdout);
644                          fputs(": unexpected end-of-file\n", stdout);
645                  }
646 +                free_line(&l2buf);
647                  return(0);
648          }
649 +        free_line(&l2buf);
650          return(good_RMS());                     /* final check for reals */
651   }
652  
653 + /* Check image/map resolutions */
654 + static int
655 + check_resolu(const char *class, RESOLU *r1p, RESOLU *r2p)
656 + {
657 +        if (r1p->rt != r2p->rt) {
658 +                if (report != REP_QUIET)
659 +                        printf(
660 +                        "%s: %ss '%s' and '%s' have different pixel ordering\n",
661 +                                        progname, class, f1name, f2name);
662 +                return(0);
663 +        }
664 +        if ((r1p->xr != r2p->xr) | (r1p->yr != r2p->yr)) {
665 +                if (report != REP_QUIET)
666 +                        printf(
667 +                        "%s: %ss '%s' and '%s' are different sizes\n",
668 +                                        progname, class, f1name, f2name);
669 +                return(0);
670 +        }
671 +        return(1);
672 + }
673 +
674   /* Compare two inputs that are known to be RGBE or XYZE images */
675   static int
676   compare_hdr()
# Line 538 | Line 685 | compare_hdr()
685          }
686          fgetsresolu(&rs1, f1in);
687          fgetsresolu(&rs2, f2in);
688 <        if (rs1.rt != rs2.rt) {
542 <                if (report != REP_QUIET)
543 <                        printf(
544 <                        "%s: Images '%s' and '%s' have different pixel ordering\n",
545 <                                        progname, f1name, f2name);
688 >        if (!check_resolu("HDR image", &rs1, &rs2))
689                  return(0);
547        }
548        if ((rs1.xr != rs2.xr) | (rs1.yr != rs2.yr)) {
549                if (report != REP_QUIET)
550                        printf(
551                        "%s: Images '%s' and '%s' are different sizes\n",
552                                        progname, f1name, f2name);
553                return(0);
554        }
690          scan1 = (COLOR *)malloc(scanlen(&rs1)*sizeof(COLOR));
691          scan2 = (COLOR *)malloc(scanlen(&rs2)*sizeof(COLOR));
692          if (!scan1 | !scan2) {
# Line 596 | Line 731 | compare_hdr()
731          return(good_RMS());                     /* final check of RMS */
732   }
733  
734 + /* Set reference depth based on header variable */
735 + static int
736 + set_refdepth(DEPTHCODEC *dcp, LUTAB *htp)
737 + {
738 +        static char     depthvar[] = DEPTHSTR;
739 +        const char      *drval;
740 +
741 +        depthvar[LDEPTHSTR-1] = '\0';
742 +        drval = (const char *)lu_find(htp, depthvar)->data;
743 +        if (!drval)
744 +                return(0);
745 +        dcp->refdepth = atof(drval);
746 +        if (dcp->refdepth <= 0) {
747 +                if (report != REP_QUIET) {
748 +                        fputs(dcp->inpname, stderr);
749 +                        fputs(": bad reference depth '", stderr);
750 +                        fputs(drval, stderr);
751 +                        fputs("'\n", stderr);
752 +                }
753 +                return(-1);
754 +        }
755 +        return(1);
756 + }
757 +
758 + /* Compare two encoded depth maps */
759 + static int
760 + compare_depth()
761 + {
762 +        long            nread = 0;
763 +        DEPTHCODEC      dc1, dc2;
764 +
765 +        if (report >= REP_VERBOSE) {
766 +                fputs(progname, stdout);
767 +                fputs(": comparing inputs as depth maps\n", stdout);
768 +        }
769 +        set_dc_defaults(&dc1);
770 +        dc1.hdrflags = HF_RESIN;
771 +        dc1.finp = f1in;
772 +        dc1.inpname = f1name;
773 +        set_dc_defaults(&dc2);
774 +        dc2.hdrflags = HF_RESIN;
775 +        dc2.finp = f2in;
776 +        dc2.inpname = f2name;
777 +        if (report != REP_QUIET) {
778 +                dc1.hdrflags |= HF_STDERR;
779 +                dc2.hdrflags |= HF_STDERR;
780 +        }
781 +        if (!process_dc_header(&dc1, 0, NULL))
782 +                return(0);
783 +        if (!process_dc_header(&dc2, 0, NULL))
784 +                return(0);
785 +        if (!check_resolu("Depth map", &dc1.res, &dc2.res))
786 +                return(0);
787 +        if (set_refdepth(&dc1, &hdr1) < 0)
788 +                return(0);
789 +        if (set_refdepth(&dc2, &hdr2) < 0)
790 +                return(0);
791 +        while (nread < dc1.res.xr*dc1.res.yr) {
792 +                double  d1 = decode_depth_next(&dc1);
793 +                double  d2 = decode_depth_next(&dc2);
794 +                if ((d1 < 0) | (d2 < 0)) {
795 +                        if (report != REP_QUIET)
796 +                                printf("%s: unexpected end-of-file\n",
797 +                                                progname);
798 +                        return(0);
799 +                }
800 +                ++nread;
801 +                if (real_check(d1, d2))
802 +                        continue;
803 +                if (report != REP_QUIET)
804 +                        printf("%s: %ld%s depth values differ\n",
805 +                                        progname, nread, num_sfx(nread));
806 +                return(0);
807 +        }
808 +        return(good_RMS());             /* final check of RMS */
809 + }
810 +
811 + /* Compare two encoded normal maps */
812 + static int
813 + compare_norm()
814 + {
815 +        long            nread = 0;
816 +        NORMCODEC       nc1, nc2;
817 +
818 +        if (report >= REP_VERBOSE) {
819 +                fputs(progname, stdout);
820 +                fputs(": comparing inputs as normal maps\n", stdout);
821 +        }
822 +        set_nc_defaults(&nc1);
823 +        nc1.hdrflags = HF_RESIN;
824 +        nc1.finp = f1in;
825 +        nc1.inpname = f1name;
826 +        set_nc_defaults(&nc2);
827 +        nc2.hdrflags = HF_RESIN;
828 +        nc2.finp = f2in;
829 +        nc2.inpname = f2name;
830 +        if (report != REP_QUIET) {
831 +                nc1.hdrflags |= HF_STDERR;
832 +                nc2.hdrflags |= HF_STDERR;
833 +        }
834 +        if (!process_nc_header(&nc1, 0, NULL))
835 +                return(0);
836 +        if (!process_nc_header(&nc2, 0, NULL))
837 +                return(0);
838 +        if (!check_resolu("Normal map", &nc1.res, &nc2.res))
839 +                return(0);
840 +        while (nread < nc1.res.xr*nc1.res.yr) {
841 +                FVECT   nv1, nv2;
842 +                int     rv1 = decode_normal_next(nv1, &nc1);
843 +                int     rv2 = decode_normal_next(nv2, &nc2);
844 +                if ((rv1 < 0) | (rv2 < 0)) {
845 +                        if (report != REP_QUIET)
846 +                                printf("%s: unexpected end-of-file\n",
847 +                                                progname);
848 +                        return(0);
849 +                }
850 +                ++nread;
851 +                if (rv1 == rv2 && (!rv1 || norm_check(nv1, nv2)))
852 +                        continue;
853 +                if (report != REP_QUIET)
854 +                        printf("%s: %ld%s normal vectors differ\n",
855 +                                        progname, nread, num_sfx(nread));
856 +                return(0);
857 +        }
858 +        return(good_RMS());             /* final check of RMS */
859 + }
860 +
861   /* Compare two inputs that are known to be 32-bit floating-point data */
862   static int
863   compare_float()
# Line 611 | Line 873 | compare_float()
873                  if (!getbinary(&f2, sizeof(f2), 1, f2in))
874                          goto badeof;
875                  ++nread;
876 +                if (f1swap) swap32((char *)&f1, 1);
877 +                if (f2swap) swap32((char *)&f2, 1);
878                  if (real_check(f1, f2))
879                          continue;
880                  if (report != REP_QUIET)
# Line 641 | Line 905 | compare_double()
905                  if (!getbinary(&f2, sizeof(f2), 1, f2in))
906                          goto badeof;
907                  ++nread;
908 +                if (f1swap) swap64((char *)&f1, 1);
909 +                if (f2swap) swap64((char *)&f2, 1);
910                  if (real_check(f1, f2))
911                          continue;
912                  if (report != REP_QUIET)
# Line 669 | Line 935 | main(int argc, char *argv[])
935                  case 'h':                       /* ignore header info. */
936                          ign_header = !ign_header;
937                          continue;
938 +                case 'n':                       /* allow newline escapes */
939 +                        escape_newlines = !escape_newlines;
940 +                        continue;
941 +                case 'c':                       /* ignore comments */
942 +                        comment_c = argv[a][2];
943 +                        continue;
944                  case 's':                       /* silent operation */
945                          report = REP_QUIET;
946                          continue;
# Line 729 | Line 1001 | main(int argc, char *argv[])
1001                  return(2);
1002          if (typ1 != typ2) {
1003                  if (report != REP_QUIET)
1004 <                        printf("%s: '%s' is %s and '%s' is %s\n",
1004 >                        printf("%s: '%s' format is %s and '%s' is %s\n",
1005                                          progname, f1name, file_type[typ1],
1006                                          f2name, file_type[typ2]);
1007                  return(1);
# Line 737 | Line 1009 | main(int argc, char *argv[])
1009          ign_header |= !has_header(typ1);        /* check headers if indicated */
1010          if (!ign_header && !headers_match())
1011                  return(1);
740        lu_done(&hdr1); lu_done(&hdr2);
1012          if (!ign_header & (report >= REP_WARN)) {
742                if (typ1 == TYP_UNKNOWN)
743                        printf("%s: warning - unrecognized format, comparing as binary\n",
744                                        progname);
1013                  if (lin1cnt != lin2cnt)
1014                          printf("%s: warning - headers are different lengths\n",
1015                                          progname);
1016 +                if (typ1 == TYP_UNKNOWN)
1017 +                        printf("%s: warning - unrecognized format\n",
1018 +                                        progname);
1019          }
1020 <        if (report >= REP_VERBOSE)
1021 <                printf("%s: input file type is %s\n",
1022 <                                progname, file_type[typ1]);
1023 <
1020 >        if (report >= REP_VERBOSE) {
1021 >                printf("%s: data format is %s\n", progname, file_type[typ1]);
1022 >                if ((typ1 == TYP_FLOAT) | (typ1 == TYP_DOUBLE)) {
1023 >                        if (f1swap)
1024 >                                printf("%s: input '%s' is byte-swapped\n",
1025 >                                                progname, f1name);
1026 >                        if (f2swap)
1027 >                                printf("%s: input '%s' is byte-swapped\n",
1028 >                                                progname, f2name);
1029 >                }
1030 >        }
1031          switch (typ1) {                         /* compare based on type */
1032          case TYP_BINARY:
1033          case TYP_TMESH:
1034          case TYP_OCTREE:
1035          case TYP_RBFMESH:
1036 +        case TYP_ID8:
1037 +        case TYP_ID16:
1038 +        case TYP_ID24:
1039          case TYP_UNKNOWN:
1040                  return( !compare_binary() );
1041          case TYP_TEXT:
# Line 763 | Line 1044 | main(int argc, char *argv[])
1044          case TYP_RGBE:
1045          case TYP_XYZE:
1046                  return( !compare_hdr() );
1047 +        case TYP_DEPTH:
1048 +                return( !compare_depth() );
1049 +        case TYP_NORM:
1050 +                return( !compare_norm() );
1051          case TYP_FLOAT:
1052                  return( !compare_float() );
1053          case TYP_DOUBLE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines