|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 /* 00002 * jdmainct.c 00003 * 00004 * Copyright (C) 1994-1996, Thomas G. Lane. 00005 * This file is part of the Independent JPEG Group's software. 00006 * For conditions of distribution and use, see the accompanying README file. 00007 * 00008 * This file contains the main buffer controller for decompression. 00009 * The main buffer lies between the JPEG decompressor proper and the 00010 * post-processor; it holds downsampled data in the JPEG colorspace. 00011 * 00012 * Note that this code is bypassed in raw-data mode, since the application 00013 * supplies the equivalent of the main buffer in that case. 00014 */ 00015 00016 #define JPEG_INTERNALS 00017 #include "jinclude.h" 00018 #include "jpeglib.h" 00019 00020 00021 /* 00022 * In the current system design, the main buffer need never be a full-image 00023 * buffer; any full-height buffers will be found inside the coefficient or 00024 * postprocessing controllers. Nonetheless, the main controller is not 00025 * trivial. Its responsibility is to provide context rows for upsampling/ 00026 * rescaling, and doing this in an efficient fashion is a bit tricky. 00027 * 00028 * Postprocessor input data is counted in "row groups". A row group 00029 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) 00030 * sample rows of each component. (We require DCT_scaled_size values to be 00031 * chosen such that these numbers are integers. In practice DCT_scaled_size 00032 * values will likely be powers of two, so we actually have the stronger 00033 * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) 00034 * Upsampling will typically produce max_v_samp_factor pixel rows from each 00035 * row group (times any additional scale factor that the upsampler is 00036 * applying). 00037 * 00038 * The coefficient controller will deliver data to us one iMCU row at a time; 00039 * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or 00040 * exactly min_DCT_scaled_size row groups. (This amount of data corresponds 00041 * to one row of MCUs when the image is fully interleaved.) Note that the 00042 * number of sample rows varies across components, but the number of row 00043 * groups does not. Some garbage sample rows may be included in the last iMCU 00044 * row at the bottom of the image. 00045 * 00046 * Depending on the vertical scaling algorithm used, the upsampler may need 00047 * access to the sample row(s) above and below its current input row group. 00048 * The upsampler is required to set need_context_rows TRUE at global selection 00049 * time if so. When need_context_rows is FALSE, this controller can simply 00050 * obtain one iMCU row at a time from the coefficient controller and dole it 00051 * out as row groups to the postprocessor. 00052 * 00053 * When need_context_rows is TRUE, this controller guarantees that the buffer 00054 * passed to postprocessing contains at least one row group's worth of samples 00055 * above and below the row group(s) being processed. Note that the context 00056 * rows "above" the first passed row group appear at negative row offsets in 00057 * the passed buffer. At the top and bottom of the image, the required 00058 * context rows are manufactured by duplicating the first or last real sample 00059 * row; this avoids having special cases in the upsampling inner loops. 00060 * 00061 * The amount of context is fixed at one row group just because that's a 00062 * convenient number for this controller to work with. The existing 00063 * upsamplers really only need one sample row of context. An upsampler 00064 * supporting arbitrary output rescaling might wish for more than one row 00065 * group of context when shrinking the image; tough, we don't handle that. 00066 * (This is justified by the assumption that downsizing will be handled mostly 00067 * by adjusting the DCT_scaled_size values, so that the actual scale factor at 00068 * the upsample step needn't be much less than one.) 00069 * 00070 * To provide the desired context, we have to retain the last two row groups 00071 * of one iMCU row while reading in the next iMCU row. (The last row group 00072 * can't be processed until we have another row group for its below-context, 00073 * and so we have to save the next-to-last group too for its above-context.) 00074 * We could do this most simply by copying data around in our buffer, but 00075 * that'd be very slow. We can avoid copying any data by creating a rather 00076 * strange pointer structure. Here's how it works. We allocate a workspace 00077 * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number 00078 * of row groups per iMCU row). We create two sets of redundant pointers to 00079 * the workspace. Labeling the physical row groups 0 to M+1, the synthesized 00080 * pointer lists look like this: 00081 * M+1 M-1 00082 * master pointer --> 0 master pointer --> 0 00083 * 1 1 00084 * ... ... 00085 * M-3 M-3 00086 * M-2 M 00087 * M-1 M+1 00088 * M M-2 00089 * M+1 M-1 00090 * 0 0 00091 * We read alternate iMCU rows using each master pointer; thus the last two 00092 * row groups of the previous iMCU row remain un-overwritten in the workspace. 00093 * The pointer lists are set up so that the required context rows appear to 00094 * be adjacent to the proper places when we pass the pointer lists to the 00095 * upsampler. 00096 * 00097 * The above pictures describe the normal state of the pointer lists. 00098 * At top and bottom of the image, we diddle the pointer lists to duplicate 00099 * the first or last sample row as necessary (this is cheaper than copying 00100 * sample rows around). 00101 * 00102 * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that 00103 * situation each iMCU row provides only one row group so the buffering logic 00104 * must be different (eg, we must read two iMCU rows before we can emit the 00105 * first row group). For now, we simply do not support providing context 00106 * rows when min_DCT_scaled_size is 1. That combination seems unlikely to 00107 * be worth providing --- if someone wants a 1/8th-size preview, they probably 00108 * want it quick and dirty, so a context-free upsampler is sufficient. 00109 */ 00110 00111 00112 /* Private buffer controller object */ 00113 00114 typedef struct { 00115 struct jpeg_d_main_controller pub; /* public fields */ 00116 00117 /* Pointer to allocated workspace (M or M+2 row groups). */ 00118 JSAMPARRAY buffer[MAX_COMPONENTS]; 00119 00120 boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ 00121 JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ 00122 00123 /* Remaining fields are only used in the context case. */ 00124 00125 /* These are the master pointers to the funny-order pointer lists. */ 00126 JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ 00127 00128 int whichptr; /* indicates which pointer set is now in use */ 00129 int context_state; /* process_data state machine status */ 00130 JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ 00131 JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ 00132 } my_main_controller; 00133 00134 typedef my_main_controller * my_main_ptr; 00135 00136 /* context_state values: */ 00137 #define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ 00138 #define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ 00139 #define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ 00140 00141 00142 /* Forward declarations */ 00143 METHODDEF(void) process_data_simple_main 00144 JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, 00145 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); 00146 METHODDEF(void) process_data_context_main 00147 JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, 00148 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); 00149 #ifdef QUANT_2PASS_SUPPORTED 00150 METHODDEF(void) process_data_crank_post 00151 JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, 00152 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); 00153 #endif 00154 00155 00156 LOCAL(void) 00157 alloc_funny_pointers (j_decompress_ptr cinfo) 00158 /* Allocate space for the funny pointer lists. 00159 * This is done only once, not once per pass. 00160 */ 00161 { 00162 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00163 int ci, rgroup; 00164 int M = cinfo->min_DCT_scaled_size; 00165 jpeg_component_info *compptr; 00166 JSAMPARRAY xbuf; 00167 00168 /* Get top-level space for component array pointers. 00169 * We alloc both arrays with one call to save a few cycles. 00170 */ 00171 jmain->xbuffer[0] = (JSAMPIMAGE) 00172 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00173 cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); 00174 jmain->xbuffer[1] = jmain->xbuffer[0] + cinfo->num_components; 00175 00176 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00177 ci++, compptr++) { 00178 rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / 00179 cinfo->min_DCT_scaled_size; /* height of a row group of component */ 00180 /* Get space for pointer lists --- M+4 row groups in each list. 00181 * We alloc both pointer lists with one call to save a few cycles. 00182 */ 00183 xbuf = (JSAMPARRAY) 00184 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00185 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); 00186 xbuf += rgroup; /* want one row group at negative offsets */ 00187 jmain->xbuffer[0][ci] = xbuf; 00188 xbuf += rgroup * (M + 4); 00189 jmain->xbuffer[1][ci] = xbuf; 00190 } 00191 } 00192 00193 00194 LOCAL(void) 00195 make_funny_pointers (j_decompress_ptr cinfo) 00196 /* Create the funny pointer lists discussed in the comments above. 00197 * The actual workspace is already allocated (in jmain->buffer), 00198 * and the space for the pointer lists is allocated too. 00199 * This routine just fills in the curiously ordered lists. 00200 * This will be repeated at the beginning of each pass. 00201 */ 00202 { 00203 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00204 int ci, i, rgroup; 00205 int M = cinfo->min_DCT_scaled_size; 00206 jpeg_component_info *compptr; 00207 JSAMPARRAY buf, xbuf0, xbuf1; 00208 00209 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00210 ci++, compptr++) { 00211 rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / 00212 cinfo->min_DCT_scaled_size; /* height of a row group of component */ 00213 xbuf0 = jmain->xbuffer[0][ci]; 00214 xbuf1 = jmain->xbuffer[1][ci]; 00215 /* First copy the workspace pointers as-is */ 00216 buf = jmain->buffer[ci]; 00217 for (i = 0; i < rgroup * (M + 2); i++) { 00218 xbuf0[i] = xbuf1[i] = buf[i]; 00219 } 00220 /* In the second list, put the last four row groups in swapped order */ 00221 for (i = 0; i < rgroup * 2; i++) { 00222 xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; 00223 xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; 00224 } 00225 /* The wraparound pointers at top and bottom will be filled later 00226 * (see set_wraparound_pointers, below). Initially we want the "above" 00227 * pointers to duplicate the first actual data line. This only needs 00228 * to happen in xbuffer[0]. 00229 */ 00230 for (i = 0; i < rgroup; i++) { 00231 xbuf0[i - rgroup] = xbuf0[0]; 00232 } 00233 } 00234 } 00235 00236 00237 LOCAL(void) 00238 set_wraparound_pointers (j_decompress_ptr cinfo) 00239 /* Set up the "wraparound" pointers at top and bottom of the pointer lists. 00240 * This changes the pointer list state from top-of-image to the normal state. 00241 */ 00242 { 00243 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00244 int ci, i, rgroup; 00245 int M = cinfo->min_DCT_scaled_size; 00246 jpeg_component_info *compptr; 00247 JSAMPARRAY xbuf0, xbuf1; 00248 00249 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00250 ci++, compptr++) { 00251 rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / 00252 cinfo->min_DCT_scaled_size; /* height of a row group of component */ 00253 xbuf0 = jmain->xbuffer[0][ci]; 00254 xbuf1 = jmain->xbuffer[1][ci]; 00255 for (i = 0; i < rgroup; i++) { 00256 xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; 00257 xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; 00258 xbuf0[rgroup*(M+2) + i] = xbuf0[i]; 00259 xbuf1[rgroup*(M+2) + i] = xbuf1[i]; 00260 } 00261 } 00262 } 00263 00264 00265 LOCAL(void) 00266 set_bottom_pointers (j_decompress_ptr cinfo) 00267 /* Change the pointer lists to duplicate the last sample row at the bottom 00268 * of the image. whichptr indicates which xbuffer holds the final iMCU row. 00269 * Also sets rowgroups_avail to indicate number of nondummy row groups in row. 00270 */ 00271 { 00272 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00273 int ci, i, rgroup, iMCUheight, rows_left; 00274 jpeg_component_info *compptr; 00275 JSAMPARRAY xbuf; 00276 00277 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00278 ci++, compptr++) { 00279 /* Count sample rows in one iMCU row and in one row group */ 00280 iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; 00281 rgroup = iMCUheight / cinfo->min_DCT_scaled_size; 00282 /* Count nondummy sample rows remaining for this component */ 00283 rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); 00284 if (rows_left == 0) rows_left = iMCUheight; 00285 /* Count nondummy row groups. Should get same answer for each component, 00286 * so we need only do it once. 00287 */ 00288 if (ci == 0) { 00289 jmain->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); 00290 } 00291 /* Duplicate the last real sample row rgroup*2 times; this pads out the 00292 * last partial rowgroup and ensures at least one full rowgroup of context. 00293 */ 00294 xbuf = jmain->xbuffer[jmain->whichptr][ci]; 00295 for (i = 0; i < rgroup * 2; i++) { 00296 xbuf[rows_left + i] = xbuf[rows_left-1]; 00297 } 00298 } 00299 } 00300 00301 00302 /* 00303 * Initialize for a processing pass. 00304 */ 00305 00306 METHODDEF(void) 00307 start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) 00308 { 00309 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00310 00311 switch (pass_mode) { 00312 case JBUF_PASS_THRU: 00313 if (cinfo->upsample->need_context_rows) { 00314 jmain->pub.process_data = process_data_context_main; 00315 make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ 00316 jmain->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ 00317 jmain->context_state = CTX_PREPARE_FOR_IMCU; 00318 jmain->iMCU_row_ctr = 0; 00319 } else { 00320 /* Simple case with no context needed */ 00321 jmain->pub.process_data = process_data_simple_main; 00322 } 00323 jmain->buffer_full = FALSE; /* Mark buffer empty */ 00324 jmain->rowgroup_ctr = 0; 00325 break; 00326 #ifdef QUANT_2PASS_SUPPORTED 00327 case JBUF_CRANK_DEST: 00328 /* For last pass of 2-pass quantization, just crank the postprocessor */ 00329 jmain->pub.process_data = process_data_crank_post; 00330 break; 00331 #endif 00332 default: 00333 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); 00334 break; 00335 } 00336 } 00337 00338 00339 /* 00340 * Process some data. 00341 * This handles the simple case where no context is required. 00342 */ 00343 00344 METHODDEF(void) 00345 process_data_simple_main (j_decompress_ptr cinfo, 00346 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, 00347 JDIMENSION out_rows_avail) 00348 { 00349 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00350 JDIMENSION rowgroups_avail; 00351 00352 /* Read input data if we haven't filled the main buffer yet */ 00353 if (! jmain->buffer_full) { 00354 if (! (*cinfo->coef->decompress_data) (cinfo, jmain->buffer)) 00355 return; /* suspension forced, can do nothing more */ 00356 jmain->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ 00357 } 00358 00359 /* There are always min_DCT_scaled_size row groups in an iMCU row. */ 00360 rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; 00361 /* Note: at the bottom of the image, we may pass extra garbage row groups 00362 * to the postprocessor. The postprocessor has to check for bottom 00363 * of image anyway (at row resolution), so no point in us doing it too. 00364 */ 00365 00366 /* Feed the postprocessor */ 00367 (*cinfo->post->post_process_data) (cinfo, jmain->buffer, 00368 &jmain->rowgroup_ctr, rowgroups_avail, 00369 output_buf, out_row_ctr, out_rows_avail); 00370 00371 /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ 00372 if (jmain->rowgroup_ctr >= rowgroups_avail) { 00373 jmain->buffer_full = FALSE; 00374 jmain->rowgroup_ctr = 0; 00375 } 00376 } 00377 00378 00379 /* 00380 * Process some data. 00381 * This handles the case where context rows must be provided. 00382 */ 00383 00384 METHODDEF(void) 00385 process_data_context_main (j_decompress_ptr cinfo, 00386 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, 00387 JDIMENSION out_rows_avail) 00388 { 00389 my_main_ptr jmain = (my_main_ptr) cinfo->main; 00390 00391 /* Read input data if we haven't filled the main buffer yet */ 00392 if (! jmain->buffer_full) { 00393 if (! (*cinfo->coef->decompress_data) (cinfo, 00394 jmain->xbuffer[jmain->whichptr])) 00395 return; /* suspension forced, can do nothing more */ 00396 jmain->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ 00397 jmain->iMCU_row_ctr++; /* count rows received */ 00398 } 00399 00400 /* Postprocessor typically will not swallow all the input data it is handed 00401 * in one call (due to filling the output buffer first). Must be prepared 00402 * to exit and restart. This switch lets us keep track of how far we got. 00403 * Note that each case falls through to the next on successful completion. 00404 */ 00405 switch (jmain->context_state) { 00406 case CTX_POSTPONED_ROW: 00407 /* Call postprocessor using previously set pointers for postponed row */ 00408 (*cinfo->post->post_process_data) (cinfo, jmain->xbuffer[jmain->whichptr], 00409 &jmain->rowgroup_ctr, jmain->rowgroups_avail, 00410 output_buf, out_row_ctr, out_rows_avail); 00411 if (jmain->rowgroup_ctr < jmain->rowgroups_avail) 00412 return; /* Need to suspend */ 00413 jmain->context_state = CTX_PREPARE_FOR_IMCU; 00414 if (*out_row_ctr >= out_rows_avail) 00415 return; /* Postprocessor exactly filled output buf */ 00416 /*FALLTHROUGH*/ 00417 case CTX_PREPARE_FOR_IMCU: 00418 /* Prepare to process first M-1 row groups of this iMCU row */ 00419 jmain->rowgroup_ctr = 0; 00420 jmain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); 00421 /* Check for bottom of image: if so, tweak pointers to "duplicate" 00422 * the last sample row, and adjust rowgroups_avail to ignore padding rows. 00423 */ 00424 if (jmain->iMCU_row_ctr == cinfo->total_iMCU_rows) 00425 set_bottom_pointers(cinfo); 00426 jmain->context_state = CTX_PROCESS_IMCU; 00427 /*FALLTHROUGH*/ 00428 case CTX_PROCESS_IMCU: 00429 /* Call postprocessor using previously set pointers */ 00430 (*cinfo->post->post_process_data) (cinfo, jmain->xbuffer[jmain->whichptr], 00431 &jmain->rowgroup_ctr, jmain->rowgroups_avail, 00432 output_buf, out_row_ctr, out_rows_avail); 00433 if (jmain->rowgroup_ctr < jmain->rowgroups_avail) 00434 return; /* Need to suspend */ 00435 /* After the first iMCU, change wraparound pointers to normal state */ 00436 if (jmain->iMCU_row_ctr == 1) 00437 set_wraparound_pointers(cinfo); 00438 /* Prepare to load new iMCU row using other xbuffer list */ 00439 jmain->whichptr ^= 1; /* 0=>1 or 1=>0 */ 00440 jmain->buffer_full = FALSE; 00441 /* Still need to process last row group of this iMCU row, */ 00442 /* which is saved at index M+1 of the other xbuffer */ 00443 jmain->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); 00444 jmain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); 00445 jmain->context_state = CTX_POSTPONED_ROW; 00446 } 00447 } 00448 00449 00450 /* 00451 * Process some data. 00452 * Final pass of two-pass quantization: just call the postprocessor. 00453 * Source data will be the postprocessor controller's internal buffer. 00454 */ 00455 00456 #ifdef QUANT_2PASS_SUPPORTED 00457 00458 METHODDEF(void) 00459 process_data_crank_post (j_decompress_ptr cinfo, 00460 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, 00461 JDIMENSION out_rows_avail) 00462 { 00463 (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, 00464 (JDIMENSION *) NULL, (JDIMENSION) 0, 00465 output_buf, out_row_ctr, out_rows_avail); 00466 } 00467 00468 #endif /* QUANT_2PASS_SUPPORTED */ 00469 00470 00471 /* 00472 * Initialize main buffer controller. 00473 */ 00474 00475 GLOBAL(void) 00476 jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) 00477 { 00478 my_main_ptr jmain; 00479 int ci, rgroup, ngroups; 00480 jpeg_component_info *compptr; 00481 00482 jmain = (my_main_ptr) 00483 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00484 SIZEOF(my_main_controller)); 00485 cinfo->main = (struct jpeg_d_main_controller *) jmain; 00486 jmain->pub.start_pass = start_pass_main; 00487 00488 if (need_full_buffer) /* shouldn't happen */ 00489 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); 00490 00491 /* Allocate the workspace. 00492 * ngroups is the number of row groups we need. 00493 */ 00494 if (cinfo->upsample->need_context_rows) { 00495 if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ 00496 ERREXIT(cinfo, JERR_NOTIMPL); 00497 alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ 00498 ngroups = cinfo->min_DCT_scaled_size + 2; 00499 } else { 00500 ngroups = cinfo->min_DCT_scaled_size; 00501 } 00502 00503 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00504 ci++, compptr++) { 00505 rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / 00506 cinfo->min_DCT_scaled_size; /* height of a row group of component */ 00507 jmain->buffer[ci] = (*cinfo->mem->alloc_sarray) 00508 ((j_common_ptr) cinfo, JPOOL_IMAGE, 00509 compptr->width_in_blocks * compptr->DCT_scaled_size, 00510 (JDIMENSION) (rgroup * ngroups)); 00511 } 00512 }