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