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