Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: jidctred.c

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « jidctint.c ('k') | jinclude.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * jidctred.c 2 * jidctred.c
3 * 3 *
4 * This file was part of the Independent JPEG Group's software.
4 * Copyright (C) 1994-1998, Thomas G. Lane. 5 * Copyright (C) 1994-1998, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software. 6 * libjpeg-turbo Modifications:
6 * For conditions of distribution and use, see the accompanying README file. 7 * Copyright (C) 2015, D. R. Commander
8 * For conditions of distribution and use, see the accompanying README.ijg
9 * file.
7 * 10 *
8 * This file contains inverse-DCT routines that produce reduced-size output: 11 * This file contains inverse-DCT routines that produce reduced-size output:
9 * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. 12 * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.
10 * 13 *
11 * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) 14 * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)
12 * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step 15 * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step
13 * with an 8-to-4 step that produces the four averages of two adjacent outputs 16 * with an 8-to-4 step that produces the four averages of two adjacent outputs
14 * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). 17 * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output).
15 * These steps were derived by computing the corresponding values at the end 18 * These steps were derived by computing the corresponding values at the end
16 * of the normal LL&M code, then simplifying as much as possible. 19 * of the normal LL&M code, then simplifying as much as possible.
17 * 20 *
18 * 1x1 is trivial: just take the DC coefficient divided by 8. 21 * 1x1 is trivial: just take the DC coefficient divided by 8.
19 * 22 *
20 * See jidctint.c for additional comments. 23 * See jidctint.c for additional comments.
21 */ 24 */
22 25
23 #define JPEG_INTERNALS 26 #define JPEG_INTERNALS
24 #include "jinclude.h" 27 #include "jinclude.h"
25 #include "jpeglib.h" 28 #include "jpeglib.h"
26 #include "jdct.h"» » /* Private declarations for DCT subsystem */ 29 #include "jdct.h" /* Private declarations for DCT subsystem */
27 30
28 #ifdef IDCT_SCALING_SUPPORTED 31 #ifdef IDCT_SCALING_SUPPORTED
29 32
30 33
31 /* 34 /*
32 * This module is specialized to the case DCTSIZE = 8. 35 * This module is specialized to the case DCTSIZE = 8.
33 */ 36 */
34 37
35 #if DCTSIZE != 8 38 #if DCTSIZE != 8
36 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ 39 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
37 #endif 40 #endif
38 41
39 42
40 /* Scaling is the same as in jidctint.c. */ 43 /* Scaling is the same as in jidctint.c. */
41 44
42 #if BITS_IN_JSAMPLE == 8 45 #if BITS_IN_JSAMPLE == 8
43 #define CONST_BITS 13 46 #define CONST_BITS 13
44 #define PASS1_BITS 2 47 #define PASS1_BITS 2
45 #else 48 #else
46 #define CONST_BITS 13 49 #define CONST_BITS 13
47 #define PASS1_BITS 1» » /* lose a little precision to avoid overflow */ 50 #define PASS1_BITS 1 /* lose a little precision to avoid overflow */
48 #endif 51 #endif
49 52
50 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus 53 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
51 * causing a lot of useless floating-point operations at run time. 54 * causing a lot of useless floating-point operations at run time.
52 * To get around this we use the following pre-calculated constants. 55 * To get around this we use the following pre-calculated constants.
53 * If you change CONST_BITS you may want to add appropriate values. 56 * If you change CONST_BITS you may want to add appropriate values.
54 * (With a reasonable C compiler, you can just rely on the FIX() macro...) 57 * (With a reasonable C compiler, you can just rely on the FIX() macro...)
55 */ 58 */
56 59
57 #if CONST_BITS == 13 60 #if CONST_BITS == 13
58 #define FIX_0_211164243 ((INT32) 1730)» /* FIX(0.211164243) */ 61 #define FIX_0_211164243 ((JLONG) 1730) /* FIX(0.211164243) */
59 #define FIX_0_509795579 ((INT32) 4176)» /* FIX(0.509795579) */ 62 #define FIX_0_509795579 ((JLONG) 4176) /* FIX(0.509795579) */
60 #define FIX_0_601344887 ((INT32) 4926)» /* FIX(0.601344887) */ 63 #define FIX_0_601344887 ((JLONG) 4926) /* FIX(0.601344887) */
61 #define FIX_0_720959822 ((INT32) 5906)» /* FIX(0.720959822) */ 64 #define FIX_0_720959822 ((JLONG) 5906) /* FIX(0.720959822) */
62 #define FIX_0_765366865 ((INT32) 6270)» /* FIX(0.765366865) */ 65 #define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */
63 #define FIX_0_850430095 ((INT32) 6967)» /* FIX(0.850430095) */ 66 #define FIX_0_850430095 ((JLONG) 6967) /* FIX(0.850430095) */
64 #define FIX_0_899976223 ((INT32) 7373)» /* FIX(0.899976223) */ 67 #define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */
65 #define FIX_1_061594337 ((INT32) 8697)» /* FIX(1.061594337) */ 68 #define FIX_1_061594337 ((JLONG) 8697) /* FIX(1.061594337) */
66 #define FIX_1_272758580 ((INT32) 10426)» /* FIX(1.272758580) */ 69 #define FIX_1_272758580 ((JLONG) 10426) /* FIX(1.272758580) */
67 #define FIX_1_451774981 ((INT32) 11893)» /* FIX(1.451774981) */ 70 #define FIX_1_451774981 ((JLONG) 11893) /* FIX(1.451774981) */
68 #define FIX_1_847759065 ((INT32) 15137)» /* FIX(1.847759065) */ 71 #define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */
69 #define FIX_2_172734803 ((INT32) 17799)» /* FIX(2.172734803) */ 72 #define FIX_2_172734803 ((JLONG) 17799) /* FIX(2.172734803) */
70 #define FIX_2_562915447 ((INT32) 20995)» /* FIX(2.562915447) */ 73 #define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */
71 #define FIX_3_624509785 ((INT32) 29692)» /* FIX(3.624509785) */ 74 #define FIX_3_624509785 ((JLONG) 29692) /* FIX(3.624509785) */
72 #else 75 #else
73 #define FIX_0_211164243 FIX(0.211164243) 76 #define FIX_0_211164243 FIX(0.211164243)
74 #define FIX_0_509795579 FIX(0.509795579) 77 #define FIX_0_509795579 FIX(0.509795579)
75 #define FIX_0_601344887 FIX(0.601344887) 78 #define FIX_0_601344887 FIX(0.601344887)
76 #define FIX_0_720959822 FIX(0.720959822) 79 #define FIX_0_720959822 FIX(0.720959822)
77 #define FIX_0_765366865 FIX(0.765366865) 80 #define FIX_0_765366865 FIX(0.765366865)
78 #define FIX_0_850430095 FIX(0.850430095) 81 #define FIX_0_850430095 FIX(0.850430095)
79 #define FIX_0_899976223 FIX(0.899976223) 82 #define FIX_0_899976223 FIX(0.899976223)
80 #define FIX_1_061594337 FIX(1.061594337) 83 #define FIX_1_061594337 FIX(1.061594337)
81 #define FIX_1_272758580 FIX(1.272758580) 84 #define FIX_1_272758580 FIX(1.272758580)
82 #define FIX_1_451774981 FIX(1.451774981) 85 #define FIX_1_451774981 FIX(1.451774981)
83 #define FIX_1_847759065 FIX(1.847759065) 86 #define FIX_1_847759065 FIX(1.847759065)
84 #define FIX_2_172734803 FIX(2.172734803) 87 #define FIX_2_172734803 FIX(2.172734803)
85 #define FIX_2_562915447 FIX(2.562915447) 88 #define FIX_2_562915447 FIX(2.562915447)
86 #define FIX_3_624509785 FIX(3.624509785) 89 #define FIX_3_624509785 FIX(3.624509785)
87 #endif 90 #endif
88 91
89 92
90 /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. 93 /* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
91 * For 8-bit samples with the recommended scaling, all the variable 94 * For 8-bit samples with the recommended scaling, all the variable
92 * and constant values involved are no more than 16 bits wide, so a 95 * and constant values involved are no more than 16 bits wide, so a
93 * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. 96 * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
94 * For 12-bit samples, a full 32-bit multiplication will be needed. 97 * For 12-bit samples, a full 32-bit multiplication will be needed.
95 */ 98 */
96 99
97 #if BITS_IN_JSAMPLE == 8 100 #if BITS_IN_JSAMPLE == 8
98 #define MULTIPLY(var,const) MULTIPLY16C16(var,const) 101 #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
99 #else 102 #else
100 #define MULTIPLY(var,const) ((var) * (const)) 103 #define MULTIPLY(var,const) ((var) * (const))
101 #endif 104 #endif
102 105
103 106
104 /* Dequantize a coefficient by multiplying it by the multiplier-table 107 /* Dequantize a coefficient by multiplying it by the multiplier-table
105 * entry; produce an int result. In this module, both inputs and result 108 * entry; produce an int result. In this module, both inputs and result
106 * are 16 bits or less, so either int or short multiply will work. 109 * are 16 bits or less, so either int or short multiply will work.
107 */ 110 */
108 111
109 #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) 112 #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
110 113
111 114
112 /* 115 /*
113 * Perform dequantization and inverse DCT on one block of coefficients, 116 * Perform dequantization and inverse DCT on one block of coefficients,
114 * producing a reduced-size 4x4 output block. 117 * producing a reduced-size 4x4 output block.
115 */ 118 */
116 119
117 GLOBAL(void) 120 GLOBAL(void)
118 jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, 121 jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
119 » JCOEFPTR coef_block, 122 JCOEFPTR coef_block,
120 » JSAMPARRAY output_buf, JDIMENSION output_col) 123 JSAMPARRAY output_buf, JDIMENSION output_col)
121 { 124 {
122 INT32 tmp0, tmp2, tmp10, tmp12; 125 JLONG tmp0, tmp2, tmp10, tmp12;
123 INT32 z1, z2, z3, z4; 126 JLONG z1, z2, z3, z4;
124 JCOEFPTR inptr; 127 JCOEFPTR inptr;
125 ISLOW_MULT_TYPE * quantptr; 128 ISLOW_MULT_TYPE *quantptr;
126 int * wsptr; 129 int *wsptr;
127 JSAMPROW outptr; 130 JSAMPROW outptr;
128 JSAMPLE *range_limit = IDCT_range_limit(cinfo); 131 JSAMPLE *range_limit = IDCT_range_limit(cinfo);
129 int ctr; 132 int ctr;
130 int workspace[DCTSIZE*4];» /* buffers data between passes */ 133 int workspace[DCTSIZE*4]; /* buffers data between passes */
131 SHIFT_TEMPS 134 SHIFT_TEMPS
132 135
133 /* Pass 1: process columns from input, store into work array. */ 136 /* Pass 1: process columns from input, store into work array. */
134 137
135 inptr = coef_block; 138 inptr = coef_block;
136 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; 139 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
137 wsptr = workspace; 140 wsptr = workspace;
138 for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { 141 for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
139 /* Don't bother to process column 4, because second pass won't use it */ 142 /* Don't bother to process column 4, because second pass won't use it */
140 if (ctr == DCTSIZE-4) 143 if (ctr == DCTSIZE-4)
141 continue; 144 continue;
142 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && 145 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
143 » inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && 146 inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
144 » inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { 147 inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
145 /* AC terms all zero; we need not examine term 4 for 4x4 output */ 148 /* AC terms all zero; we need not examine term 4 for 4x4 output */
146 int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BIT S; 149 int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
147 150 PASS1_BITS);
151
148 wsptr[DCTSIZE*0] = dcval; 152 wsptr[DCTSIZE*0] = dcval;
149 wsptr[DCTSIZE*1] = dcval; 153 wsptr[DCTSIZE*1] = dcval;
150 wsptr[DCTSIZE*2] = dcval; 154 wsptr[DCTSIZE*2] = dcval;
151 wsptr[DCTSIZE*3] = dcval; 155 wsptr[DCTSIZE*3] = dcval;
152 156
153 continue; 157 continue;
154 } 158 }
155 159
156 /* Even part */ 160 /* Even part */
157 161
158 tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); 162 tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
159 tmp0 <<= (CONST_BITS+1); 163 tmp0 = LEFT_SHIFT(tmp0, CONST_BITS+1);
160 164
161 z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); 165 z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
162 z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); 166 z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
163 167
164 tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); 168 tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
165 169
166 tmp10 = tmp0 + tmp2; 170 tmp10 = tmp0 + tmp2;
167 tmp12 = tmp0 - tmp2; 171 tmp12 = tmp0 - tmp2;
168 172
169 /* Odd part */ 173 /* Odd part */
170 174
171 z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); 175 z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
172 z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); 176 z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
173 z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); 177 z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
174 z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); 178 z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
175 179
176 tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ 180 tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
177 » + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ 181 + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
178 » + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ 182 + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
179 » + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ 183 + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
180 184
181 tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ 185 tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
182 » + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ 186 + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
183 » + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ 187 + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
184 » + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ 188 + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
185 189
186 /* Final output stage */ 190 /* Final output stage */
187 191
188 wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); 192 wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
189 wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); 193 wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
190 wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); 194 wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
191 wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); 195 wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
192 } 196 }
193 197
194 /* Pass 2: process 4 rows from work array, store into output array. */ 198 /* Pass 2: process 4 rows from work array, store into output array. */
195 199
196 wsptr = workspace; 200 wsptr = workspace;
197 for (ctr = 0; ctr < 4; ctr++) { 201 for (ctr = 0; ctr < 4; ctr++) {
198 outptr = output_buf[ctr] + output_col; 202 outptr = output_buf[ctr] + output_col;
199 /* It's not clear whether a zero row test is worthwhile here ... */ 203 /* It's not clear whether a zero row test is worthwhile here ... */
200 204
201 #ifndef NO_ZERO_ROW_TEST 205 #ifndef NO_ZERO_ROW_TEST
202 if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && 206 if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
203 » wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { 207 wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
204 /* AC terms all zero */ 208 /* AC terms all zero */
205 JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) 209 JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
206 » » » » & RANGE_MASK]; 210 & RANGE_MASK];
207 211
208 outptr[0] = dcval; 212 outptr[0] = dcval;
209 outptr[1] = dcval; 213 outptr[1] = dcval;
210 outptr[2] = dcval; 214 outptr[2] = dcval;
211 outptr[3] = dcval; 215 outptr[3] = dcval;
212 216
213 wsptr += DCTSIZE;»» /* advance pointer to next row */ 217 wsptr += DCTSIZE; /* advance pointer to next row */
214 continue; 218 continue;
215 } 219 }
216 #endif 220 #endif
217 221
218 /* Even part */ 222 /* Even part */
219 223
220 tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); 224 tmp0 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+1);
221 225
222 tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) 226 tmp2 = MULTIPLY((JLONG) wsptr[2], FIX_1_847759065)
223 » + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); 227 + MULTIPLY((JLONG) wsptr[6], - FIX_0_765366865);
224 228
225 tmp10 = tmp0 + tmp2; 229 tmp10 = tmp0 + tmp2;
226 tmp12 = tmp0 - tmp2; 230 tmp12 = tmp0 - tmp2;
227 231
228 /* Odd part */ 232 /* Odd part */
229 233
230 z1 = (INT32) wsptr[7]; 234 z1 = (JLONG) wsptr[7];
231 z2 = (INT32) wsptr[5]; 235 z2 = (JLONG) wsptr[5];
232 z3 = (INT32) wsptr[3]; 236 z3 = (JLONG) wsptr[3];
233 z4 = (INT32) wsptr[1]; 237 z4 = (JLONG) wsptr[1];
234 238
235 tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ 239 tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
236 » + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ 240 + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
237 » + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ 241 + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
238 » + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ 242 + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
239 243
240 tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ 244 tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
241 » + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ 245 + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
242 » + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ 246 + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
243 » + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ 247 + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
244 248
245 /* Final output stage */ 249 /* Final output stage */
246 250
247 outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, 251 outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
248 » » » » » CONST_BITS+PASS1_BITS+3+1) 252 CONST_BITS+PASS1_BITS+3+1)
249 » » » & RANGE_MASK]; 253 & RANGE_MASK];
250 outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, 254 outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
251 » » » » » CONST_BITS+PASS1_BITS+3+1) 255 CONST_BITS+PASS1_BITS+3+1)
252 » » » & RANGE_MASK]; 256 & RANGE_MASK];
253 outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, 257 outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
254 » » » » » CONST_BITS+PASS1_BITS+3+1) 258 CONST_BITS+PASS1_BITS+3+1)
255 » » » & RANGE_MASK]; 259 & RANGE_MASK];
256 outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, 260 outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
257 » » » » » CONST_BITS+PASS1_BITS+3+1) 261 CONST_BITS+PASS1_BITS+3+1)
258 » » » & RANGE_MASK]; 262 & RANGE_MASK];
259 263
260 wsptr += DCTSIZE;» » /* advance pointer to next row */ 264 wsptr += DCTSIZE; /* advance pointer to next row */
261 } 265 }
262 } 266 }
263 267
264 268
265 /* 269 /*
266 * Perform dequantization and inverse DCT on one block of coefficients, 270 * Perform dequantization and inverse DCT on one block of coefficients,
267 * producing a reduced-size 2x2 output block. 271 * producing a reduced-size 2x2 output block.
268 */ 272 */
269 273
270 GLOBAL(void) 274 GLOBAL(void)
271 jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, 275 jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
272 » JCOEFPTR coef_block, 276 JCOEFPTR coef_block,
273 » JSAMPARRAY output_buf, JDIMENSION output_col) 277 JSAMPARRAY output_buf, JDIMENSION output_col)
274 { 278 {
275 INT32 tmp0, tmp10, z1; 279 JLONG tmp0, tmp10, z1;
276 JCOEFPTR inptr; 280 JCOEFPTR inptr;
277 ISLOW_MULT_TYPE * quantptr; 281 ISLOW_MULT_TYPE *quantptr;
278 int * wsptr; 282 int *wsptr;
279 JSAMPROW outptr; 283 JSAMPROW outptr;
280 JSAMPLE *range_limit = IDCT_range_limit(cinfo); 284 JSAMPLE *range_limit = IDCT_range_limit(cinfo);
281 int ctr; 285 int ctr;
282 int workspace[DCTSIZE*2];» /* buffers data between passes */ 286 int workspace[DCTSIZE*2]; /* buffers data between passes */
283 SHIFT_TEMPS 287 SHIFT_TEMPS
284 288
285 /* Pass 1: process columns from input, store into work array. */ 289 /* Pass 1: process columns from input, store into work array. */
286 290
287 inptr = coef_block; 291 inptr = coef_block;
288 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; 292 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
289 wsptr = workspace; 293 wsptr = workspace;
290 for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { 294 for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
291 /* Don't bother to process columns 2,4,6 */ 295 /* Don't bother to process columns 2,4,6 */
292 if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) 296 if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
293 continue; 297 continue;
294 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && 298 if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
295 » inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { 299 inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
296 /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ 300 /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
297 int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BIT S; 301 int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
298 302 PASS1_BITS);
303
299 wsptr[DCTSIZE*0] = dcval; 304 wsptr[DCTSIZE*0] = dcval;
300 wsptr[DCTSIZE*1] = dcval; 305 wsptr[DCTSIZE*1] = dcval;
301 306
302 continue; 307 continue;
303 } 308 }
304 309
305 /* Even part */ 310 /* Even part */
306 311
307 z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); 312 z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
308 tmp10 = z1 << (CONST_BITS+2); 313 tmp10 = LEFT_SHIFT(z1, CONST_BITS+2);
309 314
310 /* Odd part */ 315 /* Odd part */
311 316
312 z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); 317 z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
313 tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ 318 tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
314 z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); 319 z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
315 tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ 320 tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
316 z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); 321 z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
317 tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ 322 tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
318 z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); 323 z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
319 tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ 324 tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
320 325
321 /* Final output stage */ 326 /* Final output stage */
322 327
323 wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); 328 wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
324 wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); 329 wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
325 } 330 }
326 331
327 /* Pass 2: process 2 rows from work array, store into output array. */ 332 /* Pass 2: process 2 rows from work array, store into output array. */
328 333
329 wsptr = workspace; 334 wsptr = workspace;
330 for (ctr = 0; ctr < 2; ctr++) { 335 for (ctr = 0; ctr < 2; ctr++) {
331 outptr = output_buf[ctr] + output_col; 336 outptr = output_buf[ctr] + output_col;
332 /* It's not clear whether a zero row test is worthwhile here ... */ 337 /* It's not clear whether a zero row test is worthwhile here ... */
333 338
334 #ifndef NO_ZERO_ROW_TEST 339 #ifndef NO_ZERO_ROW_TEST
335 if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { 340 if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
336 /* AC terms all zero */ 341 /* AC terms all zero */
337 JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) 342 JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
338 » » » » & RANGE_MASK]; 343 & RANGE_MASK];
339 344
340 outptr[0] = dcval; 345 outptr[0] = dcval;
341 outptr[1] = dcval; 346 outptr[1] = dcval;
342 347
343 wsptr += DCTSIZE;»» /* advance pointer to next row */ 348 wsptr += DCTSIZE; /* advance pointer to next row */
344 continue; 349 continue;
345 } 350 }
346 #endif 351 #endif
347 352
348 /* Even part */ 353 /* Even part */
349 354
350 tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); 355 tmp10 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+2);
351 356
352 /* Odd part */ 357 /* Odd part */
353 358
354 tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3- c1) */ 359 tmp0 = MULTIPLY((JLONG) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3- c1) */
355 » + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c 7) */ 360 + MULTIPLY((JLONG) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c 7) */
356 » + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5 -c7) */ 361 + MULTIPLY((JLONG) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5 -c7) */
357 » + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c 7) */ 362 + MULTIPLY((JLONG) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c 7) */
358 363
359 /* Final output stage */ 364 /* Final output stage */
360 365
361 outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, 366 outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
362 » » » » » CONST_BITS+PASS1_BITS+3+2) 367 CONST_BITS+PASS1_BITS+3+2)
363 » » » & RANGE_MASK]; 368 & RANGE_MASK];
364 outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, 369 outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
365 » » » » » CONST_BITS+PASS1_BITS+3+2) 370 CONST_BITS+PASS1_BITS+3+2)
366 » » » & RANGE_MASK]; 371 & RANGE_MASK];
367 372
368 wsptr += DCTSIZE;» » /* advance pointer to next row */ 373 wsptr += DCTSIZE; /* advance pointer to next row */
369 } 374 }
370 } 375 }
371 376
372 377
373 /* 378 /*
374 * Perform dequantization and inverse DCT on one block of coefficients, 379 * Perform dequantization and inverse DCT on one block of coefficients,
375 * producing a reduced-size 1x1 output block. 380 * producing a reduced-size 1x1 output block.
376 */ 381 */
377 382
378 GLOBAL(void) 383 GLOBAL(void)
379 jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, 384 jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
380 » JCOEFPTR coef_block, 385 JCOEFPTR coef_block,
381 » JSAMPARRAY output_buf, JDIMENSION output_col) 386 JSAMPARRAY output_buf, JDIMENSION output_col)
382 { 387 {
383 int dcval; 388 int dcval;
384 ISLOW_MULT_TYPE * quantptr; 389 ISLOW_MULT_TYPE *quantptr;
385 JSAMPLE *range_limit = IDCT_range_limit(cinfo); 390 JSAMPLE *range_limit = IDCT_range_limit(cinfo);
386 SHIFT_TEMPS 391 SHIFT_TEMPS
387 392
388 /* We hardly need an inverse DCT routine for this: just take the 393 /* We hardly need an inverse DCT routine for this: just take the
389 * average pixel value, which is one-eighth of the DC coefficient. 394 * average pixel value, which is one-eighth of the DC coefficient.
390 */ 395 */
391 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; 396 quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
392 dcval = DEQUANTIZE(coef_block[0], quantptr[0]); 397 dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
393 dcval = (int) DESCALE((INT32) dcval, 3); 398 dcval = (int) DESCALE((JLONG) dcval, 3);
394 399
395 output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; 400 output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
396 } 401 }
397 402
398 #endif /* IDCT_SCALING_SUPPORTED */ 403 #endif /* IDCT_SCALING_SUPPORTED */
OLDNEW
« no previous file with comments | « jidctint.c ('k') | jinclude.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698