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.19 by greg, Tue Apr 10 23:42:52 2018 UTC vs.
Revision 2.20 by greg, Sat Feb 23 19:11:25 2019 UTC

# Line 36 | Line 36 | tempbuffer(                    /* get a temporary buffer */
36          static char  *tempbuf = NULL;
37          static unsigned  tempbuflen = 0;
38  
39 <        if (len > tempbuflen) {
40 <                if (tempbuflen > 0)
41 <                        tempbuf = (char *)realloc((void *)tempbuf, len);
42 <                else
43 <                        tempbuf = (char *)malloc(len);
44 <                tempbuflen = tempbuf==NULL ? 0 : len;
39 >        if (!len | (len > tempbuflen)) {
40 >                if (tempbuflen)
41 >                        free(tempbuf);
42 >                tempbuf = len ? (char *)malloc(len) : (char *)NULL;
43 >                tempbuflen = len*(tempbuf != NULL);
44          }
45          return(tempbuf);
46   }
# Line 68 | Line 67 | fwritecolrs(                   /* write out a colr scanline */
67          for (i = 0; i < 4; i++) {
68              for (j = 0; j < len; j += cnt) {    /* find next run */
69                  for (beg = j; beg < len; beg += cnt) {
70 <                    for (cnt = 1; cnt < 127 && beg+cnt < len &&
70 >                    for (cnt = 1; (cnt < 127) & (beg+cnt < len) &&
71                              scanline[beg+cnt][i] == scanline[beg][i]; cnt++)
72                          ;
73                      if (cnt >= MINRUN)
74                          break;                  /* long enough */
75                  }
76 <                if (beg-j > 1 && beg-j < MINRUN) {
76 >                if ((beg-j > 1) & (beg-j < MINRUN)) {
77                      c2 = j+1;
78                      while (scanline[c2++][i] == scanline[j][i])
79                          if (c2 == beg) {        /* short run */
# Line 118 | Line 117 | oldreadcolrs(                  /* read in an old-style colr scanline
117                  scanline[0][EXP] = i = getc(fp);
118                  if (i == EOF)
119                          return(-1);
120 <                if (scanline[0][RED] == 1 &&
121 <                                scanline[0][GRN] == 1 &&
122 <                                scanline[0][BLU] == 1) {
123 <                        for (i = scanline[0][EXP] << rshift; i > 0; i--) {
120 >                if (scanline[0][GRN] == 1 &&
121 >                                (scanline[0][RED] == 1) &
122 >                                (scanline[0][BLU] == 1)) {
123 >                        i = scanline[0][EXP] << rshift;
124 >                        while (i--) {
125                                  copycolr(scanline[0], scanline[-1]);
126 +                                if (--len <= 0)
127 +                                        return(0);
128                                  scanline++;
127                                len--;
129                          }
130                          rshift += 8;
131                  } else {
# Line 237 | Line 238 | freadscan(                     /* read in a scanline */
238          colr_color(scanline[0], clrscan[0]);
239          while (--len > 0) {
240                  scanline++; clrscan++;
241 <                if (clrscan[0][RED] == clrscan[-1][RED] &&
242 <                            clrscan[0][GRN] == clrscan[-1][GRN] &&
243 <                            clrscan[0][BLU] == clrscan[-1][BLU] &&
244 <                            clrscan[0][EXP] == clrscan[-1][EXP])
241 >                if (clrscan[0][GRN] == clrscan[-1][GRN] &&
242 >                            (clrscan[0][RED] == clrscan[-1][RED]) &
243 >                            (clrscan[0][BLU] == clrscan[-1][BLU]) &
244 >                            (clrscan[0][EXP] == clrscan[-1][EXP]))
245                          copycolor(scanline[0], scanline[-1]);
246                  else
247                          colr_color(scanline[0], clrscan[0]);
# Line 318 | Line 319 | bigdiff(                               /* c1 delta c2 > md? */
319  
320          for (i = 0; i < 3; i++)
321                  if (colval(c1,i)-colval(c2,i) > md*colval(c2,i) ||
322 <                        colval(c2,i)-colval(c1,i) > md*colval(c1,i))
322 >                                colval(c2,i)-colval(c1,i) > md*colval(c1,i))
323                          return(1);
324          return(0);
325   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines