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

Comparing ray/src/common/depthcodec.c (file contents):
Revision 2.2 by greg, Fri Jul 26 17:04:12 2019 UTC vs.
Revision 2.4 by greg, Wed Aug 14 21:00:14 2019 UTC

# Line 16 | Line 16 | static const char RCSid[] = "$Id$";
16   #include "depthcodec.h"
17  
18  
19 < #if 0                   /* defined as macro in depthcodec.h */
19 > #ifndef depth2code
20   /* Encode depth as 16-bit signed integer */
21   int
22   depth2code(double d, double dref)
# Line 25 | Line 25 | depth2code(double d, double dref)
25                  return -32768;
26  
27          if (d > dref)
28 <                return (int)(32768 - 32768*dref/d) - 1;
28 >                return (int)(32768.001 - 32768.*dref/d) - 1;
29  
30 <        return (int)(32767*d/dref - 32768);
30 >        return (int)(32767.*d/dref - 32768.);
31   }
32   #endif
33  
34  
35 + #ifndef code2depth
36   /* Decode depth from 16-bit signed integer */
37   double
38   code2depth(int c, double dref)
# Line 47 | Line 48 | code2depth(int c, double dref)
48          
49          return dref*32768./(32766.5 - c);
50   }
51 + #endif
52  
53  
54   /* Set codec defaults */
# Line 57 | Line 59 | set_dc_defaults(DEPTHCODEC *dcp)
59          dcp->finp = stdin;
60          dcp->inpname = "<stdin>";
61          dcp->format = 'a';
62 +        dcp->swapped = 0;
63          dcp->refdepth = 1.;
64          dcp->depth_unit[0] = '1';
65          dcp->vw = stdview;
# Line 70 | Line 73 | static int
73   headline(char *s, void *p)
74   {
75          DEPTHCODEC      *dcp = (DEPTHCODEC *)p;
76 +        int             rv;
77  
78          if (formatval(dcp->inpfmt, s))  /* don't pass format */
79                  return 0;
80 +
81 +        if ((rv = isbigendian(s)) >= 0) {
82 +                dcp->swapped = (nativebigendian() != rv);
83 +                return 0;
84 +        }
85                                          /* check for reference depth */
86          if (!strncmp(s, DEPTHSTR, LDEPTHSTR)) {
87                  char    *cp;
# Line 126 | Line 135 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
135                                  fputformat("ascii", stdout);
136                                  break;
137                          case 'f':
138 +                                fputendian(stdout);
139                                  fputformat("float", stdout);
140                                  break;
141                          case 'd':
142 +                                fputendian(stdout);
143                                  fputformat("double", stdout);
144                                  break;
145                          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines