forked from bartvdbraak/blender
Fix T47203: Render Crash due to missing zbuf_float handling in IMB scaling.
This commit is contained in:
parent
d44ea880ea
commit
70c690c6e4
@ -1485,38 +1485,68 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
|
|||||||
return(ibuf);
|
return(ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* no float buf needed here! */
|
|
||||||
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
|
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
|
||||||
{
|
{
|
||||||
unsigned int *rect, *_newrect, *newrect;
|
int *zbuf, *newzbuf, *_newzbuf = NULL;
|
||||||
|
float *zbuf_float, *newzbuf_float, *_newzbuf_float = NULL;
|
||||||
int x, y;
|
int x, y;
|
||||||
int ofsx, ofsy, stepx, stepy;
|
int ofsx, ofsy, stepx, stepy;
|
||||||
|
|
||||||
if (ibuf->zbuf) {
|
if (ibuf->zbuf) {
|
||||||
_newrect = MEM_mallocN(newx * newy * sizeof(int), "z rect");
|
_newzbuf = MEM_mallocN(newx * newy * sizeof(int), __func__);
|
||||||
if (_newrect == NULL) return;
|
if (_newzbuf == NULL) {
|
||||||
|
IMB_freezbufImBuf(ibuf);
|
||||||
stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
|
}
|
||||||
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
|
}
|
||||||
ofsy = 32768;
|
|
||||||
|
|
||||||
newrect = _newrect;
|
if (ibuf->zbuf_float) {
|
||||||
|
_newzbuf_float = MEM_mallocN((size_t)newx * newy * sizeof(float), __func__);
|
||||||
for (y = newy; y > 0; y--) {
|
if (_newzbuf_float == NULL) {
|
||||||
rect = (unsigned int *) ibuf->zbuf;
|
IMB_freezbuffloatImBuf(ibuf);
|
||||||
rect += (ofsy >> 16) * ibuf->x;
|
}
|
||||||
ofsy += stepy;
|
}
|
||||||
|
|
||||||
|
if (!_newzbuf && !_newzbuf_float) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
|
||||||
|
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
|
||||||
|
ofsy = 32768;
|
||||||
|
|
||||||
|
newzbuf = _newzbuf;
|
||||||
|
newzbuf_float = _newzbuf_float;
|
||||||
|
|
||||||
|
for (y = newy; y > 0; y--, ofsy += stepy) {
|
||||||
|
if (newzbuf) {
|
||||||
|
zbuf = ibuf->zbuf;
|
||||||
|
zbuf += (ofsy >> 16) * ibuf->x;
|
||||||
ofsx = 32768;
|
ofsx = 32768;
|
||||||
for (x = newx; x > 0; x--) {
|
for (x = newx; x > 0; x--, ofsx += stepx) {
|
||||||
*newrect++ = rect[ofsx >> 16];
|
*newzbuf++ = zbuf[ofsx >> 16];
|
||||||
ofsx += stepx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newzbuf_float) {
|
||||||
|
zbuf_float = ibuf->zbuf_float;
|
||||||
|
zbuf_float += (ofsy >> 16) * ibuf->x;
|
||||||
|
ofsx = 32768;
|
||||||
|
for (x = newx; x > 0; x--, ofsx += stepx) {
|
||||||
|
*newzbuf_float++ = zbuf_float[ofsx >> 16];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_newzbuf) {
|
||||||
IMB_freezbufImBuf(ibuf);
|
IMB_freezbufImBuf(ibuf);
|
||||||
ibuf->mall |= IB_zbuf;
|
ibuf->mall |= IB_zbuf;
|
||||||
ibuf->zbuf = (int *) _newrect;
|
ibuf->zbuf = _newzbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_newzbuf_float) {
|
||||||
|
IMB_freezbuffloatImBuf(ibuf);
|
||||||
|
ibuf->mall |= IB_zbuffloat;
|
||||||
|
ibuf->zbuf_float = _newzbuf_float;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1586,30 +1616,24 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned
|
|||||||
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
|
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
|
||||||
ofsy = 32768;
|
ofsy = 32768;
|
||||||
|
|
||||||
for (y = newy; y > 0; y--) {
|
for (y = newy; y > 0; y--, ofsy += stepy) {
|
||||||
if (do_rect) {
|
if (do_rect) {
|
||||||
rect = ibuf->rect;
|
rect = ibuf->rect;
|
||||||
rect += (ofsy >> 16) * ibuf->x;
|
rect += (ofsy >> 16) * ibuf->x;
|
||||||
}
|
ofsx = 32768;
|
||||||
if (do_float) {
|
|
||||||
rectf = (struct imbufRGBA *)ibuf->rect_float;
|
for (x = newx; x > 0; x--, ofsx += stepx) {
|
||||||
rectf += (ofsy >> 16) * ibuf->x;
|
|
||||||
}
|
|
||||||
ofsy += stepy;
|
|
||||||
ofsx = 32768;
|
|
||||||
|
|
||||||
if (do_rect) {
|
|
||||||
for (x = newx; x > 0; x--) {
|
|
||||||
*newrect++ = rect[ofsx >> 16];
|
*newrect++ = rect[ofsx >> 16];
|
||||||
ofsx += stepx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_float) {
|
if (do_float) {
|
||||||
|
rectf = (struct imbufRGBA *)ibuf->rect_float;
|
||||||
|
rectf += (ofsy >> 16) * ibuf->x;
|
||||||
ofsx = 32768;
|
ofsx = 32768;
|
||||||
for (x = newx; x > 0; x--) {
|
|
||||||
|
for (x = newx; x > 0; x--, ofsx += stepx) {
|
||||||
*newrectf++ = rectf[ofsx >> 16];
|
*newrectf++ = rectf[ofsx >> 16];
|
||||||
ofsx += stepx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user