diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-10-10 18:52:18 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-10-10 20:01:13 +0100 |
commit | e0505043f7d784536a9552ef918d63968f3bd530 (patch) | |
tree | 87dd48cf28217103c8261390643c20f98c665161 /source | |
parent | bc9fdb018f48a5c68bb055e21941289f41665a7e (diff) | |
download | mupdf-e0505043f7d784536a9552ef918d63968f3bd530.tar.xz |
PDF Images: Add a flag for if we need to apply the decode array
This avoids us having to check the entire array each time, and
makes the next commit simpler.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/draw-unpack.c | 6 | ||||
-rw-r--r-- | source/fitz/image.c | 14 |
2 files changed, 12 insertions, 8 deletions
diff --git a/source/fitz/draw-unpack.c b/source/fitz/draw-unpack.c index ba11cd3e..35ee9b41 100644 --- a/source/fitz/draw-unpack.c +++ b/source/fitz/draw-unpack.c @@ -231,23 +231,17 @@ fz_decode_tile(fz_context *ctx, fz_pixmap *pix, const float *decode) int stride = pix->stride - pix->w * pix->n; int len; int n = fz_maxi(1, pix->n - pix->alpha); - int needed; int k; int h; - 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; - h = pix->h; while (h--) { diff --git a/source/fitz/image.c b/source/fitz/image.c index 77344a16..3420067d 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -342,7 +342,7 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image fz_drop_pixmap(ctx, tile); tile = conv; } - else + else if (image->use_decode) { fz_decode_tile(ctx, tile, image->decode); } @@ -770,6 +770,7 @@ fz_new_image(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, fz_image_get_size_fn *get_size, fz_drop_image_fn *drop) { fz_image *image; + int i; assert(mask == NULL || mask->mask == NULL); assert(size >= sizeof(fz_image)); @@ -792,18 +793,27 @@ fz_new_image(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, image->use_colorkey = (colorkey != NULL); if (colorkey) memcpy(image->colorkey, colorkey, sizeof(int)*image->n*2); + image->use_decode = 0; if (decode) + { memcpy(image->decode, decode, sizeof(float)*image->n*2); + } else { float maxval = fz_colorspace_is_indexed(ctx, colorspace) ? (1 << bpc) - 1 : 1; - int i; for (i = 0; i < image->n; i++) { image->decode[2*i] = 0; image->decode[2*i+1] = maxval; } } + for (i = 0; i < image->n; i++) + { + if (image->decode[i * 2] * 255 != 0 || image->decode[i * 2 + 1] * 255 != 255) + break; + } + if (i != image->n) + image->use_decode = 1; image->mask = mask; return image; |