| 52 |
|
goto memerr; |
| 53 |
|
for (i = nmods; i--; ) { |
| 54 |
|
MODCONT *mp = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
| 55 |
< |
bp->mca[i] = (MODCONT *)malloc(sizeof(MODCONT) + |
| 56 |
< |
sizeof(DCOLOR)*(mp->nbins-1)); |
| 55 |
> |
bp->mca[i] = (MODCONT *)malloc(mcsize(mp->nbins)); |
| 56 |
|
if (bp->mca[i] == NULL) |
| 57 |
|
goto memerr; |
| 58 |
< |
memcpy(bp->mca[i], mp, sizeof(MODCONT)-sizeof(DCOLOR)); |
| 59 |
< |
/* memset(bp->mca[i]->cbin, 0, sizeof(DCOLOR)*mp->nbins); */ |
| 58 |
> |
memcpy(bp->mca[i], mp, sizeof(MODCONT)-sizeof(DCOLORV)); |
| 59 |
> |
/* memset(bp->mca[i]->cbin, 0, DCOLORSIZ*mp->nbins); */ |
| 60 |
|
} |
| 61 |
|
bp->ndx = 0; |
| 62 |
|
bp->nadded = 0; |
| 86 |
|
} |
| 87 |
|
/* clear sums for next use */ |
| 88 |
|
/* for (i = nmods; i--; ) |
| 89 |
< |
memset(bp->mca[i]->cbin, 0, sizeof(DCOLOR)*bp->mca[i]->nbins); |
| 89 |
> |
memset(bp->mca[i]->cbin, 0, DCOLORSIZ*bp->mca[i]->nbins); |
| 90 |
|
*/ |
| 91 |
|
if (bp->next != NULL) |
| 92 |
|
error(CONSISTENCY, "free_binq() handed list"); |
| 101 |
|
queue_modifiers() |
| 102 |
|
{ |
| 103 |
|
MODCONT *mpin, *mpout; |
| 104 |
< |
int i, j; |
| 104 |
> |
DCOLORV *ssrc, *sdst; |
| 105 |
> |
int i; |
| 106 |
|
|
| 107 |
|
if ((accumulate > 0) | (out_bq == NULL)) |
| 108 |
|
error(CONSISTENCY, "bad call to queue_modifiers()"); |
| 110 |
|
for (i = nmods; i--; ) { |
| 111 |
|
mpin = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
| 112 |
|
mpout = out_bq->mca[i]; |
| 113 |
< |
for (j = mpout->nbins; j--; ) |
| 114 |
< |
addcolor(mpout->cbin[j], mpin->cbin[j]); |
| 115 |
< |
memset(mpin->cbin, 0, sizeof(DCOLOR)*mpin->nbins); |
| 113 |
> |
ssrc = mcbin(mpin, mpin->nbins); |
| 114 |
> |
sdst = mcbin(mpout, mpout->nbins); |
| 115 |
> |
while (sdst > mpout->cbin) |
| 116 |
> |
*--sdst += *--ssrc; |
| 117 |
> |
memset(mpin->cbin, 0, DCOLORSIZ*mpin->nbins); |
| 118 |
|
} |
| 119 |
|
out_bq->nadded++; |
| 120 |
|
} |
| 124 |
|
static void |
| 125 |
|
add_modbin(BINQ *dst, BINQ *src) |
| 126 |
|
{ |
| 127 |
< |
int i, j; |
| 128 |
< |
|
| 127 |
> |
MODCONT *mpin, *mpout; |
| 128 |
> |
DCOLORV *ssrc, *sdst; |
| 129 |
> |
int i; |
| 130 |
> |
|
| 131 |
|
for (i = nmods; i--; ) { |
| 132 |
< |
MODCONT *mpin = src->mca[i]; |
| 133 |
< |
MODCONT *mpout = dst->mca[i]; |
| 134 |
< |
for (j = mpout->nbins; j--; ) |
| 135 |
< |
addcolor(mpout->cbin[j], mpin->cbin[j]); |
| 132 |
> |
mpin = src->mca[i]; |
| 133 |
> |
mpout = dst->mca[i]; |
| 134 |
> |
ssrc = mcbin(mpin, mpin->nbins); |
| 135 |
> |
sdst = mcbin(mpout, mpout->nbins); |
| 136 |
> |
while (sdst > mpout->cbin) |
| 137 |
> |
*--sdst += *--ssrc; |
| 138 |
|
} |
| 139 |
|
dst->nadded += src->nadded; |
| 140 |
|
} |
| 237 |
|
int i; |
| 238 |
|
|
| 239 |
|
for (i = nmods; i--; ) |
| 240 |
< |
memset(bp->mca[i]->cbin, 0, sizeof(DCOLOR)*bp->mca[i]->nbins); |
| 240 |
> |
memset(bp->mca[i]->cbin, 0, DCOLORSIZ*bp->mca[i]->nbins); |
| 241 |
|
bp->ndx = ndx; |
| 242 |
|
bp->nadded = 1; |
| 243 |
|
queue_output(bp); |
| 256 |
|
bq->nadded = kida[k].nr; |
| 257 |
|
/* read from child */ |
| 258 |
|
for (j = 0; j < nmods; j++) |
| 259 |
< |
if (getbinary(bq->mca[j]->cbin, sizeof(DCOLOR), bq->mca[j]->nbins, |
| 259 |
> |
if (getbinary(bq->mca[j]->cbin, DCOLORSIZ, bq->mca[j]->nbins, |
| 260 |
|
kida[k].infp) != bq->mca[j]->nbins) |
| 261 |
|
error(SYSTEM, "read error from render process"); |
| 262 |
|
|
| 428 |
|
if (accumulate > 1) /* need terminator? */ |
| 429 |
|
memset(orgdir[2*n++], 0, sizeof(FVECT)*2); |
| 430 |
|
n *= sizeof(FVECT)*2; /* send assignment */ |
| 431 |
< |
if (writebuf(kidpr[i].w, (char *)orgdir, n) != n) |
| 431 |
> |
if (writebuf(kidpr[i].w, orgdir, n) != n) |
| 432 |
|
error(SYSTEM, "pipe write error"); |
| 433 |
|
kida[i].r1 = lastray+1; |
| 434 |
|
lastray += kida[i].nr = ninq; /* mark as busy */ |
| 450 |
|
} |
| 451 |
|
put_zero_record(++lastray); |
| 452 |
|
} |
| 453 |
< |
if (raysleft && !--raysleft) |
| 453 |
> |
if (!morays()) |
| 454 |
|
break; /* preemptive EOI */ |
| 455 |
|
} |
| 456 |
|
while (next_child_nq(1) >= 0) /* empty results queue */ |
| 527 |
|
if (++ninq >= MAXIQ) { |
| 528 |
|
i = next_child_ready(); /* get eager child */ |
| 529 |
|
n = sizeof(FVECT)*2 * ninq; /* give assignment */ |
| 530 |
< |
if (writebuf(kidpr[i].w, (char *)orgdir, n) != n) |
| 530 |
> |
if (writebuf(kidpr[i].w, orgdir, n) != n) |
| 531 |
|
error(SYSTEM, "pipe write error"); |
| 532 |
|
kida[i].r1 = lastray+1; |
| 533 |
|
lastray += kida[i].nr = ninq; |
| 535 |
|
lastdone = lastray = 0; |
| 536 |
|
ninq = 0; |
| 537 |
|
} |
| 538 |
< |
if (raysleft && !--raysleft) |
| 538 |
> |
if (!morays()) |
| 539 |
|
break; /* preemptive EOI */ |
| 540 |
|
} |
| 541 |
|
if (ninq) { /* polish off input */ |
| 542 |
|
i = next_child_ready(); |
| 543 |
|
n = sizeof(FVECT)*2 * ninq; |
| 544 |
< |
if (writebuf(kidpr[i].w, (char *)orgdir, n) != n) |
| 544 |
> |
if (writebuf(kidpr[i].w, orgdir, n) != n) |
| 545 |
|
error(SYSTEM, "pipe write error"); |
| 546 |
|
kida[i].r1 = lastray+1; |
| 547 |
|
lastray += kida[i].nr = ninq; |
| 549 |
|
} |
| 550 |
|
memset(orgdir, 0, sizeof(FVECT)*2); /* get results */ |
| 551 |
|
for (i = nchild; i--; ) { |
| 552 |
< |
writebuf(kidpr[i].w, (char *)orgdir, sizeof(FVECT)*2); |
| 552 |
> |
writebuf(kidpr[i].w, orgdir, sizeof(FVECT)*2); |
| 553 |
|
queue_results(i); |
| 554 |
|
} |
| 555 |
|
if (recover) /* and from before? */ |