| Index: jidctfst.c
|
| diff --git a/jidctfst.c b/jidctfst.c
|
| index dba4216fb95e7148c24f2d6f6bba8309bb9be24e..10db739b86246ad36481ebfc51b38076deb4e375 100644
|
| --- a/jidctfst.c
|
| +++ b/jidctfst.c
|
| @@ -1,9 +1,12 @@
|
| /*
|
| * jidctfst.c
|
| *
|
| + * This file was part of the Independent JPEG Group's software:
|
| * Copyright (C) 1994-1998, Thomas G. Lane.
|
| - * This file is part of the Independent JPEG Group's software.
|
| - * For conditions of distribution and use, see the accompanying README file.
|
| + * libjpeg-turbo Modifications:
|
| + * Copyright (C) 2015, D. R. Commander.
|
| + * For conditions of distribution and use, see the accompanying README.ijg
|
| + * file.
|
| *
|
| * This file contains a fast, not so accurate integer implementation of the
|
| * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
|
| @@ -17,8 +20,8 @@
|
| * This implementation is based on Arai, Agui, and Nakajima's algorithm for
|
| * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
|
| * Japanese, but the algorithm is described in the Pennebaker & Mitchell
|
| - * JPEG textbook (see REFERENCES section in file README). The following code
|
| - * is based directly on figure 4-8 in P&M.
|
| + * JPEG textbook (see REFERENCES section in file README.ijg). The following
|
| + * code is based directly on figure 4-8 in P&M.
|
| * While an 8-point DCT cannot be done in less than 11 multiplies, it is
|
| * possible to arrange the computation so that many of the multiplies are
|
| * simple scalings of the final outputs. These multiplies can then be
|
| @@ -35,7 +38,7 @@
|
| #define JPEG_INTERNALS
|
| #include "jinclude.h"
|
| #include "jpeglib.h"
|
| -#include "jdct.h" /* Private declarations for DCT subsystem */
|
| +#include "jdct.h" /* Private declarations for DCT subsystem */
|
|
|
| #ifdef DCT_IFAST_SUPPORTED
|
|
|
| @@ -78,7 +81,7 @@
|
| #define PASS1_BITS 2
|
| #else
|
| #define CONST_BITS 8
|
| -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
|
| +#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
|
| #endif
|
|
|
| /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
|
| @@ -89,10 +92,10 @@
|
| */
|
|
|
| #if CONST_BITS == 8
|
| -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */
|
| -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */
|
| -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */
|
| -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */
|
| +#define FIX_1_082392200 ((JLONG) 277) /* FIX(1.082392200) */
|
| +#define FIX_1_414213562 ((JLONG) 362) /* FIX(1.414213562) */
|
| +#define FIX_1_847759065 ((JLONG) 473) /* FIX(1.847759065) */
|
| +#define FIX_2_613125930 ((JLONG) 669) /* FIX(2.613125930) */
|
| #else
|
| #define FIX_1_082392200 FIX(1.082392200)
|
| #define FIX_1_414213562 FIX(1.414213562)
|
| @@ -112,7 +115,7 @@
|
| #endif
|
|
|
|
|
| -/* Multiply a DCTELEM variable by an INT32 constant, and immediately
|
| +/* Multiply a DCTELEM variable by an JLONG constant, and immediately
|
| * descale to yield a DCTELEM result.
|
| */
|
|
|
| @@ -122,27 +125,27 @@
|
| /* Dequantize a coefficient by multiplying it by the multiplier-table
|
| * entry; produce a DCTELEM result. For 8-bit data a 16x16->16
|
| * multiplication will do. For 12-bit data, the multiplier table is
|
| - * declared INT32, so a 32-bit multiply will be used.
|
| + * declared JLONG, so a 32-bit multiply will be used.
|
| */
|
|
|
| #if BITS_IN_JSAMPLE == 8
|
| #define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval))
|
| #else
|
| #define DEQUANTIZE(coef,quantval) \
|
| - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
|
| + DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
|
| #endif
|
|
|
|
|
| /* Like DESCALE, but applies to a DCTELEM and produces an int.
|
| - * We assume that int right shift is unsigned if INT32 right shift is.
|
| + * We assume that int right shift is unsigned if JLONG right shift is.
|
| */
|
|
|
| #ifdef RIGHT_SHIFT_IS_UNSIGNED
|
| -#define ISHIFT_TEMPS DCTELEM ishift_temp;
|
| +#define ISHIFT_TEMPS DCTELEM ishift_temp;
|
| #if BITS_IN_JSAMPLE == 8
|
| -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
|
| +#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
|
| #else
|
| -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
|
| +#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
|
| #endif
|
| #define IRIGHT_SHIFT(x,shft) \
|
| ((ishift_temp = (x)) < 0 ? \
|
| @@ -150,7 +153,7 @@
|
| (ishift_temp >> (shft)))
|
| #else
|
| #define ISHIFT_TEMPS
|
| -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
| +#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
| #endif
|
|
|
| #ifdef USE_ACCURATE_ROUNDING
|
| @@ -165,22 +168,22 @@
|
| */
|
|
|
| GLOBAL(void)
|
| -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| - JCOEFPTR coef_block,
|
| - JSAMPARRAY output_buf, JDIMENSION output_col)
|
| +jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| + JCOEFPTR coef_block,
|
| + JSAMPARRAY output_buf, JDIMENSION output_col)
|
| {
|
| DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
|
| DCTELEM tmp10, tmp11, tmp12, tmp13;
|
| DCTELEM z5, z10, z11, z12, z13;
|
| JCOEFPTR inptr;
|
| - IFAST_MULT_TYPE * quantptr;
|
| - int * wsptr;
|
| + IFAST_MULT_TYPE *quantptr;
|
| + int *wsptr;
|
| JSAMPROW outptr;
|
| JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
| int ctr;
|
| - int workspace[DCTSIZE2]; /* buffers data between passes */
|
| - SHIFT_TEMPS /* for DESCALE */
|
| - ISHIFT_TEMPS /* for IDESCALE */
|
| + int workspace[DCTSIZE2]; /* buffers data between passes */
|
| + SHIFT_TEMPS /* for DESCALE */
|
| + ISHIFT_TEMPS /* for IDESCALE */
|
|
|
| /* Pass 1: process columns from input, store into work array. */
|
|
|
| @@ -196,11 +199,11 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| * With typical images and quantization tables, half or more of the
|
| * column DCT calculations can be simplified this way.
|
| */
|
| -
|
| +
|
| if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
|
| - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
| - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
| - inptr[DCTSIZE*7] == 0) {
|
| + inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
|
| + inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
|
| + inptr[DCTSIZE*7] == 0) {
|
| /* AC terms all zero */
|
| int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
|
|
| @@ -212,13 +215,13 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| wsptr[DCTSIZE*5] = dcval;
|
| wsptr[DCTSIZE*6] = dcval;
|
| wsptr[DCTSIZE*7] = dcval;
|
| -
|
| - inptr++; /* advance pointers to next column */
|
| +
|
| + inptr++; /* advance pointers to next column */
|
| quantptr++;
|
| wsptr++;
|
| continue;
|
| }
|
| -
|
| +
|
| /* Even part */
|
|
|
| tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
|
| @@ -226,17 +229,17 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
|
| tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
|
|
|
| - tmp10 = tmp0 + tmp2; /* phase 3 */
|
| + tmp10 = tmp0 + tmp2; /* phase 3 */
|
| tmp11 = tmp0 - tmp2;
|
|
|
| - tmp13 = tmp1 + tmp3; /* phases 5-3 */
|
| + tmp13 = tmp1 + tmp3; /* phases 5-3 */
|
| tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */
|
|
|
| - tmp0 = tmp10 + tmp13; /* phase 2 */
|
| + tmp0 = tmp10 + tmp13; /* phase 2 */
|
| tmp3 = tmp10 - tmp13;
|
| tmp1 = tmp11 + tmp12;
|
| tmp2 = tmp11 - tmp12;
|
| -
|
| +
|
| /* Odd part */
|
|
|
| tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
|
| @@ -244,19 +247,19 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
|
| tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
|
|
|
| - z13 = tmp6 + tmp5; /* phase 6 */
|
| + z13 = tmp6 + tmp5; /* phase 6 */
|
| z10 = tmp6 - tmp5;
|
| z11 = tmp4 + tmp7;
|
| z12 = tmp4 - tmp7;
|
|
|
| - tmp7 = z11 + z13; /* phase 5 */
|
| + tmp7 = z11 + z13; /* phase 5 */
|
| tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
|
|
| z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
| tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
| tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
|
|
| - tmp6 = tmp12 - tmp7; /* phase 2 */
|
| + tmp6 = tmp12 - tmp7; /* phase 2 */
|
| tmp5 = tmp11 - tmp6;
|
| tmp4 = tmp10 + tmp5;
|
|
|
| @@ -269,11 +272,11 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
|
| wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
|
|
|
| - inptr++; /* advance pointers to next column */
|
| + inptr++; /* advance pointers to next column */
|
| quantptr++;
|
| wsptr++;
|
| }
|
| -
|
| +
|
| /* Pass 2: process rows from work array, store into output array. */
|
| /* Note that we must descale the results by a factor of 8 == 2**3, */
|
| /* and also undo the PASS1_BITS scaling. */
|
| @@ -288,14 +291,14 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| * test takes more time than it's worth. In that case this section
|
| * may be commented out.
|
| */
|
| -
|
| +
|
| #ifndef NO_ZERO_ROW_TEST
|
| if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
|
| - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
| + wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
| /* AC terms all zero */
|
| JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| -
|
| + & RANGE_MASK];
|
| +
|
| outptr[0] = dcval;
|
| outptr[1] = dcval;
|
| outptr[2] = dcval;
|
| @@ -305,11 +308,11 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| outptr[6] = dcval;
|
| outptr[7] = dcval;
|
|
|
| - wsptr += DCTSIZE; /* advance pointer to next row */
|
| + wsptr += DCTSIZE; /* advance pointer to next row */
|
| continue;
|
| }
|
| #endif
|
| -
|
| +
|
| /* Even part */
|
|
|
| tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
|
| @@ -317,7 +320,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|
|
| tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
|
| tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
|
| - - tmp13;
|
| + - tmp13;
|
|
|
| tmp0 = tmp10 + tmp13;
|
| tmp3 = tmp10 - tmp13;
|
| @@ -331,37 +334,37 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
|
| z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
|
|
|
| - tmp7 = z11 + z13; /* phase 5 */
|
| + tmp7 = z11 + z13; /* phase 5 */
|
| tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
|
|
| z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
| tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
| tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
|
|
| - tmp6 = tmp12 - tmp7; /* phase 2 */
|
| + tmp6 = tmp12 - tmp7; /* phase 2 */
|
| tmp5 = tmp11 - tmp6;
|
| tmp4 = tmp10 + tmp5;
|
|
|
| /* Final output stage: scale down by a factor of 8 and range-limit */
|
|
|
| outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
| outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
|
| - & RANGE_MASK];
|
| + & RANGE_MASK];
|
|
|
| - wsptr += DCTSIZE; /* advance pointer to next row */
|
| + wsptr += DCTSIZE; /* advance pointer to next row */
|
| }
|
| }
|
|
|
|
|