source: golgotha/src/i4/loaders/jpg/jcmaster.cc @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 20.0 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9/*
10 * jcmaster.c
11 *
12 * Copyright (C) 1991-1996, Thomas G. Lane.
13 * This file is part of the Independent JPEG Group's software.
14 * For conditions of distribution and use, see the accompanying README file.
15 *
16 * This file contains master control logic for the JPEG compressor.
17 * These routines are concerned with parameter validation, initial setup,
18 * and inter-pass control (determining the number of passes and the work
19 * to be done in each pass).
20 */
21
22#define JPEG_INTERNALS
23#include "loaders/jpg/jinclude.h"
24#include "loaders/jpg/jpeglib.h"
25
26
27/* Private state */
28
29typedef enum {
30        main_pass,              /* input data, also do first output step */
31        huff_opt_pass,          /* Huffman code optimization pass */
32        output_pass             /* data output pass */
33} c_pass_type;
34
35typedef struct {
36  struct jpeg_comp_master pub;  /* public fields */
37
38  c_pass_type pass_type;        /* the type of the current pass */
39
40  int pass_number;              /* # of passes completed */
41  int total_passes;             /* total # of passes needed */
42
43  int scan_number;              /* current index in scan_info[] */
44} my_comp_master;
45
46typedef my_comp_master * my_master_ptr;
47
48
49/*
50 * Support routines that do various essential calculations.
51 */
52
53LOCAL(void)
54initial_setup (j_compress_ptr cinfo)
55/* Do computations that are needed before master selection phase */
56{
57  int ci;
58  jpeg_component_info *compptr;
59  long samplesperrow;
60  JDIMENSION jd_samplesperrow;
61
62  /* Sanity check on image dimensions */
63  if (cinfo->image_height <= 0 || cinfo->image_width <= 0
64      || cinfo->num_components <= 0 || cinfo->input_components <= 0)
65    ERREXIT(cinfo, JERR_EMPTY_IMAGE);
66
67  /* Make sure image isn't bigger than I can handle */
68  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
69      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
70    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
71
72  /* Width of an input scanline must be representable as JDIMENSION. */
73  samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
74  jd_samplesperrow = (JDIMENSION) samplesperrow;
75  if ((long) jd_samplesperrow != samplesperrow)
76    ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
77
78  /* For now, precision must match compiled-in value... */
79  if (cinfo->data_precision != BITS_IN_JSAMPLE)
80    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
81
82  /* Check that number of components won't exceed internal array sizes */
83  if (cinfo->num_components > MAX_COMPONENTS)
84    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
85             MAX_COMPONENTS);
86
87  /* Compute maximum sampling factors; check factor validity */
88  cinfo->max_h_samp_factor = 1;
89  cinfo->max_v_samp_factor = 1;
90  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
91       ci++, compptr++) {
92    if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
93        compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
94      ERREXIT(cinfo, JERR_BAD_SAMPLING);
95    cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
96                                   compptr->h_samp_factor);
97    cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
98                                   compptr->v_samp_factor);
99  }
100
101  /* Compute dimensions of components */
102  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
103       ci++, compptr++) {
104    /* Fill in the correct component_index value; don't rely on application */
105    compptr->component_index = ci;
106    /* For compression, we never do DCT scaling. */
107    compptr->DCT_scaled_size = DCTSIZE;
108    /* Size in DCT blocks */
109    compptr->width_in_blocks = (JDIMENSION)
110      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
111                    (long) (cinfo->max_h_samp_factor * DCTSIZE));
112    compptr->height_in_blocks = (JDIMENSION)
113      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
114                    (long) (cinfo->max_v_samp_factor * DCTSIZE));
115    /* Size in samples */
116    compptr->downsampled_width = (JDIMENSION)
117      jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
118                    (long) cinfo->max_h_samp_factor);
119    compptr->downsampled_height = (JDIMENSION)
120      jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
121                    (long) cinfo->max_v_samp_factor);
122    /* Mark component needed (this flag isn't actually used for compression) */
123    compptr->component_needed = TRUE;
124  }
125
126  /* Compute number of fully interleaved MCU rows (number of times that
127   * main controller will call coefficient controller).
128   */
129  cinfo->total_iMCU_rows = (JDIMENSION)
130    jdiv_round_up((long) cinfo->image_height,
131                  (long) (cinfo->max_v_samp_factor*DCTSIZE));
132}
133
134
135#ifdef C_MULTISCAN_FILES_SUPPORTED
136
137LOCAL(void)
138validate_script (j_compress_ptr cinfo)
139/* Verify that the scan script in cinfo->scan_info[] is valid; also
140 * determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
141 */
142{
143  const jpeg_scan_info * scanptr;
144  int scanno, ncomps, ci, coefi, thisi;
145  int Ss, Se, Ah, Al;
146  boolean component_sent[MAX_COMPONENTS];
147#ifdef C_PROGRESSIVE_SUPPORTED
148  int * last_bitpos_ptr;
149  int last_bitpos[MAX_COMPONENTS][DCTSIZE2];
150  /* -1 until that coefficient has been seen; then last Al for it */
151#endif
152
153  if (cinfo->num_scans <= 0)
154    ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
155
156  /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;
157   * for progressive JPEG, no scan can have this.
158   */
159  scanptr = cinfo->scan_info;
160  if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) {
161#ifdef C_PROGRESSIVE_SUPPORTED
162    cinfo->progressive_mode = TRUE;
163    last_bitpos_ptr = & last_bitpos[0][0];
164    for (ci = 0; ci < cinfo->num_components; ci++)
165      for (coefi = 0; coefi < DCTSIZE2; coefi++)
166        *last_bitpos_ptr++ = -1;
167#else
168    ERREXIT(cinfo, JERR_NOT_COMPILED);
169#endif
170  } else {
171    cinfo->progressive_mode = FALSE;
172    for (ci = 0; ci < cinfo->num_components; ci++)
173      component_sent[ci] = FALSE;
174  }
175
176  for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) {
177    /* Validate component indexes */
178    ncomps = scanptr->comps_in_scan;
179    if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN)
180      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN);
181    for (ci = 0; ci < ncomps; ci++) {
182      thisi = scanptr->component_index[ci];
183      if (thisi < 0 || thisi >= cinfo->num_components)
184        ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
185      /* Components must appear in SOF order within each scan */
186      if (ci > 0 && thisi <= scanptr->component_index[ci-1])
187        ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
188    }
189    /* Validate progression parameters */
190    Ss = scanptr->Ss;
191    Se = scanptr->Se;
192    Ah = scanptr->Ah;
193    Al = scanptr->Al;
194    if (cinfo->progressive_mode) {
195#ifdef C_PROGRESSIVE_SUPPORTED
196      if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
197          Ah < 0 || Ah > 13 || Al < 0 || Al > 13)
198        ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
199      if (Ss == 0) {
200        if (Se != 0)            /* DC and AC together not OK */
201          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
202      } else {
203        if (ncomps != 1)        /* AC scans must be for only one component */
204          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
205      }
206      for (ci = 0; ci < ncomps; ci++) {
207        last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
208        if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
209          ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
210        for (coefi = Ss; coefi <= Se; coefi++) {
211          if (last_bitpos_ptr[coefi] < 0) {
212            /* first scan of this coefficient */
213            if (Ah != 0)
214              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
215          } else {
216            /* not first scan */
217            if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
218              ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
219          }
220          last_bitpos_ptr[coefi] = Al;
221        }
222      }
223#endif
224    } else {
225      /* For sequential JPEG, all progression parameters must be these: */
226      if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
227        ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
228      /* Make sure components are not sent twice */
229      for (ci = 0; ci < ncomps; ci++) {
230        thisi = scanptr->component_index[ci];
231        if (component_sent[thisi])
232          ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
233        component_sent[thisi] = TRUE;
234      }
235    }
236  }
237
238  /* Now verify that everything got sent. */
239  if (cinfo->progressive_mode) {
240#ifdef C_PROGRESSIVE_SUPPORTED
241    /* For progressive mode, we only check that at least some DC data
242     * got sent for each component; the spec does not require that all bits
243     * of all coefficients be transmitted.  Would it be wiser to enforce
244     * transmission of all coefficient bits??
245     */
246    for (ci = 0; ci < cinfo->num_components; ci++) {
247      if (last_bitpos[ci][0] < 0)
248        ERREXIT(cinfo, JERR_MISSING_DATA);
249    }
250#endif
251  } else {
252    for (ci = 0; ci < cinfo->num_components; ci++) {
253      if (! component_sent[ci])
254        ERREXIT(cinfo, JERR_MISSING_DATA);
255    }
256  }
257}
258
259#endif /* C_MULTISCAN_FILES_SUPPORTED */
260
261
262LOCAL(void)
263select_scan_parameters (j_compress_ptr cinfo)
264/* Set up the scan parameters for the current scan */
265{
266  int ci;
267
268#ifdef C_MULTISCAN_FILES_SUPPORTED
269  if (cinfo->scan_info != NULL) {
270    /* Prepare for current scan --- the script is already validated */
271    my_master_ptr master = (my_master_ptr) cinfo->master;
272    const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number;
273
274    cinfo->comps_in_scan = scanptr->comps_in_scan;
275    for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
276      cinfo->cur_comp_info[ci] =
277        &cinfo->comp_info[scanptr->component_index[ci]];
278    }
279    cinfo->Ss = scanptr->Ss;
280    cinfo->Se = scanptr->Se;
281    cinfo->Ah = scanptr->Ah;
282    cinfo->Al = scanptr->Al;
283  }
284  else
285#endif
286  {
287    /* Prepare for single sequential-JPEG scan containing all components */
288    if (cinfo->num_components > MAX_COMPS_IN_SCAN)
289      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
290               MAX_COMPS_IN_SCAN);
291    cinfo->comps_in_scan = cinfo->num_components;
292    for (ci = 0; ci < cinfo->num_components; ci++) {
293      cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
294    }
295    cinfo->Ss = 0;
296    cinfo->Se = DCTSIZE2-1;
297    cinfo->Ah = 0;
298    cinfo->Al = 0;
299  }
300}
301
302
303LOCAL(void)
304per_scan_setup (j_compress_ptr cinfo)
305/* Do computations that are needed before processing a JPEG scan */
306/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
307{
308  int ci, mcublks, tmp;
309  jpeg_component_info *compptr;
310 
311  if (cinfo->comps_in_scan == 1) {
312   
313    /* Noninterleaved (single-component) scan */
314    compptr = cinfo->cur_comp_info[0];
315   
316    /* Overall image size in MCUs */
317    cinfo->MCUs_per_row = compptr->width_in_blocks;
318    cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
319   
320    /* For noninterleaved scan, always one block per MCU */
321    compptr->MCU_width = 1;
322    compptr->MCU_height = 1;
323    compptr->MCU_blocks = 1;
324    compptr->MCU_sample_width = DCTSIZE;
325    compptr->last_col_width = 1;
326    /* For noninterleaved scans, it is convenient to define last_row_height
327     * as the number of block rows present in the last iMCU row.
328     */
329    tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
330    if (tmp == 0) tmp = compptr->v_samp_factor;
331    compptr->last_row_height = tmp;
332   
333    /* Prepare array describing MCU composition */
334    cinfo->blocks_in_MCU = 1;
335    cinfo->MCU_membership[0] = 0;
336   
337  } else {
338   
339    /* Interleaved (multi-component) scan */
340    if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
341      ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
342               MAX_COMPS_IN_SCAN);
343   
344    /* Overall image size in MCUs */
345    cinfo->MCUs_per_row = (JDIMENSION)
346      jdiv_round_up((long) cinfo->image_width,
347                    (long) (cinfo->max_h_samp_factor*DCTSIZE));
348    cinfo->MCU_rows_in_scan = (JDIMENSION)
349      jdiv_round_up((long) cinfo->image_height,
350                    (long) (cinfo->max_v_samp_factor*DCTSIZE));
351   
352    cinfo->blocks_in_MCU = 0;
353   
354    for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
355      compptr = cinfo->cur_comp_info[ci];
356      /* Sampling factors give # of blocks of component in each MCU */
357      compptr->MCU_width = compptr->h_samp_factor;
358      compptr->MCU_height = compptr->v_samp_factor;
359      compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
360      compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
361      /* Figure number of non-dummy blocks in last MCU column & row */
362      tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
363      if (tmp == 0) tmp = compptr->MCU_width;
364      compptr->last_col_width = tmp;
365      tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
366      if (tmp == 0) tmp = compptr->MCU_height;
367      compptr->last_row_height = tmp;
368      /* Prepare array describing MCU composition */
369      mcublks = compptr->MCU_blocks;
370      if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
371        ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
372      while (mcublks-- > 0) {
373        cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
374      }
375    }
376   
377  }
378
379  /* Convert restart specified in rows to actual MCU count. */
380  /* Note that count must fit in 16 bits, so we provide limiting. */
381  if (cinfo->restart_in_rows > 0) {
382    long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row;
383    cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L);
384  }
385}
386
387
388/*
389 * Per-pass setup.
390 * This is called at the beginning of each pass.  We determine which modules
391 * will be active during this pass and give them appropriate start_pass calls.
392 * We also set is_last_pass to indicate whether any more passes will be
393 * required.
394 */
395
396METHODDEF(void)
397prepare_for_pass (j_compress_ptr cinfo)
398{
399  my_master_ptr master = (my_master_ptr) cinfo->master;
400
401  switch (master->pass_type) {
402  case main_pass:
403    /* Initial pass: will collect input data, and do either Huffman
404     * optimization or data output for the first scan.
405     */
406    select_scan_parameters(cinfo);
407    per_scan_setup(cinfo);
408    if (! cinfo->raw_data_in) {
409      (*cinfo->cconvert->start_pass) (cinfo);
410      (*cinfo->downsample->start_pass) (cinfo);
411      (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
412    }
413    (*cinfo->fdct->start_pass) (cinfo);
414    (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
415    (*cinfo->coef->start_pass) (cinfo,
416                                (master->total_passes > 1 ?
417                                 JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
418    (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
419    if (cinfo->optimize_coding) {
420      /* No immediate data output; postpone writing frame/scan headers */
421      master->pub.call_pass_startup = FALSE;
422    } else {
423      /* Will write frame/scan headers at first jpeg_write_scanlines call */
424      master->pub.call_pass_startup = TRUE;
425    }
426    break;
427#ifdef ENTROPY_OPT_SUPPORTED
428  case huff_opt_pass:
429    /* Do Huffman optimization for a scan after the first one. */
430    select_scan_parameters(cinfo);
431    per_scan_setup(cinfo);
432    if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) {
433      (*cinfo->entropy->start_pass) (cinfo, TRUE);
434      (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
435      master->pub.call_pass_startup = FALSE;
436      break;
437    }
438    /* Special case: Huffman DC refinement scans need no Huffman table
439     * and therefore we can skip the optimization pass for them.
440     */
441    master->pass_type = output_pass;
442    master->pass_number++;
443    /*FALLTHROUGH*/
444#endif
445  case output_pass:
446    /* Do a data-output pass. */
447    /* We need not repeat per-scan setup if prior optimization pass did it. */
448    if (! cinfo->optimize_coding) {
449      select_scan_parameters(cinfo);
450      per_scan_setup(cinfo);
451    }
452    (*cinfo->entropy->start_pass) (cinfo, FALSE);
453    (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
454    /* We emit frame/scan headers now */
455    if (master->scan_number == 0)
456      (*cinfo->marker->write_frame_header) (cinfo);
457    (*cinfo->marker->write_scan_header) (cinfo);
458    master->pub.call_pass_startup = FALSE;
459    break;
460  default:
461    ERREXIT(cinfo, JERR_NOT_COMPILED);
462  }
463
464  master->pub.is_last_pass = (master->pass_number == master->total_passes-1);
465
466  /* Set up progress monitor's pass info if present */
467  if (cinfo->progress != NULL) {
468    cinfo->progress->completed_passes = master->pass_number;
469    cinfo->progress->total_passes = master->total_passes;
470  }
471}
472
473
474/*
475 * Special start-of-pass hook.
476 * This is called by jpeg_write_scanlines if call_pass_startup is TRUE.
477 * In single-pass processing, we need this hook because we don't want to
478 * write frame/scan headers during jpeg_start_compress; we want to let the
479 * application write COM markers etc. between jpeg_start_compress and the
480 * jpeg_write_scanlines loop.
481 * In multi-pass processing, this routine is not used.
482 */
483
484METHODDEF(void)
485pass_startup (j_compress_ptr cinfo)
486{
487  cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
488
489  (*cinfo->marker->write_frame_header) (cinfo);
490  (*cinfo->marker->write_scan_header) (cinfo);
491}
492
493
494/*
495 * Finish up at end of pass.
496 */
497
498METHODDEF(void)
499finish_pass_master (j_compress_ptr cinfo)
500{
501  my_master_ptr master = (my_master_ptr) cinfo->master;
502
503  /* The entropy coder always needs an end-of-pass call,
504   * either to analyze statistics or to flush its output buffer.
505   */
506  (*cinfo->entropy->finish_pass) (cinfo);
507
508  /* Update state for next pass */
509  switch (master->pass_type) {
510  case main_pass:
511    /* next pass is either output of scan 0 (after optimization)
512     * or output of scan 1 (if no optimization).
513     */
514    master->pass_type = output_pass;
515    if (! cinfo->optimize_coding)
516      master->scan_number++;
517    break;
518  case huff_opt_pass:
519    /* next pass is always output of current scan */
520    master->pass_type = output_pass;
521    break;
522  case output_pass:
523    /* next pass is either optimization or output of next scan */
524    if (cinfo->optimize_coding)
525      master->pass_type = huff_opt_pass;
526    master->scan_number++;
527    break;
528  }
529
530  master->pass_number++;
531}
532
533
534/*
535 * Initialize master compression control.
536 */
537
538GLOBAL(void)
539jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
540{
541  my_master_ptr master;
542
543  master = (my_master_ptr)
544      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
545                                  SIZEOF(my_comp_master));
546  cinfo->master = (struct jpeg_comp_master *) master;
547  master->pub.prepare_for_pass = prepare_for_pass;
548  master->pub.pass_startup = pass_startup;
549  master->pub.finish_pass = finish_pass_master;
550  master->pub.is_last_pass = FALSE;
551
552  /* Validate parameters, determine derived values */
553  initial_setup(cinfo);
554
555  if (cinfo->scan_info != NULL) {
556#ifdef C_MULTISCAN_FILES_SUPPORTED
557    validate_script(cinfo);
558#else
559    ERREXIT(cinfo, JERR_NOT_COMPILED);
560#endif
561  } else {
562    cinfo->progressive_mode = FALSE;
563    cinfo->num_scans = 1;
564  }
565
566  if (cinfo->progressive_mode)  /*  TEMPORARY HACK ??? */
567    cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
568
569  /* Initialize my private state */
570  if (transcode_only) {
571    /* no main pass in transcoding */
572    if (cinfo->optimize_coding)
573      master->pass_type = huff_opt_pass;
574    else
575      master->pass_type = output_pass;
576  } else {
577    /* for normal compression, first pass is always this type: */
578    master->pass_type = main_pass;
579  }
580  master->scan_number = 0;
581  master->pass_number = 0;
582  if (cinfo->optimize_coding)
583    master->total_passes = cinfo->num_scans * 2;
584  else
585    master->total_passes = cinfo->num_scans;
586}
Note: See TracBrowser for help on using the repository browser.