Doxygen Source Code Documentation
jddctmgr.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h"
Go to the source code of this file.
Data Structures | |
union | multiplier_table |
struct | my_idct_controller |
Defines | |
#define | JPEG_INTERNALS |
#define | PROVIDE_ISLOW_TABLES |
#define | CONST_BITS 14 |
Typedefs | |
typedef my_idct_controller * | my_idct_ptr |
Functions | |
start_pass (j_decompress_ptr cinfo) | |
jinit_inverse_dct (j_decompress_ptr cinfo) |
Define Documentation
|
|
|
Definition at line 18 of file jddctmgr.c. |
|
Definition at line 74 of file jddctmgr.c. |
Typedef Documentation
|
Definition at line 54 of file jddctmgr.c. |
Function Documentation
|
Definition at line 247 of file jddctmgr.c. References compptr, jpeg_component_info::dct_table, JPOOL_IMAGE, MEMZERO, SIZEOF, and start_pass(). Referenced by master_selection().
00248 { 00249 my_idct_ptr idct; 00250 int ci; 00251 jpeg_component_info *compptr; 00252 00253 idct = (my_idct_ptr) 00254 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00255 SIZEOF(my_idct_controller)); 00256 cinfo->idct = (struct jpeg_inverse_dct *) idct; 00257 idct->pub.start_pass = start_pass; 00258 00259 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00260 ci++, compptr++) { 00261 /* Allocate and pre-zero a multiplier table for each component */ 00262 compptr->dct_table = 00263 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00264 SIZEOF(multiplier_table)); 00265 MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); 00266 /* Mark multiplier table not yet set up for any method */ 00267 idct->cur_method[ci] = -1; 00268 } 00269 } |
|
Definition at line 89 of file jddctmgr.c. References jpeg_decompress_struct::comp_info, jpeg_component_info::component_needed, compptr, my_idct_controller::cur_method, jpeg_decompress_struct::dct_method, jpeg_component_info::DCT_scaled_size, jpeg_component_info::dct_table, DESCALE, ERREXIT, ERREXIT1, FLOAT_MULT_TYPE, i, jpeg_decompress_struct::idct, IFAST_MULT_TYPE, IFAST_SCALE_BITS, INT16, INT32, jpeg_inverse_dct::inverse_DCT, ISLOW_MULT_TYPE, JDCT_FLOAT, JDCT_IFAST, JDCT_ISLOW, jpeg_idct_1x1(), jpeg_idct_2x2(), jpeg_idct_4x4(), jpeg_idct_float(), jpeg_idct_ifast(), jpeg_idct_islow(), MULTIPLY16V16, jpeg_decompress_struct::num_components, my_idct_controller::pub, jpeg_component_info::quant_table, and JQUANT_TBL::quantval. Referenced by jinit_inverse_dct().
00090 { 00091 my_idct_ptr idct = (my_idct_ptr) cinfo->idct; 00092 int ci, i; 00093 jpeg_component_info *compptr; 00094 int method = 0; 00095 inverse_DCT_method_ptr method_ptr = NULL; 00096 JQUANT_TBL * qtbl; 00097 00098 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00099 ci++, compptr++) { 00100 /* Select the proper IDCT routine for this component's scaling */ 00101 switch (compptr->DCT_scaled_size) { 00102 #ifdef IDCT_SCALING_SUPPORTED 00103 case 1: 00104 method_ptr = jpeg_idct_1x1; 00105 method = JDCT_ISLOW; /* jidctred uses islow-style table */ 00106 break; 00107 case 2: 00108 method_ptr = jpeg_idct_2x2; 00109 method = JDCT_ISLOW; /* jidctred uses islow-style table */ 00110 break; 00111 case 4: 00112 method_ptr = jpeg_idct_4x4; 00113 method = JDCT_ISLOW; /* jidctred uses islow-style table */ 00114 break; 00115 #endif 00116 case DCTSIZE: 00117 switch (cinfo->dct_method) { 00118 #ifdef DCT_ISLOW_SUPPORTED 00119 case JDCT_ISLOW: 00120 method_ptr = jpeg_idct_islow; 00121 method = JDCT_ISLOW; 00122 break; 00123 #endif 00124 #ifdef DCT_IFAST_SUPPORTED 00125 case JDCT_IFAST: 00126 method_ptr = jpeg_idct_ifast; 00127 method = JDCT_IFAST; 00128 break; 00129 #endif 00130 #ifdef DCT_FLOAT_SUPPORTED 00131 case JDCT_FLOAT: 00132 method_ptr = jpeg_idct_float; 00133 method = JDCT_FLOAT; 00134 break; 00135 #endif 00136 default: 00137 ERREXIT(cinfo, JERR_NOT_COMPILED); 00138 break; 00139 } 00140 break; 00141 default: 00142 ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); 00143 break; 00144 } 00145 idct->pub.inverse_DCT[ci] = method_ptr; 00146 /* Create multiplier table from quant table. 00147 * However, we can skip this if the component is uninteresting 00148 * or if we already built the table. Also, if no quant table 00149 * has yet been saved for the component, we leave the 00150 * multiplier table all-zero; we'll be reading zeroes from the 00151 * coefficient controller's buffer anyway. 00152 */ 00153 if (! compptr->component_needed || idct->cur_method[ci] == method) 00154 continue; 00155 qtbl = compptr->quant_table; 00156 if (qtbl == NULL) /* happens if no data yet for component */ 00157 continue; 00158 idct->cur_method[ci] = method; 00159 switch (method) { 00160 #ifdef PROVIDE_ISLOW_TABLES 00161 case JDCT_ISLOW: 00162 { 00163 /* For LL&M IDCT method, multipliers are equal to raw quantization 00164 * coefficients, but are stored as ints to ensure access efficiency. 00165 */ 00166 ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; 00167 for (i = 0; i < DCTSIZE2; i++) { 00168 ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; 00169 } 00170 } 00171 break; 00172 #endif 00173 #ifdef DCT_IFAST_SUPPORTED 00174 case JDCT_IFAST: 00175 { 00176 /* For AA&N IDCT method, multipliers are equal to quantization 00177 * coefficients scaled by scalefactor[row]*scalefactor[col], where 00178 * scalefactor[0] = 1 00179 * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 00180 * For integer operation, the multiplier table is to be scaled by 00181 * IFAST_SCALE_BITS. 00182 */ 00183 IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; 00184 #define CONST_BITS 14 00185 static const INT16 aanscales[DCTSIZE2] = { 00186 /* precomputed values scaled up by 14 bits */ 00187 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 00188 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, 00189 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, 00190 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, 00191 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 00192 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, 00193 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, 00194 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 00195 }; 00196 SHIFT_TEMPS 00197 00198 for (i = 0; i < DCTSIZE2; i++) { 00199 ifmtbl[i] = (IFAST_MULT_TYPE) 00200 DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], 00201 (INT32) aanscales[i]), 00202 CONST_BITS-IFAST_SCALE_BITS); 00203 } 00204 } 00205 break; 00206 #endif 00207 #ifdef DCT_FLOAT_SUPPORTED 00208 case JDCT_FLOAT: 00209 { 00210 /* For float AA&N IDCT method, multipliers are equal to quantization 00211 * coefficients scaled by scalefactor[row]*scalefactor[col], where 00212 * scalefactor[0] = 1 00213 * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 00214 */ 00215 FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; 00216 int row, col; 00217 static const double aanscalefactor[DCTSIZE] = { 00218 1.0, 1.387039845, 1.306562965, 1.175875602, 00219 1.0, 0.785694958, 0.541196100, 0.275899379 00220 }; 00221 00222 i = 0; 00223 for (row = 0; row < DCTSIZE; row++) { 00224 for (col = 0; col < DCTSIZE; col++) { 00225 fmtbl[i] = (FLOAT_MULT_TYPE) 00226 ((double) qtbl->quantval[i] * 00227 aanscalefactor[row] * aanscalefactor[col]); 00228 i++; 00229 } 00230 } 00231 } 00232 break; 00233 #endif 00234 default: 00235 ERREXIT(cinfo, JERR_NOT_COMPILED); 00236 break; 00237 } 00238 } 00239 } |