Doxygen Source Code Documentation
jidctflt.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 | DEQUANTIZE(coef, quantval) (((FAST_FLOAT) (coef)) * (quantval)) |
Functions | |
| jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) | |
Define Documentation
|
|
Definition at line 60 of file jidctflt.c. Referenced by jpeg_idct_1x1(), jpeg_idct_2x2(), jpeg_idct_4x4(), jpeg_idct_float(), jpeg_idct_ifast(), and jpeg_idct_islow(). |
|
|
Definition at line 39 of file jidctflt.c. |
Function Documentation
|
||||||||||||||||||||||||
|
Definition at line 68 of file jidctflt.c. References coef_block, compptr, jpeg_component_info::dct_table, DEQUANTIZE, DESCALE, FLOAT_MULT_TYPE, IDCT_range_limit, INT32, JCOEFPTR, JDIMENSION, JSAMPARRAY, JSAMPLE, JSAMPROW, output_col, and RANGE_MASK. Referenced by start_pass().
00071 {
00072 FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00073 FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
00074 FAST_FLOAT z5, z10, z11, z12, z13;
00075 JCOEFPTR inptr;
00076 FLOAT_MULT_TYPE * quantptr;
00077 FAST_FLOAT * wsptr;
00078 JSAMPROW outptr;
00079 JSAMPLE *range_limit = IDCT_range_limit(cinfo);
00080 int ctr;
00081 FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
00082 SHIFT_TEMPS
00083
00084 /* Pass 1: process columns from input, store into work array. */
00085
00086 inptr = coef_block;
00087 quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;
00088 wsptr = workspace;
00089 for (ctr = DCTSIZE; ctr > 0; ctr--) {
00090 /* Due to quantization, we will usually find that many of the input
00091 * coefficients are zero, especially the AC terms. We can exploit this
00092 * by short-circuiting the IDCT calculation for any column in which all
00093 * the AC terms are zero. In that case each output is equal to the
00094 * DC coefficient (with scale factor as needed).
00095 * With typical images and quantization tables, half or more of the
00096 * column DCT calculations can be simplified this way.
00097 */
00098
00099 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
00100 inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
00101 inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
00102 inptr[DCTSIZE*7] == 0) {
00103 /* AC terms all zero */
00104 FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
00105
00106 wsptr[DCTSIZE*0] = dcval;
00107 wsptr[DCTSIZE*1] = dcval;
00108 wsptr[DCTSIZE*2] = dcval;
00109 wsptr[DCTSIZE*3] = dcval;
00110 wsptr[DCTSIZE*4] = dcval;
00111 wsptr[DCTSIZE*5] = dcval;
00112 wsptr[DCTSIZE*6] = dcval;
00113 wsptr[DCTSIZE*7] = dcval;
00114
00115 inptr++; /* advance pointers to next column */
00116 quantptr++;
00117 wsptr++;
00118 continue;
00119 }
00120
00121 /* Even part */
00122
00123 tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
00124 tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
00125 tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
00126 tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
00127
00128 tmp10 = tmp0 + tmp2; /* phase 3 */
00129 tmp11 = tmp0 - tmp2;
00130
00131 tmp13 = tmp1 + tmp3; /* phases 5-3 */
00132 tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
00133
00134 tmp0 = tmp10 + tmp13; /* phase 2 */
00135 tmp3 = tmp10 - tmp13;
00136 tmp1 = tmp11 + tmp12;
00137 tmp2 = tmp11 - tmp12;
00138
00139 /* Odd part */
00140
00141 tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
00142 tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
00143 tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
00144 tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
00145
00146 z13 = tmp6 + tmp5; /* phase 6 */
00147 z10 = tmp6 - tmp5;
00148 z11 = tmp4 + tmp7;
00149 z12 = tmp4 - tmp7;
00150
00151 tmp7 = z11 + z13; /* phase 5 */
00152 tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
00153
00154 z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
00155 tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */
00156 tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */
00157
00158 tmp6 = tmp12 - tmp7; /* phase 2 */
00159 tmp5 = tmp11 - tmp6;
00160 tmp4 = tmp10 + tmp5;
00161
00162 wsptr[DCTSIZE*0] = tmp0 + tmp7;
00163 wsptr[DCTSIZE*7] = tmp0 - tmp7;
00164 wsptr[DCTSIZE*1] = tmp1 + tmp6;
00165 wsptr[DCTSIZE*6] = tmp1 - tmp6;
00166 wsptr[DCTSIZE*2] = tmp2 + tmp5;
00167 wsptr[DCTSIZE*5] = tmp2 - tmp5;
00168 wsptr[DCTSIZE*4] = tmp3 + tmp4;
00169 wsptr[DCTSIZE*3] = tmp3 - tmp4;
00170
00171 inptr++; /* advance pointers to next column */
00172 quantptr++;
00173 wsptr++;
00174 }
00175
00176 /* Pass 2: process rows from work array, store into output array. */
00177 /* Note that we must descale the results by a factor of 8 == 2**3. */
00178
00179 wsptr = workspace;
00180 for (ctr = 0; ctr < DCTSIZE; ctr++) {
00181 outptr = output_buf[ctr] + output_col;
00182 /* Rows of zeroes can be exploited in the same way as we did with columns.
00183 * However, the column calculation has created many nonzero AC terms, so
00184 * the simplification applies less often (typically 5% to 10% of the time).
00185 * And testing floats for zero is relatively expensive, so we don't bother.
00186 */
00187
00188 /* Even part */
00189
00190 tmp10 = wsptr[0] + wsptr[4];
00191 tmp11 = wsptr[0] - wsptr[4];
00192
00193 tmp13 = wsptr[2] + wsptr[6];
00194 tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
00195
00196 tmp0 = tmp10 + tmp13;
00197 tmp3 = tmp10 - tmp13;
00198 tmp1 = tmp11 + tmp12;
00199 tmp2 = tmp11 - tmp12;
00200
00201 /* Odd part */
00202
00203 z13 = wsptr[5] + wsptr[3];
00204 z10 = wsptr[5] - wsptr[3];
00205 z11 = wsptr[1] + wsptr[7];
00206 z12 = wsptr[1] - wsptr[7];
00207
00208 tmp7 = z11 + z13;
00209 tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
00210
00211 z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
00212 tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */
00213 tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */
00214
00215 tmp6 = tmp12 - tmp7;
00216 tmp5 = tmp11 - tmp6;
00217 tmp4 = tmp10 + tmp5;
00218
00219 /* Final output stage: scale down by a factor of 8 and range-limit */
00220
00221 outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3)
00222 & RANGE_MASK];
00223 outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3)
00224 & RANGE_MASK];
00225 outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3)
00226 & RANGE_MASK];
00227 outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3)
00228 & RANGE_MASK];
00229 outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3)
00230 & RANGE_MASK];
00231 outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3)
00232 & RANGE_MASK];
00233 outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3)
00234 & RANGE_MASK];
00235 outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3)
00236 & RANGE_MASK];
00237
00238 wsptr += DCTSIZE; /* advance pointer to next row */
00239 }
00240 }
|