| Index: jdapimin.c
|
| diff --git a/jdapimin.c b/jdapimin.c
|
| index cadb59fce3aa1cc239e86c592774cc500e109613..f80a14667fc8ea7c4bbeebe18ba09980482dc882 100644
|
| --- a/jdapimin.c
|
| +++ b/jdapimin.c
|
| @@ -1,9 +1,12 @@
|
| /*
|
| * jdapimin.c
|
| *
|
| + * This file was part of the Independent JPEG Group's software:
|
| * Copyright (C) 1994-1998, Thomas G. Lane.
|
| - * This file is part of the Independent JPEG Group's software.
|
| - * For conditions of distribution and use, see the accompanying README file.
|
| + * libjpeg-turbo Modifications:
|
| + * Copyright (C) 2016, D. R. Commander.
|
| + * For conditions of distribution and use, see the accompanying README.ijg
|
| + * file.
|
| *
|
| * This file contains application interface code for the decompression half
|
| * of the JPEG library. These are the "minimum" API routines that may be
|
| @@ -19,6 +22,7 @@
|
| #define JPEG_INTERNALS
|
| #include "jinclude.h"
|
| #include "jpeglib.h"
|
| +#include "jdmaster.h"
|
|
|
|
|
| /*
|
| @@ -32,12 +36,12 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
| int i;
|
|
|
| /* Guard against version mismatches between library and caller. */
|
| - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
|
| + cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
|
| if (version != JPEG_LIB_VERSION)
|
| ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
| - if (structsize != SIZEOF(struct jpeg_decompress_struct))
|
| - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
| - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
|
| + if (structsize != sizeof(struct jpeg_decompress_struct))
|
| + ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
| + (int) sizeof(struct jpeg_decompress_struct), (int) structsize);
|
|
|
| /* For debugging purposes, we zero the whole master structure.
|
| * But the application has already set the err pointer, and may have set
|
| @@ -48,7 +52,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
| {
|
| struct jpeg_error_mgr * err = cinfo->err;
|
| void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
| - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));
|
| + MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
|
| cinfo->err = err;
|
| cinfo->client_data = client_data;
|
| }
|
| @@ -80,6 +84,14 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
|
|
| /* OK, I'm ready */
|
| cinfo->global_state = DSTATE_START;
|
| +
|
| + /* The master struct is used to store extension parameters, so we allocate it
|
| + * here.
|
| + */
|
| + cinfo->master = (struct jpeg_decomp_master *)
|
| + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
| + sizeof(my_decomp_master));
|
| + MEMZERO(cinfo->master, sizeof(my_decomp_master));
|
| }
|
|
|
|
|
| @@ -121,22 +133,22 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
| cinfo->jpeg_color_space = JCS_GRAYSCALE;
|
| cinfo->out_color_space = JCS_GRAYSCALE;
|
| break;
|
| -
|
| +
|
| case 3:
|
| if (cinfo->saw_JFIF_marker) {
|
| cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
|
| } else if (cinfo->saw_Adobe_marker) {
|
| switch (cinfo->Adobe_transform) {
|
| case 0:
|
| - cinfo->jpeg_color_space = JCS_RGB;
|
| - break;
|
| + cinfo->jpeg_color_space = JCS_RGB;
|
| + break;
|
| case 1:
|
| - cinfo->jpeg_color_space = JCS_YCbCr;
|
| - break;
|
| + cinfo->jpeg_color_space = JCS_YCbCr;
|
| + break;
|
| default:
|
| - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
| - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
| - break;
|
| + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
| + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
| + break;
|
| }
|
| } else {
|
| /* Saw no special markers, try to guess from the component IDs */
|
| @@ -145,31 +157,31 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
| int cid2 = cinfo->comp_info[2].component_id;
|
|
|
| if (cid0 == 1 && cid1 == 2 && cid2 == 3)
|
| - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
|
| + cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
|
| else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
|
| - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
| + cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
| else {
|
| - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
| - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
| + TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
| + cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
| }
|
| }
|
| /* Always guess RGB is proper output colorspace. */
|
| cinfo->out_color_space = JCS_RGB;
|
| break;
|
| -
|
| +
|
| case 4:
|
| if (cinfo->saw_Adobe_marker) {
|
| switch (cinfo->Adobe_transform) {
|
| case 0:
|
| - cinfo->jpeg_color_space = JCS_CMYK;
|
| - break;
|
| + cinfo->jpeg_color_space = JCS_CMYK;
|
| + break;
|
| case 2:
|
| - cinfo->jpeg_color_space = JCS_YCCK;
|
| - break;
|
| + cinfo->jpeg_color_space = JCS_YCCK;
|
| + break;
|
| default:
|
| - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
| - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
|
| - break;
|
| + WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
| + cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
|
| + break;
|
| }
|
| } else {
|
| /* No special markers, assume straight CMYK. */
|
| @@ -177,7 +189,7 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
| }
|
| cinfo->out_color_space = JCS_CMYK;
|
| break;
|
| -
|
| +
|
| default:
|
| cinfo->jpeg_color_space = JCS_UNKNOWN;
|
| cinfo->out_color_space = JCS_UNKNOWN;
|
| @@ -185,7 +197,7 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
| }
|
|
|
| /* Set defaults for other decompression parameters. */
|
| - cinfo->scale_num = 1; /* 1:1 scaling */
|
| + cinfo->scale_num = 1; /* 1:1 scaling */
|
| cinfo->scale_denom = 1;
|
| cinfo->output_gamma = 1.0;
|
| cinfo->buffered_image = FALSE;
|
| @@ -253,7 +265,7 @@ jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
| retcode = JPEG_HEADER_OK;
|
| break;
|
| case JPEG_REACHED_EOI:
|
| - if (require_image) /* Complain if application wanted an image */
|
| + if (require_image) /* Complain if application wanted an image */
|
| ERREXIT(cinfo, JERR_NO_IMAGE);
|
| /* Reset to start state; it would be safer to require the application to
|
| * call jpeg_abort, but we can't change it now for compatibility reasons.
|
| @@ -385,7 +397,7 @@ jpeg_finish_decompress (j_decompress_ptr cinfo)
|
| /* Read until EOI */
|
| while (! cinfo->inputctl->eoi_reached) {
|
| if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
| - return FALSE; /* Suspend, come back later */
|
| + return FALSE; /* Suspend, come back later */
|
| }
|
| /* Do final cleanup */
|
| (*cinfo->src->term_source) (cinfo);
|
|
|