14 #define JPEG_INTERNALS 26 boolean using_merged_upsample;
46 #ifdef UPSAMPLE_MERGING_SUPPORTED 48 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
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)
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)
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)
87 #ifdef IDCT_SCALING_SUPPORTED 94 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
96 #ifdef IDCT_SCALING_SUPPORTED 99 if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
105 cinfo->min_DCT_scaled_size = 1;
106 }
else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
112 cinfo->min_DCT_scaled_size = 2;
113 }
else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
119 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;
133 int ssize = cinfo->min_DCT_scaled_size;
136 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
138 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
147 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
163 cinfo->output_width = cinfo->image_width;
164 cinfo->output_height = cinfo->image_height;
173 switch (cinfo->out_color_space) {
175 cinfo->out_color_components = 1;
178 #if RGB_PIXELSIZE != 3 179 cinfo->out_color_components = RGB_PIXELSIZE;
183 cinfo->out_color_components = 3;
187 cinfo->out_color_components = 4;
190 cinfo->out_color_components = cinfo->num_components;
193 cinfo->output_components = (cinfo->quantize_colors ? 1 :
194 cinfo->out_color_components);
198 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
200 cinfo->rec_outbuf_height = 1;
258 cinfo->sample_range_limit =
table;
291 boolean use_c_buffer;
300 samplesperrow = (
long) cinfo->output_width * (
long) cinfo->out_color_components;
301 jd_samplesperrow = (
JDIMENSION) samplesperrow;
302 if ((
long) jd_samplesperrow != samplesperrow)
303 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
306 master->pass_number = 0;
310 master->quantizer_1pass =
NULL;
311 master->quantizer_2pass =
NULL;
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;
318 if (cinfo->quantize_colors) {
319 if (cinfo->raw_data_out)
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;
332 cinfo->enable_1pass_quant =
TRUE;
335 if (cinfo->enable_1pass_quant) {
336 #ifdef QUANT_1PASS_SUPPORTED 338 master->quantizer_1pass = cinfo->cquantize;
340 ERREXIT(cinfo, JERR_NOT_COMPILED);
345 if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
346 #ifdef QUANT_2PASS_SUPPORTED 348 master->quantizer_2pass = cinfo->cquantize;
350 ERREXIT(cinfo, JERR_NOT_COMPILED);
359 if (! cinfo->raw_data_out) {
360 if (master->using_merged_upsample) {
361 #ifdef UPSAMPLE_MERGING_SUPPORTED 364 ERREXIT(cinfo, JERR_NOT_COMPILED);
375 if (cinfo->arith_code) {
376 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
378 if (cinfo->progressive_mode) {
379 #ifdef D_PROGRESSIVE_SUPPORTED 382 ERREXIT(cinfo, JERR_NOT_COMPILED);
389 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
392 if (! cinfo->raw_data_out)
396 (*cinfo->mem->realize_virt_arrays) ((
j_common_ptr) cinfo);
399 (*cinfo->inputctl->start_input_pass) (cinfo);
401 #ifdef D_MULTISCAN_FILES_SUPPORTED 406 if (cinfo->progress !=
NULL && ! cinfo->buffered_image &&
407 cinfo->inputctl->has_multiple_scans) {
410 if (cinfo->progressive_mode) {
412 nscans = 2 + 3 * cinfo->num_components;
415 nscans = cinfo->num_components;
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);
422 master->pass_number++;
442 if (master->pub.is_dummy_pass) {
443 #ifdef QUANT_2PASS_SUPPORTED 445 master->pub.is_dummy_pass =
FALSE;
446 (*cinfo->cquantize->start_pass) (cinfo,
FALSE);
450 ERREXIT(cinfo, JERR_NOT_COMPILED);
453 if (cinfo->quantize_colors && cinfo->colormap ==
NULL) {
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;
461 ERREXIT(cinfo, JERR_MODE_CHANGE);
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,
474 (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
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);
486 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
487 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
502 if (cinfo->quantize_colors)
503 (*cinfo->cquantize->finish_pass) (cinfo);
504 master->pass_number++;
508 #ifdef D_MULTISCAN_FILES_SUPPORTED 521 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
523 if (cinfo->quantize_colors && cinfo->enable_external_quant &&
524 cinfo->colormap !=
NULL) {
526 cinfo->cquantize = master->quantizer_2pass;
528 (*cinfo->cquantize->new_color_map) (cinfo);
529 master->pub.is_dummy_pass =
FALSE;
531 ERREXIT(cinfo, JERR_MODE_CHANGE);
549 SIZEOF(my_decomp_master));
554 master->pub.is_dummy_pass =
FALSE;
jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
JDIMENSION downsampled_width
my_comp_master * my_master_ptr
struct jpeg_common_struct * j_common_ptr
jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
#define ERREXIT(cinfo, code)
jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
jinit_upsampler(j_decompress_ptr cinfo)
jinit_color_deconverter(j_decompress_ptr cinfo)
jpeg_component_info * compptr
jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
#define MEMCOPY(dest, src, size)
prepare_range_limit_table(j_decompress_ptr cinfo)
finish_output_pass(j_decompress_ptr cinfo)
use_merged_upsample(j_decompress_ptr cinfo)
jinit_merged_upsampler(j_decompress_ptr cinfo)
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
jdiv_round_up(long a, long b)
jinit_phuff_decoder(j_decompress_ptr cinfo)
jinit_master_decompress(j_decompress_ptr cinfo)
jinit_1pass_quantizer(j_decompress_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
jpeg_new_colormap(j_decompress_ptr cinfo)
if(!abbox) return FT_THROW(Invalid_Argument)
master_selection(j_decompress_ptr cinfo)
my_decomp_master * my_master_ptr
jinit_inverse_dct(j_decompress_ptr cinfo)
prepare_for_output_pass(j_decompress_ptr cinfo)
GLenum GLsizei GLenum GLenum const GLvoid * table
jinit_2pass_quantizer(j_decompress_ptr cinfo)
#define MEMZERO(target, size)
JDIMENSION downsampled_height
jinit_huff_decoder(j_decompress_ptr cinfo)