10 #define JPEG_INTERNALS 41 #ifdef UPSAMPLE_MERGING_SUPPORTED 43 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
return FALSE;
45 if (cinfo->jpeg_color_space !=
JCS_YCbCr || cinfo->num_components != 3 ||
46 cinfo->out_color_space !=
JCS_RGB ||
47 cinfo->out_color_components != RGB_PIXELSIZE)
50 if (cinfo->comp_info[0].h_samp_factor != 2 ||
51 cinfo->comp_info[1].h_samp_factor != 1 ||
52 cinfo->comp_info[2].h_samp_factor != 1 ||
53 cinfo->comp_info[0].v_samp_factor > 2 ||
54 cinfo->comp_info[1].v_samp_factor != 1 ||
55 cinfo->comp_info[2].v_samp_factor != 1)
58 if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
59 cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
60 cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
80 #ifdef IDCT_SCALING_SUPPORTED 87 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
89 #ifdef IDCT_SCALING_SUPPORTED 92 if (cinfo->scale_num * 8 <= cinfo->scale_denom)
97 cinfo->output_height =
99 cinfo->min_DCT_scaled_size = 1;
101 else if (cinfo->scale_num * 4 <= cinfo->scale_denom)
104 cinfo->output_width =
106 cinfo->output_height =
108 cinfo->min_DCT_scaled_size = 2;
110 else if (cinfo->scale_num * 2 <= cinfo->scale_denom)
113 cinfo->output_width =
115 cinfo->output_height =
117 cinfo->min_DCT_scaled_size = 4;
122 cinfo->output_width = cinfo->image_width;
123 cinfo->output_height = cinfo->image_height;
124 cinfo->min_DCT_scaled_size =
DCTSIZE;
131 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
134 int ssize = cinfo->min_DCT_scaled_size;
137 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
139 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size))
149 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
154 (
long)cinfo->image_width *
156 (long)(cinfo->max_h_samp_factor *
DCTSIZE));
158 (
long)cinfo->image_height *
160 (long)(cinfo->max_v_samp_factor *
DCTSIZE));
166 cinfo->output_width = cinfo->image_width;
167 cinfo->output_height = cinfo->image_height;
176 switch (cinfo->out_color_space)
179 cinfo->out_color_components = 1;
182 #if RGB_PIXELSIZE != 3 183 cinfo->out_color_components = RGB_PIXELSIZE;
187 cinfo->out_color_components = 3;
191 cinfo->out_color_components = 4;
194 cinfo->out_color_components = cinfo->num_components;
197 cinfo->output_components =
198 (cinfo->quantize_colors ? 1 : cinfo->out_color_components);
202 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
204 cinfo->rec_outbuf_height = 1;
261 cinfo->sample_range_limit =
table;
294 boolean use_c_buffer;
304 (long)cinfo->output_width * (
long)cinfo->out_color_components;
306 if ((
long)jd_samplesperrow != samplesperrow)
307 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
314 master->quantizer_1pass =
nullptr;
315 master->quantizer_2pass =
nullptr;
317 if (!cinfo->quantize_colors || !cinfo->buffered_image)
319 cinfo->enable_1pass_quant =
FALSE;
320 cinfo->enable_external_quant =
FALSE;
321 cinfo->enable_2pass_quant =
FALSE;
323 if (cinfo->quantize_colors)
325 if (cinfo->raw_data_out)
ERREXIT(cinfo, JERR_NOTIMPL);
327 if (cinfo->out_color_components != 3)
329 cinfo->enable_1pass_quant =
TRUE;
330 cinfo->enable_external_quant =
FALSE;
331 cinfo->enable_2pass_quant =
FALSE;
332 cinfo->colormap =
nullptr;
334 else if (cinfo->colormap !=
nullptr)
336 cinfo->enable_external_quant =
TRUE;
338 else if (cinfo->two_pass_quantize)
340 cinfo->enable_2pass_quant =
TRUE;
344 cinfo->enable_1pass_quant =
TRUE;
347 if (cinfo->enable_1pass_quant)
349 #ifdef QUANT_1PASS_SUPPORTED 351 master->quantizer_1pass = cinfo->cquantize;
353 ERREXIT(cinfo, JERR_NOT_COMPILED);
358 if (cinfo->enable_2pass_quant || cinfo->enable_external_quant)
360 #ifdef QUANT_2PASS_SUPPORTED 362 master->quantizer_2pass = cinfo->cquantize;
364 ERREXIT(cinfo, JERR_NOT_COMPILED);
373 if (!cinfo->raw_data_out)
375 if (master->using_merged_upsample)
377 #ifdef UPSAMPLE_MERGING_SUPPORTED 380 ERREXIT(cinfo, JERR_NOT_COMPILED);
393 if (cinfo->arith_code)
395 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
399 if (cinfo->progressive_mode)
401 #ifdef D_PROGRESSIVE_SUPPORTED 404 ERREXIT(cinfo, JERR_NOT_COMPILED);
412 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
415 if (!cinfo->raw_data_out)
419 (*cinfo->mem->realize_virt_arrays)((
j_common_ptr)cinfo);
422 (*cinfo->inputctl->start_input_pass)(cinfo);
424 #ifdef D_MULTISCAN_FILES_SUPPORTED 429 if (cinfo->progress !=
nullptr && !cinfo->buffered_image &&
430 cinfo->inputctl->has_multiple_scans)
434 if (cinfo->progressive_mode)
438 nscans = 2 + 3 * cinfo->num_components;
444 nscans = cinfo->num_components;
446 cinfo->progress->pass_counter = 0L;
447 cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
448 cinfo->progress->completed_passes = 0;
449 cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
470 if (master->
pub.is_dummy_pass)
472 #ifdef QUANT_2PASS_SUPPORTED 475 (*cinfo->cquantize->start_pass)(cinfo,
FALSE);
479 ERREXIT(cinfo, JERR_NOT_COMPILED);
484 if (cinfo->quantize_colors && cinfo->colormap ==
nullptr)
487 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant)
489 cinfo->cquantize = master->quantizer_2pass;
490 master->
pub.is_dummy_pass =
TRUE;
492 else if (cinfo->enable_1pass_quant)
494 cinfo->cquantize = master->quantizer_1pass;
498 ERREXIT(cinfo, JERR_MODE_CHANGE);
501 (*cinfo->idct->start_pass)(cinfo);
502 (*cinfo->coef->start_output_pass)(cinfo);
503 if (!cinfo->raw_data_out)
505 if (!master->using_merged_upsample)
506 (*cinfo->cconvert->start_pass)(cinfo);
507 (*cinfo->upsample->start_pass)(cinfo);
508 if (cinfo->quantize_colors)
509 (*cinfo->cquantize->start_pass)(
510 cinfo, master->
pub.is_dummy_pass);
511 (*cinfo->post->start_pass)(
519 if (cinfo->progress !=
nullptr)
521 cinfo->progress->completed_passes = master->
pass_number;
522 cinfo->progress->total_passes =
527 if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached)
529 cinfo->progress->total_passes +=
530 (cinfo->enable_2pass_quant ? 2 : 1);
544 if (cinfo->quantize_colors) (*cinfo->cquantize->finish_pass)(cinfo);
548 #ifdef D_MULTISCAN_FILES_SUPPORTED 561 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
563 if (cinfo->quantize_colors && cinfo->enable_external_quant &&
564 cinfo->colormap !=
nullptr)
567 cinfo->cquantize = master->quantizer_2pass;
569 (*cinfo->cquantize->new_color_map)(cinfo);
573 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
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)
jpeg_component_info * compptr
JDIMENSION downsampled_height