Coverage Report

Created: 2023-10-07 13:33

/src/libjpeg-turbo.main/jdmaster.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * jdmaster.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1991-1997, Thomas G. Lane.
6
 * Modified 2002-2009 by Guido Vollbeding.
7
 * Lossless JPEG Modifications:
8
 * Copyright (C) 1999, Ken Murchison.
9
 * libjpeg-turbo Modifications:
10
 * Copyright (C) 2009-2011, 2016, 2019, 2022-2023, D. R. Commander.
11
 * Copyright (C) 2013, Linaro Limited.
12
 * Copyright (C) 2015, Google, Inc.
13
 * For conditions of distribution and use, see the accompanying README.ijg
14
 * file.
15
 *
16
 * This file contains master control logic for the JPEG decompressor.
17
 * These routines are concerned with selecting the modules to be executed
18
 * and with determining the number of passes and the work to be done in each
19
 * pass.
20
 */
21
22
#define JPEG_INTERNALS
23
#include "jinclude.h"
24
#include "jpeglib.h"
25
#include "jpegapicomp.h"
26
#include "jdmaster.h"
27
28
29
/*
30
 * Determine whether merged upsample/color conversion should be used.
31
 * CRUCIAL: this must match the actual capabilities of jdmerge.c!
32
 */
33
34
LOCAL(boolean)
35
use_merged_upsample(j_decompress_ptr cinfo)
36
313k
{
37
313k
#ifdef UPSAMPLE_MERGING_SUPPORTED
38
  /* Merging is the equivalent of plain box-filter upsampling */
39
313k
  if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
40
175k
    return FALSE;
41
  /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
42
138k
  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
43
138k
      (cinfo->out_color_space != JCS_RGB &&
44
117k
       cinfo->out_color_space != JCS_RGB565 &&
45
117k
       cinfo->out_color_space != JCS_EXT_RGB &&
46
117k
       cinfo->out_color_space != JCS_EXT_RGBX &&
47
117k
       cinfo->out_color_space != JCS_EXT_BGR &&
48
117k
       cinfo->out_color_space != JCS_EXT_BGRX &&
49
117k
       cinfo->out_color_space != JCS_EXT_XBGR &&
50
117k
       cinfo->out_color_space != JCS_EXT_XRGB &&
51
117k
       cinfo->out_color_space != JCS_EXT_RGBA &&
52
117k
       cinfo->out_color_space != JCS_EXT_BGRA &&
53
117k
       cinfo->out_color_space != JCS_EXT_ABGR &&
54
117k
       cinfo->out_color_space != JCS_EXT_ARGB))
55
20.3k
    return FALSE;
56
117k
  if ((cinfo->out_color_space == JCS_RGB565 &&
57
117k
       cinfo->out_color_components != 3) ||
58
117k
      (cinfo->out_color_space != JCS_RGB565 &&
59
117k
       cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
60
0
    return FALSE;
61
  /* and it only handles 2h1v or 2h2v sampling ratios */
62
117k
  if (cinfo->comp_info[0].h_samp_factor != 2 ||
63
117k
      cinfo->comp_info[1].h_samp_factor != 1 ||
64
117k
      cinfo->comp_info[2].h_samp_factor != 1 ||
65
117k
      cinfo->comp_info[0].v_samp_factor >  2 ||
66
117k
      cinfo->comp_info[1].v_samp_factor != 1 ||
67
117k
      cinfo->comp_info[2].v_samp_factor != 1)
68
62.1k
    return FALSE;
69
  /* furthermore, it doesn't work if we've scaled the IDCTs differently */
70
55.6k
  if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
71
55.6k
      cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
72
55.6k
      cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
73
0
    return FALSE;
74
  /* ??? also need to test for upsample-time rescaling, when & if supported */
75
55.6k
  return TRUE;                  /* by golly, it'll work... */
76
#else
77
  return FALSE;
78
#endif
79
55.6k
}
80
81
82
/*
83
 * Compute output image dimensions and related values.
84
 * NOTE: this is exported for possible use by application.
85
 * Hence it mustn't do anything that can't be done twice.
86
 */
87
88
#if JPEG_LIB_VERSION >= 80
89
GLOBAL(void)
90
#else
91
LOCAL(void)
92
#endif
93
jpeg_core_output_dimensions(j_decompress_ptr cinfo)
94
/* Do computations that are needed before master selection phase.
95
 * This function is used for transcoding and full decompression.
96
 */
97
156k
{
98
156k
#ifdef IDCT_SCALING_SUPPORTED
99
156k
  int ci;
100
156k
  jpeg_component_info *compptr;
101
102
156k
  if (!cinfo->master->lossless) {
103
    /* Compute actual output image dimensions and DCT scaling choices. */
104
103k
    if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
105
      /* Provide 1/block_size scaling */
106
0
      cinfo->output_width = (JDIMENSION)
107
0
        jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
108
0
      cinfo->output_height = (JDIMENSION)
109
0
        jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
110
0
      cinfo->_min_DCT_h_scaled_size = 1;
111
0
      cinfo->_min_DCT_v_scaled_size = 1;
112
103k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
113
      /* Provide 2/block_size scaling */
114
0
      cinfo->output_width = (JDIMENSION)
115
0
        jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
116
0
      cinfo->output_height = (JDIMENSION)
117
0
        jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
118
0
      cinfo->_min_DCT_h_scaled_size = 2;
119
0
      cinfo->_min_DCT_v_scaled_size = 2;
120
103k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
121
      /* Provide 3/block_size scaling */
122
0
      cinfo->output_width = (JDIMENSION)
123
0
        jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
124
0
      cinfo->output_height = (JDIMENSION)
125
0
        jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
126
0
      cinfo->_min_DCT_h_scaled_size = 3;
127
0
      cinfo->_min_DCT_v_scaled_size = 3;
128
103k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
129
      /* Provide 4/block_size scaling */
130
11.4k
      cinfo->output_width = (JDIMENSION)
131
11.4k
        jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
132
11.4k
      cinfo->output_height = (JDIMENSION)
133
11.4k
        jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
134
11.4k
      cinfo->_min_DCT_h_scaled_size = 4;
135
11.4k
      cinfo->_min_DCT_v_scaled_size = 4;
136
91.9k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
137
      /* Provide 5/block_size scaling */
138
0
      cinfo->output_width = (JDIMENSION)
139
0
        jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
140
0
      cinfo->output_height = (JDIMENSION)
141
0
        jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
142
0
      cinfo->_min_DCT_h_scaled_size = 5;
143
0
      cinfo->_min_DCT_v_scaled_size = 5;
144
91.9k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
145
      /* Provide 6/block_size scaling */
146
0
      cinfo->output_width = (JDIMENSION)
147
0
        jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
148
0
      cinfo->output_height = (JDIMENSION)
149
0
        jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
150
0
      cinfo->_min_DCT_h_scaled_size = 6;
151
0
      cinfo->_min_DCT_v_scaled_size = 6;
152
91.9k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
153
      /* Provide 7/block_size scaling */
154
0
      cinfo->output_width = (JDIMENSION)
155
0
        jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
156
0
      cinfo->output_height = (JDIMENSION)
157
0
        jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
158
0
      cinfo->_min_DCT_h_scaled_size = 7;
159
0
      cinfo->_min_DCT_v_scaled_size = 7;
160
91.9k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
161
      /* Provide 8/block_size scaling */
162
91.9k
      cinfo->output_width = (JDIMENSION)
163
91.9k
        jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
164
91.9k
      cinfo->output_height = (JDIMENSION)
165
91.9k
        jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
166
91.9k
      cinfo->_min_DCT_h_scaled_size = 8;
167
91.9k
      cinfo->_min_DCT_v_scaled_size = 8;
168
91.9k
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
169
      /* Provide 9/block_size scaling */
170
0
      cinfo->output_width = (JDIMENSION)
171
0
        jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
172
0
      cinfo->output_height = (JDIMENSION)
173
0
        jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
174
0
      cinfo->_min_DCT_h_scaled_size = 9;
175
0
      cinfo->_min_DCT_v_scaled_size = 9;
176
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
177
      /* Provide 10/block_size scaling */
178
0
      cinfo->output_width = (JDIMENSION)
179
0
        jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
180
0
      cinfo->output_height = (JDIMENSION)
181
0
        jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
182
0
      cinfo->_min_DCT_h_scaled_size = 10;
183
0
      cinfo->_min_DCT_v_scaled_size = 10;
184
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
185
      /* Provide 11/block_size scaling */
186
0
      cinfo->output_width = (JDIMENSION)
187
0
        jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
188
0
      cinfo->output_height = (JDIMENSION)
189
0
        jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
190
0
      cinfo->_min_DCT_h_scaled_size = 11;
191
0
      cinfo->_min_DCT_v_scaled_size = 11;
192
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
193
      /* Provide 12/block_size scaling */
194
0
      cinfo->output_width = (JDIMENSION)
195
0
        jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
196
0
      cinfo->output_height = (JDIMENSION)
197
0
        jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
198
0
      cinfo->_min_DCT_h_scaled_size = 12;
199
0
      cinfo->_min_DCT_v_scaled_size = 12;
200
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
201
      /* Provide 13/block_size scaling */
202
0
      cinfo->output_width = (JDIMENSION)
203
0
        jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
204
0
      cinfo->output_height = (JDIMENSION)
205
0
        jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
206
0
      cinfo->_min_DCT_h_scaled_size = 13;
207
0
      cinfo->_min_DCT_v_scaled_size = 13;
208
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
209
      /* Provide 14/block_size scaling */
210
0
      cinfo->output_width = (JDIMENSION)
211
0
        jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
212
0
      cinfo->output_height = (JDIMENSION)
213
0
        jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
214
0
      cinfo->_min_DCT_h_scaled_size = 14;
215
0
      cinfo->_min_DCT_v_scaled_size = 14;
216
0
    } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
217
      /* Provide 15/block_size scaling */
218
0
      cinfo->output_width = (JDIMENSION)
219
0
        jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
220
0
      cinfo->output_height = (JDIMENSION)
221
0
        jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
222
0
      cinfo->_min_DCT_h_scaled_size = 15;
223
0
      cinfo->_min_DCT_v_scaled_size = 15;
224
0
    } else {
225
      /* Provide 16/block_size scaling */
226
0
      cinfo->output_width = (JDIMENSION)
227
0
        jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
228
0
      cinfo->output_height = (JDIMENSION)
229
0
        jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
230
0
      cinfo->_min_DCT_h_scaled_size = 16;
231
0
      cinfo->_min_DCT_v_scaled_size = 16;
232
0
    }
233
234
    /* Recompute dimensions of components */
235
399k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
236
296k
         ci++, compptr++) {
237
296k
      compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
238
296k
      compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
239
296k
    }
240
103k
  } else
241
53.2k
#endif /* !IDCT_SCALING_SUPPORTED */
242
53.2k
  {
243
    /* Hardwire it to "no scaling" */
244
53.2k
    cinfo->output_width = cinfo->image_width;
245
53.2k
    cinfo->output_height = cinfo->image_height;
246
    /* jdinput.c has already initialized DCT_scaled_size,
247
     * and has computed unscaled downsampled_width and downsampled_height.
248
     */
249
53.2k
  }
250
156k
}
251
252
253
/*
254
 * Compute output image dimensions and related values.
255
 * NOTE: this is exported for possible use by application.
256
 * Hence it mustn't do anything that can't be done twice.
257
 * Also note that it may be called before the master module is initialized!
258
 */
259
260
GLOBAL(void)
261
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
262
/* Do computations that are needed before master selection phase */
263
156k
{
264
156k
#ifdef IDCT_SCALING_SUPPORTED
265
156k
  int ci;
266
156k
  jpeg_component_info *compptr;
267
156k
#endif
268
269
  /* Prevent application from calling me at wrong times */
270
156k
  if (cinfo->global_state != DSTATE_READY)
271
0
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
272
273
  /* Compute core output image dimensions and DCT scaling choices. */
274
156k
  jpeg_core_output_dimensions(cinfo);
275
276
156k
#ifdef IDCT_SCALING_SUPPORTED
277
278
156k
  if (!cinfo->master->lossless) {
279
    /* In selecting the actual DCT scaling for each component, we try to
280
     * scale up the chroma components via IDCT scaling rather than upsampling.
281
     * This saves time if the upsampler gets to use 1:1 scaling.
282
     * Note this code adapts subsampling ratios which are powers of 2.
283
     */
284
399k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
285
296k
         ci++, compptr++) {
286
296k
      int ssize = cinfo->_min_DCT_scaled_size;
287
308k
      while (ssize < DCTSIZE &&
288
308k
             ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
289
32.4k
              (compptr->h_samp_factor * ssize * 2) == 0) &&
290
308k
             ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
291
18.3k
              (compptr->v_samp_factor * ssize * 2) == 0)) {
292
11.8k
        ssize = ssize * 2;
293
11.8k
      }
294
#if JPEG_LIB_VERSION >= 70
295
      compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
296
#else
297
296k
      compptr->DCT_scaled_size = ssize;
298
296k
#endif
299
296k
    }
300
301
    /* Recompute downsampled dimensions of components;
302
     * application needs to know these if using raw downsampled data.
303
     */
304
399k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
305
296k
         ci++, compptr++) {
306
      /* Size in samples, after IDCT scaling */
307
296k
      compptr->downsampled_width = (JDIMENSION)
308
296k
        jdiv_round_up((long)cinfo->image_width *
309
296k
                      (long)(compptr->h_samp_factor *
310
296k
                             compptr->_DCT_scaled_size),
311
296k
                      (long)(cinfo->max_h_samp_factor * DCTSIZE));
312
296k
      compptr->downsampled_height = (JDIMENSION)
313
296k
        jdiv_round_up((long)cinfo->image_height *
314
296k
                      (long)(compptr->v_samp_factor *
315
296k
                             compptr->_DCT_scaled_size),
316
296k
                      (long)(cinfo->max_v_samp_factor * DCTSIZE));
317
296k
    }
318
103k
  } else
319
53.2k
#endif /* IDCT_SCALING_SUPPORTED */
320
53.2k
  {
321
    /* Hardwire it to "no scaling" */
322
53.2k
    cinfo->output_width = cinfo->image_width;
323
53.2k
    cinfo->output_height = cinfo->image_height;
324
    /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
325
     * and has computed unscaled downsampled_width and downsampled_height.
326
     */
327
53.2k
  }
328
329
  /* Report number of components in selected colorspace. */
330
  /* Probably this should be in the color conversion module... */
331
156k
  switch (cinfo->out_color_space) {
332
12.9k
  case JCS_GRAYSCALE:
333
12.9k
    cinfo->out_color_components = 1;
334
12.9k
    break;
335
0
  case JCS_RGB:
336
119k
  case JCS_EXT_RGB:
337
119k
  case JCS_EXT_RGBX:
338
119k
  case JCS_EXT_BGR:
339
132k
  case JCS_EXT_BGRX:
340
132k
  case JCS_EXT_XBGR:
341
132k
  case JCS_EXT_XRGB:
342
132k
  case JCS_EXT_RGBA:
343
132k
  case JCS_EXT_BGRA:
344
132k
  case JCS_EXT_ABGR:
345
132k
  case JCS_EXT_ARGB:
346
132k
    cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
347
132k
    break;
348
0
  case JCS_YCbCr:
349
0
  case JCS_RGB565:
350
0
    cinfo->out_color_components = 3;
351
0
    break;
352
11.4k
  case JCS_CMYK:
353
11.4k
  case JCS_YCCK:
354
11.4k
    cinfo->out_color_components = 4;
355
11.4k
    break;
356
0
  default:                      /* else must be same colorspace as in file */
357
0
    cinfo->out_color_components = cinfo->num_components;
358
0
    break;
359
156k
  }
360
156k
  cinfo->output_components = (cinfo->quantize_colors ? 1 :
361
156k
                              cinfo->out_color_components);
362
363
  /* See if upsampler will want to emit more than one row at a time */
364
156k
  if (use_merged_upsample(cinfo))
365
27.8k
    cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
366
128k
  else
367
128k
    cinfo->rec_outbuf_height = 1;
368
156k
}
369
370
371
/*
372
 * Several decompression processes need to range-limit values to the range
373
 * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
374
 * due to noise introduced by quantization, roundoff error, etc.  These
375
 * processes are inner loops and need to be as fast as possible.  On most
376
 * machines, particularly CPUs with pipelines or instruction prefetch,
377
 * a (subscript-check-less) C table lookup
378
 *              x = sample_range_limit[x];
379
 * is faster than explicit tests
380
 *              if (x < 0)  x = 0;
381
 *              else if (x > MAXJSAMPLE)  x = MAXJSAMPLE;
382
 * These processes all use a common table prepared by the routine below.
383
 *
384
 * For most steps we can mathematically guarantee that the initial value
385
 * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
386
 * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial
387
 * limiting step (just after the IDCT), a wildly out-of-range value is
388
 * possible if the input data is corrupt.  To avoid any chance of indexing
389
 * off the end of memory and getting a bad-pointer trap, we perform the
390
 * post-IDCT limiting thus:
391
 *              x = range_limit[x & MASK];
392
 * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
393
 * samples.  Under normal circumstances this is more than enough range and
394
 * a correct output will be generated; with bogus input data the mask will
395
 * cause wraparound, and we will safely generate a bogus-but-in-range output.
396
 * For the post-IDCT step, we want to convert the data from signed to unsigned
397
 * representation by adding CENTERJSAMPLE at the same time that we limit it.
398
 * So the post-IDCT limiting table ends up looking like this:
399
 *   CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
400
 *   MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
401
 *   0          (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
402
 *   0,1,...,CENTERJSAMPLE-1
403
 * Negative inputs select values from the upper half of the table after
404
 * masking.
405
 *
406
 * We can save some space by overlapping the start of the post-IDCT table
407
 * with the simpler range limiting table.  The post-IDCT table begins at
408
 * sample_range_limit + CENTERJSAMPLE.
409
 */
410
411
LOCAL(void)
412
prepare_range_limit_table(j_decompress_ptr cinfo)
413
/* Allocate and fill in the sample_range_limit table */
414
156k
{
415
156k
  JSAMPLE *table;
416
156k
  J12SAMPLE *table12;
417
156k
#ifdef D_LOSSLESS_SUPPORTED
418
156k
  J16SAMPLE *table16;
419
156k
#endif
420
156k
  int i;
421
422
156k
  if (cinfo->data_precision == 16) {
423
20.2k
#ifdef D_LOSSLESS_SUPPORTED
424
20.2k
    table16 = (J16SAMPLE *)
425
20.2k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
426
20.2k
                  (5 * (MAXJ16SAMPLE + 1) + CENTERJ16SAMPLE) *
427
20.2k
                  sizeof(J16SAMPLE));
428
20.2k
    table16 += (MAXJ16SAMPLE + 1);  /* allow negative subscripts of simple
429
                                       table */
430
20.2k
    cinfo->sample_range_limit = (JSAMPLE *)table16;
431
    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
432
20.2k
    memset(table16 - (MAXJ16SAMPLE + 1), 0,
433
20.2k
           (MAXJ16SAMPLE + 1) * sizeof(J16SAMPLE));
434
    /* Main part of "simple" table: limit[x] = x */
435
1.32G
    for (i = 0; i <= MAXJ16SAMPLE; i++)
436
1.32G
      table16[i] = (J16SAMPLE)i;
437
20.2k
    table16 += CENTERJ16SAMPLE; /* Point to where post-IDCT table starts */
438
    /* End of simple table, rest of first half of post-IDCT table */
439
1.99G
    for (i = CENTERJ16SAMPLE; i < 2 * (MAXJ16SAMPLE + 1); i++)
440
1.99G
      table16[i] = MAXJ16SAMPLE;
441
    /* Second half of post-IDCT table */
442
20.2k
    memset(table16 + (2 * (MAXJ16SAMPLE + 1)), 0,
443
20.2k
           (2 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE) * sizeof(J16SAMPLE));
444
20.2k
    memcpy(table16 + (4 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE),
445
20.2k
           cinfo->sample_range_limit, CENTERJ16SAMPLE * sizeof(J16SAMPLE));
446
#else
447
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
448
#endif
449
136k
  } else if (cinfo->data_precision == 12) {
450
68.3k
    table12 = (J12SAMPLE *)
451
68.3k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
452
68.3k
                  (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
453
68.3k
                  sizeof(J12SAMPLE));
454
68.3k
    table12 += (MAXJ12SAMPLE + 1);  /* allow negative subscripts of simple
455
                                       table */
456
68.3k
    cinfo->sample_range_limit = (JSAMPLE *)table12;
457
    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
458
68.3k
    memset(table12 - (MAXJ12SAMPLE + 1), 0,
459
68.3k
           (MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
460
    /* Main part of "simple" table: limit[x] = x */
461
279M
    for (i = 0; i <= MAXJ12SAMPLE; i++)
462
279M
      table12[i] = (J12SAMPLE)i;
463
68.3k
    table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
464
    /* End of simple table, rest of first half of post-IDCT table */
465
419M
    for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
466
419M
      table12[i] = MAXJ12SAMPLE;
467
    /* Second half of post-IDCT table */
468
68.3k
    memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
469
68.3k
           (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
470
68.3k
    memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
471
68.3k
           cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
472
68.3k
  } else {
473
68.0k
    table = (JSAMPLE *)
474
68.0k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
475
68.0k
                  (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
476
68.0k
    table += (MAXJSAMPLE + 1);  /* allow negative subscripts of simple table */
477
68.0k
    cinfo->sample_range_limit = table;
478
    /* First segment of "simple" table: limit[x] = 0 for x < 0 */
479
68.0k
    memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
480
    /* Main part of "simple" table: limit[x] = x */
481
17.4M
    for (i = 0; i <= MAXJSAMPLE; i++)
482
17.4M
      table[i] = (JSAMPLE)i;
483
68.0k
    table += CENTERJSAMPLE;     /* Point to where post-IDCT table starts */
484
    /* End of simple table, rest of first half of post-IDCT table */
485
26.1M
    for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
486
26.1M
      table[i] = MAXJSAMPLE;
487
    /* Second half of post-IDCT table */
488
68.0k
    memset(table + (2 * (MAXJSAMPLE + 1)), 0,
489
68.0k
           (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
490
68.0k
    memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
491
68.0k
           cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
492
68.0k
  }
493
156k
}
494
495
496
/*
497
 * Master selection of decompression modules.
498
 * This is done once at jpeg_start_decompress time.  We determine
499
 * which modules will be used and give them appropriate initialization calls.
500
 * We also initialize the decompressor input side to begin consuming data.
501
 *
502
 * Since jpeg_read_header has finished, we know what is in the SOF
503
 * and (first) SOS markers.  We also have all the application parameter
504
 * settings.
505
 */
506
507
LOCAL(void)
508
master_selection(j_decompress_ptr cinfo)
509
156k
{
510
156k
  my_master_ptr master = (my_master_ptr)cinfo->master;
511
156k
  boolean use_c_buffer;
512
156k
  long samplesperrow;
513
156k
  JDIMENSION jd_samplesperrow;
514
515
  /* Disable IDCT scaling and raw (downsampled) data output in lossless mode.
516
   * IDCT scaling is not useful in lossless mode, and it must be disabled in
517
   * order to properly calculate the output dimensions.  Raw data output isn't
518
   * particularly useful without subsampling and has not been tested in
519
   * lossless mode.
520
   */
521
156k
  if (cinfo->master->lossless) {
522
53.2k
    cinfo->raw_data_out = FALSE;
523
53.2k
    cinfo->scale_num = cinfo->scale_denom = 1;
524
53.2k
  }
525
526
  /* Initialize dimensions and other stuff */
527
156k
  jpeg_calc_output_dimensions(cinfo);
528
156k
  prepare_range_limit_table(cinfo);
529
530
  /* Width of an output scanline must be representable as JDIMENSION. */
531
156k
  samplesperrow = (long)cinfo->output_width *
532
156k
                  (long)cinfo->out_color_components;
533
156k
  jd_samplesperrow = (JDIMENSION)samplesperrow;
534
156k
  if ((long)jd_samplesperrow != samplesperrow)
535
0
    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
536
537
  /* Initialize my private state */
538
156k
  master->pass_number = 0;
539
156k
  master->using_merged_upsample = use_merged_upsample(cinfo);
540
541
  /* Color quantizer selection */
542
156k
  master->quantizer_1pass = NULL;
543
156k
  master->quantizer_2pass = NULL;
544
  /* No mode changes if not using buffered-image mode. */
545
156k
  if (!cinfo->quantize_colors || !cinfo->buffered_image) {
546
156k
    cinfo->enable_1pass_quant = FALSE;
547
156k
    cinfo->enable_external_quant = FALSE;
548
156k
    cinfo->enable_2pass_quant = FALSE;
549
156k
  }
550
156k
  if (cinfo->quantize_colors) {
551
0
    if (cinfo->raw_data_out)
552
0
      ERREXIT(cinfo, JERR_NOTIMPL);
553
    /* 2-pass quantizer only works in 3-component color space. */
554
0
    if (cinfo->out_color_components != 3 ||
555
0
        cinfo->out_color_space == JCS_RGB565) {
556
0
      cinfo->enable_1pass_quant = TRUE;
557
0
      cinfo->enable_external_quant = FALSE;
558
0
      cinfo->enable_2pass_quant = FALSE;
559
0
      cinfo->colormap = NULL;
560
0
    } else if (cinfo->colormap != NULL) {
561
0
      cinfo->enable_external_quant = TRUE;
562
0
    } else if (cinfo->two_pass_quantize) {
563
0
      cinfo->enable_2pass_quant = TRUE;
564
0
    } else {
565
0
      cinfo->enable_1pass_quant = TRUE;
566
0
    }
567
568
0
    if (cinfo->enable_1pass_quant) {
569
0
#ifdef QUANT_1PASS_SUPPORTED
570
0
      if (cinfo->data_precision == 16)
571
0
#ifdef D_LOSSLESS_SUPPORTED
572
0
        j16init_1pass_quantizer(cinfo);
573
#else
574
        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
575
#endif
576
0
      else if (cinfo->data_precision == 12)
577
0
        j12init_1pass_quantizer(cinfo);
578
0
      else
579
0
        jinit_1pass_quantizer(cinfo);
580
0
      master->quantizer_1pass = cinfo->cquantize;
581
#else
582
      ERREXIT(cinfo, JERR_NOT_COMPILED);
583
#endif
584
0
    }
585
586
    /* We use the 2-pass code to map to external colormaps. */
587
0
    if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
588
0
#ifdef QUANT_2PASS_SUPPORTED
589
0
      if (cinfo->data_precision == 16)
590
0
#ifdef D_LOSSLESS_SUPPORTED
591
0
        j16init_2pass_quantizer(cinfo);
592
#else
593
        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
594
#endif
595
0
      else if (cinfo->data_precision == 12)
596
0
        j12init_2pass_quantizer(cinfo);
597
0
      else
598
0
        jinit_2pass_quantizer(cinfo);
599
0
      master->quantizer_2pass = cinfo->cquantize;
600
#else
601
      ERREXIT(cinfo, JERR_NOT_COMPILED);
602
#endif
603
0
    }
604
    /* If both quantizers are initialized, the 2-pass one is left active;
605
     * this is necessary for starting with quantization to an external map.
606
     */
607
0
  }
608
609
  /* Post-processing: in particular, color conversion first */
610
156k
  if (!cinfo->raw_data_out) {
611
156k
    if (master->using_merged_upsample) {
612
27.8k
#ifdef UPSAMPLE_MERGING_SUPPORTED
613
27.8k
      if (cinfo->data_precision == 16)
614
18
        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
615
27.8k
      else if (cinfo->data_precision == 12)
616
10.0k
        j12init_merged_upsampler(cinfo); /* does color conversion too */
617
17.7k
      else
618
17.7k
        jinit_merged_upsampler(cinfo); /* does color conversion too */
619
#else
620
      ERREXIT(cinfo, JERR_NOT_COMPILED);
621
#endif
622
128k
    } else {
623
128k
      if (cinfo->data_precision == 16) {
624
20.2k
#ifdef D_LOSSLESS_SUPPORTED
625
20.2k
        j16init_color_deconverter(cinfo);
626
20.2k
        j16init_upsampler(cinfo);
627
#else
628
        ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
629
#endif
630
108k
      } else if (cinfo->data_precision == 12) {
631
58.2k
        j12init_color_deconverter(cinfo);
632
58.2k
        j12init_upsampler(cinfo);
633
58.2k
      } else {
634
50.2k
        jinit_color_deconverter(cinfo);
635
50.2k
        jinit_upsampler(cinfo);
636
50.2k
      }
637
128k
    }
638
156k
    if (cinfo->data_precision == 16)
639
19.4k
#ifdef D_LOSSLESS_SUPPORTED
640
19.4k
      j16init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
641
#else
642
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
643
#endif
644
137k
    else if (cinfo->data_precision == 12)
645
59.7k
      j12init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
646
77.3k
    else
647
77.3k
      jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
648
156k
  }
649
650
156k
  if (cinfo->master->lossless) {
651
51.5k
#ifdef D_LOSSLESS_SUPPORTED
652
    /* Prediction, sample undifferencing, point transform, and sample size
653
     * scaling
654
     */
655
51.5k
    if (cinfo->data_precision == 16)
656
19.3k
      j16init_lossless_decompressor(cinfo);
657
32.2k
    else if (cinfo->data_precision == 12)
658
16.9k
      j12init_lossless_decompressor(cinfo);
659
15.2k
    else
660
15.2k
      jinit_lossless_decompressor(cinfo);
661
    /* Entropy decoding: either Huffman or arithmetic coding. */
662
51.5k
    if (cinfo->arith_code) {
663
50
      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
664
51.4k
    } else {
665
51.4k
      jinit_lhuff_decoder(cinfo);
666
51.4k
    }
667
668
    /* Initialize principal buffer controllers. */
669
51.5k
    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
670
51.5k
                   cinfo->buffered_image;
671
51.5k
    if (cinfo->data_precision == 16)
672
19.2k
      j16init_d_diff_controller(cinfo, use_c_buffer);
673
32.2k
    else if (cinfo->data_precision == 12)
674
16.9k
      j12init_d_diff_controller(cinfo, use_c_buffer);
675
15.2k
    else
676
15.2k
      jinit_d_diff_controller(cinfo, use_c_buffer);
677
#else
678
    ERREXIT(cinfo, JERR_NOT_COMPILED);
679
#endif
680
105k
  } else {
681
105k
    if (cinfo->data_precision == 16)
682
129
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
683
    /* Inverse DCT */
684
105k
    if (cinfo->data_precision == 12)
685
42.7k
      j12init_inverse_dct(cinfo);
686
62.2k
    else
687
62.2k
      jinit_inverse_dct(cinfo);
688
    /* Entropy decoding: either Huffman or arithmetic coding. */
689
105k
    if (cinfo->arith_code) {
690
31.4k
#ifdef D_ARITH_CODING_SUPPORTED
691
31.4k
      jinit_arith_decoder(cinfo);
692
#else
693
      ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
694
#endif
695
73.6k
    } else {
696
73.6k
      if (cinfo->progressive_mode) {
697
21.4k
#ifdef D_PROGRESSIVE_SUPPORTED
698
21.4k
        jinit_phuff_decoder(cinfo);
699
#else
700
        ERREXIT(cinfo, JERR_NOT_COMPILED);
701
#endif
702
21.4k
      } else
703
52.1k
        jinit_huff_decoder(cinfo);
704
73.6k
    }
705
706
    /* Initialize principal buffer controllers. */
707
105k
    use_c_buffer = cinfo->inputctl->has_multiple_scans ||
708
105k
                   cinfo->buffered_image;
709
105k
    if (cinfo->data_precision == 12)
710
42.7k
      j12init_d_coef_controller(cinfo, use_c_buffer);
711
62.2k
    else
712
62.2k
      jinit_d_coef_controller(cinfo, use_c_buffer);
713
105k
  }
714
715
156k
  if (!cinfo->raw_data_out) {
716
143k
    if (cinfo->data_precision == 16)
717
19.2k
#ifdef D_LOSSLESS_SUPPORTED
718
19.2k
      j16init_d_main_controller(cinfo,
719
19.2k
                                FALSE /* never need full buffer here */);
720
#else
721
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
722
#endif
723
123k
    else if (cinfo->data_precision == 12)
724
59.7k
      j12init_d_main_controller(cinfo,
725
59.7k
                                FALSE /* never need full buffer here */);
726
63.9k
    else
727
63.9k
      jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
728
143k
  }
729
730
  /* We can now tell the memory manager to allocate virtual arrays. */
731
156k
  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
732
733
  /* Initialize input side of decompressor to consume first scan. */
734
156k
  (*cinfo->inputctl->start_input_pass) (cinfo);
735
736
  /* Set the first and last iMCU columns to decompress from single-scan images.
737
   * By default, decompress all of the iMCU columns.
738
   */
739
156k
  cinfo->master->first_iMCU_col = 0;
740
156k
  cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
741
156k
  cinfo->master->last_good_iMCU_row = 0;
742
743
156k
#ifdef D_MULTISCAN_FILES_SUPPORTED
744
  /* If jpeg_start_decompress will read the whole file, initialize
745
   * progress monitoring appropriately.  The input step is counted
746
   * as one pass.
747
   */
748
156k
  if (cinfo->progress != NULL && !cinfo->buffered_image &&
749
156k
      cinfo->inputctl->has_multiple_scans) {
750
53.3k
    int nscans;
751
    /* Estimate number of scans to set pass_limit. */
752
53.3k
    if (cinfo->progressive_mode) {
753
      /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
754
43.8k
      nscans = 2 + 3 * cinfo->num_components;
755
43.8k
    } else {
756
      /* For a nonprogressive multiscan file, estimate 1 scan per component. */
757
9.44k
      nscans = cinfo->num_components;
758
9.44k
    }
759
53.3k
    cinfo->progress->pass_counter = 0L;
760
53.3k
    cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
761
53.3k
    cinfo->progress->completed_passes = 0;
762
53.3k
    cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
763
    /* Count the input pass as done */
764
53.3k
    master->pass_number++;
765
53.3k
  }
766
156k
#endif /* D_MULTISCAN_FILES_SUPPORTED */
767
156k
}
768
769
770
/*
771
 * Per-pass setup.
772
 * This is called at the beginning of each output pass.  We determine which
773
 * modules will be active during this pass and give them appropriate
774
 * start_pass calls.  We also set is_dummy_pass to indicate whether this
775
 * is a "real" output pass or a dummy pass for color quantization.
776
 * (In the latter case, jdapistd.c will crank the pass to completion.)
777
 */
778
779
METHODDEF(void)
780
prepare_for_output_pass(j_decompress_ptr cinfo)
781
120k
{
782
120k
  my_master_ptr master = (my_master_ptr)cinfo->master;
783
784
120k
  if (master->pub.is_dummy_pass) {
785
0
#ifdef QUANT_2PASS_SUPPORTED
786
    /* Final pass of 2-pass quantization */
787
0
    master->pub.is_dummy_pass = FALSE;
788
0
    (*cinfo->cquantize->start_pass) (cinfo, FALSE);
789
0
    (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
790
0
    (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
791
#else
792
    ERREXIT(cinfo, JERR_NOT_COMPILED);
793
#endif /* QUANT_2PASS_SUPPORTED */
794
120k
  } else {
795
120k
    if (cinfo->quantize_colors && cinfo->colormap == NULL) {
796
      /* Select new quantization method */
797
0
      if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
798
0
        cinfo->cquantize = master->quantizer_2pass;
799
0
        master->pub.is_dummy_pass = TRUE;
800
0
      } else if (cinfo->enable_1pass_quant) {
801
0
        cinfo->cquantize = master->quantizer_1pass;
802
0
      } else {
803
0
        ERREXIT(cinfo, JERR_MODE_CHANGE);
804
0
      }
805
0
    }
806
120k
    (*cinfo->idct->start_pass) (cinfo);
807
120k
    (*cinfo->coef->start_output_pass) (cinfo);
808
120k
    if (!cinfo->raw_data_out) {
809
120k
      if (!master->using_merged_upsample)
810
101k
        (*cinfo->cconvert->start_pass) (cinfo);
811
120k
      (*cinfo->upsample->start_pass) (cinfo);
812
120k
      if (cinfo->quantize_colors)
813
0
        (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
814
120k
      (*cinfo->post->start_pass) (cinfo,
815
120k
            (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
816
120k
      (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
817
120k
    }
818
120k
  }
819
820
  /* Set up progress monitor's pass info if present */
821
120k
  if (cinfo->progress != NULL) {
822
120k
    cinfo->progress->completed_passes = master->pass_number;
823
120k
    cinfo->progress->total_passes = master->pass_number +
824
120k
                                    (master->pub.is_dummy_pass ? 2 : 1);
825
    /* In buffered-image mode, we assume one more output pass if EOI not
826
     * yet reached, but no more passes if EOI has been reached.
827
     */
828
120k
    if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
829
0
      cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
830
0
    }
831
120k
  }
832
120k
}
833
834
835
/*
836
 * Finish up at end of an output pass.
837
 */
838
839
METHODDEF(void)
840
finish_output_pass(j_decompress_ptr cinfo)
841
118k
{
842
118k
  my_master_ptr master = (my_master_ptr)cinfo->master;
843
844
118k
  if (cinfo->quantize_colors)
845
0
    (*cinfo->cquantize->finish_pass) (cinfo);
846
118k
  master->pass_number++;
847
118k
}
848
849
850
#ifdef D_MULTISCAN_FILES_SUPPORTED
851
852
/*
853
 * Switch to a new external colormap between output passes.
854
 */
855
856
GLOBAL(void)
857
jpeg_new_colormap(j_decompress_ptr cinfo)
858
0
{
859
0
  my_master_ptr master = (my_master_ptr)cinfo->master;
860
861
  /* Prevent application from calling me at wrong times */
862
0
  if (cinfo->global_state != DSTATE_BUFIMAGE)
863
0
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
864
865
0
  if (cinfo->quantize_colors && cinfo->enable_external_quant &&
866
0
      cinfo->colormap != NULL) {
867
    /* Select 2-pass quantizer for external colormap use */
868
0
    cinfo->cquantize = master->quantizer_2pass;
869
    /* Notify quantizer of colormap change */
870
0
    (*cinfo->cquantize->new_color_map) (cinfo);
871
0
    master->pub.is_dummy_pass = FALSE; /* just in case */
872
0
  } else
873
0
    ERREXIT(cinfo, JERR_MODE_CHANGE);
874
0
}
875
876
#endif /* D_MULTISCAN_FILES_SUPPORTED */
877
878
879
/*
880
 * Initialize master decompression control and select active modules.
881
 * This is performed at the start of jpeg_start_decompress.
882
 */
883
884
GLOBAL(void)
885
jinit_master_decompress(j_decompress_ptr cinfo)
886
156k
{
887
156k
  my_master_ptr master = (my_master_ptr)cinfo->master;
888
889
156k
  master->pub.prepare_for_output_pass = prepare_for_output_pass;
890
156k
  master->pub.finish_output_pass = finish_output_pass;
891
892
156k
  master->pub.is_dummy_pass = FALSE;
893
156k
  master->pub.jinit_upsampler_no_alloc = FALSE;
894
895
156k
  master_selection(cinfo);
896
156k
}