Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * jdmaster.c |
| 3 | * |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 4 | * Copyright (C) 1991-1997, Thomas G. Lane. |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 5 | * Copyright (C) 2009-2011, D. R. Commander. |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 6 | * This file is part of the Independent JPEG Group's software. |
| 7 | * For conditions of distribution and use, see the accompanying README file. |
| 8 | * |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 9 | * This file contains master control logic for the JPEG decompressor. |
| 10 | * These routines are concerned with selecting the modules to be executed |
| 11 | * and with determining the number of passes and the work to be done in each |
| 12 | * pass. |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 13 | */ |
| 14 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 15 | #define JPEG_INTERNALS |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 16 | #include "jinclude.h" |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 17 | #include "jpeglib.h" |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 18 | #include "jpegcomp.h" |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 19 | |
| 20 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 21 | /* Private state */ |
| 22 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 23 | typedef struct { |
| 24 | struct jpeg_decomp_master pub; /* public fields */ |
| 25 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 26 | int pass_number; /* # of passes completed */ |
| 27 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 28 | boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ |
| 29 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 30 | /* Saved references to initialized quantizer modules, |
| 31 | * in case we need to switch modes. |
| 32 | */ |
| 33 | struct jpeg_color_quantizer * quantizer_1pass; |
| 34 | struct jpeg_color_quantizer * quantizer_2pass; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 35 | } my_decomp_master; |
| 36 | |
| 37 | typedef my_decomp_master * my_master_ptr; |
| 38 | |
| 39 | |
| 40 | /* |
| 41 | * Determine whether merged upsample/color conversion should be used. |
| 42 | * CRUCIAL: this must match the actual capabilities of jdmerge.c! |
| 43 | */ |
| 44 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 45 | LOCAL(boolean) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 46 | use_merged_upsample (j_decompress_ptr cinfo) |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 47 | { |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 48 | #ifdef UPSAMPLE_MERGING_SUPPORTED |
| 49 | /* Merging is the equivalent of plain box-filter upsampling */ |
| 50 | if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) |
| 51 | return FALSE; |
| 52 | /* jdmerge.c only supports YCC=>RGB color conversion */ |
| 53 | if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 54 | (cinfo->out_color_space != JCS_RGB && |
| 55 | cinfo->out_color_space != JCS_EXT_RGB && |
| 56 | cinfo->out_color_space != JCS_EXT_RGBX && |
| 57 | cinfo->out_color_space != JCS_EXT_BGR && |
| 58 | cinfo->out_color_space != JCS_EXT_BGRX && |
| 59 | cinfo->out_color_space != JCS_EXT_XBGR && |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 60 | cinfo->out_color_space != JCS_EXT_XRGB && |
| 61 | cinfo->out_color_space != JCS_EXT_RGBA && |
| 62 | cinfo->out_color_space != JCS_EXT_BGRA && |
| 63 | cinfo->out_color_space != JCS_EXT_ABGR && |
| 64 | cinfo->out_color_space != JCS_EXT_ARGB) || |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 65 | cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 66 | return FALSE; |
| 67 | /* and it only handles 2h1v or 2h2v sampling ratios */ |
| 68 | if (cinfo->comp_info[0].h_samp_factor != 2 || |
| 69 | cinfo->comp_info[1].h_samp_factor != 1 || |
| 70 | cinfo->comp_info[2].h_samp_factor != 1 || |
| 71 | cinfo->comp_info[0].v_samp_factor > 2 || |
| 72 | cinfo->comp_info[1].v_samp_factor != 1 || |
| 73 | cinfo->comp_info[2].v_samp_factor != 1) |
| 74 | return FALSE; |
| 75 | /* furthermore, it doesn't work if we've scaled the IDCTs differently */ |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 76 | if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size || |
| 77 | cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size || |
| 78 | cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 79 | return FALSE; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 80 | /* ??? also need to test for upsample-time rescaling, when & if supported */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 81 | return TRUE; /* by golly, it'll work... */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 82 | #else |
| 83 | return FALSE; |
| 84 | #endif |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 88 | /* |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 89 | * Compute output image dimensions and related values. |
| 90 | * NOTE: this is exported for possible use by application. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 91 | * Hence it mustn't do anything that can't be done twice. |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 92 | * Also note that it may be called before the master module is initialized! |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 93 | */ |
| 94 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 95 | GLOBAL(void) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 96 | jpeg_calc_output_dimensions (j_decompress_ptr cinfo) |
| 97 | /* Do computations that are needed before master selection phase */ |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 98 | { |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 99 | #ifdef IDCT_SCALING_SUPPORTED |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 100 | int ci; |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 101 | jpeg_component_info *compptr; |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 102 | #endif |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 103 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 104 | /* Prevent application from calling me at wrong times */ |
| 105 | if (cinfo->global_state != DSTATE_READY) |
| 106 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 107 | |
| 108 | #ifdef IDCT_SCALING_SUPPORTED |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 109 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 110 | /* Compute actual output image dimensions and DCT scaling choices. */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 111 | if (cinfo->scale_num * 8 <= cinfo->scale_denom) { |
| 112 | /* Provide 1/8 scaling */ |
| 113 | cinfo->output_width = (JDIMENSION) |
| 114 | jdiv_round_up((long) cinfo->image_width, 8L); |
| 115 | cinfo->output_height = (JDIMENSION) |
| 116 | jdiv_round_up((long) cinfo->image_height, 8L); |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 117 | #if JPEG_LIB_VERSION >= 70 |
| 118 | cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 1; |
| 119 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 120 | cinfo->min_DCT_scaled_size = 1; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 121 | #endif |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 122 | } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { |
| 123 | /* Provide 1/4 scaling */ |
| 124 | cinfo->output_width = (JDIMENSION) |
| 125 | jdiv_round_up((long) cinfo->image_width, 4L); |
| 126 | cinfo->output_height = (JDIMENSION) |
| 127 | jdiv_round_up((long) cinfo->image_height, 4L); |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 128 | #if JPEG_LIB_VERSION >= 70 |
| 129 | cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 2; |
| 130 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 131 | cinfo->min_DCT_scaled_size = 2; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 132 | #endif |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 133 | } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { |
| 134 | /* Provide 1/2 scaling */ |
| 135 | cinfo->output_width = (JDIMENSION) |
| 136 | jdiv_round_up((long) cinfo->image_width, 2L); |
| 137 | cinfo->output_height = (JDIMENSION) |
| 138 | jdiv_round_up((long) cinfo->image_height, 2L); |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 139 | #if JPEG_LIB_VERSION >= 70 |
| 140 | cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = 4; |
| 141 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 142 | cinfo->min_DCT_scaled_size = 4; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 143 | #endif |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 144 | } else { |
| 145 | /* Provide 1/1 scaling */ |
| 146 | cinfo->output_width = cinfo->image_width; |
| 147 | cinfo->output_height = cinfo->image_height; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 148 | #if JPEG_LIB_VERSION >= 70 |
| 149 | cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE; |
| 150 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 151 | cinfo->min_DCT_scaled_size = DCTSIZE; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 152 | #endif |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 153 | } |
| 154 | /* In selecting the actual DCT scaling for each component, we try to |
| 155 | * scale up the chroma components via IDCT scaling rather than upsampling. |
| 156 | * This saves time if the upsampler gets to use 1:1 scaling. |
| 157 | * Note this code assumes that the supported DCT scalings are powers of 2. |
| 158 | */ |
| 159 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 160 | ci++, compptr++) { |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 161 | int ssize = cinfo->_min_DCT_scaled_size; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 162 | while (ssize < DCTSIZE && |
| 163 | (compptr->h_samp_factor * ssize * 2 <= |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 164 | cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) && |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 165 | (compptr->v_samp_factor * ssize * 2 <= |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 166 | cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size)) { |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 167 | ssize = ssize * 2; |
| 168 | } |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 169 | #if JPEG_LIB_VERSION >= 70 |
| 170 | compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize; |
| 171 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 172 | compptr->DCT_scaled_size = ssize; |
DRC | 36a6eec | 2010-10-08 08:05:44 +0000 | [diff] [blame] | 173 | #endif |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 174 | } |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 175 | |
| 176 | /* Recompute downsampled dimensions of components; |
| 177 | * application needs to know these if using raw downsampled data. |
| 178 | */ |
| 179 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 180 | ci++, compptr++) { |
| 181 | /* Size in samples, after IDCT scaling */ |
| 182 | compptr->downsampled_width = (JDIMENSION) |
| 183 | jdiv_round_up((long) cinfo->image_width * |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 184 | (long) (compptr->h_samp_factor * compptr->_DCT_scaled_size), |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 185 | (long) (cinfo->max_h_samp_factor * DCTSIZE)); |
| 186 | compptr->downsampled_height = (JDIMENSION) |
| 187 | jdiv_round_up((long) cinfo->image_height * |
DRC | 49967cd | 2010-10-09 19:57:51 +0000 | [diff] [blame] | 188 | (long) (compptr->v_samp_factor * compptr->_DCT_scaled_size), |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 189 | (long) (cinfo->max_v_samp_factor * DCTSIZE)); |
| 190 | } |
| 191 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 192 | #else /* !IDCT_SCALING_SUPPORTED */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 193 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 194 | /* Hardwire it to "no scaling" */ |
| 195 | cinfo->output_width = cinfo->image_width; |
| 196 | cinfo->output_height = cinfo->image_height; |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 197 | /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, |
| 198 | * and has computed unscaled downsampled_width and downsampled_height. |
| 199 | */ |
| 200 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 201 | #endif /* IDCT_SCALING_SUPPORTED */ |
| 202 | |
| 203 | /* Report number of components in selected colorspace. */ |
| 204 | /* Probably this should be in the color conversion module... */ |
| 205 | switch (cinfo->out_color_space) { |
| 206 | case JCS_GRAYSCALE: |
| 207 | cinfo->out_color_components = 1; |
| 208 | break; |
| 209 | case JCS_RGB: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 210 | case JCS_EXT_RGB: |
| 211 | case JCS_EXT_RGBX: |
| 212 | case JCS_EXT_BGR: |
| 213 | case JCS_EXT_BGRX: |
| 214 | case JCS_EXT_XBGR: |
| 215 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 216 | case JCS_EXT_RGBA: |
| 217 | case JCS_EXT_BGRA: |
| 218 | case JCS_EXT_ABGR: |
| 219 | case JCS_EXT_ARGB: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 220 | cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 221 | break; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 222 | case JCS_YCbCr: |
| 223 | cinfo->out_color_components = 3; |
| 224 | break; |
| 225 | case JCS_CMYK: |
| 226 | case JCS_YCCK: |
| 227 | cinfo->out_color_components = 4; |
| 228 | break; |
| 229 | default: /* else must be same colorspace as in file */ |
| 230 | cinfo->out_color_components = cinfo->num_components; |
| 231 | break; |
| 232 | } |
| 233 | cinfo->output_components = (cinfo->quantize_colors ? 1 : |
| 234 | cinfo->out_color_components); |
| 235 | |
| 236 | /* See if upsampler will want to emit more than one row at a time */ |
| 237 | if (use_merged_upsample(cinfo)) |
| 238 | cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; |
| 239 | else |
| 240 | cinfo->rec_outbuf_height = 1; |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | |
| 244 | /* |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 245 | * Several decompression processes need to range-limit values to the range |
| 246 | * 0..MAXJSAMPLE; the input value may fall somewhat outside this range |
| 247 | * due to noise introduced by quantization, roundoff error, etc. These |
| 248 | * processes are inner loops and need to be as fast as possible. On most |
| 249 | * machines, particularly CPUs with pipelines or instruction prefetch, |
| 250 | * a (subscript-check-less) C table lookup |
| 251 | * x = sample_range_limit[x]; |
| 252 | * is faster than explicit tests |
| 253 | * if (x < 0) x = 0; |
| 254 | * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; |
| 255 | * These processes all use a common table prepared by the routine below. |
| 256 | * |
| 257 | * For most steps we can mathematically guarantee that the initial value |
| 258 | * of x is within MAXJSAMPLE+1 of the legal range, so a table running from |
| 259 | * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial |
| 260 | * limiting step (just after the IDCT), a wildly out-of-range value is |
| 261 | * possible if the input data is corrupt. To avoid any chance of indexing |
| 262 | * off the end of memory and getting a bad-pointer trap, we perform the |
| 263 | * post-IDCT limiting thus: |
| 264 | * x = range_limit[x & MASK]; |
| 265 | * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit |
| 266 | * samples. Under normal circumstances this is more than enough range and |
| 267 | * a correct output will be generated; with bogus input data the mask will |
| 268 | * cause wraparound, and we will safely generate a bogus-but-in-range output. |
| 269 | * For the post-IDCT step, we want to convert the data from signed to unsigned |
| 270 | * representation by adding CENTERJSAMPLE at the same time that we limit it. |
| 271 | * So the post-IDCT limiting table ends up looking like this: |
| 272 | * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, |
| 273 | * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), |
| 274 | * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), |
| 275 | * 0,1,...,CENTERJSAMPLE-1 |
| 276 | * Negative inputs select values from the upper half of the table after |
| 277 | * masking. |
| 278 | * |
| 279 | * We can save some space by overlapping the start of the post-IDCT table |
| 280 | * with the simpler range limiting table. The post-IDCT table begins at |
| 281 | * sample_range_limit + CENTERJSAMPLE. |
| 282 | * |
| 283 | * Note that the table is allocated in near data space on PCs; it's small |
| 284 | * enough and used often enough to justify this. |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 285 | */ |
| 286 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 287 | LOCAL(void) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 288 | prepare_range_limit_table (j_decompress_ptr cinfo) |
| 289 | /* Allocate and fill in the sample_range_limit table */ |
| 290 | { |
| 291 | JSAMPLE * table; |
| 292 | int i; |
| 293 | |
| 294 | table = (JSAMPLE *) |
| 295 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 296 | (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); |
| 297 | table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ |
| 298 | cinfo->sample_range_limit = table; |
| 299 | /* First segment of "simple" table: limit[x] = 0 for x < 0 */ |
| 300 | MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); |
| 301 | /* Main part of "simple" table: limit[x] = x */ |
| 302 | for (i = 0; i <= MAXJSAMPLE; i++) |
| 303 | table[i] = (JSAMPLE) i; |
| 304 | table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ |
| 305 | /* End of simple table, rest of first half of post-IDCT table */ |
| 306 | for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) |
| 307 | table[i] = MAXJSAMPLE; |
| 308 | /* Second half of post-IDCT table */ |
| 309 | MEMZERO(table + (2 * (MAXJSAMPLE+1)), |
| 310 | (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); |
| 311 | MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), |
| 312 | cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); |
| 313 | } |
| 314 | |
| 315 | |
| 316 | /* |
| 317 | * Master selection of decompression modules. |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 318 | * This is done once at jpeg_start_decompress time. We determine |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 319 | * which modules will be used and give them appropriate initialization calls. |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 320 | * We also initialize the decompressor input side to begin consuming data. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 321 | * |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 322 | * Since jpeg_read_header has finished, we know what is in the SOF |
| 323 | * and (first) SOS markers. We also have all the application parameter |
| 324 | * settings. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 325 | */ |
| 326 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 327 | LOCAL(void) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 328 | master_selection (j_decompress_ptr cinfo) |
| 329 | { |
| 330 | my_master_ptr master = (my_master_ptr) cinfo->master; |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 331 | boolean use_c_buffer; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 332 | long samplesperrow; |
| 333 | JDIMENSION jd_samplesperrow; |
| 334 | |
| 335 | /* Initialize dimensions and other stuff */ |
| 336 | jpeg_calc_output_dimensions(cinfo); |
| 337 | prepare_range_limit_table(cinfo); |
| 338 | |
| 339 | /* Width of an output scanline must be representable as JDIMENSION. */ |
| 340 | samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; |
| 341 | jd_samplesperrow = (JDIMENSION) samplesperrow; |
| 342 | if ((long) jd_samplesperrow != samplesperrow) |
| 343 | ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); |
| 344 | |
| 345 | /* Initialize my private state */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 346 | master->pass_number = 0; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 347 | master->using_merged_upsample = use_merged_upsample(cinfo); |
| 348 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 349 | /* Color quantizer selection */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 350 | master->quantizer_1pass = NULL; |
| 351 | master->quantizer_2pass = NULL; |
| 352 | /* No mode changes if not using buffered-image mode. */ |
| 353 | if (! cinfo->quantize_colors || ! cinfo->buffered_image) { |
| 354 | cinfo->enable_1pass_quant = FALSE; |
| 355 | cinfo->enable_external_quant = FALSE; |
| 356 | cinfo->enable_2pass_quant = FALSE; |
| 357 | } |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 358 | if (cinfo->quantize_colors) { |
| 359 | if (cinfo->raw_data_out) |
| 360 | ERREXIT(cinfo, JERR_NOTIMPL); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 361 | /* 2-pass quantizer only works in 3-component color space. */ |
| 362 | if (cinfo->out_color_components != 3) { |
| 363 | cinfo->enable_1pass_quant = TRUE; |
| 364 | cinfo->enable_external_quant = FALSE; |
| 365 | cinfo->enable_2pass_quant = FALSE; |
| 366 | cinfo->colormap = NULL; |
| 367 | } else if (cinfo->colormap != NULL) { |
| 368 | cinfo->enable_external_quant = TRUE; |
| 369 | } else if (cinfo->two_pass_quantize) { |
| 370 | cinfo->enable_2pass_quant = TRUE; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 371 | } else { |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 372 | cinfo->enable_1pass_quant = TRUE; |
| 373 | } |
| 374 | |
| 375 | if (cinfo->enable_1pass_quant) { |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 376 | #ifdef QUANT_1PASS_SUPPORTED |
| 377 | jinit_1pass_quantizer(cinfo); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 378 | master->quantizer_1pass = cinfo->cquantize; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 379 | #else |
| 380 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
| 381 | #endif |
| 382 | } |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 383 | |
| 384 | /* We use the 2-pass code to map to external colormaps. */ |
| 385 | if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { |
| 386 | #ifdef QUANT_2PASS_SUPPORTED |
| 387 | jinit_2pass_quantizer(cinfo); |
| 388 | master->quantizer_2pass = cinfo->cquantize; |
| 389 | #else |
| 390 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
| 391 | #endif |
| 392 | } |
| 393 | /* If both quantizers are initialized, the 2-pass one is left active; |
| 394 | * this is necessary for starting with quantization to an external map. |
| 395 | */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | /* Post-processing: in particular, color conversion first */ |
| 399 | if (! cinfo->raw_data_out) { |
| 400 | if (master->using_merged_upsample) { |
| 401 | #ifdef UPSAMPLE_MERGING_SUPPORTED |
| 402 | jinit_merged_upsampler(cinfo); /* does color conversion too */ |
| 403 | #else |
| 404 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
| 405 | #endif |
| 406 | } else { |
| 407 | jinit_color_deconverter(cinfo); |
| 408 | jinit_upsampler(cinfo); |
| 409 | } |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 410 | jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 411 | } |
| 412 | /* Inverse DCT */ |
| 413 | jinit_inverse_dct(cinfo); |
| 414 | /* Entropy decoding: either Huffman or arithmetic coding. */ |
| 415 | if (cinfo->arith_code) { |
DRC | 66f97e6 | 2010-11-23 05:49:54 +0000 | [diff] [blame] | 416 | #ifdef D_ARITH_CODING_SUPPORTED |
Guido Vollbeding | 1e247ac | 1998-03-28 00:00:00 +0000 | [diff] [blame] | 417 | jinit_arith_decoder(cinfo); |
DRC | 66f97e6 | 2010-11-23 05:49:54 +0000 | [diff] [blame] | 418 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 419 | ERREXIT(cinfo, JERR_ARITH_NOTIMPL); |
DRC | 66f97e6 | 2010-11-23 05:49:54 +0000 | [diff] [blame] | 420 | #endif |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 421 | } else { |
| 422 | if (cinfo->progressive_mode) { |
| 423 | #ifdef D_PROGRESSIVE_SUPPORTED |
| 424 | jinit_phuff_decoder(cinfo); |
| 425 | #else |
| 426 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 427 | #endif |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 428 | } else |
| 429 | jinit_huff_decoder(cinfo); |
| 430 | } |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 431 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 432 | /* Initialize principal buffer controllers. */ |
| 433 | use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; |
| 434 | jinit_d_coef_controller(cinfo, use_c_buffer); |
| 435 | |
| 436 | if (! cinfo->raw_data_out) |
| 437 | jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 438 | |
| 439 | /* We can now tell the memory manager to allocate virtual arrays. */ |
| 440 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 441 | |
| 442 | /* Initialize input side of decompressor to consume first scan. */ |
| 443 | (*cinfo->inputctl->start_input_pass) (cinfo); |
| 444 | |
| 445 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
| 446 | /* If jpeg_start_decompress will read the whole file, initialize |
| 447 | * progress monitoring appropriately. The input step is counted |
| 448 | * as one pass. |
| 449 | */ |
| 450 | if (cinfo->progress != NULL && ! cinfo->buffered_image && |
| 451 | cinfo->inputctl->has_multiple_scans) { |
| 452 | int nscans; |
| 453 | /* Estimate number of scans to set pass_limit. */ |
| 454 | if (cinfo->progressive_mode) { |
| 455 | /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ |
| 456 | nscans = 2 + 3 * cinfo->num_components; |
| 457 | } else { |
| 458 | /* For a nonprogressive multiscan file, estimate 1 scan per component. */ |
| 459 | nscans = cinfo->num_components; |
| 460 | } |
| 461 | cinfo->progress->pass_counter = 0L; |
| 462 | cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; |
| 463 | cinfo->progress->completed_passes = 0; |
| 464 | cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); |
| 465 | /* Count the input pass as done */ |
| 466 | master->pass_number++; |
| 467 | } |
| 468 | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | |
| 472 | /* |
| 473 | * Per-pass setup. |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 474 | * This is called at the beginning of each output pass. We determine which |
| 475 | * modules will be active during this pass and give them appropriate |
| 476 | * start_pass calls. We also set is_dummy_pass to indicate whether this |
| 477 | * is a "real" output pass or a dummy pass for color quantization. |
Thomas G. Lane | 5ead57a | 1998-03-27 00:00:00 +0000 | [diff] [blame] | 478 | * (In the latter case, jdapistd.c will crank the pass to completion.) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 479 | */ |
| 480 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 481 | METHODDEF(void) |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 482 | prepare_for_output_pass (j_decompress_ptr cinfo) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 483 | { |
| 484 | my_master_ptr master = (my_master_ptr) cinfo->master; |
| 485 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 486 | if (master->pub.is_dummy_pass) { |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 487 | #ifdef QUANT_2PASS_SUPPORTED |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 488 | /* Final pass of 2-pass quantization */ |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 489 | master->pub.is_dummy_pass = FALSE; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 490 | (*cinfo->cquantize->start_pass) (cinfo, FALSE); |
| 491 | (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); |
| 492 | (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 493 | #else |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 494 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 495 | #endif /* QUANT_2PASS_SUPPORTED */ |
| 496 | } else { |
| 497 | if (cinfo->quantize_colors && cinfo->colormap == NULL) { |
| 498 | /* Select new quantization method */ |
| 499 | if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { |
| 500 | cinfo->cquantize = master->quantizer_2pass; |
| 501 | master->pub.is_dummy_pass = TRUE; |
| 502 | } else if (cinfo->enable_1pass_quant) { |
| 503 | cinfo->cquantize = master->quantizer_1pass; |
| 504 | } else { |
| 505 | ERREXIT(cinfo, JERR_MODE_CHANGE); |
| 506 | } |
| 507 | } |
| 508 | (*cinfo->idct->start_pass) (cinfo); |
| 509 | (*cinfo->coef->start_output_pass) (cinfo); |
| 510 | if (! cinfo->raw_data_out) { |
| 511 | if (! master->using_merged_upsample) |
| 512 | (*cinfo->cconvert->start_pass) (cinfo); |
| 513 | (*cinfo->upsample->start_pass) (cinfo); |
| 514 | if (cinfo->quantize_colors) |
| 515 | (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); |
| 516 | (*cinfo->post->start_pass) (cinfo, |
| 517 | (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); |
| 518 | (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); |
| 519 | } |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | /* Set up progress monitor's pass info if present */ |
| 523 | if (cinfo->progress != NULL) { |
| 524 | cinfo->progress->completed_passes = master->pass_number; |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 525 | cinfo->progress->total_passes = master->pass_number + |
| 526 | (master->pub.is_dummy_pass ? 2 : 1); |
| 527 | /* In buffered-image mode, we assume one more output pass if EOI not |
| 528 | * yet reached, but no more passes if EOI has been reached. |
| 529 | */ |
| 530 | if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { |
| 531 | cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); |
| 532 | } |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
| 536 | |
| 537 | /* |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 538 | * Finish up at end of an output pass. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 539 | */ |
| 540 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 541 | METHODDEF(void) |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 542 | finish_output_pass (j_decompress_ptr cinfo) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 543 | { |
| 544 | my_master_ptr master = (my_master_ptr) cinfo->master; |
| 545 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 546 | if (cinfo->quantize_colors) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 547 | (*cinfo->cquantize->finish_pass) (cinfo); |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 548 | master->pass_number++; |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 552 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
| 553 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 554 | /* |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 555 | * Switch to a new external colormap between output passes. |
| 556 | */ |
| 557 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 558 | GLOBAL(void) |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 559 | jpeg_new_colormap (j_decompress_ptr cinfo) |
| 560 | { |
| 561 | my_master_ptr master = (my_master_ptr) cinfo->master; |
| 562 | |
| 563 | /* Prevent application from calling me at wrong times */ |
| 564 | if (cinfo->global_state != DSTATE_BUFIMAGE) |
| 565 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 566 | |
| 567 | if (cinfo->quantize_colors && cinfo->enable_external_quant && |
| 568 | cinfo->colormap != NULL) { |
| 569 | /* Select 2-pass quantizer for external colormap use */ |
| 570 | cinfo->cquantize = master->quantizer_2pass; |
| 571 | /* Notify quantizer of colormap change */ |
| 572 | (*cinfo->cquantize->new_color_map) (cinfo); |
| 573 | master->pub.is_dummy_pass = FALSE; /* just in case */ |
| 574 | } else |
| 575 | ERREXIT(cinfo, JERR_MODE_CHANGE); |
| 576 | } |
| 577 | |
| 578 | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
| 579 | |
| 580 | |
| 581 | /* |
| 582 | * Initialize master decompression control and select active modules. |
| 583 | * This is performed at the start of jpeg_start_decompress. |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 584 | */ |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 585 | |
Thomas G. Lane | 489583f | 1996-02-07 00:00:00 +0000 | [diff] [blame] | 586 | GLOBAL(void) |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 587 | jinit_master_decompress (j_decompress_ptr cinfo) |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 588 | { |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 589 | my_master_ptr master; |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 590 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 591 | master = (my_master_ptr) |
| 592 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 593 | SIZEOF(my_decomp_master)); |
| 594 | cinfo->master = (struct jpeg_decomp_master *) master; |
Thomas G. Lane | bc79e06 | 1995-08-02 00:00:00 +0000 | [diff] [blame] | 595 | master->pub.prepare_for_output_pass = prepare_for_output_pass; |
| 596 | master->pub.finish_output_pass = finish_output_pass; |
| 597 | |
| 598 | master->pub.is_dummy_pass = FALSE; |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 599 | |
Thomas G. Lane | 36a4ccc | 1994-09-24 00:00:00 +0000 | [diff] [blame] | 600 | master_selection(cinfo); |
Thomas G. Lane | 2cbeb8a | 1991-10-07 00:00:00 +0000 | [diff] [blame] | 601 | } |