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

Comparing ray/src/common/color.c (file contents):
Revision 2.20 by greg, Sat Feb 23 19:11:25 2019 UTC vs.
Revision 2.22 by greg, Sat Mar 5 17:18:02 2022 UTC

# Line 28 | Line 28 | static const char      RCSid[] = "$Id$";
28   #define  MINRUN         4       /* minimum run length */
29  
30  
31 < char *
31 > void *
32   tempbuffer(                     /* get a temporary buffer */
33          unsigned int  len
34   )
35   {
36 <        static char  *tempbuf = NULL;
37 <        static unsigned  tempbuflen = 0;
36 >        static void             *tempbuf = NULL;
37 >        static unsigned int     tempbuflen = 0;
38  
39 <        if (!len | (len > tempbuflen)) {
40 <                if (tempbuflen)
39 >        if (!len) {             /* call to free */
40 >                if (tempbuflen) {
41                          free(tempbuf);
42 <                tempbuf = len ? (char *)malloc(len) : (char *)NULL;
43 <                tempbuflen = len*(tempbuf != NULL);
42 >                        tempbuf = NULL;
43 >                        tempbuflen = 0;
44 >                }
45 >                return(NULL);
46          }
47 +        if (len <= tempbuflen)  /* big enough already? */
48 +                return(tempbuf);
49 +                                /* else free & reallocate */
50 +        if (tempbuflen)
51 +                free(tempbuf);
52 +        tempbuf = malloc(len);
53 +        tempbuflen = len*(tempbuf != NULL);
54          return(tempbuf);
55   }
56  
# Line 62 | Line 71 | fwritecolrs(                   /* write out a colr scanline */
71          putc(2, fp);
72          putc(2, fp);
73          putc(len>>8, fp);
74 <        putc(len&255, fp);
74 >        putc(len&0xff, fp);
75                                          /* put components seperately */
76          for (i = 0; i < 4; i++) {
77              for (j = 0; j < len; j += cnt) {    /* find next run */
# Line 160 | Line 169 | freadcolrs(                    /* read in an encoded colr scanline */
169          scanline[0][BLU] = getc(fp);
170          if ((i = getc(fp)) == EOF)
171                  return(-1);
172 <        if (scanline[0][GRN] != 2 || scanline[0][BLU] & 128) {
172 >        if ((scanline[0][GRN] != 2) | ((scanline[0][BLU] & 0x80) != 0)) {
173                  scanline[0][RED] = 2;
174                  scanline[0][EXP] = i;
175                  return(oldreadcolrs(scanline+1, len-1, fp));
# Line 270 | Line 279 | setcolr(                       /* assign a short color value */
279                  return;
280          }
281  
282 <        d = frexp(d, &e) * 255.9999 / d;
282 >        d = frexp(d, &e) * 256.0 / d;
283  
284          if (r > 0.0)
285                  clr[RED] = r * d;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines