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.19 by greg, Wed Aug 14 04:18:12 2019 UTC vs.
Revision 2.22 by greg, Sat Aug 24 02:22:02 2019 UTC

# Line 99 | Line 99 | 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;
# Line 223 | Line 224 | color_check(COLOR c1, COLOR c2)
224   static int
225   norm_check(FVECT nv1, FVECT nv2)
226   {
227 <        double  max2 = nv1[2]*nv1[2];
227 >        double  max2 = nv1[2]*nv2[2];
228          int     imax = 2;
229          int     i = 2;
230                                          /* identify largest component */
231          while (i--) {
232 <                double  tm2 = nv1[i]*nv1[i];
232 >                double  tm2 = nv1[i]*nv2[i];
233                  if (tm2 > max2) {
234                          imax = i;
235                          max2 = tm2;
# Line 325 | Line 326 | setheadvar(char *val, void *p)
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++;
# Line 822 | Line 831 | 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)
# Line 852 | Line 863 | compare_double()
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)
# Line 940 | Line 953 | main(int argc, char *argv[])
953                  return(2);
954          if (typ1 != typ2) {
955                  if (report != REP_QUIET)
956 <                        printf("%s: '%s' is %s and '%s' is %s\n",
956 >                        printf("%s: '%s' format is %s and '%s' is %s\n",
957                                          progname, f1name, file_type[typ1],
958                                          f2name, file_type[typ2]);
959                  return(1);
# Line 956 | Line 969 | main(int argc, char *argv[])
969                          printf("%s: warning - unrecognized format\n",
970                                          progname);
971          }
972 <        if (report >= REP_VERBOSE)
973 <                printf("%s: input file type is %s\n",
974 <                                progname, file_type[typ1]);
975 <
972 >        if (report >= REP_VERBOSE) {
973 >                printf("%s: data format is %s\n", progname, file_type[typ1]);
974 >                if ((typ1 == TYP_FLOAT) | (typ1 == TYP_DOUBLE)) {
975 >                        if (f1swap)
976 >                                printf("%s: input '%s' is byte-swapped\n",
977 >                                                progname, f1name);
978 >                        if (f2swap)
979 >                                printf("%s: input '%s' is byte-swapped\n",
980 >                                                progname, f2name);
981 >                }
982 >        }
983          switch (typ1) {                         /* compare based on type */
984          case TYP_BINARY:
985          case TYP_TMESH:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines