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.4 by greg, Wed Aug 14 21:00:14 2019 UTC vs.
Revision 2.5 by greg, Thu Nov 7 23:20:28 2019 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   #include "copyright.h"
9  
10   #include <stdlib.h>
11 #include <string.h>
11   #include <math.h>
12   #include <ctype.h>
13   #include "rtio.h"
# Line 42 | Line 41 | code2depth(int c, double dref)
41  
42          if (c >= 32767)
43                  return FHUGE;
44 <                
45 <        if (c < 0)
46 <                return dref*(32767.5 + c)*(1./32767.);
47 <        
48 <        return dref*32768./(32766.5 - c);
44 >
45 >        if (c >= 0)
46 >                return dref*32768./(32766.5 - c);
47 >
48 >        return dref*(32767.5 + c)*(1./32767.);
49   }
50   #endif
51  
# Line 59 | Line 58 | set_dc_defaults(DEPTHCODEC *dcp)
58          dcp->finp = stdin;
59          dcp->inpname = "<stdin>";
60          dcp->format = 'a';
62        dcp->swapped = 0;
61          dcp->refdepth = 1.;
62          dcp->depth_unit[0] = '1';
63          dcp->vw = stdview;
# Line 224 | Line 222 | check_decode_worldpos(DEPTHCODEC *dcp)
222   double
223   decode_depth_next(DEPTHCODEC *dcp)
224   {
225 <        int     c = getint(2, dcp->finp);
225 >        int     c;
226  
227 +        if (dcp->use_last) {
228 +                dcp->use_last = 0;
229 +                return code2depth(dcp->last_dc, dcp->refdepth);
230 +        }
231 +        c = getint(2, dcp->finp);
232 +
233          if (c == EOF && feof(dcp->finp))
234                  return -1.;
235  
236 +        dcp->last_dc = c;
237          dcp->curpos += 2;
238  
239          return code2depth(c, dcp->refdepth);
# Line 296 | Line 301 | seek_dc_pix(DEPTHCODEC *dcp, int x, int y)
301          }
302          seekpos = dcp->dstart + 2*((long)y*scanlen(&dcp->res) + x);
303  
304 +        if (seekpos == dcp->curpos-2) {
305 +                dcp->use_last++;        /* avoids seek/read */
306 +                return 1;
307 +        }
308          if (seekpos != dcp->curpos &&
309                          fseek(dcp->finp, seekpos, SEEK_SET) == EOF) {
310                  if (dcp->hdrflags & HF_STDERR) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines