summaryrefslogtreecommitdiff
path: root/raster
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2008-07-01 01:22:51 +0200
committerTor Andersson <tor@ghostscript.com>2008-07-01 01:22:51 +0200
commit8c018dd9c020e33aaf0cd520b3f89c3018dbb423 (patch)
tree539ed62a44bc224c1db97c935cda241f72e84d80 /raster
parentd4028cf9448d7e7b85b2c41442edbd9ab8c721cc (diff)
downloadmupdf-8c018dd9c020e33aaf0cd520b3f89c3018dbb423.tar.xz
Fix band height calculation bug.
Diffstat (limited to 'raster')
-rw-r--r--raster/imagescale.c44
-rw-r--r--raster/render.c7
2 files changed, 27 insertions, 24 deletions
diff --git a/raster/imagescale.c b/raster/imagescale.c
index 7ce942fb..f25d4d5a 100644
--- a/raster/imagescale.c
+++ b/raster/imagescale.c
@@ -195,7 +195,7 @@ fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xde
unsigned char *dstsamples;
int y, iy, oy;
int ow, oh, n;
- int ydenom2 = ydenom;
+ int remaining;
void (*srowx)(byte *src, byte *dst, int w, int denom) = nil;
void (*scolx)(byte *src, byte *dst, int w, int denom) = nil;
@@ -231,17 +231,17 @@ fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xde
srowx(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom);
- scolx(buf, dstsamples + oy * dst->w * n, ow, ydenom2);
+ scolx(buf, dstsamples + oy * dst->w * n, ow, ydenom);
}
- ydenom = src->h - y;
- if (ydenom)
+ remaining = src->h - y;
+ if (remaining)
{
- for (iy = 0; iy < ydenom; iy++)
+ for (iy = 0; iy < remaining; iy++)
srowx(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom);
- scolx(buf, dstsamples + oy * dst->w * n, ow, ydenom2);
+ scolx(buf, dstsamples + oy * dst->w * n, ow, ydenom);
}
}
@@ -253,17 +253,17 @@ fz_scalepixmaptile(fz_pixmap *dst, int xoffs, int yoffs, fz_pixmap *src, int xde
fz_srown(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom, n);
- fz_scoln(buf, dstsamples + oy * dst->w * n, ow, ydenom2, n);
+ fz_scoln(buf, dstsamples + oy * dst->w * n, ow, ydenom, n);
}
- ydenom = src->h - y;
- if (ydenom)
+ remaining = src->h - y;
+ if (remaining)
{
- for (iy = 0; iy < ydenom; iy++)
+ for (iy = 0; iy < remaining; iy++)
fz_srown(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom, n);
- fz_scoln(buf, dstsamples + oy * dst->w * n, ow, ydenom2, n);
+ fz_scoln(buf, dstsamples + oy * dst->w * n, ow, ydenom, n);
}
}
@@ -279,7 +279,7 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
unsigned char *buf;
int y, iy, oy;
int ow, oh, n;
- int ydenom2 = ydenom;
+ int remaining;
void (*srowx)(byte *src, byte *dst, int w, int denom) = nil;
void (*scolx)(byte *src, byte *dst, int w, int denom) = nil;
@@ -315,17 +315,17 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
srowx(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom);
- scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2);
+ scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom);
}
- ydenom = src->h - y;
- if (ydenom)
+ remaining = src->h - y;
+ if (remaining)
{
- for (iy = 0; iy < ydenom; iy++)
+ for (iy = 0; iy < remaining; iy++)
srowx(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom);
- scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2);
+ scolx(buf, dst->samples + oy * dst->w * n, dst->w, ydenom);
}
}
@@ -337,17 +337,17 @@ fz_scalepixmap(fz_pixmap **dstp, fz_pixmap *src, int xdenom, int ydenom)
fz_srown(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom, n);
- fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2, n);
+ fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom, n);
}
- ydenom = src->h - y;
- if (ydenom)
+ remaining = src->h - y;
+ if (remaining)
{
- for (iy = 0; iy < ydenom; iy++)
+ for (iy = 0; iy < remaining; iy++)
fz_srown(src->samples + (y + iy) * src->w * n,
buf + iy * ow * n,
src->w, xdenom, n);
- fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom2, n);
+ fz_scoln(buf, dst->samples + oy * dst->w * n, dst->w, ydenom, n);
}
}
diff --git a/raster/render.c b/raster/render.c
index d2532971..c7d836c8 100644
--- a/raster/render.c
+++ b/raster/render.c
@@ -413,8 +413,11 @@ DEBUG("image %dx%d %d+%d %s\n{\n", image->w, image->h, image->n, image->a, image
calcimagescale(ctm, image->w, image->h, &dx, &dy);
- /* y-banded loading/scaling of image, more cache-friendly */
- tileheight = MAX(512*1024/(image->w * (image->n + image->a)), dy);
+ /* try to fit tile into a typical L2 cachce */
+ tileheight = 512 * 1024 / (image->w * (image->n + image->a));
+ /* tileheight must be an even multiple of dy, except for last band */
+ tileheight = (tileheight + dy - 1) / dy * dy;
+
if ((dx != 1 || dy != 1) && image->h > tileheight) {
int y = 0;