146 |
|
|
147 |
|
/****************** ACUITY STUFF *******************/ |
148 |
|
|
149 |
< |
typedef struct scanbar { |
150 |
< |
short sampr; /* sample area size (power of 2) */ |
149 |
> |
typedef struct { |
150 |
> |
short sampe; /* sample area size (exponent of 2) */ |
151 |
|
short nscans; /* number of scanlines in this bar */ |
152 |
|
int len; /* individual scanline length */ |
153 |
– |
struct scanbar *next; /* next higher resolution scanbar */ |
153 |
|
int nread; /* number of scanlines loaded */ |
154 |
< |
/* followed by the scanline data */ |
154 |
> |
COLOR *sdata; /* scanbar data */ |
155 |
|
} SCANBAR; |
156 |
|
|
157 |
< |
#define bscan(sb,y) ((COLOR *)((sb)+1)+((y)%(sb)->nscans)*(sb)->len) |
157 |
> |
#define bscan(sb,y) ((COLOR *)(sb)->sdata+((y)%(sb)->nscans)*(sb)->len) |
158 |
|
|
159 |
|
SCANBAR *rootbar; /* root scan bar (lowest resolution) */ |
160 |
|
|
207 |
|
return(NULL); |
208 |
|
for ( ; y >= sb->nread; sb->nread++) { /* read as necessary */ |
209 |
|
mysl = bscan(sb, sb->nread); |
210 |
< |
if (sb->sampr == 1) { |
210 |
> |
if (sb->sampe == 0) { |
211 |
|
if (freadscan(mysl, sb->len, infp) < 0) { |
212 |
|
fprintf(stderr, "%s: %s: scanline read error\n", |
213 |
|
progname, infn); |
214 |
|
exit(1); |
215 |
|
} |
216 |
|
} else { |
217 |
< |
sl0 = getascan(sb->next, 2*y); |
217 |
> |
sl0 = getascan(sb+1, 2*y); |
218 |
|
if (sl0 == NULL) |
219 |
|
return(NULL); |
220 |
< |
sl1 = getascan(sb->next, 2*y+1); |
220 |
> |
sl1 = getascan(sb+1, 2*y+1); |
221 |
|
for (i = 0; i < sb->len; i++) { |
222 |
|
copycolor(mysl[i], sl0[2*i]); |
223 |
|
addcolor(mysl[i], sl0[2*i+1]); |
266 |
|
double d; |
267 |
|
register SCANBAR *sb0; |
268 |
|
|
269 |
< |
for (sb0 = rootbar; sb0->next != NULL && sb0->next->sampr > sr; |
271 |
< |
sb0 = sb0->next) |
269 |
> |
for (sb0 = rootbar; sb0->sampe != 0 && 1<<sb0[1].sampe > sr; sb0++) |
270 |
|
; |
271 |
|
ascanval(col, x, y, sb0); |
272 |
< |
if (sb0->next == NULL) /* don't extrapolate highest */ |
272 |
> |
if (sb0->sampe == 0) /* don't extrapolate highest */ |
273 |
|
return; |
274 |
< |
ascanval(c1, x, y, sb0->next); |
275 |
< |
d = (sb0->sampr - sr)/(sb0->sampr - sb0->next->sampr); |
274 |
> |
ascanval(c1, x, y, sb0+1); |
275 |
> |
d = ((1<<sb0->sampe) - sr)/(1<<sb0[1].sampe); |
276 |
|
scalecolor(col, 1.-d); |
277 |
|
scalecolor(c1, d); |
278 |
|
addcolor(col, c1); |
288 |
|
double dx, dy; |
289 |
|
int ix, iy; |
290 |
|
|
291 |
< |
if (sb->sampr == 1) { /* no need to interpolate */ |
291 |
> |
if (sb->sampe == 0) { /* no need to interpolate */ |
292 |
|
sl0 = getascan(sb, y); |
293 |
|
copycolor(col, sl0[x]); |
294 |
|
return; |
295 |
|
} |
296 |
|
/* compute coordinates for sb */ |
297 |
< |
ix = dx = (x+.5)/sb->sampr - .5; |
297 |
> |
ix = dx = (x+.5)/(1<<sb->sampe) - .5; |
298 |
|
while (ix >= sb->len-1) ix--; |
299 |
|
dx -= (double)ix; |
300 |
< |
iy = dy = (y+.5)/sb->sampr - .5; |
301 |
< |
while (iy >= numscans(&inpres)/sb->sampr-1) iy--; |
300 |
> |
iy = dy = (y+.5)/(1<<sb->sampe) - .5; |
301 |
> |
while (iy >= (numscans(&inpres)>>sb->sampe)-1) iy--; |
302 |
|
dy -= (double)iy; |
303 |
|
/* get scanlines */ |
304 |
|
sl0 = getascan(sb, iy); |
331 |
|
int ns; /* number of scanlines */ |
332 |
|
int sl; /* original scanline length */ |
333 |
|
{ |
334 |
+ |
SCANBAR *sbarr; |
335 |
|
register SCANBAR *sb; |
336 |
|
|
337 |
< |
sb = (SCANBAR *)malloc(sizeof(SCANBAR)+(sl/sr)*ns*sizeof(COLOR)); |
337 |
> |
sbarr = sb = (SCANBAR *)malloc((sr+1)*sizeof(SCANBAR)); |
338 |
|
if (sb == NULL) |
339 |
|
syserror("malloc"); |
340 |
< |
sb->nscans = ns; |
341 |
< |
sb->len = sl/sr; |
342 |
< |
sb->nread = 0; |
343 |
< |
if ((sb->sampr = sr) > 1) |
344 |
< |
sb->next = sballoc(sr/2, ns*2, sl); |
345 |
< |
else |
346 |
< |
sb->next = NULL; |
347 |
< |
return(sb); |
340 |
> |
do { |
341 |
> |
sb->sdata = (COLOR *)malloc((sl>>sr)*ns*sizeof(COLOR)); |
342 |
> |
if (sb->sdata == NULL) |
343 |
> |
syserror("malloc"); |
344 |
> |
sb->sampe = sr; |
345 |
> |
sb->nscans = ns; |
346 |
> |
sb->len = sl>>sr; |
347 |
> |
sb->nread = 0; |
348 |
> |
ns <<= 1; |
349 |
> |
sb++; |
350 |
> |
} while (--sr >= 0); |
351 |
> |
return(sbarr); |
352 |
|
} |
353 |
|
|
354 |
|
|
392 |
|
tsampr(y,fvxr-1) = tsampr(y,fvxr-2); |
393 |
|
} |
394 |
|
/* initialize with next power of two */ |
395 |
< |
rootbar = sballoc(2<<(int)(log(maxsr)/log(2.)), 2, scanlen(&inpres)); |
395 |
> |
rootbar = sballoc((int)(log(maxsr)/log(2.))+1, 2, scanlen(&inpres)); |
396 |
|
} |