4 * Copyright (C) 1991-1998, Thomas G. Lane.
5 * Modification developed 2002-2009 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.
171 jpeg_idct_islow (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
173 JSAMPARRAY output_buf
, JDIMENSION output_col
)
175 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
176 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
179 ISLOW_MULT_TYPE
* quantptr
;
182 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
184 int workspace
[DCTSIZE2
]; /* buffers data between passes */
187 /* Pass 1: process columns from input, store into work array. */
188 /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
189 /* furthermore, we scale the results by 2**PASS1_BITS. */
192 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
194 for (ctr
= DCTSIZE
; ctr
> 0; ctr
--) {
195 /* Due to quantization, we will usually find that many of the input
196 * coefficients are zero, especially the AC terms. We can exploit this
197 * by short-circuiting the IDCT calculation for any column in which all
198 * the AC terms are zero. In that case each output is equal to the
199 * DC coefficient (with scale factor as needed).
200 * With typical images and quantization tables, half or more of the
201 * column DCT calculations can be simplified this way.
204 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
205 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
206 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
207 inptr
[DCTSIZE
*7] == 0) {
208 /* AC terms all zero */
209 int dcval
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]) << PASS1_BITS
;
211 wsptr
[DCTSIZE
*0] = dcval
;
212 wsptr
[DCTSIZE
*1] = dcval
;
213 wsptr
[DCTSIZE
*2] = dcval
;
214 wsptr
[DCTSIZE
*3] = dcval
;
215 wsptr
[DCTSIZE
*4] = dcval
;
216 wsptr
[DCTSIZE
*5] = dcval
;
217 wsptr
[DCTSIZE
*6] = dcval
;
218 wsptr
[DCTSIZE
*7] = dcval
;
220 inptr
++; /* advance pointers to next column */
226 /* Even part: reverse the even part of the forward DCT. */
227 /* The rotator is sqrt(2)*c(-6). */
229 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
230 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
232 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
233 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
234 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
236 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
237 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
240 /* Add fudge factor here for final descale. */
241 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
251 /* Odd part per figure 8; the matrix is unitary and hence its
252 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
255 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
256 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
257 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
258 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
263 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
264 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
265 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
269 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
270 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
271 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
275 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
276 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
277 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
281 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
283 wsptr
[DCTSIZE
*0] = (int) RIGHT_SHIFT(tmp10
+ tmp3
, CONST_BITS
-PASS1_BITS
);
284 wsptr
[DCTSIZE
*7] = (int) RIGHT_SHIFT(tmp10
- tmp3
, CONST_BITS
-PASS1_BITS
);
285 wsptr
[DCTSIZE
*1] = (int) RIGHT_SHIFT(tmp11
+ tmp2
, CONST_BITS
-PASS1_BITS
);
286 wsptr
[DCTSIZE
*6] = (int) RIGHT_SHIFT(tmp11
- tmp2
, CONST_BITS
-PASS1_BITS
);
287 wsptr
[DCTSIZE
*2] = (int) RIGHT_SHIFT(tmp12
+ tmp1
, CONST_BITS
-PASS1_BITS
);
288 wsptr
[DCTSIZE
*5] = (int) RIGHT_SHIFT(tmp12
- tmp1
, CONST_BITS
-PASS1_BITS
);
289 wsptr
[DCTSIZE
*3] = (int) RIGHT_SHIFT(tmp13
+ tmp0
, CONST_BITS
-PASS1_BITS
);
290 wsptr
[DCTSIZE
*4] = (int) RIGHT_SHIFT(tmp13
- tmp0
, CONST_BITS
-PASS1_BITS
);
292 inptr
++; /* advance pointers to next column */
297 /* Pass 2: process rows from work array, store into output array. */
298 /* Note that we must descale the results by a factor of 8 == 2**3, */
299 /* and also undo the PASS1_BITS scaling. */
302 for (ctr
= 0; ctr
< DCTSIZE
; ctr
++) {
303 outptr
= output_buf
[ctr
] + output_col
;
304 /* Rows of zeroes can be exploited in the same way as we did with columns.
305 * However, the column calculation has created many nonzero AC terms, so
306 * the simplification applies less often (typically 5% to 10% of the time).
307 * On machines with very fast multiplication, it's possible that the
308 * test takes more time than it's worth. In that case this section
309 * may be commented out.
312 #ifndef NO_ZERO_ROW_TEST
313 if (wsptr
[1] == 0 && wsptr
[2] == 0 && wsptr
[3] == 0 && wsptr
[4] == 0 &&
314 wsptr
[5] == 0 && wsptr
[6] == 0 && wsptr
[7] == 0) {
315 /* AC terms all zero */
316 JSAMPLE dcval
= range_limit
[(int) DESCALE((INT32
) wsptr
[0], PASS1_BITS
+3)
328 wsptr
+= DCTSIZE
; /* advance pointer to next row */
333 /* Even part: reverse the even part of the forward DCT. */
334 /* The rotator is sqrt(2)*c(-6). */
336 z2
= (INT32
) wsptr
[2];
337 z3
= (INT32
) wsptr
[6];
339 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
340 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
341 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
343 /* Add fudge factor here for final descale. */
344 z2
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
345 z3
= (INT32
) wsptr
[4];
347 tmp0
= (z2
+ z3
) << CONST_BITS
;
348 tmp1
= (z2
- z3
) << CONST_BITS
;
355 /* Odd part per figure 8; the matrix is unitary and hence its
356 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
359 tmp0
= (INT32
) wsptr
[7];
360 tmp1
= (INT32
) wsptr
[5];
361 tmp2
= (INT32
) wsptr
[3];
362 tmp3
= (INT32
) wsptr
[1];
367 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
368 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
369 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
373 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
374 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
375 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
379 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
380 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
381 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
385 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
387 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
388 CONST_BITS
+PASS1_BITS
+3)
390 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
391 CONST_BITS
+PASS1_BITS
+3)
393 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
394 CONST_BITS
+PASS1_BITS
+3)
396 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
397 CONST_BITS
+PASS1_BITS
+3)
399 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
400 CONST_BITS
+PASS1_BITS
+3)
402 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
403 CONST_BITS
+PASS1_BITS
+3)
405 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
406 CONST_BITS
+PASS1_BITS
+3)
408 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
409 CONST_BITS
+PASS1_BITS
+3)
412 wsptr
+= DCTSIZE
; /* advance pointer to next row */
416 #ifdef IDCT_SCALING_SUPPORTED
420 * Perform dequantization and inverse DCT on one block of coefficients,
421 * producing a 7x7 output block.
423 * Optimized algorithm with 12 multiplications in the 1-D kernel.
424 * cK represents sqrt(2) * cos(K*pi/14).
428 jpeg_idct_7x7 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
430 JSAMPARRAY output_buf
, JDIMENSION output_col
)
432 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
, tmp13
;
435 ISLOW_MULT_TYPE
* quantptr
;
438 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
440 int workspace
[7*7]; /* buffers data between passes */
443 /* Pass 1: process columns from input, store into work array. */
446 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
448 for (ctr
= 0; ctr
< 7; ctr
++, inptr
++, quantptr
++, wsptr
++) {
451 tmp13
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
452 tmp13
<<= CONST_BITS
;
453 /* Add fudge factor here for final descale. */
454 tmp13
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
456 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
457 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
458 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
460 tmp10
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
461 tmp12
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
462 tmp11
= tmp10
+ tmp12
+ tmp13
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
465 tmp0
= MULTIPLY(tmp0
, FIX(1.274162392)) + tmp13
; /* c2 */
466 tmp10
+= tmp0
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
467 tmp12
+= tmp0
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
468 tmp13
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
472 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
473 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
474 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
476 tmp1
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
477 tmp2
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
480 tmp2
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
482 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
484 tmp2
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
486 /* Final output stage */
488 wsptr
[7*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
489 wsptr
[7*6] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
490 wsptr
[7*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
491 wsptr
[7*5] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
492 wsptr
[7*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
493 wsptr
[7*4] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
494 wsptr
[7*3] = (int) RIGHT_SHIFT(tmp13
, CONST_BITS
-PASS1_BITS
);
497 /* Pass 2: process 7 rows from work array, store into output array. */
500 for (ctr
= 0; ctr
< 7; ctr
++) {
501 outptr
= output_buf
[ctr
] + output_col
;
505 /* Add fudge factor here for final descale. */
506 tmp13
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
507 tmp13
<<= CONST_BITS
;
509 z1
= (INT32
) wsptr
[2];
510 z2
= (INT32
) wsptr
[4];
511 z3
= (INT32
) wsptr
[6];
513 tmp10
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
514 tmp12
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
515 tmp11
= tmp10
+ tmp12
+ tmp13
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
518 tmp0
= MULTIPLY(tmp0
, FIX(1.274162392)) + tmp13
; /* c2 */
519 tmp10
+= tmp0
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
520 tmp12
+= tmp0
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
521 tmp13
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
525 z1
= (INT32
) wsptr
[1];
526 z2
= (INT32
) wsptr
[3];
527 z3
= (INT32
) wsptr
[5];
529 tmp1
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
530 tmp2
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
533 tmp2
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
535 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
537 tmp2
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
539 /* Final output stage */
541 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
542 CONST_BITS
+PASS1_BITS
+3)
544 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
545 CONST_BITS
+PASS1_BITS
+3)
547 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
548 CONST_BITS
+PASS1_BITS
+3)
550 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
551 CONST_BITS
+PASS1_BITS
+3)
553 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
554 CONST_BITS
+PASS1_BITS
+3)
556 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
557 CONST_BITS
+PASS1_BITS
+3)
559 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
,
560 CONST_BITS
+PASS1_BITS
+3)
563 wsptr
+= 7; /* advance pointer to next row */
569 * Perform dequantization and inverse DCT on one block of coefficients,
570 * producing a reduced-size 6x6 output block.
572 * Optimized algorithm with 3 multiplications in the 1-D kernel.
573 * cK represents sqrt(2) * cos(K*pi/12).
577 jpeg_idct_6x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
579 JSAMPARRAY output_buf
, JDIMENSION output_col
)
581 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
584 ISLOW_MULT_TYPE
* quantptr
;
587 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
589 int workspace
[6*6]; /* buffers data between passes */
592 /* Pass 1: process columns from input, store into work array. */
595 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
597 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
600 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
602 /* Add fudge factor here for final descale. */
603 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
604 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
605 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
607 tmp11
= RIGHT_SHIFT(tmp0
- tmp10
- tmp10
, CONST_BITS
-PASS1_BITS
);
608 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
609 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
615 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
616 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
617 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
618 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
619 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
620 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
621 tmp1
= (z1
- z2
- z3
) << PASS1_BITS
;
623 /* Final output stage */
625 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
626 wsptr
[6*5] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
627 wsptr
[6*1] = (int) (tmp11
+ tmp1
);
628 wsptr
[6*4] = (int) (tmp11
- tmp1
);
629 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
630 wsptr
[6*3] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
633 /* Pass 2: process 6 rows from work array, store into output array. */
636 for (ctr
= 0; ctr
< 6; ctr
++) {
637 outptr
= output_buf
[ctr
] + output_col
;
641 /* Add fudge factor here for final descale. */
642 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
644 tmp2
= (INT32
) wsptr
[4];
645 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
647 tmp11
= tmp0
- tmp10
- tmp10
;
648 tmp10
= (INT32
) wsptr
[2];
649 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
655 z1
= (INT32
) wsptr
[1];
656 z2
= (INT32
) wsptr
[3];
657 z3
= (INT32
) wsptr
[5];
658 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
659 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
660 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
661 tmp1
= (z1
- z2
- z3
) << CONST_BITS
;
663 /* Final output stage */
665 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
666 CONST_BITS
+PASS1_BITS
+3)
668 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
669 CONST_BITS
+PASS1_BITS
+3)
671 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
672 CONST_BITS
+PASS1_BITS
+3)
674 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
675 CONST_BITS
+PASS1_BITS
+3)
677 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
678 CONST_BITS
+PASS1_BITS
+3)
680 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
681 CONST_BITS
+PASS1_BITS
+3)
684 wsptr
+= 6; /* advance pointer to next row */
690 * Perform dequantization and inverse DCT on one block of coefficients,
691 * producing a reduced-size 5x5 output block.
693 * Optimized algorithm with 5 multiplications in the 1-D kernel.
694 * cK represents sqrt(2) * cos(K*pi/10).
698 jpeg_idct_5x5 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
700 JSAMPARRAY output_buf
, JDIMENSION output_col
)
702 INT32 tmp0
, tmp1
, tmp10
, tmp11
, tmp12
;
705 ISLOW_MULT_TYPE
* quantptr
;
708 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
710 int workspace
[5*5]; /* buffers data between passes */
713 /* Pass 1: process columns from input, store into work array. */
716 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
718 for (ctr
= 0; ctr
< 5; ctr
++, inptr
++, quantptr
++, wsptr
++) {
721 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
722 tmp12
<<= CONST_BITS
;
723 /* Add fudge factor here for final descale. */
724 tmp12
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
725 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
726 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
727 z1
= MULTIPLY(tmp0
+ tmp1
, FIX(0.790569415)); /* (c2+c4)/2 */
728 z2
= MULTIPLY(tmp0
- tmp1
, FIX(0.353553391)); /* (c2-c4)/2 */
736 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
737 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
739 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
740 tmp0
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
741 tmp1
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
743 /* Final output stage */
745 wsptr
[5*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
746 wsptr
[5*4] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
747 wsptr
[5*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
748 wsptr
[5*3] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
749 wsptr
[5*2] = (int) RIGHT_SHIFT(tmp12
, CONST_BITS
-PASS1_BITS
);
752 /* Pass 2: process 5 rows from work array, store into output array. */
755 for (ctr
= 0; ctr
< 5; ctr
++) {
756 outptr
= output_buf
[ctr
] + output_col
;
760 /* Add fudge factor here for final descale. */
761 tmp12
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
762 tmp12
<<= CONST_BITS
;
763 tmp0
= (INT32
) wsptr
[2];
764 tmp1
= (INT32
) wsptr
[4];
765 z1
= MULTIPLY(tmp0
+ tmp1
, FIX(0.790569415)); /* (c2+c4)/2 */
766 z2
= MULTIPLY(tmp0
- tmp1
, FIX(0.353553391)); /* (c2-c4)/2 */
774 z2
= (INT32
) wsptr
[1];
775 z3
= (INT32
) wsptr
[3];
777 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
778 tmp0
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
779 tmp1
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
781 /* Final output stage */
783 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
784 CONST_BITS
+PASS1_BITS
+3)
786 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
787 CONST_BITS
+PASS1_BITS
+3)
789 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
790 CONST_BITS
+PASS1_BITS
+3)
792 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
793 CONST_BITS
+PASS1_BITS
+3)
795 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
,
796 CONST_BITS
+PASS1_BITS
+3)
799 wsptr
+= 5; /* advance pointer to next row */
805 * Perform dequantization and inverse DCT on one block of coefficients,
806 * producing a reduced-size 4x4 output block.
808 * Optimized algorithm with 3 multiplications in the 1-D kernel.
809 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
813 jpeg_idct_4x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
815 JSAMPARRAY output_buf
, JDIMENSION output_col
)
817 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
820 ISLOW_MULT_TYPE
* quantptr
;
823 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
825 int workspace
[4*4]; /* buffers data between passes */
828 /* Pass 1: process columns from input, store into work array. */
831 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
833 for (ctr
= 0; ctr
< 4; ctr
++, inptr
++, quantptr
++, wsptr
++) {
836 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
837 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
839 tmp10
= (tmp0
+ tmp2
) << PASS1_BITS
;
840 tmp12
= (tmp0
- tmp2
) << PASS1_BITS
;
843 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
845 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
846 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
848 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
849 /* Add fudge factor here for final descale. */
850 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
851 tmp0
= RIGHT_SHIFT(z1
+ MULTIPLY(z2
, FIX_0_765366865
), /* c2-c6 */
852 CONST_BITS
-PASS1_BITS
);
853 tmp2
= RIGHT_SHIFT(z1
- MULTIPLY(z3
, FIX_1_847759065
), /* c2+c6 */
854 CONST_BITS
-PASS1_BITS
);
856 /* Final output stage */
858 wsptr
[4*0] = (int) (tmp10
+ tmp0
);
859 wsptr
[4*3] = (int) (tmp10
- tmp0
);
860 wsptr
[4*1] = (int) (tmp12
+ tmp2
);
861 wsptr
[4*2] = (int) (tmp12
- tmp2
);
864 /* Pass 2: process 4 rows from work array, store into output array. */
867 for (ctr
= 0; ctr
< 4; ctr
++) {
868 outptr
= output_buf
[ctr
] + output_col
;
872 /* Add fudge factor here for final descale. */
873 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
874 tmp2
= (INT32
) wsptr
[2];
876 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
877 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
880 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
882 z2
= (INT32
) wsptr
[1];
883 z3
= (INT32
) wsptr
[3];
885 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
886 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
887 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
889 /* Final output stage */
891 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
892 CONST_BITS
+PASS1_BITS
+3)
894 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
895 CONST_BITS
+PASS1_BITS
+3)
897 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
898 CONST_BITS
+PASS1_BITS
+3)
900 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
901 CONST_BITS
+PASS1_BITS
+3)
904 wsptr
+= 4; /* advance pointer to next row */
910 * Perform dequantization and inverse DCT on one block of coefficients,
911 * producing a reduced-size 3x3 output block.
913 * Optimized algorithm with 2 multiplications in the 1-D kernel.
914 * cK represents sqrt(2) * cos(K*pi/6).
918 jpeg_idct_3x3 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
920 JSAMPARRAY output_buf
, JDIMENSION output_col
)
922 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
924 ISLOW_MULT_TYPE
* quantptr
;
927 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
929 int workspace
[3*3]; /* buffers data between passes */
932 /* Pass 1: process columns from input, store into work array. */
935 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
937 for (ctr
= 0; ctr
< 3; ctr
++, inptr
++, quantptr
++, wsptr
++) {
940 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
942 /* Add fudge factor here for final descale. */
943 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
944 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
945 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
946 tmp10
= tmp0
+ tmp12
;
947 tmp2
= tmp0
- tmp12
- tmp12
;
951 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
952 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
954 /* Final output stage */
956 wsptr
[3*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
957 wsptr
[3*2] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
958 wsptr
[3*1] = (int) RIGHT_SHIFT(tmp2
, CONST_BITS
-PASS1_BITS
);
961 /* Pass 2: process 3 rows from work array, store into output array. */
964 for (ctr
= 0; ctr
< 3; ctr
++) {
965 outptr
= output_buf
[ctr
] + output_col
;
969 /* Add fudge factor here for final descale. */
970 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
972 tmp2
= (INT32
) wsptr
[2];
973 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
974 tmp10
= tmp0
+ tmp12
;
975 tmp2
= tmp0
- tmp12
- tmp12
;
979 tmp12
= (INT32
) wsptr
[1];
980 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
982 /* Final output stage */
984 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
985 CONST_BITS
+PASS1_BITS
+3)
987 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
988 CONST_BITS
+PASS1_BITS
+3)
990 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp2
,
991 CONST_BITS
+PASS1_BITS
+3)
994 wsptr
+= 3; /* advance pointer to next row */
1000 * Perform dequantization and inverse DCT on one block of coefficients,
1001 * producing a reduced-size 2x2 output block.
1003 * Multiplication-less algorithm.
1007 jpeg_idct_2x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1008 JCOEFPTR coef_block
,
1009 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1011 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp4
, tmp5
;
1012 ISLOW_MULT_TYPE
* quantptr
;
1014 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1017 /* Pass 1: process columns from input. */
1019 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1022 tmp4
= DEQUANTIZE(coef_block
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1023 tmp5
= DEQUANTIZE(coef_block
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1024 /* Add fudge factor here for final descale. */
1031 tmp4
= DEQUANTIZE(coef_block
[DCTSIZE
*0+1], quantptr
[DCTSIZE
*0+1]);
1032 tmp5
= DEQUANTIZE(coef_block
[DCTSIZE
*1+1], quantptr
[DCTSIZE
*1+1]);
1037 /* Pass 2: process 2 rows, store into output array. */
1040 outptr
= output_buf
[0] + output_col
;
1042 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp0
+ tmp1
, 3) & RANGE_MASK
];
1043 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp0
- tmp1
, 3) & RANGE_MASK
];
1046 outptr
= output_buf
[1] + output_col
;
1048 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp2
+ tmp3
, 3) & RANGE_MASK
];
1049 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp2
- tmp3
, 3) & RANGE_MASK
];
1054 * Perform dequantization and inverse DCT on one block of coefficients,
1055 * producing a reduced-size 1x1 output block.
1057 * We hardly need an inverse DCT routine for this: just take the
1058 * average pixel value, which is one-eighth of the DC coefficient.
1062 jpeg_idct_1x1 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1063 JCOEFPTR coef_block
,
1064 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1067 ISLOW_MULT_TYPE
* quantptr
;
1068 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1071 /* 1x1 is trivial: just take the DC coefficient divided by 8. */
1072 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1073 dcval
= DEQUANTIZE(coef_block
[0], quantptr
[0]);
1074 dcval
= (int) DESCALE((INT32
) dcval
, 3);
1076 output_buf
[0][output_col
] = range_limit
[dcval
& RANGE_MASK
];
1081 * Perform dequantization and inverse DCT on one block of coefficients,
1082 * producing a 9x9 output block.
1084 * Optimized algorithm with 10 multiplications in the 1-D kernel.
1085 * cK represents sqrt(2) * cos(K*pi/18).
1089 jpeg_idct_9x9 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1090 JCOEFPTR coef_block
,
1091 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1093 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1094 INT32 z1
, z2
, z3
, z4
;
1096 ISLOW_MULT_TYPE
* quantptr
;
1099 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1101 int workspace
[8*9]; /* buffers data between passes */
1104 /* Pass 1: process columns from input, store into work array. */
1107 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1109 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1112 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1113 tmp0
<<= CONST_BITS
;
1114 /* Add fudge factor here for final descale. */
1115 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1117 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1118 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1119 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1121 tmp3
= MULTIPLY(z3
, FIX(0.707106781)); /* c6 */
1123 tmp2
= tmp0
- tmp3
- tmp3
;
1125 tmp0
= MULTIPLY(z1
- z2
, FIX(0.707106781)); /* c6 */
1126 tmp11
= tmp2
+ tmp0
;
1127 tmp14
= tmp2
- tmp0
- tmp0
;
1129 tmp0
= MULTIPLY(z1
+ z2
, FIX(1.328926049)); /* c2 */
1130 tmp2
= MULTIPLY(z1
, FIX(1.083350441)); /* c4 */
1131 tmp3
= MULTIPLY(z2
, FIX(0.245575608)); /* c8 */
1133 tmp10
= tmp1
+ tmp0
- tmp3
;
1134 tmp12
= tmp1
- tmp0
+ tmp2
;
1135 tmp13
= tmp1
- tmp2
+ tmp3
;
1139 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1140 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1141 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1142 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1144 z2
= MULTIPLY(z2
, - FIX(1.224744871)); /* -c3 */
1146 tmp2
= MULTIPLY(z1
+ z3
, FIX(0.909038955)); /* c5 */
1147 tmp3
= MULTIPLY(z1
+ z4
, FIX(0.483689525)); /* c7 */
1148 tmp0
= tmp2
+ tmp3
- z2
;
1149 tmp1
= MULTIPLY(z3
- z4
, FIX(1.392728481)); /* c1 */
1152 tmp1
= MULTIPLY(z1
- z3
- z4
, FIX(1.224744871)); /* c3 */
1154 /* Final output stage */
1156 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
1157 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
1158 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp11
+ tmp1
, CONST_BITS
-PASS1_BITS
);
1159 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp11
- tmp1
, CONST_BITS
-PASS1_BITS
);
1160 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
1161 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
1162 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp13
+ tmp3
, CONST_BITS
-PASS1_BITS
);
1163 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp13
- tmp3
, CONST_BITS
-PASS1_BITS
);
1164 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp14
, CONST_BITS
-PASS1_BITS
);
1167 /* Pass 2: process 9 rows from work array, store into output array. */
1170 for (ctr
= 0; ctr
< 9; ctr
++) {
1171 outptr
= output_buf
[ctr
] + output_col
;
1175 /* Add fudge factor here for final descale. */
1176 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
1177 tmp0
<<= CONST_BITS
;
1179 z1
= (INT32
) wsptr
[2];
1180 z2
= (INT32
) wsptr
[4];
1181 z3
= (INT32
) wsptr
[6];
1183 tmp3
= MULTIPLY(z3
, FIX(0.707106781)); /* c6 */
1185 tmp2
= tmp0
- tmp3
- tmp3
;
1187 tmp0
= MULTIPLY(z1
- z2
, FIX(0.707106781)); /* c6 */
1188 tmp11
= tmp2
+ tmp0
;
1189 tmp14
= tmp2
- tmp0
- tmp0
;
1191 tmp0
= MULTIPLY(z1
+ z2
, FIX(1.328926049)); /* c2 */
1192 tmp2
= MULTIPLY(z1
, FIX(1.083350441)); /* c4 */
1193 tmp3
= MULTIPLY(z2
, FIX(0.245575608)); /* c8 */
1195 tmp10
= tmp1
+ tmp0
- tmp3
;
1196 tmp12
= tmp1
- tmp0
+ tmp2
;
1197 tmp13
= tmp1
- tmp2
+ tmp3
;
1201 z1
= (INT32
) wsptr
[1];
1202 z2
= (INT32
) wsptr
[3];
1203 z3
= (INT32
) wsptr
[5];
1204 z4
= (INT32
) wsptr
[7];
1206 z2
= MULTIPLY(z2
, - FIX(1.224744871)); /* -c3 */
1208 tmp2
= MULTIPLY(z1
+ z3
, FIX(0.909038955)); /* c5 */
1209 tmp3
= MULTIPLY(z1
+ z4
, FIX(0.483689525)); /* c7 */
1210 tmp0
= tmp2
+ tmp3
- z2
;
1211 tmp1
= MULTIPLY(z3
- z4
, FIX(1.392728481)); /* c1 */
1214 tmp1
= MULTIPLY(z1
- z3
- z4
, FIX(1.224744871)); /* c3 */
1216 /* Final output stage */
1218 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
1219 CONST_BITS
+PASS1_BITS
+3)
1221 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
1222 CONST_BITS
+PASS1_BITS
+3)
1224 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
1225 CONST_BITS
+PASS1_BITS
+3)
1227 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
1228 CONST_BITS
+PASS1_BITS
+3)
1230 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
1231 CONST_BITS
+PASS1_BITS
+3)
1233 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
1234 CONST_BITS
+PASS1_BITS
+3)
1236 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp3
,
1237 CONST_BITS
+PASS1_BITS
+3)
1239 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp3
,
1240 CONST_BITS
+PASS1_BITS
+3)
1242 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp14
,
1243 CONST_BITS
+PASS1_BITS
+3)
1246 wsptr
+= 8; /* advance pointer to next row */
1252 * Perform dequantization and inverse DCT on one block of coefficients,
1253 * producing a 10x10 output block.
1255 * Optimized algorithm with 12 multiplications in the 1-D kernel.
1256 * cK represents sqrt(2) * cos(K*pi/20).
1260 jpeg_idct_10x10 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1261 JCOEFPTR coef_block
,
1262 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1264 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1265 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
1266 INT32 z1
, z2
, z3
, z4
, z5
;
1268 ISLOW_MULT_TYPE
* quantptr
;
1271 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1273 int workspace
[8*10]; /* buffers data between passes */
1276 /* Pass 1: process columns from input, store into work array. */
1279 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1281 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1284 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1286 /* Add fudge factor here for final descale. */
1287 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1288 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1289 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
1290 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
1294 tmp22
= RIGHT_SHIFT(z3
- ((z1
- z2
) << 1), /* c0 = (c4-c8)*2 */
1295 CONST_BITS
-PASS1_BITS
);
1297 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1298 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1300 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
1301 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
1302 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
1304 tmp20
= tmp10
+ tmp12
;
1305 tmp24
= tmp10
- tmp12
;
1306 tmp21
= tmp11
+ tmp13
;
1307 tmp23
= tmp11
- tmp13
;
1311 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1312 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1313 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1314 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1319 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
1320 z5
= z3
<< CONST_BITS
;
1322 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
1325 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
1326 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
1328 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
1329 z4
= z5
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
1331 tmp12
= (z1
- tmp13
- z3
) << PASS1_BITS
;
1333 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
1334 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
1336 /* Final output stage */
1338 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1339 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1340 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1341 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1342 wsptr
[8*2] = (int) (tmp22
+ tmp12
);
1343 wsptr
[8*7] = (int) (tmp22
- tmp12
);
1344 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1345 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1346 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1347 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1350 /* Pass 2: process 10 rows from work array, store into output array. */
1353 for (ctr
= 0; ctr
< 10; ctr
++) {
1354 outptr
= output_buf
[ctr
] + output_col
;
1358 /* Add fudge factor here for final descale. */
1359 z3
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
1361 z4
= (INT32
) wsptr
[4];
1362 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
1363 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
1367 tmp22
= z3
- ((z1
- z2
) << 1); /* c0 = (c4-c8)*2 */
1369 z2
= (INT32
) wsptr
[2];
1370 z3
= (INT32
) wsptr
[6];
1372 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
1373 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
1374 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
1376 tmp20
= tmp10
+ tmp12
;
1377 tmp24
= tmp10
- tmp12
;
1378 tmp21
= tmp11
+ tmp13
;
1379 tmp23
= tmp11
- tmp13
;
1383 z1
= (INT32
) wsptr
[1];
1384 z2
= (INT32
) wsptr
[3];
1385 z3
= (INT32
) wsptr
[5];
1387 z4
= (INT32
) wsptr
[7];
1392 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
1394 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
1397 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
1398 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
1400 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
1401 z4
= z3
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
1403 tmp12
= ((z1
- tmp13
) << CONST_BITS
) - z3
;
1405 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
1406 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
1408 /* Final output stage */
1410 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1411 CONST_BITS
+PASS1_BITS
+3)
1413 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1414 CONST_BITS
+PASS1_BITS
+3)
1416 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1417 CONST_BITS
+PASS1_BITS
+3)
1419 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1420 CONST_BITS
+PASS1_BITS
+3)
1422 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1423 CONST_BITS
+PASS1_BITS
+3)
1425 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1426 CONST_BITS
+PASS1_BITS
+3)
1428 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1429 CONST_BITS
+PASS1_BITS
+3)
1431 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1432 CONST_BITS
+PASS1_BITS
+3)
1434 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1435 CONST_BITS
+PASS1_BITS
+3)
1437 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1438 CONST_BITS
+PASS1_BITS
+3)
1441 wsptr
+= 8; /* advance pointer to next row */
1447 * Perform dequantization and inverse DCT on one block of coefficients,
1448 * producing a 11x11 output block.
1450 * Optimized algorithm with 24 multiplications in the 1-D kernel.
1451 * cK represents sqrt(2) * cos(K*pi/22).
1455 jpeg_idct_11x11 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1456 JCOEFPTR coef_block
,
1457 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1459 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
1460 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
1461 INT32 z1
, z2
, z3
, z4
;
1463 ISLOW_MULT_TYPE
* quantptr
;
1466 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1468 int workspace
[8*11]; /* buffers data between passes */
1471 /* Pass 1: process columns from input, store into work array. */
1474 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1476 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1479 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1480 tmp10
<<= CONST_BITS
;
1481 /* Add fudge factor here for final descale. */
1482 tmp10
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1484 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1485 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1486 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1488 tmp20
= MULTIPLY(z2
- z3
, FIX(2.546640132)); /* c2+c4 */
1489 tmp23
= MULTIPLY(z2
- z1
, FIX(0.430815045)); /* c2-c6 */
1491 tmp24
= MULTIPLY(z4
, - FIX(1.155664402)); /* -(c2-c10) */
1493 tmp25
= tmp10
+ MULTIPLY(z4
, FIX(1.356927976)); /* c2 */
1494 tmp21
= tmp20
+ tmp23
+ tmp25
-
1495 MULTIPLY(z2
, FIX(1.821790775)); /* c2+c4+c10-c6 */
1496 tmp20
+= tmp25
+ MULTIPLY(z3
, FIX(2.115825087)); /* c4+c6 */
1497 tmp23
+= tmp25
- MULTIPLY(z1
, FIX(1.513598477)); /* c6+c8 */
1499 tmp22
= tmp24
- MULTIPLY(z3
, FIX(0.788749120)); /* c8+c10 */
1500 tmp24
+= MULTIPLY(z2
, FIX(1.944413522)) - /* c2+c8 */
1501 MULTIPLY(z1
, FIX(1.390975730)); /* c4+c10 */
1502 tmp25
= tmp10
- MULTIPLY(z4
, FIX(1.414213562)); /* c0 */
1506 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1507 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1508 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1509 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1512 tmp14
= MULTIPLY(tmp11
+ z3
+ z4
, FIX(0.398430003)); /* c9 */
1513 tmp11
= MULTIPLY(tmp11
, FIX(0.887983902)); /* c3-c9 */
1514 tmp12
= MULTIPLY(z1
+ z3
, FIX(0.670361295)); /* c5-c9 */
1515 tmp13
= tmp14
+ MULTIPLY(z1
+ z4
, FIX(0.366151574)); /* c7-c9 */
1516 tmp10
= tmp11
+ tmp12
+ tmp13
-
1517 MULTIPLY(z1
, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
1518 z1
= tmp14
- MULTIPLY(z2
+ z3
, FIX(1.163011579)); /* c7+c9 */
1519 tmp11
+= z1
+ MULTIPLY(z2
, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
1520 tmp12
+= z1
- MULTIPLY(z3
, FIX(1.192193623)); /* c3+c5-c7-c9 */
1521 z1
= MULTIPLY(z2
+ z4
, - FIX(1.798248910)); /* -(c1+c9) */
1523 tmp13
+= z1
+ MULTIPLY(z4
, FIX(2.102458632)); /* c1+c5+c9-c7 */
1524 tmp14
+= MULTIPLY(z2
, - FIX(1.467221301)) + /* -(c5+c9) */
1525 MULTIPLY(z3
, FIX(1.001388905)) - /* c1-c9 */
1526 MULTIPLY(z4
, FIX(1.684843907)); /* c3+c9 */
1528 /* Final output stage */
1530 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1531 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1532 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1533 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1534 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1535 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1536 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1537 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1538 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1539 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1540 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
, CONST_BITS
-PASS1_BITS
);
1543 /* Pass 2: process 11 rows from work array, store into output array. */
1546 for (ctr
= 0; ctr
< 11; ctr
++) {
1547 outptr
= output_buf
[ctr
] + output_col
;
1551 /* Add fudge factor here for final descale. */
1552 tmp10
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
1553 tmp10
<<= CONST_BITS
;
1555 z1
= (INT32
) wsptr
[2];
1556 z2
= (INT32
) wsptr
[4];
1557 z3
= (INT32
) wsptr
[6];
1559 tmp20
= MULTIPLY(z2
- z3
, FIX(2.546640132)); /* c2+c4 */
1560 tmp23
= MULTIPLY(z2
- z1
, FIX(0.430815045)); /* c2-c6 */
1562 tmp24
= MULTIPLY(z4
, - FIX(1.155664402)); /* -(c2-c10) */
1564 tmp25
= tmp10
+ MULTIPLY(z4
, FIX(1.356927976)); /* c2 */
1565 tmp21
= tmp20
+ tmp23
+ tmp25
-
1566 MULTIPLY(z2
, FIX(1.821790775)); /* c2+c4+c10-c6 */
1567 tmp20
+= tmp25
+ MULTIPLY(z3
, FIX(2.115825087)); /* c4+c6 */
1568 tmp23
+= tmp25
- MULTIPLY(z1
, FIX(1.513598477)); /* c6+c8 */
1570 tmp22
= tmp24
- MULTIPLY(z3
, FIX(0.788749120)); /* c8+c10 */
1571 tmp24
+= MULTIPLY(z2
, FIX(1.944413522)) - /* c2+c8 */
1572 MULTIPLY(z1
, FIX(1.390975730)); /* c4+c10 */
1573 tmp25
= tmp10
- MULTIPLY(z4
, FIX(1.414213562)); /* c0 */
1577 z1
= (INT32
) wsptr
[1];
1578 z2
= (INT32
) wsptr
[3];
1579 z3
= (INT32
) wsptr
[5];
1580 z4
= (INT32
) wsptr
[7];
1583 tmp14
= MULTIPLY(tmp11
+ z3
+ z4
, FIX(0.398430003)); /* c9 */
1584 tmp11
= MULTIPLY(tmp11
, FIX(0.887983902)); /* c3-c9 */
1585 tmp12
= MULTIPLY(z1
+ z3
, FIX(0.670361295)); /* c5-c9 */
1586 tmp13
= tmp14
+ MULTIPLY(z1
+ z4
, FIX(0.366151574)); /* c7-c9 */
1587 tmp10
= tmp11
+ tmp12
+ tmp13
-
1588 MULTIPLY(z1
, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
1589 z1
= tmp14
- MULTIPLY(z2
+ z3
, FIX(1.163011579)); /* c7+c9 */
1590 tmp11
+= z1
+ MULTIPLY(z2
, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
1591 tmp12
+= z1
- MULTIPLY(z3
, FIX(1.192193623)); /* c3+c5-c7-c9 */
1592 z1
= MULTIPLY(z2
+ z4
, - FIX(1.798248910)); /* -(c1+c9) */
1594 tmp13
+= z1
+ MULTIPLY(z4
, FIX(2.102458632)); /* c1+c5+c9-c7 */
1595 tmp14
+= MULTIPLY(z2
, - FIX(1.467221301)) + /* -(c5+c9) */
1596 MULTIPLY(z3
, FIX(1.001388905)) - /* c1-c9 */
1597 MULTIPLY(z4
, FIX(1.684843907)); /* c3+c9 */
1599 /* Final output stage */
1601 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1602 CONST_BITS
+PASS1_BITS
+3)
1604 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1605 CONST_BITS
+PASS1_BITS
+3)
1607 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1608 CONST_BITS
+PASS1_BITS
+3)
1610 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1611 CONST_BITS
+PASS1_BITS
+3)
1613 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1614 CONST_BITS
+PASS1_BITS
+3)
1616 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1617 CONST_BITS
+PASS1_BITS
+3)
1619 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1620 CONST_BITS
+PASS1_BITS
+3)
1622 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1623 CONST_BITS
+PASS1_BITS
+3)
1625 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1626 CONST_BITS
+PASS1_BITS
+3)
1628 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1629 CONST_BITS
+PASS1_BITS
+3)
1631 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
,
1632 CONST_BITS
+PASS1_BITS
+3)
1635 wsptr
+= 8; /* advance pointer to next row */
1641 * Perform dequantization and inverse DCT on one block of coefficients,
1642 * producing a 12x12 output block.
1644 * Optimized algorithm with 15 multiplications in the 1-D kernel.
1645 * cK represents sqrt(2) * cos(K*pi/24).
1649 jpeg_idct_12x12 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1650 JCOEFPTR coef_block
,
1651 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1653 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
1654 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
1655 INT32 z1
, z2
, z3
, z4
;
1657 ISLOW_MULT_TYPE
* quantptr
;
1660 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1662 int workspace
[8*12]; /* buffers data between passes */
1665 /* Pass 1: process columns from input, store into work array. */
1668 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1670 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1673 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1675 /* Add fudge factor here for final descale. */
1676 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1678 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1679 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
1684 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1685 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
1687 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1697 tmp20
= tmp10
+ tmp12
;
1698 tmp25
= tmp10
- tmp12
;
1700 tmp12
= z4
- z1
- z2
;
1702 tmp22
= tmp11
+ tmp12
;
1703 tmp23
= tmp11
- tmp12
;
1707 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1708 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1709 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1710 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1712 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
1713 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
1716 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
1717 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
1718 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
1719 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
1720 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
1721 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
1722 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
1723 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
1727 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
1728 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
1729 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
1731 /* Final output stage */
1733 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1734 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1735 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1736 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1737 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1738 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1739 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1740 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1741 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1742 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1743 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
1744 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
1747 /* Pass 2: process 12 rows from work array, store into output array. */
1750 for (ctr
= 0; ctr
< 12; ctr
++) {
1751 outptr
= output_buf
[ctr
] + output_col
;
1755 /* Add fudge factor here for final descale. */
1756 z3
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
1759 z4
= (INT32
) wsptr
[4];
1760 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
1765 z1
= (INT32
) wsptr
[2];
1766 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
1768 z2
= (INT32
) wsptr
[6];
1778 tmp20
= tmp10
+ tmp12
;
1779 tmp25
= tmp10
- tmp12
;
1781 tmp12
= z4
- z1
- z2
;
1783 tmp22
= tmp11
+ tmp12
;
1784 tmp23
= tmp11
- tmp12
;
1788 z1
= (INT32
) wsptr
[1];
1789 z2
= (INT32
) wsptr
[3];
1790 z3
= (INT32
) wsptr
[5];
1791 z4
= (INT32
) wsptr
[7];
1793 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
1794 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
1797 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
1798 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
1799 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
1800 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
1801 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
1802 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
1803 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
1804 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
1808 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
1809 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
1810 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
1812 /* Final output stage */
1814 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
1815 CONST_BITS
+PASS1_BITS
+3)
1817 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
1818 CONST_BITS
+PASS1_BITS
+3)
1820 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
1821 CONST_BITS
+PASS1_BITS
+3)
1823 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
1824 CONST_BITS
+PASS1_BITS
+3)
1826 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
1827 CONST_BITS
+PASS1_BITS
+3)
1829 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
1830 CONST_BITS
+PASS1_BITS
+3)
1832 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
1833 CONST_BITS
+PASS1_BITS
+3)
1835 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
1836 CONST_BITS
+PASS1_BITS
+3)
1838 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
1839 CONST_BITS
+PASS1_BITS
+3)
1841 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
1842 CONST_BITS
+PASS1_BITS
+3)
1844 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
1845 CONST_BITS
+PASS1_BITS
+3)
1847 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
1848 CONST_BITS
+PASS1_BITS
+3)
1851 wsptr
+= 8; /* advance pointer to next row */
1857 * Perform dequantization and inverse DCT on one block of coefficients,
1858 * producing a 13x13 output block.
1860 * Optimized algorithm with 29 multiplications in the 1-D kernel.
1861 * cK represents sqrt(2) * cos(K*pi/26).
1865 jpeg_idct_13x13 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
1866 JCOEFPTR coef_block
,
1867 JSAMPARRAY output_buf
, JDIMENSION output_col
)
1869 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
1870 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
1871 INT32 z1
, z2
, z3
, z4
;
1873 ISLOW_MULT_TYPE
* quantptr
;
1876 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
1878 int workspace
[8*13]; /* buffers data between passes */
1881 /* Pass 1: process columns from input, store into work array. */
1884 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
1886 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
1889 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
1891 /* Add fudge factor here for final descale. */
1892 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
1894 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
1895 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
1896 z4
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
1901 tmp12
= MULTIPLY(tmp10
, FIX(1.155388986)); /* (c4+c6)/2 */
1902 tmp13
= MULTIPLY(tmp11
, FIX(0.096834934)) + z1
; /* (c4-c6)/2 */
1904 tmp20
= MULTIPLY(z2
, FIX(1.373119086)) + tmp12
+ tmp13
; /* c2 */
1905 tmp22
= MULTIPLY(z2
, FIX(0.501487041)) - tmp12
+ tmp13
; /* c10 */
1907 tmp12
= MULTIPLY(tmp10
, FIX(0.316450131)); /* (c8-c12)/2 */
1908 tmp13
= MULTIPLY(tmp11
, FIX(0.486914739)) + z1
; /* (c8+c12)/2 */
1910 tmp21
= MULTIPLY(z2
, FIX(1.058554052)) - tmp12
+ tmp13
; /* c6 */
1911 tmp25
= MULTIPLY(z2
, - FIX(1.252223920)) + tmp12
+ tmp13
; /* c4 */
1913 tmp12
= MULTIPLY(tmp10
, FIX(0.435816023)); /* (c2-c10)/2 */
1914 tmp13
= MULTIPLY(tmp11
, FIX(0.937303064)) - z1
; /* (c2+c10)/2 */
1916 tmp23
= MULTIPLY(z2
, - FIX(0.170464608)) - tmp12
- tmp13
; /* c12 */
1917 tmp24
= MULTIPLY(z2
, - FIX(0.803364869)) + tmp12
- tmp13
; /* c8 */
1919 tmp26
= MULTIPLY(tmp11
- z2
, FIX(1.414213562)) + z1
; /* c0 */
1923 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
1924 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
1925 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
1926 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
1928 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.322312651)); /* c3 */
1929 tmp12
= MULTIPLY(z1
+ z3
, FIX(1.163874945)); /* c5 */
1931 tmp13
= MULTIPLY(tmp15
, FIX(0.937797057)); /* c7 */
1932 tmp10
= tmp11
+ tmp12
+ tmp13
-
1933 MULTIPLY(z1
, FIX(2.020082300)); /* c7+c5+c3-c1 */
1934 tmp14
= MULTIPLY(z2
+ z3
, - FIX(0.338443458)); /* -c11 */
1935 tmp11
+= tmp14
+ MULTIPLY(z2
, FIX(0.837223564)); /* c5+c9+c11-c3 */
1936 tmp12
+= tmp14
- MULTIPLY(z3
, FIX(1.572116027)); /* c1+c5-c9-c11 */
1937 tmp14
= MULTIPLY(z2
+ z4
, - FIX(1.163874945)); /* -c5 */
1939 tmp13
+= tmp14
+ MULTIPLY(z4
, FIX(2.205608352)); /* c3+c5+c9-c7 */
1940 tmp14
= MULTIPLY(z3
+ z4
, - FIX(0.657217813)); /* -c9 */
1943 tmp15
= MULTIPLY(tmp15
, FIX(0.338443458)); /* c11 */
1944 tmp14
= tmp15
+ MULTIPLY(z1
, FIX(0.318774355)) - /* c9-c11 */
1945 MULTIPLY(z2
, FIX(0.466105296)); /* c1-c7 */
1946 z1
= MULTIPLY(z3
- z2
, FIX(0.937797057)); /* c7 */
1948 tmp15
+= z1
+ MULTIPLY(z3
, FIX(0.384515595)) - /* c3-c7 */
1949 MULTIPLY(z4
, FIX(1.742345811)); /* c1+c11 */
1951 /* Final output stage */
1953 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
1954 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
1955 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
1956 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
1957 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
1958 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
1959 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
1960 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
1961 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
1962 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
1963 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
1964 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
1965 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
, CONST_BITS
-PASS1_BITS
);
1968 /* Pass 2: process 13 rows from work array, store into output array. */
1971 for (ctr
= 0; ctr
< 13; ctr
++) {
1972 outptr
= output_buf
[ctr
] + output_col
;
1976 /* Add fudge factor here for final descale. */
1977 z1
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
1980 z2
= (INT32
) wsptr
[2];
1981 z3
= (INT32
) wsptr
[4];
1982 z4
= (INT32
) wsptr
[6];
1987 tmp12
= MULTIPLY(tmp10
, FIX(1.155388986)); /* (c4+c6)/2 */
1988 tmp13
= MULTIPLY(tmp11
, FIX(0.096834934)) + z1
; /* (c4-c6)/2 */
1990 tmp20
= MULTIPLY(z2
, FIX(1.373119086)) + tmp12
+ tmp13
; /* c2 */
1991 tmp22
= MULTIPLY(z2
, FIX(0.501487041)) - tmp12
+ tmp13
; /* c10 */
1993 tmp12
= MULTIPLY(tmp10
, FIX(0.316450131)); /* (c8-c12)/2 */
1994 tmp13
= MULTIPLY(tmp11
, FIX(0.486914739)) + z1
; /* (c8+c12)/2 */
1996 tmp21
= MULTIPLY(z2
, FIX(1.058554052)) - tmp12
+ tmp13
; /* c6 */
1997 tmp25
= MULTIPLY(z2
, - FIX(1.252223920)) + tmp12
+ tmp13
; /* c4 */
1999 tmp12
= MULTIPLY(tmp10
, FIX(0.435816023)); /* (c2-c10)/2 */
2000 tmp13
= MULTIPLY(tmp11
, FIX(0.937303064)) - z1
; /* (c2+c10)/2 */
2002 tmp23
= MULTIPLY(z2
, - FIX(0.170464608)) - tmp12
- tmp13
; /* c12 */
2003 tmp24
= MULTIPLY(z2
, - FIX(0.803364869)) + tmp12
- tmp13
; /* c8 */
2005 tmp26
= MULTIPLY(tmp11
- z2
, FIX(1.414213562)) + z1
; /* c0 */
2009 z1
= (INT32
) wsptr
[1];
2010 z2
= (INT32
) wsptr
[3];
2011 z3
= (INT32
) wsptr
[5];
2012 z4
= (INT32
) wsptr
[7];
2014 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.322312651)); /* c3 */
2015 tmp12
= MULTIPLY(z1
+ z3
, FIX(1.163874945)); /* c5 */
2017 tmp13
= MULTIPLY(tmp15
, FIX(0.937797057)); /* c7 */
2018 tmp10
= tmp11
+ tmp12
+ tmp13
-
2019 MULTIPLY(z1
, FIX(2.020082300)); /* c7+c5+c3-c1 */
2020 tmp14
= MULTIPLY(z2
+ z3
, - FIX(0.338443458)); /* -c11 */
2021 tmp11
+= tmp14
+ MULTIPLY(z2
, FIX(0.837223564)); /* c5+c9+c11-c3 */
2022 tmp12
+= tmp14
- MULTIPLY(z3
, FIX(1.572116027)); /* c1+c5-c9-c11 */
2023 tmp14
= MULTIPLY(z2
+ z4
, - FIX(1.163874945)); /* -c5 */
2025 tmp13
+= tmp14
+ MULTIPLY(z4
, FIX(2.205608352)); /* c3+c5+c9-c7 */
2026 tmp14
= MULTIPLY(z3
+ z4
, - FIX(0.657217813)); /* -c9 */
2029 tmp15
= MULTIPLY(tmp15
, FIX(0.338443458)); /* c11 */
2030 tmp14
= tmp15
+ MULTIPLY(z1
, FIX(0.318774355)) - /* c9-c11 */
2031 MULTIPLY(z2
, FIX(0.466105296)); /* c1-c7 */
2032 z1
= MULTIPLY(z3
- z2
, FIX(0.937797057)); /* c7 */
2034 tmp15
+= z1
+ MULTIPLY(z3
, FIX(0.384515595)) - /* c3-c7 */
2035 MULTIPLY(z4
, FIX(1.742345811)); /* c1+c11 */
2037 /* Final output stage */
2039 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2040 CONST_BITS
+PASS1_BITS
+3)
2042 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2043 CONST_BITS
+PASS1_BITS
+3)
2045 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2046 CONST_BITS
+PASS1_BITS
+3)
2048 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2049 CONST_BITS
+PASS1_BITS
+3)
2051 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2052 CONST_BITS
+PASS1_BITS
+3)
2054 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2055 CONST_BITS
+PASS1_BITS
+3)
2057 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2058 CONST_BITS
+PASS1_BITS
+3)
2060 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2061 CONST_BITS
+PASS1_BITS
+3)
2063 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2064 CONST_BITS
+PASS1_BITS
+3)
2066 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2067 CONST_BITS
+PASS1_BITS
+3)
2069 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2070 CONST_BITS
+PASS1_BITS
+3)
2072 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2073 CONST_BITS
+PASS1_BITS
+3)
2075 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
,
2076 CONST_BITS
+PASS1_BITS
+3)
2079 wsptr
+= 8; /* advance pointer to next row */
2085 * Perform dequantization and inverse DCT on one block of coefficients,
2086 * producing a 14x14 output block.
2088 * Optimized algorithm with 20 multiplications in the 1-D kernel.
2089 * cK represents sqrt(2) * cos(K*pi/28).
2093 jpeg_idct_14x14 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2094 JCOEFPTR coef_block
,
2095 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2097 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
2098 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
2099 INT32 z1
, z2
, z3
, z4
;
2101 ISLOW_MULT_TYPE
* quantptr
;
2104 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2106 int workspace
[8*14]; /* buffers data between passes */
2109 /* Pass 1: process columns from input, store into work array. */
2112 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2114 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2117 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2119 /* Add fudge factor here for final descale. */
2120 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2121 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2122 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
2123 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
2124 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
2130 tmp23
= RIGHT_SHIFT(z1
- ((z2
+ z3
- z4
) << 1), /* c0 = (c4+c12-c8)*2 */
2131 CONST_BITS
-PASS1_BITS
);
2133 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2134 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2136 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
2138 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
2139 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
2140 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
2141 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
2143 tmp20
= tmp10
+ tmp13
;
2144 tmp26
= tmp10
- tmp13
;
2145 tmp21
= tmp11
+ tmp14
;
2146 tmp25
= tmp11
- tmp14
;
2147 tmp22
= tmp12
+ tmp15
;
2148 tmp24
= tmp12
- tmp15
;
2152 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2153 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2154 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2155 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2156 tmp13
= z4
<< CONST_BITS
;
2159 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
2160 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
2161 tmp10
= tmp11
+ tmp12
+ tmp13
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
2162 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
2163 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
2165 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - tmp13
; /* c11 */
2168 z4
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - tmp13
; /* -c13 */
2169 tmp11
+= z4
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
2170 tmp12
+= z4
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
2171 z4
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
2172 tmp14
+= z4
+ tmp13
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
2173 tmp15
+= z4
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
2175 tmp13
= (z1
- z3
) << PASS1_BITS
;
2177 /* Final output stage */
2179 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2180 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
2181 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2182 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
2183 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2184 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
2185 wsptr
[8*3] = (int) (tmp23
+ tmp13
);
2186 wsptr
[8*10] = (int) (tmp23
- tmp13
);
2187 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
2188 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
2189 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
2190 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
2191 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
2192 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
2195 /* Pass 2: process 14 rows from work array, store into output array. */
2198 for (ctr
= 0; ctr
< 14; ctr
++) {
2199 outptr
= output_buf
[ctr
] + output_col
;
2203 /* Add fudge factor here for final descale. */
2204 z1
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
2206 z4
= (INT32
) wsptr
[4];
2207 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
2208 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
2209 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
2215 tmp23
= z1
- ((z2
+ z3
- z4
) << 1); /* c0 = (c4+c12-c8)*2 */
2217 z1
= (INT32
) wsptr
[2];
2218 z2
= (INT32
) wsptr
[6];
2220 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
2222 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
2223 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
2224 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
2225 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
2227 tmp20
= tmp10
+ tmp13
;
2228 tmp26
= tmp10
- tmp13
;
2229 tmp21
= tmp11
+ tmp14
;
2230 tmp25
= tmp11
- tmp14
;
2231 tmp22
= tmp12
+ tmp15
;
2232 tmp24
= tmp12
- tmp15
;
2236 z1
= (INT32
) wsptr
[1];
2237 z2
= (INT32
) wsptr
[3];
2238 z3
= (INT32
) wsptr
[5];
2239 z4
= (INT32
) wsptr
[7];
2243 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
2244 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
2245 tmp10
= tmp11
+ tmp12
+ z4
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
2246 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
2247 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
2249 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - z4
; /* c11 */
2251 tmp13
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - z4
; /* -c13 */
2252 tmp11
+= tmp13
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
2253 tmp12
+= tmp13
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
2254 tmp13
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
2255 tmp14
+= tmp13
+ z4
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
2256 tmp15
+= tmp13
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
2258 tmp13
= ((z1
- z3
) << CONST_BITS
) + z4
;
2260 /* Final output stage */
2262 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2263 CONST_BITS
+PASS1_BITS
+3)
2265 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2266 CONST_BITS
+PASS1_BITS
+3)
2268 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2269 CONST_BITS
+PASS1_BITS
+3)
2271 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2272 CONST_BITS
+PASS1_BITS
+3)
2274 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2275 CONST_BITS
+PASS1_BITS
+3)
2277 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2278 CONST_BITS
+PASS1_BITS
+3)
2280 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2281 CONST_BITS
+PASS1_BITS
+3)
2283 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2284 CONST_BITS
+PASS1_BITS
+3)
2286 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2287 CONST_BITS
+PASS1_BITS
+3)
2289 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2290 CONST_BITS
+PASS1_BITS
+3)
2292 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2293 CONST_BITS
+PASS1_BITS
+3)
2295 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2296 CONST_BITS
+PASS1_BITS
+3)
2298 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
2299 CONST_BITS
+PASS1_BITS
+3)
2301 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
2302 CONST_BITS
+PASS1_BITS
+3)
2305 wsptr
+= 8; /* advance pointer to next row */
2311 * Perform dequantization and inverse DCT on one block of coefficients,
2312 * producing a 15x15 output block.
2314 * Optimized algorithm with 22 multiplications in the 1-D kernel.
2315 * cK represents sqrt(2) * cos(K*pi/30).
2319 jpeg_idct_15x15 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2320 JCOEFPTR coef_block
,
2321 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2323 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
2324 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2325 INT32 z1
, z2
, z3
, z4
;
2327 ISLOW_MULT_TYPE
* quantptr
;
2330 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2332 int workspace
[8*15]; /* buffers data between passes */
2335 /* Pass 1: process columns from input, store into work array. */
2338 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2340 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2343 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2345 /* Add fudge factor here for final descale. */
2346 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2348 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2349 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2350 z4
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2352 tmp10
= MULTIPLY(z4
, FIX(0.437016024)); /* c12 */
2353 tmp11
= MULTIPLY(z4
, FIX(1.144122806)); /* c6 */
2357 z1
-= (tmp11
- tmp10
) << 1; /* c0 = (c6-c12)*2 */
2361 tmp10
= MULTIPLY(z3
, FIX(1.337628990)); /* (c2+c4)/2 */
2362 tmp11
= MULTIPLY(z4
, FIX(0.045680613)); /* (c2-c4)/2 */
2363 z2
= MULTIPLY(z2
, FIX(1.439773946)); /* c4+c14 */
2365 tmp20
= tmp13
+ tmp10
+ tmp11
;
2366 tmp23
= tmp12
- tmp10
+ tmp11
+ z2
;
2368 tmp10
= MULTIPLY(z3
, FIX(0.547059574)); /* (c8+c14)/2 */
2369 tmp11
= MULTIPLY(z4
, FIX(0.399234004)); /* (c8-c14)/2 */
2371 tmp25
= tmp13
- tmp10
- tmp11
;
2372 tmp26
= tmp12
+ tmp10
- tmp11
- z2
;
2374 tmp10
= MULTIPLY(z3
, FIX(0.790569415)); /* (c6+c12)/2 */
2375 tmp11
= MULTIPLY(z4
, FIX(0.353553391)); /* (c6-c12)/2 */
2377 tmp21
= tmp12
+ tmp10
+ tmp11
;
2378 tmp24
= tmp13
- tmp10
+ tmp11
;
2380 tmp22
= z1
+ tmp11
; /* c10 = c6-c12 */
2381 tmp27
= z1
- tmp11
- tmp11
; /* c0 = (c6-c12)*2 */
2385 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2386 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2387 z4
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2388 z3
= MULTIPLY(z4
, FIX(1.224744871)); /* c5 */
2389 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2392 tmp15
= MULTIPLY(z1
+ tmp13
, FIX(0.831253876)); /* c9 */
2393 tmp11
= tmp15
+ MULTIPLY(z1
, FIX(0.513743148)); /* c3-c9 */
2394 tmp14
= tmp15
- MULTIPLY(tmp13
, FIX(2.176250899)); /* c3+c9 */
2396 tmp13
= MULTIPLY(z2
, - FIX(0.831253876)); /* -c9 */
2397 tmp15
= MULTIPLY(z2
, - FIX(1.344997024)); /* -c3 */
2399 tmp12
= z3
+ MULTIPLY(z2
, FIX(1.406466353)); /* c1 */
2401 tmp10
= tmp12
+ MULTIPLY(z4
, FIX(2.457431844)) - tmp15
; /* c1+c7 */
2402 tmp16
= tmp12
- MULTIPLY(z1
, FIX(1.112434820)) + tmp13
; /* c1-c13 */
2403 tmp12
= MULTIPLY(z2
, FIX(1.224744871)) - z3
; /* c5 */
2404 z2
= MULTIPLY(z1
+ z4
, FIX(0.575212477)); /* c11 */
2405 tmp13
+= z2
+ MULTIPLY(z1
, FIX(0.475753014)) - z3
; /* c7-c11 */
2406 tmp15
+= z2
- MULTIPLY(z4
, FIX(0.869244010)) + z3
; /* c11+c13 */
2408 /* Final output stage */
2410 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2411 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
2412 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2413 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
2414 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2415 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
2416 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
2417 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
2418 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
2419 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
2420 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
2421 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
2422 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
2423 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
2424 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
, CONST_BITS
-PASS1_BITS
);
2427 /* Pass 2: process 15 rows from work array, store into output array. */
2430 for (ctr
= 0; ctr
< 15; ctr
++) {
2431 outptr
= output_buf
[ctr
] + output_col
;
2435 /* Add fudge factor here for final descale. */
2436 z1
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
2439 z2
= (INT32
) wsptr
[2];
2440 z3
= (INT32
) wsptr
[4];
2441 z4
= (INT32
) wsptr
[6];
2443 tmp10
= MULTIPLY(z4
, FIX(0.437016024)); /* c12 */
2444 tmp11
= MULTIPLY(z4
, FIX(1.144122806)); /* c6 */
2448 z1
-= (tmp11
- tmp10
) << 1; /* c0 = (c6-c12)*2 */
2452 tmp10
= MULTIPLY(z3
, FIX(1.337628990)); /* (c2+c4)/2 */
2453 tmp11
= MULTIPLY(z4
, FIX(0.045680613)); /* (c2-c4)/2 */
2454 z2
= MULTIPLY(z2
, FIX(1.439773946)); /* c4+c14 */
2456 tmp20
= tmp13
+ tmp10
+ tmp11
;
2457 tmp23
= tmp12
- tmp10
+ tmp11
+ z2
;
2459 tmp10
= MULTIPLY(z3
, FIX(0.547059574)); /* (c8+c14)/2 */
2460 tmp11
= MULTIPLY(z4
, FIX(0.399234004)); /* (c8-c14)/2 */
2462 tmp25
= tmp13
- tmp10
- tmp11
;
2463 tmp26
= tmp12
+ tmp10
- tmp11
- z2
;
2465 tmp10
= MULTIPLY(z3
, FIX(0.790569415)); /* (c6+c12)/2 */
2466 tmp11
= MULTIPLY(z4
, FIX(0.353553391)); /* (c6-c12)/2 */
2468 tmp21
= tmp12
+ tmp10
+ tmp11
;
2469 tmp24
= tmp13
- tmp10
+ tmp11
;
2471 tmp22
= z1
+ tmp11
; /* c10 = c6-c12 */
2472 tmp27
= z1
- tmp11
- tmp11
; /* c0 = (c6-c12)*2 */
2476 z1
= (INT32
) wsptr
[1];
2477 z2
= (INT32
) wsptr
[3];
2478 z4
= (INT32
) wsptr
[5];
2479 z3
= MULTIPLY(z4
, FIX(1.224744871)); /* c5 */
2480 z4
= (INT32
) wsptr
[7];
2483 tmp15
= MULTIPLY(z1
+ tmp13
, FIX(0.831253876)); /* c9 */
2484 tmp11
= tmp15
+ MULTIPLY(z1
, FIX(0.513743148)); /* c3-c9 */
2485 tmp14
= tmp15
- MULTIPLY(tmp13
, FIX(2.176250899)); /* c3+c9 */
2487 tmp13
= MULTIPLY(z2
, - FIX(0.831253876)); /* -c9 */
2488 tmp15
= MULTIPLY(z2
, - FIX(1.344997024)); /* -c3 */
2490 tmp12
= z3
+ MULTIPLY(z2
, FIX(1.406466353)); /* c1 */
2492 tmp10
= tmp12
+ MULTIPLY(z4
, FIX(2.457431844)) - tmp15
; /* c1+c7 */
2493 tmp16
= tmp12
- MULTIPLY(z1
, FIX(1.112434820)) + tmp13
; /* c1-c13 */
2494 tmp12
= MULTIPLY(z2
, FIX(1.224744871)) - z3
; /* c5 */
2495 z2
= MULTIPLY(z1
+ z4
, FIX(0.575212477)); /* c11 */
2496 tmp13
+= z2
+ MULTIPLY(z1
, FIX(0.475753014)) - z3
; /* c7-c11 */
2497 tmp15
+= z2
- MULTIPLY(z4
, FIX(0.869244010)) + z3
; /* c11+c13 */
2499 /* Final output stage */
2501 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
2502 CONST_BITS
+PASS1_BITS
+3)
2504 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
2505 CONST_BITS
+PASS1_BITS
+3)
2507 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
2508 CONST_BITS
+PASS1_BITS
+3)
2510 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
2511 CONST_BITS
+PASS1_BITS
+3)
2513 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
2514 CONST_BITS
+PASS1_BITS
+3)
2516 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
2517 CONST_BITS
+PASS1_BITS
+3)
2519 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
2520 CONST_BITS
+PASS1_BITS
+3)
2522 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
2523 CONST_BITS
+PASS1_BITS
+3)
2525 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
2526 CONST_BITS
+PASS1_BITS
+3)
2528 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
2529 CONST_BITS
+PASS1_BITS
+3)
2531 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
2532 CONST_BITS
+PASS1_BITS
+3)
2534 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
2535 CONST_BITS
+PASS1_BITS
+3)
2537 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
2538 CONST_BITS
+PASS1_BITS
+3)
2540 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
2541 CONST_BITS
+PASS1_BITS
+3)
2543 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
,
2544 CONST_BITS
+PASS1_BITS
+3)
2547 wsptr
+= 8; /* advance pointer to next row */
2553 * Perform dequantization and inverse DCT on one block of coefficients,
2554 * producing a 16x16 output block.
2556 * Optimized algorithm with 28 multiplications in the 1-D kernel.
2557 * cK represents sqrt(2) * cos(K*pi/32).
2561 jpeg_idct_16x16 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2562 JCOEFPTR coef_block
,
2563 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2565 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
2566 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2567 INT32 z1
, z2
, z3
, z4
;
2569 ISLOW_MULT_TYPE
* quantptr
;
2572 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2574 int workspace
[8*16]; /* buffers data between passes */
2577 /* Pass 1: process columns from input, store into work array. */
2580 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2582 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
2585 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2586 tmp0
<<= CONST_BITS
;
2587 /* Add fudge factor here for final descale. */
2588 tmp0
+= 1 << (CONST_BITS
-PASS1_BITS
-1);
2590 z1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2591 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
2592 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
2594 tmp10
= tmp0
+ tmp1
;
2595 tmp11
= tmp0
- tmp1
;
2596 tmp12
= tmp0
+ tmp2
;
2597 tmp13
= tmp0
- tmp2
;
2599 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2600 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2602 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
2603 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
2605 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
2606 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
2607 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
2608 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
2610 tmp20
= tmp10
+ tmp0
;
2611 tmp27
= tmp10
- tmp0
;
2612 tmp21
= tmp12
+ tmp1
;
2613 tmp26
= tmp12
- tmp1
;
2614 tmp22
= tmp13
+ tmp2
;
2615 tmp25
= tmp13
- tmp2
;
2616 tmp23
= tmp11
+ tmp3
;
2617 tmp24
= tmp11
- tmp3
;
2621 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2622 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2623 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2624 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2628 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
2629 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
2630 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
2631 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
2632 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
2633 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
2634 tmp0
= tmp1
+ tmp2
+ tmp3
-
2635 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
2636 tmp13
= tmp10
+ tmp11
+ tmp12
-
2637 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
2638 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
2639 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
2640 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
2641 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
2642 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
2643 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
2645 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
2647 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
2648 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
2649 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
2651 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
2654 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
2658 /* Final output stage */
2660 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp0
, CONST_BITS
-PASS1_BITS
);
2661 wsptr
[8*15] = (int) RIGHT_SHIFT(tmp20
- tmp0
, CONST_BITS
-PASS1_BITS
);
2662 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp1
, CONST_BITS
-PASS1_BITS
);
2663 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp21
- tmp1
, CONST_BITS
-PASS1_BITS
);
2664 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp2
, CONST_BITS
-PASS1_BITS
);
2665 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp22
- tmp2
, CONST_BITS
-PASS1_BITS
);
2666 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp3
, CONST_BITS
-PASS1_BITS
);
2667 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp23
- tmp3
, CONST_BITS
-PASS1_BITS
);
2668 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp10
, CONST_BITS
-PASS1_BITS
);
2669 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp24
- tmp10
, CONST_BITS
-PASS1_BITS
);
2670 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp11
, CONST_BITS
-PASS1_BITS
);
2671 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp25
- tmp11
, CONST_BITS
-PASS1_BITS
);
2672 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp12
, CONST_BITS
-PASS1_BITS
);
2673 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp26
- tmp12
, CONST_BITS
-PASS1_BITS
);
2674 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
+ tmp13
, CONST_BITS
-PASS1_BITS
);
2675 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp27
- tmp13
, CONST_BITS
-PASS1_BITS
);
2678 /* Pass 2: process 16 rows from work array, store into output array. */
2681 for (ctr
= 0; ctr
< 16; ctr
++) {
2682 outptr
= output_buf
[ctr
] + output_col
;
2686 /* Add fudge factor here for final descale. */
2687 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
2688 tmp0
<<= CONST_BITS
;
2690 z1
= (INT32
) wsptr
[4];
2691 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
2692 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
2694 tmp10
= tmp0
+ tmp1
;
2695 tmp11
= tmp0
- tmp1
;
2696 tmp12
= tmp0
+ tmp2
;
2697 tmp13
= tmp0
- tmp2
;
2699 z1
= (INT32
) wsptr
[2];
2700 z2
= (INT32
) wsptr
[6];
2702 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
2703 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
2705 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
2706 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
2707 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
2708 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
2710 tmp20
= tmp10
+ tmp0
;
2711 tmp27
= tmp10
- tmp0
;
2712 tmp21
= tmp12
+ tmp1
;
2713 tmp26
= tmp12
- tmp1
;
2714 tmp22
= tmp13
+ tmp2
;
2715 tmp25
= tmp13
- tmp2
;
2716 tmp23
= tmp11
+ tmp3
;
2717 tmp24
= tmp11
- tmp3
;
2721 z1
= (INT32
) wsptr
[1];
2722 z2
= (INT32
) wsptr
[3];
2723 z3
= (INT32
) wsptr
[5];
2724 z4
= (INT32
) wsptr
[7];
2728 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
2729 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
2730 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
2731 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
2732 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
2733 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
2734 tmp0
= tmp1
+ tmp2
+ tmp3
-
2735 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
2736 tmp13
= tmp10
+ tmp11
+ tmp12
-
2737 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
2738 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
2739 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
2740 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
2741 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
2742 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
2743 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
2745 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
2747 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
2748 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
2749 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
2751 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
2754 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
2758 /* Final output stage */
2760 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp0
,
2761 CONST_BITS
+PASS1_BITS
+3)
2763 outptr
[15] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp0
,
2764 CONST_BITS
+PASS1_BITS
+3)
2766 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp1
,
2767 CONST_BITS
+PASS1_BITS
+3)
2769 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp1
,
2770 CONST_BITS
+PASS1_BITS
+3)
2772 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp2
,
2773 CONST_BITS
+PASS1_BITS
+3)
2775 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp2
,
2776 CONST_BITS
+PASS1_BITS
+3)
2778 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp3
,
2779 CONST_BITS
+PASS1_BITS
+3)
2781 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp3
,
2782 CONST_BITS
+PASS1_BITS
+3)
2784 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp10
,
2785 CONST_BITS
+PASS1_BITS
+3)
2787 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp10
,
2788 CONST_BITS
+PASS1_BITS
+3)
2790 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp11
,
2791 CONST_BITS
+PASS1_BITS
+3)
2793 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp11
,
2794 CONST_BITS
+PASS1_BITS
+3)
2796 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp12
,
2797 CONST_BITS
+PASS1_BITS
+3)
2799 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp12
,
2800 CONST_BITS
+PASS1_BITS
+3)
2802 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
+ tmp13
,
2803 CONST_BITS
+PASS1_BITS
+3)
2805 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp27
- tmp13
,
2806 CONST_BITS
+PASS1_BITS
+3)
2809 wsptr
+= 8; /* advance pointer to next row */
2815 * Perform dequantization and inverse DCT on one block of coefficients,
2816 * producing a 16x8 output block.
2818 * 8-point IDCT in pass 1 (columns), 16-point in pass 2 (rows).
2822 jpeg_idct_16x8 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
2823 JCOEFPTR coef_block
,
2824 JSAMPARRAY output_buf
, JDIMENSION output_col
)
2826 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
2827 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
2828 INT32 z1
, z2
, z3
, z4
;
2830 ISLOW_MULT_TYPE
* quantptr
;
2833 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
2835 int workspace
[8*8]; /* buffers data between passes */
2838 /* Pass 1: process columns from input, store into work array. */
2839 /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
2840 /* furthermore, we scale the results by 2**PASS1_BITS. */
2843 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
2845 for (ctr
= DCTSIZE
; ctr
> 0; ctr
--) {
2846 /* Due to quantization, we will usually find that many of the input
2847 * coefficients are zero, especially the AC terms. We can exploit this
2848 * by short-circuiting the IDCT calculation for any column in which all
2849 * the AC terms are zero. In that case each output is equal to the
2850 * DC coefficient (with scale factor as needed).
2851 * With typical images and quantization tables, half or more of the
2852 * column DCT calculations can be simplified this way.
2855 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
2856 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
2857 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
2858 inptr
[DCTSIZE
*7] == 0) {
2859 /* AC terms all zero */
2860 int dcval
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]) << PASS1_BITS
;
2862 wsptr
[DCTSIZE
*0] = dcval
;
2863 wsptr
[DCTSIZE
*1] = dcval
;
2864 wsptr
[DCTSIZE
*2] = dcval
;
2865 wsptr
[DCTSIZE
*3] = dcval
;
2866 wsptr
[DCTSIZE
*4] = dcval
;
2867 wsptr
[DCTSIZE
*5] = dcval
;
2868 wsptr
[DCTSIZE
*6] = dcval
;
2869 wsptr
[DCTSIZE
*7] = dcval
;
2871 inptr
++; /* advance pointers to next column */
2877 /* Even part: reverse the even part of the forward DCT. */
2878 /* The rotator is sqrt(2)*c(-6). */
2880 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
2881 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
2883 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
2884 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
2885 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
2887 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
2888 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
2891 /* Add fudge factor here for final descale. */
2892 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
2897 tmp10
= tmp0
+ tmp2
;
2898 tmp13
= tmp0
- tmp2
;
2899 tmp11
= tmp1
+ tmp3
;
2900 tmp12
= tmp1
- tmp3
;
2902 /* Odd part per figure 8; the matrix is unitary and hence its
2903 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
2906 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
2907 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
2908 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
2909 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
2914 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
2915 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
2916 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
2920 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
2921 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
2922 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
2926 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
2927 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
2928 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
2932 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
2934 wsptr
[DCTSIZE
*0] = (int) RIGHT_SHIFT(tmp10
+ tmp3
, CONST_BITS
-PASS1_BITS
);
2935 wsptr
[DCTSIZE
*7] = (int) RIGHT_SHIFT(tmp10
- tmp3
, CONST_BITS
-PASS1_BITS
);
2936 wsptr
[DCTSIZE
*1] = (int) RIGHT_SHIFT(tmp11
+ tmp2
, CONST_BITS
-PASS1_BITS
);
2937 wsptr
[DCTSIZE
*6] = (int) RIGHT_SHIFT(tmp11
- tmp2
, CONST_BITS
-PASS1_BITS
);
2938 wsptr
[DCTSIZE
*2] = (int) RIGHT_SHIFT(tmp12
+ tmp1
, CONST_BITS
-PASS1_BITS
);
2939 wsptr
[DCTSIZE
*5] = (int) RIGHT_SHIFT(tmp12
- tmp1
, CONST_BITS
-PASS1_BITS
);
2940 wsptr
[DCTSIZE
*3] = (int) RIGHT_SHIFT(tmp13
+ tmp0
, CONST_BITS
-PASS1_BITS
);
2941 wsptr
[DCTSIZE
*4] = (int) RIGHT_SHIFT(tmp13
- tmp0
, CONST_BITS
-PASS1_BITS
);
2943 inptr
++; /* advance pointers to next column */
2948 /* Pass 2: process 8 rows from work array, store into output array.
2949 * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
2952 for (ctr
= 0; ctr
< 8; ctr
++) {
2953 outptr
= output_buf
[ctr
] + output_col
;
2957 /* Add fudge factor here for final descale. */
2958 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
2959 tmp0
<<= CONST_BITS
;
2961 z1
= (INT32
) wsptr
[4];
2962 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
2963 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
2965 tmp10
= tmp0
+ tmp1
;
2966 tmp11
= tmp0
- tmp1
;
2967 tmp12
= tmp0
+ tmp2
;
2968 tmp13
= tmp0
- tmp2
;
2970 z1
= (INT32
) wsptr
[2];
2971 z2
= (INT32
) wsptr
[6];
2973 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
2974 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
2976 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
2977 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
2978 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
2979 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
2981 tmp20
= tmp10
+ tmp0
;
2982 tmp27
= tmp10
- tmp0
;
2983 tmp21
= tmp12
+ tmp1
;
2984 tmp26
= tmp12
- tmp1
;
2985 tmp22
= tmp13
+ tmp2
;
2986 tmp25
= tmp13
- tmp2
;
2987 tmp23
= tmp11
+ tmp3
;
2988 tmp24
= tmp11
- tmp3
;
2992 z1
= (INT32
) wsptr
[1];
2993 z2
= (INT32
) wsptr
[3];
2994 z3
= (INT32
) wsptr
[5];
2995 z4
= (INT32
) wsptr
[7];
2999 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
3000 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
3001 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
3002 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
3003 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
3004 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
3005 tmp0
= tmp1
+ tmp2
+ tmp3
-
3006 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
3007 tmp13
= tmp10
+ tmp11
+ tmp12
-
3008 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
3009 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
3010 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
3011 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
3012 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
3013 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
3014 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
3016 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
3018 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
3019 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
3020 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
3022 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
3025 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
3029 /* Final output stage */
3031 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp0
,
3032 CONST_BITS
+PASS1_BITS
+3)
3034 outptr
[15] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp0
,
3035 CONST_BITS
+PASS1_BITS
+3)
3037 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp1
,
3038 CONST_BITS
+PASS1_BITS
+3)
3040 outptr
[14] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp1
,
3041 CONST_BITS
+PASS1_BITS
+3)
3043 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp2
,
3044 CONST_BITS
+PASS1_BITS
+3)
3046 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp2
,
3047 CONST_BITS
+PASS1_BITS
+3)
3049 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp3
,
3050 CONST_BITS
+PASS1_BITS
+3)
3052 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp3
,
3053 CONST_BITS
+PASS1_BITS
+3)
3055 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp10
,
3056 CONST_BITS
+PASS1_BITS
+3)
3058 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp10
,
3059 CONST_BITS
+PASS1_BITS
+3)
3061 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp11
,
3062 CONST_BITS
+PASS1_BITS
+3)
3064 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp11
,
3065 CONST_BITS
+PASS1_BITS
+3)
3067 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp12
,
3068 CONST_BITS
+PASS1_BITS
+3)
3070 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp12
,
3071 CONST_BITS
+PASS1_BITS
+3)
3073 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp27
+ tmp13
,
3074 CONST_BITS
+PASS1_BITS
+3)
3076 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp27
- tmp13
,
3077 CONST_BITS
+PASS1_BITS
+3)
3080 wsptr
+= 8; /* advance pointer to next row */
3086 * Perform dequantization and inverse DCT on one block of coefficients,
3087 * producing a 14x7 output block.
3089 * 7-point IDCT in pass 1 (columns), 14-point in pass 2 (rows).
3093 jpeg_idct_14x7 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3094 JCOEFPTR coef_block
,
3095 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3097 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
3098 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
3099 INT32 z1
, z2
, z3
, z4
;
3101 ISLOW_MULT_TYPE
* quantptr
;
3104 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3106 int workspace
[8*7]; /* buffers data between passes */
3109 /* Pass 1: process columns from input, store into work array.
3110 * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14).
3113 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3115 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3118 tmp23
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3119 tmp23
<<= CONST_BITS
;
3120 /* Add fudge factor here for final descale. */
3121 tmp23
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3123 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3124 z2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3125 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
3127 tmp20
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
3128 tmp22
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
3129 tmp21
= tmp20
+ tmp22
+ tmp23
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
3132 tmp10
= MULTIPLY(tmp10
, FIX(1.274162392)) + tmp23
; /* c2 */
3133 tmp20
+= tmp10
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
3134 tmp22
+= tmp10
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
3135 tmp23
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
3139 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3140 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3141 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
3143 tmp11
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
3144 tmp12
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
3145 tmp10
= tmp11
- tmp12
;
3147 tmp12
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
3149 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
3151 tmp12
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
3153 /* Final output stage */
3155 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
3156 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
3157 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
3158 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
3159 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
3160 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
3161 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
, CONST_BITS
-PASS1_BITS
);
3164 /* Pass 2: process 7 rows from work array, store into output array.
3165 * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28).
3168 for (ctr
= 0; ctr
< 7; ctr
++) {
3169 outptr
= output_buf
[ctr
] + output_col
;
3173 /* Add fudge factor here for final descale. */
3174 z1
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
3176 z4
= (INT32
) wsptr
[4];
3177 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
3178 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
3179 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
3185 tmp23
= z1
- ((z2
+ z3
- z4
) << 1); /* c0 = (c4+c12-c8)*2 */
3187 z1
= (INT32
) wsptr
[2];
3188 z2
= (INT32
) wsptr
[6];
3190 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
3192 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
3193 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
3194 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
3195 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
3197 tmp20
= tmp10
+ tmp13
;
3198 tmp26
= tmp10
- tmp13
;
3199 tmp21
= tmp11
+ tmp14
;
3200 tmp25
= tmp11
- tmp14
;
3201 tmp22
= tmp12
+ tmp15
;
3202 tmp24
= tmp12
- tmp15
;
3206 z1
= (INT32
) wsptr
[1];
3207 z2
= (INT32
) wsptr
[3];
3208 z3
= (INT32
) wsptr
[5];
3209 z4
= (INT32
) wsptr
[7];
3213 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
3214 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
3215 tmp10
= tmp11
+ tmp12
+ z4
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
3216 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
3217 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
3219 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - z4
; /* c11 */
3221 tmp13
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - z4
; /* -c13 */
3222 tmp11
+= tmp13
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
3223 tmp12
+= tmp13
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
3224 tmp13
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
3225 tmp14
+= tmp13
+ z4
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
3226 tmp15
+= tmp13
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
3228 tmp13
= ((z1
- z3
) << CONST_BITS
) + z4
;
3230 /* Final output stage */
3232 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3233 CONST_BITS
+PASS1_BITS
+3)
3235 outptr
[13] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3236 CONST_BITS
+PASS1_BITS
+3)
3238 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3239 CONST_BITS
+PASS1_BITS
+3)
3241 outptr
[12] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3242 CONST_BITS
+PASS1_BITS
+3)
3244 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3245 CONST_BITS
+PASS1_BITS
+3)
3247 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3248 CONST_BITS
+PASS1_BITS
+3)
3250 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3251 CONST_BITS
+PASS1_BITS
+3)
3253 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3254 CONST_BITS
+PASS1_BITS
+3)
3256 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3257 CONST_BITS
+PASS1_BITS
+3)
3259 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3260 CONST_BITS
+PASS1_BITS
+3)
3262 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
3263 CONST_BITS
+PASS1_BITS
+3)
3265 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
3266 CONST_BITS
+PASS1_BITS
+3)
3268 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp26
+ tmp16
,
3269 CONST_BITS
+PASS1_BITS
+3)
3271 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp26
- tmp16
,
3272 CONST_BITS
+PASS1_BITS
+3)
3275 wsptr
+= 8; /* advance pointer to next row */
3281 * Perform dequantization and inverse DCT on one block of coefficients,
3282 * producing a 12x6 output block.
3284 * 6-point IDCT in pass 1 (columns), 12-point in pass 2 (rows).
3288 jpeg_idct_12x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3289 JCOEFPTR coef_block
,
3290 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3292 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
3293 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
3294 INT32 z1
, z2
, z3
, z4
;
3296 ISLOW_MULT_TYPE
* quantptr
;
3299 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3301 int workspace
[8*6]; /* buffers data between passes */
3304 /* Pass 1: process columns from input, store into work array.
3305 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
3308 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3310 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3313 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3314 tmp10
<<= CONST_BITS
;
3315 /* Add fudge factor here for final descale. */
3316 tmp10
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3317 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3318 tmp20
= MULTIPLY(tmp12
, FIX(0.707106781)); /* c4 */
3319 tmp11
= tmp10
+ tmp20
;
3320 tmp21
= RIGHT_SHIFT(tmp10
- tmp20
- tmp20
, CONST_BITS
-PASS1_BITS
);
3321 tmp20
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3322 tmp10
= MULTIPLY(tmp20
, FIX(1.224744871)); /* c2 */
3323 tmp20
= tmp11
+ tmp10
;
3324 tmp22
= tmp11
- tmp10
;
3328 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3329 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3330 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
3331 tmp11
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
3332 tmp10
= tmp11
+ ((z1
+ z2
) << CONST_BITS
);
3333 tmp12
= tmp11
+ ((z3
- z2
) << CONST_BITS
);
3334 tmp11
= (z1
- z2
- z3
) << PASS1_BITS
;
3336 /* Final output stage */
3338 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
3339 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
3340 wsptr
[8*1] = (int) (tmp21
+ tmp11
);
3341 wsptr
[8*4] = (int) (tmp21
- tmp11
);
3342 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
3343 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
3346 /* Pass 2: process 6 rows from work array, store into output array.
3347 * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24).
3350 for (ctr
= 0; ctr
< 6; ctr
++) {
3351 outptr
= output_buf
[ctr
] + output_col
;
3355 /* Add fudge factor here for final descale. */
3356 z3
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
3359 z4
= (INT32
) wsptr
[4];
3360 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
3365 z1
= (INT32
) wsptr
[2];
3366 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
3368 z2
= (INT32
) wsptr
[6];
3378 tmp20
= tmp10
+ tmp12
;
3379 tmp25
= tmp10
- tmp12
;
3381 tmp12
= z4
- z1
- z2
;
3383 tmp22
= tmp11
+ tmp12
;
3384 tmp23
= tmp11
- tmp12
;
3388 z1
= (INT32
) wsptr
[1];
3389 z2
= (INT32
) wsptr
[3];
3390 z3
= (INT32
) wsptr
[5];
3391 z4
= (INT32
) wsptr
[7];
3393 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
3394 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
3397 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
3398 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
3399 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
3400 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
3401 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
3402 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
3403 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
3404 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
3408 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
3409 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
3410 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
3412 /* Final output stage */
3414 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3415 CONST_BITS
+PASS1_BITS
+3)
3417 outptr
[11] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3418 CONST_BITS
+PASS1_BITS
+3)
3420 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3421 CONST_BITS
+PASS1_BITS
+3)
3423 outptr
[10] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3424 CONST_BITS
+PASS1_BITS
+3)
3426 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3427 CONST_BITS
+PASS1_BITS
+3)
3429 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3430 CONST_BITS
+PASS1_BITS
+3)
3432 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3433 CONST_BITS
+PASS1_BITS
+3)
3435 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3436 CONST_BITS
+PASS1_BITS
+3)
3438 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3439 CONST_BITS
+PASS1_BITS
+3)
3441 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3442 CONST_BITS
+PASS1_BITS
+3)
3444 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp25
+ tmp15
,
3445 CONST_BITS
+PASS1_BITS
+3)
3447 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp25
- tmp15
,
3448 CONST_BITS
+PASS1_BITS
+3)
3451 wsptr
+= 8; /* advance pointer to next row */
3457 * Perform dequantization and inverse DCT on one block of coefficients,
3458 * producing a 10x5 output block.
3460 * 5-point IDCT in pass 1 (columns), 10-point in pass 2 (rows).
3464 jpeg_idct_10x5 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3465 JCOEFPTR coef_block
,
3466 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3468 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
3469 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
3470 INT32 z1
, z2
, z3
, z4
;
3472 ISLOW_MULT_TYPE
* quantptr
;
3475 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3477 int workspace
[8*5]; /* buffers data between passes */
3480 /* Pass 1: process columns from input, store into work array.
3481 * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10).
3484 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3486 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3489 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3490 tmp12
<<= CONST_BITS
;
3491 /* Add fudge factor here for final descale. */
3492 tmp12
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3493 tmp13
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3494 tmp14
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
3495 z1
= MULTIPLY(tmp13
+ tmp14
, FIX(0.790569415)); /* (c2+c4)/2 */
3496 z2
= MULTIPLY(tmp13
- tmp14
, FIX(0.353553391)); /* (c2-c4)/2 */
3504 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3505 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3507 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
3508 tmp13
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
3509 tmp14
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
3511 /* Final output stage */
3513 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp10
+ tmp13
, CONST_BITS
-PASS1_BITS
);
3514 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp10
- tmp13
, CONST_BITS
-PASS1_BITS
);
3515 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp11
+ tmp14
, CONST_BITS
-PASS1_BITS
);
3516 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp11
- tmp14
, CONST_BITS
-PASS1_BITS
);
3517 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp12
, CONST_BITS
-PASS1_BITS
);
3520 /* Pass 2: process 5 rows from work array, store into output array.
3521 * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20).
3524 for (ctr
= 0; ctr
< 5; ctr
++) {
3525 outptr
= output_buf
[ctr
] + output_col
;
3529 /* Add fudge factor here for final descale. */
3530 z3
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
3532 z4
= (INT32
) wsptr
[4];
3533 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
3534 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
3538 tmp22
= z3
- ((z1
- z2
) << 1); /* c0 = (c4-c8)*2 */
3540 z2
= (INT32
) wsptr
[2];
3541 z3
= (INT32
) wsptr
[6];
3543 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
3544 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
3545 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
3547 tmp20
= tmp10
+ tmp12
;
3548 tmp24
= tmp10
- tmp12
;
3549 tmp21
= tmp11
+ tmp13
;
3550 tmp23
= tmp11
- tmp13
;
3554 z1
= (INT32
) wsptr
[1];
3555 z2
= (INT32
) wsptr
[3];
3556 z3
= (INT32
) wsptr
[5];
3558 z4
= (INT32
) wsptr
[7];
3563 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
3565 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
3568 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
3569 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
3571 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
3572 z4
= z3
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
3574 tmp12
= ((z1
- tmp13
) << CONST_BITS
) - z3
;
3576 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
3577 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
3579 /* Final output stage */
3581 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
3582 CONST_BITS
+PASS1_BITS
+3)
3584 outptr
[9] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
3585 CONST_BITS
+PASS1_BITS
+3)
3587 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
3588 CONST_BITS
+PASS1_BITS
+3)
3590 outptr
[8] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
3591 CONST_BITS
+PASS1_BITS
+3)
3593 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
3594 CONST_BITS
+PASS1_BITS
+3)
3596 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
3597 CONST_BITS
+PASS1_BITS
+3)
3599 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
+ tmp13
,
3600 CONST_BITS
+PASS1_BITS
+3)
3602 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp23
- tmp13
,
3603 CONST_BITS
+PASS1_BITS
+3)
3605 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp24
+ tmp14
,
3606 CONST_BITS
+PASS1_BITS
+3)
3608 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp24
- tmp14
,
3609 CONST_BITS
+PASS1_BITS
+3)
3612 wsptr
+= 8; /* advance pointer to next row */
3618 * Perform dequantization and inverse DCT on one block of coefficients,
3619 * producing a 8x4 output block.
3621 * 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
3625 jpeg_idct_8x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3626 JCOEFPTR coef_block
,
3627 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3629 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
3630 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
3633 ISLOW_MULT_TYPE
* quantptr
;
3636 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3638 int workspace
[8*4]; /* buffers data between passes */
3641 /* Pass 1: process columns from input, store into work array.
3642 * 4-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
3645 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3647 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3650 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3651 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3653 tmp10
= (tmp0
+ tmp2
) << PASS1_BITS
;
3654 tmp12
= (tmp0
- tmp2
) << PASS1_BITS
;
3657 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
3659 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3660 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
3662 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
3663 /* Add fudge factor here for final descale. */
3664 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3665 tmp0
= RIGHT_SHIFT(z1
+ MULTIPLY(z2
, FIX_0_765366865
), /* c2-c6 */
3666 CONST_BITS
-PASS1_BITS
);
3667 tmp2
= RIGHT_SHIFT(z1
- MULTIPLY(z3
, FIX_1_847759065
), /* c2+c6 */
3668 CONST_BITS
-PASS1_BITS
);
3670 /* Final output stage */
3672 wsptr
[8*0] = (int) (tmp10
+ tmp0
);
3673 wsptr
[8*3] = (int) (tmp10
- tmp0
);
3674 wsptr
[8*1] = (int) (tmp12
+ tmp2
);
3675 wsptr
[8*2] = (int) (tmp12
- tmp2
);
3678 /* Pass 2: process rows from work array, store into output array. */
3679 /* Note that we must descale the results by a factor of 8 == 2**3, */
3680 /* and also undo the PASS1_BITS scaling. */
3683 for (ctr
= 0; ctr
< 4; ctr
++) {
3684 outptr
= output_buf
[ctr
] + output_col
;
3686 /* Even part: reverse the even part of the forward DCT. */
3687 /* The rotator is sqrt(2)*c(-6). */
3689 z2
= (INT32
) wsptr
[2];
3690 z3
= (INT32
) wsptr
[6];
3692 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
3693 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
3694 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
3696 /* Add fudge factor here for final descale. */
3697 z2
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
3698 z3
= (INT32
) wsptr
[4];
3700 tmp0
= (z2
+ z3
) << CONST_BITS
;
3701 tmp1
= (z2
- z3
) << CONST_BITS
;
3703 tmp10
= tmp0
+ tmp2
;
3704 tmp13
= tmp0
- tmp2
;
3705 tmp11
= tmp1
+ tmp3
;
3706 tmp12
= tmp1
- tmp3
;
3708 /* Odd part per figure 8; the matrix is unitary and hence its
3709 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
3712 tmp0
= (INT32
) wsptr
[7];
3713 tmp1
= (INT32
) wsptr
[5];
3714 tmp2
= (INT32
) wsptr
[3];
3715 tmp3
= (INT32
) wsptr
[1];
3720 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
3721 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
3722 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
3726 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
3727 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
3728 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
3732 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
3733 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
3734 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
3738 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
3740 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
3741 CONST_BITS
+PASS1_BITS
+3)
3743 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
3744 CONST_BITS
+PASS1_BITS
+3)
3746 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
3747 CONST_BITS
+PASS1_BITS
+3)
3749 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
3750 CONST_BITS
+PASS1_BITS
+3)
3752 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
3753 CONST_BITS
+PASS1_BITS
+3)
3755 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
3756 CONST_BITS
+PASS1_BITS
+3)
3758 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
3759 CONST_BITS
+PASS1_BITS
+3)
3761 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
3762 CONST_BITS
+PASS1_BITS
+3)
3765 wsptr
+= DCTSIZE
; /* advance pointer to next row */
3771 * Perform dequantization and inverse DCT on one block of coefficients,
3772 * producing a reduced-size 6x3 output block.
3774 * 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
3778 jpeg_idct_6x3 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3779 JCOEFPTR coef_block
,
3780 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3782 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
3785 ISLOW_MULT_TYPE
* quantptr
;
3788 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3790 int workspace
[6*3]; /* buffers data between passes */
3793 /* Pass 1: process columns from input, store into work array.
3794 * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6).
3797 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3799 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3802 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3803 tmp0
<<= CONST_BITS
;
3804 /* Add fudge factor here for final descale. */
3805 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
3806 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
3807 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
3808 tmp10
= tmp0
+ tmp12
;
3809 tmp2
= tmp0
- tmp12
- tmp12
;
3813 tmp12
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3814 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
3816 /* Final output stage */
3818 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
3819 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
3820 wsptr
[6*1] = (int) RIGHT_SHIFT(tmp2
, CONST_BITS
-PASS1_BITS
);
3823 /* Pass 2: process 3 rows from work array, store into output array.
3824 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
3827 for (ctr
= 0; ctr
< 3; ctr
++) {
3828 outptr
= output_buf
[ctr
] + output_col
;
3832 /* Add fudge factor here for final descale. */
3833 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
3834 tmp0
<<= CONST_BITS
;
3835 tmp2
= (INT32
) wsptr
[4];
3836 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
3837 tmp1
= tmp0
+ tmp10
;
3838 tmp11
= tmp0
- tmp10
- tmp10
;
3839 tmp10
= (INT32
) wsptr
[2];
3840 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
3841 tmp10
= tmp1
+ tmp0
;
3842 tmp12
= tmp1
- tmp0
;
3846 z1
= (INT32
) wsptr
[1];
3847 z2
= (INT32
) wsptr
[3];
3848 z3
= (INT32
) wsptr
[5];
3849 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
3850 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
3851 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
3852 tmp1
= (z1
- z2
- z3
) << CONST_BITS
;
3854 /* Final output stage */
3856 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
3857 CONST_BITS
+PASS1_BITS
+3)
3859 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
3860 CONST_BITS
+PASS1_BITS
+3)
3862 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp1
,
3863 CONST_BITS
+PASS1_BITS
+3)
3865 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp1
,
3866 CONST_BITS
+PASS1_BITS
+3)
3868 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
3869 CONST_BITS
+PASS1_BITS
+3)
3871 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
3872 CONST_BITS
+PASS1_BITS
+3)
3875 wsptr
+= 6; /* advance pointer to next row */
3881 * Perform dequantization and inverse DCT on one block of coefficients,
3882 * producing a 4x2 output block.
3884 * 2-point IDCT in pass 1 (columns), 4-point in pass 2 (rows).
3888 jpeg_idct_4x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3889 JCOEFPTR coef_block
,
3890 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3892 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
3895 ISLOW_MULT_TYPE
* quantptr
;
3898 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3900 INT32 workspace
[4*2]; /* buffers data between passes */
3903 /* Pass 1: process columns from input, store into work array. */
3906 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3908 for (ctr
= 0; ctr
< 4; ctr
++, inptr
++, quantptr
++, wsptr
++) {
3911 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
3915 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
3917 /* Final output stage */
3919 wsptr
[4*0] = tmp10
+ tmp0
;
3920 wsptr
[4*1] = tmp10
- tmp0
;
3923 /* Pass 2: process 2 rows from work array, store into output array.
3924 * 4-point IDCT kernel,
3925 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
3928 for (ctr
= 0; ctr
< 2; ctr
++) {
3929 outptr
= output_buf
[ctr
] + output_col
;
3933 /* Add fudge factor here for final descale. */
3934 tmp0
= wsptr
[0] + (ONE
<< 2);
3937 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
3938 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
3941 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
3946 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
3947 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
3948 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
3950 /* Final output stage */
3952 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
3955 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
3958 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
3961 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
3965 wsptr
+= 4; /* advance pointer to next row */
3971 * Perform dequantization and inverse DCT on one block of coefficients,
3972 * producing a 2x1 output block.
3974 * 1-point IDCT in pass 1 (columns), 2-point in pass 2 (rows).
3978 jpeg_idct_2x1 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
3979 JCOEFPTR coef_block
,
3980 JSAMPARRAY output_buf
, JDIMENSION output_col
)
3983 ISLOW_MULT_TYPE
* quantptr
;
3985 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
3988 /* Pass 1: empty. */
3990 /* Pass 2: process 1 row from input, store into output array. */
3992 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
3993 outptr
= output_buf
[0] + output_col
;
3997 tmp10
= DEQUANTIZE(coef_block
[0], quantptr
[0]);
3998 /* Add fudge factor here for final descale. */
4003 tmp0
= DEQUANTIZE(coef_block
[1], quantptr
[1]);
4005 /* Final output stage */
4007 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
, 3) & RANGE_MASK
];
4008 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
, 3) & RANGE_MASK
];
4013 * Perform dequantization and inverse DCT on one block of coefficients,
4014 * producing a 8x16 output block.
4016 * 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
4020 jpeg_idct_8x16 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4021 JCOEFPTR coef_block
,
4022 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4024 INT32 tmp0
, tmp1
, tmp2
, tmp3
, tmp10
, tmp11
, tmp12
, tmp13
;
4025 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
, tmp27
;
4026 INT32 z1
, z2
, z3
, z4
;
4028 ISLOW_MULT_TYPE
* quantptr
;
4031 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4033 int workspace
[8*16]; /* buffers data between passes */
4036 /* Pass 1: process columns from input, store into work array.
4037 * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
4040 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4042 for (ctr
= 0; ctr
< 8; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4045 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4046 tmp0
<<= CONST_BITS
;
4047 /* Add fudge factor here for final descale. */
4048 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4050 z1
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4051 tmp1
= MULTIPLY(z1
, FIX(1.306562965)); /* c4[16] = c2[8] */
4052 tmp2
= MULTIPLY(z1
, FIX_0_541196100
); /* c12[16] = c6[8] */
4054 tmp10
= tmp0
+ tmp1
;
4055 tmp11
= tmp0
- tmp1
;
4056 tmp12
= tmp0
+ tmp2
;
4057 tmp13
= tmp0
- tmp2
;
4059 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4060 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4062 z4
= MULTIPLY(z3
, FIX(0.275899379)); /* c14[16] = c7[8] */
4063 z3
= MULTIPLY(z3
, FIX(1.387039845)); /* c2[16] = c1[8] */
4065 tmp0
= z3
+ MULTIPLY(z2
, FIX_2_562915447
); /* (c6+c2)[16] = (c3+c1)[8] */
4066 tmp1
= z4
+ MULTIPLY(z1
, FIX_0_899976223
); /* (c6-c14)[16] = (c3-c7)[8] */
4067 tmp2
= z3
- MULTIPLY(z1
, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */
4068 tmp3
= z4
- MULTIPLY(z2
, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */
4070 tmp20
= tmp10
+ tmp0
;
4071 tmp27
= tmp10
- tmp0
;
4072 tmp21
= tmp12
+ tmp1
;
4073 tmp26
= tmp12
- tmp1
;
4074 tmp22
= tmp13
+ tmp2
;
4075 tmp25
= tmp13
- tmp2
;
4076 tmp23
= tmp11
+ tmp3
;
4077 tmp24
= tmp11
- tmp3
;
4081 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4082 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4083 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4084 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4088 tmp1
= MULTIPLY(z1
+ z2
, FIX(1.353318001)); /* c3 */
4089 tmp2
= MULTIPLY(tmp11
, FIX(1.247225013)); /* c5 */
4090 tmp3
= MULTIPLY(z1
+ z4
, FIX(1.093201867)); /* c7 */
4091 tmp10
= MULTIPLY(z1
- z4
, FIX(0.897167586)); /* c9 */
4092 tmp11
= MULTIPLY(tmp11
, FIX(0.666655658)); /* c11 */
4093 tmp12
= MULTIPLY(z1
- z2
, FIX(0.410524528)); /* c13 */
4094 tmp0
= tmp1
+ tmp2
+ tmp3
-
4095 MULTIPLY(z1
, FIX(2.286341144)); /* c7+c5+c3-c1 */
4096 tmp13
= tmp10
+ tmp11
+ tmp12
-
4097 MULTIPLY(z1
, FIX(1.835730603)); /* c9+c11+c13-c15 */
4098 z1
= MULTIPLY(z2
+ z3
, FIX(0.138617169)); /* c15 */
4099 tmp1
+= z1
+ MULTIPLY(z2
, FIX(0.071888074)); /* c9+c11-c3-c15 */
4100 tmp2
+= z1
- MULTIPLY(z3
, FIX(1.125726048)); /* c5+c7+c15-c3 */
4101 z1
= MULTIPLY(z3
- z2
, FIX(1.407403738)); /* c1 */
4102 tmp11
+= z1
- MULTIPLY(z3
, FIX(0.766367282)); /* c1+c11-c9-c13 */
4103 tmp12
+= z1
+ MULTIPLY(z2
, FIX(1.971951411)); /* c1+c5+c13-c7 */
4105 z1
= MULTIPLY(z2
, - FIX(0.666655658)); /* -c11 */
4107 tmp3
+= z1
+ MULTIPLY(z4
, FIX(1.065388962)); /* c3+c11+c15-c7 */
4108 z2
= MULTIPLY(z2
, - FIX(1.247225013)); /* -c5 */
4109 tmp10
+= z2
+ MULTIPLY(z4
, FIX(3.141271809)); /* c1+c5+c9-c13 */
4111 z2
= MULTIPLY(z3
+ z4
, - FIX(1.353318001)); /* -c3 */
4114 z2
= MULTIPLY(z4
- z3
, FIX(0.410524528)); /* c13 */
4118 /* Final output stage */
4120 wsptr
[8*0] = (int) RIGHT_SHIFT(tmp20
+ tmp0
, CONST_BITS
-PASS1_BITS
);
4121 wsptr
[8*15] = (int) RIGHT_SHIFT(tmp20
- tmp0
, CONST_BITS
-PASS1_BITS
);
4122 wsptr
[8*1] = (int) RIGHT_SHIFT(tmp21
+ tmp1
, CONST_BITS
-PASS1_BITS
);
4123 wsptr
[8*14] = (int) RIGHT_SHIFT(tmp21
- tmp1
, CONST_BITS
-PASS1_BITS
);
4124 wsptr
[8*2] = (int) RIGHT_SHIFT(tmp22
+ tmp2
, CONST_BITS
-PASS1_BITS
);
4125 wsptr
[8*13] = (int) RIGHT_SHIFT(tmp22
- tmp2
, CONST_BITS
-PASS1_BITS
);
4126 wsptr
[8*3] = (int) RIGHT_SHIFT(tmp23
+ tmp3
, CONST_BITS
-PASS1_BITS
);
4127 wsptr
[8*12] = (int) RIGHT_SHIFT(tmp23
- tmp3
, CONST_BITS
-PASS1_BITS
);
4128 wsptr
[8*4] = (int) RIGHT_SHIFT(tmp24
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4129 wsptr
[8*11] = (int) RIGHT_SHIFT(tmp24
- tmp10
, CONST_BITS
-PASS1_BITS
);
4130 wsptr
[8*5] = (int) RIGHT_SHIFT(tmp25
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4131 wsptr
[8*10] = (int) RIGHT_SHIFT(tmp25
- tmp11
, CONST_BITS
-PASS1_BITS
);
4132 wsptr
[8*6] = (int) RIGHT_SHIFT(tmp26
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4133 wsptr
[8*9] = (int) RIGHT_SHIFT(tmp26
- tmp12
, CONST_BITS
-PASS1_BITS
);
4134 wsptr
[8*7] = (int) RIGHT_SHIFT(tmp27
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4135 wsptr
[8*8] = (int) RIGHT_SHIFT(tmp27
- tmp13
, CONST_BITS
-PASS1_BITS
);
4138 /* Pass 2: process rows from work array, store into output array. */
4139 /* Note that we must descale the results by a factor of 8 == 2**3, */
4140 /* and also undo the PASS1_BITS scaling. */
4143 for (ctr
= 0; ctr
< 16; ctr
++) {
4144 outptr
= output_buf
[ctr
] + output_col
;
4146 /* Even part: reverse the even part of the forward DCT. */
4147 /* The rotator is sqrt(2)*c(-6). */
4149 z2
= (INT32
) wsptr
[2];
4150 z3
= (INT32
) wsptr
[6];
4152 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
4153 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
4154 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
4156 /* Add fudge factor here for final descale. */
4157 z2
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4158 z3
= (INT32
) wsptr
[4];
4160 tmp0
= (z2
+ z3
) << CONST_BITS
;
4161 tmp1
= (z2
- z3
) << CONST_BITS
;
4163 tmp10
= tmp0
+ tmp2
;
4164 tmp13
= tmp0
- tmp2
;
4165 tmp11
= tmp1
+ tmp3
;
4166 tmp12
= tmp1
- tmp3
;
4168 /* Odd part per figure 8; the matrix is unitary and hence its
4169 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
4172 tmp0
= (INT32
) wsptr
[7];
4173 tmp1
= (INT32
) wsptr
[5];
4174 tmp2
= (INT32
) wsptr
[3];
4175 tmp3
= (INT32
) wsptr
[1];
4180 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
4181 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
4182 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
4186 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
4187 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
4188 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
4192 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
4193 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
4194 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
4198 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
4200 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp3
,
4201 CONST_BITS
+PASS1_BITS
+3)
4203 outptr
[7] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp3
,
4204 CONST_BITS
+PASS1_BITS
+3)
4206 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp2
,
4207 CONST_BITS
+PASS1_BITS
+3)
4209 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp2
,
4210 CONST_BITS
+PASS1_BITS
+3)
4212 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp1
,
4213 CONST_BITS
+PASS1_BITS
+3)
4215 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp1
,
4216 CONST_BITS
+PASS1_BITS
+3)
4218 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp13
+ tmp0
,
4219 CONST_BITS
+PASS1_BITS
+3)
4221 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp13
- tmp0
,
4222 CONST_BITS
+PASS1_BITS
+3)
4225 wsptr
+= DCTSIZE
; /* advance pointer to next row */
4231 * Perform dequantization and inverse DCT on one block of coefficients,
4232 * producing a 7x14 output block.
4234 * 14-point IDCT in pass 1 (columns), 7-point in pass 2 (rows).
4238 jpeg_idct_7x14 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4239 JCOEFPTR coef_block
,
4240 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4242 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
, tmp16
;
4243 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
, tmp26
;
4244 INT32 z1
, z2
, z3
, z4
;
4246 ISLOW_MULT_TYPE
* quantptr
;
4249 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4251 int workspace
[7*14]; /* buffers data between passes */
4254 /* Pass 1: process columns from input, store into work array.
4255 * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28).
4258 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4260 for (ctr
= 0; ctr
< 7; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4263 z1
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4265 /* Add fudge factor here for final descale. */
4266 z1
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4267 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4268 z2
= MULTIPLY(z4
, FIX(1.274162392)); /* c4 */
4269 z3
= MULTIPLY(z4
, FIX(0.314692123)); /* c12 */
4270 z4
= MULTIPLY(z4
, FIX(0.881747734)); /* c8 */
4276 tmp23
= RIGHT_SHIFT(z1
- ((z2
+ z3
- z4
) << 1), /* c0 = (c4+c12-c8)*2 */
4277 CONST_BITS
-PASS1_BITS
);
4279 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4280 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4282 z3
= MULTIPLY(z1
+ z2
, FIX(1.105676686)); /* c6 */
4284 tmp13
= z3
+ MULTIPLY(z1
, FIX(0.273079590)); /* c2-c6 */
4285 tmp14
= z3
- MULTIPLY(z2
, FIX(1.719280954)); /* c6+c10 */
4286 tmp15
= MULTIPLY(z1
, FIX(0.613604268)) - /* c10 */
4287 MULTIPLY(z2
, FIX(1.378756276)); /* c2 */
4289 tmp20
= tmp10
+ tmp13
;
4290 tmp26
= tmp10
- tmp13
;
4291 tmp21
= tmp11
+ tmp14
;
4292 tmp25
= tmp11
- tmp14
;
4293 tmp22
= tmp12
+ tmp15
;
4294 tmp24
= tmp12
- tmp15
;
4298 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4299 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4300 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4301 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4302 tmp13
= z4
<< CONST_BITS
;
4305 tmp11
= MULTIPLY(z1
+ z2
, FIX(1.334852607)); /* c3 */
4306 tmp12
= MULTIPLY(tmp14
, FIX(1.197448846)); /* c5 */
4307 tmp10
= tmp11
+ tmp12
+ tmp13
- MULTIPLY(z1
, FIX(1.126980169)); /* c3+c5-c1 */
4308 tmp14
= MULTIPLY(tmp14
, FIX(0.752406978)); /* c9 */
4309 tmp16
= tmp14
- MULTIPLY(z1
, FIX(1.061150426)); /* c9+c11-c13 */
4311 tmp15
= MULTIPLY(z1
, FIX(0.467085129)) - tmp13
; /* c11 */
4314 z4
= MULTIPLY(z2
+ z3
, - FIX(0.158341681)) - tmp13
; /* -c13 */
4315 tmp11
+= z4
- MULTIPLY(z2
, FIX(0.424103948)); /* c3-c9-c13 */
4316 tmp12
+= z4
- MULTIPLY(z3
, FIX(2.373959773)); /* c3+c5-c13 */
4317 z4
= MULTIPLY(z3
- z2
, FIX(1.405321284)); /* c1 */
4318 tmp14
+= z4
+ tmp13
- MULTIPLY(z3
, FIX(1.6906431334)); /* c1+c9-c11 */
4319 tmp15
+= z4
+ MULTIPLY(z2
, FIX(0.674957567)); /* c1+c11-c5 */
4321 tmp13
= (z1
- z3
) << PASS1_BITS
;
4323 /* Final output stage */
4325 wsptr
[7*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4326 wsptr
[7*13] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4327 wsptr
[7*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4328 wsptr
[7*12] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4329 wsptr
[7*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4330 wsptr
[7*11] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
4331 wsptr
[7*3] = (int) (tmp23
+ tmp13
);
4332 wsptr
[7*10] = (int) (tmp23
- tmp13
);
4333 wsptr
[7*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4334 wsptr
[7*9] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4335 wsptr
[7*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
4336 wsptr
[7*8] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
4337 wsptr
[7*6] = (int) RIGHT_SHIFT(tmp26
+ tmp16
, CONST_BITS
-PASS1_BITS
);
4338 wsptr
[7*7] = (int) RIGHT_SHIFT(tmp26
- tmp16
, CONST_BITS
-PASS1_BITS
);
4341 /* Pass 2: process 14 rows from work array, store into output array.
4342 * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14).
4345 for (ctr
= 0; ctr
< 14; ctr
++) {
4346 outptr
= output_buf
[ctr
] + output_col
;
4350 /* Add fudge factor here for final descale. */
4351 tmp23
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4352 tmp23
<<= CONST_BITS
;
4354 z1
= (INT32
) wsptr
[2];
4355 z2
= (INT32
) wsptr
[4];
4356 z3
= (INT32
) wsptr
[6];
4358 tmp20
= MULTIPLY(z2
- z3
, FIX(0.881747734)); /* c4 */
4359 tmp22
= MULTIPLY(z1
- z2
, FIX(0.314692123)); /* c6 */
4360 tmp21
= tmp20
+ tmp22
+ tmp23
- MULTIPLY(z2
, FIX(1.841218003)); /* c2+c4-c6 */
4363 tmp10
= MULTIPLY(tmp10
, FIX(1.274162392)) + tmp23
; /* c2 */
4364 tmp20
+= tmp10
- MULTIPLY(z3
, FIX(0.077722536)); /* c2-c4-c6 */
4365 tmp22
+= tmp10
- MULTIPLY(z1
, FIX(2.470602249)); /* c2+c4+c6 */
4366 tmp23
+= MULTIPLY(z2
, FIX(1.414213562)); /* c0 */
4370 z1
= (INT32
) wsptr
[1];
4371 z2
= (INT32
) wsptr
[3];
4372 z3
= (INT32
) wsptr
[5];
4374 tmp11
= MULTIPLY(z1
+ z2
, FIX(0.935414347)); /* (c3+c1-c5)/2 */
4375 tmp12
= MULTIPLY(z1
- z2
, FIX(0.170262339)); /* (c3+c5-c1)/2 */
4376 tmp10
= tmp11
- tmp12
;
4378 tmp12
= MULTIPLY(z2
+ z3
, - FIX(1.378756276)); /* -c1 */
4380 z2
= MULTIPLY(z1
+ z3
, FIX(0.613604268)); /* c5 */
4382 tmp12
+= z2
+ MULTIPLY(z3
, FIX(1.870828693)); /* c3+c1-c5 */
4384 /* Final output stage */
4386 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
4387 CONST_BITS
+PASS1_BITS
+3)
4389 outptr
[6] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
4390 CONST_BITS
+PASS1_BITS
+3)
4392 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
4393 CONST_BITS
+PASS1_BITS
+3)
4395 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
4396 CONST_BITS
+PASS1_BITS
+3)
4398 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
4399 CONST_BITS
+PASS1_BITS
+3)
4401 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
4402 CONST_BITS
+PASS1_BITS
+3)
4404 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp23
,
4405 CONST_BITS
+PASS1_BITS
+3)
4408 wsptr
+= 7; /* advance pointer to next row */
4414 * Perform dequantization and inverse DCT on one block of coefficients,
4415 * producing a 6x12 output block.
4417 * 12-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
4421 jpeg_idct_6x12 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4422 JCOEFPTR coef_block
,
4423 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4425 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
, tmp15
;
4426 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
, tmp25
;
4427 INT32 z1
, z2
, z3
, z4
;
4429 ISLOW_MULT_TYPE
* quantptr
;
4432 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4434 int workspace
[6*12]; /* buffers data between passes */
4437 /* Pass 1: process columns from input, store into work array.
4438 * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24).
4441 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4443 for (ctr
= 0; ctr
< 6; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4446 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4448 /* Add fudge factor here for final descale. */
4449 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4451 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4452 z4
= MULTIPLY(z4
, FIX(1.224744871)); /* c4 */
4457 z1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4458 z4
= MULTIPLY(z1
, FIX(1.366025404)); /* c2 */
4460 z2
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4470 tmp20
= tmp10
+ tmp12
;
4471 tmp25
= tmp10
- tmp12
;
4473 tmp12
= z4
- z1
- z2
;
4475 tmp22
= tmp11
+ tmp12
;
4476 tmp23
= tmp11
- tmp12
;
4480 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4481 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4482 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4483 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4485 tmp11
= MULTIPLY(z2
, FIX(1.306562965)); /* c3 */
4486 tmp14
= MULTIPLY(z2
, - FIX_0_541196100
); /* -c9 */
4489 tmp15
= MULTIPLY(tmp10
+ z4
, FIX(0.860918669)); /* c7 */
4490 tmp12
= tmp15
+ MULTIPLY(tmp10
, FIX(0.261052384)); /* c5-c7 */
4491 tmp10
= tmp12
+ tmp11
+ MULTIPLY(z1
, FIX(0.280143716)); /* c1-c5 */
4492 tmp13
= MULTIPLY(z3
+ z4
, - FIX(1.045510580)); /* -(c7+c11) */
4493 tmp12
+= tmp13
+ tmp14
- MULTIPLY(z3
, FIX(1.478575242)); /* c1+c5-c7-c11 */
4494 tmp13
+= tmp15
- tmp11
+ MULTIPLY(z4
, FIX(1.586706681)); /* c1+c11 */
4495 tmp15
+= tmp14
- MULTIPLY(z1
, FIX(0.676326758)) - /* c7-c11 */
4496 MULTIPLY(z4
, FIX(1.982889723)); /* c5+c7 */
4500 z3
= MULTIPLY(z1
+ z2
, FIX_0_541196100
); /* c9 */
4501 tmp11
= z3
+ MULTIPLY(z1
, FIX_0_765366865
); /* c3-c9 */
4502 tmp14
= z3
- MULTIPLY(z2
, FIX_1_847759065
); /* c3+c9 */
4504 /* Final output stage */
4506 wsptr
[6*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4507 wsptr
[6*11] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4508 wsptr
[6*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4509 wsptr
[6*10] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4510 wsptr
[6*2] = (int) RIGHT_SHIFT(tmp22
+ tmp12
, CONST_BITS
-PASS1_BITS
);
4511 wsptr
[6*9] = (int) RIGHT_SHIFT(tmp22
- tmp12
, CONST_BITS
-PASS1_BITS
);
4512 wsptr
[6*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4513 wsptr
[6*8] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
4514 wsptr
[6*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4515 wsptr
[6*7] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4516 wsptr
[6*5] = (int) RIGHT_SHIFT(tmp25
+ tmp15
, CONST_BITS
-PASS1_BITS
);
4517 wsptr
[6*6] = (int) RIGHT_SHIFT(tmp25
- tmp15
, CONST_BITS
-PASS1_BITS
);
4520 /* Pass 2: process 12 rows from work array, store into output array.
4521 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
4524 for (ctr
= 0; ctr
< 12; ctr
++) {
4525 outptr
= output_buf
[ctr
] + output_col
;
4529 /* Add fudge factor here for final descale. */
4530 tmp10
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4531 tmp10
<<= CONST_BITS
;
4532 tmp12
= (INT32
) wsptr
[4];
4533 tmp20
= MULTIPLY(tmp12
, FIX(0.707106781)); /* c4 */
4534 tmp11
= tmp10
+ tmp20
;
4535 tmp21
= tmp10
- tmp20
- tmp20
;
4536 tmp20
= (INT32
) wsptr
[2];
4537 tmp10
= MULTIPLY(tmp20
, FIX(1.224744871)); /* c2 */
4538 tmp20
= tmp11
+ tmp10
;
4539 tmp22
= tmp11
- tmp10
;
4543 z1
= (INT32
) wsptr
[1];
4544 z2
= (INT32
) wsptr
[3];
4545 z3
= (INT32
) wsptr
[5];
4546 tmp11
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
4547 tmp10
= tmp11
+ ((z1
+ z2
) << CONST_BITS
);
4548 tmp12
= tmp11
+ ((z3
- z2
) << CONST_BITS
);
4549 tmp11
= (z1
- z2
- z3
) << CONST_BITS
;
4551 /* Final output stage */
4553 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp20
+ tmp10
,
4554 CONST_BITS
+PASS1_BITS
+3)
4556 outptr
[5] = range_limit
[(int) RIGHT_SHIFT(tmp20
- tmp10
,
4557 CONST_BITS
+PASS1_BITS
+3)
4559 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp21
+ tmp11
,
4560 CONST_BITS
+PASS1_BITS
+3)
4562 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp21
- tmp11
,
4563 CONST_BITS
+PASS1_BITS
+3)
4565 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp22
+ tmp12
,
4566 CONST_BITS
+PASS1_BITS
+3)
4568 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp22
- tmp12
,
4569 CONST_BITS
+PASS1_BITS
+3)
4572 wsptr
+= 6; /* advance pointer to next row */
4578 * Perform dequantization and inverse DCT on one block of coefficients,
4579 * producing a 5x10 output block.
4581 * 10-point IDCT in pass 1 (columns), 5-point in pass 2 (rows).
4585 jpeg_idct_5x10 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4586 JCOEFPTR coef_block
,
4587 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4589 INT32 tmp10
, tmp11
, tmp12
, tmp13
, tmp14
;
4590 INT32 tmp20
, tmp21
, tmp22
, tmp23
, tmp24
;
4591 INT32 z1
, z2
, z3
, z4
, z5
;
4593 ISLOW_MULT_TYPE
* quantptr
;
4596 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4598 int workspace
[5*10]; /* buffers data between passes */
4601 /* Pass 1: process columns from input, store into work array.
4602 * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20).
4605 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4607 for (ctr
= 0; ctr
< 5; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4610 z3
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4612 /* Add fudge factor here for final descale. */
4613 z3
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4614 z4
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4615 z1
= MULTIPLY(z4
, FIX(1.144122806)); /* c4 */
4616 z2
= MULTIPLY(z4
, FIX(0.437016024)); /* c8 */
4620 tmp22
= RIGHT_SHIFT(z3
- ((z1
- z2
) << 1), /* c0 = (c4-c8)*2 */
4621 CONST_BITS
-PASS1_BITS
);
4623 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4624 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4626 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c6 */
4627 tmp12
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c2-c6 */
4628 tmp13
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c2+c6 */
4630 tmp20
= tmp10
+ tmp12
;
4631 tmp24
= tmp10
- tmp12
;
4632 tmp21
= tmp11
+ tmp13
;
4633 tmp23
= tmp11
- tmp13
;
4637 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4638 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4639 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4640 z4
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4645 tmp12
= MULTIPLY(tmp13
, FIX(0.309016994)); /* (c3-c7)/2 */
4646 z5
= z3
<< CONST_BITS
;
4648 z2
= MULTIPLY(tmp11
, FIX(0.951056516)); /* (c3+c7)/2 */
4651 tmp10
= MULTIPLY(z1
, FIX(1.396802247)) + z2
+ z4
; /* c1 */
4652 tmp14
= MULTIPLY(z1
, FIX(0.221231742)) - z2
+ z4
; /* c9 */
4654 z2
= MULTIPLY(tmp11
, FIX(0.587785252)); /* (c1-c9)/2 */
4655 z4
= z5
- tmp12
- (tmp13
<< (CONST_BITS
- 1));
4657 tmp12
= (z1
- tmp13
- z3
) << PASS1_BITS
;
4659 tmp11
= MULTIPLY(z1
, FIX(1.260073511)) - z2
- z4
; /* c3 */
4660 tmp13
= MULTIPLY(z1
, FIX(0.642039522)) - z2
+ z4
; /* c7 */
4662 /* Final output stage */
4664 wsptr
[5*0] = (int) RIGHT_SHIFT(tmp20
+ tmp10
, CONST_BITS
-PASS1_BITS
);
4665 wsptr
[5*9] = (int) RIGHT_SHIFT(tmp20
- tmp10
, CONST_BITS
-PASS1_BITS
);
4666 wsptr
[5*1] = (int) RIGHT_SHIFT(tmp21
+ tmp11
, CONST_BITS
-PASS1_BITS
);
4667 wsptr
[5*8] = (int) RIGHT_SHIFT(tmp21
- tmp11
, CONST_BITS
-PASS1_BITS
);
4668 wsptr
[5*2] = (int) (tmp22
+ tmp12
);
4669 wsptr
[5*7] = (int) (tmp22
- tmp12
);
4670 wsptr
[5*3] = (int) RIGHT_SHIFT(tmp23
+ tmp13
, CONST_BITS
-PASS1_BITS
);
4671 wsptr
[5*6] = (int) RIGHT_SHIFT(tmp23
- tmp13
, CONST_BITS
-PASS1_BITS
);
4672 wsptr
[5*4] = (int) RIGHT_SHIFT(tmp24
+ tmp14
, CONST_BITS
-PASS1_BITS
);
4673 wsptr
[5*5] = (int) RIGHT_SHIFT(tmp24
- tmp14
, CONST_BITS
-PASS1_BITS
);
4676 /* Pass 2: process 10 rows from work array, store into output array.
4677 * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10).
4680 for (ctr
= 0; ctr
< 10; ctr
++) {
4681 outptr
= output_buf
[ctr
] + output_col
;
4685 /* Add fudge factor here for final descale. */
4686 tmp12
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4687 tmp12
<<= CONST_BITS
;
4688 tmp13
= (INT32
) wsptr
[2];
4689 tmp14
= (INT32
) wsptr
[4];
4690 z1
= MULTIPLY(tmp13
+ tmp14
, FIX(0.790569415)); /* (c2+c4)/2 */
4691 z2
= MULTIPLY(tmp13
- tmp14
, FIX(0.353553391)); /* (c2-c4)/2 */
4699 z2
= (INT32
) wsptr
[1];
4700 z3
= (INT32
) wsptr
[3];
4702 z1
= MULTIPLY(z2
+ z3
, FIX(0.831253876)); /* c3 */
4703 tmp13
= z1
+ MULTIPLY(z2
, FIX(0.513743148)); /* c1-c3 */
4704 tmp14
= z1
- MULTIPLY(z3
, FIX(2.176250899)); /* c1+c3 */
4706 /* Final output stage */
4708 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp13
,
4709 CONST_BITS
+PASS1_BITS
+3)
4711 outptr
[4] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp13
,
4712 CONST_BITS
+PASS1_BITS
+3)
4714 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp11
+ tmp14
,
4715 CONST_BITS
+PASS1_BITS
+3)
4717 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp11
- tmp14
,
4718 CONST_BITS
+PASS1_BITS
+3)
4720 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
,
4721 CONST_BITS
+PASS1_BITS
+3)
4724 wsptr
+= 5; /* advance pointer to next row */
4730 * Perform dequantization and inverse DCT on one block of coefficients,
4731 * producing a 4x8 output block.
4733 * 8-point IDCT in pass 1 (columns), 4-point in pass 2 (rows).
4737 jpeg_idct_4x8 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4738 JCOEFPTR coef_block
,
4739 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4741 INT32 tmp0
, tmp1
, tmp2
, tmp3
;
4742 INT32 tmp10
, tmp11
, tmp12
, tmp13
;
4745 ISLOW_MULT_TYPE
* quantptr
;
4748 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4750 int workspace
[4*8]; /* buffers data between passes */
4753 /* Pass 1: process columns from input, store into work array. */
4754 /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
4755 /* furthermore, we scale the results by 2**PASS1_BITS. */
4758 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4760 for (ctr
= 4; ctr
> 0; ctr
--) {
4761 /* Due to quantization, we will usually find that many of the input
4762 * coefficients are zero, especially the AC terms. We can exploit this
4763 * by short-circuiting the IDCT calculation for any column in which all
4764 * the AC terms are zero. In that case each output is equal to the
4765 * DC coefficient (with scale factor as needed).
4766 * With typical images and quantization tables, half or more of the
4767 * column DCT calculations can be simplified this way.
4770 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
4771 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
4772 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
4773 inptr
[DCTSIZE
*7] == 0) {
4774 /* AC terms all zero */
4775 int dcval
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]) << PASS1_BITS
;
4786 inptr
++; /* advance pointers to next column */
4792 /* Even part: reverse the even part of the forward DCT. */
4793 /* The rotator is sqrt(2)*c(-6). */
4795 z2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4796 z3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
4798 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
);
4799 tmp2
= z1
+ MULTIPLY(z2
, FIX_0_765366865
);
4800 tmp3
= z1
- MULTIPLY(z3
, FIX_1_847759065
);
4802 z2
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4803 z3
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4806 /* Add fudge factor here for final descale. */
4807 z2
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4812 tmp10
= tmp0
+ tmp2
;
4813 tmp13
= tmp0
- tmp2
;
4814 tmp11
= tmp1
+ tmp3
;
4815 tmp12
= tmp1
- tmp3
;
4817 /* Odd part per figure 8; the matrix is unitary and hence its
4818 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
4821 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
4822 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4823 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4824 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4829 z1
= MULTIPLY(z2
+ z3
, FIX_1_175875602
); /* sqrt(2) * c3 */
4830 z2
= MULTIPLY(z2
, - FIX_1_961570560
); /* sqrt(2) * (-c3-c5) */
4831 z3
= MULTIPLY(z3
, - FIX_0_390180644
); /* sqrt(2) * (c5-c3) */
4835 z1
= MULTIPLY(tmp0
+ tmp3
, - FIX_0_899976223
); /* sqrt(2) * (c7-c3) */
4836 tmp0
= MULTIPLY(tmp0
, FIX_0_298631336
); /* sqrt(2) * (-c1+c3+c5-c7) */
4837 tmp3
= MULTIPLY(tmp3
, FIX_1_501321110
); /* sqrt(2) * ( c1+c3-c5-c7) */
4841 z1
= MULTIPLY(tmp1
+ tmp2
, - FIX_2_562915447
); /* sqrt(2) * (-c1-c3) */
4842 tmp1
= MULTIPLY(tmp1
, FIX_2_053119869
); /* sqrt(2) * ( c1+c3-c5+c7) */
4843 tmp2
= MULTIPLY(tmp2
, FIX_3_072711026
); /* sqrt(2) * ( c1+c3+c5-c7) */
4847 /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
4849 wsptr
[4*0] = (int) RIGHT_SHIFT(tmp10
+ tmp3
, CONST_BITS
-PASS1_BITS
);
4850 wsptr
[4*7] = (int) RIGHT_SHIFT(tmp10
- tmp3
, CONST_BITS
-PASS1_BITS
);
4851 wsptr
[4*1] = (int) RIGHT_SHIFT(tmp11
+ tmp2
, CONST_BITS
-PASS1_BITS
);
4852 wsptr
[4*6] = (int) RIGHT_SHIFT(tmp11
- tmp2
, CONST_BITS
-PASS1_BITS
);
4853 wsptr
[4*2] = (int) RIGHT_SHIFT(tmp12
+ tmp1
, CONST_BITS
-PASS1_BITS
);
4854 wsptr
[4*5] = (int) RIGHT_SHIFT(tmp12
- tmp1
, CONST_BITS
-PASS1_BITS
);
4855 wsptr
[4*3] = (int) RIGHT_SHIFT(tmp13
+ tmp0
, CONST_BITS
-PASS1_BITS
);
4856 wsptr
[4*4] = (int) RIGHT_SHIFT(tmp13
- tmp0
, CONST_BITS
-PASS1_BITS
);
4858 inptr
++; /* advance pointers to next column */
4863 /* Pass 2: process 8 rows from work array, store into output array.
4864 * 4-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
4867 for (ctr
= 0; ctr
< 8; ctr
++) {
4868 outptr
= output_buf
[ctr
] + output_col
;
4872 /* Add fudge factor here for final descale. */
4873 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4874 tmp2
= (INT32
) wsptr
[2];
4876 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
4877 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
4880 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
4882 z2
= (INT32
) wsptr
[1];
4883 z3
= (INT32
) wsptr
[3];
4885 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
4886 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
4887 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
4889 /* Final output stage */
4891 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
4892 CONST_BITS
+PASS1_BITS
+3)
4894 outptr
[3] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
4895 CONST_BITS
+PASS1_BITS
+3)
4897 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp12
+ tmp2
,
4898 CONST_BITS
+PASS1_BITS
+3)
4900 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp12
- tmp2
,
4901 CONST_BITS
+PASS1_BITS
+3)
4904 wsptr
+= 4; /* advance pointer to next row */
4910 * Perform dequantization and inverse DCT on one block of coefficients,
4911 * producing a reduced-size 3x6 output block.
4913 * 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows).
4917 jpeg_idct_3x6 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
4918 JCOEFPTR coef_block
,
4919 JSAMPARRAY output_buf
, JDIMENSION output_col
)
4921 INT32 tmp0
, tmp1
, tmp2
, tmp10
, tmp11
, tmp12
;
4924 ISLOW_MULT_TYPE
* quantptr
;
4927 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
4929 int workspace
[3*6]; /* buffers data between passes */
4932 /* Pass 1: process columns from input, store into work array.
4933 * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
4936 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
4938 for (ctr
= 0; ctr
< 3; ctr
++, inptr
++, quantptr
++, wsptr
++) {
4941 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
4942 tmp0
<<= CONST_BITS
;
4943 /* Add fudge factor here for final descale. */
4944 tmp0
+= ONE
<< (CONST_BITS
-PASS1_BITS
-1);
4945 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
4946 tmp10
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c4 */
4947 tmp1
= tmp0
+ tmp10
;
4948 tmp11
= RIGHT_SHIFT(tmp0
- tmp10
- tmp10
, CONST_BITS
-PASS1_BITS
);
4949 tmp10
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
4950 tmp0
= MULTIPLY(tmp10
, FIX(1.224744871)); /* c2 */
4951 tmp10
= tmp1
+ tmp0
;
4952 tmp12
= tmp1
- tmp0
;
4956 z1
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
4957 z2
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
4958 z3
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
4959 tmp1
= MULTIPLY(z1
+ z3
, FIX(0.366025404)); /* c5 */
4960 tmp0
= tmp1
+ ((z1
+ z2
) << CONST_BITS
);
4961 tmp2
= tmp1
+ ((z3
- z2
) << CONST_BITS
);
4962 tmp1
= (z1
- z2
- z3
) << PASS1_BITS
;
4964 /* Final output stage */
4966 wsptr
[3*0] = (int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
-PASS1_BITS
);
4967 wsptr
[3*5] = (int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
-PASS1_BITS
);
4968 wsptr
[3*1] = (int) (tmp11
+ tmp1
);
4969 wsptr
[3*4] = (int) (tmp11
- tmp1
);
4970 wsptr
[3*2] = (int) RIGHT_SHIFT(tmp12
+ tmp2
, CONST_BITS
-PASS1_BITS
);
4971 wsptr
[3*3] = (int) RIGHT_SHIFT(tmp12
- tmp2
, CONST_BITS
-PASS1_BITS
);
4974 /* Pass 2: process 6 rows from work array, store into output array.
4975 * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6).
4978 for (ctr
= 0; ctr
< 6; ctr
++) {
4979 outptr
= output_buf
[ctr
] + output_col
;
4983 /* Add fudge factor here for final descale. */
4984 tmp0
= (INT32
) wsptr
[0] + (ONE
<< (PASS1_BITS
+2));
4985 tmp0
<<= CONST_BITS
;
4986 tmp2
= (INT32
) wsptr
[2];
4987 tmp12
= MULTIPLY(tmp2
, FIX(0.707106781)); /* c2 */
4988 tmp10
= tmp0
+ tmp12
;
4989 tmp2
= tmp0
- tmp12
- tmp12
;
4993 tmp12
= (INT32
) wsptr
[1];
4994 tmp0
= MULTIPLY(tmp12
, FIX(1.224744871)); /* c1 */
4996 /* Final output stage */
4998 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
,
4999 CONST_BITS
+PASS1_BITS
+3)
5001 outptr
[2] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
,
5002 CONST_BITS
+PASS1_BITS
+3)
5004 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp2
,
5005 CONST_BITS
+PASS1_BITS
+3)
5008 wsptr
+= 3; /* advance pointer to next row */
5014 * Perform dequantization and inverse DCT on one block of coefficients,
5015 * producing a 2x4 output block.
5017 * 4-point IDCT in pass 1 (columns), 2-point in pass 2 (rows).
5021 jpeg_idct_2x4 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
5022 JCOEFPTR coef_block
,
5023 JSAMPARRAY output_buf
, JDIMENSION output_col
)
5025 INT32 tmp0
, tmp2
, tmp10
, tmp12
;
5028 ISLOW_MULT_TYPE
* quantptr
;
5031 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
5033 INT32 workspace
[2*4]; /* buffers data between passes */
5036 /* Pass 1: process columns from input, store into work array.
5037 * 4-point IDCT kernel,
5038 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT].
5041 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
5043 for (ctr
= 0; ctr
< 2; ctr
++, inptr
++, quantptr
++, wsptr
++) {
5046 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
5047 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
5049 tmp10
= (tmp0
+ tmp2
) << CONST_BITS
;
5050 tmp12
= (tmp0
- tmp2
) << CONST_BITS
;
5053 /* Same rotation as in the even part of the 8x8 LL&M IDCT */
5055 z2
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
5056 z3
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
5058 z1
= MULTIPLY(z2
+ z3
, FIX_0_541196100
); /* c6 */
5059 tmp0
= z1
+ MULTIPLY(z2
, FIX_0_765366865
); /* c2-c6 */
5060 tmp2
= z1
- MULTIPLY(z3
, FIX_1_847759065
); /* c2+c6 */
5062 /* Final output stage */
5064 wsptr
[2*0] = tmp10
+ tmp0
;
5065 wsptr
[2*3] = tmp10
- tmp0
;
5066 wsptr
[2*1] = tmp12
+ tmp2
;
5067 wsptr
[2*2] = tmp12
- tmp2
;
5070 /* Pass 2: process 4 rows from work array, store into output array. */
5073 for (ctr
= 0; ctr
< 4; ctr
++) {
5074 outptr
= output_buf
[ctr
] + output_col
;
5078 /* Add fudge factor here for final descale. */
5079 tmp10
= wsptr
[0] + (ONE
<< (CONST_BITS
+2));
5085 /* Final output stage */
5087 outptr
[0] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
, CONST_BITS
+3)
5089 outptr
[1] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
, CONST_BITS
+3)
5092 wsptr
+= 2; /* advance pointer to next row */
5098 * Perform dequantization and inverse DCT on one block of coefficients,
5099 * producing a 1x2 output block.
5101 * 2-point IDCT in pass 1 (columns), 1-point in pass 2 (rows).
5105 jpeg_idct_1x2 (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
5106 JCOEFPTR coef_block
,
5107 JSAMPARRAY output_buf
, JDIMENSION output_col
)
5110 ISLOW_MULT_TYPE
* quantptr
;
5111 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
5114 /* Process 1 column from input, store into output array. */
5116 quantptr
= (ISLOW_MULT_TYPE
*) compptr
->dct_table
;
5120 tmp10
= DEQUANTIZE(coef_block
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
5121 /* Add fudge factor here for final descale. */
5126 tmp0
= DEQUANTIZE(coef_block
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
5128 /* Final output stage */
5130 output_buf
[0][output_col
] = range_limit
[(int) RIGHT_SHIFT(tmp10
+ tmp0
, 3)
5132 output_buf
[1][output_col
] = range_limit
[(int) RIGHT_SHIFT(tmp10
- tmp0
, 3)
5136 #endif /* IDCT_SCALING_SUPPORTED */
5137 #endif /* DCT_ISLOW_SUPPORTED */