summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-07-25 13:34:38 +0000
committerTor Andersson <tor@ghostscript.com>2010-07-25 13:34:38 +0000
commitbf7a5bbe52b3d6f74db37756518c4215a3c04a62 (patch)
tree1a953168844898852176c8d1dec8db62680bf3a8
parentf1cac331247fbf673e02bdb8a657e4cf56a88cb1 (diff)
downloadmupdf-bf7a5bbe52b3d6f74db37756518c4215a3c04a62.tar.xz
Use a separate decodetile function for non-indexed images.
-rw-r--r--draw/imageunpack.c49
-rw-r--r--fitz/fitz.h3
-rw-r--r--mupdf/pdf_image.c6
3 files changed, 45 insertions, 13 deletions
diff --git a/draw/imageunpack.c b/draw/imageunpack.c
index a1afe49b..4465d587 100644
--- a/draw/imageunpack.c
+++ b/draw/imageunpack.c
@@ -161,11 +161,10 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in
/* Apply decode array */
void
-fz_decodetile(fz_pixmap *pix, float *decode, int maxval)
+fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval)
{
- int min[FZ_MAXCOLORS];
- int max[FZ_MAXCOLORS];
- int sub[FZ_MAXCOLORS];
+ int add[FZ_MAXCOLORS];
+ int mul[FZ_MAXCOLORS];
unsigned char *p = pix->samples;
int len = pix->w * pix->h;
int n = pix->n - 1;
@@ -175,10 +174,11 @@ fz_decodetile(fz_pixmap *pix, float *decode, int maxval)
needed = 0;
for (k = 0; k < n; k++)
{
- min[k] = decode[k * 2] * 256;
- max[k] = decode[k * 2 + 1] * 256;
- sub[k] = (max[k] - min[k]) / maxval;
- needed |= min[k] != 0 || max[k] != maxval * 256;
+ int min = decode[k * 2] * 256;
+ int max = decode[k * 2 + 1] * 256;
+ add[k] = min;
+ mul[k] = (max - min) / maxval;
+ needed |= min != 0 || max != maxval * 256;
}
if (!needed)
@@ -187,8 +187,39 @@ fz_decodetile(fz_pixmap *pix, float *decode, int maxval)
while (len--)
{
for (k = 0; k < n; k++)
- p[k] = (min[k] + (((p[k] << 8) * sub[k]) >> 8)) >> 8;
+ p[k] = (add[k] + (((p[k] << 8) * mul[k]) >> 8)) >> 8;
p += n + 1;
}
}
+void
+fz_decodetile(fz_pixmap *pix, float *decode)
+{
+ int add[FZ_MAXCOLORS];
+ int mul[FZ_MAXCOLORS];
+ unsigned char *p = pix->samples;
+ int len = pix->w * pix->h;
+ int n = pix->n - 1;
+ int needed;
+ int k;
+
+ needed = 0;
+ for (k = 0; k < n; k++)
+ {
+ int min = decode[k * 2] * 255;
+ int max = decode[k * 2 + 1] * 255;
+ add[k] = min;
+ mul[k] = max - min;
+ needed |= min != 0 || max != 255;
+ }
+
+ if (!needed)
+ return;
+
+ while (len--)
+ {
+ for (k = 0; k < n; k++)
+ p[k] = add[k] + fz_mul255(p[k], mul[k]);
+ p += n + 1;
+ }
+}
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 5aa2dd0b..150c3e56 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -1135,7 +1135,8 @@ void fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix ctm);
void fz_accelerate(void);
void fz_acceleratearch(void);
-void fz_decodetile(fz_pixmap *pix, float *decode, int maxval);
+void fz_decodetile(fz_pixmap *pix, float *decode);
+void fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval);
void fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale);
void fz_blendpixmapswithmode(fz_pixmap *dst, fz_pixmap *src, fz_blendmode blendmode);
diff --git a/mupdf/pdf_image.c b/mupdf/pdf_image.c
index ce258c10..24b25751 100644
--- a/mupdf/pdf_image.c
+++ b/mupdf/pdf_image.c
@@ -53,7 +53,7 @@ pdf_loadimageheader(pdf_image **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict)
if (img->h == 0)
fz_warn("image height is zero");
if (img->bpc == 0)
- fz_warn("image bit depth is zero"); /* okay for JPX */
+ img->bpc = 8; /* for JPX */
obj = fz_dictgetsa(dict, "ColorSpace", "CS");
if (obj)
@@ -278,7 +278,7 @@ pdf_loadtile(pdf_image *img /* ...bbox/y+h should go here... */)
{
fz_pixmap *conv;
- fz_decodetile(tile, img->decode, (1 << img->bpc) - 1);
+ fz_decodeindexedtile(tile, img->decode, (1 << img->bpc) - 1);
conv = pdf_expandindexedpixmap(tile);
fz_droppixmap(tile);
@@ -286,7 +286,7 @@ pdf_loadtile(pdf_image *img /* ...bbox/y+h should go here... */)
}
else
{
- fz_decodetile(tile, img->decode, 1);
+ fz_decodetile(tile, img->decode);
}
return tile;