28 #define JPEG_INTERNALS
33 #ifdef DCT_ISLOW_SUPPORTED
41 Sorry,
this code only copes with 8x8 DCTs.
77 #if BITS_IN_JSAMPLE == 8
93 #define FIX_0_298631336 ((INT32) 2446)
94 #define FIX_0_390180644 ((INT32) 3196)
95 #define FIX_0_541196100 ((INT32) 4433)
96 #define FIX_0_765366865 ((INT32) 6270)
97 #define FIX_0_899976223 ((INT32) 7373)
98 #define FIX_1_175875602 ((INT32) 9633)
99 #define FIX_1_501321110 ((INT32) 12299)
100 #define FIX_1_847759065 ((INT32) 15137)
101 #define FIX_1_961570560 ((INT32) 16069)
102 #define FIX_2_053119869 ((INT32) 16819)
103 #define FIX_2_562915447 ((INT32) 20995)
104 #define FIX_3_072711026 ((INT32) 25172)
106 #define FIX_0_298631336 FIX(0.298631336)
107 #define FIX_0_390180644 FIX(0.390180644)
108 #define FIX_0_541196100 FIX(0.541196100)
109 #define FIX_0_765366865 FIX(0.765366865)
110 #define FIX_0_899976223 FIX(0.899976223)
111 #define FIX_1_175875602 FIX(1.175875602)
112 #define FIX_1_501321110 FIX(1.501321110)
113 #define FIX_1_847759065 FIX(1.847759065)
114 #define FIX_1_961570560 FIX(1.961570560)
115 #define FIX_2_053119869 FIX(2.053119869)
116 #define FIX_2_562915447 FIX(2.562915447)
117 #define FIX_3_072711026 FIX(3.072711026)
128 #if BITS_IN_JSAMPLE == 8
129 #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
131 #define MULTIPLY(var,const) ((var) * (const))
140 #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
152 INT32 tmp0, tmp1, tmp2, tmp3;
153 INT32 tmp10, tmp11, tmp12, tmp13;
154 INT32 z1, z2, z3, z4, z5;
171 for (ctr =
DCTSIZE; ctr > 0; ctr--) {
185 int dcval =
DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
187 wsptr[DCTSIZE*0] = dcval;
188 wsptr[DCTSIZE*1] = dcval;
189 wsptr[DCTSIZE*2] = dcval;
190 wsptr[DCTSIZE*3] = dcval;
191 wsptr[DCTSIZE*4] = dcval;
192 wsptr[DCTSIZE*5] = dcval;
193 wsptr[DCTSIZE*6] = dcval;
194 wsptr[DCTSIZE*7] = dcval;
205 z2 =
DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
206 z3 =
DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
208 z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
209 tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
210 tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
212 z2 =
DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
213 z3 =
DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
215 tmp0 = (z2 + z3) << CONST_BITS;
216 tmp1 = (z2 - z3) << CONST_BITS;
227 tmp0 =
DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
228 tmp1 =
DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
229 tmp2 =
DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
230 tmp3 =
DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
236 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
238 tmp0 = MULTIPLY(tmp0, FIX_0_298631336);
239 tmp1 = MULTIPLY(tmp1, FIX_2_053119869);
240 tmp2 = MULTIPLY(tmp2, FIX_3_072711026);
241 tmp3 = MULTIPLY(tmp3, FIX_1_501321110);
242 z1 = MULTIPLY(z1, - FIX_0_899976223);
243 z2 = MULTIPLY(z2, - FIX_2_562915447);
244 z3 = MULTIPLY(z3, - FIX_1_961570560);
245 z4 = MULTIPLY(z4, - FIX_0_390180644);
257 wsptr[DCTSIZE*0] = (
int)
DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
258 wsptr[DCTSIZE*7] = (
int)
DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
259 wsptr[DCTSIZE*1] = (
int)
DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
260 wsptr[DCTSIZE*6] = (
int)
DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
261 wsptr[DCTSIZE*2] = (
int)
DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
262 wsptr[DCTSIZE*5] = (
int)
DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
263 wsptr[DCTSIZE*3] = (
int)
DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
264 wsptr[DCTSIZE*4] = (
int)
DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
276 for (ctr = 0; ctr <
DCTSIZE; ctr++) {
277 outptr = output_buf[ctr] + output_col;
286 #ifndef NO_ZERO_ROW_TEST
287 if ((wsptr[1] | wsptr[2] | wsptr[3] | wsptr[4] | wsptr[5] | wsptr[6] |
310 z2 = (
INT32) wsptr[2];
311 z3 = (
INT32) wsptr[6];
313 z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
314 tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
315 tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
317 tmp0 = ((
INT32) wsptr[0] + (
INT32) wsptr[4]) << CONST_BITS;
318 tmp1 = ((
INT32) wsptr[0] - (
INT32) wsptr[4]) << CONST_BITS;
329 tmp0 = (
INT32) wsptr[7];
330 tmp1 = (
INT32) wsptr[5];
331 tmp2 = (
INT32) wsptr[3];
332 tmp3 = (
INT32) wsptr[1];
338 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
340 tmp0 = MULTIPLY(tmp0, FIX_0_298631336);
341 tmp1 = MULTIPLY(tmp1, FIX_2_053119869);
342 tmp2 = MULTIPLY(tmp2, FIX_3_072711026);
343 tmp3 = MULTIPLY(tmp3, FIX_1_501321110);
344 z1 = MULTIPLY(z1, - FIX_0_899976223);
345 z2 = MULTIPLY(z2, - FIX_2_562915447);
346 z3 = MULTIPLY(z3, - FIX_1_961570560);
347 z4 = MULTIPLY(z4, - FIX_0_390180644);
359 outptr[0] = range_limit[(
int)
DESCALE(tmp10 + tmp3,
360 CONST_BITS+PASS1_BITS+3)
362 outptr[7] = range_limit[(
int)
DESCALE(tmp10 - tmp3,
363 CONST_BITS+PASS1_BITS+3)
365 outptr[1] = range_limit[(
int)
DESCALE(tmp11 + tmp2,
366 CONST_BITS+PASS1_BITS+3)
368 outptr[6] = range_limit[(
int)
DESCALE(tmp11 - tmp2,
369 CONST_BITS+PASS1_BITS+3)
371 outptr[2] = range_limit[(
int)
DESCALE(tmp12 + tmp1,
372 CONST_BITS+PASS1_BITS+3)
374 outptr[5] = range_limit[(
int)
DESCALE(tmp12 - tmp1,
375 CONST_BITS+PASS1_BITS+3)
377 outptr[3] = range_limit[(
int)
DESCALE(tmp13 + tmp0,
378 CONST_BITS+PASS1_BITS+3)
380 outptr[4] = range_limit[(
int)
DESCALE(tmp13 - tmp0,
381 CONST_BITS+PASS1_BITS+3)
#define IDCT_range_limit(cinfo)
MULTIPLIER ISLOW_MULT_TYPE
#define DEQUANTIZE(coef, quantval)