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 1.8 by greg, Fri Oct 20 20:35:22 1989 UTC vs.
Revision 2.24 by greg, Fri Jun 30 00:58:47 2023 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  color.c - routines for color calculations.
6   *
7 < *     10/10/85
7 > *  Externals declared in color.h
8   */
9  
10 < #include  <stdio.h>
10 > #include "copyright.h"
11  
12 + #include  <stdio.h>
13 + #include  <stdlib.h>
14 + #include  <math.h>
15   #include  "color.h"
16  
17 < #ifdef  SPEC_RGB
18 < /*
19 < *      The following table contains the CIE tristimulus integrals
20 < *  for X, Y, and Z.  The table is cumulative, so that
21 < *  each color coordinate integrates to 1.
22 < */
17 > #ifdef getc_unlocked            /* avoid horrendous overhead of flockfile */
18 > #undef getc
19 > #undef putc
20 > #undef ferror
21 > #define getc    getc_unlocked
22 > #define putc    putc_unlocked
23 > #define ferror  ferror_unlocked
24 > #endif
25  
26 < #define  STARTWL        380             /* starting wavelength (nanometers) */
27 < #define  INCWL          10              /* wavelength increment */
28 < #define  NINC           40              /* # of values */
26 > #define  MINELEN        8       /* minimum scanline length for encoding */
27 > #define  MAXELEN        0x7fff  /* maximum scanline length for encoding */
28 > #define  MINRUN         4       /* minimum run length */
29  
28 static BYTE  chroma[3][NINC] = {
29        {                                                       /* X */
30                0,   0,   0,   2,   6,   13,  22,  30,  36,  41,
31                42,  43,  43,  44,  46,  52,  60,  71,  87,  106,
32                128, 153, 178, 200, 219, 233, 243, 249, 252, 254,
33                255, 255, 255, 255, 255, 255, 255, 255, 255, 255
34        }, {                                                    /* Y */
35                0,   0,   0,   0,   0,   1,   2,   4,   7,   11,
36                17,  24,  34,  48,  64,  84,  105, 127, 148, 169,
37                188, 205, 220, 232, 240, 246, 250, 253, 254, 255,
38                255, 255, 255, 255, 255, 255, 255, 255, 255, 255
39        }, {                                                    /* Z */
40                0,   0,   2,   10,  32,  66,  118, 153, 191, 220,
41                237, 246, 251, 253, 254, 255, 255, 255, 255, 255,
42                255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
43                255, 255, 255, 255, 255, 255, 255, 255, 255, 255
44        }
45 };
30  
31 <
32 < spec_rgb(col, s, e)             /* comput RGB color from spectral range */
33 < COLOR  col;
34 < int  s, e;
31 > void *
32 > tempbuffer(                     /* get a temporary buffer */
33 >        unsigned int  len
34 > )
35   {
36 <        COLOR  ciecolor;
36 >        static void             *tempbuf = NULL;
37 >        static unsigned int     tempbuflen = 0;
38  
39 <        spec_cie(ciecolor, s, e);
40 <        cie_rgb(col, ciecolor);
41 < }
42 <
43 <
44 < spec_cie(col, s, e)             /* compute a color from a spectral range */
45 < COLOR  col;             /* returned color */
61 < int  s, e;              /* starting and ending wavelengths */
62 < {
63 <        register int  i, d, r;
64 <        
65 <        s -= STARTWL;
66 <        if (s < 0)
67 <                s = 0;
68 <
69 <        e -= STARTWL;
70 <        if (e >= INCWL*(NINC - 1))
71 <                e = INCWL*(NINC - 1) - 1;
72 <
73 <        d = e / INCWL;                  /* interpolate values */
74 <        r = e % INCWL;
75 <        for (i = 0; i < 3; i++)
76 <                col[i] = chroma[i][d]*(INCWL - r) + chroma[i][d + 1]*r;
77 <
78 <        d = s / INCWL;
79 <        r = s % INCWL;
80 <        for (i = 0; i < 3; i++)
81 <                col[i] -= chroma[i][d]*(INCWL - r) - chroma[i][d + 1]*r;
82 <
83 <        col[RED] = (col[RED] + 0.5) / (256*INCWL);
84 <        col[GRN] = (col[GRN] + 0.5) / (256*INCWL);
85 <        col[BLU] = (col[BLU] + 0.5) / (256*INCWL);
86 < }
87 <
88 <
89 < cie_rgb(rgbcolor, ciecolor)             /* convert CIE to RGB (NTSC) */
90 < register COLOR  rgbcolor, ciecolor;
91 < {
92 <        static float  cmat[3][3] = {
93 <                1.73, -.48, -.26,
94 <                -.81, 1.65, -.02,
95 <                 .08, -.17, 1.28,
96 <        };
97 <        register int  i;
98 <
99 <        for (i = 0; i < 3; i++) {
100 <                rgbcolor[i] =   cmat[i][0]*ciecolor[0] +
101 <                                cmat[i][1]*ciecolor[1] +
102 <                                cmat[i][2]*ciecolor[2] ;
103 <                if (rgbcolor[i] < 0.0)
104 <                        rgbcolor[i] = 0.0;
39 >        if (!len) {             /* call to free */
40 >                if (tempbuflen) {
41 >                        free(tempbuf);
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   }
107 #endif
56  
57  
58 < fputresolu(ord, xres, yres, fp)         /* put x and y resolution */
59 < register int  ord;
60 < int  xres, yres;
61 < FILE  *fp;
58 > int
59 > fwritecolrs(                    /* write out a colr scanline */
60 >        COLR  *scanline,
61 >        int  len,
62 >        FILE  *fp
63 > )
64   {
65 <        if (ord&YMAJOR)
66 <                fprintf(fp, "%cY %d %cX %d\n",
117 <                                ord&YDECR ? '-' : '+', yres,
118 <                                ord&XDECR ? '-' : '+', xres);
119 <        else
120 <                fprintf(fp, "%cX %d %cY %d\n",
121 <                                ord&XDECR ? '-' : '+', xres,
122 <                                ord&YDECR ? '-' : '+', yres);
123 < }
124 <
125 <
126 < fgetresolu(xrp, yrp, fp)                /* get x and y resolution */
127 < int  *xrp, *yrp;
128 < FILE  *fp;
129 < {
130 <        char  buf[64], *xndx, *yndx;
131 <        register char  *cp;
132 <        register int  ord;
133 <
134 <        if (fgets(buf, sizeof(buf), fp) == NULL)
135 <                return(-1);
136 <        xndx = yndx = NULL;
137 <        for (cp = buf+1; *cp; cp++)
138 <                if (*cp == 'X')
139 <                        xndx = cp;
140 <                else if (*cp == 'Y')
141 <                        yndx = cp;
142 <        if (xndx == NULL || yndx == NULL)
143 <                return(-1);
144 <        ord = 0;
145 <        if (xndx > yndx) ord |= YMAJOR;
146 <        if (xndx[-1] == '-') ord |= XDECR;
147 <        if (yndx[-1] == '-') ord |= YDECR;
148 <        if ((*xrp = atoi(xndx+1)) <= 0)
149 <                return(-1);
150 <        if ((*yrp = atoi(yndx+1)) <= 0)
151 <                return(-1);
152 <        return(ord);
153 < }
154 <
155 <
156 < fwritecolrs(scanline, len, fp)          /* write out a colr scanline */
157 < register COLR  *scanline;
158 < int  len;
159 < register FILE  *fp;
160 < {
161 <        COLR  lastcolr;
162 <        int  rept;
65 >        int  i, j, beg, cnt = 1;
66 >        int  c2;
67          
68 <        lastcolr[RED] = lastcolr[GRN] = lastcolr[BLU] = 1;
69 <        lastcolr[EXP] = 0;
70 <        rept = 0;
71 <        
72 <        while (len > 0) {
73 <                if (scanline[0][EXP] == lastcolr[EXP] &&
74 <                                scanline[0][RED] == lastcolr[RED] &&
75 <                                scanline[0][GRN] == lastcolr[GRN] &&
76 <                                scanline[0][BLU] == lastcolr[BLU])
77 <                        rept++;
78 <                else {
79 <                        while (rept) {          /* write out count */
80 <                                putc(1, fp);
81 <                                putc(1, fp);
82 <                                putc(1, fp);
83 <                                putc(rept & 255, fp);
84 <                                rept >>= 8;
68 >        if ((len < MINELEN) | (len > MAXELEN))  /* OOBs, write out flat */
69 >                return(fwrite((char *)scanline,sizeof(COLR),len,fp) - len);
70 >                                        /* put magic header */
71 >        putc(2, fp);
72 >        putc(2, fp);
73 >        putc(len>>8, 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 */
78 >                for (beg = j; beg < len; beg += cnt) {
79 >                    for (cnt = 1; (cnt < 127) & (beg+cnt < len) &&
80 >                            scanline[beg+cnt][i] == scanline[beg][i]; cnt++)
81 >                        ;
82 >                    if (cnt >= MINRUN)
83 >                        break;                  /* long enough */
84 >                }
85 >                if ((beg-j > 1) & (beg-j < MINRUN)) {
86 >                    c2 = j+1;
87 >                    while (scanline[c2++][i] == scanline[j][i])
88 >                        if (c2 == beg) {        /* short run */
89 >                            putc(128+beg-j, fp);
90 >                            putc(scanline[j][i], fp);
91 >                            j = beg;
92 >                            break;
93                          }
182                        putc(scanline[0][RED], fp);     /* new color */
183                        putc(scanline[0][GRN], fp);
184                        putc(scanline[0][BLU], fp);
185                        putc(scanline[0][EXP], fp);
186                        copycolr(lastcolr, scanline[0]);
187                        rept = 0;
94                  }
95 <                scanline++;
96 <                len--;
95 >                while (j < beg) {               /* write out non-run */
96 >                    if ((c2 = beg-j) > 128) c2 = 128;
97 >                    putc(c2, fp);
98 >                    while (c2--)
99 >                        putc(scanline[j++][i], fp);
100 >                }
101 >                if (cnt >= MINRUN) {            /* write out run */
102 >                    putc(128+cnt, fp);
103 >                    putc(scanline[beg][i], fp);
104 >                } else
105 >                    cnt = 0;
106 >            }
107          }
192        while (rept) {          /* write out count */
193                putc(1, fp);
194                putc(1, fp);
195                putc(1, fp);
196                putc(rept & 255, fp);
197                rept >>= 8;
198        }
108          return(ferror(fp) ? -1 : 0);
109   }
110  
111 <
112 < freadcolrs(scanline, len, fp)           /* read in a colr scanline */
113 < register COLR  *scanline;
114 < int  len;
115 < register FILE  *fp;
111 > /*
112 > * An old-format scanline is either a stream of valid RGBE or XYZE real
113 > * pixels or at least one real pixel followed by some number of
114 > * invalid real pixels of the form (1,1,1,n), where n is a count.
115 > * These can themselves be repeated to create a multibyte repeat
116 > * count, with the least significant byte first (little-endian order.)
117 > * Repeat counts are limited by the size of an int; if a repetition
118 > * leads to an overrun, the rest of the the repetition will be
119 > * silently ignored.
120 > */
121 > static int
122 > oldreadcolrs(                   /* read in an old-style colr scanline */
123 >        COLR  *scanline,
124 >        int  len,
125 >        FILE  *fp
126 > )
127   {
128 <        int  rshift;
129 <        register int  i;
128 >        int  rshift = -1;
129 >        int  i;
130          
211        rshift = 0;
212        
131          while (len > 0) {
132                  scanline[0][RED] = getc(fp);
133                  scanline[0][GRN] = getc(fp);
134                  scanline[0][BLU] = getc(fp);
135 <                scanline[0][EXP] = getc(fp);
136 <                if (feof(fp) || ferror(fp))
135 >                scanline[0][EXP] = i = getc(fp);
136 >                if (i == EOF)
137                          return(-1);
138 <                if (scanline[0][RED] == 1 &&
139 <                                scanline[0][GRN] == 1 &&
140 <                                scanline[0][BLU] == 1) {
141 <                        for (i = scanline[0][EXP] << rshift; i > 0; i--) {
138 >                if (scanline[0][GRN] == 1 &&
139 >                                (scanline[0][RED] == 1) &
140 >                                (scanline[0][BLU] == 1) &&
141 >                                rshift >= 0) {
142 >                        i = scanline[0][EXP] << rshift;
143 >                        while (i--) {
144                                  copycolr(scanline[0], scanline[-1]);
145 +                                if (--len <= 0)
146 +                                        return(0);
147                                  scanline++;
226                                len--;
148                          }
149                          rshift += 8;
150                  } else {
# Line 235 | Line 156 | register FILE  *fp;
156          return(0);
157   }
158  
159 + /*
160 + * There are two scanline formats: old and new.  The old format
161 + * compresses runs of RGBE or XYZE four-byte real pixels; the new
162 + * format breaks the pixels into R, G, B, and E lines (or XYZE lines)
163 + * which are individually run-length encoded.
164 + *
165 + * An old-format scanline always begins with a valid real pixel; at
166 + * least one of the RGB (or XYZ) values will have its high-order bit
167 + * set.  A new-format scanline begins with four bytes which are not a
168 + * valid real pixel: (2, 2, lenhigh, lenlow) where lenhigh is always
169 + * less than 128 and hence never has a high-order bit set.
170 + *
171 + * A new-format scanline is broken into its RGBE or XYZE components.
172 + * Each is output and run-length encoded separately so that a scanline
173 + * is broken into four records.  In turn, each record is organized
174 + * into chunks of up to 128 characters, which begin with a count byte.
175 + * If the count byte is greater than 128, the following data byte is
176 + * repeated (count-128) times.  If not, the count byte is followed by
177 + * that many data bytes.
178 + */
179 + int
180 + freadcolrs(                     /* read in an encoded colr scanline */
181 +        COLR  *scanline,
182 +        int  len,
183 +        FILE  *fp
184 + )
185 + {
186 +        int  i, j;
187 +        int  code, val;
188 +                                        /* determine scanline type */
189 +        if ((len < MINELEN) | (len > MAXELEN))
190 +                return(oldreadcolrs(scanline, len, fp));
191 +        if ((i = getc(fp)) == EOF)
192 +                return(-1);
193 +        if (i != 2) {
194 +                ungetc(i, fp);
195 +                return(oldreadcolrs(scanline, len, fp));
196 +        }
197 +        scanline[0][GRN] = getc(fp);
198 +        scanline[0][BLU] = getc(fp);
199 +        if ((i = getc(fp)) == EOF)
200 +                return(-1);
201 +        if ((scanline[0][GRN] != 2) | ((scanline[0][BLU] & 0x80) != 0)) {
202 +                scanline[0][RED] = 2;
203 +                scanline[0][EXP] = i;
204 +                return(oldreadcolrs(scanline+1, len-1, fp));
205 +        }
206 +        if ((scanline[0][BLU]<<8 | i) != len)
207 +                return(-1);             /* length mismatch! */
208 +                                        /* read each component */
209 +        for (i = 0; i < 4; i++)
210 +            for (j = 0; j < len; ) {
211 +                if ((code = getc(fp)) == EOF)
212 +                    return(-1);
213 +                if (code > 128) {       /* run */
214 +                    code &= 127;
215 +                    if ((val = getc(fp)) == EOF)
216 +                        return -1;
217 +                    if (j + code > len)
218 +                        return -1;      /* overrun */
219 +                    while (code--)
220 +                        scanline[j++][i] = val;
221 +                } else {                /* non-run */
222 +                    if (j + code > len)
223 +                        return -1;      /* overrun */
224 +                    while (code--) {
225 +                        if ((val = getc(fp)) == EOF)
226 +                            return -1;
227 +                        scanline[j++][i] = val;
228 +                    }
229 +                }
230 +            }
231 +        return(0);
232 + }
233  
234 < fwritescan(scanline, len, fp)           /* write out a scanline */
235 < register COLOR  *scanline;
236 < int  len;
237 < register FILE  *fp;
234 >
235 > int
236 > fwritescan(                     /* write out a scanline */
237 >        COLOR  *scanline,
238 >        int  len,
239 >        FILE  *fp
240 > )
241   {
242 <        COLR  lastcolr, thiscolr;
243 <        int  rept;
244 <        
245 <        lastcolr[RED] = lastcolr[GRN] = lastcolr[BLU] = 1;
246 <        lastcolr[EXP] = 0;
247 <        rept = 0;
248 <        
249 <        while (len > 0) {
250 <                setcolr(thiscolr, scanline[0][RED],
242 >        COLR  *clrscan;
243 >        int  n;
244 >        COLR  *sp;
245 >                                        /* get scanline buffer */
246 >        if ((sp = (COLR *)tempbuffer(len*sizeof(COLR))) == NULL)
247 >                return(-1);
248 >        clrscan = sp;
249 >                                        /* convert scanline */
250 >        n = len;
251 >        while (n-- > 0) {
252 >                setcolr(sp[0], scanline[0][RED],
253                                    scanline[0][GRN],
254                                    scanline[0][BLU]);
255                if (thiscolr[EXP] == lastcolr[EXP] &&
256                                thiscolr[RED] == lastcolr[RED] &&
257                                thiscolr[GRN] == lastcolr[GRN] &&
258                                thiscolr[BLU] == lastcolr[BLU])
259                        rept++;
260                else {
261                        while (rept) {          /* write out count */
262                                putc(1, fp);
263                                putc(1, fp);
264                                putc(1, fp);
265                                putc(rept & 255, fp);
266                                rept >>= 8;
267                        }
268                        putc(thiscolr[RED], fp);        /* new color */
269                        putc(thiscolr[GRN], fp);
270                        putc(thiscolr[BLU], fp);
271                        putc(thiscolr[EXP], fp);
272                        copycolr(lastcolr, thiscolr);
273                        rept = 0;
274                }
255                  scanline++;
256 <                len--;
256 >                sp++;
257          }
258 <        while (rept) {          /* write out count */
279 <                putc(1, fp);
280 <                putc(1, fp);
281 <                putc(1, fp);
282 <                putc(rept & 255, fp);
283 <                rept >>= 8;
284 <        }
285 <        return(ferror(fp) ? -1 : 0);
258 >        return(fwritecolrs(clrscan, len, fp));
259   }
260  
261  
262 < freadscan(scanline, len, fp)            /* read in a scanline */
263 < register COLOR  *scanline;
264 < int  len;
265 < register FILE  *fp;
262 > int
263 > freadscan(                      /* read in a scanline */
264 >        COLOR  *scanline,
265 >        int  len,
266 >        FILE  *fp
267 > )
268   {
269 <        COLR  thiscolr;
270 <        int  rshift;
271 <        register int  i;
272 <        
273 <        rshift = 0;
274 <        
275 <        while (len > 0) {
276 <                thiscolr[RED] = getc(fp);
277 <                thiscolr[GRN] = getc(fp);
278 <                thiscolr[BLU] = getc(fp);
279 <                thiscolr[EXP] = getc(fp);
280 <                if (feof(fp) || ferror(fp))
281 <                        return(-1);
282 <                if (thiscolr[RED] == 1 &&
283 <                                thiscolr[GRN] == 1 &&
284 <                                thiscolr[BLU] == 1) {
285 <                        for (i = thiscolr[EXP] << rshift; i > 0; i--) {
311 <                                copycolor(scanline[0], scanline[-1]);
312 <                                scanline++;
313 <                                len--;
314 <                        }
315 <                        rshift += 8;
316 <                } else {
317 <                        colr_color(scanline[0], thiscolr);
318 <                        scanline++;
319 <                        len--;
320 <                        rshift = 0;
321 <                }
269 >        COLR  *clrscan;
270 >
271 >        if ((clrscan = (COLR *)tempbuffer(len*sizeof(COLR))) == NULL)
272 >                return(-1);
273 >        if (freadcolrs(clrscan, len, fp) < 0)
274 >                return(-1);
275 >                                        /* convert scanline */
276 >        colr_color(scanline[0], clrscan[0]);
277 >        while (--len > 0) {
278 >                scanline++; clrscan++;
279 >                if (clrscan[0][GRN] == clrscan[-1][GRN] &&
280 >                            (clrscan[0][RED] == clrscan[-1][RED]) &
281 >                            (clrscan[0][BLU] == clrscan[-1][BLU]) &
282 >                            (clrscan[0][EXP] == clrscan[-1][EXP]))
283 >                        copycolor(scanline[0], scanline[-1]);
284 >                else
285 >                        colr_color(scanline[0], clrscan[0]);
286          }
287          return(0);
288   }
289  
290  
291 < setcolr(clr, r, g, b)           /* assign a short color value */
292 < register COLR  clr;
293 < double  r, g, b;
291 > void
292 > setcolr(                        /* assign a short color value */
293 >        COLR  clr,
294 >        double  r,
295 >        double  g,
296 >        double  b
297 > )
298   {
331        double  frexp();
299          double  d;
300          int  e;
301          
# Line 343 | Line 310 | double  r, g, b;
310  
311          d = frexp(d, &e) * 256.0 / d;
312  
313 <        clr[RED] = r * d;
314 <        clr[GRN] = g * d;
315 <        clr[BLU] = b * d;
313 >        if (r > 0.0)
314 >                clr[RED] = r * d;
315 >        else
316 >                clr[RED] = 0;
317 >        if (g > 0.0)
318 >                clr[GRN] = g * d;
319 >        else
320 >                clr[GRN] = 0;
321 >        if (b > 0.0)
322 >                clr[BLU] = b * d;
323 >        else
324 >                clr[BLU] = 0;
325 >
326          clr[EXP] = e + COLXS;
327   }
328  
329  
330 < colr_color(col, clr)            /* convert short to float color */
331 < register COLOR  col;
332 < register COLR  clr;
330 > void
331 > colr_color(                     /* convert short to float color */
332 >        COLOR  col,
333 >        COLR  clr
334 > )
335   {
336          double  f;
337          
# Line 367 | Line 346 | register COLR  clr;
346   }
347  
348  
349 < normcolrs(scan, len)            /* normalize a scanline of colrs */
350 < register COLR  *scan;
351 < int  len;
349 > int
350 > bigdiff(                                /* c1 delta c2 > md? */
351 >        COLOR  c1,
352 >        COLOR  c2,
353 >        double  md
354 > )
355   {
356 <        register int  c;
375 <        register int  shift;
356 >        int  i;
357  
377        while (len-- > 0) {
378                shift = scan[0][EXP] - COLXS;
379                if (shift > 0) {
380                        if (shift >= 8) {
381                                scan[0][RED] =
382                                scan[0][GRN] =
383                                scan[0][BLU] = 255;
384                        } else {
385                                c = scan[0][RED] << shift;
386                                scan[0][RED] = c > 255 ? 255 : c;
387                                c = scan[0][GRN] << shift;
388                                scan[0][GRN] = c > 255 ? 255 : c;
389                                c = scan[0][BLU] << shift;
390                                scan[0][BLU] = c > 255 ? 255 : c;
391                        }
392                } else if (shift < 0) {
393                        if (shift <= -8) {
394                                scan[0][RED] =
395                                scan[0][GRN] =
396                                scan[0][BLU] = 0;
397                        } else {
398                                scan[0][RED] = scan[0][RED] >> -shift;
399                                scan[0][GRN] = scan[0][GRN] >> -shift;
400                                scan[0][BLU] = scan[0][BLU] >> -shift;
401                        }
402                }
403                scan[0][EXP] = COLXS;
404                scan++;
405        }
406 }
407
408
409 bigdiff(c1, c2, md)                     /* c1 delta c2 > md? */
410 register COLOR  c1, c2;
411 double  md;
412 {
413        register int  i;
414
358          for (i = 0; i < 3; i++)
359                  if (colval(c1,i)-colval(c2,i) > md*colval(c2,i) ||
360 <                        colval(c2,i)-colval(c1,i) > md*colval(c1,i))
360 >                                colval(c2,i)-colval(c1,i) > md*colval(c1,i))
361                          return(1);
362          return(0);
363   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines