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

Comparing ray/src/common/normcodec.c (file contents):
Revision 2.2 by greg, Fri Jul 26 17:04:12 2019 UTC vs.
Revision 2.5 by greg, Thu Nov 7 23:20:28 2019 UTC

# Line 30 | Line 30 | static int
30   headline(char *s, void *p)
31   {
32          NORMCODEC       *ncp = (NORMCODEC *)p;
33 +        int             rv;
34  
35          if (formatval(ncp->inpfmt, s))  /* don't pass format */
36                  return 0;
37  
38 +        if ((rv = isbigendian(s)) >= 0) {
39 +                ncp->swapped = (nativebigendian() != rv);
40 +                return 0;
41 +        }
42          if (ncp->hdrflags & HF_HEADOUT)
43                  fputs(s, stdout);       /* copy to standard output */
44          return 1;
# Line 65 | Line 70 | process_nc_header(NORMCODEC *ncp, int ac, char *av[])
70                                  fputformat("ascii", stdout);
71                                  break;
72                          case 'f':
73 +                                fputendian(stdout);
74                                  fputformat("float", stdout);
75                                  break;
76                          case 'd':
77 +                                fputendian(stdout);
78                                  fputformat("double", stdout);
79                                  break;
80                          }
# Line 117 | Line 124 | check_decode_normals(NORMCODEC *ncp)
124   int
125   decode_normal_next(FVECT nrm, NORMCODEC *ncp)
126   {
127 <        int32   c = getint(4, ncp->finp);
127 >        static int32    lastc;
128 >        static FVECT    lastv;
129 >        int32           c = getint(4, ncp->finp);
130  
131          if (c == EOF && feof(ncp->finp))
132                  return -1;
133  
134          ncp->curpos += 4;
135  
136 <        decodedir(nrm, c);
137 <
136 >        if (c == lastc) {                       /* optimization */
137 >                VCOPY(nrm, lastv);
138 >        } else {
139 >                decodedir(nrm, c);
140 >                if (c) {
141 >                        lastc = c;
142 >                        VCOPY(lastv, nrm);
143 >                }
144 >        }
145          return (c != 0);
146   }
147  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines