📄 jidctred.c
字号:
/* Add fudge factor here for final descale. */
z3 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
z3 <<= CONST_BITS;
z4 = (INT32) wsptr[4];
z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */
tmp10 = z3 + z4;
tmp11 = z3 - z4;
z1 = (INT32) wsptr[2];
z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
z1 <<= CONST_BITS;
z2 = (INT32) wsptr[6];
z2 <<= CONST_BITS;
tmp12 = z1 - z2;
tmp21 = z3 + tmp12;
tmp24 = z3 - tmp12;
tmp12 = z4 + z2;
tmp20 = tmp10 + tmp12;
tmp25 = tmp10 - tmp12;
tmp12 = z4 - z1 - z2;
tmp22 = tmp11 + tmp12;
tmp23 = tmp11 - tmp12;
/* Odd part */
z1 = (INT32) wsptr[1];
z2 = (INT32) wsptr[3];
z3 = (INT32) wsptr[5];
z4 = (INT32) wsptr[7];
tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */
tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */
tmp10 = z1 + z3;
tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */
tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */
tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */
tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */
tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */
tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */
tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */
MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */
z1 -= z4;
z2 -= z3;
z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */
tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */
tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */
/* Final output stage */
outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
}
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a 13x13 output block.
*
* Optimized algorithm with 29 multiplications in the 1-D kernel.
* cK represents sqrt(2) * cos(K*pi/26).
*/
GLOBAL(void)
jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
INT32 z1, z2, z3, z4;
JCOEFPTR inptr;
ISLOW_MULT_TYPE * quantptr;
int * wsptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8*13]; /* buffers data between passes */
SHIFT_TEMPS
/* Pass 1: process columns from input, store into work array. */
inptr = coef_block;
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
wsptr = workspace;
for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
/* Even part */
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
z1 <<= CONST_BITS;
/* Add fudge factor here for final descale. */
z1 += ONE << (CONST_BITS-PASS1_BITS-1);
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
tmp10 = z3 + z4;
tmp11 = z3 - z4;
tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */
tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */
tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */
tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */
tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */
tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */
tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */
tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */
tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */
tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */
/* Odd part */
z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */
tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */
tmp15 = z1 + z4;
tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */
tmp10 = tmp11 + tmp12 + tmp13 -
MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */
tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */
tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */
tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */
tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */
tmp11 += tmp14;
tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */
tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */
tmp12 += tmp14;
tmp13 += tmp14;
tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */
tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */
MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */
z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */
tmp14 += z1;
tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */
MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */
/* Final output stage */
wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*12] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*11] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*10] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*9] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*8] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS);
wsptr[8*7] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS);
wsptr[8*6] = (int) RIGHT_SHIFT(tmp26, CONST_BITS-PASS1_BITS);
}
/* Pass 2: process 13 rows from work array, store into output array. */
wsptr = workspace;
for (ctr = 0; ctr < 13; ctr++) {
outptr = output_buf[ctr] + output_col;
/* Even part */
/* Add fudge factor here for final descale. */
z1 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
z1 <<= CONST_BITS;
z2 = (INT32) wsptr[2];
z3 = (INT32) wsptr[4];
z4 = (INT32) wsptr[6];
tmp10 = z3 + z4;
tmp11 = z3 - z4;
tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */
tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */
tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */
tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */
tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */
tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */
tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */
tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */
tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */
tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */
tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */
/* Odd part */
z1 = (INT32) wsptr[1];
z2 = (INT32) wsptr[3];
z3 = (INT32) wsptr[5];
z4 = (INT32) wsptr[7];
tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */
tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */
tmp15 = z1 + z4;
tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */
tmp10 = tmp11 + tmp12 + tmp13 -
MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */
tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */
tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */
tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */
tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */
tmp11 += tmp14;
tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */
tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */
tmp12 += tmp14;
tmp13 += tmp14;
tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */
tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */
MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */
z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */
tmp14 += z1;
tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */
MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */
/* Final output stage */
outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
wsptr += 8; /* advance pointer to next row */
}
}
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a 14x14 output block.
*
* Optimized algorithm with 20 multiplications in the 1-D kernel.
* cK represents sqrt(2) * cos(K*pi/28).
*/
GLOBAL(void)
jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
INT32 z1, z2, z3, z4;
JCOEFPTR inptr;
ISLOW_MULT_TYPE * quantptr;
int * wsptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8*14]; /* buffers data between passes */
SHIFT_TEMPS
/* Pass 1: process columns from input, store into work array. */
inptr = coef_block;
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
wsptr = workspace;
for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) {
/* Even part */
z1 = DEQUANTIZE(inpt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -