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
path: root/source
diff options
context:
space:
mode:
authorSv. Lockal <lockalsash@gmail.com>2012-08-08 16:15:26 +0400
committerSv. Lockal <lockalsash@gmail.com>2012-08-08 16:15:26 +0400
commit6292fed832241f109b54c47815ce921079bca869 (patch)
tree22a3655d35dbec2bbbd64f05d4a2bcc1a14a2de5 /source
parent572c82e74ea3bd9bfea2df8b4527b37c8ef075db (diff)
Fix logic error in mipmap filter and refactor scaling routine to lower self cost by ~30%
Diffstat (limited to 'source')
-rw-r--r--source/blender/imbuf/intern/filter.c16
-rw-r--r--source/blender/imbuf/intern/scaling.c59
2 files changed, 39 insertions, 36 deletions
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 7804ee1fdf1..678b2908b96 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -226,24 +226,24 @@ void IMB_filterN(ImBuf *out, ImBuf *in)
for (x = 0; x < rowlen; x++) {
if (x == 0) {
r11 = row1;
- r21 = row1;
- r31 = row1;
+ r21 = row2;
+ r31 = row3;
}
else {
r11 = row1 - 4;
- r21 = row1 - 4;
- r31 = row1 - 4;
+ r21 = row2 - 4;
+ r31 = row3 - 4;
}
if (x == rowlen - 1) {
r13 = row1;
- r23 = row1;
- r33 = row1;
+ r23 = row2;
+ r33 = row3;
}
else {
r13 = row1 + 4;
- r23 = row1 + 4;
- r33 = row1 + 4;
+ r23 = row2 + 4;
+ r33 = row3 + 4;
}
cp[0] = (r11[0] + 2 * row1[0] + r13[0] + 2 * r21[0] + 4 * row2[0] + 2 * r23[0] + r31[0] + 2 * row3[0] + r33[0]) >> 4;
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index a57926f0202..ea1d483090c 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -295,9 +295,7 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
/* result in ibuf2, scaling should be done correctly */
void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
{
- uchar *p1, *p2 = NULL, *dest;
- float *p1f, *destf, *p2f = NULL;
- int x, y;
+ int x, y;
const short do_rect = (ibuf1->rect != NULL);
const short do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL);
@@ -305,16 +303,14 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
imb_addrectImBuf(ibuf2);
}
- p1f = ibuf1->rect_float;
- destf = ibuf2->rect_float;
- p1 = (uchar *) ibuf1->rect;
- dest = (uchar *) ibuf2->rect;
-
- for (y = ibuf2->y; y > 0; y--) {
- if (do_rect) p2 = p1 + (ibuf1->x << 2);
- if (do_float) p2f = p1f + (ibuf1->x << 2);
- for (x = ibuf2->x; x > 0; x--) {
- if (do_rect) {
+ if (do_rect) {
+ char *p1, *p2, *dest;
+
+ p1 = (char *) ibuf1->rect;
+ dest = (char *) ibuf2->rect;
+ for (y = ibuf2->y; y > 0; y--) {
+ p2 = p1 + (ibuf1->x << 2);
+ for (x = ibuf2->x; x > 0; x--) {
dest[0] = (p1[0] + p2[0] + p1[4] + p2[4]) >> 2;
dest[1] = (p1[1] + p2[1] + p1[5] + p2[5]) >> 2;
dest[2] = (p1[2] + p2[2] + p1[6] + p2[6]) >> 2;
@@ -323,24 +319,31 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
p2 += 8;
dest += 4;
}
- if (do_float) {
- destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
- destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
- destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
- destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
- p1f += 8;
- p2f += 8;
- destf += 4;
- }
- }
- if (do_rect) p1 = p2;
- if (do_float) p1f = p2f;
- if (ibuf1->x & 1) {
- if (do_rect) p1 += 4;
- if (do_float) p1f += 4;
+ p1 = p2;
+ if (ibuf1->x & 1) p1 += 4;
}
}
+ if (do_float) {
+ float *p1f, *p2f, *destf;
+
+ p1f = ibuf1->rect_float;
+ destf = ibuf2->rect_float;
+ for (y = ibuf2->y; y > 0; y--) {
+ p2f = p1f + (ibuf1->x << 2);
+ for (x = ibuf2->x; x > 0; x--) {
+ destf[0] = 0.25f * (p1f[0] + p2f[0] + p1f[4] + p2f[4]);
+ destf[1] = 0.25f * (p1f[1] + p2f[1] + p1f[5] + p2f[5]);
+ destf[2] = 0.25f * (p1f[2] + p2f[2] + p1f[6] + p2f[6]);
+ destf[3] = 0.25f * (p1f[3] + p2f[3] + p1f[7] + p2f[7]);
+ p1f += 8;
+ p2f += 8;
+ destf += 4;
+ }
+ p1f = p2f;
+ if (ibuf1->x & 1) p1f += 4;
+ }
+ }
}
ImBuf *IMB_onehalf(struct ImBuf *ibuf1)