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

Comparing ray/src/util/cmatrix.c (file contents):
Revision 2.25 by greg, Wed Mar 25 01:51:09 2020 UTC vs.
Revision 2.26 by greg, Thu Mar 26 02:48:31 2020 UTC

# Line 21 | Line 21 | const char     *cm_fmt_id[] = {
21                  };
22  
23   const int       cm_elem_size[] = {
24 <                        0, 0, 4, 4, 3*sizeof(float), 3*sizeof(double)
24 >                        0, 4, 4, 3*sizeof(float), 0, 3*sizeof(double)
25                  };
26  
27   /* Allocate a color coefficient matrix */
# Line 333 | Line 333 | cm_load(const char *inspec, int nrows, int ncols, int
333                                          goto EOFerror;
334                          } while (nread < cm->nrows*cm->ncols);
335  
336 +                        if (swap) {
337 +                                if (sizeof(COLORV) == 4)
338 +                                        swap32((char *)cm->cmem,
339 +                                                        3*cm->nrows*cm->ncols);
340 +                                else /* sizeof(COLORV) == 8 */
341 +                                        swap64((char *)cm->cmem,
342 +                                                        3*cm->nrows*cm->ncols);
343 +                        }
344                  } else if (dtype == DTdouble) {
345                          double  dc[3];                  /* load from double */
346                          COLORV  *cvp = cm->cmem;
# Line 343 | Line 351 | cm_load(const char *inspec, int nrows, int ncols, int
351                          while (n--) {
352                                  if (getbinary(dc, sizeof(double), 3, fp) != 3)
353                                          goto EOFerror;
354 +                                if (swap) swap64((char *)dc, 3);
355                                  copycolor(cvp, dc);
356                                  cvp += 3;
357                          }
# Line 356 | Line 365 | cm_load(const char *inspec, int nrows, int ncols, int
365                          while (n--) {
366                                  if (getbinary(fc, sizeof(float), 3, fp) != 3)
367                                          goto EOFerror;
368 +                                if (swap) swap32((char *)fc, 3);
369                                  copycolor(cvp, fc);
370                                  cvp += 3;
371                          }
# Line 366 | Line 376 | cm_load(const char *inspec, int nrows, int ncols, int
376                                                  inspec);
377                                  error(WARNING, errmsg);
378                  }
369        }
370        if (swap) {
371                if (dtype == DTfloat)
372                        swap32((char *)cm->cmem, 3*cm->nrows*cm->ncols);
373                else if (dtype == DTdouble)
374                        swap64((char *)cm->cmem, 3*cm->nrows*cm->ncols);
379          }
380   cleanup:
381          if (fp != stdin) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines