COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jdmaster.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdmaster.cpp:

Classes

struct  my_decomp_master
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_decomp_mastermy_master_ptr
 

Functions

static boolean use_merged_upsample (j_decompress_ptr cinfo)
 
void jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
 
static void prepare_range_limit_table (j_decompress_ptr cinfo)
 
static void master_selection (j_decompress_ptr cinfo)
 
static void prepare_for_output_pass (j_decompress_ptr cinfo)
 
static void finish_output_pass (j_decompress_ptr cinfo)
 
void jpeg_new_colormap (j_decompress_ptr cinfo)
 
void jinit_master_decompress (j_decompress_ptr cinfo)
 

Macro Definition Documentation

#define JPEG_INTERNALS

Typedef Documentation

Function Documentation

static boolean use_merged_upsample ( j_decompress_ptr  cinfo)
static
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  /* jdmerge.c only supports YCC=>RGB color conversion */
51  if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
52  cinfo->out_color_space != JCS_RGB ||
53  cinfo->out_color_components != RGB_PIXELSIZE)
54  return FALSE;
55  /* and it only handles 2h1v or 2h2v sampling ratios */
56  if (cinfo->comp_info[0].h_samp_factor != 2 ||
57  cinfo->comp_info[1].h_samp_factor != 1 ||
58  cinfo->comp_info[2].h_samp_factor != 1 ||
59  cinfo->comp_info[0].v_samp_factor > 2 ||
60  cinfo->comp_info[1].v_samp_factor != 1 ||
61  cinfo->comp_info[2].v_samp_factor != 1)
62  return FALSE;
63  /* furthermore, it doesn't work if we've scaled the IDCTs differently */
64  if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
65  cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
66  cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
67  return FALSE;
68  /* ??? also need to test for upsample-time rescaling, when & if supported */
69  return TRUE; /* by golly, it'll work... */
70 #else
71  return FALSE;
72 #endif
73 }
int v_samp_factor
Definition: jpeglib.h:128
int num_components
Definition: jpeglib.h:427
jpeg_component_info * comp_info
Definition: jpeglib.h:540
boolean do_fancy_upsampling
Definition: jpeglib.h:445
int min_DCT_scaled_size
Definition: jpeglib.h:583
int DCT_scaled_size
Definition: jpeglib.h:152
J_COLOR_SPACE out_color_space
Definition: jpeglib.h:435
#define FALSE
Definition: jpleph.cpp:69
Definition: jpeglib.h:214
int out_color_components
Definition: jpeglib.h:466
#define TRUE
Definition: jpleph.cpp:68
boolean CCIR601_sampling
Definition: jpeglib.h:565
Definition: jpeglib.h:215
int h_samp_factor
Definition: jpeglib.h:127
J_COLOR_SPACE jpeg_color_space
Definition: jpeglib.h:428
void jpeg_calc_output_dimensions ( j_decompress_ptr  cinfo)
86 {
87 #ifdef IDCT_SCALING_SUPPORTED
88  int ci;
90 #endif
91 
92  /* Prevent application from calling me at wrong times */
93  if (cinfo->global_state != DSTATE_READY)
94  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
95 
96 #ifdef IDCT_SCALING_SUPPORTED
97 
98  /* Compute actual output image dimensions and DCT scaling choices. */
99  if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
100  /* Provide 1/8 scaling */
101  cinfo->output_width = (JDIMENSION)
102  jdiv_round_up((long) cinfo->image_width, 8L);
103  cinfo->output_height = (JDIMENSION)
104  jdiv_round_up((long) cinfo->image_height, 8L);
105  cinfo->min_DCT_scaled_size = 1;
106  } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
107  /* Provide 1/4 scaling */
108  cinfo->output_width = (JDIMENSION)
109  jdiv_round_up((long) cinfo->image_width, 4L);
110  cinfo->output_height = (JDIMENSION)
111  jdiv_round_up((long) cinfo->image_height, 4L);
112  cinfo->min_DCT_scaled_size = 2;
113  } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
114  /* Provide 1/2 scaling */
115  cinfo->output_width = (JDIMENSION)
116  jdiv_round_up((long) cinfo->image_width, 2L);
117  cinfo->output_height = (JDIMENSION)
118  jdiv_round_up((long) cinfo->image_height, 2L);
119  cinfo->min_DCT_scaled_size = 4;
120  } else {
121  /* Provide 1/1 scaling */
122  cinfo->output_width = cinfo->image_width;
123  cinfo->output_height = cinfo->image_height;
124  cinfo->min_DCT_scaled_size = DCTSIZE;
125  }
126  /* In selecting the actual DCT scaling for each component, we try to
127  * scale up the chroma components via IDCT scaling rather than upsampling.
128  * This saves time if the upsampler gets to use 1:1 scaling.
129  * Note this code assumes that the supported DCT scalings are powers of 2.
130  */
131  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
132  ci++, compptr++) {
133  int ssize = cinfo->min_DCT_scaled_size;
134  while (ssize < DCTSIZE &&
135  (compptr->h_samp_factor * ssize * 2 <=
136  cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
137  (compptr->v_samp_factor * ssize * 2 <=
138  cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
139  ssize = ssize * 2;
140  }
141  compptr->DCT_scaled_size = ssize;
142  }
143 
144  /* Recompute downsampled dimensions of components;
145  * application needs to know these if using raw downsampled data.
146  */
147  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
148  ci++, compptr++) {
149  /* Size in samples, after IDCT scaling */
150  compptr->downsampled_width = (JDIMENSION)
151  jdiv_round_up((long) cinfo->image_width *
152  (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
153  (long) (cinfo->max_h_samp_factor * DCTSIZE));
154  compptr->downsampled_height = (JDIMENSION)
155  jdiv_round_up((long) cinfo->image_height *
156  (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
157  (long) (cinfo->max_v_samp_factor * DCTSIZE));
158  }
159 
160 #else /* !IDCT_SCALING_SUPPORTED */
161 
162  /* Hardwire it to "no scaling" */
163  cinfo->output_width = cinfo->image_width;
164  cinfo->output_height = cinfo->image_height;
165  /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
166  * and has computed unscaled downsampled_width and downsampled_height.
167  */
168 
169 #endif /* IDCT_SCALING_SUPPORTED */
170 
171  /* Report number of components in selected colorspace. */
172  /* Probably this should be in the color conversion module... */
173  switch (cinfo->out_color_space) {
174  case JCS_GRAYSCALE:
175  cinfo->out_color_components = 1;
176  break;
177  case JCS_RGB:
178 #if RGB_PIXELSIZE != 3
179  cinfo->out_color_components = RGB_PIXELSIZE;
180  break;
181 #endif /* else share code with YCbCr */
182  case JCS_YCbCr:
183  cinfo->out_color_components = 3;
184  break;
185  case JCS_CMYK:
186  case JCS_YCCK:
187  cinfo->out_color_components = 4;
188  break;
189  default: /* else must be same colorspace as in file */
190  cinfo->out_color_components = cinfo->num_components;
191  break;
192  }
193  cinfo->output_components = (cinfo->quantize_colors ? 1 :
194  cinfo->out_color_components);
195 
196  /* See if upsampler will want to emit more than one row at a time */
197  if (use_merged_upsample(cinfo))
198  cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
199  else
200  cinfo->rec_outbuf_height = 1;
201 }
Definition: jpeglib.h:217
int v_samp_factor
Definition: jpeglib.h:128
int num_components
Definition: jpeglib.h:427
JDIMENSION output_height
Definition: jpeglib.h:465
JDIMENSION downsampled_width
Definition: jpeglib.h:159
int rec_outbuf_height
Definition: jpeglib.h:471
jpeg_component_info * comp_info
Definition: jpeglib.h:540
boolean quantize_colors
Definition: jpeglib.h:448
int min_DCT_scaled_size
Definition: jpeglib.h:583
int DCT_scaled_size
Definition: jpeglib.h:152
JDIMENSION image_width
Definition: jpeglib.h:425
Definition: jerror.h:65
JDIMENSION output_width
Definition: jpeglib.h:464
JDIMENSION image_height
Definition: jpeglib.h:426
jpeg_component_info * compptr
Definition: jdct.h:102
J_COLOR_SPACE out_color_space
Definition: jpeglib.h:435
int max_h_samp_factor
Definition: jpeglib.h:580
Definition: jpeglib.h:214
Definition: jpeglib.h:213
int output_components
Definition: jpeglib.h:467
#define DSTATE_READY
Definition: jpegint.h:31
int out_color_components
Definition: jpeglib.h:466
unsigned int scale_denom
Definition: jpeglib.h:437
int max_v_samp_factor
Definition: jpeglib.h:581
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
Definition: jpeglib.h:121
static boolean use_merged_upsample(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:44
long jdiv_round_up(long a, long b)
Definition: jutils.cpp:72
Definition: jpeglib.h:215
#define DCTSIZE
Definition: jpeglib.h:46
int h_samp_factor
Definition: jpeglib.h:127
int global_state
Definition: jpeglib.h:417
unsigned int JDIMENSION
Definition: jmorecfg.h:171
unsigned int scale_num
Definition: jpeglib.h:437
Definition: jpeglib.h:216
JDIMENSION downsampled_height
Definition: jpeglib.h:160
static void prepare_range_limit_table ( j_decompress_ptr  cinfo)
static
250 {
251  JSAMPLE * table;
252  int i;
253 
254  table = (JSAMPLE *)
255  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
256  (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
257  table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
258  cinfo->sample_range_limit = table;
259  /* First segment of "simple" table: limit[x] = 0 for x < 0 */
260  MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
261  /* Main part of "simple" table: limit[x] = x */
262  for (i = 0; i <= MAXJSAMPLE; i++)
263  table[i] = (JSAMPLE) i;
264  table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
265  /* End of simple table, rest of first half of post-IDCT table */
266  for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
267  table[i] = MAXJSAMPLE;
268  /* Second half of post-IDCT table */
269  MEMZERO(table + (2 * (MAXJSAMPLE+1)),
270  (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
271  MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
273 }
#define CENTERJSAMPLE
Definition: jmorecfg.h:74
char JSAMPLE
Definition: jmorecfg.h:64
int i
Definition: rw_test.cpp:37
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
void *(* alloc_small)()
Definition: jpeglib.h:764
#define SIZEOF(object)
Definition: jinclude.h:80
#define MAXJSAMPLE
Definition: jmorecfg.h:73
#define JPOOL_IMAGE
Definition: jpeglib.h:754
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
#define MEMCOPY(dest, src, size)
Definition: jinclude.h:68
JSAMPLE * sample_range_limit
Definition: jpeglib.h:594
#define MEMZERO(target, size)
Definition: jinclude.h:67
static void master_selection ( j_decompress_ptr  cinfo)
static
289 {
290  my_master_ptr master = (my_master_ptr) cinfo->master;
291  boolean use_c_buffer;
292  long samplesperrow;
293  JDIMENSION jd_samplesperrow;
294 
295  /* Initialize dimensions and other stuff */
298 
299  /* Width of an output scanline must be representable as JDIMENSION. */
300  samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
301  jd_samplesperrow = (JDIMENSION) samplesperrow;
302  if ((long) jd_samplesperrow != samplesperrow)
304 
305  /* Initialize my private state */
306  master->pass_number = 0;
307  master->using_merged_upsample = use_merged_upsample(cinfo);
308 
309  /* Color quantizer selection */
310  master->quantizer_1pass = NULL;
311  master->quantizer_2pass = NULL;
312  /* No mode changes if not using buffered-image mode. */
313  if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
314  cinfo->enable_1pass_quant = FALSE;
315  cinfo->enable_external_quant = FALSE;
316  cinfo->enable_2pass_quant = FALSE;
317  }
318  if (cinfo->quantize_colors) {
319  if (cinfo->raw_data_out)
320  ERREXIT(cinfo, JERR_NOTIMPL);
321  /* 2-pass quantizer only works in 3-component color space. */
322  if (cinfo->out_color_components != 3) {
323  cinfo->enable_1pass_quant = TRUE;
324  cinfo->enable_external_quant = FALSE;
325  cinfo->enable_2pass_quant = FALSE;
326  cinfo->colormap = NULL;
327  } else if (cinfo->colormap != NULL) {
328  cinfo->enable_external_quant = TRUE;
329  } else if (cinfo->two_pass_quantize) {
330  cinfo->enable_2pass_quant = TRUE;
331  } else {
332  cinfo->enable_1pass_quant = TRUE;
333  }
334 
335  if (cinfo->enable_1pass_quant) {
336 #ifdef QUANT_1PASS_SUPPORTED
337  jinit_1pass_quantizer(cinfo);
338  master->quantizer_1pass = cinfo->cquantize;
339 #else
340  ERREXIT(cinfo, JERR_NOT_COMPILED);
341 #endif
342  }
343 
344  /* We use the 2-pass code to map to external colormaps. */
345  if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
346 #ifdef QUANT_2PASS_SUPPORTED
347  jinit_2pass_quantizer(cinfo);
348  master->quantizer_2pass = cinfo->cquantize;
349 #else
350  ERREXIT(cinfo, JERR_NOT_COMPILED);
351 #endif
352  }
353  /* If both quantizers are initialized, the 2-pass one is left active;
354  * this is necessary for starting with quantization to an external map.
355  */
356  }
357 
358  /* Post-processing: in particular, color conversion first */
359  if (! cinfo->raw_data_out) {
360  if (master->using_merged_upsample) {
361 #ifdef UPSAMPLE_MERGING_SUPPORTED
362  jinit_merged_upsampler(cinfo); /* does color conversion too */
363 #else
364  ERREXIT(cinfo, JERR_NOT_COMPILED);
365 #endif
366  } else {
368  jinit_upsampler(cinfo);
369  }
371  }
372  /* Inverse DCT */
373  jinit_inverse_dct(cinfo);
374  /* Entropy decoding: either Huffman or arithmetic coding. */
375  if (cinfo->arith_code) {
376  ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
377  } else {
378  if (cinfo->progressive_mode) {
379 #ifdef D_PROGRESSIVE_SUPPORTED
380  jinit_phuff_decoder(cinfo);
381 #else
382  ERREXIT(cinfo, JERR_NOT_COMPILED);
383 #endif
384  } else
385  jinit_huff_decoder(cinfo);
386  }
387 
388  /* Initialize principal buffer controllers. */
389  use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
390  jinit_d_coef_controller(cinfo, use_c_buffer);
391 
392  if (! cinfo->raw_data_out)
393  jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
394 
395  /* We can now tell the memory manager to allocate virtual arrays. */
396  (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
397 
398  /* Initialize input side of decompressor to consume first scan. */
399  (*cinfo->inputctl->start_input_pass) (cinfo);
400 
401 #ifdef D_MULTISCAN_FILES_SUPPORTED
402  /* If jpeg_start_decompress will read the whole file, initialize
403  * progress monitoring appropriately. The input step is counted
404  * as one pass.
405  */
406  if (cinfo->progress != NULL && ! cinfo->buffered_image &&
407  cinfo->inputctl->has_multiple_scans) {
408  int nscans;
409  /* Estimate number of scans to set pass_limit. */
410  if (cinfo->progressive_mode) {
411  /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
412  nscans = 2 + 3 * cinfo->num_components;
413  } else {
414  /* For a nonprogressive multiscan file, estimate 1 scan per component. */
415  nscans = cinfo->num_components;
416  }
417  cinfo->progress->pass_counter = 0L;
418  cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
419  cinfo->progress->completed_passes = 0;
420  cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
421  /* Count the input pass as done */
422  master->pass_number++;
423  }
424 #endif /* D_MULTISCAN_FILES_SUPPORTED */
425 }
boolean has_multiple_scans
Definition: jpegint.h:153
int num_components
Definition: jpeglib.h:427
void jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
Definition: jdcoefct.cpp:676
int completed_passes
Definition: jpeglib.h:711
void jinit_upsampler(j_decompress_ptr cinfo)
Definition: jdsample.cpp:399
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
Definition: jcmaster.cpp:27
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
boolean enable_2pass_quant
Definition: jpeglib.h:456
boolean quantize_colors
Definition: jpeglib.h:448
long pass_limit
Definition: jpeglib.h:710
boolean enable_external_quant
Definition: jpeglib.h:455
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
JDIMENSION output_width
Definition: jpeglib.h:464
void jinit_color_deconverter(j_decompress_ptr cinfo)
Definition: jdcolor.cpp:304
void jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:84
Definition: jerror.h:43
long pass_counter
Definition: jpeglib.h:709
int pass_number
Definition: jcmaster.cpp:32
boolean two_pass_quantize
Definition: jpeglib.h:451
Definition: jerror.h:119
void jinit_huff_decoder(j_decompress_ptr cinfo)
Definition: jdhuff.cpp:635
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
my_decomp_master * my_master_ptr
Definition: jdmaster.cpp:35
#define FALSE
Definition: jpleph.cpp:69
Definition: jerror.h:95
void jinit_inverse_dct(j_decompress_ptr cinfo)
Definition: jddctmgr.cpp:247
void jinit_merged_upsampler(j_decompress_ptr cinfo)
Definition: jdmerge.cpp:370
boolean raw_data_out
Definition: jpeglib.h:442
struct jpeg_color_quantizer * cquantize
Definition: jpeglib.h:634
boolean arith_code
Definition: jpeglib.h:544
int out_color_components
Definition: jpeglib.h:466
void jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
Definition: jdpostct.cpp:250
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
boolean enable_1pass_quant
Definition: jpeglib.h:454
#define TRUE
Definition: jpleph.cpp:68
Definition: jerror.h:94
void jinit_phuff_decoder(j_decompress_ptr cinfo)
Definition: jdphuff.cpp:641
JSAMPARRAY colormap
Definition: jpeglib.h:484
void(* realize_virt_arrays)()
Definition: jpeglib.h:785
int total_passes
Definition: jpeglib.h:712
static boolean use_merged_upsample(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:44
void jinit_1pass_quantizer(j_decompress_ptr cinfo)
Definition: jquant1.cpp:821
boolean progressive_mode
Definition: jpeglib.h:543
unsigned int JDIMENSION
Definition: jmorecfg.h:171
boolean buffered_image
Definition: jpeglib.h:441
void jinit_2pass_quantizer(j_decompress_ptr cinfo)
Definition: jquant2.cpp:1244
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
static void prepare_range_limit_table(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:248
void jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
Definition: jdmainct.cpp:476
static void prepare_for_output_pass ( j_decompress_ptr  cinfo)
static
439 {
440  my_master_ptr master = (my_master_ptr) cinfo->master;
441 
442  if (master->pub.is_dummy_pass) {
443 #ifdef QUANT_2PASS_SUPPORTED
444  /* Final pass of 2-pass quantization */
445  master->pub.is_dummy_pass = FALSE;
446  (*cinfo->cquantize->start_pass) (cinfo, FALSE);
447  (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
448  (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
449 #else
450  ERREXIT(cinfo, JERR_NOT_COMPILED);
451 #endif /* QUANT_2PASS_SUPPORTED */
452  } else {
453  if (cinfo->quantize_colors && cinfo->colormap == NULL) {
454  /* Select new quantization method */
455  if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
456  cinfo->cquantize = master->quantizer_2pass;
457  master->pub.is_dummy_pass = TRUE;
458  } else if (cinfo->enable_1pass_quant) {
459  cinfo->cquantize = master->quantizer_1pass;
460  } else {
461  ERREXIT(cinfo, JERR_MODE_CHANGE);
462  }
463  }
464  (*cinfo->idct->start_pass) (cinfo);
465  (*cinfo->coef->start_output_pass) (cinfo);
466  if (! cinfo->raw_data_out) {
467  if (! master->using_merged_upsample)
468  (*cinfo->cconvert->start_pass) (cinfo);
469  (*cinfo->upsample->start_pass) (cinfo);
470  if (cinfo->quantize_colors)
471  (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
472  (*cinfo->post->start_pass) (cinfo,
473  (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
474  (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
475  }
476  }
477 
478  /* Set up progress monitor's pass info if present */
479  if (cinfo->progress != NULL) {
480  cinfo->progress->completed_passes = master->pass_number;
481  cinfo->progress->total_passes = master->pass_number +
482  (master->pub.is_dummy_pass ? 2 : 1);
483  /* In buffered-image mode, we assume one more output pass if EOI not
484  * yet reached, but no more passes if EOI has been reached.
485  */
486  if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
487  cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
488  }
489  }
490 }
int completed_passes
Definition: jpeglib.h:711
struct jpeg_d_post_controller * post
Definition: jpeglib.h:627
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
Definition: jpegint.h:20
struct jpeg_d_main_controller * main
Definition: jpeglib.h:625
Definition: jcmaster.cpp:27
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
boolean enable_2pass_quant
Definition: jpeglib.h:456
boolean quantize_colors
Definition: jpeglib.h:448
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
Definition: jpegint.h:21
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
int pass_number
Definition: jcmaster.cpp:32
boolean two_pass_quantize
Definition: jpeglib.h:451
struct jpeg_comp_master pub
Definition: jcmaster.cpp:28
my_decomp_master * my_master_ptr
Definition: jdmaster.cpp:35
#define FALSE
Definition: jpleph.cpp:69
Definition: jerror.h:93
Definition: jerror.h:95
boolean raw_data_out
Definition: jpeglib.h:442
struct jpeg_color_quantizer * cquantize
Definition: jpeglib.h:634
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
boolean eoi_reached
Definition: jpegint.h:154
boolean enable_1pass_quant
Definition: jpeglib.h:454
#define TRUE
Definition: jpleph.cpp:68
struct jpeg_color_deconverter * cconvert
Definition: jpeglib.h:633
JSAMPARRAY colormap
Definition: jpeglib.h:484
int total_passes
Definition: jpeglib.h:712
struct jpeg_upsampler * upsample
Definition: jpeglib.h:632
Definition: jpegint.h:17
struct jpeg_inverse_dct * idct
Definition: jpeglib.h:631
boolean buffered_image
Definition: jpeglib.h:441
static void finish_output_pass ( j_decompress_ptr  cinfo)
static
499 {
500  my_master_ptr master = (my_master_ptr) cinfo->master;
501 
502  if (cinfo->quantize_colors)
503  (*cinfo->cquantize->finish_pass) (cinfo);
504  master->pass_number++;
505 }
Definition: jcmaster.cpp:27
boolean quantize_colors
Definition: jpeglib.h:448
int pass_number
Definition: jcmaster.cpp:32
my_decomp_master * my_master_ptr
Definition: jdmaster.cpp:35
struct jpeg_color_quantizer * cquantize
Definition: jpeglib.h:634
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
void jpeg_new_colormap ( j_decompress_ptr  cinfo)
516 {
517  my_master_ptr master = (my_master_ptr) cinfo->master;
518 
519  /* Prevent application from calling me at wrong times */
520  if (cinfo->global_state != DSTATE_BUFIMAGE)
521  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
522 
523  if (cinfo->quantize_colors && cinfo->enable_external_quant &&
524  cinfo->colormap != NULL) {
525  /* Select 2-pass quantizer for external colormap use */
526  cinfo->cquantize = master->quantizer_2pass;
527  /* Notify quantizer of colormap change */
528  (*cinfo->cquantize->new_color_map) (cinfo);
529  master->pub.is_dummy_pass = FALSE; /* just in case */
530  } else
531  ERREXIT(cinfo, JERR_MODE_CHANGE);
532 }
Definition: jcmaster.cpp:27
#define DSTATE_BUFIMAGE
Definition: jpegint.h:36
boolean quantize_colors
Definition: jpeglib.h:448
boolean enable_external_quant
Definition: jpeglib.h:455
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jerror.h:65
struct jpeg_comp_master pub
Definition: jcmaster.cpp:28
my_decomp_master * my_master_ptr
Definition: jdmaster.cpp:35
#define FALSE
Definition: jpleph.cpp:69
Definition: jerror.h:93
struct jpeg_color_quantizer * cquantize
Definition: jpeglib.h:634
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
JSAMPARRAY colormap
Definition: jpeglib.h:484
int global_state
Definition: jpeglib.h:417
void jinit_master_decompress ( j_decompress_ptr  cinfo)
544 {
545  my_master_ptr master;
546 
547  master = (my_master_ptr)
548  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
550  cinfo->master = (struct jpeg_decomp_master *) master;
551  master->pub.prepare_for_output_pass = prepare_for_output_pass;
552  master->pub.finish_output_pass = finish_output_pass;
553 
554  master->pub.is_dummy_pass = FALSE;
555 
556  master_selection(cinfo);
557 }
static void prepare_for_output_pass(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:438
Definition: jpegint.h:137
Definition: jcmaster.cpp:27
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
void *(* alloc_small)()
Definition: jpeglib.h:764
#define SIZEOF(object)
Definition: jinclude.h:80
#define JPOOL_IMAGE
Definition: jpeglib.h:754
struct jpeg_comp_master pub
Definition: jcmaster.cpp:28
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:417
my_decomp_master * my_master_ptr
Definition: jdmaster.cpp:35
#define FALSE
Definition: jpleph.cpp:69
static void finish_output_pass(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:498
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
Definition: jdmaster.cpp:21
static void master_selection(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:288