4 * Copyright (C) 1991-1998, Thomas G. Lane.
5 * Modification developed 2002-2015 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.
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.
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.
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.
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.
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.
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.
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.
51 #define JPEG_INTERNALS
54 #include "jdct.h" /* Private declarations for DCT subsystem */
56 #ifdef DCT_ISLOW_SUPPORTED
60 * This module is specialized to the case DCTSIZE = 8.
64 Sorry
, this code only copes with
8x8 DCT blocks
. /* deliberate syntax err */
69 * The poop on this scaling stuff is as follows:
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).
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.
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.)
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.
100 #if BITS_IN_JSAMPLE == 8
101 #define CONST_BITS 13
104 #define CONST_BITS 13
105 #define PASS1_BITS 1 /* lose a little precision to avoid overflow */
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...)
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) */
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)
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.
151 #if BITS_IN_JSAMPLE == 8
152 #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
154 #define MULTIPLY(var,const) ((var) * (const))
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.
163 #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
167 * Perform dequantization and inverse DCT on one block of coefficients.
169 * cK represents sqrt(2) * cos(K*pi/16).
173 jpeg_idct_islow (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
175 JSAMPARRAY output_buf
, JDIMENSION output_col
)
177 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
178 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
181 ISLOW_MULT_TYPE
* quantptr
;
184 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
186 int workspace
[DCTSIZE2
]; /* buffers data between passes */
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.
195 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
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.
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
;
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
;
223 inptr
++; /* advance pointers to next column */
229 /* Even part: reverse the even part of the forward DCT.
230 * The rotator is c(-6).
233 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
234 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
237 /* Add fudge factor here for final descale. */
238 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
243 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
244 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
246 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
247 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
248 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
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.
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]);
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 */
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 */
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 */
285 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
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
);
296 inptr
++; /* advance pointers to next column */
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.
307 for (ctr
= 0; ctr
< DCTSIZE
; ctr
++) {
308 outptr
= output_buf
[ctr
] + output_col
;
310 /* Add range center and fudge factor for final descale and range-limit. */
311 z2
= (INT32
) wsptr
[0] +
312 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
313 (ONE
<< (PASS1_BITS
+2)));
315 /* Rows of zeroes can be exploited in the same way as we did with columns.
316 * However, the column calculation has created many nonzero AC terms, so
317 * the simplification applies less often (typically 5% to 10% of the time).
318 * On machines with very fast multiplication, it's possible that the
319 * test takes more time than it's worth. In that case this section
320 * may be commented out.
323 #ifndef NO_ZERO_ROW_TEST
324 if (wsptr
[1] == 0 && wsptr
[2] == 0 && wsptr
[3] == 0 && wsptr
[4] == 0 &&
325 wsptr
[5] == 0 && wsptr
[6] == 0 && wsptr
[7] == 0) {
326 /* AC terms all zero */
327 JSAMPLE dcval
= range_limit
[(int) RIGHT_SHIFT(z2
, PASS1_BITS
+3)
339 wsptr
+= DCTSIZE
; /* advance pointer to next row */
344 /* Even part: reverse the even part of the forward DCT.
345 * The rotator is c(-6).
348 z3
= (INT32
) wsptr
[4];
350 tmp0
= (z2
+ z3
) << CONST_BITS
;
351 tmp1
= (z2
- z3
) << CONST_BITS
;
353 z2
= (INT32
) wsptr
[2];
354 z3
= (INT32
) wsptr
[6];
356 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
357 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
358 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
365 /* Odd part per figure 8; the matrix is unitary and hence its
366 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
369 tmp0
= (INT32
) wsptr
[7];
370 tmp1
= (INT32
) wsptr
[5];
371 tmp2
= (INT32
) wsptr
[3];
372 tmp3
= (INT32
) wsptr
[1];
377 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* c3 */
378 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* -c3-c5 */
379 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* -c3+c5 */
383 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* -c3+c7 */
384 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* -c1+c3+c5-c7 */
385 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* c1+c3-c5-c7 */
389 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* -c1-c3 */
390 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* c1+c3-c5+c7 */
391 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* c1+c3+c5-c7 */
395 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
397 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
398 CONST_BITS
+PASS1_BITS
+3)
400 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
401 CONST_BITS
+PASS1_BITS
+3)
403 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
404 CONST_BITS
+PASS1_BITS
+3)
406 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
407 CONST_BITS
+PASS1_BITS
+3)
409 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
410 CONST_BITS
+PASS1_BITS
+3)
412 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
413 CONST_BITS
+PASS1_BITS
+3)
415 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
416 CONST_BITS
+PASS1_BITS
+3)
418 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
419 CONST_BITS
+PASS1_BITS
+3)
422 wsptr
+= DCTSIZE
; /* advance pointer to next row */
426 #ifdef IDCT_SCALING_SUPPORTED
430 * Perform dequantization and inverse DCT on one block of coefficients,
431 * producing a 7x7 output block.
433 * Optimized algorithm with 12 multiplications in the 1-D kernel.
434 * cK represents sqrt(2) * cos(K*pi/14).
438 jpeg_idct_7x7 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
440 JSAMPARRAY output_buf
, JDIMENSION output_col
)
442 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
, tmp13
;
445 ISLOW_MULT_TYPE
* quantptr
;
448 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
450 int workspace
[7*7]; /* buffers data between passes */
453 /* Pass 1: process columns from input, store into work array. */
456 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
458 for (ctr
= 0; ctr
< 7; ctr
++, inptr
++, quantptr
++, wsptr
++) {
461 tmp13
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
462 tmp13
<<= CONST_BITS
;
463 /* Add fudge factor here for final descale. */
464 tmp13
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
466 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
467 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
468 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
470 tmp10
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
471 tmp12
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
472 tmp11
= tmp10
+ tmp12
+ tmp13
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
475 tmp0
= MULTIPLY(tmp0
, FIX(1.274162392)) + tmp13
; /* c2 */
476 tmp10
+= tmp0
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
477 tmp12
+= tmp0
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
478 tmp13
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
482 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
483 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
484 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
486 tmp1
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
487 tmp2
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
490 tmp2
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
492 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
494 tmp2
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
496 /* Final output stage */
498 wsptr
[7*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
499 wsptr
[7*6] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
500 wsptr
[7*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
501 wsptr
[7*5] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
502 wsptr
[7*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
503 wsptr
[7*4] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
504 wsptr
[7*3] = (int) RIGHT_SHIFT(tmp13
, CONST_BITS
-PASS1_BITS
);
507 /* Pass 2: process 7 rows from work array, store into output array. */
510 for (ctr
= 0; ctr
< 7; ctr
++) {
511 outptr
= output_buf
[ctr
] + output_col
;
515 /* Add range center and fudge factor for final descale and range-limit. */
516 tmp13
= (INT32
) wsptr
[0] +
517 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
518 (ONE
<< (PASS1_BITS
+2)));
519 tmp13
<<= CONST_BITS
;
521 z1
= (INT32
) wsptr
[2];
522 z2
= (INT32
) wsptr
[4];
523 z3
= (INT32
) wsptr
[6];
525 tmp10
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
526 tmp12
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
527 tmp11
= tmp10
+ tmp12
+ tmp13
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
530 tmp0
= MULTIPLY(tmp0
, FIX(1.274162392)) + tmp13
; /* c2 */
531 tmp10
+= tmp0
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
532 tmp12
+= tmp0
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
533 tmp13
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
537 z1
= (INT32
) wsptr
[1];
538 z2
= (INT32
) wsptr
[3];
539 z3
= (INT32
) wsptr
[5];
541 tmp1
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
542 tmp2
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
545 tmp2
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
547 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
549 tmp2
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
551 /* Final output stage */
553 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
554 CONST_BITS
+PASS1_BITS
+3)
556 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
557 CONST_BITS
+PASS1_BITS
+3)
559 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
560 CONST_BITS
+PASS1_BITS
+3)
562 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
563 CONST_BITS
+PASS1_BITS
+3)
565 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
566 CONST_BITS
+PASS1_BITS
+3)
568 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
569 CONST_BITS
+PASS1_BITS
+3)
571 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
,
572 CONST_BITS
+PASS1_BITS
+3)
575 wsptr
+= 7; /* advance pointer to next row */
581 * Perform dequantization and inverse DCT on one block of coefficients,
582 * producing a reduced-size 6x6 output block.
584 * Optimized algorithm with 3 multiplications in the 1-D kernel.
585 * cK represents sqrt(2) * cos(K*pi/12).
589 jpeg_idct_6x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
591 JSAMPARRAY output_buf
, JDIMENSION output_col
)
593 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
596 ISLOW_MULT_TYPE
* quantptr
;
599 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
601 int workspace
[6*6]; /* buffers data between passes */
604 /* Pass 1: process columns from input, store into work array. */
607 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
609 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
612 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
614 /* Add fudge factor here for final descale. */
615 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
616 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
617 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
619 tmp11
= RIGHT_SHIFT(tmp0
- tmp10
- tmp10
, CONST_BITS
-PASS1_BITS
);
620 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
621 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
627 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
628 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
629 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
630 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
631 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
632 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
633 tmp1
= (z1
- z2
- z3
) << PASS1_BITS
;
635 /* Final output stage */
637 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
638 wsptr
[6*5] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
639 wsptr
[6*1] = (int) (tmp11
+ tmp1
);
640 wsptr
[6*4] = (int) (tmp11
- tmp1
);
641 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
642 wsptr
[6*3] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
645 /* Pass 2: process 6 rows from work array, store into output array. */
648 for (ctr
= 0; ctr
< 6; ctr
++) {
649 outptr
= output_buf
[ctr
] + output_col
;
653 /* Add range center and fudge factor for final descale and range-limit. */
654 tmp0
= (INT32
) wsptr
[0] +
655 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
656 (ONE
<< (PASS1_BITS
+2)));
658 tmp2
= (INT32
) wsptr
[4];
659 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
661 tmp11
= tmp0
- tmp10
- tmp10
;
662 tmp10
= (INT32
) wsptr
[2];
663 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
669 z1
= (INT32
) wsptr
[1];
670 z2
= (INT32
) wsptr
[3];
671 z3
= (INT32
) wsptr
[5];
672 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
673 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
674 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
675 tmp1
= (z1
- z2
- z3
) << CONST_BITS
;
677 /* Final output stage */
679 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
680 CONST_BITS
+PASS1_BITS
+3)
682 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
683 CONST_BITS
+PASS1_BITS
+3)
685 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
686 CONST_BITS
+PASS1_BITS
+3)
688 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
689 CONST_BITS
+PASS1_BITS
+3)
691 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
692 CONST_BITS
+PASS1_BITS
+3)
694 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
695 CONST_BITS
+PASS1_BITS
+3)
698 wsptr
+= 6; /* advance pointer to next row */
704 * Perform dequantization and inverse DCT on one block of coefficients,
705 * producing a reduced-size 5x5 output block.
707 * Optimized algorithm with 5 multiplications in the 1-D kernel.
708 * cK represents sqrt(2) * cos(K*pi/10).
712 jpeg_idct_5x5 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
714 JSAMPARRAY output_buf
, JDIMENSION output_col
)
716 INT32 tmp0
, tmp1
, tmp10
, tmp11
, tmp12
;
719 ISLOW_MULT_TYPE
* quantptr
;
722 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
724 int workspace
[5*5]; /* buffers data between passes */
727 /* Pass 1: process columns from input, store into work array. */
730 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
732 for (ctr
= 0; ctr
< 5; ctr
++, inptr
++, quantptr
++, wsptr
++) {
735 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
736 tmp12
<<= CONST_BITS
;
737 /* Add fudge factor here for final descale. */
738 tmp12
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
739 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
740 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
741 z1
= MULTIPLY(tmp0
+ tmp1
, FIX(0.790569415)); /* (c2+c4)/2 */
742 z2
= MULTIPLY(tmp0
- tmp1
, FIX(0.353553391)); /* (c2-c4)/2 */
750 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
751 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
753 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
754 tmp0
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
755 tmp1
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
757 /* Final output stage */
759 wsptr
[5*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
760 wsptr
[5*4] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
761 wsptr
[5*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
762 wsptr
[5*3] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
763 wsptr
[5*2] = (int) RIGHT_SHIFT(tmp12
, CONST_BITS
-PASS1_BITS
);
766 /* Pass 2: process 5 rows from work array, store into output array. */
769 for (ctr
= 0; ctr
< 5; ctr
++) {
770 outptr
= output_buf
[ctr
] + output_col
;
774 /* Add range center and fudge factor for final descale and range-limit. */
775 tmp12
= (INT32
) wsptr
[0] +
776 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
777 (ONE
<< (PASS1_BITS
+2)));
778 tmp12
<<= CONST_BITS
;
779 tmp0
= (INT32
) wsptr
[2];
780 tmp1
= (INT32
) wsptr
[4];
781 z1
= MULTIPLY(tmp0
+ tmp1
, FIX(0.790569415)); /* (c2+c4)/2 */
782 z2
= MULTIPLY(tmp0
- tmp1
, FIX(0.353553391)); /* (c2-c4)/2 */
790 z2
= (INT32
) wsptr
[1];
791 z3
= (INT32
) wsptr
[3];
793 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
794 tmp0
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
795 tmp1
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
797 /* Final output stage */
799 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
800 CONST_BITS
+PASS1_BITS
+3)
802 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
803 CONST_BITS
+PASS1_BITS
+3)
805 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
806 CONST_BITS
+PASS1_BITS
+3)
808 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
809 CONST_BITS
+PASS1_BITS
+3)
811 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
,
812 CONST_BITS
+PASS1_BITS
+3)
815 wsptr
+= 5; /* advance pointer to next row */
821 * Perform dequantization and inverse DCT on one block of coefficients,
822 * producing a reduced-size 4x4 output block.
824 * Optimized algorithm with 3 multiplications in the 1-D kernel.
825 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
829 jpeg_idct_4x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
831 JSAMPARRAY output_buf
, JDIMENSION output_col
)
833 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
836 ISLOW_MULT_TYPE
* quantptr
;
839 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
841 int workspace
[4*4]; /* buffers data between passes */
844 /* Pass 1: process columns from input, store into work array. */
847 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
849 for (ctr
= 0; ctr
< 4; ctr
++, inptr
++, quantptr
++, wsptr
++) {
852 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
853 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
855 tmp10
= (tmp0
+ tmp2
) << PASS1_BITS
;
856 tmp12
= (tmp0
- tmp2
) << PASS1_BITS
;
859 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
861 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
862 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
864 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
865 /* Add fudge factor here for final descale. */
866 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
867 tmp0
= RIGHT_SHIFT(z1
+ MULTIPLY(z2
, FIX_0_765366865
), /* c2-c6 */
868 CONST_BITS
-PASS1_BITS
);
869 tmp2
= RIGHT_SHIFT(z1
- MULTIPLY(z3
, FIX_1_847759065
), /* c2+c6 */
870 CONST_BITS
-PASS1_BITS
);
872 /* Final output stage */
874 wsptr
[4*0] = (int) (tmp10
+ tmp0
);
875 wsptr
[4*3] = (int) (tmp10
- tmp0
);
876 wsptr
[4*1] = (int) (tmp12
+ tmp2
);
877 wsptr
[4*2] = (int) (tmp12
- tmp2
);
880 /* Pass 2: process 4 rows from work array, store into output array. */
883 for (ctr
= 0; ctr
< 4; ctr
++) {
884 outptr
= output_buf
[ctr
] + output_col
;
888 /* Add range center and fudge factor for final descale and range-limit. */
889 tmp0
= (INT32
) wsptr
[0] +
890 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
891 (ONE
<< (PASS1_BITS
+2)));
892 tmp2
= (INT32
) wsptr
[2];
894 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
895 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
898 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
900 z2
= (INT32
) wsptr
[1];
901 z3
= (INT32
) wsptr
[3];
903 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
904 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
905 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
907 /* Final output stage */
909 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
910 CONST_BITS
+PASS1_BITS
+3)
912 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
913 CONST_BITS
+PASS1_BITS
+3)
915 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
916 CONST_BITS
+PASS1_BITS
+3)
918 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
919 CONST_BITS
+PASS1_BITS
+3)
922 wsptr
+= 4; /* advance pointer to next row */
928 * Perform dequantization and inverse DCT on one block of coefficients,
929 * producing a reduced-size 3x3 output block.
931 * Optimized algorithm with 2 multiplications in the 1-D kernel.
932 * cK represents sqrt(2) * cos(K*pi/6).
936 jpeg_idct_3x3 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
938 JSAMPARRAY output_buf
, JDIMENSION output_col
)
940 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
942 ISLOW_MULT_TYPE
* quantptr
;
945 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
947 int workspace
[3*3]; /* buffers data between passes */
950 /* Pass 1: process columns from input, store into work array. */
953 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
955 for (ctr
= 0; ctr
< 3; ctr
++, inptr
++, quantptr
++, wsptr
++) {
958 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
960 /* Add fudge factor here for final descale. */
961 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
962 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
963 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
964 tmp10
= tmp0
+ tmp12
;
965 tmp2
= tmp0
- tmp12
- tmp12
;
969 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
970 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
972 /* Final output stage */
974 wsptr
[3*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
975 wsptr
[3*2] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
976 wsptr
[3*1] = (int) RIGHT_SHIFT(tmp2
, CONST_BITS
-PASS1_BITS
);
979 /* Pass 2: process 3 rows from work array, store into output array. */
982 for (ctr
= 0; ctr
< 3; ctr
++) {
983 outptr
= output_buf
[ctr
] + output_col
;
987 /* Add range center and fudge factor for final descale and range-limit. */
988 tmp0
= (INT32
) wsptr
[0] +
989 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
990 (ONE
<< (PASS1_BITS
+2)));
992 tmp2
= (INT32
) wsptr
[2];
993 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
994 tmp10
= tmp0
+ tmp12
;
995 tmp2
= tmp0
- tmp12
- tmp12
;
999 tmp12
= (INT32
) wsptr
[1];
1000 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
1002 /* Final output stage */
1004 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
1005 CONST_BITS
+PASS1_BITS
+3)
1007 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
1008 CONST_BITS
+PASS1_BITS
+3)
1010 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp2
,
1011 CONST_BITS
+PASS1_BITS
+3)
1014 wsptr
+= 3; /* advance pointer to next row */
1020 * Perform dequantization and inverse DCT on one block of coefficients,
1021 * producing a reduced-size 2x2 output block.
1023 * Multiplication-less algorithm.
1027 jpeg_idct_2x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1028 JCOEFPTR coef_block
,
1029 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1031 DCTELEM tmp0
, tmp1
, tmp2
, tmp3
, tmp4
, tmp5
;
1032 ISLOW_MULT_TYPE
* quantptr
;
1034 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1037 /* Pass 1: process columns from input. */
1039 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1042 tmp4
= DEQUANTIZE(coef_block
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1043 tmp5
= DEQUANTIZE(coef_block
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1044 /* Add range center and fudge factor for final descale and range-limit. */
1045 tmp4
+= (((DCTELEM
) RANGE_CENTER
) << 3) + (1 << 2);
1051 tmp4
= DEQUANTIZE(coef_block
[DCTSIZE
*0+1], quantptr
[DCTSIZE
*0+1]);
1052 tmp5
= DEQUANTIZE(coef_block
[DCTSIZE
*1+1], quantptr
[DCTSIZE
*1+1]);
1057 /* Pass 2: process 2 rows, store into output array. */
1060 outptr
= output_buf
[0] + output_col
;
1062 outptr
[0] = range_limit
[(int) IRIGHT_SHIFT(tmp0
+ tmp1
, 3) & RANGE_MASK
];
1063 outptr
[1] = range_limit
[(int) IRIGHT_SHIFT(tmp0
- tmp1
, 3) & RANGE_MASK
];
1066 outptr
= output_buf
[1] + output_col
;
1068 outptr
[0] = range_limit
[(int) IRIGHT_SHIFT(tmp2
+ tmp3
, 3) & RANGE_MASK
];
1069 outptr
[1] = range_limit
[(int) IRIGHT_SHIFT(tmp2
- tmp3
, 3) & RANGE_MASK
];
1074 * Perform dequantization and inverse DCT on one block of coefficients,
1075 * producing a reduced-size 1x1 output block.
1077 * We hardly need an inverse DCT routine for this: just take the
1078 * average pixel value, which is one-eighth of the DC coefficient.
1082 jpeg_idct_1x1 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1083 JCOEFPTR coef_block
,
1084 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1087 ISLOW_MULT_TYPE
* quantptr
;
1088 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1091 /* 1x1 is trivial: just take the DC coefficient divided by 8. */
1093 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1095 dcval
= DEQUANTIZE(coef_block
[0], quantptr
[0]);
1096 /* Add range center and fudge factor for descale and range-limit. */
1097 dcval
+= (((DCTELEM
) RANGE_CENTER
) << 3) + (1 << 2);
1099 output_buf
[0][output_col
] =
1100 range_limit
[(int) IRIGHT_SHIFT(dcval
, 3) & RANGE_MASK
];
1105 * Perform dequantization and inverse DCT on one block of coefficients,
1106 * producing a 9x9 output block.
1108 * Optimized algorithm with 10 multiplications in the 1-D kernel.
1109 * cK represents sqrt(2) * cos(K*pi/18).
1113 jpeg_idct_9x9 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1114 JCOEFPTR coef_block
,
1115 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1117 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1118 INT32 z1
, z2
, z3
, z4
;
1120 ISLOW_MULT_TYPE
* quantptr
;
1123 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1125 int workspace
[8*9]; /* buffers data between passes */
1128 /* Pass 1: process columns from input, store into work array. */
1131 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1133 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1136 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1137 tmp0
<<= CONST_BITS
;
1138 /* Add fudge factor here for final descale. */
1139 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1141 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1142 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1143 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1145 tmp3
= MULTIPLY(z3
, FIX(0.707106781)); /* c6 */
1147 tmp2
= tmp0
- tmp3
- tmp3
;
1149 tmp0
= MULTIPLY(z1
- z2
, FIX(0.707106781)); /* c6 */
1150 tmp11
= tmp2
+ tmp0
;
1151 tmp14
= tmp2
- tmp0
- tmp0
;
1153 tmp0
= MULTIPLY(z1
+ z2
, FIX(1.328926049)); /* c2 */
1154 tmp2
= MULTIPLY(z1
, FIX(1.083350441)); /* c4 */
1155 tmp3
= MULTIPLY(z2
, FIX(0.245575608)); /* c8 */
1157 tmp10
= tmp1
+ tmp0
- tmp3
;
1158 tmp12
= tmp1
- tmp0
+ tmp2
;
1159 tmp13
= tmp1
- tmp2
+ tmp3
;
1163 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1164 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1165 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1166 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1168 z2
= MULTIPLY(z2
, - FIX(1.224744871)); /* -c3 */
1170 tmp2
= MULTIPLY(z1
+ z3
, FIX(0.909038955)); /* c5 */
1171 tmp3
= MULTIPLY(z1
+ z4
, FIX(0.483689525)); /* c7 */
1172 tmp0
= tmp2
+ tmp3
- z2
;
1173 tmp1
= MULTIPLY(z3
- z4
, FIX(1.392728481)); /* c1 */
1176 tmp1
= MULTIPLY(z1
- z3
- z4
, FIX(1.224744871)); /* c3 */
1178 /* Final output stage */
1180 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
1181 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
1182 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
1183 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
1184 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
1185 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
1186 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp13
+ tmp3
, CONST_BITS
-PASS1_BITS
);
1187 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp13
- tmp3
, CONST_BITS
-PASS1_BITS
);
1188 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp14
, CONST_BITS
-PASS1_BITS
);
1191 /* Pass 2: process 9 rows from work array, store into output array. */
1194 for (ctr
= 0; ctr
< 9; ctr
++) {
1195 outptr
= output_buf
[ctr
] + output_col
;
1199 /* Add range center and fudge factor for final descale and range-limit. */
1200 tmp0
= (INT32
) wsptr
[0] +
1201 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
1202 (ONE
<< (PASS1_BITS
+2)));
1203 tmp0
<<= CONST_BITS
;
1205 z1
= (INT32
) wsptr
[2];
1206 z2
= (INT32
) wsptr
[4];
1207 z3
= (INT32
) wsptr
[6];
1209 tmp3
= MULTIPLY(z3
, FIX(0.707106781)); /* c6 */
1211 tmp2
= tmp0
- tmp3
- tmp3
;
1213 tmp0
= MULTIPLY(z1
- z2
, FIX(0.707106781)); /* c6 */
1214 tmp11
= tmp2
+ tmp0
;
1215 tmp14
= tmp2
- tmp0
- tmp0
;
1217 tmp0
= MULTIPLY(z1
+ z2
, FIX(1.328926049)); /* c2 */
1218 tmp2
= MULTIPLY(z1
, FIX(1.083350441)); /* c4 */
1219 tmp3
= MULTIPLY(z2
, FIX(0.245575608)); /* c8 */
1221 tmp10
= tmp1
+ tmp0
- tmp3
;
1222 tmp12
= tmp1
- tmp0
+ tmp2
;
1223 tmp13
= tmp1
- tmp2
+ tmp3
;
1227 z1
= (INT32
) wsptr
[1];
1228 z2
= (INT32
) wsptr
[3];
1229 z3
= (INT32
) wsptr
[5];
1230 z4
= (INT32
) wsptr
[7];
1232 z2
= MULTIPLY(z2
, - FIX(1.224744871)); /* -c3 */
1234 tmp2
= MULTIPLY(z1
+ z3
, FIX(0.909038955)); /* c5 */
1235 tmp3
= MULTIPLY(z1
+ z4
, FIX(0.483689525)); /* c7 */
1236 tmp0
= tmp2
+ tmp3
- z2
;
1237 tmp1
= MULTIPLY(z3
- z4
, FIX(1.392728481)); /* c1 */
1240 tmp1
= MULTIPLY(z1
- z3
- z4
, FIX(1.224744871)); /* c3 */
1242 /* Final output stage */
1244 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
1245 CONST_BITS
+PASS1_BITS
+3)
1247 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
1248 CONST_BITS
+PASS1_BITS
+3)
1250 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
1251 CONST_BITS
+PASS1_BITS
+3)
1253 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
1254 CONST_BITS
+PASS1_BITS
+3)
1256 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
1257 CONST_BITS
+PASS1_BITS
+3)
1259 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
1260 CONST_BITS
+PASS1_BITS
+3)
1262 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp3
,
1263 CONST_BITS
+PASS1_BITS
+3)
1265 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp3
,
1266 CONST_BITS
+PASS1_BITS
+3)
1268 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp14
,
1269 CONST_BITS
+PASS1_BITS
+3)
1272 wsptr
+= 8; /* advance pointer to next row */
1278 * Perform dequantization and inverse DCT on one block of coefficients,
1279 * producing a 10x10 output block.
1281 * Optimized algorithm with 12 multiplications in the 1-D kernel.
1282 * cK represents sqrt(2) * cos(K*pi/20).
1286 jpeg_idct_10x10 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1287 JCOEFPTR coef_block
,
1288 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1290 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1291 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
1292 INT32 z1
, z2
, z3
, z4
, z5
;
1294 ISLOW_MULT_TYPE
* quantptr
;
1297 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1299 int workspace
[8*10]; /* buffers data between passes */
1302 /* Pass 1: process columns from input, store into work array. */
1305 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1307 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1310 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1312 /* Add fudge factor here for final descale. */
1313 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1314 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1315 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
1316 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
1320 tmp22
= RIGHT_SHIFT(z3
- ((z1
- z2
) << 1), /* c0 = (c4-c8)*2 */
1321 CONST_BITS
-PASS1_BITS
);
1323 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1324 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1326 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
1327 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
1328 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
1330 tmp20
= tmp10
+ tmp12
;
1331 tmp24
= tmp10
- tmp12
;
1332 tmp21
= tmp11
+ tmp13
;
1333 tmp23
= tmp11
- tmp13
;
1337 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1338 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1339 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1340 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1345 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
1346 z5
= z3
<< CONST_BITS
;
1348 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
1351 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
1352 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
1354 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
1355 z4
= z5
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
1357 tmp12
= (z1
- tmp13
- z3
) << PASS1_BITS
;
1359 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
1360 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
1362 /* Final output stage */
1364 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1365 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1366 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1367 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1368 wsptr
[8*2] = (int) (tmp22
+ tmp12
);
1369 wsptr
[8*7] = (int) (tmp22
- tmp12
);
1370 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1371 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1372 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1373 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1376 /* Pass 2: process 10 rows from work array, store into output array. */
1379 for (ctr
= 0; ctr
< 10; ctr
++) {
1380 outptr
= output_buf
[ctr
] + output_col
;
1384 /* Add range center and fudge factor for final descale and range-limit. */
1385 z3
= (INT32
) wsptr
[0] +
1386 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
1387 (ONE
<< (PASS1_BITS
+2)));
1389 z4
= (INT32
) wsptr
[4];
1390 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
1391 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
1395 tmp22
= z3
- ((z1
- z2
) << 1); /* c0 = (c4-c8)*2 */
1397 z2
= (INT32
) wsptr
[2];
1398 z3
= (INT32
) wsptr
[6];
1400 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
1401 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
1402 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
1404 tmp20
= tmp10
+ tmp12
;
1405 tmp24
= tmp10
- tmp12
;
1406 tmp21
= tmp11
+ tmp13
;
1407 tmp23
= tmp11
- tmp13
;
1411 z1
= (INT32
) wsptr
[1];
1412 z2
= (INT32
) wsptr
[3];
1413 z3
= (INT32
) wsptr
[5];
1415 z4
= (INT32
) wsptr
[7];
1420 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
1422 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
1425 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
1426 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
1428 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
1429 z4
= z3
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
1431 tmp12
= ((z1
- tmp13
) << CONST_BITS
) - z3
;
1433 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
1434 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
1436 /* Final output stage */
1438 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1439 CONST_BITS
+PASS1_BITS
+3)
1441 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1442 CONST_BITS
+PASS1_BITS
+3)
1444 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1445 CONST_BITS
+PASS1_BITS
+3)
1447 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1448 CONST_BITS
+PASS1_BITS
+3)
1450 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1451 CONST_BITS
+PASS1_BITS
+3)
1453 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1454 CONST_BITS
+PASS1_BITS
+3)
1456 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1457 CONST_BITS
+PASS1_BITS
+3)
1459 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1460 CONST_BITS
+PASS1_BITS
+3)
1462 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1463 CONST_BITS
+PASS1_BITS
+3)
1465 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1466 CONST_BITS
+PASS1_BITS
+3)
1469 wsptr
+= 8; /* advance pointer to next row */
1475 * Perform dequantization and inverse DCT on one block of coefficients,
1476 * producing a 11x11 output block.
1478 * Optimized algorithm with 24 multiplications in the 1-D kernel.
1479 * cK represents sqrt(2) * cos(K*pi/22).
1483 jpeg_idct_11x11 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1484 JCOEFPTR coef_block
,
1485 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1487 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1488 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
1489 INT32 z1
, z2
, z3
, z4
;
1491 ISLOW_MULT_TYPE
* quantptr
;
1494 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1496 int workspace
[8*11]; /* buffers data between passes */
1499 /* Pass 1: process columns from input, store into work array. */
1502 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1504 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1507 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1508 tmp10
<<= CONST_BITS
;
1509 /* Add fudge factor here for final descale. */
1510 tmp10
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1512 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1513 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1514 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1516 tmp20
= MULTIPLY(z2
- z3
, FIX(2.546640132)); /* c2+c4 */
1517 tmp23
= MULTIPLY(z2
- z1
, FIX(0.430815045)); /* c2-c6 */
1519 tmp24
= MULTIPLY(z4
, - FIX(1.155664402)); /* -(c2-c10) */
1521 tmp25
= tmp10
+ MULTIPLY(z4
, FIX(1.356927976)); /* c2 */
1522 tmp21
= tmp20
+ tmp23
+ tmp25
-
1523 MULTIPLY(z2
, FIX(1.821790775)); /* c2+c4+c10-c6 */
1524 tmp20
+= tmp25
+ MULTIPLY(z3
, FIX(2.115825087)); /* c4+c6 */
1525 tmp23
+= tmp25
- MULTIPLY(z1
, FIX(1.513598477)); /* c6+c8 */
1527 tmp22
= tmp24
- MULTIPLY(z3
, FIX(0.788749120)); /* c8+c10 */
1528 tmp24
+= MULTIPLY(z2
, FIX(1.944413522)) - /* c2+c8 */
1529 MULTIPLY(z1
, FIX(1.390975730)); /* c4+c10 */
1530 tmp25
= tmp10
- MULTIPLY(z4
, FIX(1.414213562)); /* c0 */
1534 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1535 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1536 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1537 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1540 tmp14
= MULTIPLY(tmp11
+ z3
+ z4
, FIX(0.398430003)); /* c9 */
1541 tmp11
= MULTIPLY(tmp11
, FIX(0.887983902)); /* c3-c9 */
1542 tmp12
= MULTIPLY(z1
+ z3
, FIX(0.670361295)); /* c5-c9 */
1543 tmp13
= tmp14
+ MULTIPLY(z1
+ z4
, FIX(0.366151574)); /* c7-c9 */
1544 tmp10
= tmp11
+ tmp12
+ tmp13
-
1545 MULTIPLY(z1
, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
1546 z1
= tmp14
- MULTIPLY(z2
+ z3
, FIX(1.163011579)); /* c7+c9 */
1547 tmp11
+= z1
+ MULTIPLY(z2
, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
1548 tmp12
+= z1
- MULTIPLY(z3
, FIX(1.192193623)); /* c3+c5-c7-c9 */
1549 z1
= MULTIPLY(z2
+ z4
, - FIX(1.798248910)); /* -(c1+c9) */
1551 tmp13
+= z1
+ MULTIPLY(z4
, FIX(2.102458632)); /* c1+c5+c9-c7 */
1552 tmp14
+= MULTIPLY(z2
, - FIX(1.467221301)) + /* -(c5+c9) */
1553 MULTIPLY(z3
, FIX(1.001388905)) - /* c1-c9 */
1554 MULTIPLY(z4
, FIX(1.684843907)); /* c3+c9 */
1556 /* Final output stage */
1558 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1559 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1560 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1561 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1562 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1563 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1564 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1565 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1566 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1567 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1568 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
, CONST_BITS
-PASS1_BITS
);
1571 /* Pass 2: process 11 rows from work array, store into output array. */
1574 for (ctr
= 0; ctr
< 11; ctr
++) {
1575 outptr
= output_buf
[ctr
] + output_col
;
1579 /* Add range center and fudge factor for final descale and range-limit. */
1580 tmp10
= (INT32
) wsptr
[0] +
1581 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
1582 (ONE
<< (PASS1_BITS
+2)));
1583 tmp10
<<= CONST_BITS
;
1585 z1
= (INT32
) wsptr
[2];
1586 z2
= (INT32
) wsptr
[4];
1587 z3
= (INT32
) wsptr
[6];
1589 tmp20
= MULTIPLY(z2
- z3
, FIX(2.546640132)); /* c2+c4 */
1590 tmp23
= MULTIPLY(z2
- z1
, FIX(0.430815045)); /* c2-c6 */
1592 tmp24
= MULTIPLY(z4
, - FIX(1.155664402)); /* -(c2-c10) */
1594 tmp25
= tmp10
+ MULTIPLY(z4
, FIX(1.356927976)); /* c2 */
1595 tmp21
= tmp20
+ tmp23
+ tmp25
-
1596 MULTIPLY(z2
, FIX(1.821790775)); /* c2+c4+c10-c6 */
1597 tmp20
+= tmp25
+ MULTIPLY(z3
, FIX(2.115825087)); /* c4+c6 */
1598 tmp23
+= tmp25
- MULTIPLY(z1
, FIX(1.513598477)); /* c6+c8 */
1600 tmp22
= tmp24
- MULTIPLY(z3
, FIX(0.788749120)); /* c8+c10 */
1601 tmp24
+= MULTIPLY(z2
, FIX(1.944413522)) - /* c2+c8 */
1602 MULTIPLY(z1
, FIX(1.390975730)); /* c4+c10 */
1603 tmp25
= tmp10
- MULTIPLY(z4
, FIX(1.414213562)); /* c0 */
1607 z1
= (INT32
) wsptr
[1];
1608 z2
= (INT32
) wsptr
[3];
1609 z3
= (INT32
) wsptr
[5];
1610 z4
= (INT32
) wsptr
[7];
1613 tmp14
= MULTIPLY(tmp11
+ z3
+ z4
, FIX(0.398430003)); /* c9 */
1614 tmp11
= MULTIPLY(tmp11
, FIX(0.887983902)); /* c3-c9 */
1615 tmp12
= MULTIPLY(z1
+ z3
, FIX(0.670361295)); /* c5-c9 */
1616 tmp13
= tmp14
+ MULTIPLY(z1
+ z4
, FIX(0.366151574)); /* c7-c9 */
1617 tmp10
= tmp11
+ tmp12
+ tmp13
-
1618 MULTIPLY(z1
, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
1619 z1
= tmp14
- MULTIPLY(z2
+ z3
, FIX(1.163011579)); /* c7+c9 */
1620 tmp11
+= z1
+ MULTIPLY(z2
, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
1621 tmp12
+= z1
- MULTIPLY(z3
, FIX(1.192193623)); /* c3+c5-c7-c9 */
1622 z1
= MULTIPLY(z2
+ z4
, - FIX(1.798248910)); /* -(c1+c9) */
1624 tmp13
+= z1
+ MULTIPLY(z4
, FIX(2.102458632)); /* c1+c5+c9-c7 */
1625 tmp14
+= MULTIPLY(z2
, - FIX(1.467221301)) + /* -(c5+c9) */
1626 MULTIPLY(z3
, FIX(1.001388905)) - /* c1-c9 */
1627 MULTIPLY(z4
, FIX(1.684843907)); /* c3+c9 */
1629 /* Final output stage */
1631 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1632 CONST_BITS
+PASS1_BITS
+3)
1634 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1635 CONST_BITS
+PASS1_BITS
+3)
1637 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1638 CONST_BITS
+PASS1_BITS
+3)
1640 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1641 CONST_BITS
+PASS1_BITS
+3)
1643 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1644 CONST_BITS
+PASS1_BITS
+3)
1646 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1647 CONST_BITS
+PASS1_BITS
+3)
1649 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1650 CONST_BITS
+PASS1_BITS
+3)
1652 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1653 CONST_BITS
+PASS1_BITS
+3)
1655 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1656 CONST_BITS
+PASS1_BITS
+3)
1658 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1659 CONST_BITS
+PASS1_BITS
+3)
1661 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
,
1662 CONST_BITS
+PASS1_BITS
+3)
1665 wsptr
+= 8; /* advance pointer to next row */
1671 * Perform dequantization and inverse DCT on one block of coefficients,
1672 * producing a 12x12 output block.
1674 * Optimized algorithm with 15 multiplications in the 1-D kernel.
1675 * cK represents sqrt(2) * cos(K*pi/24).
1679 jpeg_idct_12x12 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1680 JCOEFPTR coef_block
,
1681 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1683 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
1684 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
1685 INT32 z1
, z2
, z3
, z4
;
1687 ISLOW_MULT_TYPE
* quantptr
;
1690 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1692 int workspace
[8*12]; /* buffers data between passes */
1695 /* Pass 1: process columns from input, store into work array. */
1698 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1700 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1703 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1705 /* Add fudge factor here for final descale. */
1706 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1708 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1709 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
1714 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1715 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
1717 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1727 tmp20
= tmp10
+ tmp12
;
1728 tmp25
= tmp10
- tmp12
;
1730 tmp12
= z4
- z1
- z2
;
1732 tmp22
= tmp11
+ tmp12
;
1733 tmp23
= tmp11
- tmp12
;
1737 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1738 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1739 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1740 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1742 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
1743 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
1746 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
1747 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
1748 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
1749 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
1750 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
1751 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
1752 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
1753 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
1757 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
1758 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
1759 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
1761 /* Final output stage */
1763 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1764 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1765 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1766 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1767 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1768 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1769 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1770 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1771 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1772 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1773 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
1774 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
1777 /* Pass 2: process 12 rows from work array, store into output array. */
1780 for (ctr
= 0; ctr
< 12; ctr
++) {
1781 outptr
= output_buf
[ctr
] + output_col
;
1785 /* Add range center and fudge factor for final descale and range-limit. */
1786 z3
= (INT32
) wsptr
[0] +
1787 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
1788 (ONE
<< (PASS1_BITS
+2)));
1791 z4
= (INT32
) wsptr
[4];
1792 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
1797 z1
= (INT32
) wsptr
[2];
1798 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
1800 z2
= (INT32
) wsptr
[6];
1810 tmp20
= tmp10
+ tmp12
;
1811 tmp25
= tmp10
- tmp12
;
1813 tmp12
= z4
- z1
- z2
;
1815 tmp22
= tmp11
+ tmp12
;
1816 tmp23
= tmp11
- tmp12
;
1820 z1
= (INT32
) wsptr
[1];
1821 z2
= (INT32
) wsptr
[3];
1822 z3
= (INT32
) wsptr
[5];
1823 z4
= (INT32
) wsptr
[7];
1825 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
1826 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
1829 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
1830 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
1831 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
1832 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
1833 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
1834 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
1835 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
1836 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
1840 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
1841 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
1842 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
1844 /* Final output stage */
1846 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1847 CONST_BITS
+PASS1_BITS
+3)
1849 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1850 CONST_BITS
+PASS1_BITS
+3)
1852 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1853 CONST_BITS
+PASS1_BITS
+3)
1855 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1856 CONST_BITS
+PASS1_BITS
+3)
1858 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1859 CONST_BITS
+PASS1_BITS
+3)
1861 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1862 CONST_BITS
+PASS1_BITS
+3)
1864 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1865 CONST_BITS
+PASS1_BITS
+3)
1867 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1868 CONST_BITS
+PASS1_BITS
+3)
1870 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1871 CONST_BITS
+PASS1_BITS
+3)
1873 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1874 CONST_BITS
+PASS1_BITS
+3)
1876 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
1877 CONST_BITS
+PASS1_BITS
+3)
1879 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
1880 CONST_BITS
+PASS1_BITS
+3)
1883 wsptr
+= 8; /* advance pointer to next row */
1889 * Perform dequantization and inverse DCT on one block of coefficients,
1890 * producing a 13x13 output block.
1892 * Optimized algorithm with 29 multiplications in the 1-D kernel.
1893 * cK represents sqrt(2) * cos(K*pi/26).
1897 jpeg_idct_13x13 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1898 JCOEFPTR coef_block
,
1899 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1901 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
1902 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
1903 INT32 z1
, z2
, z3
, z4
;
1905 ISLOW_MULT_TYPE
* quantptr
;
1908 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1910 int workspace
[8*13]; /* buffers data between passes */
1913 /* Pass 1: process columns from input, store into work array. */
1916 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1918 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1921 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1923 /* Add fudge factor here for final descale. */
1924 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1926 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1927 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1928 z4
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1933 tmp12
= MULTIPLY(tmp10
, FIX(1.155388986)); /* (c4+c6)/2 */
1934 tmp13
= MULTIPLY(tmp11
, FIX(0.096834934)) + z1
; /* (c4-c6)/2 */
1936 tmp20
= MULTIPLY(z2
, FIX(1.373119086)) + tmp12
+ tmp13
; /* c2 */
1937 tmp22
= MULTIPLY(z2
, FIX(0.501487041)) - tmp12
+ tmp13
; /* c10 */
1939 tmp12
= MULTIPLY(tmp10
, FIX(0.316450131)); /* (c8-c12)/2 */
1940 tmp13
= MULTIPLY(tmp11
, FIX(0.486914739)) + z1
; /* (c8+c12)/2 */
1942 tmp21
= MULTIPLY(z2
, FIX(1.058554052)) - tmp12
+ tmp13
; /* c6 */
1943 tmp25
= MULTIPLY(z2
, - FIX(1.252223920)) + tmp12
+ tmp13
; /* c4 */
1945 tmp12
= MULTIPLY(tmp10
, FIX(0.435816023)); /* (c2-c10)/2 */
1946 tmp13
= MULTIPLY(tmp11
, FIX(0.937303064)) - z1
; /* (c2+c10)/2 */
1948 tmp23
= MULTIPLY(z2
, - FIX(0.170464608)) - tmp12
- tmp13
; /* c12 */
1949 tmp24
= MULTIPLY(z2
, - FIX(0.803364869)) + tmp12
- tmp13
; /* c8 */
1951 tmp26
= MULTIPLY(tmp11
- z2
, FIX(1.414213562)) + z1
; /* c0 */
1955 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1956 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1957 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1958 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1960 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.322312651)); /* c3 */
1961 tmp12
= MULTIPLY(z1
+ z3
, FIX(1.163874945)); /* c5 */
1963 tmp13
= MULTIPLY(tmp15
, FIX(0.937797057)); /* c7 */
1964 tmp10
= tmp11
+ tmp12
+ tmp13
-
1965 MULTIPLY(z1
, FIX(2.020082300)); /* c7+c5+c3-c1 */
1966 tmp14
= MULTIPLY(z2
+ z3
, - FIX(0.338443458)); /* -c11 */
1967 tmp11
+= tmp14
+ MULTIPLY(z2
, FIX(0.837223564)); /* c5+c9+c11-c3 */
1968 tmp12
+= tmp14
- MULTIPLY(z3
, FIX(1.572116027)); /* c1+c5-c9-c11 */
1969 tmp14
= MULTIPLY(z2
+ z4
, - FIX(1.163874945)); /* -c5 */
1971 tmp13
+= tmp14
+ MULTIPLY(z4
, FIX(2.205608352)); /* c3+c5+c9-c7 */
1972 tmp14
= MULTIPLY(z3
+ z4
, - FIX(0.657217813)); /* -c9 */
1975 tmp15
= MULTIPLY(tmp15
, FIX(0.338443458)); /* c11 */
1976 tmp14
= tmp15
+ MULTIPLY(z1
, FIX(0.318774355)) - /* c9-c11 */
1977 MULTIPLY(z2
, FIX(0.466105296)); /* c1-c7 */
1978 z1
= MULTIPLY(z3
- z2
, FIX(0.937797057)); /* c7 */
1980 tmp15
+= z1
+ MULTIPLY(z3
, FIX(0.384515595)) - /* c3-c7 */
1981 MULTIPLY(z4
, FIX(1.742345811)); /* c1+c11 */
1983 /* Final output stage */
1985 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1986 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1987 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1988 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1989 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1990 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1991 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1992 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1993 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1994 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1995 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
1996 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
1997 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
, CONST_BITS
-PASS1_BITS
);
2000 /* Pass 2: process 13 rows from work array, store into output array. */
2003 for (ctr
= 0; ctr
< 13; ctr
++) {
2004 outptr
= output_buf
[ctr
] + output_col
;
2008 /* Add range center and fudge factor for final descale and range-limit. */
2009 z1
= (INT32
) wsptr
[0] +
2010 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
2011 (ONE
<< (PASS1_BITS
+2)));
2014 z2
= (INT32
) wsptr
[2];
2015 z3
= (INT32
) wsptr
[4];
2016 z4
= (INT32
) wsptr
[6];
2021 tmp12
= MULTIPLY(tmp10
, FIX(1.155388986)); /* (c4+c6)/2 */
2022 tmp13
= MULTIPLY(tmp11
, FIX(0.096834934)) + z1
; /* (c4-c6)/2 */
2024 tmp20
= MULTIPLY(z2
, FIX(1.373119086)) + tmp12
+ tmp13
; /* c2 */
2025 tmp22
= MULTIPLY(z2
, FIX(0.501487041)) - tmp12
+ tmp13
; /* c10 */
2027 tmp12
= MULTIPLY(tmp10
, FIX(0.316450131)); /* (c8-c12)/2 */
2028 tmp13
= MULTIPLY(tmp11
, FIX(0.486914739)) + z1
; /* (c8+c12)/2 */
2030 tmp21
= MULTIPLY(z2
, FIX(1.058554052)) - tmp12
+ tmp13
; /* c6 */
2031 tmp25
= MULTIPLY(z2
, - FIX(1.252223920)) + tmp12
+ tmp13
; /* c4 */
2033 tmp12
= MULTIPLY(tmp10
, FIX(0.435816023)); /* (c2-c10)/2 */
2034 tmp13
= MULTIPLY(tmp11
, FIX(0.937303064)) - z1
; /* (c2+c10)/2 */
2036 tmp23
= MULTIPLY(z2
, - FIX(0.170464608)) - tmp12
- tmp13
; /* c12 */
2037 tmp24
= MULTIPLY(z2
, - FIX(0.803364869)) + tmp12
- tmp13
; /* c8 */
2039 tmp26
= MULTIPLY(tmp11
- z2
, FIX(1.414213562)) + z1
; /* c0 */
2043 z1
= (INT32
) wsptr
[1];
2044 z2
= (INT32
) wsptr
[3];
2045 z3
= (INT32
) wsptr
[5];
2046 z4
= (INT32
) wsptr
[7];
2048 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.322312651)); /* c3 */
2049 tmp12
= MULTIPLY(z1
+ z3
, FIX(1.163874945)); /* c5 */
2051 tmp13
= MULTIPLY(tmp15
, FIX(0.937797057)); /* c7 */
2052 tmp10
= tmp11
+ tmp12
+ tmp13
-
2053 MULTIPLY(z1
, FIX(2.020082300)); /* c7+c5+c3-c1 */
2054 tmp14
= MULTIPLY(z2
+ z3
, - FIX(0.338443458)); /* -c11 */
2055 tmp11
+= tmp14
+ MULTIPLY(z2
, FIX(0.837223564)); /* c5+c9+c11-c3 */
2056 tmp12
+= tmp14
- MULTIPLY(z3
, FIX(1.572116027)); /* c1+c5-c9-c11 */
2057 tmp14
= MULTIPLY(z2
+ z4
, - FIX(1.163874945)); /* -c5 */
2059 tmp13
+= tmp14
+ MULTIPLY(z4
, FIX(2.205608352)); /* c3+c5+c9-c7 */
2060 tmp14
= MULTIPLY(z3
+ z4
, - FIX(0.657217813)); /* -c9 */
2063 tmp15
= MULTIPLY(tmp15
, FIX(0.338443458)); /* c11 */
2064 tmp14
= tmp15
+ MULTIPLY(z1
, FIX(0.318774355)) - /* c9-c11 */
2065 MULTIPLY(z2
, FIX(0.466105296)); /* c1-c7 */
2066 z1
= MULTIPLY(z3
- z2
, FIX(0.937797057)); /* c7 */
2068 tmp15
+= z1
+ MULTIPLY(z3
, FIX(0.384515595)) - /* c3-c7 */
2069 MULTIPLY(z4
, FIX(1.742345811)); /* c1+c11 */
2071 /* Final output stage */
2073 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2074 CONST_BITS
+PASS1_BITS
+3)
2076 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2077 CONST_BITS
+PASS1_BITS
+3)
2079 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2080 CONST_BITS
+PASS1_BITS
+3)
2082 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2083 CONST_BITS
+PASS1_BITS
+3)
2085 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2086 CONST_BITS
+PASS1_BITS
+3)
2088 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2089 CONST_BITS
+PASS1_BITS
+3)
2091 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2092 CONST_BITS
+PASS1_BITS
+3)
2094 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2095 CONST_BITS
+PASS1_BITS
+3)
2097 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2098 CONST_BITS
+PASS1_BITS
+3)
2100 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2101 CONST_BITS
+PASS1_BITS
+3)
2103 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2104 CONST_BITS
+PASS1_BITS
+3)
2106 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2107 CONST_BITS
+PASS1_BITS
+3)
2109 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
,
2110 CONST_BITS
+PASS1_BITS
+3)
2113 wsptr
+= 8; /* advance pointer to next row */
2119 * Perform dequantization and inverse DCT on one block of coefficients,
2120 * producing a 14x14 output block.
2122 * Optimized algorithm with 20 multiplications in the 1-D kernel.
2123 * cK represents sqrt(2) * cos(K*pi/28).
2127 jpeg_idct_14x14 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2128 JCOEFPTR coef_block
,
2129 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2131 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
2132 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
2133 INT32 z1
, z2
, z3
, z4
;
2135 ISLOW_MULT_TYPE
* quantptr
;
2138 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2140 int workspace
[8*14]; /* buffers data between passes */
2143 /* Pass 1: process columns from input, store into work array. */
2146 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2148 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2151 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2153 /* Add fudge factor here for final descale. */
2154 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2155 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2156 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
2157 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
2158 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
2164 tmp23
= RIGHT_SHIFT(z1
- ((z2
+ z3
- z4
) << 1), /* c0 = (c4+c12-c8)*2 */
2165 CONST_BITS
-PASS1_BITS
);
2167 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2168 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2170 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
2172 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
2173 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
2174 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
2175 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
2177 tmp20
= tmp10
+ tmp13
;
2178 tmp26
= tmp10
- tmp13
;
2179 tmp21
= tmp11
+ tmp14
;
2180 tmp25
= tmp11
- tmp14
;
2181 tmp22
= tmp12
+ tmp15
;
2182 tmp24
= tmp12
- tmp15
;
2186 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2187 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2188 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2189 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2190 tmp13
= z4
<< CONST_BITS
;
2193 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
2194 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
2195 tmp10
= tmp11
+ tmp12
+ tmp13
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
2196 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
2197 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
2199 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - tmp13
; /* c11 */
2202 z4
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - tmp13
; /* -c13 */
2203 tmp11
+= z4
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
2204 tmp12
+= z4
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
2205 z4
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
2206 tmp14
+= z4
+ tmp13
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
2207 tmp15
+= z4
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
2209 tmp13
= (z1
- z3
) << PASS1_BITS
;
2211 /* Final output stage */
2213 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2214 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
2215 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2216 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
2217 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2218 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
2219 wsptr
[8*3] = (int) (tmp23
+ tmp13
);
2220 wsptr
[8*10] = (int) (tmp23
- tmp13
);
2221 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
2222 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
2223 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
2224 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
2225 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
2226 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
2229 /* Pass 2: process 14 rows from work array, store into output array. */
2232 for (ctr
= 0; ctr
< 14; ctr
++) {
2233 outptr
= output_buf
[ctr
] + output_col
;
2237 /* Add range center and fudge factor for final descale and range-limit. */
2238 z1
= (INT32
) wsptr
[0] +
2239 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
2240 (ONE
<< (PASS1_BITS
+2)));
2242 z4
= (INT32
) wsptr
[4];
2243 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
2244 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
2245 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
2251 tmp23
= z1
- ((z2
+ z3
- z4
) << 1); /* c0 = (c4+c12-c8)*2 */
2253 z1
= (INT32
) wsptr
[2];
2254 z2
= (INT32
) wsptr
[6];
2256 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
2258 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
2259 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
2260 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
2261 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
2263 tmp20
= tmp10
+ tmp13
;
2264 tmp26
= tmp10
- tmp13
;
2265 tmp21
= tmp11
+ tmp14
;
2266 tmp25
= tmp11
- tmp14
;
2267 tmp22
= tmp12
+ tmp15
;
2268 tmp24
= tmp12
- tmp15
;
2272 z1
= (INT32
) wsptr
[1];
2273 z2
= (INT32
) wsptr
[3];
2274 z3
= (INT32
) wsptr
[5];
2275 z4
= (INT32
) wsptr
[7];
2279 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
2280 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
2281 tmp10
= tmp11
+ tmp12
+ z4
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
2282 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
2283 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
2285 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - z4
; /* c11 */
2287 tmp13
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - z4
; /* -c13 */
2288 tmp11
+= tmp13
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
2289 tmp12
+= tmp13
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
2290 tmp13
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
2291 tmp14
+= tmp13
+ z4
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
2292 tmp15
+= tmp13
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
2294 tmp13
= ((z1
- z3
) << CONST_BITS
) + z4
;
2296 /* Final output stage */
2298 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2299 CONST_BITS
+PASS1_BITS
+3)
2301 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2302 CONST_BITS
+PASS1_BITS
+3)
2304 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2305 CONST_BITS
+PASS1_BITS
+3)
2307 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2308 CONST_BITS
+PASS1_BITS
+3)
2310 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2311 CONST_BITS
+PASS1_BITS
+3)
2313 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2314 CONST_BITS
+PASS1_BITS
+3)
2316 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2317 CONST_BITS
+PASS1_BITS
+3)
2319 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2320 CONST_BITS
+PASS1_BITS
+3)
2322 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2323 CONST_BITS
+PASS1_BITS
+3)
2325 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2326 CONST_BITS
+PASS1_BITS
+3)
2328 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2329 CONST_BITS
+PASS1_BITS
+3)
2331 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2332 CONST_BITS
+PASS1_BITS
+3)
2334 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
2335 CONST_BITS
+PASS1_BITS
+3)
2337 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
2338 CONST_BITS
+PASS1_BITS
+3)
2341 wsptr
+= 8; /* advance pointer to next row */
2347 * Perform dequantization and inverse DCT on one block of coefficients,
2348 * producing a 15x15 output block.
2350 * Optimized algorithm with 22 multiplications in the 1-D kernel.
2351 * cK represents sqrt(2) * cos(K*pi/30).
2355 jpeg_idct_15x15 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2356 JCOEFPTR coef_block
,
2357 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2359 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
2360 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2361 INT32 z1
, z2
, z3
, z4
;
2363 ISLOW_MULT_TYPE
* quantptr
;
2366 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2368 int workspace
[8*15]; /* buffers data between passes */
2371 /* Pass 1: process columns from input, store into work array. */
2374 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2376 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2379 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2381 /* Add fudge factor here for final descale. */
2382 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2384 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2385 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2386 z4
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2388 tmp10
= MULTIPLY(z4
, FIX(0.437016024)); /* c12 */
2389 tmp11
= MULTIPLY(z4
, FIX(1.144122806)); /* c6 */
2393 z1
-= (tmp11
- tmp10
) << 1; /* c0 = (c6-c12)*2 */
2397 tmp10
= MULTIPLY(z3
, FIX(1.337628990)); /* (c2+c4)/2 */
2398 tmp11
= MULTIPLY(z4
, FIX(0.045680613)); /* (c2-c4)/2 */
2399 z2
= MULTIPLY(z2
, FIX(1.439773946)); /* c4+c14 */
2401 tmp20
= tmp13
+ tmp10
+ tmp11
;
2402 tmp23
= tmp12
- tmp10
+ tmp11
+ z2
;
2404 tmp10
= MULTIPLY(z3
, FIX(0.547059574)); /* (c8+c14)/2 */
2405 tmp11
= MULTIPLY(z4
, FIX(0.399234004)); /* (c8-c14)/2 */
2407 tmp25
= tmp13
- tmp10
- tmp11
;
2408 tmp26
= tmp12
+ tmp10
- tmp11
- z2
;
2410 tmp10
= MULTIPLY(z3
, FIX(0.790569415)); /* (c6+c12)/2 */
2411 tmp11
= MULTIPLY(z4
, FIX(0.353553391)); /* (c6-c12)/2 */
2413 tmp21
= tmp12
+ tmp10
+ tmp11
;
2414 tmp24
= tmp13
- tmp10
+ tmp11
;
2416 tmp22
= z1
+ tmp11
; /* c10 = c6-c12 */
2417 tmp27
= z1
- tmp11
- tmp11
; /* c0 = (c6-c12)*2 */
2421 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2422 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2423 z4
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2424 z3
= MULTIPLY(z4
, FIX(1.224744871)); /* c5 */
2425 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2428 tmp15
= MULTIPLY(z1
+ tmp13
, FIX(0.831253876)); /* c9 */
2429 tmp11
= tmp15
+ MULTIPLY(z1
, FIX(0.513743148)); /* c3-c9 */
2430 tmp14
= tmp15
- MULTIPLY(tmp13
, FIX(2.176250899)); /* c3+c9 */
2432 tmp13
= MULTIPLY(z2
, - FIX(0.831253876)); /* -c9 */
2433 tmp15
= MULTIPLY(z2
, - FIX(1.344997024)); /* -c3 */
2435 tmp12
= z3
+ MULTIPLY(z2
, FIX(1.406466353)); /* c1 */
2437 tmp10
= tmp12
+ MULTIPLY(z4
, FIX(2.457431844)) - tmp15
; /* c1+c7 */
2438 tmp16
= tmp12
- MULTIPLY(z1
, FIX(1.112434820)) + tmp13
; /* c1-c13 */
2439 tmp12
= MULTIPLY(z2
, FIX(1.224744871)) - z3
; /* c5 */
2440 z2
= MULTIPLY(z1
+ z4
, FIX(0.575212477)); /* c11 */
2441 tmp13
+= z2
+ MULTIPLY(z1
, FIX(0.475753014)) - z3
; /* c7-c11 */
2442 tmp15
+= z2
- MULTIPLY(z4
, FIX(0.869244010)) + z3
; /* c11+c13 */
2444 /* Final output stage */
2446 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2447 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
2448 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2449 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
2450 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2451 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
2452 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
2453 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
2454 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
2455 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
2456 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
2457 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
2458 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
2459 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
2460 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
, CONST_BITS
-PASS1_BITS
);
2463 /* Pass 2: process 15 rows from work array, store into output array. */
2466 for (ctr
= 0; ctr
< 15; ctr
++) {
2467 outptr
= output_buf
[ctr
] + output_col
;
2471 /* Add range center and fudge factor for final descale and range-limit. */
2472 z1
= (INT32
) wsptr
[0] +
2473 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
2474 (ONE
<< (PASS1_BITS
+2)));
2477 z2
= (INT32
) wsptr
[2];
2478 z3
= (INT32
) wsptr
[4];
2479 z4
= (INT32
) wsptr
[6];
2481 tmp10
= MULTIPLY(z4
, FIX(0.437016024)); /* c12 */
2482 tmp11
= MULTIPLY(z4
, FIX(1.144122806)); /* c6 */
2486 z1
-= (tmp11
- tmp10
) << 1; /* c0 = (c6-c12)*2 */
2490 tmp10
= MULTIPLY(z3
, FIX(1.337628990)); /* (c2+c4)/2 */
2491 tmp11
= MULTIPLY(z4
, FIX(0.045680613)); /* (c2-c4)/2 */
2492 z2
= MULTIPLY(z2
, FIX(1.439773946)); /* c4+c14 */
2494 tmp20
= tmp13
+ tmp10
+ tmp11
;
2495 tmp23
= tmp12
- tmp10
+ tmp11
+ z2
;
2497 tmp10
= MULTIPLY(z3
, FIX(0.547059574)); /* (c8+c14)/2 */
2498 tmp11
= MULTIPLY(z4
, FIX(0.399234004)); /* (c8-c14)/2 */
2500 tmp25
= tmp13
- tmp10
- tmp11
;
2501 tmp26
= tmp12
+ tmp10
- tmp11
- z2
;
2503 tmp10
= MULTIPLY(z3
, FIX(0.790569415)); /* (c6+c12)/2 */
2504 tmp11
= MULTIPLY(z4
, FIX(0.353553391)); /* (c6-c12)/2 */
2506 tmp21
= tmp12
+ tmp10
+ tmp11
;
2507 tmp24
= tmp13
- tmp10
+ tmp11
;
2509 tmp22
= z1
+ tmp11
; /* c10 = c6-c12 */
2510 tmp27
= z1
- tmp11
- tmp11
; /* c0 = (c6-c12)*2 */
2514 z1
= (INT32
) wsptr
[1];
2515 z2
= (INT32
) wsptr
[3];
2516 z4
= (INT32
) wsptr
[5];
2517 z3
= MULTIPLY(z4
, FIX(1.224744871)); /* c5 */
2518 z4
= (INT32
) wsptr
[7];
2521 tmp15
= MULTIPLY(z1
+ tmp13
, FIX(0.831253876)); /* c9 */
2522 tmp11
= tmp15
+ MULTIPLY(z1
, FIX(0.513743148)); /* c3-c9 */
2523 tmp14
= tmp15
- MULTIPLY(tmp13
, FIX(2.176250899)); /* c3+c9 */
2525 tmp13
= MULTIPLY(z2
, - FIX(0.831253876)); /* -c9 */
2526 tmp15
= MULTIPLY(z2
, - FIX(1.344997024)); /* -c3 */
2528 tmp12
= z3
+ MULTIPLY(z2
, FIX(1.406466353)); /* c1 */
2530 tmp10
= tmp12
+ MULTIPLY(z4
, FIX(2.457431844)) - tmp15
; /* c1+c7 */
2531 tmp16
= tmp12
- MULTIPLY(z1
, FIX(1.112434820)) + tmp13
; /* c1-c13 */
2532 tmp12
= MULTIPLY(z2
, FIX(1.224744871)) - z3
; /* c5 */
2533 z2
= MULTIPLY(z1
+ z4
, FIX(0.575212477)); /* c11 */
2534 tmp13
+= z2
+ MULTIPLY(z1
, FIX(0.475753014)) - z3
; /* c7-c11 */
2535 tmp15
+= z2
- MULTIPLY(z4
, FIX(0.869244010)) + z3
; /* c11+c13 */
2537 /* Final output stage */
2539 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2540 CONST_BITS
+PASS1_BITS
+3)
2542 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2543 CONST_BITS
+PASS1_BITS
+3)
2545 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2546 CONST_BITS
+PASS1_BITS
+3)
2548 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2549 CONST_BITS
+PASS1_BITS
+3)
2551 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2552 CONST_BITS
+PASS1_BITS
+3)
2554 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2555 CONST_BITS
+PASS1_BITS
+3)
2557 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2558 CONST_BITS
+PASS1_BITS
+3)
2560 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2561 CONST_BITS
+PASS1_BITS
+3)
2563 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2564 CONST_BITS
+PASS1_BITS
+3)
2566 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2567 CONST_BITS
+PASS1_BITS
+3)
2569 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2570 CONST_BITS
+PASS1_BITS
+3)
2572 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2573 CONST_BITS
+PASS1_BITS
+3)
2575 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
2576 CONST_BITS
+PASS1_BITS
+3)
2578 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
2579 CONST_BITS
+PASS1_BITS
+3)
2581 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
,
2582 CONST_BITS
+PASS1_BITS
+3)
2585 wsptr
+= 8; /* advance pointer to next row */
2591 * Perform dequantization and inverse DCT on one block of coefficients,
2592 * producing a 16x16 output block.
2594 * Optimized algorithm with 28 multiplications in the 1-D kernel.
2595 * cK represents sqrt(2) * cos(K*pi/32).
2599 jpeg_idct_16x16 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2600 JCOEFPTR coef_block
,
2601 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2603 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
2604 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2605 INT32 z1
, z2
, z3
, z4
;
2607 ISLOW_MULT_TYPE
* quantptr
;
2610 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2612 int workspace
[8*16]; /* buffers data between passes */
2615 /* Pass 1: process columns from input, store into work array. */
2618 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2620 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2623 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2624 tmp0
<<= CONST_BITS
;
2625 /* Add fudge factor here for final descale. */
2626 tmp0
+= 1 << (CONST_BITS
-PASS1_BITS
-1);
2628 z1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2629 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
2630 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
2632 tmp10
= tmp0
+ tmp1
;
2633 tmp11
= tmp0
- tmp1
;
2634 tmp12
= tmp0
+ tmp2
;
2635 tmp13
= tmp0
- tmp2
;
2637 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2638 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2640 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
2641 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
2643 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
2644 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
2645 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
2646 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
2648 tmp20
= tmp10
+ tmp0
;
2649 tmp27
= tmp10
- tmp0
;
2650 tmp21
= tmp12
+ tmp1
;
2651 tmp26
= tmp12
- tmp1
;
2652 tmp22
= tmp13
+ tmp2
;
2653 tmp25
= tmp13
- tmp2
;
2654 tmp23
= tmp11
+ tmp3
;
2655 tmp24
= tmp11
- tmp3
;
2659 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2660 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2661 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2662 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2666 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
2667 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
2668 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
2669 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
2670 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
2671 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
2672 tmp0
= tmp1
+ tmp2
+ tmp3
-
2673 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
2674 tmp13
= tmp10
+ tmp11
+ tmp12
-
2675 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
2676 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
2677 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
2678 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
2679 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
2680 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
2681 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
2683 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
2685 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
2686 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
2687 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
2689 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
2692 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
2696 /* Final output stage */
2698 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp0
, CONST_BITS
-PASS1_BITS
);
2699 wsptr
[8*15] = (int) RIGHT_SHIFT(tmp20
- tmp0
, CONST_BITS
-PASS1_BITS
);
2700 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp1
, CONST_BITS
-PASS1_BITS
);
2701 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp21
- tmp1
, CONST_BITS
-PASS1_BITS
);
2702 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp2
, CONST_BITS
-PASS1_BITS
);
2703 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp22
- tmp2
, CONST_BITS
-PASS1_BITS
);
2704 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp3
, CONST_BITS
-PASS1_BITS
);
2705 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp23
- tmp3
, CONST_BITS
-PASS1_BITS
);
2706 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2707 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp24
- tmp10
, CONST_BITS
-PASS1_BITS
);
2708 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2709 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp25
- tmp11
, CONST_BITS
-PASS1_BITS
);
2710 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2711 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp26
- tmp12
, CONST_BITS
-PASS1_BITS
);
2712 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
+ tmp13
, CONST_BITS
-PASS1_BITS
);
2713 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp27
- tmp13
, CONST_BITS
-PASS1_BITS
);
2716 /* Pass 2: process 16 rows from work array, store into output array. */
2719 for (ctr
= 0; ctr
< 16; ctr
++) {
2720 outptr
= output_buf
[ctr
] + output_col
;
2724 /* Add range center and fudge factor for final descale and range-limit. */
2725 tmp0
= (INT32
) wsptr
[0] +
2726 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
2727 (ONE
<< (PASS1_BITS
+2)));
2728 tmp0
<<= CONST_BITS
;
2730 z1
= (INT32
) wsptr
[4];
2731 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
2732 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
2734 tmp10
= tmp0
+ tmp1
;
2735 tmp11
= tmp0
- tmp1
;
2736 tmp12
= tmp0
+ tmp2
;
2737 tmp13
= tmp0
- tmp2
;
2739 z1
= (INT32
) wsptr
[2];
2740 z2
= (INT32
) wsptr
[6];
2742 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
2743 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
2745 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
2746 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
2747 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
2748 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
2750 tmp20
= tmp10
+ tmp0
;
2751 tmp27
= tmp10
- tmp0
;
2752 tmp21
= tmp12
+ tmp1
;
2753 tmp26
= tmp12
- tmp1
;
2754 tmp22
= tmp13
+ tmp2
;
2755 tmp25
= tmp13
- tmp2
;
2756 tmp23
= tmp11
+ tmp3
;
2757 tmp24
= tmp11
- tmp3
;
2761 z1
= (INT32
) wsptr
[1];
2762 z2
= (INT32
) wsptr
[3];
2763 z3
= (INT32
) wsptr
[5];
2764 z4
= (INT32
) wsptr
[7];
2768 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
2769 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
2770 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
2771 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
2772 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
2773 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
2774 tmp0
= tmp1
+ tmp2
+ tmp3
-
2775 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
2776 tmp13
= tmp10
+ tmp11
+ tmp12
-
2777 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
2778 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
2779 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
2780 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
2781 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
2782 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
2783 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
2785 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
2787 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
2788 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
2789 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
2791 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
2794 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
2798 /* Final output stage */
2800 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp0
,
2801 CONST_BITS
+PASS1_BITS
+3)
2803 outptr
[15] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp0
,
2804 CONST_BITS
+PASS1_BITS
+3)
2806 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp1
,
2807 CONST_BITS
+PASS1_BITS
+3)
2809 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp1
,
2810 CONST_BITS
+PASS1_BITS
+3)
2812 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp2
,
2813 CONST_BITS
+PASS1_BITS
+3)
2815 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp2
,
2816 CONST_BITS
+PASS1_BITS
+3)
2818 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp3
,
2819 CONST_BITS
+PASS1_BITS
+3)
2821 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp3
,
2822 CONST_BITS
+PASS1_BITS
+3)
2824 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp10
,
2825 CONST_BITS
+PASS1_BITS
+3)
2827 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp10
,
2828 CONST_BITS
+PASS1_BITS
+3)
2830 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp11
,
2831 CONST_BITS
+PASS1_BITS
+3)
2833 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp11
,
2834 CONST_BITS
+PASS1_BITS
+3)
2836 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp12
,
2837 CONST_BITS
+PASS1_BITS
+3)
2839 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp12
,
2840 CONST_BITS
+PASS1_BITS
+3)
2842 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
+ tmp13
,
2843 CONST_BITS
+PASS1_BITS
+3)
2845 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp27
- tmp13
,
2846 CONST_BITS
+PASS1_BITS
+3)
2849 wsptr
+= 8; /* advance pointer to next row */
2855 * Perform dequantization and inverse DCT on one block of coefficients,
2856 * producing a 16x8 output block.
2858 * 8-point IDCT in pass 1 (columns), 16-point in pass 2 (rows).
2862 jpeg_idct_16x8 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2863 JCOEFPTR coef_block
,
2864 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2866 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
2867 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2868 INT32 z1
, z2
, z3
, z4
;
2870 ISLOW_MULT_TYPE
* quantptr
;
2873 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2875 int workspace
[8*8]; /* buffers data between passes */
2878 /* Pass 1: process columns from input, store into work array.
2879 * Note results are scaled up by sqrt(8) compared to a true IDCT;
2880 * furthermore, we scale the results by 2**PASS1_BITS.
2881 * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
2885 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2887 for (ctr
= DCTSIZE
; ctr
> 0; ctr
--) {
2888 /* Due to quantization, we will usually find that many of the input
2889 * coefficients are zero, especially the AC terms. We can exploit this
2890 * by short-circuiting the IDCT calculation for any column in which all
2891 * the AC terms are zero. In that case each output is equal to the
2892 * DC coefficient (with scale factor as needed).
2893 * With typical images and quantization tables, half or more of the
2894 * column DCT calculations can be simplified this way.
2897 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
2898 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
2899 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
2900 inptr
[DCTSIZE
*7] == 0) {
2901 /* AC terms all zero */
2902 int dcval
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]) << PASS1_BITS
;
2904 wsptr
[DCTSIZE
*0] = dcval
;
2905 wsptr
[DCTSIZE
*1] = dcval
;
2906 wsptr
[DCTSIZE
*2] = dcval
;
2907 wsptr
[DCTSIZE
*3] = dcval
;
2908 wsptr
[DCTSIZE
*4] = dcval
;
2909 wsptr
[DCTSIZE
*5] = dcval
;
2910 wsptr
[DCTSIZE
*6] = dcval
;
2911 wsptr
[DCTSIZE
*7] = dcval
;
2913 inptr
++; /* advance pointers to next column */
2919 /* Even part: reverse the even part of the forward DCT.
2920 * The rotator is c(-6).
2923 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2924 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2926 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
2927 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
2928 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
2930 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2931 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2934 /* Add fudge factor here for final descale. */
2935 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2940 tmp10
= tmp0
+ tmp2
;
2941 tmp13
= tmp0
- tmp2
;
2942 tmp11
= tmp1
+ tmp3
;
2943 tmp12
= tmp1
- tmp3
;
2945 /* Odd part per figure 8; the matrix is unitary and hence its
2946 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
2949 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2950 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2951 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2952 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2957 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* c3 */
2958 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* -c3-c5 */
2959 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* -c3+c5 */
2963 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* -c3+c7 */
2964 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* -c1+c3+c5-c7 */
2965 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* c1+c3-c5-c7 */
2969 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* -c1-c3 */
2970 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* c1+c3-c5+c7 */
2971 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* c1+c3+c5-c7 */
2975 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
2977 wsptr
[DCTSIZE
*0] = (int) RIGHT_SHIFT(tmp10
+ tmp3
, CONST_BITS
-PASS1_BITS
);
2978 wsptr
[DCTSIZE
*7] = (int) RIGHT_SHIFT(tmp10
- tmp3
, CONST_BITS
-PASS1_BITS
);
2979 wsptr
[DCTSIZE
*1] = (int) RIGHT_SHIFT(tmp11
+ tmp2
, CONST_BITS
-PASS1_BITS
);
2980 wsptr
[DCTSIZE
*6] = (int) RIGHT_SHIFT(tmp11
- tmp2
, CONST_BITS
-PASS1_BITS
);
2981 wsptr
[DCTSIZE
*2] = (int) RIGHT_SHIFT(tmp12
+ tmp1
, CONST_BITS
-PASS1_BITS
);
2982 wsptr
[DCTSIZE
*5] = (int) RIGHT_SHIFT(tmp12
- tmp1
, CONST_BITS
-PASS1_BITS
);
2983 wsptr
[DCTSIZE
*3] = (int) RIGHT_SHIFT(tmp13
+ tmp0
, CONST_BITS
-PASS1_BITS
);
2984 wsptr
[DCTSIZE
*4] = (int) RIGHT_SHIFT(tmp13
- tmp0
, CONST_BITS
-PASS1_BITS
);
2986 inptr
++; /* advance pointers to next column */
2991 /* Pass 2: process 8 rows from work array, store into output array.
2992 * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
2996 for (ctr
= 0; ctr
< 8; ctr
++) {
2997 outptr
= output_buf
[ctr
] + output_col
;
3001 /* Add range center and fudge factor for final descale and range-limit. */
3002 tmp0
= (INT32
) wsptr
[0] +
3003 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3004 (ONE
<< (PASS1_BITS
+2)));
3005 tmp0
<<= CONST_BITS
;
3007 z1
= (INT32
) wsptr
[4];
3008 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
3009 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
3011 tmp10
= tmp0
+ tmp1
;
3012 tmp11
= tmp0
- tmp1
;
3013 tmp12
= tmp0
+ tmp2
;
3014 tmp13
= tmp0
- tmp2
;
3016 z1
= (INT32
) wsptr
[2];
3017 z2
= (INT32
) wsptr
[6];
3019 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
3020 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
3022 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
3023 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
3024 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
3025 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
3027 tmp20
= tmp10
+ tmp0
;
3028 tmp27
= tmp10
- tmp0
;
3029 tmp21
= tmp12
+ tmp1
;
3030 tmp26
= tmp12
- tmp1
;
3031 tmp22
= tmp13
+ tmp2
;
3032 tmp25
= tmp13
- tmp2
;
3033 tmp23
= tmp11
+ tmp3
;
3034 tmp24
= tmp11
- tmp3
;
3038 z1
= (INT32
) wsptr
[1];
3039 z2
= (INT32
) wsptr
[3];
3040 z3
= (INT32
) wsptr
[5];
3041 z4
= (INT32
) wsptr
[7];
3045 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
3046 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
3047 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
3048 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
3049 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
3050 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
3051 tmp0
= tmp1
+ tmp2
+ tmp3
-
3052 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
3053 tmp13
= tmp10
+ tmp11
+ tmp12
-
3054 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
3055 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
3056 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
3057 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
3058 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
3059 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
3060 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
3062 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
3064 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
3065 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
3066 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
3068 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
3071 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
3075 /* Final output stage */
3077 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp0
,
3078 CONST_BITS
+PASS1_BITS
+3)
3080 outptr
[15] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp0
,
3081 CONST_BITS
+PASS1_BITS
+3)
3083 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp1
,
3084 CONST_BITS
+PASS1_BITS
+3)
3086 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp1
,
3087 CONST_BITS
+PASS1_BITS
+3)
3089 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp2
,
3090 CONST_BITS
+PASS1_BITS
+3)
3092 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp2
,
3093 CONST_BITS
+PASS1_BITS
+3)
3095 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp3
,
3096 CONST_BITS
+PASS1_BITS
+3)
3098 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp3
,
3099 CONST_BITS
+PASS1_BITS
+3)
3101 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp10
,
3102 CONST_BITS
+PASS1_BITS
+3)
3104 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp10
,
3105 CONST_BITS
+PASS1_BITS
+3)
3107 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp11
,
3108 CONST_BITS
+PASS1_BITS
+3)
3110 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp11
,
3111 CONST_BITS
+PASS1_BITS
+3)
3113 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp12
,
3114 CONST_BITS
+PASS1_BITS
+3)
3116 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp12
,
3117 CONST_BITS
+PASS1_BITS
+3)
3119 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
+ tmp13
,
3120 CONST_BITS
+PASS1_BITS
+3)
3122 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp27
- tmp13
,
3123 CONST_BITS
+PASS1_BITS
+3)
3126 wsptr
+= 8; /* advance pointer to next row */
3132 * Perform dequantization and inverse DCT on one block of coefficients,
3133 * producing a 14x7 output block.
3135 * 7-point IDCT in pass 1 (columns), 14-point in pass 2 (rows).
3139 jpeg_idct_14x7 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3140 JCOEFPTR coef_block
,
3141 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3143 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
3144 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
3145 INT32 z1
, z2
, z3
, z4
;
3147 ISLOW_MULT_TYPE
* quantptr
;
3150 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3152 int workspace
[8*7]; /* buffers data between passes */
3155 /* Pass 1: process columns from input, store into work array.
3156 * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14).
3160 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3162 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3165 tmp23
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3166 tmp23
<<= CONST_BITS
;
3167 /* Add fudge factor here for final descale. */
3168 tmp23
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3170 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3171 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3172 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
3174 tmp20
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
3175 tmp22
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
3176 tmp21
= tmp20
+ tmp22
+ tmp23
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
3179 tmp10
= MULTIPLY(tmp10
, FIX(1.274162392)) + tmp23
; /* c2 */
3180 tmp20
+= tmp10
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
3181 tmp22
+= tmp10
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
3182 tmp23
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
3186 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3187 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3188 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
3190 tmp11
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
3191 tmp12
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
3192 tmp10
= tmp11
- tmp12
;
3194 tmp12
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
3196 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
3198 tmp12
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
3200 /* Final output stage */
3202 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
3203 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
3204 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
3205 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
3206 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
3207 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
3208 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
, CONST_BITS
-PASS1_BITS
);
3211 /* Pass 2: process 7 rows from work array, store into output array.
3212 * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28).
3216 for (ctr
= 0; ctr
< 7; ctr
++) {
3217 outptr
= output_buf
[ctr
] + output_col
;
3221 /* Add range center and fudge factor for final descale and range-limit. */
3222 z1
= (INT32
) wsptr
[0] +
3223 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3224 (ONE
<< (PASS1_BITS
+2)));
3226 z4
= (INT32
) wsptr
[4];
3227 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
3228 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
3229 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
3235 tmp23
= z1
- ((z2
+ z3
- z4
) << 1); /* c0 = (c4+c12-c8)*2 */
3237 z1
= (INT32
) wsptr
[2];
3238 z2
= (INT32
) wsptr
[6];
3240 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
3242 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
3243 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
3244 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
3245 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
3247 tmp20
= tmp10
+ tmp13
;
3248 tmp26
= tmp10
- tmp13
;
3249 tmp21
= tmp11
+ tmp14
;
3250 tmp25
= tmp11
- tmp14
;
3251 tmp22
= tmp12
+ tmp15
;
3252 tmp24
= tmp12
- tmp15
;
3256 z1
= (INT32
) wsptr
[1];
3257 z2
= (INT32
) wsptr
[3];
3258 z3
= (INT32
) wsptr
[5];
3259 z4
= (INT32
) wsptr
[7];
3263 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
3264 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
3265 tmp10
= tmp11
+ tmp12
+ z4
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
3266 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
3267 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
3269 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - z4
; /* c11 */
3271 tmp13
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - z4
; /* -c13 */
3272 tmp11
+= tmp13
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
3273 tmp12
+= tmp13
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
3274 tmp13
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
3275 tmp14
+= tmp13
+ z4
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
3276 tmp15
+= tmp13
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
3278 tmp13
= ((z1
- z3
) << CONST_BITS
) + z4
;
3280 /* Final output stage */
3282 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3283 CONST_BITS
+PASS1_BITS
+3)
3285 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3286 CONST_BITS
+PASS1_BITS
+3)
3288 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3289 CONST_BITS
+PASS1_BITS
+3)
3291 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3292 CONST_BITS
+PASS1_BITS
+3)
3294 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3295 CONST_BITS
+PASS1_BITS
+3)
3297 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3298 CONST_BITS
+PASS1_BITS
+3)
3300 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3301 CONST_BITS
+PASS1_BITS
+3)
3303 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3304 CONST_BITS
+PASS1_BITS
+3)
3306 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3307 CONST_BITS
+PASS1_BITS
+3)
3309 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3310 CONST_BITS
+PASS1_BITS
+3)
3312 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
3313 CONST_BITS
+PASS1_BITS
+3)
3315 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
3316 CONST_BITS
+PASS1_BITS
+3)
3318 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
3319 CONST_BITS
+PASS1_BITS
+3)
3321 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
3322 CONST_BITS
+PASS1_BITS
+3)
3325 wsptr
+= 8; /* advance pointer to next row */
3331 * Perform dequantization and inverse DCT on one block of coefficients,
3332 * producing a 12x6 output block.
3334 * 6-point IDCT in pass 1 (columns), 12-point in pass 2 (rows).
3338 jpeg_idct_12x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3339 JCOEFPTR coef_block
,
3340 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3342 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
3343 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
3344 INT32 z1
, z2
, z3
, z4
;
3346 ISLOW_MULT_TYPE
* quantptr
;
3349 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3351 int workspace
[8*6]; /* buffers data between passes */
3354 /* Pass 1: process columns from input, store into work array.
3355 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
3359 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3361 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3364 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3365 tmp10
<<= CONST_BITS
;
3366 /* Add fudge factor here for final descale. */
3367 tmp10
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3368 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3369 tmp20
= MULTIPLY(tmp12
, FIX(0.707106781)); /* c4 */
3370 tmp11
= tmp10
+ tmp20
;
3371 tmp21
= RIGHT_SHIFT(tmp10
- tmp20
- tmp20
, CONST_BITS
-PASS1_BITS
);
3372 tmp20
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3373 tmp10
= MULTIPLY(tmp20
, FIX(1.224744871)); /* c2 */
3374 tmp20
= tmp11
+ tmp10
;
3375 tmp22
= tmp11
- tmp10
;
3379 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3380 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3381 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
3382 tmp11
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
3383 tmp10
= tmp11
+ ((z1
+ z2
) << CONST_BITS
);
3384 tmp12
= tmp11
+ ((z3
- z2
) << CONST_BITS
);
3385 tmp11
= (z1
- z2
- z3
) << PASS1_BITS
;
3387 /* Final output stage */
3389 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
3390 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
3391 wsptr
[8*1] = (int) (tmp21
+ tmp11
);
3392 wsptr
[8*4] = (int) (tmp21
- tmp11
);
3393 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
3394 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
3397 /* Pass 2: process 6 rows from work array, store into output array.
3398 * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24).
3402 for (ctr
= 0; ctr
< 6; ctr
++) {
3403 outptr
= output_buf
[ctr
] + output_col
;
3407 /* Add range center and fudge factor for final descale and range-limit. */
3408 z3
= (INT32
) wsptr
[0] +
3409 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3410 (ONE
<< (PASS1_BITS
+2)));
3413 z4
= (INT32
) wsptr
[4];
3414 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
3419 z1
= (INT32
) wsptr
[2];
3420 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
3422 z2
= (INT32
) wsptr
[6];
3432 tmp20
= tmp10
+ tmp12
;
3433 tmp25
= tmp10
- tmp12
;
3435 tmp12
= z4
- z1
- z2
;
3437 tmp22
= tmp11
+ tmp12
;
3438 tmp23
= tmp11
- tmp12
;
3442 z1
= (INT32
) wsptr
[1];
3443 z2
= (INT32
) wsptr
[3];
3444 z3
= (INT32
) wsptr
[5];
3445 z4
= (INT32
) wsptr
[7];
3447 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
3448 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
3451 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
3452 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
3453 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
3454 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
3455 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
3456 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
3457 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
3458 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
3462 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
3463 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
3464 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
3466 /* Final output stage */
3468 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3469 CONST_BITS
+PASS1_BITS
+3)
3471 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3472 CONST_BITS
+PASS1_BITS
+3)
3474 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3475 CONST_BITS
+PASS1_BITS
+3)
3477 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3478 CONST_BITS
+PASS1_BITS
+3)
3480 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3481 CONST_BITS
+PASS1_BITS
+3)
3483 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3484 CONST_BITS
+PASS1_BITS
+3)
3486 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3487 CONST_BITS
+PASS1_BITS
+3)
3489 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3490 CONST_BITS
+PASS1_BITS
+3)
3492 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3493 CONST_BITS
+PASS1_BITS
+3)
3495 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3496 CONST_BITS
+PASS1_BITS
+3)
3498 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
3499 CONST_BITS
+PASS1_BITS
+3)
3501 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
3502 CONST_BITS
+PASS1_BITS
+3)
3505 wsptr
+= 8; /* advance pointer to next row */
3511 * Perform dequantization and inverse DCT on one block of coefficients,
3512 * producing a 10x5 output block.
3514 * 5-point IDCT in pass 1 (columns), 10-point in pass 2 (rows).
3518 jpeg_idct_10x5 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3519 JCOEFPTR coef_block
,
3520 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3522 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
3523 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
3524 INT32 z1
, z2
, z3
, z4
;
3526 ISLOW_MULT_TYPE
* quantptr
;
3529 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3531 int workspace
[8*5]; /* buffers data between passes */
3534 /* Pass 1: process columns from input, store into work array.
3535 * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10).
3539 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3541 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3544 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3545 tmp12
<<= CONST_BITS
;
3546 /* Add fudge factor here for final descale. */
3547 tmp12
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3548 tmp13
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3549 tmp14
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3550 z1
= MULTIPLY(tmp13
+ tmp14
, FIX(0.790569415)); /* (c2+c4)/2 */
3551 z2
= MULTIPLY(tmp13
- tmp14
, FIX(0.353553391)); /* (c2-c4)/2 */
3559 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3560 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3562 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
3563 tmp13
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
3564 tmp14
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
3566 /* Final output stage */
3568 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp10
+ tmp13
, CONST_BITS
-PASS1_BITS
);
3569 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp10
- tmp13
, CONST_BITS
-PASS1_BITS
);
3570 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp11
+ tmp14
, CONST_BITS
-PASS1_BITS
);
3571 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp11
- tmp14
, CONST_BITS
-PASS1_BITS
);
3572 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp12
, CONST_BITS
-PASS1_BITS
);
3575 /* Pass 2: process 5 rows from work array, store into output array.
3576 * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20).
3580 for (ctr
= 0; ctr
< 5; ctr
++) {
3581 outptr
= output_buf
[ctr
] + output_col
;
3585 /* Add range center and fudge factor for final descale and range-limit. */
3586 z3
= (INT32
) wsptr
[0] +
3587 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3588 (ONE
<< (PASS1_BITS
+2)));
3590 z4
= (INT32
) wsptr
[4];
3591 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
3592 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
3596 tmp22
= z3
- ((z1
- z2
) << 1); /* c0 = (c4-c8)*2 */
3598 z2
= (INT32
) wsptr
[2];
3599 z3
= (INT32
) wsptr
[6];
3601 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
3602 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
3603 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
3605 tmp20
= tmp10
+ tmp12
;
3606 tmp24
= tmp10
- tmp12
;
3607 tmp21
= tmp11
+ tmp13
;
3608 tmp23
= tmp11
- tmp13
;
3612 z1
= (INT32
) wsptr
[1];
3613 z2
= (INT32
) wsptr
[3];
3614 z3
= (INT32
) wsptr
[5];
3616 z4
= (INT32
) wsptr
[7];
3621 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
3623 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
3626 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
3627 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
3629 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
3630 z4
= z3
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
3632 tmp12
= ((z1
- tmp13
) << CONST_BITS
) - z3
;
3634 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
3635 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
3637 /* Final output stage */
3639 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3640 CONST_BITS
+PASS1_BITS
+3)
3642 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3643 CONST_BITS
+PASS1_BITS
+3)
3645 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3646 CONST_BITS
+PASS1_BITS
+3)
3648 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3649 CONST_BITS
+PASS1_BITS
+3)
3651 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3652 CONST_BITS
+PASS1_BITS
+3)
3654 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3655 CONST_BITS
+PASS1_BITS
+3)
3657 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3658 CONST_BITS
+PASS1_BITS
+3)
3660 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3661 CONST_BITS
+PASS1_BITS
+3)
3663 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3664 CONST_BITS
+PASS1_BITS
+3)
3666 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3667 CONST_BITS
+PASS1_BITS
+3)
3670 wsptr
+= 8; /* advance pointer to next row */
3676 * Perform dequantization and inverse DCT on one block of coefficients,
3677 * producing a 8x4 output block.
3679 * 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
3683 jpeg_idct_8x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3684 JCOEFPTR coef_block
,
3685 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3687 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
3688 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
3691 ISLOW_MULT_TYPE
* quantptr
;
3694 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3696 int workspace
[8*4]; /* buffers data between passes */
3699 /* Pass 1: process columns from input, store into work array.
3700 * 4-point IDCT kernel,
3701 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
3705 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3707 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3710 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3711 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3713 tmp10
= (tmp0
+ tmp2
) << PASS1_BITS
;
3714 tmp12
= (tmp0
- tmp2
) << PASS1_BITS
;
3717 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
3719 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3720 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3722 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
3723 /* Add fudge factor here for final descale. */
3724 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3725 tmp0
= RIGHT_SHIFT(z1
+ MULTIPLY(z2
, FIX_0_765366865
), /* c2-c6 */
3726 CONST_BITS
-PASS1_BITS
);
3727 tmp2
= RIGHT_SHIFT(z1
- MULTIPLY(z3
, FIX_1_847759065
), /* c2+c6 */
3728 CONST_BITS
-PASS1_BITS
);
3730 /* Final output stage */
3732 wsptr
[8*0] = (int) (tmp10
+ tmp0
);
3733 wsptr
[8*3] = (int) (tmp10
- tmp0
);
3734 wsptr
[8*1] = (int) (tmp12
+ tmp2
);
3735 wsptr
[8*2] = (int) (tmp12
- tmp2
);
3738 /* Pass 2: process rows from work array, store into output array.
3739 * Note that we must descale the results by a factor of 8 == 2**3,
3740 * and also undo the PASS1_BITS scaling.
3741 * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
3745 for (ctr
= 0; ctr
< 4; ctr
++) {
3746 outptr
= output_buf
[ctr
] + output_col
;
3748 /* Even part: reverse the even part of the forward DCT.
3749 * The rotator is c(-6).
3752 /* Add range center and fudge factor for final descale and range-limit. */
3753 z2
= (INT32
) wsptr
[0] +
3754 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3755 (ONE
<< (PASS1_BITS
+2)));
3756 z3
= (INT32
) wsptr
[4];
3758 tmp0
= (z2
+ z3
) << CONST_BITS
;
3759 tmp1
= (z2
- z3
) << CONST_BITS
;
3761 z2
= (INT32
) wsptr
[2];
3762 z3
= (INT32
) wsptr
[6];
3764 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
3765 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
3766 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
3768 tmp10
= tmp0
+ tmp2
;
3769 tmp13
= tmp0
- tmp2
;
3770 tmp11
= tmp1
+ tmp3
;
3771 tmp12
= tmp1
- tmp3
;
3773 /* Odd part per figure 8; the matrix is unitary and hence its
3774 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
3777 tmp0
= (INT32
) wsptr
[7];
3778 tmp1
= (INT32
) wsptr
[5];
3779 tmp2
= (INT32
) wsptr
[3];
3780 tmp3
= (INT32
) wsptr
[1];
3785 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* c3 */
3786 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* -c3-c5 */
3787 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* -c3+c5 */
3791 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* -c3+c7 */
3792 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* -c1+c3+c5-c7 */
3793 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* c1+c3-c5-c7 */
3797 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* -c1-c3 */
3798 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* c1+c3-c5+c7 */
3799 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* c1+c3+c5-c7 */
3803 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
3805 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
3806 CONST_BITS
+PASS1_BITS
+3)
3808 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
3809 CONST_BITS
+PASS1_BITS
+3)
3811 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
3812 CONST_BITS
+PASS1_BITS
+3)
3814 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
3815 CONST_BITS
+PASS1_BITS
+3)
3817 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
3818 CONST_BITS
+PASS1_BITS
+3)
3820 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
3821 CONST_BITS
+PASS1_BITS
+3)
3823 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
3824 CONST_BITS
+PASS1_BITS
+3)
3826 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
3827 CONST_BITS
+PASS1_BITS
+3)
3830 wsptr
+= DCTSIZE
; /* advance pointer to next row */
3836 * Perform dequantization and inverse DCT on one block of coefficients,
3837 * producing a reduced-size 6x3 output block.
3839 * 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
3843 jpeg_idct_6x3 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3844 JCOEFPTR coef_block
,
3845 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3847 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
3850 ISLOW_MULT_TYPE
* quantptr
;
3853 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3855 int workspace
[6*3]; /* buffers data between passes */
3858 /* Pass 1: process columns from input, store into work array.
3859 * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6).
3863 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3865 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3868 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3869 tmp0
<<= CONST_BITS
;
3870 /* Add fudge factor here for final descale. */
3871 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3872 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3873 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
3874 tmp10
= tmp0
+ tmp12
;
3875 tmp2
= tmp0
- tmp12
- tmp12
;
3879 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3880 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
3882 /* Final output stage */
3884 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
3885 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
3886 wsptr
[6*1] = (int) RIGHT_SHIFT(tmp2
, CONST_BITS
-PASS1_BITS
);
3889 /* Pass 2: process 3 rows from work array, store into output array.
3890 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
3894 for (ctr
= 0; ctr
< 3; ctr
++) {
3895 outptr
= output_buf
[ctr
] + output_col
;
3899 /* Add range center and fudge factor for final descale and range-limit. */
3900 tmp0
= (INT32
) wsptr
[0] +
3901 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
3902 (ONE
<< (PASS1_BITS
+2)));
3903 tmp0
<<= CONST_BITS
;
3904 tmp2
= (INT32
) wsptr
[4];
3905 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
3906 tmp1
= tmp0
+ tmp10
;
3907 tmp11
= tmp0
- tmp10
- tmp10
;
3908 tmp10
= (INT32
) wsptr
[2];
3909 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
3910 tmp10
= tmp1
+ tmp0
;
3911 tmp12
= tmp1
- tmp0
;
3915 z1
= (INT32
) wsptr
[1];
3916 z2
= (INT32
) wsptr
[3];
3917 z3
= (INT32
) wsptr
[5];
3918 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
3919 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
3920 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
3921 tmp1
= (z1
- z2
- z3
) << CONST_BITS
;
3923 /* Final output stage */
3925 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
3926 CONST_BITS
+PASS1_BITS
+3)
3928 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
3929 CONST_BITS
+PASS1_BITS
+3)
3931 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
3932 CONST_BITS
+PASS1_BITS
+3)
3934 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
3935 CONST_BITS
+PASS1_BITS
+3)
3937 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
3938 CONST_BITS
+PASS1_BITS
+3)
3940 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
3941 CONST_BITS
+PASS1_BITS
+3)
3944 wsptr
+= 6; /* advance pointer to next row */
3950 * Perform dequantization and inverse DCT on one block of coefficients,
3951 * producing a 4x2 output block.
3953 * 2-point IDCT in pass 1 (columns), 4-point in pass 2 (rows).
3957 jpeg_idct_4x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3958 JCOEFPTR coef_block
,
3959 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3961 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
3964 ISLOW_MULT_TYPE
* quantptr
;
3967 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3969 INT32 workspace
[4*2]; /* buffers data between passes */
3972 /* Pass 1: process columns from input, store into work array. */
3975 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3977 for (ctr
= 0; ctr
< 4; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3980 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3984 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3986 /* Final output stage */
3988 wsptr
[4*0] = tmp10
+ tmp0
;
3989 wsptr
[4*1] = tmp10
- tmp0
;
3992 /* Pass 2: process 2 rows from work array, store into output array.
3993 * 4-point IDCT kernel,
3994 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
3998 for (ctr
= 0; ctr
< 2; ctr
++) {
3999 outptr
= output_buf
[ctr
] + output_col
;
4003 /* Add range center and fudge factor for final descale and range-limit. */
4004 tmp0
= wsptr
[0] + ((((INT32
) RANGE_CENTER
) << 3) + (ONE
<< 2));
4007 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
4008 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
4011 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
4016 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
4017 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
4018 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
4020 /* Final output stage */
4022 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
4025 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
4028 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
4031 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
4035 wsptr
+= 4; /* advance pointer to next row */
4041 * Perform dequantization and inverse DCT on one block of coefficients,
4042 * producing a 2x1 output block.
4044 * 1-point IDCT in pass 1 (columns), 2-point in pass 2 (rows).
4048 jpeg_idct_2x1 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4049 JCOEFPTR coef_block
,
4050 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4053 ISLOW_MULT_TYPE
* quantptr
;
4055 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4058 /* Pass 1: empty. */
4060 /* Pass 2: process 1 row from input, store into output array. */
4062 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4063 outptr
= output_buf
[0] + output_col
;
4067 tmp0
= DEQUANTIZE(coef_block
[0], quantptr
[0]);
4068 /* Add range center and fudge factor for final descale and range-limit. */
4069 tmp0
+= (((DCTELEM
) RANGE_CENTER
) << 3) + (1 << 2);
4073 tmp1
= DEQUANTIZE(coef_block
[1], quantptr
[1]);
4075 /* Final output stage */
4077 outptr
[0] = range_limit
[(int) IRIGHT_SHIFT(tmp0
+ tmp1
, 3) & RANGE_MASK
];
4078 outptr
[1] = range_limit
[(int) IRIGHT_SHIFT(tmp0
- tmp1
, 3) & RANGE_MASK
];
4083 * Perform dequantization and inverse DCT on one block of coefficients,
4084 * producing a 8x16 output block.
4086 * 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
4090 jpeg_idct_8x16 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4091 JCOEFPTR coef_block
,
4092 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4094 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
4095 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
4096 INT32 z1
, z2
, z3
, z4
;
4098 ISLOW_MULT_TYPE
* quantptr
;
4101 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4103 int workspace
[8*16]; /* buffers data between passes */
4106 /* Pass 1: process columns from input, store into work array.
4107 * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
4111 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4113 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4116 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4117 tmp0
<<= CONST_BITS
;
4118 /* Add fudge factor here for final descale. */
4119 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4121 z1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4122 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
4123 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
4125 tmp10
= tmp0
+ tmp1
;
4126 tmp11
= tmp0
- tmp1
;
4127 tmp12
= tmp0
+ tmp2
;
4128 tmp13
= tmp0
- tmp2
;
4130 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4131 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4133 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
4134 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
4136 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
4137 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
4138 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
4139 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
4141 tmp20
= tmp10
+ tmp0
;
4142 tmp27
= tmp10
- tmp0
;
4143 tmp21
= tmp12
+ tmp1
;
4144 tmp26
= tmp12
- tmp1
;
4145 tmp22
= tmp13
+ tmp2
;
4146 tmp25
= tmp13
- tmp2
;
4147 tmp23
= tmp11
+ tmp3
;
4148 tmp24
= tmp11
- tmp3
;
4152 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4153 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4154 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4155 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4159 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
4160 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
4161 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
4162 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
4163 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
4164 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
4165 tmp0
= tmp1
+ tmp2
+ tmp3
-
4166 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
4167 tmp13
= tmp10
+ tmp11
+ tmp12
-
4168 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
4169 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
4170 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
4171 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
4172 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
4173 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
4174 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
4176 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
4178 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
4179 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
4180 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
4182 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
4185 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
4189 /* Final output stage */
4191 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp0
, CONST_BITS
-PASS1_BITS
);
4192 wsptr
[8*15] = (int) RIGHT_SHIFT(tmp20
- tmp0
, CONST_BITS
-PASS1_BITS
);
4193 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp1
, CONST_BITS
-PASS1_BITS
);
4194 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp21
- tmp1
, CONST_BITS
-PASS1_BITS
);
4195 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp2
, CONST_BITS
-PASS1_BITS
);
4196 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp22
- tmp2
, CONST_BITS
-PASS1_BITS
);
4197 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp3
, CONST_BITS
-PASS1_BITS
);
4198 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp23
- tmp3
, CONST_BITS
-PASS1_BITS
);
4199 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4200 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp24
- tmp10
, CONST_BITS
-PASS1_BITS
);
4201 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4202 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp25
- tmp11
, CONST_BITS
-PASS1_BITS
);
4203 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4204 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp26
- tmp12
, CONST_BITS
-PASS1_BITS
);
4205 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4206 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp27
- tmp13
, CONST_BITS
-PASS1_BITS
);
4209 /* Pass 2: process rows from work array, store into output array.
4210 * Note that we must descale the results by a factor of 8 == 2**3,
4211 * and also undo the PASS1_BITS scaling.
4212 * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
4216 for (ctr
= 0; ctr
< 16; ctr
++) {
4217 outptr
= output_buf
[ctr
] + output_col
;
4219 /* Even part: reverse the even part of the forward DCT.
4220 * The rotator is c(-6).
4223 /* Add range center and fudge factor for final descale and range-limit. */
4224 z2
= (INT32
) wsptr
[0] +
4225 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
4226 (ONE
<< (PASS1_BITS
+2)));
4227 z3
= (INT32
) wsptr
[4];
4229 tmp0
= (z2
+ z3
) << CONST_BITS
;
4230 tmp1
= (z2
- z3
) << CONST_BITS
;
4232 z2
= (INT32
) wsptr
[2];
4233 z3
= (INT32
) wsptr
[6];
4235 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
4236 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
4237 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
4239 tmp10
= tmp0
+ tmp2
;
4240 tmp13
= tmp0
- tmp2
;
4241 tmp11
= tmp1
+ tmp3
;
4242 tmp12
= tmp1
- tmp3
;
4244 /* Odd part per figure 8; the matrix is unitary and hence its
4245 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
4248 tmp0
= (INT32
) wsptr
[7];
4249 tmp1
= (INT32
) wsptr
[5];
4250 tmp2
= (INT32
) wsptr
[3];
4251 tmp3
= (INT32
) wsptr
[1];
4256 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* c3 */
4257 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* -c3-c5 */
4258 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* -c3+c5 */
4262 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* -c3+c7 */
4263 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* -c1+c3+c5-c7 */
4264 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* c1+c3-c5-c7 */
4268 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* -c1-c3 */
4269 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* c1+c3-c5+c7 */
4270 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* c1+c3+c5-c7 */
4274 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
4276 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
4277 CONST_BITS
+PASS1_BITS
+3)
4279 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
4280 CONST_BITS
+PASS1_BITS
+3)
4282 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
4283 CONST_BITS
+PASS1_BITS
+3)
4285 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
4286 CONST_BITS
+PASS1_BITS
+3)
4288 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
4289 CONST_BITS
+PASS1_BITS
+3)
4291 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
4292 CONST_BITS
+PASS1_BITS
+3)
4294 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
4295 CONST_BITS
+PASS1_BITS
+3)
4297 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
4298 CONST_BITS
+PASS1_BITS
+3)
4301 wsptr
+= DCTSIZE
; /* advance pointer to next row */
4307 * Perform dequantization and inverse DCT on one block of coefficients,
4308 * producing a 7x14 output block.
4310 * 14-point IDCT in pass 1 (columns), 7-point in pass 2 (rows).
4314 jpeg_idct_7x14 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4315 JCOEFPTR coef_block
,
4316 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4318 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
4319 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
4320 INT32 z1
, z2
, z3
, z4
;
4322 ISLOW_MULT_TYPE
* quantptr
;
4325 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4327 int workspace
[7*14]; /* buffers data between passes */
4330 /* Pass 1: process columns from input, store into work array.
4331 * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28).
4335 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4337 for (ctr
= 0; ctr
< 7; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4340 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4342 /* Add fudge factor here for final descale. */
4343 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4344 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4345 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
4346 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
4347 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
4353 tmp23
= RIGHT_SHIFT(z1
- ((z2
+ z3
- z4
) << 1), /* c0 = (c4+c12-c8)*2 */
4354 CONST_BITS
-PASS1_BITS
);
4356 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4357 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4359 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
4361 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
4362 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
4363 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
4364 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
4366 tmp20
= tmp10
+ tmp13
;
4367 tmp26
= tmp10
- tmp13
;
4368 tmp21
= tmp11
+ tmp14
;
4369 tmp25
= tmp11
- tmp14
;
4370 tmp22
= tmp12
+ tmp15
;
4371 tmp24
= tmp12
- tmp15
;
4375 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4376 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4377 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4378 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4379 tmp13
= z4
<< CONST_BITS
;
4382 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
4383 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
4384 tmp10
= tmp11
+ tmp12
+ tmp13
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
4385 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
4386 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
4388 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - tmp13
; /* c11 */
4391 z4
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - tmp13
; /* -c13 */
4392 tmp11
+= z4
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
4393 tmp12
+= z4
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
4394 z4
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
4395 tmp14
+= z4
+ tmp13
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
4396 tmp15
+= z4
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
4398 tmp13
= (z1
- z3
) << PASS1_BITS
;
4400 /* Final output stage */
4402 wsptr
[7*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4403 wsptr
[7*13] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4404 wsptr
[7*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4405 wsptr
[7*12] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4406 wsptr
[7*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4407 wsptr
[7*11] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
4408 wsptr
[7*3] = (int) (tmp23
+ tmp13
);
4409 wsptr
[7*10] = (int) (tmp23
- tmp13
);
4410 wsptr
[7*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4411 wsptr
[7*9] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4412 wsptr
[7*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
4413 wsptr
[7*8] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
4414 wsptr
[7*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
4415 wsptr
[7*7] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
4418 /* Pass 2: process 14 rows from work array, store into output array.
4419 * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14).
4423 for (ctr
= 0; ctr
< 14; ctr
++) {
4424 outptr
= output_buf
[ctr
] + output_col
;
4428 /* Add range center and fudge factor for final descale and range-limit. */
4429 tmp23
= (INT32
) wsptr
[0] +
4430 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
4431 (ONE
<< (PASS1_BITS
+2)));
4432 tmp23
<<= CONST_BITS
;
4434 z1
= (INT32
) wsptr
[2];
4435 z2
= (INT32
) wsptr
[4];
4436 z3
= (INT32
) wsptr
[6];
4438 tmp20
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
4439 tmp22
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
4440 tmp21
= tmp20
+ tmp22
+ tmp23
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
4443 tmp10
= MULTIPLY(tmp10
, FIX(1.274162392)) + tmp23
; /* c2 */
4444 tmp20
+= tmp10
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
4445 tmp22
+= tmp10
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
4446 tmp23
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
4450 z1
= (INT32
) wsptr
[1];
4451 z2
= (INT32
) wsptr
[3];
4452 z3
= (INT32
) wsptr
[5];
4454 tmp11
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
4455 tmp12
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
4456 tmp10
= tmp11
- tmp12
;
4458 tmp12
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
4460 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
4462 tmp12
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
4464 /* Final output stage */
4466 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
4467 CONST_BITS
+PASS1_BITS
+3)
4469 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
4470 CONST_BITS
+PASS1_BITS
+3)
4472 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
4473 CONST_BITS
+PASS1_BITS
+3)
4475 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
4476 CONST_BITS
+PASS1_BITS
+3)
4478 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
4479 CONST_BITS
+PASS1_BITS
+3)
4481 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
4482 CONST_BITS
+PASS1_BITS
+3)
4484 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
,
4485 CONST_BITS
+PASS1_BITS
+3)
4488 wsptr
+= 7; /* advance pointer to next row */
4494 * Perform dequantization and inverse DCT on one block of coefficients,
4495 * producing a 6x12 output block.
4497 * 12-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
4501 jpeg_idct_6x12 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4502 JCOEFPTR coef_block
,
4503 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4505 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
4506 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
4507 INT32 z1
, z2
, z3
, z4
;
4509 ISLOW_MULT_TYPE
* quantptr
;
4512 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4514 int workspace
[6*12]; /* buffers data between passes */
4517 /* Pass 1: process columns from input, store into work array.
4518 * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24).
4522 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4524 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4527 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4529 /* Add fudge factor here for final descale. */
4530 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4532 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4533 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
4538 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4539 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
4541 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4551 tmp20
= tmp10
+ tmp12
;
4552 tmp25
= tmp10
- tmp12
;
4554 tmp12
= z4
- z1
- z2
;
4556 tmp22
= tmp11
+ tmp12
;
4557 tmp23
= tmp11
- tmp12
;
4561 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4562 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4563 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4564 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4566 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
4567 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
4570 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
4571 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
4572 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
4573 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
4574 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
4575 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
4576 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
4577 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
4581 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
4582 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
4583 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
4585 /* Final output stage */
4587 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4588 wsptr
[6*11] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4589 wsptr
[6*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4590 wsptr
[6*10] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4591 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4592 wsptr
[6*9] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
4593 wsptr
[6*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4594 wsptr
[6*8] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
4595 wsptr
[6*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4596 wsptr
[6*7] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4597 wsptr
[6*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
4598 wsptr
[6*6] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
4601 /* Pass 2: process 12 rows from work array, store into output array.
4602 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
4606 for (ctr
= 0; ctr
< 12; ctr
++) {
4607 outptr
= output_buf
[ctr
] + output_col
;
4611 /* Add range center and fudge factor for final descale and range-limit. */
4612 tmp10
= (INT32
) wsptr
[0] +
4613 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
4614 (ONE
<< (PASS1_BITS
+2)));
4615 tmp10
<<= CONST_BITS
;
4616 tmp12
= (INT32
) wsptr
[4];
4617 tmp20
= MULTIPLY(tmp12
, FIX(0.707106781)); /* c4 */
4618 tmp11
= tmp10
+ tmp20
;
4619 tmp21
= tmp10
- tmp20
- tmp20
;
4620 tmp20
= (INT32
) wsptr
[2];
4621 tmp10
= MULTIPLY(tmp20
, FIX(1.224744871)); /* c2 */
4622 tmp20
= tmp11
+ tmp10
;
4623 tmp22
= tmp11
- tmp10
;
4627 z1
= (INT32
) wsptr
[1];
4628 z2
= (INT32
) wsptr
[3];
4629 z3
= (INT32
) wsptr
[5];
4630 tmp11
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
4631 tmp10
= tmp11
+ ((z1
+ z2
) << CONST_BITS
);
4632 tmp12
= tmp11
+ ((z3
- z2
) << CONST_BITS
);
4633 tmp11
= (z1
- z2
- z3
) << CONST_BITS
;
4635 /* Final output stage */
4637 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
4638 CONST_BITS
+PASS1_BITS
+3)
4640 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
4641 CONST_BITS
+PASS1_BITS
+3)
4643 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
4644 CONST_BITS
+PASS1_BITS
+3)
4646 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
4647 CONST_BITS
+PASS1_BITS
+3)
4649 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
4650 CONST_BITS
+PASS1_BITS
+3)
4652 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
4653 CONST_BITS
+PASS1_BITS
+3)
4656 wsptr
+= 6; /* advance pointer to next row */
4662 * Perform dequantization and inverse DCT on one block of coefficients,
4663 * producing a 5x10 output block.
4665 * 10-point IDCT in pass 1 (columns), 5-point in pass 2 (rows).
4669 jpeg_idct_5x10 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4670 JCOEFPTR coef_block
,
4671 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4673 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
4674 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
4675 INT32 z1
, z2
, z3
, z4
, z5
;
4677 ISLOW_MULT_TYPE
* quantptr
;
4680 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4682 int workspace
[5*10]; /* buffers data between passes */
4685 /* Pass 1: process columns from input, store into work array.
4686 * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20).
4690 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4692 for (ctr
= 0; ctr
< 5; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4695 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4697 /* Add fudge factor here for final descale. */
4698 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4699 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4700 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
4701 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
4705 tmp22
= RIGHT_SHIFT(z3
- ((z1
- z2
) << 1), /* c0 = (c4-c8)*2 */
4706 CONST_BITS
-PASS1_BITS
);
4708 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4709 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4711 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
4712 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
4713 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
4715 tmp20
= tmp10
+ tmp12
;
4716 tmp24
= tmp10
- tmp12
;
4717 tmp21
= tmp11
+ tmp13
;
4718 tmp23
= tmp11
- tmp13
;
4722 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4723 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4724 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4725 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4730 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
4731 z5
= z3
<< CONST_BITS
;
4733 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
4736 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
4737 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
4739 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
4740 z4
= z5
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
4742 tmp12
= (z1
- tmp13
- z3
) << PASS1_BITS
;
4744 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
4745 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
4747 /* Final output stage */
4749 wsptr
[5*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4750 wsptr
[5*9] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4751 wsptr
[5*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4752 wsptr
[5*8] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4753 wsptr
[5*2] = (int) (tmp22
+ tmp12
);
4754 wsptr
[5*7] = (int) (tmp22
- tmp12
);
4755 wsptr
[5*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4756 wsptr
[5*6] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
4757 wsptr
[5*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4758 wsptr
[5*5] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4761 /* Pass 2: process 10 rows from work array, store into output array.
4762 * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10).
4766 for (ctr
= 0; ctr
< 10; ctr
++) {
4767 outptr
= output_buf
[ctr
] + output_col
;
4771 /* Add range center and fudge factor for final descale and range-limit. */
4772 tmp12
= (INT32
) wsptr
[0] +
4773 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
4774 (ONE
<< (PASS1_BITS
+2)));
4775 tmp12
<<= CONST_BITS
;
4776 tmp13
= (INT32
) wsptr
[2];
4777 tmp14
= (INT32
) wsptr
[4];
4778 z1
= MULTIPLY(tmp13
+ tmp14
, FIX(0.790569415)); /* (c2+c4)/2 */
4779 z2
= MULTIPLY(tmp13
- tmp14
, FIX(0.353553391)); /* (c2-c4)/2 */
4787 z2
= (INT32
) wsptr
[1];
4788 z3
= (INT32
) wsptr
[3];
4790 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
4791 tmp13
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
4792 tmp14
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
4794 /* Final output stage */
4796 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp13
,
4797 CONST_BITS
+PASS1_BITS
+3)
4799 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp13
,
4800 CONST_BITS
+PASS1_BITS
+3)
4802 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp14
,
4803 CONST_BITS
+PASS1_BITS
+3)
4805 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp14
,
4806 CONST_BITS
+PASS1_BITS
+3)
4808 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
,
4809 CONST_BITS
+PASS1_BITS
+3)
4812 wsptr
+= 5; /* advance pointer to next row */
4818 * Perform dequantization and inverse DCT on one block of coefficients,
4819 * producing a 4x8 output block.
4821 * 8-point IDCT in pass 1 (columns), 4-point in pass 2 (rows).
4825 jpeg_idct_4x8 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4826 JCOEFPTR coef_block
,
4827 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4829 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
4830 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
4833 ISLOW_MULT_TYPE
* quantptr
;
4836 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4838 int workspace
[4*8]; /* buffers data between passes */
4841 /* Pass 1: process columns from input, store into work array.
4842 * Note results are scaled up by sqrt(8) compared to a true IDCT;
4843 * furthermore, we scale the results by 2**PASS1_BITS.
4844 * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
4848 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4850 for (ctr
= 4; ctr
> 0; ctr
--) {
4851 /* Due to quantization, we will usually find that many of the input
4852 * coefficients are zero, especially the AC terms. We can exploit this
4853 * by short-circuiting the IDCT calculation for any column in which all
4854 * the AC terms are zero. In that case each output is equal to the
4855 * DC coefficient (with scale factor as needed).
4856 * With typical images and quantization tables, half or more of the
4857 * column DCT calculations can be simplified this way.
4860 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
4861 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
4862 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
4863 inptr
[DCTSIZE
*7] == 0) {
4864 /* AC terms all zero */
4865 int dcval
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]) << PASS1_BITS
;
4876 inptr
++; /* advance pointers to next column */
4882 /* Even part: reverse the even part of the forward DCT.
4883 * The rotator is c(-6).
4886 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4887 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4889 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
4890 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
4891 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
4893 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4894 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4897 /* Add fudge factor here for final descale. */
4898 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4903 tmp10
= tmp0
+ tmp2
;
4904 tmp13
= tmp0
- tmp2
;
4905 tmp11
= tmp1
+ tmp3
;
4906 tmp12
= tmp1
- tmp3
;
4908 /* Odd part per figure 8; the matrix is unitary and hence its
4909 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
4912 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4913 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4914 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4915 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4920 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* c3 */
4921 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* -c3-c5 */
4922 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* -c3+c5 */
4926 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* -c3+c7 */
4927 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* -c1+c3+c5-c7 */
4928 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* c1+c3-c5-c7 */
4932 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* -c1-c3 */
4933 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* c1+c3-c5+c7 */
4934 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* c1+c3+c5-c7 */
4938 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
4940 wsptr
[4*0] = (int) RIGHT_SHIFT(tmp10
+ tmp3
, CONST_BITS
-PASS1_BITS
);
4941 wsptr
[4*7] = (int) RIGHT_SHIFT(tmp10
- tmp3
, CONST_BITS
-PASS1_BITS
);
4942 wsptr
[4*1] = (int) RIGHT_SHIFT(tmp11
+ tmp2
, CONST_BITS
-PASS1_BITS
);
4943 wsptr
[4*6] = (int) RIGHT_SHIFT(tmp11
- tmp2
, CONST_BITS
-PASS1_BITS
);
4944 wsptr
[4*2] = (int) RIGHT_SHIFT(tmp12
+ tmp1
, CONST_BITS
-PASS1_BITS
);
4945 wsptr
[4*5] = (int) RIGHT_SHIFT(tmp12
- tmp1
, CONST_BITS
-PASS1_BITS
);
4946 wsptr
[4*3] = (int) RIGHT_SHIFT(tmp13
+ tmp0
, CONST_BITS
-PASS1_BITS
);
4947 wsptr
[4*4] = (int) RIGHT_SHIFT(tmp13
- tmp0
, CONST_BITS
-PASS1_BITS
);
4949 inptr
++; /* advance pointers to next column */
4954 /* Pass 2: process 8 rows from work array, store into output array.
4955 * 4-point IDCT kernel,
4956 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
4960 for (ctr
= 0; ctr
< 8; ctr
++) {
4961 outptr
= output_buf
[ctr
] + output_col
;
4965 /* Add range center and fudge factor for final descale and range-limit. */
4966 tmp0
= (INT32
) wsptr
[0] +
4967 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
4968 (ONE
<< (PASS1_BITS
+2)));
4969 tmp2
= (INT32
) wsptr
[2];
4971 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
4972 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
4975 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
4977 z2
= (INT32
) wsptr
[1];
4978 z3
= (INT32
) wsptr
[3];
4980 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
4981 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
4982 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
4984 /* Final output stage */
4986 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
4987 CONST_BITS
+PASS1_BITS
+3)
4989 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
4990 CONST_BITS
+PASS1_BITS
+3)
4992 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
4993 CONST_BITS
+PASS1_BITS
+3)
4995 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
4996 CONST_BITS
+PASS1_BITS
+3)
4999 wsptr
+= 4; /* advance pointer to next row */
5005 * Perform dequantization and inverse DCT on one block of coefficients,
5006 * producing a reduced-size 3x6 output block.
5008 * 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows).
5012 jpeg_idct_3x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
5013 JCOEFPTR coef_block
,
5014 JSAMPARRAY output_buf
, JDIMENSION output_col
)
5016 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
5019 ISLOW_MULT_TYPE
* quantptr
;
5022 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
5024 int workspace
[3*6]; /* buffers data between passes */
5027 /* Pass 1: process columns from input, store into work array.
5028 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
5032 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
5034 for (ctr
= 0; ctr
< 3; ctr
++, inptr
++, quantptr
++, wsptr
++) {
5037 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
5038 tmp0
<<= CONST_BITS
;
5039 /* Add fudge factor here for final descale. */
5040 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
5041 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
5042 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
5043 tmp1
= tmp0
+ tmp10
;
5044 tmp11
= RIGHT_SHIFT(tmp0
- tmp10
- tmp10
, CONST_BITS
-PASS1_BITS
);
5045 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
5046 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
5047 tmp10
= tmp1
+ tmp0
;
5048 tmp12
= tmp1
- tmp0
;
5052 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
5053 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
5054 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
5055 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
5056 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
5057 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
5058 tmp1
= (z1
- z2
- z3
) << PASS1_BITS
;
5060 /* Final output stage */
5062 wsptr
[3*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
5063 wsptr
[3*5] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
5064 wsptr
[3*1] = (int) (tmp11
+ tmp1
);
5065 wsptr
[3*4] = (int) (tmp11
- tmp1
);
5066 wsptr
[3*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
5067 wsptr
[3*3] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
5070 /* Pass 2: process 6 rows from work array, store into output array.
5071 * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6).
5075 for (ctr
= 0; ctr
< 6; ctr
++) {
5076 outptr
= output_buf
[ctr
] + output_col
;
5080 /* Add range center and fudge factor for final descale and range-limit. */
5081 tmp0
= (INT32
) wsptr
[0] +
5082 ((((INT32
) RANGE_CENTER
) << (PASS1_BITS
+3)) +
5083 (ONE
<< (PASS1_BITS
+2)));
5084 tmp0
<<= CONST_BITS
;
5085 tmp2
= (INT32
) wsptr
[2];
5086 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
5087 tmp10
= tmp0
+ tmp12
;
5088 tmp2
= tmp0
- tmp12
- tmp12
;
5092 tmp12
= (INT32
) wsptr
[1];
5093 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
5095 /* Final output stage */
5097 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
5098 CONST_BITS
+PASS1_BITS
+3)
5100 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
5101 CONST_BITS
+PASS1_BITS
+3)
5103 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp2
,
5104 CONST_BITS
+PASS1_BITS
+3)
5107 wsptr
+= 3; /* advance pointer to next row */
5113 * Perform dequantization and inverse DCT on one block of coefficients,
5114 * producing a 2x4 output block.
5116 * 4-point IDCT in pass 1 (columns), 2-point in pass 2 (rows).
5120 jpeg_idct_2x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
5121 JCOEFPTR coef_block
,
5122 JSAMPARRAY output_buf
, JDIMENSION output_col
)
5124 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
5127 ISLOW_MULT_TYPE
* quantptr
;
5130 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
5132 INT32 workspace
[2*4]; /* buffers data between passes */
5135 /* Pass 1: process columns from input, store into work array.
5136 * 4-point IDCT kernel,
5137 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
5141 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
5143 for (ctr
= 0; ctr
< 2; ctr
++, inptr
++, quantptr
++, wsptr
++) {
5146 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
5147 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
5149 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
5150 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
5153 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
5155 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
5156 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
5158 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
5159 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
5160 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
5162 /* Final output stage */
5164 wsptr
[2*0] = tmp10
+ tmp0
;
5165 wsptr
[2*3] = tmp10
- tmp0
;
5166 wsptr
[2*1] = tmp12
+ tmp2
;
5167 wsptr
[2*2] = tmp12
- tmp2
;
5170 /* Pass 2: process 4 rows from work array, store into output array. */
5173 for (ctr
= 0; ctr
< 4; ctr
++) {
5174 outptr
= output_buf
[ctr
] + output_col
;
5178 /* Add range center and fudge factor for final descale and range-limit. */
5180 ((((INT32
) RANGE_CENTER
) << (CONST_BITS
+3)) +
5181 (ONE
<< (CONST_BITS
+2)));
5187 /* Final output stage */
5189 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
+3)
5191 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
+3)
5194 wsptr
+= 2; /* advance pointer to next row */
5200 * Perform dequantization and inverse DCT on one block of coefficients,
5201 * producing a 1x2 output block.
5203 * 2-point IDCT in pass 1 (columns), 1-point in pass 2 (rows).
5207 jpeg_idct_1x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
5208 JCOEFPTR coef_block
,
5209 JSAMPARRAY output_buf
, JDIMENSION output_col
)
5212 ISLOW_MULT_TYPE
* quantptr
;
5213 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
5216 /* Process 1 column from input, store into output array. */
5218 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
5222 tmp0
= DEQUANTIZE(coef_block
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
5223 /* Add range center and fudge factor for final descale and range-limit. */
5224 tmp0
+= (((DCTELEM
) RANGE_CENTER
) << 3) + (1 << 2);
5228 tmp1
= DEQUANTIZE(coef_block
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
5230 /* Final output stage */
5232 output_buf
[0][output_col
] =
5233 range_limit
[(int) IRIGHT_SHIFT(tmp0
+ tmp1
, 3) & RANGE_MASK
];
5234 output_buf
[1][output_col
] =
5235 range_limit
[(int) IRIGHT_SHIFT(tmp0
- tmp1
, 3) & RANGE_MASK
];
5238 #endif /* IDCT_SCALING_SUPPORTED */
5239 #endif /* DCT_ISLOW_SUPPORTED */