| 39 |
|
static long ncall = 0L; /* number of calls to getpictscan */ |
| 40 |
|
static long nread = 0L; /* number of scanlines read */ |
| 41 |
|
|
| 42 |
+ |
extern long ftell(); |
| 43 |
|
|
| 44 |
+ |
|
| 45 |
|
COLR * |
| 46 |
|
getpictscan(y) /* get picture scanline */ |
| 47 |
|
int y; |
| 48 |
|
{ |
| 47 |
– |
extern long ftell(); |
| 49 |
|
int minused; |
| 50 |
|
register int i; |
| 51 |
|
/* first check our buffers */ |
| 60 |
|
minused = i; |
| 61 |
|
} |
| 62 |
|
/* not there, read it in */ |
| 63 |
< |
if (scanpos[y] == -1) { /* need to search */ |
| 64 |
< |
while (curpos > y) { |
| 63 |
> |
if (scanpos[y] < 0) { /* need to search */ |
| 64 |
> |
for (i = y+1; i < curpos; i++) |
| 65 |
> |
if (scanpos[i] >= 0) { |
| 66 |
> |
if (fseek(pictfp, scanpos[i], 0) < 0) |
| 67 |
> |
goto seekerr; |
| 68 |
> |
curpos = i; |
| 69 |
> |
break; |
| 70 |
> |
} |
| 71 |
> |
while (curpos >= y) { |
| 72 |
|
scanpos[curpos] = ftell(pictfp); |
| 73 |
|
if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0) |
| 74 |
|
goto readerr; |
| 75 |
+ |
nread++; |
| 76 |
|
curpos--; |
| 77 |
|
} |
| 78 |
< |
} else if (fseek(pictfp, scanpos[y], 0) < 0) { |
| 79 |
< |
fprintf(stderr, "%s: picture seek error\n", progname); |
| 80 |
< |
exit(1); |
| 78 |
> |
} else { |
| 79 |
> |
if (curpos != y && fseek(pictfp, scanpos[y], 0) < 0) |
| 80 |
> |
goto seekerr; |
| 81 |
> |
if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0) |
| 82 |
> |
goto readerr; |
| 83 |
> |
nread++; |
| 84 |
> |
curpos = y-1; |
| 85 |
|
} |
| 73 |
– |
if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0) |
| 74 |
– |
goto readerr; |
| 75 |
– |
nread++; |
| 76 |
– |
curpos = y-1; |
| 86 |
|
scan[minused].lused = ncall; |
| 87 |
|
scan[minused].y = y; |
| 88 |
|
return(scan[minused].sl); |
| 89 |
|
readerr: |
| 90 |
|
fprintf(stderr, "%s: picture read error\n", progname); |
| 91 |
|
exit(1); |
| 92 |
+ |
seekerr: |
| 93 |
+ |
fprintf(stderr, "%s: picture seek error\n", progname); |
| 94 |
+ |
exit(1); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
+ |
#ifdef DEBUG |
| 99 |
|
pict_stats() /* print out picture read statistics */ |
| 100 |
|
{ |
| 101 |
|
static long lastcall = 0L; /* ncall at last report */ |
| 103 |
|
|
| 104 |
|
if (ncall == lastcall) |
| 105 |
|
return; |
| 106 |
< |
fprintf(stderr, "%s: %ld scanlines read, %ld reused\n", |
| 107 |
< |
progname, nread-lastread, |
| 95 |
< |
(ncall-lastcall)-(nread-lastread)); |
| 106 |
> |
fprintf(stderr, "%s: %ld scanlines read in %ld calls\n", |
| 107 |
> |
progname, nread-lastread, ncall-lastcall); |
| 108 |
|
lastcall = ncall; |
| 109 |
|
lastread = nread; |
| 110 |
|
} |
| 111 |
+ |
#endif |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
double |
| 142 |
|
|
| 143 |
|
if (compdir(dir, vh, vv) < 0) |
| 144 |
|
return(-1.0); |
| 145 |
+ |
npixinvw++; |
| 146 |
|
if ((res = pict_val(dir)) >= 0.0) |
| 147 |
|
return(res); |
| 148 |
< |
if (rt_pid == -1) |
| 148 |
> |
if (rt_pid == -1) { |
| 149 |
> |
npixmiss++; |
| 150 |
|
return(-1.0); |
| 151 |
+ |
} |
| 152 |
|
rt_buf[0] = ourview.vp[0]; |
| 153 |
|
rt_buf[1] = ourview.vp[1]; |
| 154 |
|
rt_buf[2] = ourview.vp[2]; |
| 181 |
|
vb[vh+hsize] = -1.0; |
| 182 |
|
continue; |
| 183 |
|
} |
| 184 |
+ |
npixinvw++; |
| 185 |
|
if ((vb[vh+hsize] = pict_val(dir)) >= 0.0) |
| 186 |
|
continue; |
| 187 |
< |
if (rt_pid == -1) /* missing information */ |
| 187 |
> |
if (rt_pid == -1) { /* missing information */ |
| 188 |
> |
npixmiss++; |
| 189 |
|
continue; |
| 190 |
+ |
} |
| 191 |
|
/* send to rtrace */ |
| 192 |
|
if (n >= MAXPIX) { /* flush */ |
| 193 |
|
rt_compute(rt_buf, n); |
| 266 |
|
scanpos = (long *)malloc(pysiz*sizeof(long)); |
| 267 |
|
if (scanpos == NULL) |
| 268 |
|
memerr("scanline positions"); |
| 269 |
< |
for (i = 0; i < pysiz; i++) |
| 269 |
> |
for (i = pysiz-1; i >= 0; i--) |
| 270 |
|
scanpos[i] = -1L; |
| 271 |
+ |
curpos = pysiz-1; |
| 272 |
|
for (i = 0; i < NSCANS; i++) { |
| 273 |
|
scan[i].lused = -1; |
| 274 |
|
scan[i].y = -1; |
| 276 |
|
if (scan[i].sl == NULL) |
| 277 |
|
memerr("scanline buffers"); |
| 278 |
|
} |
| 259 |
– |
curpos = pysiz-1; |
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
|