/* * jidctred.c * * This file was part of the Independent JPEG Group's software: * Copyright (C) 1994-1998, Thomas G. Lane. * libjpeg-turbo Modifications: * Copyright (C) 2015, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * * This file contains inverse-DCT routines that produce reduced-size output: * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. * * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step * with an 8-to-4 step that produces the four averages of two adjacent outputs * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). * These steps were derived by computing the corresponding values at the end * of the normal LL&M code, then simplifying as much as possible. * * 1x1 is trivial: just take the DC coefficient divided by 8. * * See jidctint.c for additional comments. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #include "jdct.h" /* Private declarations for DCT subsystem */ #ifdef IDCT_SCALING_SUPPORTED /* * This module is specialized to the case DCTSIZE = 8. */ #if DCTSIZE != 8 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ #endif /* Scaling is the same as in jidctint.c. */ #if BITS_IN_JSAMPLE == 8 #define CONST_BITS … #define PASS1_BITS … #else #define CONST_BITS … #define PASS1_BITS … #endif /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus * causing a lot of useless floating-point operations at run time. * To get around this we use the following pre-calculated constants. * If you change CONST_BITS you may want to add appropriate values. * (With a reasonable C compiler, you can just rely on the FIX() macro...) */ #if CONST_BITS == 13 #define FIX_0_211164243 … #define FIX_0_509795579 … #define FIX_0_601344887 … #define FIX_0_720959822 … #define FIX_0_765366865 … #define FIX_0_850430095 … #define FIX_0_899976223 … #define FIX_1_061594337 … #define FIX_1_272758580 … #define FIX_1_451774981 … #define FIX_1_847759065 … #define FIX_2_172734803 … #define FIX_2_562915447 … #define FIX_3_624509785 … #else #define FIX_0_211164243 … #define FIX_0_509795579 … #define FIX_0_601344887 … #define FIX_0_720959822 … #define FIX_0_765366865 … #define FIX_0_850430095 … #define FIX_0_899976223 … #define FIX_1_061594337 … #define FIX_1_272758580 … #define FIX_1_451774981 … #define FIX_1_847759065 … #define FIX_2_172734803 … #define FIX_2_562915447 … #define FIX_3_624509785 … #endif /* Multiply a JLONG variable by a JLONG constant to yield a JLONG result. * For 8-bit samples with the recommended scaling, all the variable * and constant values involved are no more than 16 bits wide, so a * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. * For 12-bit samples, a full 32-bit multiplication will be needed. */ #if BITS_IN_JSAMPLE == 8 #define MULTIPLY(var, const) … #else #define MULTIPLY … #endif /* Dequantize a coefficient by multiplying it by the multiplier-table * entry; produce an int result. In this module, both inputs and result * are 16 bits or less, so either int or short multiply will work. */ #define DEQUANTIZE(coef, quantval) … /* * Perform dequantization and inverse DCT on one block of coefficients, * producing a reduced-size 4x4 output block. */ GLOBAL(void) jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) { … } /* * Perform dequantization and inverse DCT on one block of coefficients, * producing a reduced-size 2x2 output block. */ GLOBAL(void) jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) { … } /* * Perform dequantization and inverse DCT on one block of coefficients, * producing a reduced-size 1x1 output block. */ GLOBAL(void) jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) { … } #endif /* IDCT_SCALING_SUPPORTED */