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.6 by greg, Fri Jan 10 01:02:14 2020 UTC vs.
Revision 2.12 by greg, Thu Mar 3 16:09:31 2022 UTC

# Line 26 | Line 26 | depth2code(double d, double dref)
26          if (d > dref)
27                  return (int)(32768.001 - 32768.*dref/d) - 1;
28  
29 <        return (int)(32767.*d/dref - 32768.);
29 >        return (int)(32767.*d/dref - 32768.999);
30   }
31   #endif
32  
# Line 42 | Line 42 | code2depth(int c, double dref)
42          if (c >= 32767)
43                  return FHUGE;
44  
45 <        if (c >= 0)
45 >        if (c >= -1)
46                  return dref*32768./(32766.5 - c);
47  
48 <        return dref*(32767.5 + c)*(1./32767.);
48 >        return dref*(32768.5 + c)*(1./32767.);
49   }
50   #endif
51  
# Line 97 | Line 97 | headline(char *s, void *p)
97                          }
98                          return -1;
99                  }
100 +                if (dcp->hdrflags & HF_ENCODE)
101 +                        return 0;       /* will add this later */
102          } else if (!strncmp(s, "SAMP360=", 8))
103                  dcp->gotview--;
104          else if (isview(s))             /* get view params */
# Line 120 | Line 122 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
122                  return 0;
123          }
124          dcp->gotview *= (dcp->gotview > 0);
125 +                                        /* get resolution string? */
126 +        if (dcp->hdrflags & HF_RESIN && !fgetsresolu(&dcp->res, dcp->finp)) {
127 +                if (dcp->hdrflags & HF_STDERR) {
128 +                        fputs(dcp->inpname, stderr);
129 +                        fputs(": bad resolution string\n", stderr);
130 +                }
131 +                return 0;
132 +        }
133          if (dcp->hdrflags & HF_HEADOUT) {       /* finish header */
134                  if (!(dcp->hdrflags & HF_HEADIN))
135                          newheader("RADIANCE", stdout);
# Line 130 | Line 140 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
140                          fputs(dcp->depth_unit, stdout);
141                          fputc('\n', stdout);
142                          fputformat(DEPTH16FMT, stdout);
143 <                } else
143 >                } else {
144 >                        fputs("NCOMP=1\n", stdout);
145 >                        if ((dcp->hdrflags & (HF_RESIN|HF_RESOUT)) == HF_RESIN)
146 >                                printf("NCOLS=%d\nNROWS=%d\n",
147 >                                                scanlen(&dcp->res),
148 >                                                numscans(&dcp->res));
149                          switch (dcp->format) {
150                          case 'a':
151                                  fputformat("ascii", stdout);
# Line 144 | Line 159 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
159                                  fputformat("double", stdout);
160                                  break;
161                          }
162 +                }
163                  fputc('\n', stdout);
164          }
165 <                                        /* get/put resolution string */
150 <        if (dcp->hdrflags & HF_RESIN && !fgetsresolu(&dcp->res, dcp->finp)) {
151 <                if (dcp->hdrflags & HF_STDERR) {
152 <                        fputs(dcp->inpname, stderr);
153 <                        fputs(": bad resolution string\n", stderr);
154 <                }
155 <                return 0;
156 <        }
157 <        if (dcp->hdrflags & HF_RESOUT)
165 >        if (dcp->hdrflags & HF_RESOUT)  /* put resolution string? */
166                  fputsresolu(&dcp->res, stdout);
167  
168          dcp->dstart = dcp->curpos = ftell(dcp->finp);
# Line 250 | Line 258 | compute_worldpos(FVECT wpos, DEPTHCODEC *dcp, int x, i
258          RREAL   loc[2];
259          FVECT   rdir;
260  
261 +        if (d >= FHUGE*.99)
262 +                goto badval;
263 +
264          pix2loc(loc, &dcp->res, x, y);
265  
266 <        if (viewray(wpos, rdir, &dcp->vw, loc[0], loc[1]) < -FTINY) {
267 <                VCOPY(wpos, dcp->vw.vp);
268 <                return 0;
266 >        if (viewray(wpos, rdir, &dcp->vw, loc[0], loc[1]) >= -FTINY) {
267 >                VSUM(wpos, wpos, rdir, d);
268 >                return 1;
269          }
270 <        VSUM(wpos, wpos, rdir, d);
271 <        return 1;
270 > badval:
271 >        VCOPY(wpos, dcp->vw.vp);
272 >        return 0;
273   }
274  
275  
# Line 317 | Line 329 | seek_dc_pix(DEPTHCODEC *dcp, int x, int y)
329                  return -1;
330          }
331          dcp->curpos = seekpos;
332 +        dcp->use_last = 0;
333          return 1;
334   }
335  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines