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.9 by greg, Wed Feb 12 01:11:39 2020 UTC vs.
Revision 2.13 by greg, Thu Sep 22 21:45:28 2022 UTC

# Line 80 | Line 80 | headline(char *s, void *p)
80                  dcp->swapped = (nativebigendian() != rv);
81                  return 0;
82          }
83 <                                        /* check for reference depth */
83 >        if (!strncmp(s, "NCOMP=", 6)) {
84 >                if (atoi(s+6) != 1) {
85 >                        if (dcp->hdrflags & HF_STDERR) {
86 >                                fputs(dcp->inpname, stderr);
87 >                                fputs(": NCOMP must equal 1\n", stderr);
88 >                        }
89 >                        return -1;
90 >                }
91 >                return 0;
92 >        }
93 >        if (!strncmp(s, "NROWS=", 6)) {
94 >                dcp->res.yr = atoi(s+6);
95 >                return 0;
96 >        }
97 >        if (!strncmp(s, "NCOLS=", 6)) {
98 >                dcp->res.xr = atoi(s+6);
99 >                return 0;
100 >        }
101 >                                                /* check for reference depth */
102          if (!strncmp(s, DEPTHSTR, LDEPTHSTR)) {
103                  char    *cp;
104                  strlcpy(dcp->depth_unit, s+LDEPTHSTR, sizeof(dcp->depth_unit));
# Line 122 | Line 140 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
140                  return 0;
141          }
142          dcp->gotview *= (dcp->gotview > 0);
143 +                                        /* get resolution string? */
144 +        if (dcp->hdrflags & HF_RESIN &&
145 +                        (dcp->res.xr <= 0) | (dcp->res.yr <= 0) &&
146 +                        !fgetsresolu(&dcp->res, dcp->finp)) {
147 +                if (dcp->hdrflags & HF_STDERR) {
148 +                        fputs(dcp->inpname, stderr);
149 +                        fputs(": bad resolution string\n", stderr);
150 +                }
151 +                return 0;
152 +        }
153          if (dcp->hdrflags & HF_HEADOUT) {       /* finish header */
154                  if (!(dcp->hdrflags & HF_HEADIN))
155                          newheader("RADIANCE", stdout);
# Line 132 | Line 160 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
160                          fputs(dcp->depth_unit, stdout);
161                          fputc('\n', stdout);
162                          fputformat(DEPTH16FMT, stdout);
163 <                } else
163 >                } else {
164 >                        fputs("NCOMP=1\n", stdout);
165 >                        if ((dcp->hdrflags & (HF_RESIN|HF_RESOUT)) == HF_RESIN)
166 >                                printf("NCOLS=%d\nNROWS=%d\n",
167 >                                                scanlen(&dcp->res),
168 >                                                numscans(&dcp->res));
169                          switch (dcp->format) {
170                          case 'a':
171                                  fputformat("ascii", stdout);
# Line 146 | Line 179 | process_dc_header(DEPTHCODEC *dcp, int ac, char *av[])
179                                  fputformat("double", stdout);
180                                  break;
181                          }
182 +                }
183                  fputc('\n', stdout);
184          }
185 <                                        /* get/put resolution string */
152 <        if (dcp->hdrflags & HF_RESIN && !fgetsresolu(&dcp->res, dcp->finp)) {
153 <                if (dcp->hdrflags & HF_STDERR) {
154 <                        fputs(dcp->inpname, stderr);
155 <                        fputs(": bad resolution string\n", stderr);
156 <                }
157 <                return 0;
158 <        }
159 <        if (dcp->hdrflags & HF_RESOUT)
185 >        if (dcp->hdrflags & HF_RESOUT)  /* put resolution string? */
186                  fputsresolu(&dcp->res, stdout);
187  
188          dcp->dstart = dcp->curpos = ftell(dcp->finp);
# Line 252 | Line 278 | compute_worldpos(FVECT wpos, DEPTHCODEC *dcp, int x, i
278          RREAL   loc[2];
279          FVECT   rdir;
280  
281 +        if (d >= FHUGE*.99)
282 +                goto badval;
283 +
284          pix2loc(loc, &dcp->res, x, y);
285  
286 <        if (viewray(wpos, rdir, &dcp->vw, loc[0], loc[1]) < -FTINY) {
287 <                VCOPY(wpos, dcp->vw.vp);
288 <                return 0;
286 >        if (viewray(wpos, rdir, &dcp->vw, loc[0], loc[1]) >= -FTINY) {
287 >                VSUM(wpos, wpos, rdir, d);
288 >                return 1;
289          }
290 <        VSUM(wpos, wpos, rdir, d);
291 <        return 1;
290 > badval:
291 >        VCOPY(wpos, dcp->vw.vp);
292 >        return 0;
293   }
294  
295  
# Line 319 | Line 349 | seek_dc_pix(DEPTHCODEC *dcp, int x, int y)
349                  return -1;
350          }
351          dcp->curpos = seekpos;
352 +        dcp->use_last = 0;
353          return 1;
354   }
355  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines