Doxygen Source Code Documentation
jdmaster.c File Reference
#include "jinclude.h"#include "jpeglib.h"Go to the source code of this file.
Data Structures | |
| struct | my_decomp_master |
Defines | |
| #define | JPEG_INTERNALS |
Typedefs | |
| typedef my_decomp_master * | my_master_ptr |
Functions | |
| use_merged_upsample (j_decompress_ptr cinfo) | |
| jpeg_calc_output_dimensions (j_decompress_ptr cinfo) | |
| prepare_range_limit_table (j_decompress_ptr cinfo) | |
| master_selection (j_decompress_ptr cinfo) | |
| prepare_for_output_pass (j_decompress_ptr cinfo) | |
| finish_output_pass (j_decompress_ptr cinfo) | |
| jpeg_new_colormap (j_decompress_ptr cinfo) | |
| jinit_master_decompress (j_decompress_ptr cinfo) | |
Define Documentation
|
|
Definition at line 14 of file jdmaster.c. |
Typedef Documentation
|
|
Definition at line 35 of file jdmaster.c. |
Function Documentation
|
|
Definition at line 498 of file jdmaster.c. References jpeg_decompress_struct::cquantize, jpeg_decompress_struct::master, my_decomp_master::pass_number, and jpeg_decompress_struct::quantize_colors. Referenced by jinit_master_decompress().
00499 {
00500 my_master_ptr master = (my_master_ptr) cinfo->master;
00501
00502 if (cinfo->quantize_colors)
00503 (*cinfo->cquantize->finish_pass) (cinfo);
00504 master->pass_number++;
00505 }
|
|
|
Definition at line 543 of file jdmaster.c. References finish_output_pass(), jpeg_decomp_master::is_dummy_pass, JPOOL_IMAGE, master_selection(), prepare_for_output_pass(), and SIZEOF. Referenced by jpeg_start_decompress().
00544 {
00545 my_master_ptr master;
00546
00547 master = (my_master_ptr)
00548 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00549 SIZEOF(my_decomp_master));
00550 cinfo->master = (struct jpeg_decomp_master *) master;
00551 master->pub.prepare_for_output_pass = prepare_for_output_pass;
00552 master->pub.finish_output_pass = finish_output_pass;
00553
00554 master->pub.is_dummy_pass = FALSE;
00555
00556 master_selection(cinfo);
00557 }
|
|
|
Definition at line 84 of file jdmaster.c. References jpeg_decompress_struct::comp_info, compptr, jpeg_component_info::DCT_scaled_size, jpeg_component_info::downsampled_height, jpeg_component_info::downsampled_width, DSTATE_READY, ERREXIT1, jpeg_component_info::h_samp_factor, jpeg_decompress_struct::image_height, jpeg_decompress_struct::image_width, JCS_CMYK, JCS_GRAYSCALE, JCS_RGB, JCS_YCbCr, JCS_YCCK, jdiv_round_up(), L, jpeg_decompress_struct::max_h_samp_factor, jpeg_decompress_struct::max_v_samp_factor, jpeg_decompress_struct::min_DCT_scaled_size, jpeg_decompress_struct::num_components, jpeg_decompress_struct::out_color_components, jpeg_decompress_struct::out_color_space, jpeg_decompress_struct::output_components, jpeg_decompress_struct::output_height, jpeg_decompress_struct::output_width, jpeg_decompress_struct::quantize_colors, jpeg_decompress_struct::rec_outbuf_height, jpeg_decompress_struct::scale_denom, jpeg_decompress_struct::scale_num, use_merged_upsample(), and jpeg_component_info::v_samp_factor. Referenced by master_selection().
00086 {
00087 #ifdef IDCT_SCALING_SUPPORTED
00088 int ci;
00089 jpeg_component_info *compptr;
00090 #endif
00091
00092 /* Prevent application from calling me at wrong times */
00093 if (cinfo->global_state != DSTATE_READY)
00094 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00095
00096 #ifdef IDCT_SCALING_SUPPORTED
00097
00098 /* Compute actual output image dimensions and DCT scaling choices. */
00099 if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
00100 /* Provide 1/8 scaling */
00101 cinfo->output_width = (JDIMENSION)
00102 jdiv_round_up((long) cinfo->image_width, 8L);
00103 cinfo->output_height = (JDIMENSION)
00104 jdiv_round_up((long) cinfo->image_height, 8L);
00105 cinfo->min_DCT_scaled_size = 1;
00106 } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
00107 /* Provide 1/4 scaling */
00108 cinfo->output_width = (JDIMENSION)
00109 jdiv_round_up((long) cinfo->image_width, 4L);
00110 cinfo->output_height = (JDIMENSION)
00111 jdiv_round_up((long) cinfo->image_height, 4L);
00112 cinfo->min_DCT_scaled_size = 2;
00113 } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
00114 /* Provide 1/2 scaling */
00115 cinfo->output_width = (JDIMENSION)
00116 jdiv_round_up((long) cinfo->image_width, 2L);
00117 cinfo->output_height = (JDIMENSION)
00118 jdiv_round_up((long) cinfo->image_height, 2L);
00119 cinfo->min_DCT_scaled_size = 4;
00120 } else {
00121 /* Provide 1/1 scaling */
00122 cinfo->output_width = cinfo->image_width;
00123 cinfo->output_height = cinfo->image_height;
00124 cinfo->min_DCT_scaled_size = DCTSIZE;
00125 }
00126 /* In selecting the actual DCT scaling for each component, we try to
00127 * scale up the chroma components via IDCT scaling rather than upsampling.
00128 * This saves time if the upsampler gets to use 1:1 scaling.
00129 * Note this code assumes that the supported DCT scalings are powers of 2.
00130 */
00131 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00132 ci++, compptr++) {
00133 int ssize = cinfo->min_DCT_scaled_size;
00134 while (ssize < DCTSIZE &&
00135 (compptr->h_samp_factor * ssize * 2 <=
00136 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
00137 (compptr->v_samp_factor * ssize * 2 <=
00138 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
00139 ssize = ssize * 2;
00140 }
00141 compptr->DCT_scaled_size = ssize;
00142 }
00143
00144 /* Recompute downsampled dimensions of components;
00145 * application needs to know these if using raw downsampled data.
00146 */
00147 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00148 ci++, compptr++) {
00149 /* Size in samples, after IDCT scaling */
00150 compptr->downsampled_width = (JDIMENSION)
00151 jdiv_round_up((long) cinfo->image_width *
00152 (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
00153 (long) (cinfo->max_h_samp_factor * DCTSIZE));
00154 compptr->downsampled_height = (JDIMENSION)
00155 jdiv_round_up((long) cinfo->image_height *
00156 (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
00157 (long) (cinfo->max_v_samp_factor * DCTSIZE));
00158 }
00159
00160 #else /* !IDCT_SCALING_SUPPORTED */
00161
00162 /* Hardwire it to "no scaling" */
00163 cinfo->output_width = cinfo->image_width;
00164 cinfo->output_height = cinfo->image_height;
00165 /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
00166 * and has computed unscaled downsampled_width and downsampled_height.
00167 */
00168
00169 #endif /* IDCT_SCALING_SUPPORTED */
00170
00171 /* Report number of components in selected colorspace. */
00172 /* Probably this should be in the color conversion module... */
00173 switch (cinfo->out_color_space) {
00174 case JCS_GRAYSCALE:
00175 cinfo->out_color_components = 1;
00176 break;
00177 case JCS_RGB:
00178 #if RGB_PIXELSIZE != 3
00179 cinfo->out_color_components = RGB_PIXELSIZE;
00180 break;
00181 #endif /* else share code with YCbCr */
00182 case JCS_YCbCr:
00183 cinfo->out_color_components = 3;
00184 break;
00185 case JCS_CMYK:
00186 case JCS_YCCK:
00187 cinfo->out_color_components = 4;
00188 break;
00189 default: /* else must be same colorspace as in file */
00190 cinfo->out_color_components = cinfo->num_components;
00191 break;
00192 }
00193 cinfo->output_components = (cinfo->quantize_colors ? 1 :
00194 cinfo->out_color_components);
00195
00196 /* See if upsampler will want to emit more than one row at a time */
00197 if (use_merged_upsample(cinfo))
00198 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
00199 else
00200 cinfo->rec_outbuf_height = 1;
00201 }
|
|
|
Definition at line 515 of file jdmaster.c. References jpeg_decompress_struct::colormap, jpeg_decompress_struct::cquantize, DSTATE_BUFIMAGE, jpeg_decompress_struct::enable_external_quant, ERREXIT, ERREXIT1, jpeg_decomp_master::is_dummy_pass, jpeg_decompress_struct::master, my_decomp_master::pub, jpeg_decompress_struct::quantize_colors, and my_decomp_master::quantizer_2pass.
00516 {
00517 my_master_ptr master = (my_master_ptr) cinfo->master;
00518
00519 /* Prevent application from calling me at wrong times */
00520 if (cinfo->global_state != DSTATE_BUFIMAGE)
00521 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00522
00523 if (cinfo->quantize_colors && cinfo->enable_external_quant &&
00524 cinfo->colormap != NULL) {
00525 /* Select 2-pass quantizer for external colormap use */
00526 cinfo->cquantize = master->quantizer_2pass;
00527 /* Notify quantizer of colormap change */
00528 (*cinfo->cquantize->new_color_map) (cinfo);
00529 master->pub.is_dummy_pass = FALSE; /* just in case */
00530 } else
00531 ERREXIT(cinfo, JERR_MODE_CHANGE);
00532 }
|
|
|
Definition at line 288 of file jdmaster.c. References jpeg_decompress_struct::arith_code, jpeg_decompress_struct::buffered_image, jpeg_decompress_struct::colormap, jpeg_decompress_struct::cquantize, jpeg_decompress_struct::enable_1pass_quant, jpeg_decompress_struct::enable_2pass_quant, jpeg_decompress_struct::enable_external_quant, ERREXIT, jpeg_input_controller::has_multiple_scans, jpeg_decompress_struct::inputctl, JDIMENSION, JERR_ARITH_NOTIMPL, jinit_1pass_quantizer(), jinit_2pass_quantizer(), jinit_color_deconverter(), jinit_d_coef_controller(), jinit_d_main_controller(), jinit_d_post_controller(), jinit_huff_decoder(), jinit_inverse_dct(), jinit_merged_upsampler(), jinit_phuff_decoder(), jinit_upsampler(), jpeg_calc_output_dimensions(), L, jpeg_decompress_struct::master, jpeg_decompress_struct::num_components, jpeg_decompress_struct::out_color_components, jpeg_decompress_struct::output_width, my_decomp_master::pass_number, prepare_range_limit_table(), jpeg_decompress_struct::progressive_mode, jpeg_decompress_struct::quantize_colors, my_decomp_master::quantizer_1pass, my_decomp_master::quantizer_2pass, jpeg_decompress_struct::raw_data_out, jpeg_decompress_struct::total_iMCU_rows, jpeg_decompress_struct::two_pass_quantize, use_merged_upsample(), and my_decomp_master::using_merged_upsample. Referenced by jinit_master_decompress().
00289 {
00290 my_master_ptr master = (my_master_ptr) cinfo->master;
00291 boolean use_c_buffer;
00292 long samplesperrow;
00293 JDIMENSION jd_samplesperrow;
00294
00295 /* Initialize dimensions and other stuff */
00296 jpeg_calc_output_dimensions(cinfo);
00297 prepare_range_limit_table(cinfo);
00298
00299 /* Width of an output scanline must be representable as JDIMENSION. */
00300 samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
00301 jd_samplesperrow = (JDIMENSION) samplesperrow;
00302 if ((long) jd_samplesperrow != samplesperrow)
00303 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
00304
00305 /* Initialize my private state */
00306 master->pass_number = 0;
00307 master->using_merged_upsample = use_merged_upsample(cinfo);
00308
00309 /* Color quantizer selection */
00310 master->quantizer_1pass = NULL;
00311 master->quantizer_2pass = NULL;
00312 /* No mode changes if not using buffered-image mode. */
00313 if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
00314 cinfo->enable_1pass_quant = FALSE;
00315 cinfo->enable_external_quant = FALSE;
00316 cinfo->enable_2pass_quant = FALSE;
00317 }
00318 if (cinfo->quantize_colors) {
00319 if (cinfo->raw_data_out)
00320 ERREXIT(cinfo, JERR_NOTIMPL);
00321 /* 2-pass quantizer only works in 3-component color space. */
00322 if (cinfo->out_color_components != 3) {
00323 cinfo->enable_1pass_quant = TRUE;
00324 cinfo->enable_external_quant = FALSE;
00325 cinfo->enable_2pass_quant = FALSE;
00326 cinfo->colormap = NULL;
00327 } else if (cinfo->colormap != NULL) {
00328 cinfo->enable_external_quant = TRUE;
00329 } else if (cinfo->two_pass_quantize) {
00330 cinfo->enable_2pass_quant = TRUE;
00331 } else {
00332 cinfo->enable_1pass_quant = TRUE;
00333 }
00334
00335 if (cinfo->enable_1pass_quant) {
00336 #ifdef QUANT_1PASS_SUPPORTED
00337 jinit_1pass_quantizer(cinfo);
00338 master->quantizer_1pass = cinfo->cquantize;
00339 #else
00340 ERREXIT(cinfo, JERR_NOT_COMPILED);
00341 #endif
00342 }
00343
00344 /* We use the 2-pass code to map to external colormaps. */
00345 if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
00346 #ifdef QUANT_2PASS_SUPPORTED
00347 jinit_2pass_quantizer(cinfo);
00348 master->quantizer_2pass = cinfo->cquantize;
00349 #else
00350 ERREXIT(cinfo, JERR_NOT_COMPILED);
00351 #endif
00352 }
00353 /* If both quantizers are initialized, the 2-pass one is left active;
00354 * this is necessary for starting with quantization to an external map.
00355 */
00356 }
00357
00358 /* Post-processing: in particular, color conversion first */
00359 if (! cinfo->raw_data_out) {
00360 if (master->using_merged_upsample) {
00361 #ifdef UPSAMPLE_MERGING_SUPPORTED
00362 jinit_merged_upsampler(cinfo); /* does color conversion too */
00363 #else
00364 ERREXIT(cinfo, JERR_NOT_COMPILED);
00365 #endif
00366 } else {
00367 jinit_color_deconverter(cinfo);
00368 jinit_upsampler(cinfo);
00369 }
00370 jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
00371 }
00372 /* Inverse DCT */
00373 jinit_inverse_dct(cinfo);
00374 /* Entropy decoding: either Huffman or arithmetic coding. */
00375 if (cinfo->arith_code) {
00376 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
00377 } else {
00378 if (cinfo->progressive_mode) {
00379 #ifdef D_PROGRESSIVE_SUPPORTED
00380 jinit_phuff_decoder(cinfo);
00381 #else
00382 ERREXIT(cinfo, JERR_NOT_COMPILED);
00383 #endif
00384 } else
00385 jinit_huff_decoder(cinfo);
00386 }
00387
00388 /* Initialize principal buffer controllers. */
00389 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
00390 jinit_d_coef_controller(cinfo, use_c_buffer);
00391
00392 if (! cinfo->raw_data_out)
00393 jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
00394
00395 /* We can now tell the memory manager to allocate virtual arrays. */
00396 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
00397
00398 /* Initialize input side of decompressor to consume first scan. */
00399 (*cinfo->inputctl->start_input_pass) (cinfo);
00400
00401 #ifdef D_MULTISCAN_FILES_SUPPORTED
00402 /* If jpeg_start_decompress will read the whole file, initialize
00403 * progress monitoring appropriately. The input step is counted
00404 * as one pass.
00405 */
00406 if (cinfo->progress != NULL && ! cinfo->buffered_image &&
00407 cinfo->inputctl->has_multiple_scans) {
00408 int nscans;
00409 /* Estimate number of scans to set pass_limit. */
00410 if (cinfo->progressive_mode) {
00411 /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
00412 nscans = 2 + 3 * cinfo->num_components;
00413 } else {
00414 /* For a nonprogressive multiscan file, estimate 1 scan per component. */
00415 nscans = cinfo->num_components;
00416 }
00417 cinfo->progress->pass_counter = 0L;
00418 cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
00419 cinfo->progress->completed_passes = 0;
00420 cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
00421 /* Count the input pass as done */
00422 master->pass_number++;
00423 }
00424 #endif /* D_MULTISCAN_FILES_SUPPORTED */
00425 }
|
|
|
Definition at line 438 of file jdmaster.c. References jpeg_decompress_struct::buffered_image, jpeg_decompress_struct::cconvert, jpeg_decompress_struct::coef, jpeg_decompress_struct::colormap, jpeg_decompress_struct::cquantize, jpeg_decompress_struct::enable_1pass_quant, jpeg_decompress_struct::enable_2pass_quant, jpeg_input_controller::eoi_reached, ERREXIT, jpeg_decompress_struct::idct, jpeg_decompress_struct::inputctl, jpeg_decomp_master::is_dummy_pass, JBUF_CRANK_DEST, JBUF_PASS_THRU, JBUF_SAVE_AND_PASS, jpeg_decompress_struct::main, jpeg_decompress_struct::master, my_decomp_master::pass_number, jpeg_decompress_struct::post, my_decomp_master::pub, jpeg_decompress_struct::quantize_colors, my_decomp_master::quantizer_1pass, my_decomp_master::quantizer_2pass, jpeg_decompress_struct::raw_data_out, jpeg_decompress_struct::two_pass_quantize, jpeg_decompress_struct::upsample, and my_decomp_master::using_merged_upsample. Referenced by jinit_master_decompress().
00439 {
00440 my_master_ptr master = (my_master_ptr) cinfo->master;
00441
00442 if (master->pub.is_dummy_pass) {
00443 #ifdef QUANT_2PASS_SUPPORTED
00444 /* Final pass of 2-pass quantization */
00445 master->pub.is_dummy_pass = FALSE;
00446 (*cinfo->cquantize->start_pass) (cinfo, FALSE);
00447 (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
00448 (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
00449 #else
00450 ERREXIT(cinfo, JERR_NOT_COMPILED);
00451 #endif /* QUANT_2PASS_SUPPORTED */
00452 } else {
00453 if (cinfo->quantize_colors && cinfo->colormap == NULL) {
00454 /* Select new quantization method */
00455 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
00456 cinfo->cquantize = master->quantizer_2pass;
00457 master->pub.is_dummy_pass = TRUE;
00458 } else if (cinfo->enable_1pass_quant) {
00459 cinfo->cquantize = master->quantizer_1pass;
00460 } else {
00461 ERREXIT(cinfo, JERR_MODE_CHANGE);
00462 }
00463 }
00464 (*cinfo->idct->start_pass) (cinfo);
00465 (*cinfo->coef->start_output_pass) (cinfo);
00466 if (! cinfo->raw_data_out) {
00467 if (! master->using_merged_upsample)
00468 (*cinfo->cconvert->start_pass) (cinfo);
00469 (*cinfo->upsample->start_pass) (cinfo);
00470 if (cinfo->quantize_colors)
00471 (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
00472 (*cinfo->post->start_pass) (cinfo,
00473 (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
00474 (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
00475 }
00476 }
00477
00478 /* Set up progress monitor's pass info if present */
00479 if (cinfo->progress != NULL) {
00480 cinfo->progress->completed_passes = master->pass_number;
00481 cinfo->progress->total_passes = master->pass_number +
00482 (master->pub.is_dummy_pass ? 2 : 1);
00483 /* In buffered-image mode, we assume one more output pass if EOI not
00484 * yet reached, but no more passes if EOI has been reached.
00485 */
00486 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
00487 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
00488 }
00489 }
00490 }
|
|
|
Definition at line 248 of file jdmaster.c. References CENTERJSAMPLE, i, JPOOL_IMAGE, JSAMPLE, MAXJSAMPLE, MEMCOPY, MEMZERO, and SIZEOF. Referenced by master_selection().
00250 {
00251 JSAMPLE * table;
00252 int i;
00253
00254 table = (JSAMPLE *)
00255 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00256 (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
00257 table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
00258 cinfo->sample_range_limit = table;
00259 /* First segment of "simple" table: limit[x] = 0 for x < 0 */
00260 MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
00261 /* Main part of "simple" table: limit[x] = x */
00262 for (i = 0; i <= MAXJSAMPLE; i++)
00263 table[i] = (JSAMPLE) i;
00264 table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
00265 /* End of simple table, rest of first half of post-IDCT table */
00266 for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
00267 table[i] = MAXJSAMPLE;
00268 /* Second half of post-IDCT table */
00269 MEMZERO(table + (2 * (MAXJSAMPLE+1)),
00270 (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
00271 MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
00272 cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
00273 }
|
|
|
Definition at line 44 of file jdmaster.c. References jpeg_decompress_struct::CCIR601_sampling, jpeg_decompress_struct::comp_info, jpeg_component_info::DCT_scaled_size, jpeg_decompress_struct::do_fancy_upsampling, jpeg_component_info::h_samp_factor, JCS_RGB, JCS_YCbCr, jpeg_decompress_struct::jpeg_color_space, jpeg_decompress_struct::min_DCT_scaled_size, jpeg_decompress_struct::num_components, jpeg_decompress_struct::out_color_components, jpeg_decompress_struct::out_color_space, and jpeg_component_info::v_samp_factor. Referenced by jpeg_calc_output_dimensions(), and master_selection().
00045 {
00046 #ifdef UPSAMPLE_MERGING_SUPPORTED
00047 /* Merging is the equivalent of plain box-filter upsampling */
00048 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
00049 return FALSE;
00050 /* jdmerge.c only supports YCC=>RGB color conversion */
00051 if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
00052 cinfo->out_color_space != JCS_RGB ||
00053 cinfo->out_color_components != RGB_PIXELSIZE)
00054 return FALSE;
00055 /* and it only handles 2h1v or 2h2v sampling ratios */
00056 if (cinfo->comp_info[0].h_samp_factor != 2 ||
00057 cinfo->comp_info[1].h_samp_factor != 1 ||
00058 cinfo->comp_info[2].h_samp_factor != 1 ||
00059 cinfo->comp_info[0].v_samp_factor > 2 ||
00060 cinfo->comp_info[1].v_samp_factor != 1 ||
00061 cinfo->comp_info[2].v_samp_factor != 1)
00062 return FALSE;
00063 /* furthermore, it doesn't work if we've scaled the IDCTs differently */
00064 if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
00065 cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
00066 cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
00067 return FALSE;
00068 /* ??? also need to test for upsample-time rescaling, when & if supported */
00069 return TRUE; /* by golly, it'll work... */
00070 #else
00071 return FALSE;
00072 #endif
00073 }
|