Doxygen Source Code Documentation
jidctfst.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h"
Go to the source code of this file.
Defines | |
#define | JPEG_INTERNALS |
#define | CONST_BITS 8 |
#define | PASS1_BITS 2 |
#define | FIX_1_082392200 ((INT32) 277) |
#define | FIX_1_414213562 ((INT32) 362) |
#define | FIX_1_847759065 ((INT32) 473) |
#define | FIX_2_613125930 ((INT32) 669) |
#define | DESCALE(x, n) RIGHT_SHIFT(x, n) |
#define | MULTIPLY(var, const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) |
#define | DEQUANTIZE(coef, quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) |
#define | ISHIFT_TEMPS |
#define | IRIGHT_SHIFT(x, shft) ((x) >> (shft)) |
#define | IDESCALE(x, n) ((int) IRIGHT_SHIFT(x, n)) |
Functions | |
jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) |
Define Documentation
|
Definition at line 77 of file jidctfst.c. |
|
Definition at line 129 of file jidctfst.c. |
|
Definition at line 111 of file jidctfst.c. |
|
Definition at line 92 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 93 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 94 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 95 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 159 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 153 of file jidctfst.c. |
|
Definition at line 152 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
|
Definition at line 35 of file jidctfst.c. |
|
Definition at line 119 of file jidctfst.c. |
|
Definition at line 78 of file jidctfst.c. Referenced by jpeg_idct_ifast(). |
Function Documentation
|
Definition at line 168 of file jidctfst.c. References coef_block, compptr, jpeg_component_info::dct_table, DEQUANTIZE, FIX_1_082392200, FIX_1_414213562, FIX_1_847759065, FIX_2_613125930, IDCT_range_limit, IDESCALE, IFAST_MULT_TYPE, ISHIFT_TEMPS, JCOEFPTR, JDIMENSION, JSAMPARRAY, JSAMPLE, JSAMPROW, MULTIPLY, output_col, PASS1_BITS, and RANGE_MASK. Referenced by start_pass().
00171 { 00172 DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; 00173 DCTELEM tmp10, tmp11, tmp12, tmp13; 00174 DCTELEM z5, z10, z11, z12, z13; 00175 JCOEFPTR inptr; 00176 IFAST_MULT_TYPE * quantptr; 00177 int * wsptr; 00178 JSAMPROW outptr; 00179 JSAMPLE *range_limit = IDCT_range_limit(cinfo); 00180 int ctr; 00181 int workspace[DCTSIZE2]; /* buffers data between passes */ 00182 SHIFT_TEMPS /* for DESCALE */ 00183 ISHIFT_TEMPS /* for IDESCALE */ 00184 00185 /* Pass 1: process columns from input, store into work array. */ 00186 00187 inptr = coef_block; 00188 quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; 00189 wsptr = workspace; 00190 for (ctr = DCTSIZE; ctr > 0; ctr--) { 00191 /* Due to quantization, we will usually find that many of the input 00192 * coefficients are zero, especially the AC terms. We can exploit this 00193 * by short-circuiting the IDCT calculation for any column in which all 00194 * the AC terms are zero. In that case each output is equal to the 00195 * DC coefficient (with scale factor as needed). 00196 * With typical images and quantization tables, half or more of the 00197 * column DCT calculations can be simplified this way. 00198 */ 00199 00200 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && 00201 inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && 00202 inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && 00203 inptr[DCTSIZE*7] == 0) { 00204 /* AC terms all zero */ 00205 int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); 00206 00207 wsptr[DCTSIZE*0] = dcval; 00208 wsptr[DCTSIZE*1] = dcval; 00209 wsptr[DCTSIZE*2] = dcval; 00210 wsptr[DCTSIZE*3] = dcval; 00211 wsptr[DCTSIZE*4] = dcval; 00212 wsptr[DCTSIZE*5] = dcval; 00213 wsptr[DCTSIZE*6] = dcval; 00214 wsptr[DCTSIZE*7] = dcval; 00215 00216 inptr++; /* advance pointers to next column */ 00217 quantptr++; 00218 wsptr++; 00219 continue; 00220 } 00221 00222 /* Even part */ 00223 00224 tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); 00225 tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); 00226 tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); 00227 tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); 00228 00229 tmp10 = tmp0 + tmp2; /* phase 3 */ 00230 tmp11 = tmp0 - tmp2; 00231 00232 tmp13 = tmp1 + tmp3; /* phases 5-3 */ 00233 tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ 00234 00235 tmp0 = tmp10 + tmp13; /* phase 2 */ 00236 tmp3 = tmp10 - tmp13; 00237 tmp1 = tmp11 + tmp12; 00238 tmp2 = tmp11 - tmp12; 00239 00240 /* Odd part */ 00241 00242 tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); 00243 tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); 00244 tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); 00245 tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); 00246 00247 z13 = tmp6 + tmp5; /* phase 6 */ 00248 z10 = tmp6 - tmp5; 00249 z11 = tmp4 + tmp7; 00250 z12 = tmp4 - tmp7; 00251 00252 tmp7 = z11 + z13; /* phase 5 */ 00253 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ 00254 00255 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ 00256 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ 00257 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ 00258 00259 tmp6 = tmp12 - tmp7; /* phase 2 */ 00260 tmp5 = tmp11 - tmp6; 00261 tmp4 = tmp10 + tmp5; 00262 00263 wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); 00264 wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); 00265 wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); 00266 wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); 00267 wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); 00268 wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); 00269 wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); 00270 wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); 00271 00272 inptr++; /* advance pointers to next column */ 00273 quantptr++; 00274 wsptr++; 00275 } 00276 00277 /* Pass 2: process rows from work array, store into output array. */ 00278 /* Note that we must descale the results by a factor of 8 == 2**3, */ 00279 /* and also undo the PASS1_BITS scaling. */ 00280 00281 wsptr = workspace; 00282 for (ctr = 0; ctr < DCTSIZE; ctr++) { 00283 outptr = output_buf[ctr] + output_col; 00284 /* Rows of zeroes can be exploited in the same way as we did with columns. 00285 * However, the column calculation has created many nonzero AC terms, so 00286 * the simplification applies less often (typically 5% to 10% of the time). 00287 * On machines with very fast multiplication, it's possible that the 00288 * test takes more time than it's worth. In that case this section 00289 * may be commented out. 00290 */ 00291 00292 #ifndef NO_ZERO_ROW_TEST 00293 if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && 00294 wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { 00295 /* AC terms all zero */ 00296 JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) 00297 & RANGE_MASK]; 00298 00299 outptr[0] = dcval; 00300 outptr[1] = dcval; 00301 outptr[2] = dcval; 00302 outptr[3] = dcval; 00303 outptr[4] = dcval; 00304 outptr[5] = dcval; 00305 outptr[6] = dcval; 00306 outptr[7] = dcval; 00307 00308 wsptr += DCTSIZE; /* advance pointer to next row */ 00309 continue; 00310 } 00311 #endif 00312 00313 /* Even part */ 00314 00315 tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); 00316 tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); 00317 00318 tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); 00319 tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) 00320 - tmp13; 00321 00322 tmp0 = tmp10 + tmp13; 00323 tmp3 = tmp10 - tmp13; 00324 tmp1 = tmp11 + tmp12; 00325 tmp2 = tmp11 - tmp12; 00326 00327 /* Odd part */ 00328 00329 z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; 00330 z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; 00331 z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; 00332 z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; 00333 00334 tmp7 = z11 + z13; /* phase 5 */ 00335 tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ 00336 00337 z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ 00338 tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ 00339 tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ 00340 00341 tmp6 = tmp12 - tmp7; /* phase 2 */ 00342 tmp5 = tmp11 - tmp6; 00343 tmp4 = tmp10 + tmp5; 00344 00345 /* Final output stage: scale down by a factor of 8 and range-limit */ 00346 00347 outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) 00348 & RANGE_MASK]; 00349 outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) 00350 & RANGE_MASK]; 00351 outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) 00352 & RANGE_MASK]; 00353 outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) 00354 & RANGE_MASK]; 00355 outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) 00356 & RANGE_MASK]; 00357 outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) 00358 & RANGE_MASK]; 00359 outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) 00360 & RANGE_MASK]; 00361 outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) 00362 & RANGE_MASK]; 00363 00364 wsptr += DCTSIZE; /* advance pointer to next row */ 00365 } 00366 } |