10 #define JPEG_INTERNALS 42 #ifdef UPSAMPLE_MERGING_SUPPORTED 44 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
47 if (cinfo->jpeg_color_space !=
JCS_YCbCr || cinfo->num_components != 3 ||
48 cinfo->out_color_space !=
JCS_RGB ||
49 cinfo->out_color_components != RGB_PIXELSIZE)
52 if (cinfo->comp_info[0].h_samp_factor != 2 ||
53 cinfo->comp_info[1].h_samp_factor != 1 ||
54 cinfo->comp_info[2].h_samp_factor != 1 ||
55 cinfo->comp_info[0].v_samp_factor > 2 ||
56 cinfo->comp_info[1].v_samp_factor != 1 ||
57 cinfo->comp_info[2].v_samp_factor != 1)
60 if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
61 cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
62 cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
83 #ifdef IDCT_SCALING_SUPPORTED 90 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
92 #ifdef IDCT_SCALING_SUPPORTED 95 if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
101 cinfo->min_DCT_scaled_size = 1;
102 }
else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
108 cinfo->min_DCT_scaled_size = 2;
109 }
else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
115 cinfo->min_DCT_scaled_size = 4;
118 cinfo->output_width = cinfo->image_width;
119 cinfo->output_height = cinfo->image_height;
120 cinfo->min_DCT_scaled_size =
DCTSIZE;
127 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
129 int ssize = cinfo->min_DCT_scaled_size;
132 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
134 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
143 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
149 (long) (cinfo->max_h_samp_factor *
DCTSIZE));
153 (long) (cinfo->max_v_samp_factor *
DCTSIZE));
159 cinfo->output_width = cinfo->image_width;
160 cinfo->output_height = cinfo->image_height;
169 switch (cinfo->out_color_space) {
171 cinfo->out_color_components = 1;
174 #if RGB_PIXELSIZE != 3 175 cinfo->out_color_components = RGB_PIXELSIZE;
179 cinfo->out_color_components = 3;
183 cinfo->out_color_components = 4;
186 cinfo->out_color_components = cinfo->num_components;
189 cinfo->output_components = (cinfo->quantize_colors ? 1 :
190 cinfo->out_color_components);
194 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
196 cinfo->rec_outbuf_height = 1;
254 cinfo->sample_range_limit =
table;
287 boolean use_c_buffer;
296 samplesperrow = (long) cinfo->output_width * (
long) cinfo->out_color_components;
297 jd_samplesperrow = (
JDIMENSION) samplesperrow;
298 if ((
long) jd_samplesperrow != samplesperrow)
299 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
306 master->quantizer_1pass = NULL;
307 master->quantizer_2pass = NULL;
309 if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
310 cinfo->enable_1pass_quant =
FALSE;
311 cinfo->enable_external_quant =
FALSE;
312 cinfo->enable_2pass_quant =
FALSE;
314 if (cinfo->quantize_colors) {
315 if (cinfo->raw_data_out)
318 if (cinfo->out_color_components != 3) {
319 cinfo->enable_1pass_quant =
TRUE;
320 cinfo->enable_external_quant =
FALSE;
321 cinfo->enable_2pass_quant =
FALSE;
322 cinfo->colormap = NULL;
323 }
else if (cinfo->colormap != NULL) {
324 cinfo->enable_external_quant =
TRUE;
325 }
else if (cinfo->two_pass_quantize) {
326 cinfo->enable_2pass_quant =
TRUE;
328 cinfo->enable_1pass_quant =
TRUE;
331 if (cinfo->enable_1pass_quant) {
332 #ifdef QUANT_1PASS_SUPPORTED 334 master->quantizer_1pass = cinfo->cquantize;
336 ERREXIT(cinfo, JERR_NOT_COMPILED);
341 if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
342 #ifdef QUANT_2PASS_SUPPORTED 344 master->quantizer_2pass = cinfo->cquantize;
346 ERREXIT(cinfo, JERR_NOT_COMPILED);
355 if (! cinfo->raw_data_out) {
356 if (master->using_merged_upsample) {
357 #ifdef UPSAMPLE_MERGING_SUPPORTED 360 ERREXIT(cinfo, JERR_NOT_COMPILED);
371 if (cinfo->arith_code) {
372 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
374 if (cinfo->progressive_mode) {
375 #ifdef D_PROGRESSIVE_SUPPORTED 378 ERREXIT(cinfo, JERR_NOT_COMPILED);
385 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
388 if (! cinfo->raw_data_out)
392 (*cinfo->mem->realize_virt_arrays) ((
j_common_ptr) cinfo);
395 (*cinfo->inputctl->start_input_pass) (cinfo);
397 #ifdef D_MULTISCAN_FILES_SUPPORTED 402 if (cinfo->progress != NULL && ! cinfo->buffered_image &&
403 cinfo->inputctl->has_multiple_scans) {
406 if (cinfo->progressive_mode) {
408 nscans = 2 + 3 * cinfo->num_components;
411 nscans = cinfo->num_components;
413 cinfo->progress->pass_counter = 0L;
414 cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
415 cinfo->progress->completed_passes = 0;
416 cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
438 if (master->
pub.is_dummy_pass) {
439 #ifdef QUANT_2PASS_SUPPORTED 442 (*cinfo->cquantize->start_pass) (cinfo,
FALSE);
446 ERREXIT(cinfo, JERR_NOT_COMPILED);
449 if (cinfo->quantize_colors && cinfo->colormap == NULL) {
451 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
452 cinfo->cquantize = master->quantizer_2pass;
453 master->
pub.is_dummy_pass =
TRUE;
454 }
else if (cinfo->enable_1pass_quant) {
455 cinfo->cquantize = master->quantizer_1pass;
457 ERREXIT(cinfo, JERR_MODE_CHANGE);
460 (*cinfo->idct->start_pass) (cinfo);
461 (*cinfo->coef->start_output_pass) (cinfo);
462 if (! cinfo->raw_data_out) {
463 if (! master->using_merged_upsample)
464 (*cinfo->cconvert->start_pass) (cinfo);
465 (*cinfo->upsample->start_pass) (cinfo);
466 if (cinfo->quantize_colors)
467 (*cinfo->cquantize->start_pass) (cinfo, master->
pub.is_dummy_pass);
468 (*cinfo->post->start_pass) (cinfo,
475 if (cinfo->progress != NULL) {
476 cinfo->progress->completed_passes = master->
pass_number;
477 cinfo->progress->total_passes = master->
pass_number +
478 (master->
pub.is_dummy_pass ? 2 : 1);
482 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
483 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
498 if (cinfo->quantize_colors)
499 (*cinfo->cquantize->finish_pass) (cinfo);
504 #ifdef D_MULTISCAN_FILES_SUPPORTED 517 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
519 if (cinfo->quantize_colors && cinfo->enable_external_quant &&
520 cinfo->colormap != NULL) {
522 cinfo->cquantize = master->quantizer_2pass;
524 (*cinfo->cquantize->new_color_map) (cinfo);
527 ERREXIT(cinfo, JERR_MODE_CHANGE);
jdiv_round_up(long a, long b)
jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
jinit_merged_upsampler(j_decompress_ptr cinfo)
JDIMENSION downsampled_width
jinit_1pass_quantizer(j_decompress_ptr cinfo)
jinit_inverse_dct(j_decompress_ptr cinfo)
master_selection(j_decompress_ptr cinfo)
prepare_range_limit_table(j_decompress_ptr cinfo)
struct jpeg_common_struct * j_common_ptr
GLenum GLsizei GLenum GLenum const GLvoid * table
#define ERREXIT(cinfo, code)
struct jpeg_color_quantizer * quantizer_1pass
jpeg_component_info * compptr
boolean using_merged_upsample
struct jpeg_comp_master pub
jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
my_decomp_master * my_master_ptr
jinit_2pass_quantizer(j_decompress_ptr cinfo)
#define MEMCOPY(dest, src, size)
jinit_color_deconverter(j_decompress_ptr cinfo)
jinit_huff_decoder(j_decompress_ptr cinfo)
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
jinit_phuff_decoder(j_decompress_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
struct jpeg_color_quantizer * quantizer_2pass
jpeg_new_colormap(j_decompress_ptr cinfo)
use_merged_upsample(j_decompress_ptr cinfo)
finish_output_pass(j_decompress_ptr cinfo)
prepare_for_output_pass(j_decompress_ptr cinfo)
jinit_upsampler(j_decompress_ptr cinfo)
jinit_master_decompress(j_decompress_ptr cinfo)
#define MEMZERO(target, size)
JDIMENSION downsampled_height