📄 jidctred.c
字号:
tmp11 = z2 + z4;
tmp13 = z2 - z4;
tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */
z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */
z4 = z3 + tmp12;
tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */
tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */
z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */
z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1));
tmp12 = ((z1 - tmp13) << CONST_BITS) - z3;
tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */
tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */
/* Final output stage */
outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[9] = 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[8] = 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[7] = 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[6] = 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[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14,
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 11x11 output block.
*
* Optimized algorithm with 24 multiplications in the 1-D kernel.
* cK represents sqrt(2) * cos(K*pi/22).
*/
GLOBAL(void)
jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
INT32 tmp10, tmp11, tmp12, tmp13, tmp14;
INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
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*11]; /* 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 */
tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
tmp10 <<= CONST_BITS;
/* Add fudge factor here for final descale. */
tmp10 += ONE << (CONST_BITS-PASS1_BITS-1);
z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */
tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */
z4 = z1 + z3;
tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */
z4 -= z2;
tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */
tmp21 = tmp20 + tmp23 + tmp25 -
MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */
tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */
tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */
tmp24 += tmp25;
tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */
tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */
MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */
tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* 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 = z1 + z2;
tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */
tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */
tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */
tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */
tmp10 = tmp11 + tmp12 + tmp13 -
MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */
tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */
z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */
tmp11 += z1;
tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */
tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */
MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */
MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */
/* Final output stage */
wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*10] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*9] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*8] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*7] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*6] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*5] = (int) RIGHT_SHIFT(tmp25, CONST_BITS-PASS1_BITS);
}
/* Pass 2: process 11 rows from work array, store into output array. */
wsptr = workspace;
for (ctr = 0; ctr < 11; ctr++) {
outptr = output_buf[ctr] + output_col;
/* Even part */
/* Add fudge factor here for final descale. */
tmp10 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2));
tmp10 <<= CONST_BITS;
z1 = (INT32) wsptr[2];
z2 = (INT32) wsptr[4];
z3 = (INT32) wsptr[6];
tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */
tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */
z4 = z1 + z3;
tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */
z4 -= z2;
tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */
tmp21 = tmp20 + tmp23 + tmp25 -
MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */
tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */
tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */
tmp24 += tmp25;
tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */
tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */
MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */
tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */
/* Odd part */
z1 = (INT32) wsptr[1];
z2 = (INT32) wsptr[3];
z3 = (INT32) wsptr[5];
z4 = (INT32) wsptr[7];
tmp11 = z1 + z2;
tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */
tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */
tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */
tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */
tmp10 = tmp11 + tmp12 + tmp13 -
MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */
z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */
tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */
tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */
z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */
tmp11 += z1;
tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */
tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */
MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */
MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */
/* Final output stage */
outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[10] = 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[9] = 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[8] = 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[7] = 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[6] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14,
CONST_BITS+PASS1_BITS+3)
& RANGE_MASK];
outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25,
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 12x12 output block.
*
* Optimized algorithm with 15 multiplications in the 1-D kernel.
* cK represents sqrt(2) * cos(K*pi/24).
*/
GLOBAL(void)
jpeg_idct_12x12 (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;
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*12]; /* 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 */
z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
z3 <<= CONST_BITS;
/* Add fudge factor here for final descale. */
z3 += ONE << (CONST_BITS-PASS1_BITS-1);
z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */
tmp10 = z3 + z4;
tmp11 = z3 - z4;
z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */
z1 <<= CONST_BITS;
z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*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 = 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(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 */
wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS);
wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS);
wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS);
wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS);
wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS);
wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS);
wsptr[8*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS);
}
/* Pass 2: process 12 rows from work array, store into output array. */
wsptr = workspace;
for (ctr = 0; ctr < 12; ctr++) {
outptr = output_buf[ctr] + output_col;
/* Even part */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -