#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jccoefct.c:

Go to the source code of this file.
Data Structures | |
| struct | my_coef_controller |
Defines | |
| #define | FULL_COEF_BUFFER_SUPPORTED |
| #define | JPEG_INTERNALS |
Typedefs | |
| typedef my_coef_controller * | my_coef_ptr |
Functions | |
| METHODDEF boolean | compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) |
| METHODDEF boolean | compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) |
| METHODDEF boolean | compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) |
| GLOBAL void | jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) |
| METHODDEF boolean compress_data | JPP ((j_compress_ptr cinfo, JSAMPIMAGE input_buf)) |
| LOCAL void | start_iMCU_row (j_compress_ptr cinfo) |
| METHODDEF void | start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) |
|
|
Definition at line 24 of file jccoefct.c. |
|
|
Definition at line 13 of file jccoefct.c. |
|
|
Definition at line 57 of file jccoefct.c. Referenced by compress_data(), compress_first_pass(), compress_output(), decompress_onepass(), jinit_c_coef_controller(), jinit_d_coef_controller(), start_iMCU_row(), start_output_pass(), start_pass_coef(), and transencode_coef_controller(). |
|
||||||||||||
|
Definition at line 143 of file jccoefct.c. References jpeg_compress_struct::coef, jpeg_compress_struct::comps_in_scan, jpeg_compress_struct::cur_comp_info, jpeg_compress_struct::entropy, FAR, jpeg_compress_struct::fdct, my_coef_controller::iMCU_row_num, j_compress_ptr, JBLOCK, JDIMENSION, jzero_far(), jpeg_component_info::last_col_width, jpeg_component_info::last_row_height, my_coef_controller::MCU_buffer, my_coef_controller::mcu_ctr, jpeg_component_info::MCU_height, my_coef_controller::MCU_rows_per_iMCU_row, jpeg_component_info::MCU_sample_width, my_coef_controller::MCU_vert_offset, jpeg_component_info::MCU_width, jpeg_compress_struct::MCUs_per_row, my_coef_ptr, SIZEOF, start_iMCU_row(), jpeg_compress_struct::total_iMCU_rows, and yoffset. 00144 {
00145 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00146 JDIMENSION MCU_col_num; /* index of current MCU within row */
00147 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
00148 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00149 int blkn, bi, ci, yindex, yoffset, blockcnt;
00150 JDIMENSION ypos, xpos;
00151 jpeg_component_info *compptr;
00152
00153 /* Loop to write as much as one whole iMCU row */
00154 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00155 yoffset++) {
00156 for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
00157 MCU_col_num++) {
00158 /* Determine where data comes from in input_buf and do the DCT thing.
00159 * Each call on forward_DCT processes a horizontal row of DCT blocks
00160 * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks
00161 * sequentially. Dummy blocks at the right or bottom edge are filled in
00162 * specially. The data in them does not matter for image reconstruction,
00163 * so we fill them with values that will encode to the smallest amount of
00164 * data, viz: all zeroes in the AC entries, DC entries equal to previous
00165 * block's DC value. (Thanks to Thomas Kinsman for this idea.)
00166 */
00167 blkn = 0;
00168 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00169 compptr = cinfo->cur_comp_info[ci];
00170 blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
00171 : compptr->last_col_width;
00172 xpos = MCU_col_num * compptr->MCU_sample_width;
00173 ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
00174 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00175 if (coef->iMCU_row_num < last_iMCU_row ||
00176 yoffset+yindex < compptr->last_row_height) {
00177 (*cinfo->fdct->forward_DCT) (cinfo, compptr,
00178 input_buf[ci], coef->MCU_buffer[blkn],
00179 ypos, xpos, (JDIMENSION) blockcnt);
00180 if (blockcnt < compptr->MCU_width) {
00181 /* Create some dummy blocks at the right edge of the image. */
00182 jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt],
00183 (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
00184 for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
00185 coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
00186 }
00187 }
00188 } else {
00189 /* Create a row of dummy blocks at the bottom of the image. */
00190 jzero_far((void FAR *) coef->MCU_buffer[blkn],
00191 compptr->MCU_width * SIZEOF(JBLOCK));
00192 for (bi = 0; bi < compptr->MCU_width; bi++) {
00193 coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
00194 }
00195 }
00196 blkn += compptr->MCU_width;
00197 ypos += DCTSIZE;
00198 }
00199 }
00200 /* Try to write the MCU. In event of a suspension failure, we will
00201 * re-DCT the MCU on restart (a bit inefficient, could be fixed...)
00202 */
00203 if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
00204 /* Suspension forced; update state counters and exit */
00205 coef->MCU_vert_offset = yoffset;
00206 coef->mcu_ctr = MCU_col_num;
00207 return FALSE;
00208 }
00209 }
00210 /* Completed an MCU row, but perhaps not an iMCU row */
00211 coef->mcu_ctr = 0;
00212 }
00213 /* Completed the iMCU row, advance counters for next one */
00214 coef->iMCU_row_num++;
00215 start_iMCU_row(cinfo);
00216 return TRUE;
00217 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 244 of file jccoefct.c. References buffer, jpeg_compress_struct::coef, jpeg_compress_struct::comp_info, compress_output(), FAR, jpeg_compress_struct::fdct, jpeg_component_info::h_samp_factor, jpeg_component_info::height_in_blocks, my_coef_controller::iMCU_row_num, j_common_ptr, j_compress_ptr, JBLOCK, JBLOCKARRAY, JBLOCKROW, JCOEF, JDIMENSION, jzero_far(), my_coef_ptr, jpeg_compress_struct::num_components, size_t, SIZEOF, jpeg_compress_struct::total_iMCU_rows, jpeg_component_info::v_samp_factor, my_coef_controller::whole_image, and jpeg_component_info::width_in_blocks. 00245 {
00246 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00247 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00248 JDIMENSION blocks_across, MCUs_across, MCUindex;
00249 int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
00250 JCOEF lastDC;
00251 jpeg_component_info *compptr;
00252 JBLOCKARRAY buffer;
00253 JBLOCKROW thisblockrow, lastblockrow;
00254
00255 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00256 ci++, compptr++) {
00257 /* Align the virtual buffer for this component. */
00258 buffer = (*cinfo->mem->access_virt_barray)
00259 ((j_common_ptr) cinfo, coef->whole_image[ci],
00260 coef->iMCU_row_num * compptr->v_samp_factor,
00261 (JDIMENSION) compptr->v_samp_factor, TRUE);
00262 /* Count non-dummy DCT block rows in this iMCU row. */
00263 if (coef->iMCU_row_num < last_iMCU_row)
00264 block_rows = compptr->v_samp_factor;
00265 else {
00266 /* NB: can't use last_row_height here, since may not be set! */
00267 block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00268 if (block_rows == 0) block_rows = compptr->v_samp_factor;
00269 }
00270 blocks_across = compptr->width_in_blocks;
00271 h_samp_factor = compptr->h_samp_factor;
00272 /* Count number of dummy blocks to be added at the right margin. */
00273 ndummy = (int) (blocks_across % h_samp_factor);
00274 if (ndummy > 0)
00275 ndummy = h_samp_factor - ndummy;
00276 /* Perform DCT for all non-dummy blocks in this iMCU row. Each call
00277 * on forward_DCT processes a complete horizontal row of DCT blocks.
00278 */
00279 for (block_row = 0; block_row < block_rows; block_row++) {
00280 thisblockrow = buffer[block_row];
00281 (*cinfo->fdct->forward_DCT) (cinfo, compptr,
00282 input_buf[ci], thisblockrow,
00283 (JDIMENSION) (block_row * DCTSIZE),
00284 (JDIMENSION) 0, blocks_across);
00285 if (ndummy > 0) {
00286 /* Create dummy blocks at the right edge of the image. */
00287 thisblockrow += blocks_across; /* => first dummy block */
00288 jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
00289 lastDC = thisblockrow[-1][0];
00290 for (bi = 0; bi < ndummy; bi++) {
00291 thisblockrow[bi][0] = lastDC;
00292 }
00293 }
00294 }
00295 /* If at end of image, create dummy block rows as needed.
00296 * The tricky part here is that within each MCU, we want the DC values
00297 * of the dummy blocks to match the last real block's DC value.
00298 * This squeezes a few more bytes out of the resulting file...
00299 */
00300 if (coef->iMCU_row_num == last_iMCU_row) {
00301 blocks_across += ndummy; /* include lower right corner */
00302 MCUs_across = blocks_across / h_samp_factor;
00303 for (block_row = block_rows; block_row < compptr->v_samp_factor;
00304 block_row++) {
00305 thisblockrow = buffer[block_row];
00306 lastblockrow = buffer[block_row-1];
00307 jzero_far((void FAR *) thisblockrow,
00308 (size_t) (blocks_across * SIZEOF(JBLOCK)));
00309 for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
00310 lastDC = lastblockrow[h_samp_factor-1][0];
00311 for (bi = 0; bi < h_samp_factor; bi++) {
00312 thisblockrow[bi][0] = lastDC;
00313 }
00314 thisblockrow += h_samp_factor; /* advance to next MCU in row */
00315 lastblockrow += h_samp_factor;
00316 }
00317 }
00318 }
00319 }
00320 /* NB: compress_output will increment iMCU_row_num if successful.
00321 * A suspension return will result in redoing all the work above next time.
00322 */
00323
00324 /* Emit data to the entropy encoder, sharing code with subsequent passes */
00325 return compress_output(cinfo, input_buf);
00326 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 340 of file jccoefct.c. References buffer, jpeg_compress_struct::coef, jpeg_component_info::component_index, jpeg_compress_struct::comps_in_scan, jpeg_compress_struct::cur_comp_info, jpeg_compress_struct::entropy, my_coef_controller::iMCU_row_num, j_common_ptr, j_compress_ptr, JBLOCKARRAY, JBLOCKROW, JDIMENSION, my_coef_controller::MCU_buffer, my_coef_controller::mcu_ctr, jpeg_component_info::MCU_height, my_coef_controller::MCU_rows_per_iMCU_row, my_coef_controller::MCU_vert_offset, jpeg_component_info::MCU_width, jpeg_compress_struct::MCUs_per_row, my_coef_ptr, start_iMCU_row(), jpeg_component_info::v_samp_factor, my_coef_controller::whole_image, and yoffset. 00341 {
00342 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00343 JDIMENSION MCU_col_num; /* index of current MCU within row */
00344 int blkn, ci, xindex, yindex, yoffset;
00345 JDIMENSION start_col;
00346 JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
00347 JBLOCKROW buffer_ptr;
00348 jpeg_component_info *compptr;
00349
00350 /* Align the virtual buffers for the components used in this scan.
00351 * NB: during first pass, this is safe only because the buffers will
00352 * already be aligned properly, so jmemmgr.c won't need to do any I/O.
00353 */
00354 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00355 compptr = cinfo->cur_comp_info[ci];
00356 buffer[ci] = (*cinfo->mem->access_virt_barray)
00357 ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
00358 coef->iMCU_row_num * compptr->v_samp_factor,
00359 (JDIMENSION) compptr->v_samp_factor, FALSE);
00360 }
00361
00362 /* Loop to process one whole iMCU row */
00363 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00364 yoffset++) {
00365 for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
00366 MCU_col_num++) {
00367 /* Construct list of pointers to DCT blocks belonging to this MCU */
00368 blkn = 0; /* index of current DCT block within MCU */
00369 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00370 compptr = cinfo->cur_comp_info[ci];
00371 start_col = MCU_col_num * compptr->MCU_width;
00372 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00373 buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
00374 for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
00375 coef->MCU_buffer[blkn++] = buffer_ptr++;
00376 }
00377 }
00378 }
00379 /* Try to write the MCU. */
00380 if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
00381 /* Suspension forced; update state counters and exit */
00382 coef->MCU_vert_offset = yoffset;
00383 coef->mcu_ctr = MCU_col_num;
00384 return FALSE;
00385 }
00386 }
00387 /* Completed an MCU row, but perhaps not an iMCU row */
00388 coef->mcu_ctr = 0;
00389 }
00390 /* Completed the iMCU row, advance counters for next one */
00391 coef->iMCU_row_num++;
00392 start_iMCU_row(cinfo);
00393 return TRUE;
00394 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 404 of file jccoefct.c. References buffer, C_MAX_BLOCKS_IN_MCU, jpeg_compress_struct::coef, jpeg_compress_struct::comp_info, ERREXIT, jpeg_component_info::h_samp_factor, jpeg_component_info::height_in_blocks, i, j_common_ptr, j_compress_ptr, JBLOCK, JBLOCKROW, JDIMENSION, JERR_BAD_BUFFER_MODE, jround_up(), my_coef_controller::MCU_buffer, my_coef_ptr, jpeg_compress_struct::num_components, my_coef_controller::pub, SIZEOF, jpeg_component_info::v_samp_factor, my_coef_controller::whole_image, and jpeg_component_info::width_in_blocks. Referenced by jinit_compress_master(). 00405 {
00406 my_coef_ptr coef;
00407
00408 coef = (my_coef_ptr)
00409 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00410 SIZEOF(my_coef_controller));
00411 cinfo->coef = (struct jpeg_c_coef_controller *) coef;
00412 coef->pub.start_pass = start_pass_coef;
00413
00414 /* Create the coefficient buffer. */
00415 if (need_full_buffer) {
00416 #ifdef FULL_COEF_BUFFER_SUPPORTED
00417 /* Allocate a full-image virtual array for each component, */
00418 /* padded to a multiple of samp_factor DCT blocks in each direction. */
00419 int ci;
00420 jpeg_component_info *compptr;
00421
00422 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00423 ci++, compptr++) {
00424 coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
00425 ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
00426 (JDIMENSION) jround_up((long) compptr->width_in_blocks,
00427 (long) compptr->h_samp_factor),
00428 (JDIMENSION) jround_up((long) compptr->height_in_blocks,
00429 (long) compptr->v_samp_factor),
00430 (JDIMENSION) compptr->v_samp_factor);
00431 }
00432 #else
00433 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00434 #endif
00435 } else {
00436 /* We only need a single-MCU buffer. */
00437 JBLOCKROW buffer;
00438 int i;
00439
00440 buffer = (JBLOCKROW)
00441 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00442 C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
00443 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
00444 coef->MCU_buffer[i] = buffer + i;
00445 }
00446 coef->whole_image[0] = NULL; /* flag for no virtual arrays */
00447 }
00448 }
|
Here is the call graph for this function:

|
|
|
|
|
||||||||||||
|
Definition at line 100 of file jccoefct.c. References jpeg_compress_struct::coef, ERREXIT, my_coef_controller::iMCU_row_num, j_compress_ptr, JBUF_CRANK_DEST, JBUF_PASS_THRU, JBUF_SAVE_AND_PASS, JERR_BAD_BUFFER_MODE, my_coef_ptr, my_coef_controller::pub, start_iMCU_row(), and my_coef_controller::whole_image. 00101 {
00102 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00103
00104 coef->iMCU_row_num = 0;
00105 start_iMCU_row(cinfo);
00106
00107 switch (pass_mode) {
00108 case JBUF_PASS_THRU:
00109 if (coef->whole_image[0] != NULL)
00110 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00111 coef->pub.compress_data = compress_data;
00112 break;
00113 #ifdef FULL_COEF_BUFFER_SUPPORTED
00114 case JBUF_SAVE_AND_PASS:
00115 if (coef->whole_image[0] == NULL)
00116 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00117 coef->pub.compress_data = compress_first_pass;
00118 break;
00119 case JBUF_CRANK_DEST:
00120 if (coef->whole_image[0] == NULL)
00121 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00122 coef->pub.compress_data = compress_output;
00123 break;
00124 #endif
00125 default:
00126 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
00127 break;
00128 }
00129 }
|
Here is the call graph for this function:

1.3.9.1