OLD | NEW |
1 /* | 1 /* |
2 * jdcoefct.c | 2 * jdcoefct.c |
3 * | 3 * |
4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
5 * Copyright (C) 1994-1997, Thomas G. Lane. | 5 * Copyright (C) 1994-1997, Thomas G. Lane. |
6 * libjpeg-turbo Modifications: | 6 * libjpeg-turbo Modifications: |
| 7 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
7 * Copyright (C) 2010, D. R. Commander. | 8 * Copyright (C) 2010, D. R. Commander. |
8 * For conditions of distribution and use, see the accompanying README file. | 9 * For conditions of distribution and use, see the accompanying README file. |
9 * | 10 * |
10 * This file contains the coefficient buffer controller for decompression. | 11 * This file contains the coefficient buffer controller for decompression. |
11 * This controller is the top level of the JPEG decompressor proper. | 12 * This controller is the top level of the JPEG decompressor proper. |
12 * The coefficient buffer lies between entropy decoding and inverse-DCT steps. | 13 * The coefficient buffer lies between entropy decoding and inverse-DCT steps. |
13 * | 14 * |
14 * In buffered-image mode, this controller is the interface between | 15 * In buffered-image mode, this controller is the interface between |
15 * input-oriented processing and output-oriented processing. | 16 * input-oriented processing and output-oriented processing. |
16 * Also, the input side (only) is used when reading a file for transcoding. | 17 * Also, the input side (only) is used when reading a file for transcoding. |
17 */ | 18 */ |
18 | 19 |
19 #define JPEG_INTERNALS | 20 #include "jdcoefct.h" |
20 #include "jinclude.h" | |
21 #include "jpeglib.h" | |
22 #include "jpegcomp.h" | 21 #include "jpegcomp.h" |
23 | 22 |
24 /* Block smoothing is only applicable for progressive JPEG, so: */ | |
25 #ifndef D_PROGRESSIVE_SUPPORTED | |
26 #undef BLOCK_SMOOTHING_SUPPORTED | |
27 #endif | |
28 | |
29 /* Private buffer controller object */ | |
30 | |
31 typedef struct { | |
32 struct jpeg_d_coef_controller pub; /* public fields */ | |
33 | |
34 /* These variables keep track of the current location of the input side. */ | |
35 /* cinfo->input_iMCU_row is also used for this. */ | |
36 JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ | |
37 int MCU_vert_offset; /* counts MCU rows within iMCU row */ | |
38 int MCU_rows_per_iMCU_row; /* number of such rows needed */ | |
39 | |
40 /* The output side's location is represented by cinfo->output_iMCU_row. */ | |
41 | |
42 /* In single-pass modes, it's sufficient to buffer just one MCU. | |
43 * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, | |
44 * and let the entropy decoder write into that workspace each time. | |
45 * (On 80x86, the workspace is FAR even though it's not really very big; | |
46 * this is to keep the module interfaces unchanged when a large coefficient | |
47 * buffer is necessary.) | |
48 * In multi-pass modes, this array points to the current MCU's blocks | |
49 * within the virtual arrays; it is used only by the input side. | |
50 */ | |
51 JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; | |
52 | |
53 /* Temporary workspace for one MCU */ | |
54 JCOEF * workspace; | |
55 | |
56 #ifdef D_MULTISCAN_FILES_SUPPORTED | |
57 /* In multi-pass modes, we need a virtual block array for each component. */ | |
58 jvirt_barray_ptr whole_image[MAX_COMPONENTS]; | |
59 #endif | |
60 | |
61 #ifdef BLOCK_SMOOTHING_SUPPORTED | |
62 /* When doing block smoothing, we latch coefficient Al values here */ | |
63 int * coef_bits_latch; | |
64 #define SAVED_COEFS 6 /* we save coef_bits[0..5] */ | |
65 #endif | |
66 } my_coef_controller; | |
67 | |
68 typedef my_coef_controller * my_coef_ptr; | |
69 | 23 |
70 /* Forward declarations */ | 24 /* Forward declarations */ |
71 METHODDEF(int) decompress_onepass | 25 METHODDEF(int) decompress_onepass |
72 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); | 26 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
73 #ifdef D_MULTISCAN_FILES_SUPPORTED | 27 #ifdef D_MULTISCAN_FILES_SUPPORTED |
74 METHODDEF(int) decompress_data | 28 METHODDEF(int) decompress_data |
75 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); | 29 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
76 #endif | 30 #endif |
77 #ifdef BLOCK_SMOOTHING_SUPPORTED | 31 #ifdef BLOCK_SMOOTHING_SUPPORTED |
78 LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); | 32 LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); |
79 METHODDEF(int) decompress_smooth_data | 33 METHODDEF(int) decompress_smooth_data |
80 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); | 34 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
81 #endif | 35 #endif |
82 | 36 |
83 | 37 |
84 LOCAL(void) | |
85 start_iMCU_row (j_decompress_ptr cinfo) | |
86 /* Reset within-iMCU-row counters for a new row (input side) */ | |
87 { | |
88 my_coef_ptr coef = (my_coef_ptr) cinfo->coef; | |
89 | |
90 /* In an interleaved scan, an MCU row is the same as an iMCU row. | |
91 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. | |
92 * But at the bottom of the image, process only what's left. | |
93 */ | |
94 if (cinfo->comps_in_scan > 1) { | |
95 coef->MCU_rows_per_iMCU_row = 1; | |
96 } else { | |
97 if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | |
98 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | |
99 else | |
100 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | |
101 } | |
102 | |
103 coef->MCU_ctr = 0; | |
104 coef->MCU_vert_offset = 0; | |
105 } | |
106 | |
107 | |
108 /* | 38 /* |
109 * Initialize for an input processing pass. | 39 * Initialize for an input processing pass. |
110 */ | 40 */ |
111 | 41 |
112 METHODDEF(void) | 42 METHODDEF(void) |
113 start_input_pass (j_decompress_ptr cinfo) | 43 start_input_pass (j_decompress_ptr cinfo) |
114 { | 44 { |
115 cinfo->input_iMCU_row = 0; | 45 cinfo->input_iMCU_row = 0; |
116 start_iMCU_row(cinfo); | 46 start_iMCU_row(cinfo); |
117 } | 47 } |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 coef->pub.consume_data = dummy_consume_data; | 671 coef->pub.consume_data = dummy_consume_data; |
742 coef->pub.decompress_data = decompress_onepass; | 672 coef->pub.decompress_data = decompress_onepass; |
743 coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ | 673 coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ |
744 } | 674 } |
745 | 675 |
746 /* Allocate the workspace buffer */ | 676 /* Allocate the workspace buffer */ |
747 coef->workspace = (JCOEF *) | 677 coef->workspace = (JCOEF *) |
748 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 678 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
749 SIZEOF(JCOEF) * DCTSIZE2); | 679 SIZEOF(JCOEF) * DCTSIZE2); |
750 } | 680 } |
OLD | NEW |