diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-06-26 18:45:26 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-06-29 12:15:18 +0100 |
commit | 2bb213c70d42e398ef7ea3b6551c8fbb865cf3bd (patch) | |
tree | 450c7583241f2236c82fb8ae5bedbb1c0d664ec3 /source/fitz/compressed-buffer.c | |
parent | 051b4932219bed310e17505b2e73029d371a18ce (diff) | |
download | mupdf-2bb213c70d42e398ef7ea3b6551c8fbb865cf3bd.tar.xz |
Further tweaks to fz_image handling.
Ensure that subsampling and caching happen in the generic image
code, not in the specific.
Previously, the subsampling happened only for images that were
decoded from streams. Images that were loaded direct were never
subsampled and hence were always cached at full size. After this
change both classes of image are correctly subsampled, and
the subsampled version kept in the cache.
This produces various image diffs in the cluster, none of which
are noticable to the naked eye.
Diffstat (limited to 'source/fitz/compressed-buffer.c')
-rw-r--r-- | source/fitz/compressed-buffer.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/source/fitz/compressed-buffer.c b/source/fitz/compressed-buffer.c index d1c73351..2c5dd93f 100644 --- a/source/fitz/compressed-buffer.c +++ b/source/fitz/compressed-buffer.c @@ -24,11 +24,11 @@ fz_open_image_decomp_stream_from_buffer(fz_context *ctx, fz_compressed_buffer *b fz_stream * fz_open_image_decomp_stream(fz_context *ctx, fz_stream *chain, fz_compression_params *params, int *l2factor) { + int our_l2factor = 0; + switch (params->type) { case FZ_IMAGE_FAX: - if (l2factor) - *l2factor = 0; return fz_open_faxd(ctx, chain, params->u.fax.k, params->u.fax.end_of_line, @@ -38,30 +38,27 @@ fz_open_image_decomp_stream(fz_context *ctx, fz_stream *chain, fz_compression_pa params->u.fax.end_of_block, params->u.fax.black_is_1); case FZ_IMAGE_JPEG: - if (l2factor && *l2factor > 3) - *l2factor = 3; - return fz_open_dctd(ctx, chain, params->u.jpeg.color_transform, l2factor ? *l2factor : 0, NULL); - case FZ_IMAGE_RLD: if (l2factor) - *l2factor = 0; + { + our_l2factor = *l2factor; + if (our_l2factor > 3) + our_l2factor = 3; + *l2factor -= our_l2factor; + } + return fz_open_dctd(ctx, chain, params->u.jpeg.color_transform, our_l2factor, NULL); + case FZ_IMAGE_RLD: return fz_open_rld(ctx, chain); case FZ_IMAGE_FLATE: - if (l2factor) - *l2factor = 0; chain = fz_open_flated(ctx, chain, 15); if (params->u.flate.predictor > 1) chain = fz_open_predict(ctx, chain, params->u.flate.predictor, params->u.flate.columns, params->u.flate.colors, params->u.flate.bpc); return chain; case FZ_IMAGE_LZW: - if (l2factor) - *l2factor = 0; chain = fz_open_lzwd(ctx, chain, params->u.lzw.early_change); if (params->u.lzw.predictor > 1) chain = fz_open_predict(ctx, chain, params->u.lzw.predictor, params->u.lzw.columns, params->u.lzw.colors, params->u.lzw.bpc); return chain; default: - if (l2factor) - *l2factor = 0; break; } |