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