summaryrefslogtreecommitdiff
path: root/source/fitz/load-jpx.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-29 23:40:18 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-12-14 20:39:19 +0100
commit353335db5161b7e5188ebab2f918664ab2b56af0 (patch)
tree7c17bbf9a5cab3e7f3383f0e32d27e43f4d5cd50 /source/fitz/load-jpx.c
parent2c9b27cf0d29362973cef56bf7abf60ff7e72f10 (diff)
downloadmupdf-353335db5161b7e5188ebab2f918664ab2b56af0.tar.xz
jpx: Use macro to check for palette.
Diffstat (limited to 'source/fitz/load-jpx.c')
-rw-r--r--source/fitz/load-jpx.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/fitz/load-jpx.c b/source/fitz/load-jpx.c
index 1e5fad3b..0c9946ae 100644
--- a/source/fitz/load-jpx.c
+++ b/source/fitz/load-jpx.c
@@ -11,6 +11,13 @@ typedef struct stream_block_s stream_block;
#define MAX_ALPHAS 1
#define MAX_COMPONENTS (MAX_COLORS + MAX_ALPHAS)
+#define HAS_PALETTE(cs) ( \
+ (cs) == cJP2_Colorspace_Palette_Gray || \
+ (cs) == cJP2_Colorspace_Palette_RGBa || \
+ (cs) == cJP2_Colorspace_Palette_RGB_YCCa || \
+ (cs) == cJP2_Colorspace_Palette_CIE_LABa || \
+ (cs) == cJP2_Colorspace_Palette_ICCa || \
+ (cs) == cJP2_Colorspace_Palette_CMYKa)
struct fz_jpxd_s
{
@@ -265,12 +272,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, unsigned char *data, size_t size
if (err != cJP2_Error_OK)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot get colorspace: %d", (int) err);
- if (state->colorspace == cJP2_Colorspace_Palette_Gray ||
- state->colorspace == cJP2_Colorspace_Palette_RGBa ||
- state->colorspace == cJP2_Colorspace_Palette_RGB_YCCa ||
- state->colorspace == cJP2_Colorspace_Palette_CIE_LABa ||
- state->colorspace == cJP2_Colorspace_Palette_ICCa ||
- state->colorspace == cJP2_Colorspace_Palette_CMYKa)
+ if (HAS_PALETTE(state->colorspace))
{
err = JP2_Decompress_GetPalette(state->doc, &state->palette);
if (err != cJP2_Error_OK)
@@ -306,7 +308,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, unsigned char *data, size_t size
state->nchans = colors + alphas;
- if (state->palette)
+ if (HAS_PALETTE(state->colorspace))
{
err = JP2_Decompress_GetProp(state->doc, cJP2_Prop_Width, &state->width, -1, 0);
if (err != cJP2_Error_OK)
@@ -396,7 +398,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, unsigned char *data, size_t size
}
}
- if (state->palette && !fz_colorspace_is_indexed(ctx, state->cs))
+ if (HAS_PALETTE(state->colorspace) && !fz_colorspace_is_indexed(ctx, state->cs))
state->expand_indexed = 1;
if (!onlymeta)
@@ -418,7 +420,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, unsigned char *data, size_t size
if (state->colorspace == cJP2_Colorspace_RGB_YCCa)
jpx_ycc_to_rgb(ctx, state);
- if (state->pix->alpha && ! (state->palette && !state->expand_indexed))
+ if (state->pix->alpha && ! (HAS_PALETTE(state->colorspace) && !state->expand_indexed))
{
/* CMYK is a subtractive colorspace, we want additive for premul alpha */
if (state->pix->n == 5)