Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * jidctint.c |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1991-1998, Thomas G. Lane. |
michael@0 | 5 | * Modification developed 2002-2009 by Guido Vollbeding. |
michael@0 | 6 | * This file is part of the Independent JPEG Group's software. |
michael@0 | 7 | * For conditions of distribution and use, see the accompanying README file. |
michael@0 | 8 | * |
michael@0 | 9 | * This file contains a slow-but-accurate integer implementation of the |
michael@0 | 10 | * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine |
michael@0 | 11 | * must also perform dequantization of the input coefficients. |
michael@0 | 12 | * |
michael@0 | 13 | * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT |
michael@0 | 14 | * on each row (or vice versa, but it's more convenient to emit a row at |
michael@0 | 15 | * a time). Direct algorithms are also available, but they are much more |
michael@0 | 16 | * complex and seem not to be any faster when reduced to code. |
michael@0 | 17 | * |
michael@0 | 18 | * This implementation is based on an algorithm described in |
michael@0 | 19 | * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT |
michael@0 | 20 | * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, |
michael@0 | 21 | * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. |
michael@0 | 22 | * The primary algorithm described there uses 11 multiplies and 29 adds. |
michael@0 | 23 | * We use their alternate method with 12 multiplies and 32 adds. |
michael@0 | 24 | * The advantage of this method is that no data path contains more than one |
michael@0 | 25 | * multiplication; this allows a very simple and accurate implementation in |
michael@0 | 26 | * scaled fixed-point arithmetic, with a minimal number of shifts. |
michael@0 | 27 | * |
michael@0 | 28 | * We also provide IDCT routines with various output sample block sizes for |
michael@0 | 29 | * direct resolution reduction or enlargement without additional resampling: |
michael@0 | 30 | * NxN (N=1...16) pixels for one 8x8 input DCT block. |
michael@0 | 31 | * |
michael@0 | 32 | * For N<8 we simply take the corresponding low-frequency coefficients of |
michael@0 | 33 | * the 8x8 input DCT block and apply an NxN point IDCT on the sub-block |
michael@0 | 34 | * to yield the downscaled outputs. |
michael@0 | 35 | * This can be seen as direct low-pass downsampling from the DCT domain |
michael@0 | 36 | * point of view rather than the usual spatial domain point of view, |
michael@0 | 37 | * yielding significant computational savings and results at least |
michael@0 | 38 | * as good as common bilinear (averaging) spatial downsampling. |
michael@0 | 39 | * |
michael@0 | 40 | * For N>8 we apply a partial NxN IDCT on the 8 input coefficients as |
michael@0 | 41 | * lower frequencies and higher frequencies assumed to be zero. |
michael@0 | 42 | * It turns out that the computational effort is similar to the 8x8 IDCT |
michael@0 | 43 | * regarding the output size. |
michael@0 | 44 | * Furthermore, the scaling and descaling is the same for all IDCT sizes. |
michael@0 | 45 | * |
michael@0 | 46 | * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases |
michael@0 | 47 | * since there would be too many additional constants to pre-calculate. |
michael@0 | 48 | */ |
michael@0 | 49 | |
michael@0 | 50 | #define JPEG_INTERNALS |
michael@0 | 51 | #include "jinclude.h" |
michael@0 | 52 | #include "jpeglib.h" |
michael@0 | 53 | #include "jdct.h" /* Private declarations for DCT subsystem */ |
michael@0 | 54 | |
michael@0 | 55 | #ifdef DCT_ISLOW_SUPPORTED |
michael@0 | 56 | |
michael@0 | 57 | |
michael@0 | 58 | /* |
michael@0 | 59 | * This module is specialized to the case DCTSIZE = 8. |
michael@0 | 60 | */ |
michael@0 | 61 | |
michael@0 | 62 | #if DCTSIZE != 8 |
michael@0 | 63 | Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ |
michael@0 | 64 | #endif |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | /* |
michael@0 | 68 | * The poop on this scaling stuff is as follows: |
michael@0 | 69 | * |
michael@0 | 70 | * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) |
michael@0 | 71 | * larger than the true IDCT outputs. The final outputs are therefore |
michael@0 | 72 | * a factor of N larger than desired; since N=8 this can be cured by |
michael@0 | 73 | * a simple right shift at the end of the algorithm. The advantage of |
michael@0 | 74 | * this arrangement is that we save two multiplications per 1-D IDCT, |
michael@0 | 75 | * because the y0 and y4 inputs need not be divided by sqrt(N). |
michael@0 | 76 | * |
michael@0 | 77 | * We have to do addition and subtraction of the integer inputs, which |
michael@0 | 78 | * is no problem, and multiplication by fractional constants, which is |
michael@0 | 79 | * a problem to do in integer arithmetic. We multiply all the constants |
michael@0 | 80 | * by CONST_SCALE and convert them to integer constants (thus retaining |
michael@0 | 81 | * CONST_BITS bits of precision in the constants). After doing a |
michael@0 | 82 | * multiplication we have to divide the product by CONST_SCALE, with proper |
michael@0 | 83 | * rounding, to produce the correct output. This division can be done |
michael@0 | 84 | * cheaply as a right shift of CONST_BITS bits. We postpone shifting |
michael@0 | 85 | * as long as possible so that partial sums can be added together with |
michael@0 | 86 | * full fractional precision. |
michael@0 | 87 | * |
michael@0 | 88 | * The outputs of the first pass are scaled up by PASS1_BITS bits so that |
michael@0 | 89 | * they are represented to better-than-integral precision. These outputs |
michael@0 | 90 | * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word |
michael@0 | 91 | * with the recommended scaling. (To scale up 12-bit sample data further, an |
michael@0 | 92 | * intermediate INT32 array would be needed.) |
michael@0 | 93 | * |
michael@0 | 94 | * To avoid overflow of the 32-bit intermediate results in pass 2, we must |
michael@0 | 95 | * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis |
michael@0 | 96 | * shows that the values given below are the most effective. |
michael@0 | 97 | */ |
michael@0 | 98 | |
michael@0 | 99 | #if BITS_IN_JSAMPLE == 8 |
michael@0 | 100 | #define CONST_BITS 13 |
michael@0 | 101 | #define PASS1_BITS 2 |
michael@0 | 102 | #else |
michael@0 | 103 | #define CONST_BITS 13 |
michael@0 | 104 | #define PASS1_BITS 1 /* lose a little precision to avoid overflow */ |
michael@0 | 105 | #endif |
michael@0 | 106 | |
michael@0 | 107 | /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus |
michael@0 | 108 | * causing a lot of useless floating-point operations at run time. |
michael@0 | 109 | * To get around this we use the following pre-calculated constants. |
michael@0 | 110 | * If you change CONST_BITS you may want to add appropriate values. |
michael@0 | 111 | * (With a reasonable C compiler, you can just rely on the FIX() macro...) |
michael@0 | 112 | */ |
michael@0 | 113 | |
michael@0 | 114 | #if CONST_BITS == 13 |
michael@0 | 115 | #define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ |
michael@0 | 116 | #define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ |
michael@0 | 117 | #define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ |
michael@0 | 118 | #define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ |
michael@0 | 119 | #define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ |
michael@0 | 120 | #define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ |
michael@0 | 121 | #define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ |
michael@0 | 122 | #define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ |
michael@0 | 123 | #define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ |
michael@0 | 124 | #define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ |
michael@0 | 125 | #define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ |
michael@0 | 126 | #define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ |
michael@0 | 127 | #else |
michael@0 | 128 | #define FIX_0_298631336 FIX(0.298631336) |
michael@0 | 129 | #define FIX_0_390180644 FIX(0.390180644) |
michael@0 | 130 | #define FIX_0_541196100 FIX(0.541196100) |
michael@0 | 131 | #define FIX_0_765366865 FIX(0.765366865) |
michael@0 | 132 | #define FIX_0_899976223 FIX(0.899976223) |
michael@0 | 133 | #define FIX_1_175875602 FIX(1.175875602) |
michael@0 | 134 | #define FIX_1_501321110 FIX(1.501321110) |
michael@0 | 135 | #define FIX_1_847759065 FIX(1.847759065) |
michael@0 | 136 | #define FIX_1_961570560 FIX(1.961570560) |
michael@0 | 137 | #define FIX_2_053119869 FIX(2.053119869) |
michael@0 | 138 | #define FIX_2_562915447 FIX(2.562915447) |
michael@0 | 139 | #define FIX_3_072711026 FIX(3.072711026) |
michael@0 | 140 | #endif |
michael@0 | 141 | |
michael@0 | 142 | |
michael@0 | 143 | /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. |
michael@0 | 144 | * For 8-bit samples with the recommended scaling, all the variable |
michael@0 | 145 | * and constant values involved are no more than 16 bits wide, so a |
michael@0 | 146 | * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. |
michael@0 | 147 | * For 12-bit samples, a full 32-bit multiplication will be needed. |
michael@0 | 148 | */ |
michael@0 | 149 | |
michael@0 | 150 | #if BITS_IN_JSAMPLE == 8 |
michael@0 | 151 | #define MULTIPLY(var,const) MULTIPLY16C16(var,const) |
michael@0 | 152 | #else |
michael@0 | 153 | #define MULTIPLY(var,const) ((var) * (const)) |
michael@0 | 154 | #endif |
michael@0 | 155 | |
michael@0 | 156 | |
michael@0 | 157 | /* Dequantize a coefficient by multiplying it by the multiplier-table |
michael@0 | 158 | * entry; produce an int result. In this module, both inputs and result |
michael@0 | 159 | * are 16 bits or less, so either int or short multiply will work. |
michael@0 | 160 | */ |
michael@0 | 161 | |
michael@0 | 162 | #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) |
michael@0 | 163 | |
michael@0 | 164 | |
michael@0 | 165 | /* |
michael@0 | 166 | * Perform dequantization and inverse DCT on one block of coefficients. |
michael@0 | 167 | */ |
michael@0 | 168 | |
michael@0 | 169 | GLOBAL(void) |
michael@0 | 170 | jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 171 | JCOEFPTR coef_block, |
michael@0 | 172 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 173 | { |
michael@0 | 174 | INT32 tmp0, tmp1, tmp2, tmp3; |
michael@0 | 175 | INT32 tmp10, tmp11, tmp12, tmp13; |
michael@0 | 176 | INT32 z1, z2, z3, z4, z5; |
michael@0 | 177 | JCOEFPTR inptr; |
michael@0 | 178 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 179 | int * wsptr; |
michael@0 | 180 | JSAMPROW outptr; |
michael@0 | 181 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 182 | int ctr; |
michael@0 | 183 | int workspace[DCTSIZE2]; /* buffers data between passes */ |
michael@0 | 184 | SHIFT_TEMPS |
michael@0 | 185 | |
michael@0 | 186 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 187 | /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ |
michael@0 | 188 | /* furthermore, we scale the results by 2**PASS1_BITS. */ |
michael@0 | 189 | |
michael@0 | 190 | inptr = coef_block; |
michael@0 | 191 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 192 | wsptr = workspace; |
michael@0 | 193 | for (ctr = DCTSIZE; ctr > 0; ctr--) { |
michael@0 | 194 | /* Due to quantization, we will usually find that many of the input |
michael@0 | 195 | * coefficients are zero, especially the AC terms. We can exploit this |
michael@0 | 196 | * by short-circuiting the IDCT calculation for any column in which all |
michael@0 | 197 | * the AC terms are zero. In that case each output is equal to the |
michael@0 | 198 | * DC coefficient (with scale factor as needed). |
michael@0 | 199 | * With typical images and quantization tables, half or more of the |
michael@0 | 200 | * column DCT calculations can be simplified this way. |
michael@0 | 201 | */ |
michael@0 | 202 | |
michael@0 | 203 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
michael@0 | 204 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
michael@0 | 205 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
michael@0 | 206 | inptr[DCTSIZE*7] == 0) { |
michael@0 | 207 | /* AC terms all zero */ |
michael@0 | 208 | int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; |
michael@0 | 209 | |
michael@0 | 210 | wsptr[DCTSIZE*0] = dcval; |
michael@0 | 211 | wsptr[DCTSIZE*1] = dcval; |
michael@0 | 212 | wsptr[DCTSIZE*2] = dcval; |
michael@0 | 213 | wsptr[DCTSIZE*3] = dcval; |
michael@0 | 214 | wsptr[DCTSIZE*4] = dcval; |
michael@0 | 215 | wsptr[DCTSIZE*5] = dcval; |
michael@0 | 216 | wsptr[DCTSIZE*6] = dcval; |
michael@0 | 217 | wsptr[DCTSIZE*7] = dcval; |
michael@0 | 218 | |
michael@0 | 219 | inptr++; /* advance pointers to next column */ |
michael@0 | 220 | quantptr++; |
michael@0 | 221 | wsptr++; |
michael@0 | 222 | continue; |
michael@0 | 223 | } |
michael@0 | 224 | |
michael@0 | 225 | /* Even part: reverse the even part of the forward DCT. */ |
michael@0 | 226 | /* The rotator is sqrt(2)*c(-6). */ |
michael@0 | 227 | |
michael@0 | 228 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 229 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 230 | |
michael@0 | 231 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
michael@0 | 232 | tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); |
michael@0 | 233 | tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); |
michael@0 | 234 | |
michael@0 | 235 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 236 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 237 | |
michael@0 | 238 | tmp0 = (z2 + z3) << CONST_BITS; |
michael@0 | 239 | tmp1 = (z2 - z3) << CONST_BITS; |
michael@0 | 240 | |
michael@0 | 241 | tmp10 = tmp0 + tmp3; |
michael@0 | 242 | tmp13 = tmp0 - tmp3; |
michael@0 | 243 | tmp11 = tmp1 + tmp2; |
michael@0 | 244 | tmp12 = tmp1 - tmp2; |
michael@0 | 245 | |
michael@0 | 246 | /* Odd part per figure 8; the matrix is unitary and hence its |
michael@0 | 247 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
michael@0 | 248 | */ |
michael@0 | 249 | |
michael@0 | 250 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 251 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 252 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 253 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 254 | |
michael@0 | 255 | z1 = tmp0 + tmp3; |
michael@0 | 256 | z2 = tmp1 + tmp2; |
michael@0 | 257 | z3 = tmp0 + tmp2; |
michael@0 | 258 | z4 = tmp1 + tmp3; |
michael@0 | 259 | z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ |
michael@0 | 260 | |
michael@0 | 261 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ |
michael@0 | 262 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ |
michael@0 | 263 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
michael@0 | 264 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ |
michael@0 | 265 | z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ |
michael@0 | 266 | z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ |
michael@0 | 267 | z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ |
michael@0 | 268 | z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ |
michael@0 | 269 | |
michael@0 | 270 | z3 += z5; |
michael@0 | 271 | z4 += z5; |
michael@0 | 272 | |
michael@0 | 273 | tmp0 += z1 + z3; |
michael@0 | 274 | tmp1 += z2 + z4; |
michael@0 | 275 | tmp2 += z2 + z3; |
michael@0 | 276 | tmp3 += z1 + z4; |
michael@0 | 277 | |
michael@0 | 278 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
michael@0 | 279 | |
michael@0 | 280 | wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 281 | wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 282 | wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 283 | wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 284 | wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 285 | wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 286 | wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 287 | wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 288 | |
michael@0 | 289 | inptr++; /* advance pointers to next column */ |
michael@0 | 290 | quantptr++; |
michael@0 | 291 | wsptr++; |
michael@0 | 292 | } |
michael@0 | 293 | |
michael@0 | 294 | /* Pass 2: process rows from work array, store into output array. */ |
michael@0 | 295 | /* Note that we must descale the results by a factor of 8 == 2**3, */ |
michael@0 | 296 | /* and also undo the PASS1_BITS scaling. */ |
michael@0 | 297 | |
michael@0 | 298 | wsptr = workspace; |
michael@0 | 299 | for (ctr = 0; ctr < DCTSIZE; ctr++) { |
michael@0 | 300 | outptr = output_buf[ctr] + output_col; |
michael@0 | 301 | /* Rows of zeroes can be exploited in the same way as we did with columns. |
michael@0 | 302 | * However, the column calculation has created many nonzero AC terms, so |
michael@0 | 303 | * the simplification applies less often (typically 5% to 10% of the time). |
michael@0 | 304 | * On machines with very fast multiplication, it's possible that the |
michael@0 | 305 | * test takes more time than it's worth. In that case this section |
michael@0 | 306 | * may be commented out. |
michael@0 | 307 | */ |
michael@0 | 308 | |
michael@0 | 309 | #ifndef NO_ZERO_ROW_TEST |
michael@0 | 310 | if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && |
michael@0 | 311 | wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { |
michael@0 | 312 | /* AC terms all zero */ |
michael@0 | 313 | JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) |
michael@0 | 314 | & RANGE_MASK]; |
michael@0 | 315 | |
michael@0 | 316 | outptr[0] = dcval; |
michael@0 | 317 | outptr[1] = dcval; |
michael@0 | 318 | outptr[2] = dcval; |
michael@0 | 319 | outptr[3] = dcval; |
michael@0 | 320 | outptr[4] = dcval; |
michael@0 | 321 | outptr[5] = dcval; |
michael@0 | 322 | outptr[6] = dcval; |
michael@0 | 323 | outptr[7] = dcval; |
michael@0 | 324 | |
michael@0 | 325 | wsptr += DCTSIZE; /* advance pointer to next row */ |
michael@0 | 326 | continue; |
michael@0 | 327 | } |
michael@0 | 328 | #endif |
michael@0 | 329 | |
michael@0 | 330 | /* Even part: reverse the even part of the forward DCT. */ |
michael@0 | 331 | /* The rotator is sqrt(2)*c(-6). */ |
michael@0 | 332 | |
michael@0 | 333 | z2 = (INT32) wsptr[2]; |
michael@0 | 334 | z3 = (INT32) wsptr[6]; |
michael@0 | 335 | |
michael@0 | 336 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
michael@0 | 337 | tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); |
michael@0 | 338 | tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); |
michael@0 | 339 | |
michael@0 | 340 | tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; |
michael@0 | 341 | tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; |
michael@0 | 342 | |
michael@0 | 343 | tmp10 = tmp0 + tmp3; |
michael@0 | 344 | tmp13 = tmp0 - tmp3; |
michael@0 | 345 | tmp11 = tmp1 + tmp2; |
michael@0 | 346 | tmp12 = tmp1 - tmp2; |
michael@0 | 347 | |
michael@0 | 348 | /* Odd part per figure 8; the matrix is unitary and hence its |
michael@0 | 349 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
michael@0 | 350 | */ |
michael@0 | 351 | |
michael@0 | 352 | tmp0 = (INT32) wsptr[7]; |
michael@0 | 353 | tmp1 = (INT32) wsptr[5]; |
michael@0 | 354 | tmp2 = (INT32) wsptr[3]; |
michael@0 | 355 | tmp3 = (INT32) wsptr[1]; |
michael@0 | 356 | |
michael@0 | 357 | z1 = tmp0 + tmp3; |
michael@0 | 358 | z2 = tmp1 + tmp2; |
michael@0 | 359 | z3 = tmp0 + tmp2; |
michael@0 | 360 | z4 = tmp1 + tmp3; |
michael@0 | 361 | z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ |
michael@0 | 362 | |
michael@0 | 363 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ |
michael@0 | 364 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ |
michael@0 | 365 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
michael@0 | 366 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ |
michael@0 | 367 | z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ |
michael@0 | 368 | z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ |
michael@0 | 369 | z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ |
michael@0 | 370 | z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ |
michael@0 | 371 | |
michael@0 | 372 | z3 += z5; |
michael@0 | 373 | z4 += z5; |
michael@0 | 374 | |
michael@0 | 375 | tmp0 += z1 + z3; |
michael@0 | 376 | tmp1 += z2 + z4; |
michael@0 | 377 | tmp2 += z2 + z3; |
michael@0 | 378 | tmp3 += z1 + z4; |
michael@0 | 379 | |
michael@0 | 380 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
michael@0 | 381 | |
michael@0 | 382 | outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, |
michael@0 | 383 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 384 | & RANGE_MASK]; |
michael@0 | 385 | outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, |
michael@0 | 386 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 387 | & RANGE_MASK]; |
michael@0 | 388 | outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, |
michael@0 | 389 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 390 | & RANGE_MASK]; |
michael@0 | 391 | outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, |
michael@0 | 392 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 393 | & RANGE_MASK]; |
michael@0 | 394 | outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, |
michael@0 | 395 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 396 | & RANGE_MASK]; |
michael@0 | 397 | outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, |
michael@0 | 398 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 399 | & RANGE_MASK]; |
michael@0 | 400 | outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, |
michael@0 | 401 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 402 | & RANGE_MASK]; |
michael@0 | 403 | outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, |
michael@0 | 404 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 405 | & RANGE_MASK]; |
michael@0 | 406 | |
michael@0 | 407 | wsptr += DCTSIZE; /* advance pointer to next row */ |
michael@0 | 408 | } |
michael@0 | 409 | } |
michael@0 | 410 | |
michael@0 | 411 | #ifdef IDCT_SCALING_SUPPORTED |
michael@0 | 412 | |
michael@0 | 413 | |
michael@0 | 414 | /* |
michael@0 | 415 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 416 | * producing a 7x7 output block. |
michael@0 | 417 | * |
michael@0 | 418 | * Optimized algorithm with 12 multiplications in the 1-D kernel. |
michael@0 | 419 | * cK represents sqrt(2) * cos(K*pi/14). |
michael@0 | 420 | */ |
michael@0 | 421 | |
michael@0 | 422 | GLOBAL(void) |
michael@0 | 423 | jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 424 | JCOEFPTR coef_block, |
michael@0 | 425 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 426 | { |
michael@0 | 427 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13; |
michael@0 | 428 | INT32 z1, z2, z3; |
michael@0 | 429 | JCOEFPTR inptr; |
michael@0 | 430 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 431 | int * wsptr; |
michael@0 | 432 | JSAMPROW outptr; |
michael@0 | 433 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 434 | int ctr; |
michael@0 | 435 | int workspace[7*7]; /* buffers data between passes */ |
michael@0 | 436 | SHIFT_TEMPS |
michael@0 | 437 | |
michael@0 | 438 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 439 | |
michael@0 | 440 | inptr = coef_block; |
michael@0 | 441 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 442 | wsptr = workspace; |
michael@0 | 443 | for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 444 | /* Even part */ |
michael@0 | 445 | |
michael@0 | 446 | tmp13 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 447 | tmp13 <<= CONST_BITS; |
michael@0 | 448 | /* Add fudge factor here for final descale. */ |
michael@0 | 449 | tmp13 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 450 | |
michael@0 | 451 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 452 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 453 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 454 | |
michael@0 | 455 | tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
michael@0 | 456 | tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
michael@0 | 457 | tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
michael@0 | 458 | tmp0 = z1 + z3; |
michael@0 | 459 | z2 -= tmp0; |
michael@0 | 460 | tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ |
michael@0 | 461 | tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
michael@0 | 462 | tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
michael@0 | 463 | tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
michael@0 | 464 | |
michael@0 | 465 | /* Odd part */ |
michael@0 | 466 | |
michael@0 | 467 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 468 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 469 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 470 | |
michael@0 | 471 | tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
michael@0 | 472 | tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
michael@0 | 473 | tmp0 = tmp1 - tmp2; |
michael@0 | 474 | tmp1 += tmp2; |
michael@0 | 475 | tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
michael@0 | 476 | tmp1 += tmp2; |
michael@0 | 477 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
michael@0 | 478 | tmp0 += z2; |
michael@0 | 479 | tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
michael@0 | 480 | |
michael@0 | 481 | /* Final output stage */ |
michael@0 | 482 | |
michael@0 | 483 | wsptr[7*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 484 | wsptr[7*6] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 485 | wsptr[7*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 486 | wsptr[7*5] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 487 | wsptr[7*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 488 | wsptr[7*4] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 489 | wsptr[7*3] = (int) RIGHT_SHIFT(tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 490 | } |
michael@0 | 491 | |
michael@0 | 492 | /* Pass 2: process 7 rows from work array, store into output array. */ |
michael@0 | 493 | |
michael@0 | 494 | wsptr = workspace; |
michael@0 | 495 | for (ctr = 0; ctr < 7; ctr++) { |
michael@0 | 496 | outptr = output_buf[ctr] + output_col; |
michael@0 | 497 | |
michael@0 | 498 | /* Even part */ |
michael@0 | 499 | |
michael@0 | 500 | /* Add fudge factor here for final descale. */ |
michael@0 | 501 | tmp13 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 502 | tmp13 <<= CONST_BITS; |
michael@0 | 503 | |
michael@0 | 504 | z1 = (INT32) wsptr[2]; |
michael@0 | 505 | z2 = (INT32) wsptr[4]; |
michael@0 | 506 | z3 = (INT32) wsptr[6]; |
michael@0 | 507 | |
michael@0 | 508 | tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
michael@0 | 509 | tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
michael@0 | 510 | tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
michael@0 | 511 | tmp0 = z1 + z3; |
michael@0 | 512 | z2 -= tmp0; |
michael@0 | 513 | tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ |
michael@0 | 514 | tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
michael@0 | 515 | tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
michael@0 | 516 | tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
michael@0 | 517 | |
michael@0 | 518 | /* Odd part */ |
michael@0 | 519 | |
michael@0 | 520 | z1 = (INT32) wsptr[1]; |
michael@0 | 521 | z2 = (INT32) wsptr[3]; |
michael@0 | 522 | z3 = (INT32) wsptr[5]; |
michael@0 | 523 | |
michael@0 | 524 | tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
michael@0 | 525 | tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
michael@0 | 526 | tmp0 = tmp1 - tmp2; |
michael@0 | 527 | tmp1 += tmp2; |
michael@0 | 528 | tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
michael@0 | 529 | tmp1 += tmp2; |
michael@0 | 530 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
michael@0 | 531 | tmp0 += z2; |
michael@0 | 532 | tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
michael@0 | 533 | |
michael@0 | 534 | /* Final output stage */ |
michael@0 | 535 | |
michael@0 | 536 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
michael@0 | 537 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 538 | & RANGE_MASK]; |
michael@0 | 539 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
michael@0 | 540 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 541 | & RANGE_MASK]; |
michael@0 | 542 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
michael@0 | 543 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 544 | & RANGE_MASK]; |
michael@0 | 545 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
michael@0 | 546 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 547 | & RANGE_MASK]; |
michael@0 | 548 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
michael@0 | 549 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 550 | & RANGE_MASK]; |
michael@0 | 551 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
michael@0 | 552 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 553 | & RANGE_MASK]; |
michael@0 | 554 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13, |
michael@0 | 555 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 556 | & RANGE_MASK]; |
michael@0 | 557 | |
michael@0 | 558 | wsptr += 7; /* advance pointer to next row */ |
michael@0 | 559 | } |
michael@0 | 560 | } |
michael@0 | 561 | |
michael@0 | 562 | |
michael@0 | 563 | /* |
michael@0 | 564 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 565 | * producing a reduced-size 6x6 output block. |
michael@0 | 566 | * |
michael@0 | 567 | * Optimized algorithm with 3 multiplications in the 1-D kernel. |
michael@0 | 568 | * cK represents sqrt(2) * cos(K*pi/12). |
michael@0 | 569 | */ |
michael@0 | 570 | |
michael@0 | 571 | GLOBAL(void) |
michael@0 | 572 | jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 573 | JCOEFPTR coef_block, |
michael@0 | 574 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 575 | { |
michael@0 | 576 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; |
michael@0 | 577 | INT32 z1, z2, z3; |
michael@0 | 578 | JCOEFPTR inptr; |
michael@0 | 579 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 580 | int * wsptr; |
michael@0 | 581 | JSAMPROW outptr; |
michael@0 | 582 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 583 | int ctr; |
michael@0 | 584 | int workspace[6*6]; /* buffers data between passes */ |
michael@0 | 585 | SHIFT_TEMPS |
michael@0 | 586 | |
michael@0 | 587 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 588 | |
michael@0 | 589 | inptr = coef_block; |
michael@0 | 590 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 591 | wsptr = workspace; |
michael@0 | 592 | for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 593 | /* Even part */ |
michael@0 | 594 | |
michael@0 | 595 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 596 | tmp0 <<= CONST_BITS; |
michael@0 | 597 | /* Add fudge factor here for final descale. */ |
michael@0 | 598 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 599 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 600 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
michael@0 | 601 | tmp1 = tmp0 + tmp10; |
michael@0 | 602 | tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 603 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 604 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
michael@0 | 605 | tmp10 = tmp1 + tmp0; |
michael@0 | 606 | tmp12 = tmp1 - tmp0; |
michael@0 | 607 | |
michael@0 | 608 | /* Odd part */ |
michael@0 | 609 | |
michael@0 | 610 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 611 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 612 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 613 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
michael@0 | 614 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
michael@0 | 615 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
michael@0 | 616 | tmp1 = (z1 - z2 - z3) << PASS1_BITS; |
michael@0 | 617 | |
michael@0 | 618 | /* Final output stage */ |
michael@0 | 619 | |
michael@0 | 620 | wsptr[6*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 621 | wsptr[6*5] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 622 | wsptr[6*1] = (int) (tmp11 + tmp1); |
michael@0 | 623 | wsptr[6*4] = (int) (tmp11 - tmp1); |
michael@0 | 624 | wsptr[6*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 625 | wsptr[6*3] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 626 | } |
michael@0 | 627 | |
michael@0 | 628 | /* Pass 2: process 6 rows from work array, store into output array. */ |
michael@0 | 629 | |
michael@0 | 630 | wsptr = workspace; |
michael@0 | 631 | for (ctr = 0; ctr < 6; ctr++) { |
michael@0 | 632 | outptr = output_buf[ctr] + output_col; |
michael@0 | 633 | |
michael@0 | 634 | /* Even part */ |
michael@0 | 635 | |
michael@0 | 636 | /* Add fudge factor here for final descale. */ |
michael@0 | 637 | tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 638 | tmp0 <<= CONST_BITS; |
michael@0 | 639 | tmp2 = (INT32) wsptr[4]; |
michael@0 | 640 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
michael@0 | 641 | tmp1 = tmp0 + tmp10; |
michael@0 | 642 | tmp11 = tmp0 - tmp10 - tmp10; |
michael@0 | 643 | tmp10 = (INT32) wsptr[2]; |
michael@0 | 644 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
michael@0 | 645 | tmp10 = tmp1 + tmp0; |
michael@0 | 646 | tmp12 = tmp1 - tmp0; |
michael@0 | 647 | |
michael@0 | 648 | /* Odd part */ |
michael@0 | 649 | |
michael@0 | 650 | z1 = (INT32) wsptr[1]; |
michael@0 | 651 | z2 = (INT32) wsptr[3]; |
michael@0 | 652 | z3 = (INT32) wsptr[5]; |
michael@0 | 653 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
michael@0 | 654 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
michael@0 | 655 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
michael@0 | 656 | tmp1 = (z1 - z2 - z3) << CONST_BITS; |
michael@0 | 657 | |
michael@0 | 658 | /* Final output stage */ |
michael@0 | 659 | |
michael@0 | 660 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
michael@0 | 661 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 662 | & RANGE_MASK]; |
michael@0 | 663 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
michael@0 | 664 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 665 | & RANGE_MASK]; |
michael@0 | 666 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
michael@0 | 667 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 668 | & RANGE_MASK]; |
michael@0 | 669 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
michael@0 | 670 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 671 | & RANGE_MASK]; |
michael@0 | 672 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
michael@0 | 673 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 674 | & RANGE_MASK]; |
michael@0 | 675 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
michael@0 | 676 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 677 | & RANGE_MASK]; |
michael@0 | 678 | |
michael@0 | 679 | wsptr += 6; /* advance pointer to next row */ |
michael@0 | 680 | } |
michael@0 | 681 | } |
michael@0 | 682 | |
michael@0 | 683 | |
michael@0 | 684 | /* |
michael@0 | 685 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 686 | * producing a reduced-size 5x5 output block. |
michael@0 | 687 | * |
michael@0 | 688 | * Optimized algorithm with 5 multiplications in the 1-D kernel. |
michael@0 | 689 | * cK represents sqrt(2) * cos(K*pi/10). |
michael@0 | 690 | */ |
michael@0 | 691 | |
michael@0 | 692 | GLOBAL(void) |
michael@0 | 693 | jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 694 | JCOEFPTR coef_block, |
michael@0 | 695 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 696 | { |
michael@0 | 697 | INT32 tmp0, tmp1, tmp10, tmp11, tmp12; |
michael@0 | 698 | INT32 z1, z2, z3; |
michael@0 | 699 | JCOEFPTR inptr; |
michael@0 | 700 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 701 | int * wsptr; |
michael@0 | 702 | JSAMPROW outptr; |
michael@0 | 703 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 704 | int ctr; |
michael@0 | 705 | int workspace[5*5]; /* buffers data between passes */ |
michael@0 | 706 | SHIFT_TEMPS |
michael@0 | 707 | |
michael@0 | 708 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 709 | |
michael@0 | 710 | inptr = coef_block; |
michael@0 | 711 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 712 | wsptr = workspace; |
michael@0 | 713 | for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 714 | /* Even part */ |
michael@0 | 715 | |
michael@0 | 716 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 717 | tmp12 <<= CONST_BITS; |
michael@0 | 718 | /* Add fudge factor here for final descale. */ |
michael@0 | 719 | tmp12 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 720 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 721 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 722 | z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ |
michael@0 | 723 | z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ |
michael@0 | 724 | z3 = tmp12 + z2; |
michael@0 | 725 | tmp10 = z3 + z1; |
michael@0 | 726 | tmp11 = z3 - z1; |
michael@0 | 727 | tmp12 -= z2 << 2; |
michael@0 | 728 | |
michael@0 | 729 | /* Odd part */ |
michael@0 | 730 | |
michael@0 | 731 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 732 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 733 | |
michael@0 | 734 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
michael@0 | 735 | tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
michael@0 | 736 | tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
michael@0 | 737 | |
michael@0 | 738 | /* Final output stage */ |
michael@0 | 739 | |
michael@0 | 740 | wsptr[5*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 741 | wsptr[5*4] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 742 | wsptr[5*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 743 | wsptr[5*3] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 744 | wsptr[5*2] = (int) RIGHT_SHIFT(tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 745 | } |
michael@0 | 746 | |
michael@0 | 747 | /* Pass 2: process 5 rows from work array, store into output array. */ |
michael@0 | 748 | |
michael@0 | 749 | wsptr = workspace; |
michael@0 | 750 | for (ctr = 0; ctr < 5; ctr++) { |
michael@0 | 751 | outptr = output_buf[ctr] + output_col; |
michael@0 | 752 | |
michael@0 | 753 | /* Even part */ |
michael@0 | 754 | |
michael@0 | 755 | /* Add fudge factor here for final descale. */ |
michael@0 | 756 | tmp12 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 757 | tmp12 <<= CONST_BITS; |
michael@0 | 758 | tmp0 = (INT32) wsptr[2]; |
michael@0 | 759 | tmp1 = (INT32) wsptr[4]; |
michael@0 | 760 | z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ |
michael@0 | 761 | z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ |
michael@0 | 762 | z3 = tmp12 + z2; |
michael@0 | 763 | tmp10 = z3 + z1; |
michael@0 | 764 | tmp11 = z3 - z1; |
michael@0 | 765 | tmp12 -= z2 << 2; |
michael@0 | 766 | |
michael@0 | 767 | /* Odd part */ |
michael@0 | 768 | |
michael@0 | 769 | z2 = (INT32) wsptr[1]; |
michael@0 | 770 | z3 = (INT32) wsptr[3]; |
michael@0 | 771 | |
michael@0 | 772 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
michael@0 | 773 | tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
michael@0 | 774 | tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
michael@0 | 775 | |
michael@0 | 776 | /* Final output stage */ |
michael@0 | 777 | |
michael@0 | 778 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
michael@0 | 779 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 780 | & RANGE_MASK]; |
michael@0 | 781 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
michael@0 | 782 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 783 | & RANGE_MASK]; |
michael@0 | 784 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
michael@0 | 785 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 786 | & RANGE_MASK]; |
michael@0 | 787 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
michael@0 | 788 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 789 | & RANGE_MASK]; |
michael@0 | 790 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12, |
michael@0 | 791 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 792 | & RANGE_MASK]; |
michael@0 | 793 | |
michael@0 | 794 | wsptr += 5; /* advance pointer to next row */ |
michael@0 | 795 | } |
michael@0 | 796 | } |
michael@0 | 797 | |
michael@0 | 798 | |
michael@0 | 799 | /* |
michael@0 | 800 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 801 | * producing a reduced-size 3x3 output block. |
michael@0 | 802 | * |
michael@0 | 803 | * Optimized algorithm with 2 multiplications in the 1-D kernel. |
michael@0 | 804 | * cK represents sqrt(2) * cos(K*pi/6). |
michael@0 | 805 | */ |
michael@0 | 806 | |
michael@0 | 807 | GLOBAL(void) |
michael@0 | 808 | jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 809 | JCOEFPTR coef_block, |
michael@0 | 810 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 811 | { |
michael@0 | 812 | INT32 tmp0, tmp2, tmp10, tmp12; |
michael@0 | 813 | JCOEFPTR inptr; |
michael@0 | 814 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 815 | int * wsptr; |
michael@0 | 816 | JSAMPROW outptr; |
michael@0 | 817 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 818 | int ctr; |
michael@0 | 819 | int workspace[3*3]; /* buffers data between passes */ |
michael@0 | 820 | SHIFT_TEMPS |
michael@0 | 821 | |
michael@0 | 822 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 823 | |
michael@0 | 824 | inptr = coef_block; |
michael@0 | 825 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 826 | wsptr = workspace; |
michael@0 | 827 | for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 828 | /* Even part */ |
michael@0 | 829 | |
michael@0 | 830 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 831 | tmp0 <<= CONST_BITS; |
michael@0 | 832 | /* Add fudge factor here for final descale. */ |
michael@0 | 833 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 834 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 835 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
michael@0 | 836 | tmp10 = tmp0 + tmp12; |
michael@0 | 837 | tmp2 = tmp0 - tmp12 - tmp12; |
michael@0 | 838 | |
michael@0 | 839 | /* Odd part */ |
michael@0 | 840 | |
michael@0 | 841 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 842 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
michael@0 | 843 | |
michael@0 | 844 | /* Final output stage */ |
michael@0 | 845 | |
michael@0 | 846 | wsptr[3*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 847 | wsptr[3*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 848 | wsptr[3*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 849 | } |
michael@0 | 850 | |
michael@0 | 851 | /* Pass 2: process 3 rows from work array, store into output array. */ |
michael@0 | 852 | |
michael@0 | 853 | wsptr = workspace; |
michael@0 | 854 | for (ctr = 0; ctr < 3; ctr++) { |
michael@0 | 855 | outptr = output_buf[ctr] + output_col; |
michael@0 | 856 | |
michael@0 | 857 | /* Even part */ |
michael@0 | 858 | |
michael@0 | 859 | /* Add fudge factor here for final descale. */ |
michael@0 | 860 | tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 861 | tmp0 <<= CONST_BITS; |
michael@0 | 862 | tmp2 = (INT32) wsptr[2]; |
michael@0 | 863 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
michael@0 | 864 | tmp10 = tmp0 + tmp12; |
michael@0 | 865 | tmp2 = tmp0 - tmp12 - tmp12; |
michael@0 | 866 | |
michael@0 | 867 | /* Odd part */ |
michael@0 | 868 | |
michael@0 | 869 | tmp12 = (INT32) wsptr[1]; |
michael@0 | 870 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
michael@0 | 871 | |
michael@0 | 872 | /* Final output stage */ |
michael@0 | 873 | |
michael@0 | 874 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
michael@0 | 875 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 876 | & RANGE_MASK]; |
michael@0 | 877 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
michael@0 | 878 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 879 | & RANGE_MASK]; |
michael@0 | 880 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2, |
michael@0 | 881 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 882 | & RANGE_MASK]; |
michael@0 | 883 | |
michael@0 | 884 | wsptr += 3; /* advance pointer to next row */ |
michael@0 | 885 | } |
michael@0 | 886 | } |
michael@0 | 887 | |
michael@0 | 888 | |
michael@0 | 889 | /* |
michael@0 | 890 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 891 | * producing a 9x9 output block. |
michael@0 | 892 | * |
michael@0 | 893 | * Optimized algorithm with 10 multiplications in the 1-D kernel. |
michael@0 | 894 | * cK represents sqrt(2) * cos(K*pi/18). |
michael@0 | 895 | */ |
michael@0 | 896 | |
michael@0 | 897 | GLOBAL(void) |
michael@0 | 898 | jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 899 | JCOEFPTR coef_block, |
michael@0 | 900 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 901 | { |
michael@0 | 902 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14; |
michael@0 | 903 | INT32 z1, z2, z3, z4; |
michael@0 | 904 | JCOEFPTR inptr; |
michael@0 | 905 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 906 | int * wsptr; |
michael@0 | 907 | JSAMPROW outptr; |
michael@0 | 908 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 909 | int ctr; |
michael@0 | 910 | int workspace[8*9]; /* buffers data between passes */ |
michael@0 | 911 | SHIFT_TEMPS |
michael@0 | 912 | |
michael@0 | 913 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 914 | |
michael@0 | 915 | inptr = coef_block; |
michael@0 | 916 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 917 | wsptr = workspace; |
michael@0 | 918 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 919 | /* Even part */ |
michael@0 | 920 | |
michael@0 | 921 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 922 | tmp0 <<= CONST_BITS; |
michael@0 | 923 | /* Add fudge factor here for final descale. */ |
michael@0 | 924 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 925 | |
michael@0 | 926 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 927 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 928 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 929 | |
michael@0 | 930 | tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ |
michael@0 | 931 | tmp1 = tmp0 + tmp3; |
michael@0 | 932 | tmp2 = tmp0 - tmp3 - tmp3; |
michael@0 | 933 | |
michael@0 | 934 | tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ |
michael@0 | 935 | tmp11 = tmp2 + tmp0; |
michael@0 | 936 | tmp14 = tmp2 - tmp0 - tmp0; |
michael@0 | 937 | |
michael@0 | 938 | tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ |
michael@0 | 939 | tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ |
michael@0 | 940 | tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ |
michael@0 | 941 | |
michael@0 | 942 | tmp10 = tmp1 + tmp0 - tmp3; |
michael@0 | 943 | tmp12 = tmp1 - tmp0 + tmp2; |
michael@0 | 944 | tmp13 = tmp1 - tmp2 + tmp3; |
michael@0 | 945 | |
michael@0 | 946 | /* Odd part */ |
michael@0 | 947 | |
michael@0 | 948 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 949 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 950 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 951 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 952 | |
michael@0 | 953 | z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ |
michael@0 | 954 | |
michael@0 | 955 | tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ |
michael@0 | 956 | tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ |
michael@0 | 957 | tmp0 = tmp2 + tmp3 - z2; |
michael@0 | 958 | tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ |
michael@0 | 959 | tmp2 += z2 - tmp1; |
michael@0 | 960 | tmp3 += z2 + tmp1; |
michael@0 | 961 | tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ |
michael@0 | 962 | |
michael@0 | 963 | /* Final output stage */ |
michael@0 | 964 | |
michael@0 | 965 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 966 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 967 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 968 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 969 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 970 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 971 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp13 + tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 972 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp13 - tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 973 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 974 | } |
michael@0 | 975 | |
michael@0 | 976 | /* Pass 2: process 9 rows from work array, store into output array. */ |
michael@0 | 977 | |
michael@0 | 978 | wsptr = workspace; |
michael@0 | 979 | for (ctr = 0; ctr < 9; ctr++) { |
michael@0 | 980 | outptr = output_buf[ctr] + output_col; |
michael@0 | 981 | |
michael@0 | 982 | /* Even part */ |
michael@0 | 983 | |
michael@0 | 984 | /* Add fudge factor here for final descale. */ |
michael@0 | 985 | tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 986 | tmp0 <<= CONST_BITS; |
michael@0 | 987 | |
michael@0 | 988 | z1 = (INT32) wsptr[2]; |
michael@0 | 989 | z2 = (INT32) wsptr[4]; |
michael@0 | 990 | z3 = (INT32) wsptr[6]; |
michael@0 | 991 | |
michael@0 | 992 | tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ |
michael@0 | 993 | tmp1 = tmp0 + tmp3; |
michael@0 | 994 | tmp2 = tmp0 - tmp3 - tmp3; |
michael@0 | 995 | |
michael@0 | 996 | tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ |
michael@0 | 997 | tmp11 = tmp2 + tmp0; |
michael@0 | 998 | tmp14 = tmp2 - tmp0 - tmp0; |
michael@0 | 999 | |
michael@0 | 1000 | tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ |
michael@0 | 1001 | tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ |
michael@0 | 1002 | tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ |
michael@0 | 1003 | |
michael@0 | 1004 | tmp10 = tmp1 + tmp0 - tmp3; |
michael@0 | 1005 | tmp12 = tmp1 - tmp0 + tmp2; |
michael@0 | 1006 | tmp13 = tmp1 - tmp2 + tmp3; |
michael@0 | 1007 | |
michael@0 | 1008 | /* Odd part */ |
michael@0 | 1009 | |
michael@0 | 1010 | z1 = (INT32) wsptr[1]; |
michael@0 | 1011 | z2 = (INT32) wsptr[3]; |
michael@0 | 1012 | z3 = (INT32) wsptr[5]; |
michael@0 | 1013 | z4 = (INT32) wsptr[7]; |
michael@0 | 1014 | |
michael@0 | 1015 | z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ |
michael@0 | 1016 | |
michael@0 | 1017 | tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ |
michael@0 | 1018 | tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ |
michael@0 | 1019 | tmp0 = tmp2 + tmp3 - z2; |
michael@0 | 1020 | tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ |
michael@0 | 1021 | tmp2 += z2 - tmp1; |
michael@0 | 1022 | tmp3 += z2 + tmp1; |
michael@0 | 1023 | tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ |
michael@0 | 1024 | |
michael@0 | 1025 | /* Final output stage */ |
michael@0 | 1026 | |
michael@0 | 1027 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
michael@0 | 1028 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1029 | & RANGE_MASK]; |
michael@0 | 1030 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
michael@0 | 1031 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1032 | & RANGE_MASK]; |
michael@0 | 1033 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
michael@0 | 1034 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1035 | & RANGE_MASK]; |
michael@0 | 1036 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
michael@0 | 1037 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1038 | & RANGE_MASK]; |
michael@0 | 1039 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
michael@0 | 1040 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1041 | & RANGE_MASK]; |
michael@0 | 1042 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
michael@0 | 1043 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1044 | & RANGE_MASK]; |
michael@0 | 1045 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp3, |
michael@0 | 1046 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1047 | & RANGE_MASK]; |
michael@0 | 1048 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp3, |
michael@0 | 1049 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1050 | & RANGE_MASK]; |
michael@0 | 1051 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp14, |
michael@0 | 1052 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1053 | & RANGE_MASK]; |
michael@0 | 1054 | |
michael@0 | 1055 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 1056 | } |
michael@0 | 1057 | } |
michael@0 | 1058 | |
michael@0 | 1059 | |
michael@0 | 1060 | /* |
michael@0 | 1061 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 1062 | * producing a 10x10 output block. |
michael@0 | 1063 | * |
michael@0 | 1064 | * Optimized algorithm with 12 multiplications in the 1-D kernel. |
michael@0 | 1065 | * cK represents sqrt(2) * cos(K*pi/20). |
michael@0 | 1066 | */ |
michael@0 | 1067 | |
michael@0 | 1068 | GLOBAL(void) |
michael@0 | 1069 | jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 1070 | JCOEFPTR coef_block, |
michael@0 | 1071 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 1072 | { |
michael@0 | 1073 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
michael@0 | 1074 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24; |
michael@0 | 1075 | INT32 z1, z2, z3, z4, z5; |
michael@0 | 1076 | JCOEFPTR inptr; |
michael@0 | 1077 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 1078 | int * wsptr; |
michael@0 | 1079 | JSAMPROW outptr; |
michael@0 | 1080 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 1081 | int ctr; |
michael@0 | 1082 | int workspace[8*10]; /* buffers data between passes */ |
michael@0 | 1083 | SHIFT_TEMPS |
michael@0 | 1084 | |
michael@0 | 1085 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 1086 | |
michael@0 | 1087 | inptr = coef_block; |
michael@0 | 1088 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 1089 | wsptr = workspace; |
michael@0 | 1090 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 1091 | /* Even part */ |
michael@0 | 1092 | |
michael@0 | 1093 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 1094 | z3 <<= CONST_BITS; |
michael@0 | 1095 | /* Add fudge factor here for final descale. */ |
michael@0 | 1096 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 1097 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 1098 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
michael@0 | 1099 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
michael@0 | 1100 | tmp10 = z3 + z1; |
michael@0 | 1101 | tmp11 = z3 - z2; |
michael@0 | 1102 | |
michael@0 | 1103 | tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */ |
michael@0 | 1104 | CONST_BITS-PASS1_BITS); |
michael@0 | 1105 | |
michael@0 | 1106 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 1107 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 1108 | |
michael@0 | 1109 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
michael@0 | 1110 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
michael@0 | 1111 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
michael@0 | 1112 | |
michael@0 | 1113 | tmp20 = tmp10 + tmp12; |
michael@0 | 1114 | tmp24 = tmp10 - tmp12; |
michael@0 | 1115 | tmp21 = tmp11 + tmp13; |
michael@0 | 1116 | tmp23 = tmp11 - tmp13; |
michael@0 | 1117 | |
michael@0 | 1118 | /* Odd part */ |
michael@0 | 1119 | |
michael@0 | 1120 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 1121 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 1122 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 1123 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 1124 | |
michael@0 | 1125 | tmp11 = z2 + z4; |
michael@0 | 1126 | tmp13 = z2 - z4; |
michael@0 | 1127 | |
michael@0 | 1128 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
michael@0 | 1129 | z5 = z3 << CONST_BITS; |
michael@0 | 1130 | |
michael@0 | 1131 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
michael@0 | 1132 | z4 = z5 + tmp12; |
michael@0 | 1133 | |
michael@0 | 1134 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
michael@0 | 1135 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
michael@0 | 1136 | |
michael@0 | 1137 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
michael@0 | 1138 | z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
michael@0 | 1139 | |
michael@0 | 1140 | tmp12 = (z1 - tmp13 - z3) << PASS1_BITS; |
michael@0 | 1141 | |
michael@0 | 1142 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
michael@0 | 1143 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
michael@0 | 1144 | |
michael@0 | 1145 | /* Final output stage */ |
michael@0 | 1146 | |
michael@0 | 1147 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1148 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1149 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1150 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1151 | wsptr[8*2] = (int) (tmp22 + tmp12); |
michael@0 | 1152 | wsptr[8*7] = (int) (tmp22 - tmp12); |
michael@0 | 1153 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1154 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1155 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1156 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1157 | } |
michael@0 | 1158 | |
michael@0 | 1159 | /* Pass 2: process 10 rows from work array, store into output array. */ |
michael@0 | 1160 | |
michael@0 | 1161 | wsptr = workspace; |
michael@0 | 1162 | for (ctr = 0; ctr < 10; ctr++) { |
michael@0 | 1163 | outptr = output_buf[ctr] + output_col; |
michael@0 | 1164 | |
michael@0 | 1165 | /* Even part */ |
michael@0 | 1166 | |
michael@0 | 1167 | /* Add fudge factor here for final descale. */ |
michael@0 | 1168 | z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 1169 | z3 <<= CONST_BITS; |
michael@0 | 1170 | z4 = (INT32) wsptr[4]; |
michael@0 | 1171 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
michael@0 | 1172 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
michael@0 | 1173 | tmp10 = z3 + z1; |
michael@0 | 1174 | tmp11 = z3 - z2; |
michael@0 | 1175 | |
michael@0 | 1176 | tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */ |
michael@0 | 1177 | |
michael@0 | 1178 | z2 = (INT32) wsptr[2]; |
michael@0 | 1179 | z3 = (INT32) wsptr[6]; |
michael@0 | 1180 | |
michael@0 | 1181 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
michael@0 | 1182 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
michael@0 | 1183 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
michael@0 | 1184 | |
michael@0 | 1185 | tmp20 = tmp10 + tmp12; |
michael@0 | 1186 | tmp24 = tmp10 - tmp12; |
michael@0 | 1187 | tmp21 = tmp11 + tmp13; |
michael@0 | 1188 | tmp23 = tmp11 - tmp13; |
michael@0 | 1189 | |
michael@0 | 1190 | /* Odd part */ |
michael@0 | 1191 | |
michael@0 | 1192 | z1 = (INT32) wsptr[1]; |
michael@0 | 1193 | z2 = (INT32) wsptr[3]; |
michael@0 | 1194 | z3 = (INT32) wsptr[5]; |
michael@0 | 1195 | z3 <<= CONST_BITS; |
michael@0 | 1196 | z4 = (INT32) wsptr[7]; |
michael@0 | 1197 | |
michael@0 | 1198 | tmp11 = z2 + z4; |
michael@0 | 1199 | tmp13 = z2 - z4; |
michael@0 | 1200 | |
michael@0 | 1201 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
michael@0 | 1202 | |
michael@0 | 1203 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
michael@0 | 1204 | z4 = z3 + tmp12; |
michael@0 | 1205 | |
michael@0 | 1206 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
michael@0 | 1207 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
michael@0 | 1208 | |
michael@0 | 1209 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
michael@0 | 1210 | z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
michael@0 | 1211 | |
michael@0 | 1212 | tmp12 = ((z1 - tmp13) << CONST_BITS) - z3; |
michael@0 | 1213 | |
michael@0 | 1214 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
michael@0 | 1215 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
michael@0 | 1216 | |
michael@0 | 1217 | /* Final output stage */ |
michael@0 | 1218 | |
michael@0 | 1219 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 1220 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1221 | & RANGE_MASK]; |
michael@0 | 1222 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 1223 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1224 | & RANGE_MASK]; |
michael@0 | 1225 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 1226 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1227 | & RANGE_MASK]; |
michael@0 | 1228 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 1229 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1230 | & RANGE_MASK]; |
michael@0 | 1231 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 1232 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1233 | & RANGE_MASK]; |
michael@0 | 1234 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 1235 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1236 | & RANGE_MASK]; |
michael@0 | 1237 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 1238 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1239 | & RANGE_MASK]; |
michael@0 | 1240 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 1241 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1242 | & RANGE_MASK]; |
michael@0 | 1243 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 1244 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1245 | & RANGE_MASK]; |
michael@0 | 1246 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 1247 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1248 | & RANGE_MASK]; |
michael@0 | 1249 | |
michael@0 | 1250 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 1251 | } |
michael@0 | 1252 | } |
michael@0 | 1253 | |
michael@0 | 1254 | |
michael@0 | 1255 | /* |
michael@0 | 1256 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 1257 | * producing a 11x11 output block. |
michael@0 | 1258 | * |
michael@0 | 1259 | * Optimized algorithm with 24 multiplications in the 1-D kernel. |
michael@0 | 1260 | * cK represents sqrt(2) * cos(K*pi/22). |
michael@0 | 1261 | */ |
michael@0 | 1262 | |
michael@0 | 1263 | GLOBAL(void) |
michael@0 | 1264 | jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 1265 | JCOEFPTR coef_block, |
michael@0 | 1266 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 1267 | { |
michael@0 | 1268 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
michael@0 | 1269 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
michael@0 | 1270 | INT32 z1, z2, z3, z4; |
michael@0 | 1271 | JCOEFPTR inptr; |
michael@0 | 1272 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 1273 | int * wsptr; |
michael@0 | 1274 | JSAMPROW outptr; |
michael@0 | 1275 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 1276 | int ctr; |
michael@0 | 1277 | int workspace[8*11]; /* buffers data between passes */ |
michael@0 | 1278 | SHIFT_TEMPS |
michael@0 | 1279 | |
michael@0 | 1280 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 1281 | |
michael@0 | 1282 | inptr = coef_block; |
michael@0 | 1283 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 1284 | wsptr = workspace; |
michael@0 | 1285 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 1286 | /* Even part */ |
michael@0 | 1287 | |
michael@0 | 1288 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 1289 | tmp10 <<= CONST_BITS; |
michael@0 | 1290 | /* Add fudge factor here for final descale. */ |
michael@0 | 1291 | tmp10 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 1292 | |
michael@0 | 1293 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 1294 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 1295 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 1296 | |
michael@0 | 1297 | tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ |
michael@0 | 1298 | tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ |
michael@0 | 1299 | z4 = z1 + z3; |
michael@0 | 1300 | tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ |
michael@0 | 1301 | z4 -= z2; |
michael@0 | 1302 | tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ |
michael@0 | 1303 | tmp21 = tmp20 + tmp23 + tmp25 - |
michael@0 | 1304 | MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ |
michael@0 | 1305 | tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ |
michael@0 | 1306 | tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ |
michael@0 | 1307 | tmp24 += tmp25; |
michael@0 | 1308 | tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ |
michael@0 | 1309 | tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ |
michael@0 | 1310 | MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ |
michael@0 | 1311 | tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ |
michael@0 | 1312 | |
michael@0 | 1313 | /* Odd part */ |
michael@0 | 1314 | |
michael@0 | 1315 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 1316 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 1317 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 1318 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 1319 | |
michael@0 | 1320 | tmp11 = z1 + z2; |
michael@0 | 1321 | tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ |
michael@0 | 1322 | tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ |
michael@0 | 1323 | tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ |
michael@0 | 1324 | tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ |
michael@0 | 1325 | tmp10 = tmp11 + tmp12 + tmp13 - |
michael@0 | 1326 | MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ |
michael@0 | 1327 | z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ |
michael@0 | 1328 | tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ |
michael@0 | 1329 | tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ |
michael@0 | 1330 | z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ |
michael@0 | 1331 | tmp11 += z1; |
michael@0 | 1332 | tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ |
michael@0 | 1333 | tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ |
michael@0 | 1334 | MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ |
michael@0 | 1335 | MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ |
michael@0 | 1336 | |
michael@0 | 1337 | /* Final output stage */ |
michael@0 | 1338 | |
michael@0 | 1339 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1340 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1341 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1342 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1343 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1344 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1345 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1346 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1347 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1348 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1349 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25, CONST_BITS-PASS1_BITS); |
michael@0 | 1350 | } |
michael@0 | 1351 | |
michael@0 | 1352 | /* Pass 2: process 11 rows from work array, store into output array. */ |
michael@0 | 1353 | |
michael@0 | 1354 | wsptr = workspace; |
michael@0 | 1355 | for (ctr = 0; ctr < 11; ctr++) { |
michael@0 | 1356 | outptr = output_buf[ctr] + output_col; |
michael@0 | 1357 | |
michael@0 | 1358 | /* Even part */ |
michael@0 | 1359 | |
michael@0 | 1360 | /* Add fudge factor here for final descale. */ |
michael@0 | 1361 | tmp10 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 1362 | tmp10 <<= CONST_BITS; |
michael@0 | 1363 | |
michael@0 | 1364 | z1 = (INT32) wsptr[2]; |
michael@0 | 1365 | z2 = (INT32) wsptr[4]; |
michael@0 | 1366 | z3 = (INT32) wsptr[6]; |
michael@0 | 1367 | |
michael@0 | 1368 | tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ |
michael@0 | 1369 | tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ |
michael@0 | 1370 | z4 = z1 + z3; |
michael@0 | 1371 | tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ |
michael@0 | 1372 | z4 -= z2; |
michael@0 | 1373 | tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ |
michael@0 | 1374 | tmp21 = tmp20 + tmp23 + tmp25 - |
michael@0 | 1375 | MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ |
michael@0 | 1376 | tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ |
michael@0 | 1377 | tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ |
michael@0 | 1378 | tmp24 += tmp25; |
michael@0 | 1379 | tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ |
michael@0 | 1380 | tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ |
michael@0 | 1381 | MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ |
michael@0 | 1382 | tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ |
michael@0 | 1383 | |
michael@0 | 1384 | /* Odd part */ |
michael@0 | 1385 | |
michael@0 | 1386 | z1 = (INT32) wsptr[1]; |
michael@0 | 1387 | z2 = (INT32) wsptr[3]; |
michael@0 | 1388 | z3 = (INT32) wsptr[5]; |
michael@0 | 1389 | z4 = (INT32) wsptr[7]; |
michael@0 | 1390 | |
michael@0 | 1391 | tmp11 = z1 + z2; |
michael@0 | 1392 | tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ |
michael@0 | 1393 | tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ |
michael@0 | 1394 | tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ |
michael@0 | 1395 | tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ |
michael@0 | 1396 | tmp10 = tmp11 + tmp12 + tmp13 - |
michael@0 | 1397 | MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ |
michael@0 | 1398 | z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ |
michael@0 | 1399 | tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ |
michael@0 | 1400 | tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ |
michael@0 | 1401 | z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ |
michael@0 | 1402 | tmp11 += z1; |
michael@0 | 1403 | tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ |
michael@0 | 1404 | tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ |
michael@0 | 1405 | MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ |
michael@0 | 1406 | MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ |
michael@0 | 1407 | |
michael@0 | 1408 | /* Final output stage */ |
michael@0 | 1409 | |
michael@0 | 1410 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 1411 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1412 | & RANGE_MASK]; |
michael@0 | 1413 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 1414 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1415 | & RANGE_MASK]; |
michael@0 | 1416 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 1417 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1418 | & RANGE_MASK]; |
michael@0 | 1419 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 1420 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1421 | & RANGE_MASK]; |
michael@0 | 1422 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 1423 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1424 | & RANGE_MASK]; |
michael@0 | 1425 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 1426 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1427 | & RANGE_MASK]; |
michael@0 | 1428 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 1429 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1430 | & RANGE_MASK]; |
michael@0 | 1431 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 1432 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1433 | & RANGE_MASK]; |
michael@0 | 1434 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 1435 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1436 | & RANGE_MASK]; |
michael@0 | 1437 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 1438 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1439 | & RANGE_MASK]; |
michael@0 | 1440 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25, |
michael@0 | 1441 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1442 | & RANGE_MASK]; |
michael@0 | 1443 | |
michael@0 | 1444 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 1445 | } |
michael@0 | 1446 | } |
michael@0 | 1447 | |
michael@0 | 1448 | |
michael@0 | 1449 | /* |
michael@0 | 1450 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 1451 | * producing a 12x12 output block. |
michael@0 | 1452 | * |
michael@0 | 1453 | * Optimized algorithm with 15 multiplications in the 1-D kernel. |
michael@0 | 1454 | * cK represents sqrt(2) * cos(K*pi/24). |
michael@0 | 1455 | */ |
michael@0 | 1456 | |
michael@0 | 1457 | GLOBAL(void) |
michael@0 | 1458 | jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 1459 | JCOEFPTR coef_block, |
michael@0 | 1460 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 1461 | { |
michael@0 | 1462 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
michael@0 | 1463 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
michael@0 | 1464 | INT32 z1, z2, z3, z4; |
michael@0 | 1465 | JCOEFPTR inptr; |
michael@0 | 1466 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 1467 | int * wsptr; |
michael@0 | 1468 | JSAMPROW outptr; |
michael@0 | 1469 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 1470 | int ctr; |
michael@0 | 1471 | int workspace[8*12]; /* buffers data between passes */ |
michael@0 | 1472 | SHIFT_TEMPS |
michael@0 | 1473 | |
michael@0 | 1474 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 1475 | |
michael@0 | 1476 | inptr = coef_block; |
michael@0 | 1477 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 1478 | wsptr = workspace; |
michael@0 | 1479 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 1480 | /* Even part */ |
michael@0 | 1481 | |
michael@0 | 1482 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 1483 | z3 <<= CONST_BITS; |
michael@0 | 1484 | /* Add fudge factor here for final descale. */ |
michael@0 | 1485 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 1486 | |
michael@0 | 1487 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 1488 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
michael@0 | 1489 | |
michael@0 | 1490 | tmp10 = z3 + z4; |
michael@0 | 1491 | tmp11 = z3 - z4; |
michael@0 | 1492 | |
michael@0 | 1493 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 1494 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
michael@0 | 1495 | z1 <<= CONST_BITS; |
michael@0 | 1496 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 1497 | z2 <<= CONST_BITS; |
michael@0 | 1498 | |
michael@0 | 1499 | tmp12 = z1 - z2; |
michael@0 | 1500 | |
michael@0 | 1501 | tmp21 = z3 + tmp12; |
michael@0 | 1502 | tmp24 = z3 - tmp12; |
michael@0 | 1503 | |
michael@0 | 1504 | tmp12 = z4 + z2; |
michael@0 | 1505 | |
michael@0 | 1506 | tmp20 = tmp10 + tmp12; |
michael@0 | 1507 | tmp25 = tmp10 - tmp12; |
michael@0 | 1508 | |
michael@0 | 1509 | tmp12 = z4 - z1 - z2; |
michael@0 | 1510 | |
michael@0 | 1511 | tmp22 = tmp11 + tmp12; |
michael@0 | 1512 | tmp23 = tmp11 - tmp12; |
michael@0 | 1513 | |
michael@0 | 1514 | /* Odd part */ |
michael@0 | 1515 | |
michael@0 | 1516 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 1517 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 1518 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 1519 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 1520 | |
michael@0 | 1521 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
michael@0 | 1522 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
michael@0 | 1523 | |
michael@0 | 1524 | tmp10 = z1 + z3; |
michael@0 | 1525 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
michael@0 | 1526 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
michael@0 | 1527 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
michael@0 | 1528 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
michael@0 | 1529 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
michael@0 | 1530 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
michael@0 | 1531 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
michael@0 | 1532 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
michael@0 | 1533 | |
michael@0 | 1534 | z1 -= z4; |
michael@0 | 1535 | z2 -= z3; |
michael@0 | 1536 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
michael@0 | 1537 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
michael@0 | 1538 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
michael@0 | 1539 | |
michael@0 | 1540 | /* Final output stage */ |
michael@0 | 1541 | |
michael@0 | 1542 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1543 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1544 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1545 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1546 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1547 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1548 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1549 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1550 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1551 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1552 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 1553 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 1554 | } |
michael@0 | 1555 | |
michael@0 | 1556 | /* Pass 2: process 12 rows from work array, store into output array. */ |
michael@0 | 1557 | |
michael@0 | 1558 | wsptr = workspace; |
michael@0 | 1559 | for (ctr = 0; ctr < 12; ctr++) { |
michael@0 | 1560 | outptr = output_buf[ctr] + output_col; |
michael@0 | 1561 | |
michael@0 | 1562 | /* Even part */ |
michael@0 | 1563 | |
michael@0 | 1564 | /* Add fudge factor here for final descale. */ |
michael@0 | 1565 | z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 1566 | z3 <<= CONST_BITS; |
michael@0 | 1567 | |
michael@0 | 1568 | z4 = (INT32) wsptr[4]; |
michael@0 | 1569 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
michael@0 | 1570 | |
michael@0 | 1571 | tmp10 = z3 + z4; |
michael@0 | 1572 | tmp11 = z3 - z4; |
michael@0 | 1573 | |
michael@0 | 1574 | z1 = (INT32) wsptr[2]; |
michael@0 | 1575 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
michael@0 | 1576 | z1 <<= CONST_BITS; |
michael@0 | 1577 | z2 = (INT32) wsptr[6]; |
michael@0 | 1578 | z2 <<= CONST_BITS; |
michael@0 | 1579 | |
michael@0 | 1580 | tmp12 = z1 - z2; |
michael@0 | 1581 | |
michael@0 | 1582 | tmp21 = z3 + tmp12; |
michael@0 | 1583 | tmp24 = z3 - tmp12; |
michael@0 | 1584 | |
michael@0 | 1585 | tmp12 = z4 + z2; |
michael@0 | 1586 | |
michael@0 | 1587 | tmp20 = tmp10 + tmp12; |
michael@0 | 1588 | tmp25 = tmp10 - tmp12; |
michael@0 | 1589 | |
michael@0 | 1590 | tmp12 = z4 - z1 - z2; |
michael@0 | 1591 | |
michael@0 | 1592 | tmp22 = tmp11 + tmp12; |
michael@0 | 1593 | tmp23 = tmp11 - tmp12; |
michael@0 | 1594 | |
michael@0 | 1595 | /* Odd part */ |
michael@0 | 1596 | |
michael@0 | 1597 | z1 = (INT32) wsptr[1]; |
michael@0 | 1598 | z2 = (INT32) wsptr[3]; |
michael@0 | 1599 | z3 = (INT32) wsptr[5]; |
michael@0 | 1600 | z4 = (INT32) wsptr[7]; |
michael@0 | 1601 | |
michael@0 | 1602 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
michael@0 | 1603 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
michael@0 | 1604 | |
michael@0 | 1605 | tmp10 = z1 + z3; |
michael@0 | 1606 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
michael@0 | 1607 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
michael@0 | 1608 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
michael@0 | 1609 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
michael@0 | 1610 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
michael@0 | 1611 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
michael@0 | 1612 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
michael@0 | 1613 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
michael@0 | 1614 | |
michael@0 | 1615 | z1 -= z4; |
michael@0 | 1616 | z2 -= z3; |
michael@0 | 1617 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
michael@0 | 1618 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
michael@0 | 1619 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
michael@0 | 1620 | |
michael@0 | 1621 | /* Final output stage */ |
michael@0 | 1622 | |
michael@0 | 1623 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 1624 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1625 | & RANGE_MASK]; |
michael@0 | 1626 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 1627 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1628 | & RANGE_MASK]; |
michael@0 | 1629 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 1630 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1631 | & RANGE_MASK]; |
michael@0 | 1632 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 1633 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1634 | & RANGE_MASK]; |
michael@0 | 1635 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 1636 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1637 | & RANGE_MASK]; |
michael@0 | 1638 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 1639 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1640 | & RANGE_MASK]; |
michael@0 | 1641 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 1642 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1643 | & RANGE_MASK]; |
michael@0 | 1644 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 1645 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1646 | & RANGE_MASK]; |
michael@0 | 1647 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 1648 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1649 | & RANGE_MASK]; |
michael@0 | 1650 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 1651 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1652 | & RANGE_MASK]; |
michael@0 | 1653 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
michael@0 | 1654 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1655 | & RANGE_MASK]; |
michael@0 | 1656 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
michael@0 | 1657 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1658 | & RANGE_MASK]; |
michael@0 | 1659 | |
michael@0 | 1660 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 1661 | } |
michael@0 | 1662 | } |
michael@0 | 1663 | |
michael@0 | 1664 | |
michael@0 | 1665 | /* |
michael@0 | 1666 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 1667 | * producing a 13x13 output block. |
michael@0 | 1668 | * |
michael@0 | 1669 | * Optimized algorithm with 29 multiplications in the 1-D kernel. |
michael@0 | 1670 | * cK represents sqrt(2) * cos(K*pi/26). |
michael@0 | 1671 | */ |
michael@0 | 1672 | |
michael@0 | 1673 | GLOBAL(void) |
michael@0 | 1674 | jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 1675 | JCOEFPTR coef_block, |
michael@0 | 1676 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 1677 | { |
michael@0 | 1678 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
michael@0 | 1679 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
michael@0 | 1680 | INT32 z1, z2, z3, z4; |
michael@0 | 1681 | JCOEFPTR inptr; |
michael@0 | 1682 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 1683 | int * wsptr; |
michael@0 | 1684 | JSAMPROW outptr; |
michael@0 | 1685 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 1686 | int ctr; |
michael@0 | 1687 | int workspace[8*13]; /* buffers data between passes */ |
michael@0 | 1688 | SHIFT_TEMPS |
michael@0 | 1689 | |
michael@0 | 1690 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 1691 | |
michael@0 | 1692 | inptr = coef_block; |
michael@0 | 1693 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 1694 | wsptr = workspace; |
michael@0 | 1695 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 1696 | /* Even part */ |
michael@0 | 1697 | |
michael@0 | 1698 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 1699 | z1 <<= CONST_BITS; |
michael@0 | 1700 | /* Add fudge factor here for final descale. */ |
michael@0 | 1701 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 1702 | |
michael@0 | 1703 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 1704 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 1705 | z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 1706 | |
michael@0 | 1707 | tmp10 = z3 + z4; |
michael@0 | 1708 | tmp11 = z3 - z4; |
michael@0 | 1709 | |
michael@0 | 1710 | tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ |
michael@0 | 1711 | tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ |
michael@0 | 1712 | |
michael@0 | 1713 | tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ |
michael@0 | 1714 | tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ |
michael@0 | 1715 | |
michael@0 | 1716 | tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ |
michael@0 | 1717 | tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ |
michael@0 | 1718 | |
michael@0 | 1719 | tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ |
michael@0 | 1720 | tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ |
michael@0 | 1721 | |
michael@0 | 1722 | tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ |
michael@0 | 1723 | tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ |
michael@0 | 1724 | |
michael@0 | 1725 | tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ |
michael@0 | 1726 | tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ |
michael@0 | 1727 | |
michael@0 | 1728 | tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ |
michael@0 | 1729 | |
michael@0 | 1730 | /* Odd part */ |
michael@0 | 1731 | |
michael@0 | 1732 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 1733 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 1734 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 1735 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 1736 | |
michael@0 | 1737 | tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ |
michael@0 | 1738 | tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ |
michael@0 | 1739 | tmp15 = z1 + z4; |
michael@0 | 1740 | tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ |
michael@0 | 1741 | tmp10 = tmp11 + tmp12 + tmp13 - |
michael@0 | 1742 | MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ |
michael@0 | 1743 | tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ |
michael@0 | 1744 | tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ |
michael@0 | 1745 | tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ |
michael@0 | 1746 | tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ |
michael@0 | 1747 | tmp11 += tmp14; |
michael@0 | 1748 | tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ |
michael@0 | 1749 | tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ |
michael@0 | 1750 | tmp12 += tmp14; |
michael@0 | 1751 | tmp13 += tmp14; |
michael@0 | 1752 | tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ |
michael@0 | 1753 | tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ |
michael@0 | 1754 | MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ |
michael@0 | 1755 | z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ |
michael@0 | 1756 | tmp14 += z1; |
michael@0 | 1757 | tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ |
michael@0 | 1758 | MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ |
michael@0 | 1759 | |
michael@0 | 1760 | /* Final output stage */ |
michael@0 | 1761 | |
michael@0 | 1762 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1763 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1764 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1765 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1766 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1767 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1768 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1769 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 1770 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1771 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1772 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 1773 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 1774 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26, CONST_BITS-PASS1_BITS); |
michael@0 | 1775 | } |
michael@0 | 1776 | |
michael@0 | 1777 | /* Pass 2: process 13 rows from work array, store into output array. */ |
michael@0 | 1778 | |
michael@0 | 1779 | wsptr = workspace; |
michael@0 | 1780 | for (ctr = 0; ctr < 13; ctr++) { |
michael@0 | 1781 | outptr = output_buf[ctr] + output_col; |
michael@0 | 1782 | |
michael@0 | 1783 | /* Even part */ |
michael@0 | 1784 | |
michael@0 | 1785 | /* Add fudge factor here for final descale. */ |
michael@0 | 1786 | z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 1787 | z1 <<= CONST_BITS; |
michael@0 | 1788 | |
michael@0 | 1789 | z2 = (INT32) wsptr[2]; |
michael@0 | 1790 | z3 = (INT32) wsptr[4]; |
michael@0 | 1791 | z4 = (INT32) wsptr[6]; |
michael@0 | 1792 | |
michael@0 | 1793 | tmp10 = z3 + z4; |
michael@0 | 1794 | tmp11 = z3 - z4; |
michael@0 | 1795 | |
michael@0 | 1796 | tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ |
michael@0 | 1797 | tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ |
michael@0 | 1798 | |
michael@0 | 1799 | tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ |
michael@0 | 1800 | tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ |
michael@0 | 1801 | |
michael@0 | 1802 | tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ |
michael@0 | 1803 | tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ |
michael@0 | 1804 | |
michael@0 | 1805 | tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ |
michael@0 | 1806 | tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ |
michael@0 | 1807 | |
michael@0 | 1808 | tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ |
michael@0 | 1809 | tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ |
michael@0 | 1810 | |
michael@0 | 1811 | tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ |
michael@0 | 1812 | tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ |
michael@0 | 1813 | |
michael@0 | 1814 | tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ |
michael@0 | 1815 | |
michael@0 | 1816 | /* Odd part */ |
michael@0 | 1817 | |
michael@0 | 1818 | z1 = (INT32) wsptr[1]; |
michael@0 | 1819 | z2 = (INT32) wsptr[3]; |
michael@0 | 1820 | z3 = (INT32) wsptr[5]; |
michael@0 | 1821 | z4 = (INT32) wsptr[7]; |
michael@0 | 1822 | |
michael@0 | 1823 | tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ |
michael@0 | 1824 | tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ |
michael@0 | 1825 | tmp15 = z1 + z4; |
michael@0 | 1826 | tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ |
michael@0 | 1827 | tmp10 = tmp11 + tmp12 + tmp13 - |
michael@0 | 1828 | MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ |
michael@0 | 1829 | tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ |
michael@0 | 1830 | tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ |
michael@0 | 1831 | tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ |
michael@0 | 1832 | tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ |
michael@0 | 1833 | tmp11 += tmp14; |
michael@0 | 1834 | tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ |
michael@0 | 1835 | tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ |
michael@0 | 1836 | tmp12 += tmp14; |
michael@0 | 1837 | tmp13 += tmp14; |
michael@0 | 1838 | tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ |
michael@0 | 1839 | tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ |
michael@0 | 1840 | MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ |
michael@0 | 1841 | z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ |
michael@0 | 1842 | tmp14 += z1; |
michael@0 | 1843 | tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ |
michael@0 | 1844 | MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ |
michael@0 | 1845 | |
michael@0 | 1846 | /* Final output stage */ |
michael@0 | 1847 | |
michael@0 | 1848 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 1849 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1850 | & RANGE_MASK]; |
michael@0 | 1851 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 1852 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1853 | & RANGE_MASK]; |
michael@0 | 1854 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 1855 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1856 | & RANGE_MASK]; |
michael@0 | 1857 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 1858 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1859 | & RANGE_MASK]; |
michael@0 | 1860 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 1861 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1862 | & RANGE_MASK]; |
michael@0 | 1863 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 1864 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1865 | & RANGE_MASK]; |
michael@0 | 1866 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 1867 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1868 | & RANGE_MASK]; |
michael@0 | 1869 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 1870 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1871 | & RANGE_MASK]; |
michael@0 | 1872 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 1873 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1874 | & RANGE_MASK]; |
michael@0 | 1875 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 1876 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1877 | & RANGE_MASK]; |
michael@0 | 1878 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
michael@0 | 1879 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1880 | & RANGE_MASK]; |
michael@0 | 1881 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
michael@0 | 1882 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1883 | & RANGE_MASK]; |
michael@0 | 1884 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26, |
michael@0 | 1885 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 1886 | & RANGE_MASK]; |
michael@0 | 1887 | |
michael@0 | 1888 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 1889 | } |
michael@0 | 1890 | } |
michael@0 | 1891 | |
michael@0 | 1892 | |
michael@0 | 1893 | /* |
michael@0 | 1894 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 1895 | * producing a 14x14 output block. |
michael@0 | 1896 | * |
michael@0 | 1897 | * Optimized algorithm with 20 multiplications in the 1-D kernel. |
michael@0 | 1898 | * cK represents sqrt(2) * cos(K*pi/28). |
michael@0 | 1899 | */ |
michael@0 | 1900 | |
michael@0 | 1901 | GLOBAL(void) |
michael@0 | 1902 | jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 1903 | JCOEFPTR coef_block, |
michael@0 | 1904 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 1905 | { |
michael@0 | 1906 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
michael@0 | 1907 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
michael@0 | 1908 | INT32 z1, z2, z3, z4; |
michael@0 | 1909 | JCOEFPTR inptr; |
michael@0 | 1910 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 1911 | int * wsptr; |
michael@0 | 1912 | JSAMPROW outptr; |
michael@0 | 1913 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 1914 | int ctr; |
michael@0 | 1915 | int workspace[8*14]; /* buffers data between passes */ |
michael@0 | 1916 | SHIFT_TEMPS |
michael@0 | 1917 | |
michael@0 | 1918 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 1919 | |
michael@0 | 1920 | inptr = coef_block; |
michael@0 | 1921 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 1922 | wsptr = workspace; |
michael@0 | 1923 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 1924 | /* Even part */ |
michael@0 | 1925 | |
michael@0 | 1926 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 1927 | z1 <<= CONST_BITS; |
michael@0 | 1928 | /* Add fudge factor here for final descale. */ |
michael@0 | 1929 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 1930 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 1931 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
michael@0 | 1932 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
michael@0 | 1933 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
michael@0 | 1934 | |
michael@0 | 1935 | tmp10 = z1 + z2; |
michael@0 | 1936 | tmp11 = z1 + z3; |
michael@0 | 1937 | tmp12 = z1 - z4; |
michael@0 | 1938 | |
michael@0 | 1939 | tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */ |
michael@0 | 1940 | CONST_BITS-PASS1_BITS); |
michael@0 | 1941 | |
michael@0 | 1942 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 1943 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 1944 | |
michael@0 | 1945 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
michael@0 | 1946 | |
michael@0 | 1947 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
michael@0 | 1948 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
michael@0 | 1949 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
michael@0 | 1950 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
michael@0 | 1951 | |
michael@0 | 1952 | tmp20 = tmp10 + tmp13; |
michael@0 | 1953 | tmp26 = tmp10 - tmp13; |
michael@0 | 1954 | tmp21 = tmp11 + tmp14; |
michael@0 | 1955 | tmp25 = tmp11 - tmp14; |
michael@0 | 1956 | tmp22 = tmp12 + tmp15; |
michael@0 | 1957 | tmp24 = tmp12 - tmp15; |
michael@0 | 1958 | |
michael@0 | 1959 | /* Odd part */ |
michael@0 | 1960 | |
michael@0 | 1961 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 1962 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 1963 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 1964 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 1965 | tmp13 = z4 << CONST_BITS; |
michael@0 | 1966 | |
michael@0 | 1967 | tmp14 = z1 + z3; |
michael@0 | 1968 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
michael@0 | 1969 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
michael@0 | 1970 | tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
michael@0 | 1971 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
michael@0 | 1972 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
michael@0 | 1973 | z1 -= z2; |
michael@0 | 1974 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */ |
michael@0 | 1975 | tmp16 += tmp15; |
michael@0 | 1976 | z1 += z4; |
michael@0 | 1977 | z4 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - tmp13; /* -c13 */ |
michael@0 | 1978 | tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
michael@0 | 1979 | tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
michael@0 | 1980 | z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
michael@0 | 1981 | tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
michael@0 | 1982 | tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
michael@0 | 1983 | |
michael@0 | 1984 | tmp13 = (z1 - z3) << PASS1_BITS; |
michael@0 | 1985 | |
michael@0 | 1986 | /* Final output stage */ |
michael@0 | 1987 | |
michael@0 | 1988 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1989 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 1990 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1991 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 1992 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1993 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 1994 | wsptr[8*3] = (int) (tmp23 + tmp13); |
michael@0 | 1995 | wsptr[8*10] = (int) (tmp23 - tmp13); |
michael@0 | 1996 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1997 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 1998 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 1999 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 2000 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); |
michael@0 | 2001 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); |
michael@0 | 2002 | } |
michael@0 | 2003 | |
michael@0 | 2004 | /* Pass 2: process 14 rows from work array, store into output array. */ |
michael@0 | 2005 | |
michael@0 | 2006 | wsptr = workspace; |
michael@0 | 2007 | for (ctr = 0; ctr < 14; ctr++) { |
michael@0 | 2008 | outptr = output_buf[ctr] + output_col; |
michael@0 | 2009 | |
michael@0 | 2010 | /* Even part */ |
michael@0 | 2011 | |
michael@0 | 2012 | /* Add fudge factor here for final descale. */ |
michael@0 | 2013 | z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 2014 | z1 <<= CONST_BITS; |
michael@0 | 2015 | z4 = (INT32) wsptr[4]; |
michael@0 | 2016 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
michael@0 | 2017 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
michael@0 | 2018 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
michael@0 | 2019 | |
michael@0 | 2020 | tmp10 = z1 + z2; |
michael@0 | 2021 | tmp11 = z1 + z3; |
michael@0 | 2022 | tmp12 = z1 - z4; |
michael@0 | 2023 | |
michael@0 | 2024 | tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */ |
michael@0 | 2025 | |
michael@0 | 2026 | z1 = (INT32) wsptr[2]; |
michael@0 | 2027 | z2 = (INT32) wsptr[6]; |
michael@0 | 2028 | |
michael@0 | 2029 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
michael@0 | 2030 | |
michael@0 | 2031 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
michael@0 | 2032 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
michael@0 | 2033 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
michael@0 | 2034 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
michael@0 | 2035 | |
michael@0 | 2036 | tmp20 = tmp10 + tmp13; |
michael@0 | 2037 | tmp26 = tmp10 - tmp13; |
michael@0 | 2038 | tmp21 = tmp11 + tmp14; |
michael@0 | 2039 | tmp25 = tmp11 - tmp14; |
michael@0 | 2040 | tmp22 = tmp12 + tmp15; |
michael@0 | 2041 | tmp24 = tmp12 - tmp15; |
michael@0 | 2042 | |
michael@0 | 2043 | /* Odd part */ |
michael@0 | 2044 | |
michael@0 | 2045 | z1 = (INT32) wsptr[1]; |
michael@0 | 2046 | z2 = (INT32) wsptr[3]; |
michael@0 | 2047 | z3 = (INT32) wsptr[5]; |
michael@0 | 2048 | z4 = (INT32) wsptr[7]; |
michael@0 | 2049 | z4 <<= CONST_BITS; |
michael@0 | 2050 | |
michael@0 | 2051 | tmp14 = z1 + z3; |
michael@0 | 2052 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
michael@0 | 2053 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
michael@0 | 2054 | tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
michael@0 | 2055 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
michael@0 | 2056 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
michael@0 | 2057 | z1 -= z2; |
michael@0 | 2058 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */ |
michael@0 | 2059 | tmp16 += tmp15; |
michael@0 | 2060 | tmp13 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - z4; /* -c13 */ |
michael@0 | 2061 | tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
michael@0 | 2062 | tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
michael@0 | 2063 | tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
michael@0 | 2064 | tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
michael@0 | 2065 | tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
michael@0 | 2066 | |
michael@0 | 2067 | tmp13 = ((z1 - z3) << CONST_BITS) + z4; |
michael@0 | 2068 | |
michael@0 | 2069 | /* Final output stage */ |
michael@0 | 2070 | |
michael@0 | 2071 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 2072 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2073 | & RANGE_MASK]; |
michael@0 | 2074 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 2075 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2076 | & RANGE_MASK]; |
michael@0 | 2077 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 2078 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2079 | & RANGE_MASK]; |
michael@0 | 2080 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 2081 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2082 | & RANGE_MASK]; |
michael@0 | 2083 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 2084 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2085 | & RANGE_MASK]; |
michael@0 | 2086 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 2087 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2088 | & RANGE_MASK]; |
michael@0 | 2089 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 2090 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2091 | & RANGE_MASK]; |
michael@0 | 2092 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 2093 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2094 | & RANGE_MASK]; |
michael@0 | 2095 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 2096 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2097 | & RANGE_MASK]; |
michael@0 | 2098 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 2099 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2100 | & RANGE_MASK]; |
michael@0 | 2101 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
michael@0 | 2102 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2103 | & RANGE_MASK]; |
michael@0 | 2104 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
michael@0 | 2105 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2106 | & RANGE_MASK]; |
michael@0 | 2107 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, |
michael@0 | 2108 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2109 | & RANGE_MASK]; |
michael@0 | 2110 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, |
michael@0 | 2111 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2112 | & RANGE_MASK]; |
michael@0 | 2113 | |
michael@0 | 2114 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 2115 | } |
michael@0 | 2116 | } |
michael@0 | 2117 | |
michael@0 | 2118 | |
michael@0 | 2119 | /* |
michael@0 | 2120 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 2121 | * producing a 15x15 output block. |
michael@0 | 2122 | * |
michael@0 | 2123 | * Optimized algorithm with 22 multiplications in the 1-D kernel. |
michael@0 | 2124 | * cK represents sqrt(2) * cos(K*pi/30). |
michael@0 | 2125 | */ |
michael@0 | 2126 | |
michael@0 | 2127 | GLOBAL(void) |
michael@0 | 2128 | jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 2129 | JCOEFPTR coef_block, |
michael@0 | 2130 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 2131 | { |
michael@0 | 2132 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
michael@0 | 2133 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
michael@0 | 2134 | INT32 z1, z2, z3, z4; |
michael@0 | 2135 | JCOEFPTR inptr; |
michael@0 | 2136 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 2137 | int * wsptr; |
michael@0 | 2138 | JSAMPROW outptr; |
michael@0 | 2139 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 2140 | int ctr; |
michael@0 | 2141 | int workspace[8*15]; /* buffers data between passes */ |
michael@0 | 2142 | SHIFT_TEMPS |
michael@0 | 2143 | |
michael@0 | 2144 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 2145 | |
michael@0 | 2146 | inptr = coef_block; |
michael@0 | 2147 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 2148 | wsptr = workspace; |
michael@0 | 2149 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 2150 | /* Even part */ |
michael@0 | 2151 | |
michael@0 | 2152 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 2153 | z1 <<= CONST_BITS; |
michael@0 | 2154 | /* Add fudge factor here for final descale. */ |
michael@0 | 2155 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 2156 | |
michael@0 | 2157 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 2158 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 2159 | z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 2160 | |
michael@0 | 2161 | tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ |
michael@0 | 2162 | tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ |
michael@0 | 2163 | |
michael@0 | 2164 | tmp12 = z1 - tmp10; |
michael@0 | 2165 | tmp13 = z1 + tmp11; |
michael@0 | 2166 | z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ |
michael@0 | 2167 | |
michael@0 | 2168 | z4 = z2 - z3; |
michael@0 | 2169 | z3 += z2; |
michael@0 | 2170 | tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ |
michael@0 | 2171 | tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ |
michael@0 | 2172 | z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ |
michael@0 | 2173 | |
michael@0 | 2174 | tmp20 = tmp13 + tmp10 + tmp11; |
michael@0 | 2175 | tmp23 = tmp12 - tmp10 + tmp11 + z2; |
michael@0 | 2176 | |
michael@0 | 2177 | tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ |
michael@0 | 2178 | tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ |
michael@0 | 2179 | |
michael@0 | 2180 | tmp25 = tmp13 - tmp10 - tmp11; |
michael@0 | 2181 | tmp26 = tmp12 + tmp10 - tmp11 - z2; |
michael@0 | 2182 | |
michael@0 | 2183 | tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ |
michael@0 | 2184 | tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ |
michael@0 | 2185 | |
michael@0 | 2186 | tmp21 = tmp12 + tmp10 + tmp11; |
michael@0 | 2187 | tmp24 = tmp13 - tmp10 + tmp11; |
michael@0 | 2188 | tmp11 += tmp11; |
michael@0 | 2189 | tmp22 = z1 + tmp11; /* c10 = c6-c12 */ |
michael@0 | 2190 | tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ |
michael@0 | 2191 | |
michael@0 | 2192 | /* Odd part */ |
michael@0 | 2193 | |
michael@0 | 2194 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 2195 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 2196 | z4 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 2197 | z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ |
michael@0 | 2198 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 2199 | |
michael@0 | 2200 | tmp13 = z2 - z4; |
michael@0 | 2201 | tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ |
michael@0 | 2202 | tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ |
michael@0 | 2203 | tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ |
michael@0 | 2204 | |
michael@0 | 2205 | tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ |
michael@0 | 2206 | tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ |
michael@0 | 2207 | z2 = z1 - z4; |
michael@0 | 2208 | tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ |
michael@0 | 2209 | |
michael@0 | 2210 | tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ |
michael@0 | 2211 | tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ |
michael@0 | 2212 | tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ |
michael@0 | 2213 | z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ |
michael@0 | 2214 | tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ |
michael@0 | 2215 | tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ |
michael@0 | 2216 | |
michael@0 | 2217 | /* Final output stage */ |
michael@0 | 2218 | |
michael@0 | 2219 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 2220 | wsptr[8*14] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 2221 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 2222 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 2223 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 2224 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 2225 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 2226 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 2227 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 2228 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
michael@0 | 2229 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 2230 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
michael@0 | 2231 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); |
michael@0 | 2232 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); |
michael@0 | 2233 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27, CONST_BITS-PASS1_BITS); |
michael@0 | 2234 | } |
michael@0 | 2235 | |
michael@0 | 2236 | /* Pass 2: process 15 rows from work array, store into output array. */ |
michael@0 | 2237 | |
michael@0 | 2238 | wsptr = workspace; |
michael@0 | 2239 | for (ctr = 0; ctr < 15; ctr++) { |
michael@0 | 2240 | outptr = output_buf[ctr] + output_col; |
michael@0 | 2241 | |
michael@0 | 2242 | /* Even part */ |
michael@0 | 2243 | |
michael@0 | 2244 | /* Add fudge factor here for final descale. */ |
michael@0 | 2245 | z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 2246 | z1 <<= CONST_BITS; |
michael@0 | 2247 | |
michael@0 | 2248 | z2 = (INT32) wsptr[2]; |
michael@0 | 2249 | z3 = (INT32) wsptr[4]; |
michael@0 | 2250 | z4 = (INT32) wsptr[6]; |
michael@0 | 2251 | |
michael@0 | 2252 | tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ |
michael@0 | 2253 | tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ |
michael@0 | 2254 | |
michael@0 | 2255 | tmp12 = z1 - tmp10; |
michael@0 | 2256 | tmp13 = z1 + tmp11; |
michael@0 | 2257 | z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ |
michael@0 | 2258 | |
michael@0 | 2259 | z4 = z2 - z3; |
michael@0 | 2260 | z3 += z2; |
michael@0 | 2261 | tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ |
michael@0 | 2262 | tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ |
michael@0 | 2263 | z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ |
michael@0 | 2264 | |
michael@0 | 2265 | tmp20 = tmp13 + tmp10 + tmp11; |
michael@0 | 2266 | tmp23 = tmp12 - tmp10 + tmp11 + z2; |
michael@0 | 2267 | |
michael@0 | 2268 | tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ |
michael@0 | 2269 | tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ |
michael@0 | 2270 | |
michael@0 | 2271 | tmp25 = tmp13 - tmp10 - tmp11; |
michael@0 | 2272 | tmp26 = tmp12 + tmp10 - tmp11 - z2; |
michael@0 | 2273 | |
michael@0 | 2274 | tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ |
michael@0 | 2275 | tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ |
michael@0 | 2276 | |
michael@0 | 2277 | tmp21 = tmp12 + tmp10 + tmp11; |
michael@0 | 2278 | tmp24 = tmp13 - tmp10 + tmp11; |
michael@0 | 2279 | tmp11 += tmp11; |
michael@0 | 2280 | tmp22 = z1 + tmp11; /* c10 = c6-c12 */ |
michael@0 | 2281 | tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ |
michael@0 | 2282 | |
michael@0 | 2283 | /* Odd part */ |
michael@0 | 2284 | |
michael@0 | 2285 | z1 = (INT32) wsptr[1]; |
michael@0 | 2286 | z2 = (INT32) wsptr[3]; |
michael@0 | 2287 | z4 = (INT32) wsptr[5]; |
michael@0 | 2288 | z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ |
michael@0 | 2289 | z4 = (INT32) wsptr[7]; |
michael@0 | 2290 | |
michael@0 | 2291 | tmp13 = z2 - z4; |
michael@0 | 2292 | tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ |
michael@0 | 2293 | tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ |
michael@0 | 2294 | tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ |
michael@0 | 2295 | |
michael@0 | 2296 | tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ |
michael@0 | 2297 | tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ |
michael@0 | 2298 | z2 = z1 - z4; |
michael@0 | 2299 | tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ |
michael@0 | 2300 | |
michael@0 | 2301 | tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ |
michael@0 | 2302 | tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ |
michael@0 | 2303 | tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ |
michael@0 | 2304 | z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ |
michael@0 | 2305 | tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ |
michael@0 | 2306 | tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ |
michael@0 | 2307 | |
michael@0 | 2308 | /* Final output stage */ |
michael@0 | 2309 | |
michael@0 | 2310 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
michael@0 | 2311 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2312 | & RANGE_MASK]; |
michael@0 | 2313 | outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
michael@0 | 2314 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2315 | & RANGE_MASK]; |
michael@0 | 2316 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
michael@0 | 2317 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2318 | & RANGE_MASK]; |
michael@0 | 2319 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
michael@0 | 2320 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2321 | & RANGE_MASK]; |
michael@0 | 2322 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
michael@0 | 2323 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2324 | & RANGE_MASK]; |
michael@0 | 2325 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
michael@0 | 2326 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2327 | & RANGE_MASK]; |
michael@0 | 2328 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
michael@0 | 2329 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2330 | & RANGE_MASK]; |
michael@0 | 2331 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
michael@0 | 2332 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2333 | & RANGE_MASK]; |
michael@0 | 2334 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
michael@0 | 2335 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2336 | & RANGE_MASK]; |
michael@0 | 2337 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
michael@0 | 2338 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2339 | & RANGE_MASK]; |
michael@0 | 2340 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
michael@0 | 2341 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2342 | & RANGE_MASK]; |
michael@0 | 2343 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
michael@0 | 2344 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2345 | & RANGE_MASK]; |
michael@0 | 2346 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, |
michael@0 | 2347 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2348 | & RANGE_MASK]; |
michael@0 | 2349 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, |
michael@0 | 2350 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2351 | & RANGE_MASK]; |
michael@0 | 2352 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27, |
michael@0 | 2353 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2354 | & RANGE_MASK]; |
michael@0 | 2355 | |
michael@0 | 2356 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 2357 | } |
michael@0 | 2358 | } |
michael@0 | 2359 | |
michael@0 | 2360 | |
michael@0 | 2361 | /* |
michael@0 | 2362 | * Perform dequantization and inverse DCT on one block of coefficients, |
michael@0 | 2363 | * producing a 16x16 output block. |
michael@0 | 2364 | * |
michael@0 | 2365 | * Optimized algorithm with 28 multiplications in the 1-D kernel. |
michael@0 | 2366 | * cK represents sqrt(2) * cos(K*pi/32). |
michael@0 | 2367 | */ |
michael@0 | 2368 | |
michael@0 | 2369 | GLOBAL(void) |
michael@0 | 2370 | jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
michael@0 | 2371 | JCOEFPTR coef_block, |
michael@0 | 2372 | JSAMPARRAY output_buf, JDIMENSION output_col) |
michael@0 | 2373 | { |
michael@0 | 2374 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
michael@0 | 2375 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
michael@0 | 2376 | INT32 z1, z2, z3, z4; |
michael@0 | 2377 | JCOEFPTR inptr; |
michael@0 | 2378 | ISLOW_MULT_TYPE * quantptr; |
michael@0 | 2379 | int * wsptr; |
michael@0 | 2380 | JSAMPROW outptr; |
michael@0 | 2381 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
michael@0 | 2382 | int ctr; |
michael@0 | 2383 | int workspace[8*16]; /* buffers data between passes */ |
michael@0 | 2384 | SHIFT_TEMPS |
michael@0 | 2385 | |
michael@0 | 2386 | /* Pass 1: process columns from input, store into work array. */ |
michael@0 | 2387 | |
michael@0 | 2388 | inptr = coef_block; |
michael@0 | 2389 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
michael@0 | 2390 | wsptr = workspace; |
michael@0 | 2391 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
michael@0 | 2392 | /* Even part */ |
michael@0 | 2393 | |
michael@0 | 2394 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
michael@0 | 2395 | tmp0 <<= CONST_BITS; |
michael@0 | 2396 | /* Add fudge factor here for final descale. */ |
michael@0 | 2397 | tmp0 += 1 << (CONST_BITS-PASS1_BITS-1); |
michael@0 | 2398 | |
michael@0 | 2399 | z1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
michael@0 | 2400 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
michael@0 | 2401 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
michael@0 | 2402 | |
michael@0 | 2403 | tmp10 = tmp0 + tmp1; |
michael@0 | 2404 | tmp11 = tmp0 - tmp1; |
michael@0 | 2405 | tmp12 = tmp0 + tmp2; |
michael@0 | 2406 | tmp13 = tmp0 - tmp2; |
michael@0 | 2407 | |
michael@0 | 2408 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
michael@0 | 2409 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
michael@0 | 2410 | z3 = z1 - z2; |
michael@0 | 2411 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
michael@0 | 2412 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
michael@0 | 2413 | |
michael@0 | 2414 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
michael@0 | 2415 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
michael@0 | 2416 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
michael@0 | 2417 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
michael@0 | 2418 | |
michael@0 | 2419 | tmp20 = tmp10 + tmp0; |
michael@0 | 2420 | tmp27 = tmp10 - tmp0; |
michael@0 | 2421 | tmp21 = tmp12 + tmp1; |
michael@0 | 2422 | tmp26 = tmp12 - tmp1; |
michael@0 | 2423 | tmp22 = tmp13 + tmp2; |
michael@0 | 2424 | tmp25 = tmp13 - tmp2; |
michael@0 | 2425 | tmp23 = tmp11 + tmp3; |
michael@0 | 2426 | tmp24 = tmp11 - tmp3; |
michael@0 | 2427 | |
michael@0 | 2428 | /* Odd part */ |
michael@0 | 2429 | |
michael@0 | 2430 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
michael@0 | 2431 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
michael@0 | 2432 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
michael@0 | 2433 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
michael@0 | 2434 | |
michael@0 | 2435 | tmp11 = z1 + z3; |
michael@0 | 2436 | |
michael@0 | 2437 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
michael@0 | 2438 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
michael@0 | 2439 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
michael@0 | 2440 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
michael@0 | 2441 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
michael@0 | 2442 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
michael@0 | 2443 | tmp0 = tmp1 + tmp2 + tmp3 - |
michael@0 | 2444 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
michael@0 | 2445 | tmp13 = tmp10 + tmp11 + tmp12 - |
michael@0 | 2446 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
michael@0 | 2447 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
michael@0 | 2448 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
michael@0 | 2449 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
michael@0 | 2450 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
michael@0 | 2451 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
michael@0 | 2452 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
michael@0 | 2453 | z2 += z4; |
michael@0 | 2454 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
michael@0 | 2455 | tmp1 += z1; |
michael@0 | 2456 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
michael@0 | 2457 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
michael@0 | 2458 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
michael@0 | 2459 | tmp12 += z2; |
michael@0 | 2460 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
michael@0 | 2461 | tmp2 += z2; |
michael@0 | 2462 | tmp3 += z2; |
michael@0 | 2463 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
michael@0 | 2464 | tmp10 += z2; |
michael@0 | 2465 | tmp11 += z2; |
michael@0 | 2466 | |
michael@0 | 2467 | /* Final output stage */ |
michael@0 | 2468 | |
michael@0 | 2469 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 2470 | wsptr[8*15] = (int) RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS-PASS1_BITS); |
michael@0 | 2471 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 2472 | wsptr[8*14] = (int) RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS-PASS1_BITS); |
michael@0 | 2473 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 2474 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS-PASS1_BITS); |
michael@0 | 2475 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 2476 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS-PASS1_BITS); |
michael@0 | 2477 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 2478 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS-PASS1_BITS); |
michael@0 | 2479 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 2480 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS-PASS1_BITS); |
michael@0 | 2481 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 2482 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS-PASS1_BITS); |
michael@0 | 2483 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 2484 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); |
michael@0 | 2485 | } |
michael@0 | 2486 | |
michael@0 | 2487 | /* Pass 2: process 16 rows from work array, store into output array. */ |
michael@0 | 2488 | |
michael@0 | 2489 | wsptr = workspace; |
michael@0 | 2490 | for (ctr = 0; ctr < 16; ctr++) { |
michael@0 | 2491 | outptr = output_buf[ctr] + output_col; |
michael@0 | 2492 | |
michael@0 | 2493 | /* Even part */ |
michael@0 | 2494 | |
michael@0 | 2495 | /* Add fudge factor here for final descale. */ |
michael@0 | 2496 | tmp0 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
michael@0 | 2497 | tmp0 <<= CONST_BITS; |
michael@0 | 2498 | |
michael@0 | 2499 | z1 = (INT32) wsptr[4]; |
michael@0 | 2500 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
michael@0 | 2501 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
michael@0 | 2502 | |
michael@0 | 2503 | tmp10 = tmp0 + tmp1; |
michael@0 | 2504 | tmp11 = tmp0 - tmp1; |
michael@0 | 2505 | tmp12 = tmp0 + tmp2; |
michael@0 | 2506 | tmp13 = tmp0 - tmp2; |
michael@0 | 2507 | |
michael@0 | 2508 | z1 = (INT32) wsptr[2]; |
michael@0 | 2509 | z2 = (INT32) wsptr[6]; |
michael@0 | 2510 | z3 = z1 - z2; |
michael@0 | 2511 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
michael@0 | 2512 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
michael@0 | 2513 | |
michael@0 | 2514 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
michael@0 | 2515 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
michael@0 | 2516 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
michael@0 | 2517 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
michael@0 | 2518 | |
michael@0 | 2519 | tmp20 = tmp10 + tmp0; |
michael@0 | 2520 | tmp27 = tmp10 - tmp0; |
michael@0 | 2521 | tmp21 = tmp12 + tmp1; |
michael@0 | 2522 | tmp26 = tmp12 - tmp1; |
michael@0 | 2523 | tmp22 = tmp13 + tmp2; |
michael@0 | 2524 | tmp25 = tmp13 - tmp2; |
michael@0 | 2525 | tmp23 = tmp11 + tmp3; |
michael@0 | 2526 | tmp24 = tmp11 - tmp3; |
michael@0 | 2527 | |
michael@0 | 2528 | /* Odd part */ |
michael@0 | 2529 | |
michael@0 | 2530 | z1 = (INT32) wsptr[1]; |
michael@0 | 2531 | z2 = (INT32) wsptr[3]; |
michael@0 | 2532 | z3 = (INT32) wsptr[5]; |
michael@0 | 2533 | z4 = (INT32) wsptr[7]; |
michael@0 | 2534 | |
michael@0 | 2535 | tmp11 = z1 + z3; |
michael@0 | 2536 | |
michael@0 | 2537 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
michael@0 | 2538 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
michael@0 | 2539 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
michael@0 | 2540 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
michael@0 | 2541 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
michael@0 | 2542 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
michael@0 | 2543 | tmp0 = tmp1 + tmp2 + tmp3 - |
michael@0 | 2544 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
michael@0 | 2545 | tmp13 = tmp10 + tmp11 + tmp12 - |
michael@0 | 2546 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
michael@0 | 2547 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
michael@0 | 2548 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
michael@0 | 2549 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
michael@0 | 2550 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
michael@0 | 2551 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
michael@0 | 2552 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
michael@0 | 2553 | z2 += z4; |
michael@0 | 2554 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
michael@0 | 2555 | tmp1 += z1; |
michael@0 | 2556 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
michael@0 | 2557 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
michael@0 | 2558 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
michael@0 | 2559 | tmp12 += z2; |
michael@0 | 2560 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
michael@0 | 2561 | tmp2 += z2; |
michael@0 | 2562 | tmp3 += z2; |
michael@0 | 2563 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
michael@0 | 2564 | tmp10 += z2; |
michael@0 | 2565 | tmp11 += z2; |
michael@0 | 2566 | |
michael@0 | 2567 | /* Final output stage */ |
michael@0 | 2568 | |
michael@0 | 2569 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp0, |
michael@0 | 2570 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2571 | & RANGE_MASK]; |
michael@0 | 2572 | outptr[15] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp0, |
michael@0 | 2573 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2574 | & RANGE_MASK]; |
michael@0 | 2575 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp1, |
michael@0 | 2576 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2577 | & RANGE_MASK]; |
michael@0 | 2578 | outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp1, |
michael@0 | 2579 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2580 | & RANGE_MASK]; |
michael@0 | 2581 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp2, |
michael@0 | 2582 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2583 | & RANGE_MASK]; |
michael@0 | 2584 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp2, |
michael@0 | 2585 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2586 | & RANGE_MASK]; |
michael@0 | 2587 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp3, |
michael@0 | 2588 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2589 | & RANGE_MASK]; |
michael@0 | 2590 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp3, |
michael@0 | 2591 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2592 | & RANGE_MASK]; |
michael@0 | 2593 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp10, |
michael@0 | 2594 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2595 | & RANGE_MASK]; |
michael@0 | 2596 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp10, |
michael@0 | 2597 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2598 | & RANGE_MASK]; |
michael@0 | 2599 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp11, |
michael@0 | 2600 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2601 | & RANGE_MASK]; |
michael@0 | 2602 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp11, |
michael@0 | 2603 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2604 | & RANGE_MASK]; |
michael@0 | 2605 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp12, |
michael@0 | 2606 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2607 | & RANGE_MASK]; |
michael@0 | 2608 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp12, |
michael@0 | 2609 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2610 | & RANGE_MASK]; |
michael@0 | 2611 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27 + tmp13, |
michael@0 | 2612 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2613 | & RANGE_MASK]; |
michael@0 | 2614 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp27 - tmp13, |
michael@0 | 2615 | CONST_BITS+PASS1_BITS+3) |
michael@0 | 2616 | & RANGE_MASK]; |
michael@0 | 2617 | |
michael@0 | 2618 | wsptr += 8; /* advance pointer to next row */ |
michael@0 | 2619 | } |
michael@0 | 2620 | } |
michael@0 | 2621 | |
michael@0 | 2622 | #endif /* IDCT_SCALING_SUPPORTED */ |
michael@0 | 2623 | #endif /* DCT_ISLOW_SUPPORTED */ |