Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-01-19 15:24:03 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-01-19 15:24:03 +0300
commit70c690c6e49b41ca83ebfc9f24b9c053d7e9f475 (patch)
treec74b5a250933889f6865236832a566ecb41f9c1b /source/blender/imbuf
parentd44ea880ea447ff5c7bf05af83f533901f9c12d6 (diff)
Fix T47203: Render Crash due to missing zbuf_float handling in IMB scaling.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/scaling.c92
1 files changed, 58 insertions, 34 deletions
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 605adffb813..504b59b2b1d 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -1485,38 +1485,68 @@ static ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
return(ibuf);
}
-
-/* no float buf needed here! */
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 ofsx, ofsy, stepx, stepy;
if (ibuf->zbuf) {
- _newrect = MEM_mallocN(newx * newy * sizeof(int), "z rect");
- if (_newrect == NULL) 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 = MEM_mallocN(newx * newy * sizeof(int), __func__);
+ if (_newzbuf == NULL) {
+ IMB_freezbufImBuf(ibuf);
+ }
+ }
- newrect = _newrect;
-
- for (y = newy; y > 0; y--) {
- rect = (unsigned int *) ibuf->zbuf;
- rect += (ofsy >> 16) * ibuf->x;
- ofsy += stepy;
+ if (ibuf->zbuf_float) {
+ _newzbuf_float = MEM_mallocN((size_t)newx * newy * sizeof(float), __func__);
+ if (_newzbuf_float == NULL) {
+ IMB_freezbuffloatImBuf(ibuf);
+ }
+ }
+
+ 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;
- for (x = newx; x > 0; x--) {
- *newrect++ = rect[ofsx >> 16];
- ofsx += stepx;
+ for (x = newx; x > 0; x--, ofsx += stepx) {
+ *newzbuf++ = zbuf[ofsx >> 16];
}
}
-
+
+ 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);
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;
ofsy = 32768;
- for (y = newy; y > 0; y--) {
+ for (y = newy; y > 0; y--, ofsy += stepy) {
if (do_rect) {
rect = ibuf->rect;
rect += (ofsy >> 16) * ibuf->x;
- }
- if (do_float) {
- rectf = (struct imbufRGBA *)ibuf->rect_float;
- rectf += (ofsy >> 16) * ibuf->x;
- }
- ofsy += stepy;
- ofsx = 32768;
-
- if (do_rect) {
- for (x = newx; x > 0; x--) {
+ ofsx = 32768;
+
+ for (x = newx; x > 0; x--, ofsx += stepx) {
*newrect++ = rect[ofsx >> 16];
- ofsx += stepx;
}
}
if (do_float) {
+ rectf = (struct imbufRGBA *)ibuf->rect_float;
+ rectf += (ofsy >> 16) * ibuf->x;
ofsx = 32768;
- for (x = newx; x > 0; x--) {
+
+ for (x = newx; x > 0; x--, ofsx += stepx) {
*newrectf++ = rectf[ofsx >> 16];
- ofsx += stepx;
}
}
}