1 /*
2 * jdcoefct.c
3 *
4 * Copyright (C) 1994-1997, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This file contains the coefficient buffer controller for decompression.
9 * This controller is the top level of the JPEG decompressor proper.
10 * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
11 *
12 * In buffered-image mode, this controller is the interface between
13 * input-oriented processing and output-oriented processing.
14 * Also, the input side (only) is used when reading a file for transcoding.
15 */
16
17 #define JPEG_INTERNALS
18 #include "jinclude.h"
19 #include "jpeglib.h"
20
21 /* Block smoothing is only applicable for progressive JPEG, so: */
22 #ifndef D_PROGRESSIVE_SUPPORTED
23 #undef BLOCK_SMOOTHING_SUPPORTED
24 #endif
145
146 METHODDEF(int)
147 decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
148 {
149 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
150 JDIMENSION MCU_col_num; /* index of current MCU within row */
151 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
152 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
153 int blkn, ci, xindex, yindex, yoffset, useful_width;
154 JSAMPARRAY output_ptr;
155 JDIMENSION start_col, output_col;
156 jpeg_component_info *compptr;
157 inverse_DCT_method_ptr inverse_DCT;
158
159 /* Loop to process as much as one whole iMCU row */
160 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
161 yoffset++) {
162 for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
163 MCU_col_num++) {
164 /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
165 jzero_far((void FAR *) coef->MCU_buffer[0],
166 (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
167 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
168 /* Suspension forced; update state counters and exit */
169 coef->MCU_vert_offset = yoffset;
170 coef->MCU_ctr = MCU_col_num;
171 return JPEG_SUSPENDED;
172 }
173 /* Determine where data should go in output_buf and do the IDCT thing.
174 * We skip dummy blocks at the right and bottom edges (but blkn gets
175 * incremented past them!). Note the inner loop relies on having
176 * allocated the MCU_buffer[] blocks sequentially.
177 */
178 blkn = 0; /* index of current DCT block within MCU */
179 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
180 compptr = cinfo->cur_comp_info[ci];
181 /* Don't bother to IDCT an uninteresting component. */
182 if (! compptr->component_needed) {
183 blkn += compptr->MCU_blocks;
184 continue;
185 }
712 (long) compptr->v_samp_factor),
713 (JDIMENSION) access_rows);
714 }
715 coef->pub.consume_data = consume_data;
716 coef->pub.decompress_data = decompress_data;
717 coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
718 #else
719 ERREXIT(cinfo, JERR_NOT_COMPILED);
720 #endif
721 } else {
722 /* We only need a single-MCU buffer. */
723 JBLOCKROW buffer;
724 int i;
725
726 buffer = (JBLOCKROW)
727 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
728 D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
729 for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
730 coef->MCU_buffer[i] = buffer + i;
731 }
732 coef->pub.consume_data = dummy_consume_data;
733 coef->pub.decompress_data = decompress_onepass;
734 coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
735 }
736 }
|
1 /*
2 * jdcoefct.c
3 *
4 * Copyright (C) 1994-1997, Thomas G. Lane.
5 * Modified 2002-2011 by Guido Vollbeding.
6 * This file is part of the Independent JPEG Group's software.
7 * For conditions of distribution and use, see the accompanying README file.
8 *
9 * This file contains the coefficient buffer controller for decompression.
10 * This controller is the top level of the JPEG decompressor proper.
11 * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
12 *
13 * In buffered-image mode, this controller is the interface between
14 * input-oriented processing and output-oriented processing.
15 * Also, the input side (only) is used when reading a file for transcoding.
16 */
17
18 #define JPEG_INTERNALS
19 #include "jinclude.h"
20 #include "jpeglib.h"
21
22 /* Block smoothing is only applicable for progressive JPEG, so: */
23 #ifndef D_PROGRESSIVE_SUPPORTED
24 #undef BLOCK_SMOOTHING_SUPPORTED
25 #endif
146
147 METHODDEF(int)
148 decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
149 {
150 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
151 JDIMENSION MCU_col_num; /* index of current MCU within row */
152 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
153 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
154 int blkn, ci, xindex, yindex, yoffset, useful_width;
155 JSAMPARRAY output_ptr;
156 JDIMENSION start_col, output_col;
157 jpeg_component_info *compptr;
158 inverse_DCT_method_ptr inverse_DCT;
159
160 /* Loop to process as much as one whole iMCU row */
161 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
162 yoffset++) {
163 for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
164 MCU_col_num++) {
165 /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
166 if (cinfo->lim_Se) /* can bypass in DC only case */
167 FMEMZERO((void FAR *) coef->MCU_buffer[0],
168 (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
169 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
170 /* Suspension forced; update state counters and exit */
171 coef->MCU_vert_offset = yoffset;
172 coef->MCU_ctr = MCU_col_num;
173 return JPEG_SUSPENDED;
174 }
175 /* Determine where data should go in output_buf and do the IDCT thing.
176 * We skip dummy blocks at the right and bottom edges (but blkn gets
177 * incremented past them!). Note the inner loop relies on having
178 * allocated the MCU_buffer[] blocks sequentially.
179 */
180 blkn = 0; /* index of current DCT block within MCU */
181 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
182 compptr = cinfo->cur_comp_info[ci];
183 /* Don't bother to IDCT an uninteresting component. */
184 if (! compptr->component_needed) {
185 blkn += compptr->MCU_blocks;
186 continue;
187 }
714 (long) compptr->v_samp_factor),
715 (JDIMENSION) access_rows);
716 }
717 coef->pub.consume_data = consume_data;
718 coef->pub.decompress_data = decompress_data;
719 coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
720 #else
721 ERREXIT(cinfo, JERR_NOT_COMPILED);
722 #endif
723 } else {
724 /* We only need a single-MCU buffer. */
725 JBLOCKROW buffer;
726 int i;
727
728 buffer = (JBLOCKROW)
729 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
730 D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
731 for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
732 coef->MCU_buffer[i] = buffer + i;
733 }
734 if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */
735 FMEMZERO((void FAR *) buffer,
736 (size_t) (D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)));
737 coef->pub.consume_data = dummy_consume_data;
738 coef->pub.decompress_data = decompress_onepass;
739 coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
740 }
741 }
|