Final 350 project

Dependencies:   uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed

Committer:
shoaib_ahmed
Date:
Mon Jul 31 09:16:35 2017 +0000
Revision:
0:791a779d6220
final project;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shoaib_ahmed 0:791a779d6220 1 /*
shoaib_ahmed 0:791a779d6220 2 * jfdctint.c
shoaib_ahmed 0:791a779d6220 3 *
shoaib_ahmed 0:791a779d6220 4 * Copyright (C) 1991-1996, Thomas G. Lane.
shoaib_ahmed 0:791a779d6220 5 * Modification developed 2003-2015 by Guido Vollbeding.
shoaib_ahmed 0:791a779d6220 6 * This file is part of the Independent JPEG Group's software.
shoaib_ahmed 0:791a779d6220 7 * For conditions of distribution and use, see the accompanying README file.
shoaib_ahmed 0:791a779d6220 8 *
shoaib_ahmed 0:791a779d6220 9 * This file contains a slow-but-accurate integer implementation of the
shoaib_ahmed 0:791a779d6220 10 * forward DCT (Discrete Cosine Transform).
shoaib_ahmed 0:791a779d6220 11 *
shoaib_ahmed 0:791a779d6220 12 * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
shoaib_ahmed 0:791a779d6220 13 * on each column. Direct algorithms are also available, but they are
shoaib_ahmed 0:791a779d6220 14 * much more complex and seem not to be any faster when reduced to code.
shoaib_ahmed 0:791a779d6220 15 *
shoaib_ahmed 0:791a779d6220 16 * This implementation is based on an algorithm described in
shoaib_ahmed 0:791a779d6220 17 * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
shoaib_ahmed 0:791a779d6220 18 * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
shoaib_ahmed 0:791a779d6220 19 * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
shoaib_ahmed 0:791a779d6220 20 * The primary algorithm described there uses 11 multiplies and 29 adds.
shoaib_ahmed 0:791a779d6220 21 * We use their alternate method with 12 multiplies and 32 adds.
shoaib_ahmed 0:791a779d6220 22 * The advantage of this method is that no data path contains more than one
shoaib_ahmed 0:791a779d6220 23 * multiplication; this allows a very simple and accurate implementation in
shoaib_ahmed 0:791a779d6220 24 * scaled fixed-point arithmetic, with a minimal number of shifts.
shoaib_ahmed 0:791a779d6220 25 *
shoaib_ahmed 0:791a779d6220 26 * We also provide FDCT routines with various input sample block sizes for
shoaib_ahmed 0:791a779d6220 27 * direct resolution reduction or enlargement and for direct resolving the
shoaib_ahmed 0:791a779d6220 28 * common 2x1 and 1x2 subsampling cases without additional resampling: NxN
shoaib_ahmed 0:791a779d6220 29 * (N=1...16), 2NxN, and Nx2N (N=1...8) pixels for one 8x8 output DCT block.
shoaib_ahmed 0:791a779d6220 30 *
shoaib_ahmed 0:791a779d6220 31 * For N<8 we fill the remaining block coefficients with zero.
shoaib_ahmed 0:791a779d6220 32 * For N>8 we apply a partial N-point FDCT on the input samples, computing
shoaib_ahmed 0:791a779d6220 33 * just the lower 8 frequency coefficients and discarding the rest.
shoaib_ahmed 0:791a779d6220 34 *
shoaib_ahmed 0:791a779d6220 35 * We must scale the output coefficients of the N-point FDCT appropriately
shoaib_ahmed 0:791a779d6220 36 * to the standard 8-point FDCT level by 8/N per 1-D pass. This scaling
shoaib_ahmed 0:791a779d6220 37 * is folded into the constant multipliers (pass 2) and/or final/initial
shoaib_ahmed 0:791a779d6220 38 * shifting.
shoaib_ahmed 0:791a779d6220 39 *
shoaib_ahmed 0:791a779d6220 40 * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases
shoaib_ahmed 0:791a779d6220 41 * since there would be too many additional constants to pre-calculate.
shoaib_ahmed 0:791a779d6220 42 */
shoaib_ahmed 0:791a779d6220 43
shoaib_ahmed 0:791a779d6220 44 #define JPEG_INTERNALS
shoaib_ahmed 0:791a779d6220 45 #include "jinclude.h"
shoaib_ahmed 0:791a779d6220 46 #include "jpeglib.h"
shoaib_ahmed 0:791a779d6220 47 #include "jdct.h" /* Private declarations for DCT subsystem */
shoaib_ahmed 0:791a779d6220 48
shoaib_ahmed 0:791a779d6220 49 #ifdef DCT_ISLOW_SUPPORTED
shoaib_ahmed 0:791a779d6220 50
shoaib_ahmed 0:791a779d6220 51
shoaib_ahmed 0:791a779d6220 52 /*
shoaib_ahmed 0:791a779d6220 53 * This module is specialized to the case DCTSIZE = 8.
shoaib_ahmed 0:791a779d6220 54 */
shoaib_ahmed 0:791a779d6220 55
shoaib_ahmed 0:791a779d6220 56 #if DCTSIZE != 8
shoaib_ahmed 0:791a779d6220 57 Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
shoaib_ahmed 0:791a779d6220 58 #endif
shoaib_ahmed 0:791a779d6220 59
shoaib_ahmed 0:791a779d6220 60
shoaib_ahmed 0:791a779d6220 61 /*
shoaib_ahmed 0:791a779d6220 62 * The poop on this scaling stuff is as follows:
shoaib_ahmed 0:791a779d6220 63 *
shoaib_ahmed 0:791a779d6220 64 * Each 1-D DCT step produces outputs which are a factor of sqrt(N)
shoaib_ahmed 0:791a779d6220 65 * larger than the true DCT outputs. The final outputs are therefore
shoaib_ahmed 0:791a779d6220 66 * a factor of N larger than desired; since N=8 this can be cured by
shoaib_ahmed 0:791a779d6220 67 * a simple right shift at the end of the algorithm. The advantage of
shoaib_ahmed 0:791a779d6220 68 * this arrangement is that we save two multiplications per 1-D DCT,
shoaib_ahmed 0:791a779d6220 69 * because the y0 and y4 outputs need not be divided by sqrt(N).
shoaib_ahmed 0:791a779d6220 70 * In the IJG code, this factor of 8 is removed by the quantization step
shoaib_ahmed 0:791a779d6220 71 * (in jcdctmgr.c), NOT in this module.
shoaib_ahmed 0:791a779d6220 72 *
shoaib_ahmed 0:791a779d6220 73 * We have to do addition and subtraction of the integer inputs, which
shoaib_ahmed 0:791a779d6220 74 * is no problem, and multiplication by fractional constants, which is
shoaib_ahmed 0:791a779d6220 75 * a problem to do in integer arithmetic. We multiply all the constants
shoaib_ahmed 0:791a779d6220 76 * by CONST_SCALE and convert them to integer constants (thus retaining
shoaib_ahmed 0:791a779d6220 77 * CONST_BITS bits of precision in the constants). After doing a
shoaib_ahmed 0:791a779d6220 78 * multiplication we have to divide the product by CONST_SCALE, with proper
shoaib_ahmed 0:791a779d6220 79 * rounding, to produce the correct output. This division can be done
shoaib_ahmed 0:791a779d6220 80 * cheaply as a right shift of CONST_BITS bits. We postpone shifting
shoaib_ahmed 0:791a779d6220 81 * as long as possible so that partial sums can be added together with
shoaib_ahmed 0:791a779d6220 82 * full fractional precision.
shoaib_ahmed 0:791a779d6220 83 *
shoaib_ahmed 0:791a779d6220 84 * The outputs of the first pass are scaled up by PASS1_BITS bits so that
shoaib_ahmed 0:791a779d6220 85 * they are represented to better-than-integral precision. These outputs
shoaib_ahmed 0:791a779d6220 86 * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
shoaib_ahmed 0:791a779d6220 87 * with the recommended scaling. (For 12-bit sample data, the intermediate
shoaib_ahmed 0:791a779d6220 88 * array is INT32 anyway.)
shoaib_ahmed 0:791a779d6220 89 *
shoaib_ahmed 0:791a779d6220 90 * To avoid overflow of the 32-bit intermediate results in pass 2, we must
shoaib_ahmed 0:791a779d6220 91 * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
shoaib_ahmed 0:791a779d6220 92 * shows that the values given below are the most effective.
shoaib_ahmed 0:791a779d6220 93 */
shoaib_ahmed 0:791a779d6220 94
shoaib_ahmed 0:791a779d6220 95 #if BITS_IN_JSAMPLE == 8
shoaib_ahmed 0:791a779d6220 96 #define CONST_BITS 13
shoaib_ahmed 0:791a779d6220 97 #define PASS1_BITS 2
shoaib_ahmed 0:791a779d6220 98 #else
shoaib_ahmed 0:791a779d6220 99 #define CONST_BITS 13
shoaib_ahmed 0:791a779d6220 100 #define PASS1_BITS 1 /* lose a little precision to avoid overflow */
shoaib_ahmed 0:791a779d6220 101 #endif
shoaib_ahmed 0:791a779d6220 102
shoaib_ahmed 0:791a779d6220 103 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
shoaib_ahmed 0:791a779d6220 104 * causing a lot of useless floating-point operations at run time.
shoaib_ahmed 0:791a779d6220 105 * To get around this we use the following pre-calculated constants.
shoaib_ahmed 0:791a779d6220 106 * If you change CONST_BITS you may want to add appropriate values.
shoaib_ahmed 0:791a779d6220 107 * (With a reasonable C compiler, you can just rely on the FIX() macro...)
shoaib_ahmed 0:791a779d6220 108 */
shoaib_ahmed 0:791a779d6220 109
shoaib_ahmed 0:791a779d6220 110 #if CONST_BITS == 13
shoaib_ahmed 0:791a779d6220 111 #define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
shoaib_ahmed 0:791a779d6220 112 #define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
shoaib_ahmed 0:791a779d6220 113 #define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */
shoaib_ahmed 0:791a779d6220 114 #define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
shoaib_ahmed 0:791a779d6220 115 #define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
shoaib_ahmed 0:791a779d6220 116 #define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */
shoaib_ahmed 0:791a779d6220 117 #define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */
shoaib_ahmed 0:791a779d6220 118 #define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
shoaib_ahmed 0:791a779d6220 119 #define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */
shoaib_ahmed 0:791a779d6220 120 #define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */
shoaib_ahmed 0:791a779d6220 121 #define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
shoaib_ahmed 0:791a779d6220 122 #define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */
shoaib_ahmed 0:791a779d6220 123 #else
shoaib_ahmed 0:791a779d6220 124 #define FIX_0_298631336 FIX(0.298631336)
shoaib_ahmed 0:791a779d6220 125 #define FIX_0_390180644 FIX(0.390180644)
shoaib_ahmed 0:791a779d6220 126 #define FIX_0_541196100 FIX(0.541196100)
shoaib_ahmed 0:791a779d6220 127 #define FIX_0_765366865 FIX(0.765366865)
shoaib_ahmed 0:791a779d6220 128 #define FIX_0_899976223 FIX(0.899976223)
shoaib_ahmed 0:791a779d6220 129 #define FIX_1_175875602 FIX(1.175875602)
shoaib_ahmed 0:791a779d6220 130 #define FIX_1_501321110 FIX(1.501321110)
shoaib_ahmed 0:791a779d6220 131 #define FIX_1_847759065 FIX(1.847759065)
shoaib_ahmed 0:791a779d6220 132 #define FIX_1_961570560 FIX(1.961570560)
shoaib_ahmed 0:791a779d6220 133 #define FIX_2_053119869 FIX(2.053119869)
shoaib_ahmed 0:791a779d6220 134 #define FIX_2_562915447 FIX(2.562915447)
shoaib_ahmed 0:791a779d6220 135 #define FIX_3_072711026 FIX(3.072711026)
shoaib_ahmed 0:791a779d6220 136 #endif
shoaib_ahmed 0:791a779d6220 137
shoaib_ahmed 0:791a779d6220 138
shoaib_ahmed 0:791a779d6220 139 /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
shoaib_ahmed 0:791a779d6220 140 * For 8-bit samples with the recommended scaling, all the variable
shoaib_ahmed 0:791a779d6220 141 * and constant values involved are no more than 16 bits wide, so a
shoaib_ahmed 0:791a779d6220 142 * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
shoaib_ahmed 0:791a779d6220 143 * For 12-bit samples, a full 32-bit multiplication will be needed.
shoaib_ahmed 0:791a779d6220 144 */
shoaib_ahmed 0:791a779d6220 145
shoaib_ahmed 0:791a779d6220 146 #if BITS_IN_JSAMPLE == 8
shoaib_ahmed 0:791a779d6220 147 #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
shoaib_ahmed 0:791a779d6220 148 #else
shoaib_ahmed 0:791a779d6220 149 #define MULTIPLY(var,const) ((var) * (const))
shoaib_ahmed 0:791a779d6220 150 #endif
shoaib_ahmed 0:791a779d6220 151
shoaib_ahmed 0:791a779d6220 152
shoaib_ahmed 0:791a779d6220 153 /*
shoaib_ahmed 0:791a779d6220 154 * Perform the forward DCT on one block of samples.
shoaib_ahmed 0:791a779d6220 155 */
shoaib_ahmed 0:791a779d6220 156
shoaib_ahmed 0:791a779d6220 157 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 158 jpeg_fdct_islow (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 159 {
shoaib_ahmed 0:791a779d6220 160 INT32 tmp0, tmp1, tmp2, tmp3;
shoaib_ahmed 0:791a779d6220 161 INT32 tmp10, tmp11, tmp12, tmp13;
shoaib_ahmed 0:791a779d6220 162 INT32 z1;
shoaib_ahmed 0:791a779d6220 163 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 164 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 165 int ctr;
shoaib_ahmed 0:791a779d6220 166 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 167
shoaib_ahmed 0:791a779d6220 168 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 169 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 170 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 171 * cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 172 */
shoaib_ahmed 0:791a779d6220 173
shoaib_ahmed 0:791a779d6220 174 dataptr = data;
shoaib_ahmed 0:791a779d6220 175 for (ctr = 0; ctr < DCTSIZE; ctr++) {
shoaib_ahmed 0:791a779d6220 176 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 177
shoaib_ahmed 0:791a779d6220 178 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 179 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 180 */
shoaib_ahmed 0:791a779d6220 181
shoaib_ahmed 0:791a779d6220 182 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 183 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 184 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 185 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 186
shoaib_ahmed 0:791a779d6220 187 tmp10 = tmp0 + tmp3;
shoaib_ahmed 0:791a779d6220 188 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 189 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 190 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 191
shoaib_ahmed 0:791a779d6220 192 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 193 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 194 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 195 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 196
shoaib_ahmed 0:791a779d6220 197 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 198 dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 199 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 200
shoaib_ahmed 0:791a779d6220 201 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 202 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 203 z1 += ONE << (CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 204
shoaib_ahmed 0:791a779d6220 205 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 206 RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 207 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 208 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 209 RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 210 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 211
shoaib_ahmed 0:791a779d6220 212 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 213 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 214 */
shoaib_ahmed 0:791a779d6220 215
shoaib_ahmed 0:791a779d6220 216 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 217 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 218
shoaib_ahmed 0:791a779d6220 219 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 220 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 221 z1 += ONE << (CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 222
shoaib_ahmed 0:791a779d6220 223 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 224 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 225 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 226 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 227
shoaib_ahmed 0:791a779d6220 228 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 229 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 230 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 231 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 232 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 233
shoaib_ahmed 0:791a779d6220 234 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 235 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 236 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 237 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 238 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 239
shoaib_ahmed 0:791a779d6220 240 dataptr[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 241 dataptr[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 242 dataptr[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 243 dataptr[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 244
shoaib_ahmed 0:791a779d6220 245 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 246 }
shoaib_ahmed 0:791a779d6220 247
shoaib_ahmed 0:791a779d6220 248 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 249 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 250 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 251 * cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 252 */
shoaib_ahmed 0:791a779d6220 253
shoaib_ahmed 0:791a779d6220 254 dataptr = data;
shoaib_ahmed 0:791a779d6220 255 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 256 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 257 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 258 */
shoaib_ahmed 0:791a779d6220 259
shoaib_ahmed 0:791a779d6220 260 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 261 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 262 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 263 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 264
shoaib_ahmed 0:791a779d6220 265 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 266 tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1));
shoaib_ahmed 0:791a779d6220 267 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 268 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 269 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 270
shoaib_ahmed 0:791a779d6220 271 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 272 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 273 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 274 tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 275
shoaib_ahmed 0:791a779d6220 276 dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 277 dataptr[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 278
shoaib_ahmed 0:791a779d6220 279 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 280 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 281 z1 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 282
shoaib_ahmed 0:791a779d6220 283 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 284 RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 285 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 286 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 287 RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 288 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 289
shoaib_ahmed 0:791a779d6220 290 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 291 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 292 */
shoaib_ahmed 0:791a779d6220 293
shoaib_ahmed 0:791a779d6220 294 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 295 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 296
shoaib_ahmed 0:791a779d6220 297 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 298 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 299 z1 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 300
shoaib_ahmed 0:791a779d6220 301 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 302 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 303 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 304 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 305
shoaib_ahmed 0:791a779d6220 306 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 307 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 308 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 309 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 310 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 311
shoaib_ahmed 0:791a779d6220 312 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 313 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 314 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 315 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 316 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 317
shoaib_ahmed 0:791a779d6220 318 dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 319 dataptr[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 320 dataptr[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 321 dataptr[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 322
shoaib_ahmed 0:791a779d6220 323 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 324 }
shoaib_ahmed 0:791a779d6220 325 }
shoaib_ahmed 0:791a779d6220 326
shoaib_ahmed 0:791a779d6220 327 #ifdef DCT_SCALING_SUPPORTED
shoaib_ahmed 0:791a779d6220 328
shoaib_ahmed 0:791a779d6220 329
shoaib_ahmed 0:791a779d6220 330 /*
shoaib_ahmed 0:791a779d6220 331 * Perform the forward DCT on a 7x7 sample block.
shoaib_ahmed 0:791a779d6220 332 */
shoaib_ahmed 0:791a779d6220 333
shoaib_ahmed 0:791a779d6220 334 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 335 jpeg_fdct_7x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 336 {
shoaib_ahmed 0:791a779d6220 337 INT32 tmp0, tmp1, tmp2, tmp3;
shoaib_ahmed 0:791a779d6220 338 INT32 tmp10, tmp11, tmp12;
shoaib_ahmed 0:791a779d6220 339 INT32 z1, z2, z3;
shoaib_ahmed 0:791a779d6220 340 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 341 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 342 int ctr;
shoaib_ahmed 0:791a779d6220 343 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 344
shoaib_ahmed 0:791a779d6220 345 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 346 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 347
shoaib_ahmed 0:791a779d6220 348 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 349 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 350 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 351 * cK represents sqrt(2) * cos(K*pi/14).
shoaib_ahmed 0:791a779d6220 352 */
shoaib_ahmed 0:791a779d6220 353
shoaib_ahmed 0:791a779d6220 354 dataptr = data;
shoaib_ahmed 0:791a779d6220 355 for (ctr = 0; ctr < 7; ctr++) {
shoaib_ahmed 0:791a779d6220 356 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 357
shoaib_ahmed 0:791a779d6220 358 /* Even part */
shoaib_ahmed 0:791a779d6220 359
shoaib_ahmed 0:791a779d6220 360 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 361 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 362 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 363 tmp3 = GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 364
shoaib_ahmed 0:791a779d6220 365 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 366 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 367 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 368
shoaib_ahmed 0:791a779d6220 369 z1 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 370 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 371 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 372 ((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 373 tmp3 += tmp3;
shoaib_ahmed 0:791a779d6220 374 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 375 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 376 z1 = MULTIPLY(z1, FIX(0.353553391)); /* (c2+c6-c4)/2 */
shoaib_ahmed 0:791a779d6220 377 z2 = MULTIPLY(tmp0 - tmp2, FIX(0.920609002)); /* (c2+c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 378 z3 = MULTIPLY(tmp1 - tmp2, FIX(0.314692123)); /* c6 */
shoaib_ahmed 0:791a779d6220 379 dataptr[2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 380 z1 -= z2;
shoaib_ahmed 0:791a779d6220 381 z2 = MULTIPLY(tmp0 - tmp1, FIX(0.881747734)); /* c4 */
shoaib_ahmed 0:791a779d6220 382 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 383 DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.707106781)), /* c2+c6-c4 */
shoaib_ahmed 0:791a779d6220 384 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 385 dataptr[6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 386
shoaib_ahmed 0:791a779d6220 387 /* Odd part */
shoaib_ahmed 0:791a779d6220 388
shoaib_ahmed 0:791a779d6220 389 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(0.935414347)); /* (c3+c1-c5)/2 */
shoaib_ahmed 0:791a779d6220 390 tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.170262339)); /* (c3+c5-c1)/2 */
shoaib_ahmed 0:791a779d6220 391 tmp0 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 392 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 393 tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.378756276)); /* -c1 */
shoaib_ahmed 0:791a779d6220 394 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 395 tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.613604268)); /* c5 */
shoaib_ahmed 0:791a779d6220 396 tmp0 += tmp3;
shoaib_ahmed 0:791a779d6220 397 tmp2 += tmp3 + MULTIPLY(tmp12, FIX(1.870828693)); /* c3+c1-c5 */
shoaib_ahmed 0:791a779d6220 398
shoaib_ahmed 0:791a779d6220 399 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 400 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 401 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 402
shoaib_ahmed 0:791a779d6220 403 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 404 }
shoaib_ahmed 0:791a779d6220 405
shoaib_ahmed 0:791a779d6220 406 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 407 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 408 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 409 * We must also scale the output by (8/7)**2 = 64/49, which we fold
shoaib_ahmed 0:791a779d6220 410 * into the constant multipliers:
shoaib_ahmed 0:791a779d6220 411 * cK now represents sqrt(2) * cos(K*pi/14) * 64/49.
shoaib_ahmed 0:791a779d6220 412 */
shoaib_ahmed 0:791a779d6220 413
shoaib_ahmed 0:791a779d6220 414 dataptr = data;
shoaib_ahmed 0:791a779d6220 415 for (ctr = 0; ctr < 7; ctr++) {
shoaib_ahmed 0:791a779d6220 416 /* Even part */
shoaib_ahmed 0:791a779d6220 417
shoaib_ahmed 0:791a779d6220 418 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 419 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 420 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 421 tmp3 = dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 422
shoaib_ahmed 0:791a779d6220 423 tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 424 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 425 tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 426
shoaib_ahmed 0:791a779d6220 427 z1 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 428 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 429 DESCALE(MULTIPLY(z1 + tmp1 + tmp3, FIX(1.306122449)), /* 64/49 */
shoaib_ahmed 0:791a779d6220 430 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 431 tmp3 += tmp3;
shoaib_ahmed 0:791a779d6220 432 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 433 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 434 z1 = MULTIPLY(z1, FIX(0.461784020)); /* (c2+c6-c4)/2 */
shoaib_ahmed 0:791a779d6220 435 z2 = MULTIPLY(tmp0 - tmp2, FIX(1.202428084)); /* (c2+c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 436 z3 = MULTIPLY(tmp1 - tmp2, FIX(0.411026446)); /* c6 */
shoaib_ahmed 0:791a779d6220 437 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 438 z1 -= z2;
shoaib_ahmed 0:791a779d6220 439 z2 = MULTIPLY(tmp0 - tmp1, FIX(1.151670509)); /* c4 */
shoaib_ahmed 0:791a779d6220 440 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 441 DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.923568041)), /* c2+c6-c4 */
shoaib_ahmed 0:791a779d6220 442 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 443 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 444
shoaib_ahmed 0:791a779d6220 445 /* Odd part */
shoaib_ahmed 0:791a779d6220 446
shoaib_ahmed 0:791a779d6220 447 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.221765677)); /* (c3+c1-c5)/2 */
shoaib_ahmed 0:791a779d6220 448 tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.222383464)); /* (c3+c5-c1)/2 */
shoaib_ahmed 0:791a779d6220 449 tmp0 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 450 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 451 tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.800824523)); /* -c1 */
shoaib_ahmed 0:791a779d6220 452 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 453 tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.801442310)); /* c5 */
shoaib_ahmed 0:791a779d6220 454 tmp0 += tmp3;
shoaib_ahmed 0:791a779d6220 455 tmp2 += tmp3 + MULTIPLY(tmp12, FIX(2.443531355)); /* c3+c1-c5 */
shoaib_ahmed 0:791a779d6220 456
shoaib_ahmed 0:791a779d6220 457 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 458 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 459 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 460
shoaib_ahmed 0:791a779d6220 461 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 462 }
shoaib_ahmed 0:791a779d6220 463 }
shoaib_ahmed 0:791a779d6220 464
shoaib_ahmed 0:791a779d6220 465
shoaib_ahmed 0:791a779d6220 466 /*
shoaib_ahmed 0:791a779d6220 467 * Perform the forward DCT on a 6x6 sample block.
shoaib_ahmed 0:791a779d6220 468 */
shoaib_ahmed 0:791a779d6220 469
shoaib_ahmed 0:791a779d6220 470 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 471 jpeg_fdct_6x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 472 {
shoaib_ahmed 0:791a779d6220 473 INT32 tmp0, tmp1, tmp2;
shoaib_ahmed 0:791a779d6220 474 INT32 tmp10, tmp11, tmp12;
shoaib_ahmed 0:791a779d6220 475 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 476 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 477 int ctr;
shoaib_ahmed 0:791a779d6220 478 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 479
shoaib_ahmed 0:791a779d6220 480 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 481 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 482
shoaib_ahmed 0:791a779d6220 483 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 484 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 485 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 486 * cK represents sqrt(2) * cos(K*pi/12).
shoaib_ahmed 0:791a779d6220 487 */
shoaib_ahmed 0:791a779d6220 488
shoaib_ahmed 0:791a779d6220 489 dataptr = data;
shoaib_ahmed 0:791a779d6220 490 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 491 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 492
shoaib_ahmed 0:791a779d6220 493 /* Even part */
shoaib_ahmed 0:791a779d6220 494
shoaib_ahmed 0:791a779d6220 495 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 496 tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 497 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 498
shoaib_ahmed 0:791a779d6220 499 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 500 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 501
shoaib_ahmed 0:791a779d6220 502 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 503 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 504 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 505
shoaib_ahmed 0:791a779d6220 506 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 507 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 508 ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 509 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 510 DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */
shoaib_ahmed 0:791a779d6220 511 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 512 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 513 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */
shoaib_ahmed 0:791a779d6220 514 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 515
shoaib_ahmed 0:791a779d6220 516 /* Odd part */
shoaib_ahmed 0:791a779d6220 517
shoaib_ahmed 0:791a779d6220 518 tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */
shoaib_ahmed 0:791a779d6220 519 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 520
shoaib_ahmed 0:791a779d6220 521 dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << PASS1_BITS));
shoaib_ahmed 0:791a779d6220 522 dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 523 dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << PASS1_BITS));
shoaib_ahmed 0:791a779d6220 524
shoaib_ahmed 0:791a779d6220 525 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 526 }
shoaib_ahmed 0:791a779d6220 527
shoaib_ahmed 0:791a779d6220 528 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 529 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 530 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 531 * We must also scale the output by (8/6)**2 = 16/9, which we fold
shoaib_ahmed 0:791a779d6220 532 * into the constant multipliers:
shoaib_ahmed 0:791a779d6220 533 * cK now represents sqrt(2) * cos(K*pi/12) * 16/9.
shoaib_ahmed 0:791a779d6220 534 */
shoaib_ahmed 0:791a779d6220 535
shoaib_ahmed 0:791a779d6220 536 dataptr = data;
shoaib_ahmed 0:791a779d6220 537 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 538 /* Even part */
shoaib_ahmed 0:791a779d6220 539
shoaib_ahmed 0:791a779d6220 540 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 541 tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 542 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 543
shoaib_ahmed 0:791a779d6220 544 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 545 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 546
shoaib_ahmed 0:791a779d6220 547 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 548 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 549 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 550
shoaib_ahmed 0:791a779d6220 551 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 552 DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 553 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 554 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 555 DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */
shoaib_ahmed 0:791a779d6220 556 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 557 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 558 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */
shoaib_ahmed 0:791a779d6220 559 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 560
shoaib_ahmed 0:791a779d6220 561 /* Odd part */
shoaib_ahmed 0:791a779d6220 562
shoaib_ahmed 0:791a779d6220 563 tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */
shoaib_ahmed 0:791a779d6220 564
shoaib_ahmed 0:791a779d6220 565 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 566 DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 567 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 568 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 569 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 570 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 571 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 572 DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 573 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 574
shoaib_ahmed 0:791a779d6220 575 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 576 }
shoaib_ahmed 0:791a779d6220 577 }
shoaib_ahmed 0:791a779d6220 578
shoaib_ahmed 0:791a779d6220 579
shoaib_ahmed 0:791a779d6220 580 /*
shoaib_ahmed 0:791a779d6220 581 * Perform the forward DCT on a 5x5 sample block.
shoaib_ahmed 0:791a779d6220 582 */
shoaib_ahmed 0:791a779d6220 583
shoaib_ahmed 0:791a779d6220 584 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 585 jpeg_fdct_5x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 586 {
shoaib_ahmed 0:791a779d6220 587 INT32 tmp0, tmp1, tmp2;
shoaib_ahmed 0:791a779d6220 588 INT32 tmp10, tmp11;
shoaib_ahmed 0:791a779d6220 589 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 590 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 591 int ctr;
shoaib_ahmed 0:791a779d6220 592 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 593
shoaib_ahmed 0:791a779d6220 594 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 595 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 596
shoaib_ahmed 0:791a779d6220 597 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 598 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 599 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 600 * We scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 601 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 602 * cK represents sqrt(2) * cos(K*pi/10).
shoaib_ahmed 0:791a779d6220 603 */
shoaib_ahmed 0:791a779d6220 604
shoaib_ahmed 0:791a779d6220 605 dataptr = data;
shoaib_ahmed 0:791a779d6220 606 for (ctr = 0; ctr < 5; ctr++) {
shoaib_ahmed 0:791a779d6220 607 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 608
shoaib_ahmed 0:791a779d6220 609 /* Even part */
shoaib_ahmed 0:791a779d6220 610
shoaib_ahmed 0:791a779d6220 611 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 612 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 613 tmp2 = GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 614
shoaib_ahmed 0:791a779d6220 615 tmp10 = tmp0 + tmp1;
shoaib_ahmed 0:791a779d6220 616 tmp11 = tmp0 - tmp1;
shoaib_ahmed 0:791a779d6220 617
shoaib_ahmed 0:791a779d6220 618 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 619 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 620
shoaib_ahmed 0:791a779d6220 621 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 622 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 623 ((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 624 tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */
shoaib_ahmed 0:791a779d6220 625 tmp10 -= tmp2 << 2;
shoaib_ahmed 0:791a779d6220 626 tmp10 = MULTIPLY(tmp10, FIX(0.353553391)); /* (c2-c4)/2 */
shoaib_ahmed 0:791a779d6220 627 dataptr[2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 628 dataptr[4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 629
shoaib_ahmed 0:791a779d6220 630 /* Odd part */
shoaib_ahmed 0:791a779d6220 631
shoaib_ahmed 0:791a779d6220 632 tmp10 = MULTIPLY(tmp0 + tmp1, FIX(0.831253876)); /* c3 */
shoaib_ahmed 0:791a779d6220 633
shoaib_ahmed 0:791a779d6220 634 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 635 DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.513743148)), /* c1-c3 */
shoaib_ahmed 0:791a779d6220 636 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 637 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 638 DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.176250899)), /* c1+c3 */
shoaib_ahmed 0:791a779d6220 639 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 640
shoaib_ahmed 0:791a779d6220 641 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 642 }
shoaib_ahmed 0:791a779d6220 643
shoaib_ahmed 0:791a779d6220 644 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 645 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 646 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 647 * We must also scale the output by (8/5)**2 = 64/25, which we partially
shoaib_ahmed 0:791a779d6220 648 * fold into the constant multipliers (other part was done in pass 1):
shoaib_ahmed 0:791a779d6220 649 * cK now represents sqrt(2) * cos(K*pi/10) * 32/25.
shoaib_ahmed 0:791a779d6220 650 */
shoaib_ahmed 0:791a779d6220 651
shoaib_ahmed 0:791a779d6220 652 dataptr = data;
shoaib_ahmed 0:791a779d6220 653 for (ctr = 0; ctr < 5; ctr++) {
shoaib_ahmed 0:791a779d6220 654 /* Even part */
shoaib_ahmed 0:791a779d6220 655
shoaib_ahmed 0:791a779d6220 656 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 657 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 658 tmp2 = dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 659
shoaib_ahmed 0:791a779d6220 660 tmp10 = tmp0 + tmp1;
shoaib_ahmed 0:791a779d6220 661 tmp11 = tmp0 - tmp1;
shoaib_ahmed 0:791a779d6220 662
shoaib_ahmed 0:791a779d6220 663 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 664 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 665
shoaib_ahmed 0:791a779d6220 666 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 667 DESCALE(MULTIPLY(tmp10 + tmp2, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 668 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 669 tmp11 = MULTIPLY(tmp11, FIX(1.011928851)); /* (c2+c4)/2 */
shoaib_ahmed 0:791a779d6220 670 tmp10 -= tmp2 << 2;
shoaib_ahmed 0:791a779d6220 671 tmp10 = MULTIPLY(tmp10, FIX(0.452548340)); /* (c2-c4)/2 */
shoaib_ahmed 0:791a779d6220 672 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 673 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 674
shoaib_ahmed 0:791a779d6220 675 /* Odd part */
shoaib_ahmed 0:791a779d6220 676
shoaib_ahmed 0:791a779d6220 677 tmp10 = MULTIPLY(tmp0 + tmp1, FIX(1.064004961)); /* c3 */
shoaib_ahmed 0:791a779d6220 678
shoaib_ahmed 0:791a779d6220 679 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 680 DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.657591230)), /* c1-c3 */
shoaib_ahmed 0:791a779d6220 681 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 682 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 683 DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.785601151)), /* c1+c3 */
shoaib_ahmed 0:791a779d6220 684 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 685
shoaib_ahmed 0:791a779d6220 686 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 687 }
shoaib_ahmed 0:791a779d6220 688 }
shoaib_ahmed 0:791a779d6220 689
shoaib_ahmed 0:791a779d6220 690
shoaib_ahmed 0:791a779d6220 691 /*
shoaib_ahmed 0:791a779d6220 692 * Perform the forward DCT on a 4x4 sample block.
shoaib_ahmed 0:791a779d6220 693 */
shoaib_ahmed 0:791a779d6220 694
shoaib_ahmed 0:791a779d6220 695 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 696 jpeg_fdct_4x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 697 {
shoaib_ahmed 0:791a779d6220 698 INT32 tmp0, tmp1;
shoaib_ahmed 0:791a779d6220 699 INT32 tmp10, tmp11;
shoaib_ahmed 0:791a779d6220 700 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 701 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 702 int ctr;
shoaib_ahmed 0:791a779d6220 703 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 704
shoaib_ahmed 0:791a779d6220 705 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 706 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 707
shoaib_ahmed 0:791a779d6220 708 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 709 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 710 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 711 * We must also scale the output by (8/4)**2 = 2**2, which we add here.
shoaib_ahmed 0:791a779d6220 712 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 713 */
shoaib_ahmed 0:791a779d6220 714
shoaib_ahmed 0:791a779d6220 715 dataptr = data;
shoaib_ahmed 0:791a779d6220 716 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 717 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 718
shoaib_ahmed 0:791a779d6220 719 /* Even part */
shoaib_ahmed 0:791a779d6220 720
shoaib_ahmed 0:791a779d6220 721 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 722 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 723
shoaib_ahmed 0:791a779d6220 724 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 725 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 726
shoaib_ahmed 0:791a779d6220 727 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 728 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 729 ((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+2));
shoaib_ahmed 0:791a779d6220 730 dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+2));
shoaib_ahmed 0:791a779d6220 731
shoaib_ahmed 0:791a779d6220 732 /* Odd part */
shoaib_ahmed 0:791a779d6220 733
shoaib_ahmed 0:791a779d6220 734 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 735 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 736 tmp0 += ONE << (CONST_BITS-PASS1_BITS-3);
shoaib_ahmed 0:791a779d6220 737
shoaib_ahmed 0:791a779d6220 738 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 739 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 740 CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 741 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 742 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 743 CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 744
shoaib_ahmed 0:791a779d6220 745 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 746 }
shoaib_ahmed 0:791a779d6220 747
shoaib_ahmed 0:791a779d6220 748 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 749 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 750 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 751 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 752 */
shoaib_ahmed 0:791a779d6220 753
shoaib_ahmed 0:791a779d6220 754 dataptr = data;
shoaib_ahmed 0:791a779d6220 755 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 756 /* Even part */
shoaib_ahmed 0:791a779d6220 757
shoaib_ahmed 0:791a779d6220 758 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 759 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3] + (ONE << (PASS1_BITS-1));
shoaib_ahmed 0:791a779d6220 760 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 761
shoaib_ahmed 0:791a779d6220 762 tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 763 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 764
shoaib_ahmed 0:791a779d6220 765 dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 766 dataptr[DCTSIZE*2] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 767
shoaib_ahmed 0:791a779d6220 768 /* Odd part */
shoaib_ahmed 0:791a779d6220 769
shoaib_ahmed 0:791a779d6220 770 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 771 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 772 tmp0 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 773
shoaib_ahmed 0:791a779d6220 774 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 775 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 776 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 777 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 778 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 779 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 780
shoaib_ahmed 0:791a779d6220 781 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 782 }
shoaib_ahmed 0:791a779d6220 783 }
shoaib_ahmed 0:791a779d6220 784
shoaib_ahmed 0:791a779d6220 785
shoaib_ahmed 0:791a779d6220 786 /*
shoaib_ahmed 0:791a779d6220 787 * Perform the forward DCT on a 3x3 sample block.
shoaib_ahmed 0:791a779d6220 788 */
shoaib_ahmed 0:791a779d6220 789
shoaib_ahmed 0:791a779d6220 790 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 791 jpeg_fdct_3x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 792 {
shoaib_ahmed 0:791a779d6220 793 INT32 tmp0, tmp1, tmp2;
shoaib_ahmed 0:791a779d6220 794 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 795 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 796 int ctr;
shoaib_ahmed 0:791a779d6220 797 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 798
shoaib_ahmed 0:791a779d6220 799 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 800 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 801
shoaib_ahmed 0:791a779d6220 802 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 803 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 804 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 805 * We scale the results further by 2**2 as part of output adaption
shoaib_ahmed 0:791a779d6220 806 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 807 * cK represents sqrt(2) * cos(K*pi/6).
shoaib_ahmed 0:791a779d6220 808 */
shoaib_ahmed 0:791a779d6220 809
shoaib_ahmed 0:791a779d6220 810 dataptr = data;
shoaib_ahmed 0:791a779d6220 811 for (ctr = 0; ctr < 3; ctr++) {
shoaib_ahmed 0:791a779d6220 812 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 813
shoaib_ahmed 0:791a779d6220 814 /* Even part */
shoaib_ahmed 0:791a779d6220 815
shoaib_ahmed 0:791a779d6220 816 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 817 tmp1 = GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 818
shoaib_ahmed 0:791a779d6220 819 tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 820
shoaib_ahmed 0:791a779d6220 821 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 822 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 823 ((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+2));
shoaib_ahmed 0:791a779d6220 824 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 825 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(0.707106781)), /* c2 */
shoaib_ahmed 0:791a779d6220 826 CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 827
shoaib_ahmed 0:791a779d6220 828 /* Odd part */
shoaib_ahmed 0:791a779d6220 829
shoaib_ahmed 0:791a779d6220 830 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 831 DESCALE(MULTIPLY(tmp2, FIX(1.224744871)), /* c1 */
shoaib_ahmed 0:791a779d6220 832 CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 833
shoaib_ahmed 0:791a779d6220 834 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 835 }
shoaib_ahmed 0:791a779d6220 836
shoaib_ahmed 0:791a779d6220 837 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 838 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 839 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 840 * We must also scale the output by (8/3)**2 = 64/9, which we partially
shoaib_ahmed 0:791a779d6220 841 * fold into the constant multipliers (other part was done in pass 1):
shoaib_ahmed 0:791a779d6220 842 * cK now represents sqrt(2) * cos(K*pi/6) * 16/9.
shoaib_ahmed 0:791a779d6220 843 */
shoaib_ahmed 0:791a779d6220 844
shoaib_ahmed 0:791a779d6220 845 dataptr = data;
shoaib_ahmed 0:791a779d6220 846 for (ctr = 0; ctr < 3; ctr++) {
shoaib_ahmed 0:791a779d6220 847 /* Even part */
shoaib_ahmed 0:791a779d6220 848
shoaib_ahmed 0:791a779d6220 849 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 850 tmp1 = dataptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 851
shoaib_ahmed 0:791a779d6220 852 tmp2 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 853
shoaib_ahmed 0:791a779d6220 854 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 855 DESCALE(MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 856 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 857 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 858 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(1.257078722)), /* c2 */
shoaib_ahmed 0:791a779d6220 859 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 860
shoaib_ahmed 0:791a779d6220 861 /* Odd part */
shoaib_ahmed 0:791a779d6220 862
shoaib_ahmed 0:791a779d6220 863 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 864 DESCALE(MULTIPLY(tmp2, FIX(2.177324216)), /* c1 */
shoaib_ahmed 0:791a779d6220 865 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 866
shoaib_ahmed 0:791a779d6220 867 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 868 }
shoaib_ahmed 0:791a779d6220 869 }
shoaib_ahmed 0:791a779d6220 870
shoaib_ahmed 0:791a779d6220 871
shoaib_ahmed 0:791a779d6220 872 /*
shoaib_ahmed 0:791a779d6220 873 * Perform the forward DCT on a 2x2 sample block.
shoaib_ahmed 0:791a779d6220 874 */
shoaib_ahmed 0:791a779d6220 875
shoaib_ahmed 0:791a779d6220 876 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 877 jpeg_fdct_2x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 878 {
shoaib_ahmed 0:791a779d6220 879 DCTELEM tmp0, tmp1, tmp2, tmp3;
shoaib_ahmed 0:791a779d6220 880 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 881
shoaib_ahmed 0:791a779d6220 882 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 883 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 884
shoaib_ahmed 0:791a779d6220 885 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 886 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 887 */
shoaib_ahmed 0:791a779d6220 888
shoaib_ahmed 0:791a779d6220 889 /* Row 0 */
shoaib_ahmed 0:791a779d6220 890 elemptr = sample_data[0] + start_col;
shoaib_ahmed 0:791a779d6220 891
shoaib_ahmed 0:791a779d6220 892 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 893 tmp1 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 894
shoaib_ahmed 0:791a779d6220 895 /* Row 1 */
shoaib_ahmed 0:791a779d6220 896 elemptr = sample_data[1] + start_col;
shoaib_ahmed 0:791a779d6220 897
shoaib_ahmed 0:791a779d6220 898 tmp2 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 899 tmp3 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 900
shoaib_ahmed 0:791a779d6220 901 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 902 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 903 * We must also scale the output by (8/2)**2 = 2**4.
shoaib_ahmed 0:791a779d6220 904 */
shoaib_ahmed 0:791a779d6220 905
shoaib_ahmed 0:791a779d6220 906 /* Column 0 */
shoaib_ahmed 0:791a779d6220 907 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 908 data[DCTSIZE*0] = (tmp0 + tmp2 - 4 * CENTERJSAMPLE) << 4;
shoaib_ahmed 0:791a779d6220 909 data[DCTSIZE*1] = (tmp0 - tmp2) << 4;
shoaib_ahmed 0:791a779d6220 910
shoaib_ahmed 0:791a779d6220 911 /* Column 1 */
shoaib_ahmed 0:791a779d6220 912 data[DCTSIZE*0+1] = (tmp1 + tmp3) << 4;
shoaib_ahmed 0:791a779d6220 913 data[DCTSIZE*1+1] = (tmp1 - tmp3) << 4;
shoaib_ahmed 0:791a779d6220 914 }
shoaib_ahmed 0:791a779d6220 915
shoaib_ahmed 0:791a779d6220 916
shoaib_ahmed 0:791a779d6220 917 /*
shoaib_ahmed 0:791a779d6220 918 * Perform the forward DCT on a 1x1 sample block.
shoaib_ahmed 0:791a779d6220 919 */
shoaib_ahmed 0:791a779d6220 920
shoaib_ahmed 0:791a779d6220 921 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 922 jpeg_fdct_1x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 923 {
shoaib_ahmed 0:791a779d6220 924 DCTELEM dcval;
shoaib_ahmed 0:791a779d6220 925
shoaib_ahmed 0:791a779d6220 926 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 927 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 928
shoaib_ahmed 0:791a779d6220 929 dcval = GETJSAMPLE(sample_data[0][start_col]);
shoaib_ahmed 0:791a779d6220 930
shoaib_ahmed 0:791a779d6220 931 /* We leave the result scaled up by an overall factor of 8. */
shoaib_ahmed 0:791a779d6220 932 /* We must also scale the output by (8/1)**2 = 2**6. */
shoaib_ahmed 0:791a779d6220 933 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 934 data[0] = (dcval - CENTERJSAMPLE) << 6;
shoaib_ahmed 0:791a779d6220 935 }
shoaib_ahmed 0:791a779d6220 936
shoaib_ahmed 0:791a779d6220 937
shoaib_ahmed 0:791a779d6220 938 /*
shoaib_ahmed 0:791a779d6220 939 * Perform the forward DCT on a 9x9 sample block.
shoaib_ahmed 0:791a779d6220 940 */
shoaib_ahmed 0:791a779d6220 941
shoaib_ahmed 0:791a779d6220 942 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 943 jpeg_fdct_9x9 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 944 {
shoaib_ahmed 0:791a779d6220 945 INT32 tmp0, tmp1, tmp2, tmp3, tmp4;
shoaib_ahmed 0:791a779d6220 946 INT32 tmp10, tmp11, tmp12, tmp13;
shoaib_ahmed 0:791a779d6220 947 INT32 z1, z2;
shoaib_ahmed 0:791a779d6220 948 DCTELEM workspace[8];
shoaib_ahmed 0:791a779d6220 949 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 950 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 951 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 952 int ctr;
shoaib_ahmed 0:791a779d6220 953 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 954
shoaib_ahmed 0:791a779d6220 955 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 956 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 957 * we scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 958 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 959 * cK represents sqrt(2) * cos(K*pi/18).
shoaib_ahmed 0:791a779d6220 960 */
shoaib_ahmed 0:791a779d6220 961
shoaib_ahmed 0:791a779d6220 962 dataptr = data;
shoaib_ahmed 0:791a779d6220 963 ctr = 0;
shoaib_ahmed 0:791a779d6220 964 for (;;) {
shoaib_ahmed 0:791a779d6220 965 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 966
shoaib_ahmed 0:791a779d6220 967 /* Even part */
shoaib_ahmed 0:791a779d6220 968
shoaib_ahmed 0:791a779d6220 969 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 970 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 971 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 972 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 973 tmp4 = GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 974
shoaib_ahmed 0:791a779d6220 975 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 976 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 977 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 978 tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 979
shoaib_ahmed 0:791a779d6220 980 z1 = tmp0 + tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 981 z2 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 982 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 983 dataptr[0] = (DCTELEM) ((z1 + z2 - 9 * CENTERJSAMPLE) << 1);
shoaib_ahmed 0:791a779d6220 984 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 985 DESCALE(MULTIPLY(z1 - z2 - z2, FIX(0.707106781)), /* c6 */
shoaib_ahmed 0:791a779d6220 986 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 987 z1 = MULTIPLY(tmp0 - tmp2, FIX(1.328926049)); /* c2 */
shoaib_ahmed 0:791a779d6220 988 z2 = MULTIPLY(tmp1 - tmp4 - tmp4, FIX(0.707106781)); /* c6 */
shoaib_ahmed 0:791a779d6220 989 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 990 DESCALE(MULTIPLY(tmp2 - tmp3, FIX(1.083350441)) /* c4 */
shoaib_ahmed 0:791a779d6220 991 + z1 + z2, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 992 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 993 DESCALE(MULTIPLY(tmp3 - tmp0, FIX(0.245575608)) /* c8 */
shoaib_ahmed 0:791a779d6220 994 + z1 - z2, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 995
shoaib_ahmed 0:791a779d6220 996 /* Odd part */
shoaib_ahmed 0:791a779d6220 997
shoaib_ahmed 0:791a779d6220 998 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 999 DESCALE(MULTIPLY(tmp10 - tmp12 - tmp13, FIX(1.224744871)), /* c3 */
shoaib_ahmed 0:791a779d6220 1000 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1001
shoaib_ahmed 0:791a779d6220 1002 tmp11 = MULTIPLY(tmp11, FIX(1.224744871)); /* c3 */
shoaib_ahmed 0:791a779d6220 1003 tmp0 = MULTIPLY(tmp10 + tmp12, FIX(0.909038955)); /* c5 */
shoaib_ahmed 0:791a779d6220 1004 tmp1 = MULTIPLY(tmp10 + tmp13, FIX(0.483689525)); /* c7 */
shoaib_ahmed 0:791a779d6220 1005
shoaib_ahmed 0:791a779d6220 1006 dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp0 + tmp1, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1007
shoaib_ahmed 0:791a779d6220 1008 tmp2 = MULTIPLY(tmp12 - tmp13, FIX(1.392728481)); /* c1 */
shoaib_ahmed 0:791a779d6220 1009
shoaib_ahmed 0:791a779d6220 1010 dataptr[5] = (DCTELEM) DESCALE(tmp0 - tmp11 - tmp2, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1011 dataptr[7] = (DCTELEM) DESCALE(tmp1 - tmp11 + tmp2, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1012
shoaib_ahmed 0:791a779d6220 1013 ctr++;
shoaib_ahmed 0:791a779d6220 1014
shoaib_ahmed 0:791a779d6220 1015 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1016 if (ctr == 9)
shoaib_ahmed 0:791a779d6220 1017 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1018 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1019 } else
shoaib_ahmed 0:791a779d6220 1020 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1021 }
shoaib_ahmed 0:791a779d6220 1022
shoaib_ahmed 0:791a779d6220 1023 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1024 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1025 * We must also scale the output by (8/9)**2 = 64/81, which we partially
shoaib_ahmed 0:791a779d6220 1026 * fold into the constant multipliers and final/initial shifting:
shoaib_ahmed 0:791a779d6220 1027 * cK now represents sqrt(2) * cos(K*pi/18) * 128/81.
shoaib_ahmed 0:791a779d6220 1028 */
shoaib_ahmed 0:791a779d6220 1029
shoaib_ahmed 0:791a779d6220 1030 dataptr = data;
shoaib_ahmed 0:791a779d6220 1031 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1032 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1033 /* Even part */
shoaib_ahmed 0:791a779d6220 1034
shoaib_ahmed 0:791a779d6220 1035 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1036 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1037 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1038 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1039 tmp4 = dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 1040
shoaib_ahmed 0:791a779d6220 1041 tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1042 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1043 tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1044 tmp13 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1045
shoaib_ahmed 0:791a779d6220 1046 z1 = tmp0 + tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 1047 z2 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 1048 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1049 DESCALE(MULTIPLY(z1 + z2, FIX(1.580246914)), /* 128/81 */
shoaib_ahmed 0:791a779d6220 1050 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1051 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1052 DESCALE(MULTIPLY(z1 - z2 - z2, FIX(1.117403309)), /* c6 */
shoaib_ahmed 0:791a779d6220 1053 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1054 z1 = MULTIPLY(tmp0 - tmp2, FIX(2.100031287)); /* c2 */
shoaib_ahmed 0:791a779d6220 1055 z2 = MULTIPLY(tmp1 - tmp4 - tmp4, FIX(1.117403309)); /* c6 */
shoaib_ahmed 0:791a779d6220 1056 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1057 DESCALE(MULTIPLY(tmp2 - tmp3, FIX(1.711961190)) /* c4 */
shoaib_ahmed 0:791a779d6220 1058 + z1 + z2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1059 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1060 DESCALE(MULTIPLY(tmp3 - tmp0, FIX(0.388070096)) /* c8 */
shoaib_ahmed 0:791a779d6220 1061 + z1 - z2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1062
shoaib_ahmed 0:791a779d6220 1063 /* Odd part */
shoaib_ahmed 0:791a779d6220 1064
shoaib_ahmed 0:791a779d6220 1065 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1066 DESCALE(MULTIPLY(tmp10 - tmp12 - tmp13, FIX(1.935399303)), /* c3 */
shoaib_ahmed 0:791a779d6220 1067 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1068
shoaib_ahmed 0:791a779d6220 1069 tmp11 = MULTIPLY(tmp11, FIX(1.935399303)); /* c3 */
shoaib_ahmed 0:791a779d6220 1070 tmp0 = MULTIPLY(tmp10 + tmp12, FIX(1.436506004)); /* c5 */
shoaib_ahmed 0:791a779d6220 1071 tmp1 = MULTIPLY(tmp10 + tmp13, FIX(0.764348879)); /* c7 */
shoaib_ahmed 0:791a779d6220 1072
shoaib_ahmed 0:791a779d6220 1073 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1074 DESCALE(tmp11 + tmp0 + tmp1, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1075
shoaib_ahmed 0:791a779d6220 1076 tmp2 = MULTIPLY(tmp12 - tmp13, FIX(2.200854883)); /* c1 */
shoaib_ahmed 0:791a779d6220 1077
shoaib_ahmed 0:791a779d6220 1078 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1079 DESCALE(tmp0 - tmp11 - tmp2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1080 dataptr[DCTSIZE*7] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1081 DESCALE(tmp1 - tmp11 + tmp2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1082
shoaib_ahmed 0:791a779d6220 1083 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1084 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1085 }
shoaib_ahmed 0:791a779d6220 1086 }
shoaib_ahmed 0:791a779d6220 1087
shoaib_ahmed 0:791a779d6220 1088
shoaib_ahmed 0:791a779d6220 1089 /*
shoaib_ahmed 0:791a779d6220 1090 * Perform the forward DCT on a 10x10 sample block.
shoaib_ahmed 0:791a779d6220 1091 */
shoaib_ahmed 0:791a779d6220 1092
shoaib_ahmed 0:791a779d6220 1093 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 1094 jpeg_fdct_10x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 1095 {
shoaib_ahmed 0:791a779d6220 1096 INT32 tmp0, tmp1, tmp2, tmp3, tmp4;
shoaib_ahmed 0:791a779d6220 1097 INT32 tmp10, tmp11, tmp12, tmp13, tmp14;
shoaib_ahmed 0:791a779d6220 1098 DCTELEM workspace[8*2];
shoaib_ahmed 0:791a779d6220 1099 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 1100 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 1101 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 1102 int ctr;
shoaib_ahmed 0:791a779d6220 1103 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 1104
shoaib_ahmed 0:791a779d6220 1105 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 1106 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 1107 * we scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 1108 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 1109 * cK represents sqrt(2) * cos(K*pi/20).
shoaib_ahmed 0:791a779d6220 1110 */
shoaib_ahmed 0:791a779d6220 1111
shoaib_ahmed 0:791a779d6220 1112 dataptr = data;
shoaib_ahmed 0:791a779d6220 1113 ctr = 0;
shoaib_ahmed 0:791a779d6220 1114 for (;;) {
shoaib_ahmed 0:791a779d6220 1115 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 1116
shoaib_ahmed 0:791a779d6220 1117 /* Even part */
shoaib_ahmed 0:791a779d6220 1118
shoaib_ahmed 0:791a779d6220 1119 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1120 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1121 tmp12 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1122 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1123 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 1124
shoaib_ahmed 0:791a779d6220 1125 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 1126 tmp13 = tmp0 - tmp4;
shoaib_ahmed 0:791a779d6220 1127 tmp11 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 1128 tmp14 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 1129
shoaib_ahmed 0:791a779d6220 1130 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1131 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1132 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1133 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1134 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 1135
shoaib_ahmed 0:791a779d6220 1136 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 1137 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1138 ((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << 1);
shoaib_ahmed 0:791a779d6220 1139 tmp12 += tmp12;
shoaib_ahmed 0:791a779d6220 1140 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1141 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.144122806)) - /* c4 */
shoaib_ahmed 0:791a779d6220 1142 MULTIPLY(tmp11 - tmp12, FIX(0.437016024)), /* c8 */
shoaib_ahmed 0:791a779d6220 1143 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1144 tmp10 = MULTIPLY(tmp13 + tmp14, FIX(0.831253876)); /* c6 */
shoaib_ahmed 0:791a779d6220 1145 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1146 DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.513743148)), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 1147 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1148 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1149 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.176250899)), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 1150 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1151
shoaib_ahmed 0:791a779d6220 1152 /* Odd part */
shoaib_ahmed 0:791a779d6220 1153
shoaib_ahmed 0:791a779d6220 1154 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 1155 tmp11 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 1156 dataptr[5] = (DCTELEM) ((tmp10 - tmp11 - tmp2) << 1);
shoaib_ahmed 0:791a779d6220 1157 tmp2 <<= CONST_BITS;
shoaib_ahmed 0:791a779d6220 1158 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1159 DESCALE(MULTIPLY(tmp0, FIX(1.396802247)) + /* c1 */
shoaib_ahmed 0:791a779d6220 1160 MULTIPLY(tmp1, FIX(1.260073511)) + tmp2 + /* c3 */
shoaib_ahmed 0:791a779d6220 1161 MULTIPLY(tmp3, FIX(0.642039522)) + /* c7 */
shoaib_ahmed 0:791a779d6220 1162 MULTIPLY(tmp4, FIX(0.221231742)), /* c9 */
shoaib_ahmed 0:791a779d6220 1163 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1164 tmp12 = MULTIPLY(tmp0 - tmp4, FIX(0.951056516)) - /* (c3+c7)/2 */
shoaib_ahmed 0:791a779d6220 1165 MULTIPLY(tmp1 + tmp3, FIX(0.587785252)); /* (c1-c9)/2 */
shoaib_ahmed 0:791a779d6220 1166 tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.309016994)) + /* (c3-c7)/2 */
shoaib_ahmed 0:791a779d6220 1167 (tmp11 << (CONST_BITS - 1)) - tmp2;
shoaib_ahmed 0:791a779d6220 1168 dataptr[3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1169 dataptr[7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1170
shoaib_ahmed 0:791a779d6220 1171 ctr++;
shoaib_ahmed 0:791a779d6220 1172
shoaib_ahmed 0:791a779d6220 1173 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1174 if (ctr == 10)
shoaib_ahmed 0:791a779d6220 1175 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1176 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1177 } else
shoaib_ahmed 0:791a779d6220 1178 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1179 }
shoaib_ahmed 0:791a779d6220 1180
shoaib_ahmed 0:791a779d6220 1181 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1182 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1183 * We must also scale the output by (8/10)**2 = 16/25, which we partially
shoaib_ahmed 0:791a779d6220 1184 * fold into the constant multipliers and final/initial shifting:
shoaib_ahmed 0:791a779d6220 1185 * cK now represents sqrt(2) * cos(K*pi/20) * 32/25.
shoaib_ahmed 0:791a779d6220 1186 */
shoaib_ahmed 0:791a779d6220 1187
shoaib_ahmed 0:791a779d6220 1188 dataptr = data;
shoaib_ahmed 0:791a779d6220 1189 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1190 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1191 /* Even part */
shoaib_ahmed 0:791a779d6220 1192
shoaib_ahmed 0:791a779d6220 1193 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1194 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1195 tmp12 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1196 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1197 tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1198
shoaib_ahmed 0:791a779d6220 1199 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 1200 tmp13 = tmp0 - tmp4;
shoaib_ahmed 0:791a779d6220 1201 tmp11 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 1202 tmp14 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 1203
shoaib_ahmed 0:791a779d6220 1204 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1205 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1206 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1207 tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1208 tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1209
shoaib_ahmed 0:791a779d6220 1210 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1211 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 1212 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1213 tmp12 += tmp12;
shoaib_ahmed 0:791a779d6220 1214 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1215 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.464477191)) - /* c4 */
shoaib_ahmed 0:791a779d6220 1216 MULTIPLY(tmp11 - tmp12, FIX(0.559380511)), /* c8 */
shoaib_ahmed 0:791a779d6220 1217 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1218 tmp10 = MULTIPLY(tmp13 + tmp14, FIX(1.064004961)); /* c6 */
shoaib_ahmed 0:791a779d6220 1219 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1220 DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.657591230)), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 1221 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1222 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1223 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.785601151)), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 1224 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1225
shoaib_ahmed 0:791a779d6220 1226 /* Odd part */
shoaib_ahmed 0:791a779d6220 1227
shoaib_ahmed 0:791a779d6220 1228 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 1229 tmp11 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 1230 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1231 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp2, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 1232 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1233 tmp2 = MULTIPLY(tmp2, FIX(1.28)); /* 32/25 */
shoaib_ahmed 0:791a779d6220 1234 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1235 DESCALE(MULTIPLY(tmp0, FIX(1.787906876)) + /* c1 */
shoaib_ahmed 0:791a779d6220 1236 MULTIPLY(tmp1, FIX(1.612894094)) + tmp2 + /* c3 */
shoaib_ahmed 0:791a779d6220 1237 MULTIPLY(tmp3, FIX(0.821810588)) + /* c7 */
shoaib_ahmed 0:791a779d6220 1238 MULTIPLY(tmp4, FIX(0.283176630)), /* c9 */
shoaib_ahmed 0:791a779d6220 1239 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1240 tmp12 = MULTIPLY(tmp0 - tmp4, FIX(1.217352341)) - /* (c3+c7)/2 */
shoaib_ahmed 0:791a779d6220 1241 MULTIPLY(tmp1 + tmp3, FIX(0.752365123)); /* (c1-c9)/2 */
shoaib_ahmed 0:791a779d6220 1242 tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.395541753)) + /* (c3-c7)/2 */
shoaib_ahmed 0:791a779d6220 1243 MULTIPLY(tmp11, FIX(0.64)) - tmp2; /* 16/25 */
shoaib_ahmed 0:791a779d6220 1244 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1245 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1246
shoaib_ahmed 0:791a779d6220 1247 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1248 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1249 }
shoaib_ahmed 0:791a779d6220 1250 }
shoaib_ahmed 0:791a779d6220 1251
shoaib_ahmed 0:791a779d6220 1252
shoaib_ahmed 0:791a779d6220 1253 /*
shoaib_ahmed 0:791a779d6220 1254 * Perform the forward DCT on an 11x11 sample block.
shoaib_ahmed 0:791a779d6220 1255 */
shoaib_ahmed 0:791a779d6220 1256
shoaib_ahmed 0:791a779d6220 1257 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 1258 jpeg_fdct_11x11 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 1259 {
shoaib_ahmed 0:791a779d6220 1260 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
shoaib_ahmed 0:791a779d6220 1261 INT32 tmp10, tmp11, tmp12, tmp13, tmp14;
shoaib_ahmed 0:791a779d6220 1262 INT32 z1, z2, z3;
shoaib_ahmed 0:791a779d6220 1263 DCTELEM workspace[8*3];
shoaib_ahmed 0:791a779d6220 1264 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 1265 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 1266 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 1267 int ctr;
shoaib_ahmed 0:791a779d6220 1268 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 1269
shoaib_ahmed 0:791a779d6220 1270 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 1271 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 1272 * we scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 1273 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 1274 * cK represents sqrt(2) * cos(K*pi/22).
shoaib_ahmed 0:791a779d6220 1275 */
shoaib_ahmed 0:791a779d6220 1276
shoaib_ahmed 0:791a779d6220 1277 dataptr = data;
shoaib_ahmed 0:791a779d6220 1278 ctr = 0;
shoaib_ahmed 0:791a779d6220 1279 for (;;) {
shoaib_ahmed 0:791a779d6220 1280 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 1281
shoaib_ahmed 0:791a779d6220 1282 /* Even part */
shoaib_ahmed 0:791a779d6220 1283
shoaib_ahmed 0:791a779d6220 1284 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1285 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1286 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1287 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1288 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1289 tmp5 = GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 1290
shoaib_ahmed 0:791a779d6220 1291 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1292 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1293 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1294 tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1295 tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1296
shoaib_ahmed 0:791a779d6220 1297 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 1298 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1299 ((tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 - 11 * CENTERJSAMPLE) << 1);
shoaib_ahmed 0:791a779d6220 1300 tmp5 += tmp5;
shoaib_ahmed 0:791a779d6220 1301 tmp0 -= tmp5;
shoaib_ahmed 0:791a779d6220 1302 tmp1 -= tmp5;
shoaib_ahmed 0:791a779d6220 1303 tmp2 -= tmp5;
shoaib_ahmed 0:791a779d6220 1304 tmp3 -= tmp5;
shoaib_ahmed 0:791a779d6220 1305 tmp4 -= tmp5;
shoaib_ahmed 0:791a779d6220 1306 z1 = MULTIPLY(tmp0 + tmp3, FIX(1.356927976)) + /* c2 */
shoaib_ahmed 0:791a779d6220 1307 MULTIPLY(tmp2 + tmp4, FIX(0.201263574)); /* c10 */
shoaib_ahmed 0:791a779d6220 1308 z2 = MULTIPLY(tmp1 - tmp3, FIX(0.926112931)); /* c6 */
shoaib_ahmed 0:791a779d6220 1309 z3 = MULTIPLY(tmp0 - tmp1, FIX(1.189712156)); /* c4 */
shoaib_ahmed 0:791a779d6220 1310 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1311 DESCALE(z1 + z2 - MULTIPLY(tmp3, FIX(1.018300590)) /* c2+c8-c6 */
shoaib_ahmed 0:791a779d6220 1312 - MULTIPLY(tmp4, FIX(1.390975730)), /* c4+c10 */
shoaib_ahmed 0:791a779d6220 1313 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1314 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1315 DESCALE(z2 + z3 + MULTIPLY(tmp1, FIX(0.062335650)) /* c4-c6-c10 */
shoaib_ahmed 0:791a779d6220 1316 - MULTIPLY(tmp2, FIX(1.356927976)) /* c2 */
shoaib_ahmed 0:791a779d6220 1317 + MULTIPLY(tmp4, FIX(0.587485545)), /* c8 */
shoaib_ahmed 0:791a779d6220 1318 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1319 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1320 DESCALE(z1 + z3 - MULTIPLY(tmp0, FIX(1.620527200)) /* c2+c4-c6 */
shoaib_ahmed 0:791a779d6220 1321 - MULTIPLY(tmp2, FIX(0.788749120)), /* c8+c10 */
shoaib_ahmed 0:791a779d6220 1322 CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1323
shoaib_ahmed 0:791a779d6220 1324 /* Odd part */
shoaib_ahmed 0:791a779d6220 1325
shoaib_ahmed 0:791a779d6220 1326 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.286413905)); /* c3 */
shoaib_ahmed 0:791a779d6220 1327 tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.068791298)); /* c5 */
shoaib_ahmed 0:791a779d6220 1328 tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.764581576)); /* c7 */
shoaib_ahmed 0:791a779d6220 1329 tmp0 = tmp1 + tmp2 + tmp3 - MULTIPLY(tmp10, FIX(1.719967871)) /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 1330 + MULTIPLY(tmp14, FIX(0.398430003)); /* c9 */
shoaib_ahmed 0:791a779d6220 1331 tmp4 = MULTIPLY(tmp11 + tmp12, - FIX(0.764581576)); /* -c7 */
shoaib_ahmed 0:791a779d6220 1332 tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.399818907)); /* -c1 */
shoaib_ahmed 0:791a779d6220 1333 tmp1 += tmp4 + tmp5 + MULTIPLY(tmp11, FIX(1.276416582)) /* c9+c7+c1-c3 */
shoaib_ahmed 0:791a779d6220 1334 - MULTIPLY(tmp14, FIX(1.068791298)); /* c5 */
shoaib_ahmed 0:791a779d6220 1335 tmp10 = MULTIPLY(tmp12 + tmp13, FIX(0.398430003)); /* c9 */
shoaib_ahmed 0:791a779d6220 1336 tmp2 += tmp4 + tmp10 - MULTIPLY(tmp12, FIX(1.989053629)) /* c9+c5+c3-c7 */
shoaib_ahmed 0:791a779d6220 1337 + MULTIPLY(tmp14, FIX(1.399818907)); /* c1 */
shoaib_ahmed 0:791a779d6220 1338 tmp3 += tmp5 + tmp10 + MULTIPLY(tmp13, FIX(1.305598626)) /* c1+c5-c9-c7 */
shoaib_ahmed 0:791a779d6220 1339 - MULTIPLY(tmp14, FIX(1.286413905)); /* c3 */
shoaib_ahmed 0:791a779d6220 1340
shoaib_ahmed 0:791a779d6220 1341 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1342 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1343 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1344 dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 1345
shoaib_ahmed 0:791a779d6220 1346 ctr++;
shoaib_ahmed 0:791a779d6220 1347
shoaib_ahmed 0:791a779d6220 1348 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1349 if (ctr == 11)
shoaib_ahmed 0:791a779d6220 1350 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1351 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1352 } else
shoaib_ahmed 0:791a779d6220 1353 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1354 }
shoaib_ahmed 0:791a779d6220 1355
shoaib_ahmed 0:791a779d6220 1356 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1357 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1358 * We must also scale the output by (8/11)**2 = 64/121, which we partially
shoaib_ahmed 0:791a779d6220 1359 * fold into the constant multipliers and final/initial shifting:
shoaib_ahmed 0:791a779d6220 1360 * cK now represents sqrt(2) * cos(K*pi/22) * 128/121.
shoaib_ahmed 0:791a779d6220 1361 */
shoaib_ahmed 0:791a779d6220 1362
shoaib_ahmed 0:791a779d6220 1363 dataptr = data;
shoaib_ahmed 0:791a779d6220 1364 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1365 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1366 /* Even part */
shoaib_ahmed 0:791a779d6220 1367
shoaib_ahmed 0:791a779d6220 1368 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1369 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1370 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1371 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1372 tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1373 tmp5 = dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1374
shoaib_ahmed 0:791a779d6220 1375 tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1376 tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1377 tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1378 tmp13 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1379 tmp14 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1380
shoaib_ahmed 0:791a779d6220 1381 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1382 DESCALE(MULTIPLY(tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5,
shoaib_ahmed 0:791a779d6220 1383 FIX(1.057851240)), /* 128/121 */
shoaib_ahmed 0:791a779d6220 1384 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1385 tmp5 += tmp5;
shoaib_ahmed 0:791a779d6220 1386 tmp0 -= tmp5;
shoaib_ahmed 0:791a779d6220 1387 tmp1 -= tmp5;
shoaib_ahmed 0:791a779d6220 1388 tmp2 -= tmp5;
shoaib_ahmed 0:791a779d6220 1389 tmp3 -= tmp5;
shoaib_ahmed 0:791a779d6220 1390 tmp4 -= tmp5;
shoaib_ahmed 0:791a779d6220 1391 z1 = MULTIPLY(tmp0 + tmp3, FIX(1.435427942)) + /* c2 */
shoaib_ahmed 0:791a779d6220 1392 MULTIPLY(tmp2 + tmp4, FIX(0.212906922)); /* c10 */
shoaib_ahmed 0:791a779d6220 1393 z2 = MULTIPLY(tmp1 - tmp3, FIX(0.979689713)); /* c6 */
shoaib_ahmed 0:791a779d6220 1394 z3 = MULTIPLY(tmp0 - tmp1, FIX(1.258538479)); /* c4 */
shoaib_ahmed 0:791a779d6220 1395 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1396 DESCALE(z1 + z2 - MULTIPLY(tmp3, FIX(1.077210542)) /* c2+c8-c6 */
shoaib_ahmed 0:791a779d6220 1397 - MULTIPLY(tmp4, FIX(1.471445400)), /* c4+c10 */
shoaib_ahmed 0:791a779d6220 1398 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1399 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1400 DESCALE(z2 + z3 + MULTIPLY(tmp1, FIX(0.065941844)) /* c4-c6-c10 */
shoaib_ahmed 0:791a779d6220 1401 - MULTIPLY(tmp2, FIX(1.435427942)) /* c2 */
shoaib_ahmed 0:791a779d6220 1402 + MULTIPLY(tmp4, FIX(0.621472312)), /* c8 */
shoaib_ahmed 0:791a779d6220 1403 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1404 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1405 DESCALE(z1 + z3 - MULTIPLY(tmp0, FIX(1.714276708)) /* c2+c4-c6 */
shoaib_ahmed 0:791a779d6220 1406 - MULTIPLY(tmp2, FIX(0.834379234)), /* c8+c10 */
shoaib_ahmed 0:791a779d6220 1407 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1408
shoaib_ahmed 0:791a779d6220 1409 /* Odd part */
shoaib_ahmed 0:791a779d6220 1410
shoaib_ahmed 0:791a779d6220 1411 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.360834544)); /* c3 */
shoaib_ahmed 0:791a779d6220 1412 tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.130622199)); /* c5 */
shoaib_ahmed 0:791a779d6220 1413 tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.808813568)); /* c7 */
shoaib_ahmed 0:791a779d6220 1414 tmp0 = tmp1 + tmp2 + tmp3 - MULTIPLY(tmp10, FIX(1.819470145)) /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 1415 + MULTIPLY(tmp14, FIX(0.421479672)); /* c9 */
shoaib_ahmed 0:791a779d6220 1416 tmp4 = MULTIPLY(tmp11 + tmp12, - FIX(0.808813568)); /* -c7 */
shoaib_ahmed 0:791a779d6220 1417 tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.480800167)); /* -c1 */
shoaib_ahmed 0:791a779d6220 1418 tmp1 += tmp4 + tmp5 + MULTIPLY(tmp11, FIX(1.350258864)) /* c9+c7+c1-c3 */
shoaib_ahmed 0:791a779d6220 1419 - MULTIPLY(tmp14, FIX(1.130622199)); /* c5 */
shoaib_ahmed 0:791a779d6220 1420 tmp10 = MULTIPLY(tmp12 + tmp13, FIX(0.421479672)); /* c9 */
shoaib_ahmed 0:791a779d6220 1421 tmp2 += tmp4 + tmp10 - MULTIPLY(tmp12, FIX(2.104122847)) /* c9+c5+c3-c7 */
shoaib_ahmed 0:791a779d6220 1422 + MULTIPLY(tmp14, FIX(1.480800167)); /* c1 */
shoaib_ahmed 0:791a779d6220 1423 tmp3 += tmp5 + tmp10 + MULTIPLY(tmp13, FIX(1.381129125)) /* c1+c5-c9-c7 */
shoaib_ahmed 0:791a779d6220 1424 - MULTIPLY(tmp14, FIX(1.360834544)); /* c3 */
shoaib_ahmed 0:791a779d6220 1425
shoaib_ahmed 0:791a779d6220 1426 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1427 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1428 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1429 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 1430
shoaib_ahmed 0:791a779d6220 1431 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1432 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1433 }
shoaib_ahmed 0:791a779d6220 1434 }
shoaib_ahmed 0:791a779d6220 1435
shoaib_ahmed 0:791a779d6220 1436
shoaib_ahmed 0:791a779d6220 1437 /*
shoaib_ahmed 0:791a779d6220 1438 * Perform the forward DCT on a 12x12 sample block.
shoaib_ahmed 0:791a779d6220 1439 */
shoaib_ahmed 0:791a779d6220 1440
shoaib_ahmed 0:791a779d6220 1441 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 1442 jpeg_fdct_12x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 1443 {
shoaib_ahmed 0:791a779d6220 1444 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
shoaib_ahmed 0:791a779d6220 1445 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
shoaib_ahmed 0:791a779d6220 1446 DCTELEM workspace[8*4];
shoaib_ahmed 0:791a779d6220 1447 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 1448 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 1449 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 1450 int ctr;
shoaib_ahmed 0:791a779d6220 1451 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 1452
shoaib_ahmed 0:791a779d6220 1453 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 1454 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 1455 * cK represents sqrt(2) * cos(K*pi/24).
shoaib_ahmed 0:791a779d6220 1456 */
shoaib_ahmed 0:791a779d6220 1457
shoaib_ahmed 0:791a779d6220 1458 dataptr = data;
shoaib_ahmed 0:791a779d6220 1459 ctr = 0;
shoaib_ahmed 0:791a779d6220 1460 for (;;) {
shoaib_ahmed 0:791a779d6220 1461 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 1462
shoaib_ahmed 0:791a779d6220 1463 /* Even part */
shoaib_ahmed 0:791a779d6220 1464
shoaib_ahmed 0:791a779d6220 1465 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1466 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1467 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1468 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1469 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1470 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1471
shoaib_ahmed 0:791a779d6220 1472 tmp10 = tmp0 + tmp5;
shoaib_ahmed 0:791a779d6220 1473 tmp13 = tmp0 - tmp5;
shoaib_ahmed 0:791a779d6220 1474 tmp11 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 1475 tmp14 = tmp1 - tmp4;
shoaib_ahmed 0:791a779d6220 1476 tmp12 = tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 1477 tmp15 = tmp2 - tmp3;
shoaib_ahmed 0:791a779d6220 1478
shoaib_ahmed 0:791a779d6220 1479 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1480 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1481 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1482 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1483 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1484 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1485
shoaib_ahmed 0:791a779d6220 1486 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 1487 dataptr[0] = (DCTELEM) (tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE);
shoaib_ahmed 0:791a779d6220 1488 dataptr[6] = (DCTELEM) (tmp13 - tmp14 - tmp15);
shoaib_ahmed 0:791a779d6220 1489 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1490 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.224744871)), /* c4 */
shoaib_ahmed 0:791a779d6220 1491 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1492 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1493 DESCALE(tmp14 - tmp15 + MULTIPLY(tmp13 + tmp15, FIX(1.366025404)), /* c2 */
shoaib_ahmed 0:791a779d6220 1494 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1495
shoaib_ahmed 0:791a779d6220 1496 /* Odd part */
shoaib_ahmed 0:791a779d6220 1497
shoaib_ahmed 0:791a779d6220 1498 tmp10 = MULTIPLY(tmp1 + tmp4, FIX_0_541196100); /* c9 */
shoaib_ahmed 0:791a779d6220 1499 tmp14 = tmp10 + MULTIPLY(tmp1, FIX_0_765366865); /* c3-c9 */
shoaib_ahmed 0:791a779d6220 1500 tmp15 = tmp10 - MULTIPLY(tmp4, FIX_1_847759065); /* c3+c9 */
shoaib_ahmed 0:791a779d6220 1501 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.121971054)); /* c5 */
shoaib_ahmed 0:791a779d6220 1502 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.860918669)); /* c7 */
shoaib_ahmed 0:791a779d6220 1503 tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.580774953)) /* c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 1504 + MULTIPLY(tmp5, FIX(0.184591911)); /* c11 */
shoaib_ahmed 0:791a779d6220 1505 tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.184591911)); /* -c11 */
shoaib_ahmed 0:791a779d6220 1506 tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.339493912)) /* c1+c5-c11 */
shoaib_ahmed 0:791a779d6220 1507 + MULTIPLY(tmp5, FIX(0.860918669)); /* c7 */
shoaib_ahmed 0:791a779d6220 1508 tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.725788011)) /* c1+c11-c7 */
shoaib_ahmed 0:791a779d6220 1509 - MULTIPLY(tmp5, FIX(1.121971054)); /* c5 */
shoaib_ahmed 0:791a779d6220 1510 tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.306562965)) /* c3 */
shoaib_ahmed 0:791a779d6220 1511 - MULTIPLY(tmp2 + tmp5, FIX_0_541196100); /* c9 */
shoaib_ahmed 0:791a779d6220 1512
shoaib_ahmed 0:791a779d6220 1513 dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1514 dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1515 dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1516 dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1517
shoaib_ahmed 0:791a779d6220 1518 ctr++;
shoaib_ahmed 0:791a779d6220 1519
shoaib_ahmed 0:791a779d6220 1520 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1521 if (ctr == 12)
shoaib_ahmed 0:791a779d6220 1522 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1523 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1524 } else
shoaib_ahmed 0:791a779d6220 1525 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1526 }
shoaib_ahmed 0:791a779d6220 1527
shoaib_ahmed 0:791a779d6220 1528 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1529 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1530 * We must also scale the output by (8/12)**2 = 4/9, which we partially
shoaib_ahmed 0:791a779d6220 1531 * fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 1532 * cK now represents sqrt(2) * cos(K*pi/24) * 8/9.
shoaib_ahmed 0:791a779d6220 1533 */
shoaib_ahmed 0:791a779d6220 1534
shoaib_ahmed 0:791a779d6220 1535 dataptr = data;
shoaib_ahmed 0:791a779d6220 1536 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1537 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1538 /* Even part */
shoaib_ahmed 0:791a779d6220 1539
shoaib_ahmed 0:791a779d6220 1540 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1541 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1542 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1543 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1544 tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1545 tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1546
shoaib_ahmed 0:791a779d6220 1547 tmp10 = tmp0 + tmp5;
shoaib_ahmed 0:791a779d6220 1548 tmp13 = tmp0 - tmp5;
shoaib_ahmed 0:791a779d6220 1549 tmp11 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 1550 tmp14 = tmp1 - tmp4;
shoaib_ahmed 0:791a779d6220 1551 tmp12 = tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 1552 tmp15 = tmp2 - tmp3;
shoaib_ahmed 0:791a779d6220 1553
shoaib_ahmed 0:791a779d6220 1554 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1555 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1556 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1557 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1558 tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1559 tmp5 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1560
shoaib_ahmed 0:791a779d6220 1561 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1562 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(0.888888889)), /* 8/9 */
shoaib_ahmed 0:791a779d6220 1563 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1564 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1565 DESCALE(MULTIPLY(tmp13 - tmp14 - tmp15, FIX(0.888888889)), /* 8/9 */
shoaib_ahmed 0:791a779d6220 1566 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1567 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1568 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.088662108)), /* c4 */
shoaib_ahmed 0:791a779d6220 1569 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1570 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1571 DESCALE(MULTIPLY(tmp14 - tmp15, FIX(0.888888889)) + /* 8/9 */
shoaib_ahmed 0:791a779d6220 1572 MULTIPLY(tmp13 + tmp15, FIX(1.214244803)), /* c2 */
shoaib_ahmed 0:791a779d6220 1573 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1574
shoaib_ahmed 0:791a779d6220 1575 /* Odd part */
shoaib_ahmed 0:791a779d6220 1576
shoaib_ahmed 0:791a779d6220 1577 tmp10 = MULTIPLY(tmp1 + tmp4, FIX(0.481063200)); /* c9 */
shoaib_ahmed 0:791a779d6220 1578 tmp14 = tmp10 + MULTIPLY(tmp1, FIX(0.680326102)); /* c3-c9 */
shoaib_ahmed 0:791a779d6220 1579 tmp15 = tmp10 - MULTIPLY(tmp4, FIX(1.642452502)); /* c3+c9 */
shoaib_ahmed 0:791a779d6220 1580 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(0.997307603)); /* c5 */
shoaib_ahmed 0:791a779d6220 1581 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.765261039)); /* c7 */
shoaib_ahmed 0:791a779d6220 1582 tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.516244403)) /* c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 1583 + MULTIPLY(tmp5, FIX(0.164081699)); /* c11 */
shoaib_ahmed 0:791a779d6220 1584 tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.164081699)); /* -c11 */
shoaib_ahmed 0:791a779d6220 1585 tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.079550144)) /* c1+c5-c11 */
shoaib_ahmed 0:791a779d6220 1586 + MULTIPLY(tmp5, FIX(0.765261039)); /* c7 */
shoaib_ahmed 0:791a779d6220 1587 tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.645144899)) /* c1+c11-c7 */
shoaib_ahmed 0:791a779d6220 1588 - MULTIPLY(tmp5, FIX(0.997307603)); /* c5 */
shoaib_ahmed 0:791a779d6220 1589 tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.161389302)) /* c3 */
shoaib_ahmed 0:791a779d6220 1590 - MULTIPLY(tmp2 + tmp5, FIX(0.481063200)); /* c9 */
shoaib_ahmed 0:791a779d6220 1591
shoaib_ahmed 0:791a779d6220 1592 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1593 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1594 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1595 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1596
shoaib_ahmed 0:791a779d6220 1597 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1598 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1599 }
shoaib_ahmed 0:791a779d6220 1600 }
shoaib_ahmed 0:791a779d6220 1601
shoaib_ahmed 0:791a779d6220 1602
shoaib_ahmed 0:791a779d6220 1603 /*
shoaib_ahmed 0:791a779d6220 1604 * Perform the forward DCT on a 13x13 sample block.
shoaib_ahmed 0:791a779d6220 1605 */
shoaib_ahmed 0:791a779d6220 1606
shoaib_ahmed 0:791a779d6220 1607 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 1608 jpeg_fdct_13x13 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 1609 {
shoaib_ahmed 0:791a779d6220 1610 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
shoaib_ahmed 0:791a779d6220 1611 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
shoaib_ahmed 0:791a779d6220 1612 INT32 z1, z2;
shoaib_ahmed 0:791a779d6220 1613 DCTELEM workspace[8*5];
shoaib_ahmed 0:791a779d6220 1614 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 1615 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 1616 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 1617 int ctr;
shoaib_ahmed 0:791a779d6220 1618 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 1619
shoaib_ahmed 0:791a779d6220 1620 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 1621 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 1622 * cK represents sqrt(2) * cos(K*pi/26).
shoaib_ahmed 0:791a779d6220 1623 */
shoaib_ahmed 0:791a779d6220 1624
shoaib_ahmed 0:791a779d6220 1625 dataptr = data;
shoaib_ahmed 0:791a779d6220 1626 ctr = 0;
shoaib_ahmed 0:791a779d6220 1627 for (;;) {
shoaib_ahmed 0:791a779d6220 1628 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 1629
shoaib_ahmed 0:791a779d6220 1630 /* Even part */
shoaib_ahmed 0:791a779d6220 1631
shoaib_ahmed 0:791a779d6220 1632 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 1633 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1634 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1635 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1636 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1637 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1638 tmp6 = GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 1639
shoaib_ahmed 0:791a779d6220 1640 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 1641 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1642 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1643 tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1644 tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1645 tmp15 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1646
shoaib_ahmed 0:791a779d6220 1647 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 1648 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1649 (tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6 - 13 * CENTERJSAMPLE);
shoaib_ahmed 0:791a779d6220 1650 tmp6 += tmp6;
shoaib_ahmed 0:791a779d6220 1651 tmp0 -= tmp6;
shoaib_ahmed 0:791a779d6220 1652 tmp1 -= tmp6;
shoaib_ahmed 0:791a779d6220 1653 tmp2 -= tmp6;
shoaib_ahmed 0:791a779d6220 1654 tmp3 -= tmp6;
shoaib_ahmed 0:791a779d6220 1655 tmp4 -= tmp6;
shoaib_ahmed 0:791a779d6220 1656 tmp5 -= tmp6;
shoaib_ahmed 0:791a779d6220 1657 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1658 DESCALE(MULTIPLY(tmp0, FIX(1.373119086)) + /* c2 */
shoaib_ahmed 0:791a779d6220 1659 MULTIPLY(tmp1, FIX(1.058554052)) + /* c6 */
shoaib_ahmed 0:791a779d6220 1660 MULTIPLY(tmp2, FIX(0.501487041)) - /* c10 */
shoaib_ahmed 0:791a779d6220 1661 MULTIPLY(tmp3, FIX(0.170464608)) - /* c12 */
shoaib_ahmed 0:791a779d6220 1662 MULTIPLY(tmp4, FIX(0.803364869)) - /* c8 */
shoaib_ahmed 0:791a779d6220 1663 MULTIPLY(tmp5, FIX(1.252223920)), /* c4 */
shoaib_ahmed 0:791a779d6220 1664 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1665 z1 = MULTIPLY(tmp0 - tmp2, FIX(1.155388986)) - /* (c4+c6)/2 */
shoaib_ahmed 0:791a779d6220 1666 MULTIPLY(tmp3 - tmp4, FIX(0.435816023)) - /* (c2-c10)/2 */
shoaib_ahmed 0:791a779d6220 1667 MULTIPLY(tmp1 - tmp5, FIX(0.316450131)); /* (c8-c12)/2 */
shoaib_ahmed 0:791a779d6220 1668 z2 = MULTIPLY(tmp0 + tmp2, FIX(0.096834934)) - /* (c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 1669 MULTIPLY(tmp3 + tmp4, FIX(0.937303064)) + /* (c2+c10)/2 */
shoaib_ahmed 0:791a779d6220 1670 MULTIPLY(tmp1 + tmp5, FIX(0.486914739)); /* (c8+c12)/2 */
shoaib_ahmed 0:791a779d6220 1671
shoaib_ahmed 0:791a779d6220 1672 dataptr[4] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1673 dataptr[6] = (DCTELEM) DESCALE(z1 - z2, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1674
shoaib_ahmed 0:791a779d6220 1675 /* Odd part */
shoaib_ahmed 0:791a779d6220 1676
shoaib_ahmed 0:791a779d6220 1677 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.322312651)); /* c3 */
shoaib_ahmed 0:791a779d6220 1678 tmp2 = MULTIPLY(tmp10 + tmp12, FIX(1.163874945)); /* c5 */
shoaib_ahmed 0:791a779d6220 1679 tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.937797057)) + /* c7 */
shoaib_ahmed 0:791a779d6220 1680 MULTIPLY(tmp14 + tmp15, FIX(0.338443458)); /* c11 */
shoaib_ahmed 0:791a779d6220 1681 tmp0 = tmp1 + tmp2 + tmp3 -
shoaib_ahmed 0:791a779d6220 1682 MULTIPLY(tmp10, FIX(2.020082300)) + /* c3+c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 1683 MULTIPLY(tmp14, FIX(0.318774355)); /* c9-c11 */
shoaib_ahmed 0:791a779d6220 1684 tmp4 = MULTIPLY(tmp14 - tmp15, FIX(0.937797057)) - /* c7 */
shoaib_ahmed 0:791a779d6220 1685 MULTIPLY(tmp11 + tmp12, FIX(0.338443458)); /* c11 */
shoaib_ahmed 0:791a779d6220 1686 tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(1.163874945)); /* -c5 */
shoaib_ahmed 0:791a779d6220 1687 tmp1 += tmp4 + tmp5 +
shoaib_ahmed 0:791a779d6220 1688 MULTIPLY(tmp11, FIX(0.837223564)) - /* c5+c9+c11-c3 */
shoaib_ahmed 0:791a779d6220 1689 MULTIPLY(tmp14, FIX(2.341699410)); /* c1+c7 */
shoaib_ahmed 0:791a779d6220 1690 tmp6 = MULTIPLY(tmp12 + tmp13, - FIX(0.657217813)); /* -c9 */
shoaib_ahmed 0:791a779d6220 1691 tmp2 += tmp4 + tmp6 -
shoaib_ahmed 0:791a779d6220 1692 MULTIPLY(tmp12, FIX(1.572116027)) + /* c1+c5-c9-c11 */
shoaib_ahmed 0:791a779d6220 1693 MULTIPLY(tmp15, FIX(2.260109708)); /* c3+c7 */
shoaib_ahmed 0:791a779d6220 1694 tmp3 += tmp5 + tmp6 +
shoaib_ahmed 0:791a779d6220 1695 MULTIPLY(tmp13, FIX(2.205608352)) - /* c3+c5+c9-c7 */
shoaib_ahmed 0:791a779d6220 1696 MULTIPLY(tmp15, FIX(1.742345811)); /* c1+c11 */
shoaib_ahmed 0:791a779d6220 1697
shoaib_ahmed 0:791a779d6220 1698 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1699 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1700 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1701 dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS);
shoaib_ahmed 0:791a779d6220 1702
shoaib_ahmed 0:791a779d6220 1703 ctr++;
shoaib_ahmed 0:791a779d6220 1704
shoaib_ahmed 0:791a779d6220 1705 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1706 if (ctr == 13)
shoaib_ahmed 0:791a779d6220 1707 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1708 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1709 } else
shoaib_ahmed 0:791a779d6220 1710 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1711 }
shoaib_ahmed 0:791a779d6220 1712
shoaib_ahmed 0:791a779d6220 1713 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1714 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1715 * We must also scale the output by (8/13)**2 = 64/169, which we partially
shoaib_ahmed 0:791a779d6220 1716 * fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 1717 * cK now represents sqrt(2) * cos(K*pi/26) * 128/169.
shoaib_ahmed 0:791a779d6220 1718 */
shoaib_ahmed 0:791a779d6220 1719
shoaib_ahmed 0:791a779d6220 1720 dataptr = data;
shoaib_ahmed 0:791a779d6220 1721 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1722 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1723 /* Even part */
shoaib_ahmed 0:791a779d6220 1724
shoaib_ahmed 0:791a779d6220 1725 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 1726 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1727 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1728 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1729 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1730 tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1731 tmp6 = dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 1732
shoaib_ahmed 0:791a779d6220 1733 tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 1734 tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1735 tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1736 tmp13 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1737 tmp14 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1738 tmp15 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1739
shoaib_ahmed 0:791a779d6220 1740 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1741 DESCALE(MULTIPLY(tmp0 + tmp1 + tmp2 + tmp3 + tmp4 + tmp5 + tmp6,
shoaib_ahmed 0:791a779d6220 1742 FIX(0.757396450)), /* 128/169 */
shoaib_ahmed 0:791a779d6220 1743 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1744 tmp6 += tmp6;
shoaib_ahmed 0:791a779d6220 1745 tmp0 -= tmp6;
shoaib_ahmed 0:791a779d6220 1746 tmp1 -= tmp6;
shoaib_ahmed 0:791a779d6220 1747 tmp2 -= tmp6;
shoaib_ahmed 0:791a779d6220 1748 tmp3 -= tmp6;
shoaib_ahmed 0:791a779d6220 1749 tmp4 -= tmp6;
shoaib_ahmed 0:791a779d6220 1750 tmp5 -= tmp6;
shoaib_ahmed 0:791a779d6220 1751 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1752 DESCALE(MULTIPLY(tmp0, FIX(1.039995521)) + /* c2 */
shoaib_ahmed 0:791a779d6220 1753 MULTIPLY(tmp1, FIX(0.801745081)) + /* c6 */
shoaib_ahmed 0:791a779d6220 1754 MULTIPLY(tmp2, FIX(0.379824504)) - /* c10 */
shoaib_ahmed 0:791a779d6220 1755 MULTIPLY(tmp3, FIX(0.129109289)) - /* c12 */
shoaib_ahmed 0:791a779d6220 1756 MULTIPLY(tmp4, FIX(0.608465700)) - /* c8 */
shoaib_ahmed 0:791a779d6220 1757 MULTIPLY(tmp5, FIX(0.948429952)), /* c4 */
shoaib_ahmed 0:791a779d6220 1758 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1759 z1 = MULTIPLY(tmp0 - tmp2, FIX(0.875087516)) - /* (c4+c6)/2 */
shoaib_ahmed 0:791a779d6220 1760 MULTIPLY(tmp3 - tmp4, FIX(0.330085509)) - /* (c2-c10)/2 */
shoaib_ahmed 0:791a779d6220 1761 MULTIPLY(tmp1 - tmp5, FIX(0.239678205)); /* (c8-c12)/2 */
shoaib_ahmed 0:791a779d6220 1762 z2 = MULTIPLY(tmp0 + tmp2, FIX(0.073342435)) - /* (c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 1763 MULTIPLY(tmp3 + tmp4, FIX(0.709910013)) + /* (c2+c10)/2 */
shoaib_ahmed 0:791a779d6220 1764 MULTIPLY(tmp1 + tmp5, FIX(0.368787494)); /* (c8+c12)/2 */
shoaib_ahmed 0:791a779d6220 1765
shoaib_ahmed 0:791a779d6220 1766 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1767 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 - z2, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1768
shoaib_ahmed 0:791a779d6220 1769 /* Odd part */
shoaib_ahmed 0:791a779d6220 1770
shoaib_ahmed 0:791a779d6220 1771 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.001514908)); /* c3 */
shoaib_ahmed 0:791a779d6220 1772 tmp2 = MULTIPLY(tmp10 + tmp12, FIX(0.881514751)); /* c5 */
shoaib_ahmed 0:791a779d6220 1773 tmp3 = MULTIPLY(tmp10 + tmp13, FIX(0.710284161)) + /* c7 */
shoaib_ahmed 0:791a779d6220 1774 MULTIPLY(tmp14 + tmp15, FIX(0.256335874)); /* c11 */
shoaib_ahmed 0:791a779d6220 1775 tmp0 = tmp1 + tmp2 + tmp3 -
shoaib_ahmed 0:791a779d6220 1776 MULTIPLY(tmp10, FIX(1.530003162)) + /* c3+c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 1777 MULTIPLY(tmp14, FIX(0.241438564)); /* c9-c11 */
shoaib_ahmed 0:791a779d6220 1778 tmp4 = MULTIPLY(tmp14 - tmp15, FIX(0.710284161)) - /* c7 */
shoaib_ahmed 0:791a779d6220 1779 MULTIPLY(tmp11 + tmp12, FIX(0.256335874)); /* c11 */
shoaib_ahmed 0:791a779d6220 1780 tmp5 = MULTIPLY(tmp11 + tmp13, - FIX(0.881514751)); /* -c5 */
shoaib_ahmed 0:791a779d6220 1781 tmp1 += tmp4 + tmp5 +
shoaib_ahmed 0:791a779d6220 1782 MULTIPLY(tmp11, FIX(0.634110155)) - /* c5+c9+c11-c3 */
shoaib_ahmed 0:791a779d6220 1783 MULTIPLY(tmp14, FIX(1.773594819)); /* c1+c7 */
shoaib_ahmed 0:791a779d6220 1784 tmp6 = MULTIPLY(tmp12 + tmp13, - FIX(0.497774438)); /* -c9 */
shoaib_ahmed 0:791a779d6220 1785 tmp2 += tmp4 + tmp6 -
shoaib_ahmed 0:791a779d6220 1786 MULTIPLY(tmp12, FIX(1.190715098)) + /* c1+c5-c9-c11 */
shoaib_ahmed 0:791a779d6220 1787 MULTIPLY(tmp15, FIX(1.711799069)); /* c3+c7 */
shoaib_ahmed 0:791a779d6220 1788 tmp3 += tmp5 + tmp6 +
shoaib_ahmed 0:791a779d6220 1789 MULTIPLY(tmp13, FIX(1.670519935)) - /* c3+c5+c9-c7 */
shoaib_ahmed 0:791a779d6220 1790 MULTIPLY(tmp15, FIX(1.319646532)); /* c1+c11 */
shoaib_ahmed 0:791a779d6220 1791
shoaib_ahmed 0:791a779d6220 1792 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1793 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1794 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1795 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1796
shoaib_ahmed 0:791a779d6220 1797 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1798 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1799 }
shoaib_ahmed 0:791a779d6220 1800 }
shoaib_ahmed 0:791a779d6220 1801
shoaib_ahmed 0:791a779d6220 1802
shoaib_ahmed 0:791a779d6220 1803 /*
shoaib_ahmed 0:791a779d6220 1804 * Perform the forward DCT on a 14x14 sample block.
shoaib_ahmed 0:791a779d6220 1805 */
shoaib_ahmed 0:791a779d6220 1806
shoaib_ahmed 0:791a779d6220 1807 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 1808 jpeg_fdct_14x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 1809 {
shoaib_ahmed 0:791a779d6220 1810 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
shoaib_ahmed 0:791a779d6220 1811 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
shoaib_ahmed 0:791a779d6220 1812 DCTELEM workspace[8*6];
shoaib_ahmed 0:791a779d6220 1813 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 1814 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 1815 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 1816 int ctr;
shoaib_ahmed 0:791a779d6220 1817 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 1818
shoaib_ahmed 0:791a779d6220 1819 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 1820 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 1821 * cK represents sqrt(2) * cos(K*pi/28).
shoaib_ahmed 0:791a779d6220 1822 */
shoaib_ahmed 0:791a779d6220 1823
shoaib_ahmed 0:791a779d6220 1824 dataptr = data;
shoaib_ahmed 0:791a779d6220 1825 ctr = 0;
shoaib_ahmed 0:791a779d6220 1826 for (;;) {
shoaib_ahmed 0:791a779d6220 1827 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 1828
shoaib_ahmed 0:791a779d6220 1829 /* Even part */
shoaib_ahmed 0:791a779d6220 1830
shoaib_ahmed 0:791a779d6220 1831 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 1832 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 1833 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1834 tmp13 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1835 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1836 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1837 tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1838
shoaib_ahmed 0:791a779d6220 1839 tmp10 = tmp0 + tmp6;
shoaib_ahmed 0:791a779d6220 1840 tmp14 = tmp0 - tmp6;
shoaib_ahmed 0:791a779d6220 1841 tmp11 = tmp1 + tmp5;
shoaib_ahmed 0:791a779d6220 1842 tmp15 = tmp1 - tmp5;
shoaib_ahmed 0:791a779d6220 1843 tmp12 = tmp2 + tmp4;
shoaib_ahmed 0:791a779d6220 1844 tmp16 = tmp2 - tmp4;
shoaib_ahmed 0:791a779d6220 1845
shoaib_ahmed 0:791a779d6220 1846 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 1847 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 1848 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 1849 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 1850 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 1851 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 1852 tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 1853
shoaib_ahmed 0:791a779d6220 1854 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 1855 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1856 (tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE);
shoaib_ahmed 0:791a779d6220 1857 tmp13 += tmp13;
shoaib_ahmed 0:791a779d6220 1858 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1859 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.274162392)) + /* c4 */
shoaib_ahmed 0:791a779d6220 1860 MULTIPLY(tmp11 - tmp13, FIX(0.314692123)) - /* c12 */
shoaib_ahmed 0:791a779d6220 1861 MULTIPLY(tmp12 - tmp13, FIX(0.881747734)), /* c8 */
shoaib_ahmed 0:791a779d6220 1862 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1863
shoaib_ahmed 0:791a779d6220 1864 tmp10 = MULTIPLY(tmp14 + tmp15, FIX(1.105676686)); /* c6 */
shoaib_ahmed 0:791a779d6220 1865
shoaib_ahmed 0:791a779d6220 1866 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1867 DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.273079590)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 1868 + MULTIPLY(tmp16, FIX(0.613604268)), /* c10 */
shoaib_ahmed 0:791a779d6220 1869 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1870 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1871 DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.719280954)) /* c6+c10 */
shoaib_ahmed 0:791a779d6220 1872 - MULTIPLY(tmp16, FIX(1.378756276)), /* c2 */
shoaib_ahmed 0:791a779d6220 1873 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1874
shoaib_ahmed 0:791a779d6220 1875 /* Odd part */
shoaib_ahmed 0:791a779d6220 1876
shoaib_ahmed 0:791a779d6220 1877 tmp10 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 1878 tmp11 = tmp5 - tmp4;
shoaib_ahmed 0:791a779d6220 1879 dataptr[7] = (DCTELEM) (tmp0 - tmp10 + tmp3 - tmp11 - tmp6);
shoaib_ahmed 0:791a779d6220 1880 tmp3 <<= CONST_BITS;
shoaib_ahmed 0:791a779d6220 1881 tmp10 = MULTIPLY(tmp10, - FIX(0.158341681)); /* -c13 */
shoaib_ahmed 0:791a779d6220 1882 tmp11 = MULTIPLY(tmp11, FIX(1.405321284)); /* c1 */
shoaib_ahmed 0:791a779d6220 1883 tmp10 += tmp11 - tmp3;
shoaib_ahmed 0:791a779d6220 1884 tmp11 = MULTIPLY(tmp0 + tmp2, FIX(1.197448846)) + /* c5 */
shoaib_ahmed 0:791a779d6220 1885 MULTIPLY(tmp4 + tmp6, FIX(0.752406978)); /* c9 */
shoaib_ahmed 0:791a779d6220 1886 dataptr[5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1887 DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(2.373959773)) /* c3+c5-c13 */
shoaib_ahmed 0:791a779d6220 1888 + MULTIPLY(tmp4, FIX(1.119999435)), /* c1+c11-c9 */
shoaib_ahmed 0:791a779d6220 1889 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1890 tmp12 = MULTIPLY(tmp0 + tmp1, FIX(1.334852607)) + /* c3 */
shoaib_ahmed 0:791a779d6220 1891 MULTIPLY(tmp5 - tmp6, FIX(0.467085129)); /* c11 */
shoaib_ahmed 0:791a779d6220 1892 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1893 DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.424103948)) /* c3-c9-c13 */
shoaib_ahmed 0:791a779d6220 1894 - MULTIPLY(tmp5, FIX(3.069855259)), /* c1+c5+c11 */
shoaib_ahmed 0:791a779d6220 1895 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1896 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1897 DESCALE(tmp11 + tmp12 + tmp3 + tmp6 -
shoaib_ahmed 0:791a779d6220 1898 MULTIPLY(tmp0 + tmp6, FIX(1.126980169)), /* c3+c5-c1 */
shoaib_ahmed 0:791a779d6220 1899 CONST_BITS);
shoaib_ahmed 0:791a779d6220 1900
shoaib_ahmed 0:791a779d6220 1901 ctr++;
shoaib_ahmed 0:791a779d6220 1902
shoaib_ahmed 0:791a779d6220 1903 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 1904 if (ctr == 14)
shoaib_ahmed 0:791a779d6220 1905 break; /* Done. */
shoaib_ahmed 0:791a779d6220 1906 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 1907 } else
shoaib_ahmed 0:791a779d6220 1908 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 1909 }
shoaib_ahmed 0:791a779d6220 1910
shoaib_ahmed 0:791a779d6220 1911 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 1912 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 1913 * We must also scale the output by (8/14)**2 = 16/49, which we partially
shoaib_ahmed 0:791a779d6220 1914 * fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 1915 * cK now represents sqrt(2) * cos(K*pi/28) * 32/49.
shoaib_ahmed 0:791a779d6220 1916 */
shoaib_ahmed 0:791a779d6220 1917
shoaib_ahmed 0:791a779d6220 1918 dataptr = data;
shoaib_ahmed 0:791a779d6220 1919 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 1920 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 1921 /* Even part */
shoaib_ahmed 0:791a779d6220 1922
shoaib_ahmed 0:791a779d6220 1923 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1924 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 1925 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1926 tmp13 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1927 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1928 tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1929 tmp6 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1930
shoaib_ahmed 0:791a779d6220 1931 tmp10 = tmp0 + tmp6;
shoaib_ahmed 0:791a779d6220 1932 tmp14 = tmp0 - tmp6;
shoaib_ahmed 0:791a779d6220 1933 tmp11 = tmp1 + tmp5;
shoaib_ahmed 0:791a779d6220 1934 tmp15 = tmp1 - tmp5;
shoaib_ahmed 0:791a779d6220 1935 tmp12 = tmp2 + tmp4;
shoaib_ahmed 0:791a779d6220 1936 tmp16 = tmp2 - tmp4;
shoaib_ahmed 0:791a779d6220 1937
shoaib_ahmed 0:791a779d6220 1938 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 1939 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 1940 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 1941 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 1942 tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 1943 tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 1944 tmp6 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 1945
shoaib_ahmed 0:791a779d6220 1946 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1947 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12 + tmp13,
shoaib_ahmed 0:791a779d6220 1948 FIX(0.653061224)), /* 32/49 */
shoaib_ahmed 0:791a779d6220 1949 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1950 tmp13 += tmp13;
shoaib_ahmed 0:791a779d6220 1951 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1952 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(0.832106052)) + /* c4 */
shoaib_ahmed 0:791a779d6220 1953 MULTIPLY(tmp11 - tmp13, FIX(0.205513223)) - /* c12 */
shoaib_ahmed 0:791a779d6220 1954 MULTIPLY(tmp12 - tmp13, FIX(0.575835255)), /* c8 */
shoaib_ahmed 0:791a779d6220 1955 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1956
shoaib_ahmed 0:791a779d6220 1957 tmp10 = MULTIPLY(tmp14 + tmp15, FIX(0.722074570)); /* c6 */
shoaib_ahmed 0:791a779d6220 1958
shoaib_ahmed 0:791a779d6220 1959 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1960 DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.178337691)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 1961 + MULTIPLY(tmp16, FIX(0.400721155)), /* c10 */
shoaib_ahmed 0:791a779d6220 1962 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1963 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1964 DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.122795725)) /* c6+c10 */
shoaib_ahmed 0:791a779d6220 1965 - MULTIPLY(tmp16, FIX(0.900412262)), /* c2 */
shoaib_ahmed 0:791a779d6220 1966 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1967
shoaib_ahmed 0:791a779d6220 1968 /* Odd part */
shoaib_ahmed 0:791a779d6220 1969
shoaib_ahmed 0:791a779d6220 1970 tmp10 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 1971 tmp11 = tmp5 - tmp4;
shoaib_ahmed 0:791a779d6220 1972 dataptr[DCTSIZE*7] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1973 DESCALE(MULTIPLY(tmp0 - tmp10 + tmp3 - tmp11 - tmp6,
shoaib_ahmed 0:791a779d6220 1974 FIX(0.653061224)), /* 32/49 */
shoaib_ahmed 0:791a779d6220 1975 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1976 tmp3 = MULTIPLY(tmp3 , FIX(0.653061224)); /* 32/49 */
shoaib_ahmed 0:791a779d6220 1977 tmp10 = MULTIPLY(tmp10, - FIX(0.103406812)); /* -c13 */
shoaib_ahmed 0:791a779d6220 1978 tmp11 = MULTIPLY(tmp11, FIX(0.917760839)); /* c1 */
shoaib_ahmed 0:791a779d6220 1979 tmp10 += tmp11 - tmp3;
shoaib_ahmed 0:791a779d6220 1980 tmp11 = MULTIPLY(tmp0 + tmp2, FIX(0.782007410)) + /* c5 */
shoaib_ahmed 0:791a779d6220 1981 MULTIPLY(tmp4 + tmp6, FIX(0.491367823)); /* c9 */
shoaib_ahmed 0:791a779d6220 1982 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1983 DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(1.550341076)) /* c3+c5-c13 */
shoaib_ahmed 0:791a779d6220 1984 + MULTIPLY(tmp4, FIX(0.731428202)), /* c1+c11-c9 */
shoaib_ahmed 0:791a779d6220 1985 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1986 tmp12 = MULTIPLY(tmp0 + tmp1, FIX(0.871740478)) + /* c3 */
shoaib_ahmed 0:791a779d6220 1987 MULTIPLY(tmp5 - tmp6, FIX(0.305035186)); /* c11 */
shoaib_ahmed 0:791a779d6220 1988 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1989 DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.276965844)) /* c3-c9-c13 */
shoaib_ahmed 0:791a779d6220 1990 - MULTIPLY(tmp5, FIX(2.004803435)), /* c1+c5+c11 */
shoaib_ahmed 0:791a779d6220 1991 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1992 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 1993 DESCALE(tmp11 + tmp12 + tmp3
shoaib_ahmed 0:791a779d6220 1994 - MULTIPLY(tmp0, FIX(0.735987049)) /* c3+c5-c1 */
shoaib_ahmed 0:791a779d6220 1995 - MULTIPLY(tmp6, FIX(0.082925825)), /* c9-c11-c13 */
shoaib_ahmed 0:791a779d6220 1996 CONST_BITS+1);
shoaib_ahmed 0:791a779d6220 1997
shoaib_ahmed 0:791a779d6220 1998 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 1999 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2000 }
shoaib_ahmed 0:791a779d6220 2001 }
shoaib_ahmed 0:791a779d6220 2002
shoaib_ahmed 0:791a779d6220 2003
shoaib_ahmed 0:791a779d6220 2004 /*
shoaib_ahmed 0:791a779d6220 2005 * Perform the forward DCT on a 15x15 sample block.
shoaib_ahmed 0:791a779d6220 2006 */
shoaib_ahmed 0:791a779d6220 2007
shoaib_ahmed 0:791a779d6220 2008 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2009 jpeg_fdct_15x15 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2010 {
shoaib_ahmed 0:791a779d6220 2011 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
shoaib_ahmed 0:791a779d6220 2012 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
shoaib_ahmed 0:791a779d6220 2013 INT32 z1, z2, z3;
shoaib_ahmed 0:791a779d6220 2014 DCTELEM workspace[8*7];
shoaib_ahmed 0:791a779d6220 2015 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2016 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 2017 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2018 int ctr;
shoaib_ahmed 0:791a779d6220 2019 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2020
shoaib_ahmed 0:791a779d6220 2021 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2022 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 2023 * cK represents sqrt(2) * cos(K*pi/30).
shoaib_ahmed 0:791a779d6220 2024 */
shoaib_ahmed 0:791a779d6220 2025
shoaib_ahmed 0:791a779d6220 2026 dataptr = data;
shoaib_ahmed 0:791a779d6220 2027 ctr = 0;
shoaib_ahmed 0:791a779d6220 2028 for (;;) {
shoaib_ahmed 0:791a779d6220 2029 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2030
shoaib_ahmed 0:791a779d6220 2031 /* Even part */
shoaib_ahmed 0:791a779d6220 2032
shoaib_ahmed 0:791a779d6220 2033 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2034 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2035 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2036 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2037 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2038 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2039 tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2040 tmp7 = GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2041
shoaib_ahmed 0:791a779d6220 2042 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2043 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2044 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2045 tmp13 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2046 tmp14 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2047 tmp15 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2048 tmp16 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2049
shoaib_ahmed 0:791a779d6220 2050 z1 = tmp0 + tmp4 + tmp5;
shoaib_ahmed 0:791a779d6220 2051 z2 = tmp1 + tmp3 + tmp6;
shoaib_ahmed 0:791a779d6220 2052 z3 = tmp2 + tmp7;
shoaib_ahmed 0:791a779d6220 2053 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2054 dataptr[0] = (DCTELEM) (z1 + z2 + z3 - 15 * CENTERJSAMPLE);
shoaib_ahmed 0:791a779d6220 2055 z3 += z3;
shoaib_ahmed 0:791a779d6220 2056 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2057 DESCALE(MULTIPLY(z1 - z3, FIX(1.144122806)) - /* c6 */
shoaib_ahmed 0:791a779d6220 2058 MULTIPLY(z2 - z3, FIX(0.437016024)), /* c12 */
shoaib_ahmed 0:791a779d6220 2059 CONST_BITS);
shoaib_ahmed 0:791a779d6220 2060 tmp2 += ((tmp1 + tmp4) >> 1) - tmp7 - tmp7;
shoaib_ahmed 0:791a779d6220 2061 z1 = MULTIPLY(tmp3 - tmp2, FIX(1.531135173)) - /* c2+c14 */
shoaib_ahmed 0:791a779d6220 2062 MULTIPLY(tmp6 - tmp2, FIX(2.238241955)); /* c4+c8 */
shoaib_ahmed 0:791a779d6220 2063 z2 = MULTIPLY(tmp5 - tmp2, FIX(0.798468008)) - /* c8-c14 */
shoaib_ahmed 0:791a779d6220 2064 MULTIPLY(tmp0 - tmp2, FIX(0.091361227)); /* c2-c4 */
shoaib_ahmed 0:791a779d6220 2065 z3 = MULTIPLY(tmp0 - tmp3, FIX(1.383309603)) + /* c2 */
shoaib_ahmed 0:791a779d6220 2066 MULTIPLY(tmp6 - tmp5, FIX(0.946293579)) + /* c8 */
shoaib_ahmed 0:791a779d6220 2067 MULTIPLY(tmp1 - tmp4, FIX(0.790569415)); /* (c6+c12)/2 */
shoaib_ahmed 0:791a779d6220 2068
shoaib_ahmed 0:791a779d6220 2069 dataptr[2] = (DCTELEM) DESCALE(z1 + z3, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2070 dataptr[4] = (DCTELEM) DESCALE(z2 + z3, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2071
shoaib_ahmed 0:791a779d6220 2072 /* Odd part */
shoaib_ahmed 0:791a779d6220 2073
shoaib_ahmed 0:791a779d6220 2074 tmp2 = MULTIPLY(tmp10 - tmp12 - tmp13 + tmp15 + tmp16,
shoaib_ahmed 0:791a779d6220 2075 FIX(1.224744871)); /* c5 */
shoaib_ahmed 0:791a779d6220 2076 tmp1 = MULTIPLY(tmp10 - tmp14 - tmp15, FIX(1.344997024)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2077 MULTIPLY(tmp11 - tmp13 - tmp16, FIX(0.831253876)); /* c9 */
shoaib_ahmed 0:791a779d6220 2078 tmp12 = MULTIPLY(tmp12, FIX(1.224744871)); /* c5 */
shoaib_ahmed 0:791a779d6220 2079 tmp4 = MULTIPLY(tmp10 - tmp16, FIX(1.406466353)) + /* c1 */
shoaib_ahmed 0:791a779d6220 2080 MULTIPLY(tmp11 + tmp14, FIX(1.344997024)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2081 MULTIPLY(tmp13 + tmp15, FIX(0.575212477)); /* c11 */
shoaib_ahmed 0:791a779d6220 2082 tmp0 = MULTIPLY(tmp13, FIX(0.475753014)) - /* c7-c11 */
shoaib_ahmed 0:791a779d6220 2083 MULTIPLY(tmp14, FIX(0.513743148)) + /* c3-c9 */
shoaib_ahmed 0:791a779d6220 2084 MULTIPLY(tmp16, FIX(1.700497885)) + tmp4 + tmp12; /* c1+c13 */
shoaib_ahmed 0:791a779d6220 2085 tmp3 = MULTIPLY(tmp10, - FIX(0.355500862)) - /* -(c1-c7) */
shoaib_ahmed 0:791a779d6220 2086 MULTIPLY(tmp11, FIX(2.176250899)) - /* c3+c9 */
shoaib_ahmed 0:791a779d6220 2087 MULTIPLY(tmp15, FIX(0.869244010)) + tmp4 - tmp12; /* c11+c13 */
shoaib_ahmed 0:791a779d6220 2088
shoaib_ahmed 0:791a779d6220 2089 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2090 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2091 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2092 dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS);
shoaib_ahmed 0:791a779d6220 2093
shoaib_ahmed 0:791a779d6220 2094 ctr++;
shoaib_ahmed 0:791a779d6220 2095
shoaib_ahmed 0:791a779d6220 2096 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 2097 if (ctr == 15)
shoaib_ahmed 0:791a779d6220 2098 break; /* Done. */
shoaib_ahmed 0:791a779d6220 2099 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2100 } else
shoaib_ahmed 0:791a779d6220 2101 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 2102 }
shoaib_ahmed 0:791a779d6220 2103
shoaib_ahmed 0:791a779d6220 2104 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2105 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2106 * We must also scale the output by (8/15)**2 = 64/225, which we partially
shoaib_ahmed 0:791a779d6220 2107 * fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 2108 * cK now represents sqrt(2) * cos(K*pi/30) * 256/225.
shoaib_ahmed 0:791a779d6220 2109 */
shoaib_ahmed 0:791a779d6220 2110
shoaib_ahmed 0:791a779d6220 2111 dataptr = data;
shoaib_ahmed 0:791a779d6220 2112 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 2113 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2114 /* Even part */
shoaib_ahmed 0:791a779d6220 2115
shoaib_ahmed 0:791a779d6220 2116 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2117 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2118 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2119 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2120 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 2121 tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 2122 tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 2123 tmp7 = dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 2124
shoaib_ahmed 0:791a779d6220 2125 tmp10 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2126 tmp11 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2127 tmp12 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2128 tmp13 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2129 tmp14 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 2130 tmp15 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 2131 tmp16 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 2132
shoaib_ahmed 0:791a779d6220 2133 z1 = tmp0 + tmp4 + tmp5;
shoaib_ahmed 0:791a779d6220 2134 z2 = tmp1 + tmp3 + tmp6;
shoaib_ahmed 0:791a779d6220 2135 z3 = tmp2 + tmp7;
shoaib_ahmed 0:791a779d6220 2136 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2137 DESCALE(MULTIPLY(z1 + z2 + z3, FIX(1.137777778)), /* 256/225 */
shoaib_ahmed 0:791a779d6220 2138 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2139 z3 += z3;
shoaib_ahmed 0:791a779d6220 2140 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2141 DESCALE(MULTIPLY(z1 - z3, FIX(1.301757503)) - /* c6 */
shoaib_ahmed 0:791a779d6220 2142 MULTIPLY(z2 - z3, FIX(0.497227121)), /* c12 */
shoaib_ahmed 0:791a779d6220 2143 CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2144 tmp2 += ((tmp1 + tmp4) >> 1) - tmp7 - tmp7;
shoaib_ahmed 0:791a779d6220 2145 z1 = MULTIPLY(tmp3 - tmp2, FIX(1.742091575)) - /* c2+c14 */
shoaib_ahmed 0:791a779d6220 2146 MULTIPLY(tmp6 - tmp2, FIX(2.546621957)); /* c4+c8 */
shoaib_ahmed 0:791a779d6220 2147 z2 = MULTIPLY(tmp5 - tmp2, FIX(0.908479156)) - /* c8-c14 */
shoaib_ahmed 0:791a779d6220 2148 MULTIPLY(tmp0 - tmp2, FIX(0.103948774)); /* c2-c4 */
shoaib_ahmed 0:791a779d6220 2149 z3 = MULTIPLY(tmp0 - tmp3, FIX(1.573898926)) + /* c2 */
shoaib_ahmed 0:791a779d6220 2150 MULTIPLY(tmp6 - tmp5, FIX(1.076671805)) + /* c8 */
shoaib_ahmed 0:791a779d6220 2151 MULTIPLY(tmp1 - tmp4, FIX(0.899492312)); /* (c6+c12)/2 */
shoaib_ahmed 0:791a779d6220 2152
shoaib_ahmed 0:791a779d6220 2153 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z3, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2154 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(z2 + z3, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2155
shoaib_ahmed 0:791a779d6220 2156 /* Odd part */
shoaib_ahmed 0:791a779d6220 2157
shoaib_ahmed 0:791a779d6220 2158 tmp2 = MULTIPLY(tmp10 - tmp12 - tmp13 + tmp15 + tmp16,
shoaib_ahmed 0:791a779d6220 2159 FIX(1.393487498)); /* c5 */
shoaib_ahmed 0:791a779d6220 2160 tmp1 = MULTIPLY(tmp10 - tmp14 - tmp15, FIX(1.530307725)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2161 MULTIPLY(tmp11 - tmp13 - tmp16, FIX(0.945782187)); /* c9 */
shoaib_ahmed 0:791a779d6220 2162 tmp12 = MULTIPLY(tmp12, FIX(1.393487498)); /* c5 */
shoaib_ahmed 0:791a779d6220 2163 tmp4 = MULTIPLY(tmp10 - tmp16, FIX(1.600246161)) + /* c1 */
shoaib_ahmed 0:791a779d6220 2164 MULTIPLY(tmp11 + tmp14, FIX(1.530307725)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2165 MULTIPLY(tmp13 + tmp15, FIX(0.654463974)); /* c11 */
shoaib_ahmed 0:791a779d6220 2166 tmp0 = MULTIPLY(tmp13, FIX(0.541301207)) - /* c7-c11 */
shoaib_ahmed 0:791a779d6220 2167 MULTIPLY(tmp14, FIX(0.584525538)) + /* c3-c9 */
shoaib_ahmed 0:791a779d6220 2168 MULTIPLY(tmp16, FIX(1.934788705)) + tmp4 + tmp12; /* c1+c13 */
shoaib_ahmed 0:791a779d6220 2169 tmp3 = MULTIPLY(tmp10, - FIX(0.404480980)) - /* -(c1-c7) */
shoaib_ahmed 0:791a779d6220 2170 MULTIPLY(tmp11, FIX(2.476089912)) - /* c3+c9 */
shoaib_ahmed 0:791a779d6220 2171 MULTIPLY(tmp15, FIX(0.989006518)) + tmp4 - tmp12; /* c11+c13 */
shoaib_ahmed 0:791a779d6220 2172
shoaib_ahmed 0:791a779d6220 2173 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2174 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2175 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2176 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+2);
shoaib_ahmed 0:791a779d6220 2177
shoaib_ahmed 0:791a779d6220 2178 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2179 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2180 }
shoaib_ahmed 0:791a779d6220 2181 }
shoaib_ahmed 0:791a779d6220 2182
shoaib_ahmed 0:791a779d6220 2183
shoaib_ahmed 0:791a779d6220 2184 /*
shoaib_ahmed 0:791a779d6220 2185 * Perform the forward DCT on a 16x16 sample block.
shoaib_ahmed 0:791a779d6220 2186 */
shoaib_ahmed 0:791a779d6220 2187
shoaib_ahmed 0:791a779d6220 2188 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2189 jpeg_fdct_16x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2190 {
shoaib_ahmed 0:791a779d6220 2191 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
shoaib_ahmed 0:791a779d6220 2192 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17;
shoaib_ahmed 0:791a779d6220 2193 DCTELEM workspace[DCTSIZE2];
shoaib_ahmed 0:791a779d6220 2194 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2195 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 2196 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2197 int ctr;
shoaib_ahmed 0:791a779d6220 2198 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2199
shoaib_ahmed 0:791a779d6220 2200 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2201 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 2202 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 2203 * cK represents sqrt(2) * cos(K*pi/32).
shoaib_ahmed 0:791a779d6220 2204 */
shoaib_ahmed 0:791a779d6220 2205
shoaib_ahmed 0:791a779d6220 2206 dataptr = data;
shoaib_ahmed 0:791a779d6220 2207 ctr = 0;
shoaib_ahmed 0:791a779d6220 2208 for (;;) {
shoaib_ahmed 0:791a779d6220 2209 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2210
shoaib_ahmed 0:791a779d6220 2211 /* Even part */
shoaib_ahmed 0:791a779d6220 2212
shoaib_ahmed 0:791a779d6220 2213 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[15]);
shoaib_ahmed 0:791a779d6220 2214 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2215 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2216 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2217 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2218 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2219 tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2220 tmp7 = GETJSAMPLE(elemptr[7]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2221
shoaib_ahmed 0:791a779d6220 2222 tmp10 = tmp0 + tmp7;
shoaib_ahmed 0:791a779d6220 2223 tmp14 = tmp0 - tmp7;
shoaib_ahmed 0:791a779d6220 2224 tmp11 = tmp1 + tmp6;
shoaib_ahmed 0:791a779d6220 2225 tmp15 = tmp1 - tmp6;
shoaib_ahmed 0:791a779d6220 2226 tmp12 = tmp2 + tmp5;
shoaib_ahmed 0:791a779d6220 2227 tmp16 = tmp2 - tmp5;
shoaib_ahmed 0:791a779d6220 2228 tmp13 = tmp3 + tmp4;
shoaib_ahmed 0:791a779d6220 2229 tmp17 = tmp3 - tmp4;
shoaib_ahmed 0:791a779d6220 2230
shoaib_ahmed 0:791a779d6220 2231 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[15]);
shoaib_ahmed 0:791a779d6220 2232 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2233 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2234 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2235 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2236 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2237 tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2238 tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2239
shoaib_ahmed 0:791a779d6220 2240 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2241 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2242 ((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2243 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2244 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */
shoaib_ahmed 0:791a779d6220 2245 MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */
shoaib_ahmed 0:791a779d6220 2246 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2247
shoaib_ahmed 0:791a779d6220 2248 tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */
shoaib_ahmed 0:791a779d6220 2249 MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */
shoaib_ahmed 0:791a779d6220 2250
shoaib_ahmed 0:791a779d6220 2251 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2252 DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */
shoaib_ahmed 0:791a779d6220 2253 + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */
shoaib_ahmed 0:791a779d6220 2254 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2255 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2256 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2257 - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */
shoaib_ahmed 0:791a779d6220 2258 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2259
shoaib_ahmed 0:791a779d6220 2260 /* Odd part */
shoaib_ahmed 0:791a779d6220 2261
shoaib_ahmed 0:791a779d6220 2262 tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2263 MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2264 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */
shoaib_ahmed 0:791a779d6220 2265 MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */
shoaib_ahmed 0:791a779d6220 2266 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */
shoaib_ahmed 0:791a779d6220 2267 MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */
shoaib_ahmed 0:791a779d6220 2268 tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */
shoaib_ahmed 0:791a779d6220 2269 MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */
shoaib_ahmed 0:791a779d6220 2270 tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */
shoaib_ahmed 0:791a779d6220 2271 MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */
shoaib_ahmed 0:791a779d6220 2272 tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */
shoaib_ahmed 0:791a779d6220 2273 MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2274 tmp10 = tmp11 + tmp12 + tmp13 -
shoaib_ahmed 0:791a779d6220 2275 MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 2276 MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */
shoaib_ahmed 0:791a779d6220 2277 tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */
shoaib_ahmed 0:791a779d6220 2278 - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */
shoaib_ahmed 0:791a779d6220 2279 tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */
shoaib_ahmed 0:791a779d6220 2280 + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */
shoaib_ahmed 0:791a779d6220 2281 tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */
shoaib_ahmed 0:791a779d6220 2282 + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */
shoaib_ahmed 0:791a779d6220 2283
shoaib_ahmed 0:791a779d6220 2284 dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2285 dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2286 dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2287 dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2288
shoaib_ahmed 0:791a779d6220 2289 ctr++;
shoaib_ahmed 0:791a779d6220 2290
shoaib_ahmed 0:791a779d6220 2291 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 2292 if (ctr == DCTSIZE * 2)
shoaib_ahmed 0:791a779d6220 2293 break; /* Done. */
shoaib_ahmed 0:791a779d6220 2294 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2295 } else
shoaib_ahmed 0:791a779d6220 2296 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 2297 }
shoaib_ahmed 0:791a779d6220 2298
shoaib_ahmed 0:791a779d6220 2299 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2300 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 2301 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2302 * We must also scale the output by (8/16)**2 = 1/2**2.
shoaib_ahmed 0:791a779d6220 2303 * cK represents sqrt(2) * cos(K*pi/32).
shoaib_ahmed 0:791a779d6220 2304 */
shoaib_ahmed 0:791a779d6220 2305
shoaib_ahmed 0:791a779d6220 2306 dataptr = data;
shoaib_ahmed 0:791a779d6220 2307 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 2308 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2309 /* Even part */
shoaib_ahmed 0:791a779d6220 2310
shoaib_ahmed 0:791a779d6220 2311 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 2312 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2313 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2314 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2315 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2316 tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 2317 tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 2318 tmp7 = dataptr[DCTSIZE*7] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 2319
shoaib_ahmed 0:791a779d6220 2320 tmp10 = tmp0 + tmp7;
shoaib_ahmed 0:791a779d6220 2321 tmp14 = tmp0 - tmp7;
shoaib_ahmed 0:791a779d6220 2322 tmp11 = tmp1 + tmp6;
shoaib_ahmed 0:791a779d6220 2323 tmp15 = tmp1 - tmp6;
shoaib_ahmed 0:791a779d6220 2324 tmp12 = tmp2 + tmp5;
shoaib_ahmed 0:791a779d6220 2325 tmp16 = tmp2 - tmp5;
shoaib_ahmed 0:791a779d6220 2326 tmp13 = tmp3 + tmp4;
shoaib_ahmed 0:791a779d6220 2327 tmp17 = tmp3 - tmp4;
shoaib_ahmed 0:791a779d6220 2328
shoaib_ahmed 0:791a779d6220 2329 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 2330 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2331 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2332 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2333 tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2334 tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 2335 tmp6 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 2336 tmp7 = dataptr[DCTSIZE*7] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 2337
shoaib_ahmed 0:791a779d6220 2338 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2339 DESCALE(tmp10 + tmp11 + tmp12 + tmp13, PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2340 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2341 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */
shoaib_ahmed 0:791a779d6220 2342 MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */
shoaib_ahmed 0:791a779d6220 2343 CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2344
shoaib_ahmed 0:791a779d6220 2345 tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */
shoaib_ahmed 0:791a779d6220 2346 MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */
shoaib_ahmed 0:791a779d6220 2347
shoaib_ahmed 0:791a779d6220 2348 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2349 DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */
shoaib_ahmed 0:791a779d6220 2350 + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+10 */
shoaib_ahmed 0:791a779d6220 2351 CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2352 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2353 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2354 - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */
shoaib_ahmed 0:791a779d6220 2355 CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2356
shoaib_ahmed 0:791a779d6220 2357 /* Odd part */
shoaib_ahmed 0:791a779d6220 2358
shoaib_ahmed 0:791a779d6220 2359 tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2360 MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2361 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */
shoaib_ahmed 0:791a779d6220 2362 MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */
shoaib_ahmed 0:791a779d6220 2363 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */
shoaib_ahmed 0:791a779d6220 2364 MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */
shoaib_ahmed 0:791a779d6220 2365 tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */
shoaib_ahmed 0:791a779d6220 2366 MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */
shoaib_ahmed 0:791a779d6220 2367 tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */
shoaib_ahmed 0:791a779d6220 2368 MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */
shoaib_ahmed 0:791a779d6220 2369 tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */
shoaib_ahmed 0:791a779d6220 2370 MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2371 tmp10 = tmp11 + tmp12 + tmp13 -
shoaib_ahmed 0:791a779d6220 2372 MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 2373 MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */
shoaib_ahmed 0:791a779d6220 2374 tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */
shoaib_ahmed 0:791a779d6220 2375 - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */
shoaib_ahmed 0:791a779d6220 2376 tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */
shoaib_ahmed 0:791a779d6220 2377 + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */
shoaib_ahmed 0:791a779d6220 2378 tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */
shoaib_ahmed 0:791a779d6220 2379 + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */
shoaib_ahmed 0:791a779d6220 2380
shoaib_ahmed 0:791a779d6220 2381 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2382 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2383 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2384 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS+2);
shoaib_ahmed 0:791a779d6220 2385
shoaib_ahmed 0:791a779d6220 2386 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2387 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2388 }
shoaib_ahmed 0:791a779d6220 2389 }
shoaib_ahmed 0:791a779d6220 2390
shoaib_ahmed 0:791a779d6220 2391
shoaib_ahmed 0:791a779d6220 2392 /*
shoaib_ahmed 0:791a779d6220 2393 * Perform the forward DCT on a 16x8 sample block.
shoaib_ahmed 0:791a779d6220 2394 *
shoaib_ahmed 0:791a779d6220 2395 * 16-point FDCT in pass 1 (rows), 8-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 2396 */
shoaib_ahmed 0:791a779d6220 2397
shoaib_ahmed 0:791a779d6220 2398 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2399 jpeg_fdct_16x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2400 {
shoaib_ahmed 0:791a779d6220 2401 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
shoaib_ahmed 0:791a779d6220 2402 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17;
shoaib_ahmed 0:791a779d6220 2403 INT32 z1;
shoaib_ahmed 0:791a779d6220 2404 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2405 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2406 int ctr;
shoaib_ahmed 0:791a779d6220 2407 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2408
shoaib_ahmed 0:791a779d6220 2409 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2410 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 2411 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 2412 * 16-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
shoaib_ahmed 0:791a779d6220 2413 */
shoaib_ahmed 0:791a779d6220 2414
shoaib_ahmed 0:791a779d6220 2415 dataptr = data;
shoaib_ahmed 0:791a779d6220 2416 ctr = 0;
shoaib_ahmed 0:791a779d6220 2417 for (ctr = 0; ctr < DCTSIZE; ctr++) {
shoaib_ahmed 0:791a779d6220 2418 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2419
shoaib_ahmed 0:791a779d6220 2420 /* Even part */
shoaib_ahmed 0:791a779d6220 2421
shoaib_ahmed 0:791a779d6220 2422 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[15]);
shoaib_ahmed 0:791a779d6220 2423 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2424 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2425 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2426 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2427 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2428 tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2429 tmp7 = GETJSAMPLE(elemptr[7]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2430
shoaib_ahmed 0:791a779d6220 2431 tmp10 = tmp0 + tmp7;
shoaib_ahmed 0:791a779d6220 2432 tmp14 = tmp0 - tmp7;
shoaib_ahmed 0:791a779d6220 2433 tmp11 = tmp1 + tmp6;
shoaib_ahmed 0:791a779d6220 2434 tmp15 = tmp1 - tmp6;
shoaib_ahmed 0:791a779d6220 2435 tmp12 = tmp2 + tmp5;
shoaib_ahmed 0:791a779d6220 2436 tmp16 = tmp2 - tmp5;
shoaib_ahmed 0:791a779d6220 2437 tmp13 = tmp3 + tmp4;
shoaib_ahmed 0:791a779d6220 2438 tmp17 = tmp3 - tmp4;
shoaib_ahmed 0:791a779d6220 2439
shoaib_ahmed 0:791a779d6220 2440 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[15]);
shoaib_ahmed 0:791a779d6220 2441 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[14]);
shoaib_ahmed 0:791a779d6220 2442 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2443 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2444 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2445 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2446 tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2447 tmp7 = GETJSAMPLE(elemptr[7]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2448
shoaib_ahmed 0:791a779d6220 2449 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2450 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2451 ((tmp10 + tmp11 + tmp12 + tmp13 - 16 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2452 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2453 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */
shoaib_ahmed 0:791a779d6220 2454 MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */
shoaib_ahmed 0:791a779d6220 2455 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2456
shoaib_ahmed 0:791a779d6220 2457 tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */
shoaib_ahmed 0:791a779d6220 2458 MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */
shoaib_ahmed 0:791a779d6220 2459
shoaib_ahmed 0:791a779d6220 2460 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2461 DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */
shoaib_ahmed 0:791a779d6220 2462 + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */
shoaib_ahmed 0:791a779d6220 2463 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2464 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2465 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2466 - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */
shoaib_ahmed 0:791a779d6220 2467 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2468
shoaib_ahmed 0:791a779d6220 2469 /* Odd part */
shoaib_ahmed 0:791a779d6220 2470
shoaib_ahmed 0:791a779d6220 2471 tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2472 MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2473 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */
shoaib_ahmed 0:791a779d6220 2474 MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */
shoaib_ahmed 0:791a779d6220 2475 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */
shoaib_ahmed 0:791a779d6220 2476 MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */
shoaib_ahmed 0:791a779d6220 2477 tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */
shoaib_ahmed 0:791a779d6220 2478 MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */
shoaib_ahmed 0:791a779d6220 2479 tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */
shoaib_ahmed 0:791a779d6220 2480 MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */
shoaib_ahmed 0:791a779d6220 2481 tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */
shoaib_ahmed 0:791a779d6220 2482 MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 2483 tmp10 = tmp11 + tmp12 + tmp13 -
shoaib_ahmed 0:791a779d6220 2484 MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 2485 MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */
shoaib_ahmed 0:791a779d6220 2486 tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */
shoaib_ahmed 0:791a779d6220 2487 - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */
shoaib_ahmed 0:791a779d6220 2488 tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */
shoaib_ahmed 0:791a779d6220 2489 + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */
shoaib_ahmed 0:791a779d6220 2490 tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */
shoaib_ahmed 0:791a779d6220 2491 + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */
shoaib_ahmed 0:791a779d6220 2492
shoaib_ahmed 0:791a779d6220 2493 dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2494 dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2495 dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2496 dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2497
shoaib_ahmed 0:791a779d6220 2498 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2499 }
shoaib_ahmed 0:791a779d6220 2500
shoaib_ahmed 0:791a779d6220 2501 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2502 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 2503 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2504 * We must also scale the output by 8/16 = 1/2.
shoaib_ahmed 0:791a779d6220 2505 * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 2506 */
shoaib_ahmed 0:791a779d6220 2507
shoaib_ahmed 0:791a779d6220 2508 dataptr = data;
shoaib_ahmed 0:791a779d6220 2509 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2510 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 2511 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 2512 */
shoaib_ahmed 0:791a779d6220 2513
shoaib_ahmed 0:791a779d6220 2514 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 2515 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2516 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2517 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2518
shoaib_ahmed 0:791a779d6220 2519 tmp10 = tmp0 + tmp3;
shoaib_ahmed 0:791a779d6220 2520 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 2521 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 2522 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 2523
shoaib_ahmed 0:791a779d6220 2524 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 2525 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2526 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2527 tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2528
shoaib_ahmed 0:791a779d6220 2529 dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2530 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2531
shoaib_ahmed 0:791a779d6220 2532 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 2533 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2534 DESCALE(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2535 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2536 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2537 DESCALE(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 2538 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2539
shoaib_ahmed 0:791a779d6220 2540 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 2541 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 2542 */
shoaib_ahmed 0:791a779d6220 2543
shoaib_ahmed 0:791a779d6220 2544 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 2545 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 2546
shoaib_ahmed 0:791a779d6220 2547 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 2548 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 2549 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 2550 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 2551 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 2552
shoaib_ahmed 0:791a779d6220 2553 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 2554 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 2555 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 2556 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 2557 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 2558
shoaib_ahmed 0:791a779d6220 2559 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 2560 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 2561 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 2562 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 2563 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 2564
shoaib_ahmed 0:791a779d6220 2565 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2566 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2567 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2568 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp3, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2569
shoaib_ahmed 0:791a779d6220 2570 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2571 }
shoaib_ahmed 0:791a779d6220 2572 }
shoaib_ahmed 0:791a779d6220 2573
shoaib_ahmed 0:791a779d6220 2574
shoaib_ahmed 0:791a779d6220 2575 /*
shoaib_ahmed 0:791a779d6220 2576 * Perform the forward DCT on a 14x7 sample block.
shoaib_ahmed 0:791a779d6220 2577 *
shoaib_ahmed 0:791a779d6220 2578 * 14-point FDCT in pass 1 (rows), 7-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 2579 */
shoaib_ahmed 0:791a779d6220 2580
shoaib_ahmed 0:791a779d6220 2581 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2582 jpeg_fdct_14x7 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2583 {
shoaib_ahmed 0:791a779d6220 2584 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
shoaib_ahmed 0:791a779d6220 2585 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
shoaib_ahmed 0:791a779d6220 2586 INT32 z1, z2, z3;
shoaib_ahmed 0:791a779d6220 2587 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2588 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2589 int ctr;
shoaib_ahmed 0:791a779d6220 2590 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2591
shoaib_ahmed 0:791a779d6220 2592 /* Zero bottom row of output coefficient block. */
shoaib_ahmed 0:791a779d6220 2593 MEMZERO(&data[DCTSIZE*7], SIZEOF(DCTELEM) * DCTSIZE);
shoaib_ahmed 0:791a779d6220 2594
shoaib_ahmed 0:791a779d6220 2595 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2596 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 2597 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 2598 * 14-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/28).
shoaib_ahmed 0:791a779d6220 2599 */
shoaib_ahmed 0:791a779d6220 2600
shoaib_ahmed 0:791a779d6220 2601 dataptr = data;
shoaib_ahmed 0:791a779d6220 2602 for (ctr = 0; ctr < 7; ctr++) {
shoaib_ahmed 0:791a779d6220 2603 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2604
shoaib_ahmed 0:791a779d6220 2605 /* Even part */
shoaib_ahmed 0:791a779d6220 2606
shoaib_ahmed 0:791a779d6220 2607 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2608 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2609 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2610 tmp13 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2611 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2612 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2613 tmp6 = GETJSAMPLE(elemptr[6]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2614
shoaib_ahmed 0:791a779d6220 2615 tmp10 = tmp0 + tmp6;
shoaib_ahmed 0:791a779d6220 2616 tmp14 = tmp0 - tmp6;
shoaib_ahmed 0:791a779d6220 2617 tmp11 = tmp1 + tmp5;
shoaib_ahmed 0:791a779d6220 2618 tmp15 = tmp1 - tmp5;
shoaib_ahmed 0:791a779d6220 2619 tmp12 = tmp2 + tmp4;
shoaib_ahmed 0:791a779d6220 2620 tmp16 = tmp2 - tmp4;
shoaib_ahmed 0:791a779d6220 2621
shoaib_ahmed 0:791a779d6220 2622 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[13]);
shoaib_ahmed 0:791a779d6220 2623 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[12]);
shoaib_ahmed 0:791a779d6220 2624 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2625 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2626 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2627 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2628 tmp6 = GETJSAMPLE(elemptr[6]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2629
shoaib_ahmed 0:791a779d6220 2630 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2631 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2632 ((tmp10 + tmp11 + tmp12 + tmp13 - 14 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2633 tmp13 += tmp13;
shoaib_ahmed 0:791a779d6220 2634 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2635 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.274162392)) + /* c4 */
shoaib_ahmed 0:791a779d6220 2636 MULTIPLY(tmp11 - tmp13, FIX(0.314692123)) - /* c12 */
shoaib_ahmed 0:791a779d6220 2637 MULTIPLY(tmp12 - tmp13, FIX(0.881747734)), /* c8 */
shoaib_ahmed 0:791a779d6220 2638 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2639
shoaib_ahmed 0:791a779d6220 2640 tmp10 = MULTIPLY(tmp14 + tmp15, FIX(1.105676686)); /* c6 */
shoaib_ahmed 0:791a779d6220 2641
shoaib_ahmed 0:791a779d6220 2642 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2643 DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.273079590)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2644 + MULTIPLY(tmp16, FIX(0.613604268)), /* c10 */
shoaib_ahmed 0:791a779d6220 2645 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2646 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2647 DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.719280954)) /* c6+c10 */
shoaib_ahmed 0:791a779d6220 2648 - MULTIPLY(tmp16, FIX(1.378756276)), /* c2 */
shoaib_ahmed 0:791a779d6220 2649 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2650
shoaib_ahmed 0:791a779d6220 2651 /* Odd part */
shoaib_ahmed 0:791a779d6220 2652
shoaib_ahmed 0:791a779d6220 2653 tmp10 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 2654 tmp11 = tmp5 - tmp4;
shoaib_ahmed 0:791a779d6220 2655 dataptr[7] = (DCTELEM) ((tmp0 - tmp10 + tmp3 - tmp11 - tmp6) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2656 tmp3 <<= CONST_BITS;
shoaib_ahmed 0:791a779d6220 2657 tmp10 = MULTIPLY(tmp10, - FIX(0.158341681)); /* -c13 */
shoaib_ahmed 0:791a779d6220 2658 tmp11 = MULTIPLY(tmp11, FIX(1.405321284)); /* c1 */
shoaib_ahmed 0:791a779d6220 2659 tmp10 += tmp11 - tmp3;
shoaib_ahmed 0:791a779d6220 2660 tmp11 = MULTIPLY(tmp0 + tmp2, FIX(1.197448846)) + /* c5 */
shoaib_ahmed 0:791a779d6220 2661 MULTIPLY(tmp4 + tmp6, FIX(0.752406978)); /* c9 */
shoaib_ahmed 0:791a779d6220 2662 dataptr[5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2663 DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(2.373959773)) /* c3+c5-c13 */
shoaib_ahmed 0:791a779d6220 2664 + MULTIPLY(tmp4, FIX(1.119999435)), /* c1+c11-c9 */
shoaib_ahmed 0:791a779d6220 2665 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2666 tmp12 = MULTIPLY(tmp0 + tmp1, FIX(1.334852607)) + /* c3 */
shoaib_ahmed 0:791a779d6220 2667 MULTIPLY(tmp5 - tmp6, FIX(0.467085129)); /* c11 */
shoaib_ahmed 0:791a779d6220 2668 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2669 DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.424103948)) /* c3-c9-c13 */
shoaib_ahmed 0:791a779d6220 2670 - MULTIPLY(tmp5, FIX(3.069855259)), /* c1+c5+c11 */
shoaib_ahmed 0:791a779d6220 2671 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2672 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2673 DESCALE(tmp11 + tmp12 + tmp3 + tmp6 -
shoaib_ahmed 0:791a779d6220 2674 MULTIPLY(tmp0 + tmp6, FIX(1.126980169)), /* c3+c5-c1 */
shoaib_ahmed 0:791a779d6220 2675 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2676
shoaib_ahmed 0:791a779d6220 2677 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2678 }
shoaib_ahmed 0:791a779d6220 2679
shoaib_ahmed 0:791a779d6220 2680 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2681 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 2682 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2683 * We must also scale the output by (8/14)*(8/7) = 32/49, which we
shoaib_ahmed 0:791a779d6220 2684 * partially fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 2685 * 7-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/14) * 64/49.
shoaib_ahmed 0:791a779d6220 2686 */
shoaib_ahmed 0:791a779d6220 2687
shoaib_ahmed 0:791a779d6220 2688 dataptr = data;
shoaib_ahmed 0:791a779d6220 2689 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2690 /* Even part */
shoaib_ahmed 0:791a779d6220 2691
shoaib_ahmed 0:791a779d6220 2692 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2693 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2694 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2695 tmp3 = dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2696
shoaib_ahmed 0:791a779d6220 2697 tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 2698 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2699 tmp12 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2700
shoaib_ahmed 0:791a779d6220 2701 z1 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 2702 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2703 DESCALE(MULTIPLY(z1 + tmp1 + tmp3, FIX(1.306122449)), /* 64/49 */
shoaib_ahmed 0:791a779d6220 2704 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2705 tmp3 += tmp3;
shoaib_ahmed 0:791a779d6220 2706 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 2707 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 2708 z1 = MULTIPLY(z1, FIX(0.461784020)); /* (c2+c6-c4)/2 */
shoaib_ahmed 0:791a779d6220 2709 z2 = MULTIPLY(tmp0 - tmp2, FIX(1.202428084)); /* (c2+c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 2710 z3 = MULTIPLY(tmp1 - tmp2, FIX(0.411026446)); /* c6 */
shoaib_ahmed 0:791a779d6220 2711 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2712 z1 -= z2;
shoaib_ahmed 0:791a779d6220 2713 z2 = MULTIPLY(tmp0 - tmp1, FIX(1.151670509)); /* c4 */
shoaib_ahmed 0:791a779d6220 2714 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2715 DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.923568041)), /* c2+c6-c4 */
shoaib_ahmed 0:791a779d6220 2716 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2717 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2718
shoaib_ahmed 0:791a779d6220 2719 /* Odd part */
shoaib_ahmed 0:791a779d6220 2720
shoaib_ahmed 0:791a779d6220 2721 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(1.221765677)); /* (c3+c1-c5)/2 */
shoaib_ahmed 0:791a779d6220 2722 tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.222383464)); /* (c3+c5-c1)/2 */
shoaib_ahmed 0:791a779d6220 2723 tmp0 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 2724 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 2725 tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.800824523)); /* -c1 */
shoaib_ahmed 0:791a779d6220 2726 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 2727 tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.801442310)); /* c5 */
shoaib_ahmed 0:791a779d6220 2728 tmp0 += tmp3;
shoaib_ahmed 0:791a779d6220 2729 tmp2 += tmp3 + MULTIPLY(tmp12, FIX(2.443531355)); /* c3+c1-c5 */
shoaib_ahmed 0:791a779d6220 2730
shoaib_ahmed 0:791a779d6220 2731 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp0, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2732 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp1, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2733 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp2, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2734
shoaib_ahmed 0:791a779d6220 2735 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2736 }
shoaib_ahmed 0:791a779d6220 2737 }
shoaib_ahmed 0:791a779d6220 2738
shoaib_ahmed 0:791a779d6220 2739
shoaib_ahmed 0:791a779d6220 2740 /*
shoaib_ahmed 0:791a779d6220 2741 * Perform the forward DCT on a 12x6 sample block.
shoaib_ahmed 0:791a779d6220 2742 *
shoaib_ahmed 0:791a779d6220 2743 * 12-point FDCT in pass 1 (rows), 6-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 2744 */
shoaib_ahmed 0:791a779d6220 2745
shoaib_ahmed 0:791a779d6220 2746 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2747 jpeg_fdct_12x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2748 {
shoaib_ahmed 0:791a779d6220 2749 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
shoaib_ahmed 0:791a779d6220 2750 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
shoaib_ahmed 0:791a779d6220 2751 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2752 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2753 int ctr;
shoaib_ahmed 0:791a779d6220 2754 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2755
shoaib_ahmed 0:791a779d6220 2756 /* Zero 2 bottom rows of output coefficient block. */
shoaib_ahmed 0:791a779d6220 2757 MEMZERO(&data[DCTSIZE*6], SIZEOF(DCTELEM) * DCTSIZE * 2);
shoaib_ahmed 0:791a779d6220 2758
shoaib_ahmed 0:791a779d6220 2759 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2760 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 2761 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 2762 * 12-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/24).
shoaib_ahmed 0:791a779d6220 2763 */
shoaib_ahmed 0:791a779d6220 2764
shoaib_ahmed 0:791a779d6220 2765 dataptr = data;
shoaib_ahmed 0:791a779d6220 2766 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 2767 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2768
shoaib_ahmed 0:791a779d6220 2769 /* Even part */
shoaib_ahmed 0:791a779d6220 2770
shoaib_ahmed 0:791a779d6220 2771 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2772 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2773 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2774 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2775 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2776 tmp5 = GETJSAMPLE(elemptr[5]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 2777
shoaib_ahmed 0:791a779d6220 2778 tmp10 = tmp0 + tmp5;
shoaib_ahmed 0:791a779d6220 2779 tmp13 = tmp0 - tmp5;
shoaib_ahmed 0:791a779d6220 2780 tmp11 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 2781 tmp14 = tmp1 - tmp4;
shoaib_ahmed 0:791a779d6220 2782 tmp12 = tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 2783 tmp15 = tmp2 - tmp3;
shoaib_ahmed 0:791a779d6220 2784
shoaib_ahmed 0:791a779d6220 2785 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[11]);
shoaib_ahmed 0:791a779d6220 2786 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[10]);
shoaib_ahmed 0:791a779d6220 2787 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2788 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2789 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2790 tmp5 = GETJSAMPLE(elemptr[5]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 2791
shoaib_ahmed 0:791a779d6220 2792 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2793 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2794 ((tmp10 + tmp11 + tmp12 - 12 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2795 dataptr[6] = (DCTELEM) ((tmp13 - tmp14 - tmp15) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2796 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2797 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.224744871)), /* c4 */
shoaib_ahmed 0:791a779d6220 2798 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2799 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2800 DESCALE(tmp14 - tmp15 + MULTIPLY(tmp13 + tmp15, FIX(1.366025404)), /* c2 */
shoaib_ahmed 0:791a779d6220 2801 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2802
shoaib_ahmed 0:791a779d6220 2803 /* Odd part */
shoaib_ahmed 0:791a779d6220 2804
shoaib_ahmed 0:791a779d6220 2805 tmp10 = MULTIPLY(tmp1 + tmp4, FIX_0_541196100); /* c9 */
shoaib_ahmed 0:791a779d6220 2806 tmp14 = tmp10 + MULTIPLY(tmp1, FIX_0_765366865); /* c3-c9 */
shoaib_ahmed 0:791a779d6220 2807 tmp15 = tmp10 - MULTIPLY(tmp4, FIX_1_847759065); /* c3+c9 */
shoaib_ahmed 0:791a779d6220 2808 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.121971054)); /* c5 */
shoaib_ahmed 0:791a779d6220 2809 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.860918669)); /* c7 */
shoaib_ahmed 0:791a779d6220 2810 tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.580774953)) /* c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 2811 + MULTIPLY(tmp5, FIX(0.184591911)); /* c11 */
shoaib_ahmed 0:791a779d6220 2812 tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.184591911)); /* -c11 */
shoaib_ahmed 0:791a779d6220 2813 tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.339493912)) /* c1+c5-c11 */
shoaib_ahmed 0:791a779d6220 2814 + MULTIPLY(tmp5, FIX(0.860918669)); /* c7 */
shoaib_ahmed 0:791a779d6220 2815 tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.725788011)) /* c1+c11-c7 */
shoaib_ahmed 0:791a779d6220 2816 - MULTIPLY(tmp5, FIX(1.121971054)); /* c5 */
shoaib_ahmed 0:791a779d6220 2817 tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.306562965)) /* c3 */
shoaib_ahmed 0:791a779d6220 2818 - MULTIPLY(tmp2 + tmp5, FIX_0_541196100); /* c9 */
shoaib_ahmed 0:791a779d6220 2819
shoaib_ahmed 0:791a779d6220 2820 dataptr[1] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2821 dataptr[3] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2822 dataptr[5] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2823 dataptr[7] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2824
shoaib_ahmed 0:791a779d6220 2825 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2826 }
shoaib_ahmed 0:791a779d6220 2827
shoaib_ahmed 0:791a779d6220 2828 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2829 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 2830 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2831 * We must also scale the output by (8/12)*(8/6) = 8/9, which we
shoaib_ahmed 0:791a779d6220 2832 * partially fold into the constant multipliers and final shifting:
shoaib_ahmed 0:791a779d6220 2833 * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12) * 16/9.
shoaib_ahmed 0:791a779d6220 2834 */
shoaib_ahmed 0:791a779d6220 2835
shoaib_ahmed 0:791a779d6220 2836 dataptr = data;
shoaib_ahmed 0:791a779d6220 2837 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2838 /* Even part */
shoaib_ahmed 0:791a779d6220 2839
shoaib_ahmed 0:791a779d6220 2840 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2841 tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2842 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2843
shoaib_ahmed 0:791a779d6220 2844 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 2845 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 2846
shoaib_ahmed 0:791a779d6220 2847 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 2848 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2849 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2850
shoaib_ahmed 0:791a779d6220 2851 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2852 DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 2853 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2854 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2855 DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */
shoaib_ahmed 0:791a779d6220 2856 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2857 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2858 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */
shoaib_ahmed 0:791a779d6220 2859 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2860
shoaib_ahmed 0:791a779d6220 2861 /* Odd part */
shoaib_ahmed 0:791a779d6220 2862
shoaib_ahmed 0:791a779d6220 2863 tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */
shoaib_ahmed 0:791a779d6220 2864
shoaib_ahmed 0:791a779d6220 2865 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2866 DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 2867 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2868 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2869 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 2870 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2871 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2872 DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 2873 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 2874
shoaib_ahmed 0:791a779d6220 2875 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 2876 }
shoaib_ahmed 0:791a779d6220 2877 }
shoaib_ahmed 0:791a779d6220 2878
shoaib_ahmed 0:791a779d6220 2879
shoaib_ahmed 0:791a779d6220 2880 /*
shoaib_ahmed 0:791a779d6220 2881 * Perform the forward DCT on a 10x5 sample block.
shoaib_ahmed 0:791a779d6220 2882 *
shoaib_ahmed 0:791a779d6220 2883 * 10-point FDCT in pass 1 (rows), 5-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 2884 */
shoaib_ahmed 0:791a779d6220 2885
shoaib_ahmed 0:791a779d6220 2886 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 2887 jpeg_fdct_10x5 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 2888 {
shoaib_ahmed 0:791a779d6220 2889 INT32 tmp0, tmp1, tmp2, tmp3, tmp4;
shoaib_ahmed 0:791a779d6220 2890 INT32 tmp10, tmp11, tmp12, tmp13, tmp14;
shoaib_ahmed 0:791a779d6220 2891 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 2892 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 2893 int ctr;
shoaib_ahmed 0:791a779d6220 2894 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 2895
shoaib_ahmed 0:791a779d6220 2896 /* Zero 3 bottom rows of output coefficient block. */
shoaib_ahmed 0:791a779d6220 2897 MEMZERO(&data[DCTSIZE*5], SIZEOF(DCTELEM) * DCTSIZE * 3);
shoaib_ahmed 0:791a779d6220 2898
shoaib_ahmed 0:791a779d6220 2899 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 2900 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 2901 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 2902 * 10-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/20).
shoaib_ahmed 0:791a779d6220 2903 */
shoaib_ahmed 0:791a779d6220 2904
shoaib_ahmed 0:791a779d6220 2905 dataptr = data;
shoaib_ahmed 0:791a779d6220 2906 for (ctr = 0; ctr < 5; ctr++) {
shoaib_ahmed 0:791a779d6220 2907 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 2908
shoaib_ahmed 0:791a779d6220 2909 /* Even part */
shoaib_ahmed 0:791a779d6220 2910
shoaib_ahmed 0:791a779d6220 2911 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2912 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2913 tmp12 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2914 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 2915 tmp4 = GETJSAMPLE(elemptr[4]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 2916
shoaib_ahmed 0:791a779d6220 2917 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 2918 tmp13 = tmp0 - tmp4;
shoaib_ahmed 0:791a779d6220 2919 tmp11 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 2920 tmp14 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 2921
shoaib_ahmed 0:791a779d6220 2922 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[9]);
shoaib_ahmed 0:791a779d6220 2923 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[8]);
shoaib_ahmed 0:791a779d6220 2924 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 2925 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 2926 tmp4 = GETJSAMPLE(elemptr[4]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 2927
shoaib_ahmed 0:791a779d6220 2928 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 2929 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2930 ((tmp10 + tmp11 + tmp12 - 10 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2931 tmp12 += tmp12;
shoaib_ahmed 0:791a779d6220 2932 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2933 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.144122806)) - /* c4 */
shoaib_ahmed 0:791a779d6220 2934 MULTIPLY(tmp11 - tmp12, FIX(0.437016024)), /* c8 */
shoaib_ahmed 0:791a779d6220 2935 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2936 tmp10 = MULTIPLY(tmp13 + tmp14, FIX(0.831253876)); /* c6 */
shoaib_ahmed 0:791a779d6220 2937 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2938 DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.513743148)), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 2939 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2940 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2941 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.176250899)), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 2942 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2943
shoaib_ahmed 0:791a779d6220 2944 /* Odd part */
shoaib_ahmed 0:791a779d6220 2945
shoaib_ahmed 0:791a779d6220 2946 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 2947 tmp11 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 2948 dataptr[5] = (DCTELEM) ((tmp10 - tmp11 - tmp2) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2949 tmp2 <<= CONST_BITS;
shoaib_ahmed 0:791a779d6220 2950 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2951 DESCALE(MULTIPLY(tmp0, FIX(1.396802247)) + /* c1 */
shoaib_ahmed 0:791a779d6220 2952 MULTIPLY(tmp1, FIX(1.260073511)) + tmp2 + /* c3 */
shoaib_ahmed 0:791a779d6220 2953 MULTIPLY(tmp3, FIX(0.642039522)) + /* c7 */
shoaib_ahmed 0:791a779d6220 2954 MULTIPLY(tmp4, FIX(0.221231742)), /* c9 */
shoaib_ahmed 0:791a779d6220 2955 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2956 tmp12 = MULTIPLY(tmp0 - tmp4, FIX(0.951056516)) - /* (c3+c7)/2 */
shoaib_ahmed 0:791a779d6220 2957 MULTIPLY(tmp1 + tmp3, FIX(0.587785252)); /* (c1-c9)/2 */
shoaib_ahmed 0:791a779d6220 2958 tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.309016994)) + /* (c3-c7)/2 */
shoaib_ahmed 0:791a779d6220 2959 (tmp11 << (CONST_BITS - 1)) - tmp2;
shoaib_ahmed 0:791a779d6220 2960 dataptr[3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2961 dataptr[7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2962
shoaib_ahmed 0:791a779d6220 2963 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 2964 }
shoaib_ahmed 0:791a779d6220 2965
shoaib_ahmed 0:791a779d6220 2966 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 2967 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 2968 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 2969 * We must also scale the output by (8/10)*(8/5) = 32/25, which we
shoaib_ahmed 0:791a779d6220 2970 * fold into the constant multipliers:
shoaib_ahmed 0:791a779d6220 2971 * 5-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/10) * 32/25.
shoaib_ahmed 0:791a779d6220 2972 */
shoaib_ahmed 0:791a779d6220 2973
shoaib_ahmed 0:791a779d6220 2974 dataptr = data;
shoaib_ahmed 0:791a779d6220 2975 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 2976 /* Even part */
shoaib_ahmed 0:791a779d6220 2977
shoaib_ahmed 0:791a779d6220 2978 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2979 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2980 tmp2 = dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 2981
shoaib_ahmed 0:791a779d6220 2982 tmp10 = tmp0 + tmp1;
shoaib_ahmed 0:791a779d6220 2983 tmp11 = tmp0 - tmp1;
shoaib_ahmed 0:791a779d6220 2984
shoaib_ahmed 0:791a779d6220 2985 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 2986 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 2987
shoaib_ahmed 0:791a779d6220 2988 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 2989 DESCALE(MULTIPLY(tmp10 + tmp2, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 2990 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2991 tmp11 = MULTIPLY(tmp11, FIX(1.011928851)); /* (c2+c4)/2 */
shoaib_ahmed 0:791a779d6220 2992 tmp10 -= tmp2 << 2;
shoaib_ahmed 0:791a779d6220 2993 tmp10 = MULTIPLY(tmp10, FIX(0.452548340)); /* (c2-c4)/2 */
shoaib_ahmed 0:791a779d6220 2994 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2995 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 2996
shoaib_ahmed 0:791a779d6220 2997 /* Odd part */
shoaib_ahmed 0:791a779d6220 2998
shoaib_ahmed 0:791a779d6220 2999 tmp10 = MULTIPLY(tmp0 + tmp1, FIX(1.064004961)); /* c3 */
shoaib_ahmed 0:791a779d6220 3000
shoaib_ahmed 0:791a779d6220 3001 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3002 DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.657591230)), /* c1-c3 */
shoaib_ahmed 0:791a779d6220 3003 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3004 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3005 DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.785601151)), /* c1+c3 */
shoaib_ahmed 0:791a779d6220 3006 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3007
shoaib_ahmed 0:791a779d6220 3008 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3009 }
shoaib_ahmed 0:791a779d6220 3010 }
shoaib_ahmed 0:791a779d6220 3011
shoaib_ahmed 0:791a779d6220 3012
shoaib_ahmed 0:791a779d6220 3013 /*
shoaib_ahmed 0:791a779d6220 3014 * Perform the forward DCT on an 8x4 sample block.
shoaib_ahmed 0:791a779d6220 3015 *
shoaib_ahmed 0:791a779d6220 3016 * 8-point FDCT in pass 1 (rows), 4-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3017 */
shoaib_ahmed 0:791a779d6220 3018
shoaib_ahmed 0:791a779d6220 3019 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3020 jpeg_fdct_8x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3021 {
shoaib_ahmed 0:791a779d6220 3022 INT32 tmp0, tmp1, tmp2, tmp3;
shoaib_ahmed 0:791a779d6220 3023 INT32 tmp10, tmp11, tmp12, tmp13;
shoaib_ahmed 0:791a779d6220 3024 INT32 z1;
shoaib_ahmed 0:791a779d6220 3025 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3026 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3027 int ctr;
shoaib_ahmed 0:791a779d6220 3028 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3029
shoaib_ahmed 0:791a779d6220 3030 /* Zero 4 bottom rows of output coefficient block. */
shoaib_ahmed 0:791a779d6220 3031 MEMZERO(&data[DCTSIZE*4], SIZEOF(DCTELEM) * DCTSIZE * 4);
shoaib_ahmed 0:791a779d6220 3032
shoaib_ahmed 0:791a779d6220 3033 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3034 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3035 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3036 * We must also scale the output by 8/4 = 2, which we add here.
shoaib_ahmed 0:791a779d6220 3037 * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 3038 */
shoaib_ahmed 0:791a779d6220 3039
shoaib_ahmed 0:791a779d6220 3040 dataptr = data;
shoaib_ahmed 0:791a779d6220 3041 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 3042 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3043
shoaib_ahmed 0:791a779d6220 3044 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 3045 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 3046 */
shoaib_ahmed 0:791a779d6220 3047
shoaib_ahmed 0:791a779d6220 3048 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 3049 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3050 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3051 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3052
shoaib_ahmed 0:791a779d6220 3053 tmp10 = tmp0 + tmp3;
shoaib_ahmed 0:791a779d6220 3054 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 3055 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 3056 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 3057
shoaib_ahmed 0:791a779d6220 3058 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 3059 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3060 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3061 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3062
shoaib_ahmed 0:791a779d6220 3063 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3064 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3065 ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 3066 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 3067
shoaib_ahmed 0:791a779d6220 3068 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 3069 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3070 z1 += ONE << (CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 3071
shoaib_ahmed 0:791a779d6220 3072 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3073 RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3074 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3075 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3076 RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 3077 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3078
shoaib_ahmed 0:791a779d6220 3079 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 3080 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 3081 */
shoaib_ahmed 0:791a779d6220 3082
shoaib_ahmed 0:791a779d6220 3083 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 3084 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 3085
shoaib_ahmed 0:791a779d6220 3086 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 3087 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3088 z1 += ONE << (CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 3089
shoaib_ahmed 0:791a779d6220 3090 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 3091 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 3092 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 3093 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 3094
shoaib_ahmed 0:791a779d6220 3095 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 3096 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 3097 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 3098 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 3099 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 3100
shoaib_ahmed 0:791a779d6220 3101 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 3102 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 3103 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 3104 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 3105 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 3106
shoaib_ahmed 0:791a779d6220 3107 dataptr[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3108 dataptr[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3109 dataptr[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3110 dataptr[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3111
shoaib_ahmed 0:791a779d6220 3112 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3113 }
shoaib_ahmed 0:791a779d6220 3114
shoaib_ahmed 0:791a779d6220 3115 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3116 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3117 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3118 * 4-point FDCT kernel,
shoaib_ahmed 0:791a779d6220 3119 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 3120 */
shoaib_ahmed 0:791a779d6220 3121
shoaib_ahmed 0:791a779d6220 3122 dataptr = data;
shoaib_ahmed 0:791a779d6220 3123 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 3124 /* Even part */
shoaib_ahmed 0:791a779d6220 3125
shoaib_ahmed 0:791a779d6220 3126 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3127 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3] + (ONE << (PASS1_BITS-1));
shoaib_ahmed 0:791a779d6220 3128 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3129
shoaib_ahmed 0:791a779d6220 3130 tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3131 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3132
shoaib_ahmed 0:791a779d6220 3133 dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3134 dataptr[DCTSIZE*2] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3135
shoaib_ahmed 0:791a779d6220 3136 /* Odd part */
shoaib_ahmed 0:791a779d6220 3137
shoaib_ahmed 0:791a779d6220 3138 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 3139 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3140 tmp0 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3141
shoaib_ahmed 0:791a779d6220 3142 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3143 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3144 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3145 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3146 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 3147 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3148
shoaib_ahmed 0:791a779d6220 3149 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3150 }
shoaib_ahmed 0:791a779d6220 3151 }
shoaib_ahmed 0:791a779d6220 3152
shoaib_ahmed 0:791a779d6220 3153
shoaib_ahmed 0:791a779d6220 3154 /*
shoaib_ahmed 0:791a779d6220 3155 * Perform the forward DCT on a 6x3 sample block.
shoaib_ahmed 0:791a779d6220 3156 *
shoaib_ahmed 0:791a779d6220 3157 * 6-point FDCT in pass 1 (rows), 3-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3158 */
shoaib_ahmed 0:791a779d6220 3159
shoaib_ahmed 0:791a779d6220 3160 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3161 jpeg_fdct_6x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3162 {
shoaib_ahmed 0:791a779d6220 3163 INT32 tmp0, tmp1, tmp2;
shoaib_ahmed 0:791a779d6220 3164 INT32 tmp10, tmp11, tmp12;
shoaib_ahmed 0:791a779d6220 3165 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3166 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3167 int ctr;
shoaib_ahmed 0:791a779d6220 3168 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3169
shoaib_ahmed 0:791a779d6220 3170 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3171 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3172
shoaib_ahmed 0:791a779d6220 3173 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3174 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3175 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3176 * We scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 3177 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 3178 * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
shoaib_ahmed 0:791a779d6220 3179 */
shoaib_ahmed 0:791a779d6220 3180
shoaib_ahmed 0:791a779d6220 3181 dataptr = data;
shoaib_ahmed 0:791a779d6220 3182 for (ctr = 0; ctr < 3; ctr++) {
shoaib_ahmed 0:791a779d6220 3183 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3184
shoaib_ahmed 0:791a779d6220 3185 /* Even part */
shoaib_ahmed 0:791a779d6220 3186
shoaib_ahmed 0:791a779d6220 3187 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3188 tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3189 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3190
shoaib_ahmed 0:791a779d6220 3191 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 3192 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 3193
shoaib_ahmed 0:791a779d6220 3194 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3195 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3196 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3197
shoaib_ahmed 0:791a779d6220 3198 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3199 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3200 ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 3201 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3202 DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */
shoaib_ahmed 0:791a779d6220 3203 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3204 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3205 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */
shoaib_ahmed 0:791a779d6220 3206 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3207
shoaib_ahmed 0:791a779d6220 3208 /* Odd part */
shoaib_ahmed 0:791a779d6220 3209
shoaib_ahmed 0:791a779d6220 3210 tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */
shoaib_ahmed 0:791a779d6220 3211 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 3212
shoaib_ahmed 0:791a779d6220 3213 dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << (PASS1_BITS+1)));
shoaib_ahmed 0:791a779d6220 3214 dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 3215 dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << (PASS1_BITS+1)));
shoaib_ahmed 0:791a779d6220 3216
shoaib_ahmed 0:791a779d6220 3217 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3218 }
shoaib_ahmed 0:791a779d6220 3219
shoaib_ahmed 0:791a779d6220 3220 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3221 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3222 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3223 * We must also scale the output by (8/6)*(8/3) = 32/9, which we partially
shoaib_ahmed 0:791a779d6220 3224 * fold into the constant multipliers (other part was done in pass 1):
shoaib_ahmed 0:791a779d6220 3225 * 3-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/6) * 16/9.
shoaib_ahmed 0:791a779d6220 3226 */
shoaib_ahmed 0:791a779d6220 3227
shoaib_ahmed 0:791a779d6220 3228 dataptr = data;
shoaib_ahmed 0:791a779d6220 3229 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 3230 /* Even part */
shoaib_ahmed 0:791a779d6220 3231
shoaib_ahmed 0:791a779d6220 3232 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3233 tmp1 = dataptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3234
shoaib_ahmed 0:791a779d6220 3235 tmp2 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3236
shoaib_ahmed 0:791a779d6220 3237 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3238 DESCALE(MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 3239 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3240 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3241 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(1.257078722)), /* c2 */
shoaib_ahmed 0:791a779d6220 3242 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3243
shoaib_ahmed 0:791a779d6220 3244 /* Odd part */
shoaib_ahmed 0:791a779d6220 3245
shoaib_ahmed 0:791a779d6220 3246 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3247 DESCALE(MULTIPLY(tmp2, FIX(2.177324216)), /* c1 */
shoaib_ahmed 0:791a779d6220 3248 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3249
shoaib_ahmed 0:791a779d6220 3250 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3251 }
shoaib_ahmed 0:791a779d6220 3252 }
shoaib_ahmed 0:791a779d6220 3253
shoaib_ahmed 0:791a779d6220 3254
shoaib_ahmed 0:791a779d6220 3255 /*
shoaib_ahmed 0:791a779d6220 3256 * Perform the forward DCT on a 4x2 sample block.
shoaib_ahmed 0:791a779d6220 3257 *
shoaib_ahmed 0:791a779d6220 3258 * 4-point FDCT in pass 1 (rows), 2-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3259 */
shoaib_ahmed 0:791a779d6220 3260
shoaib_ahmed 0:791a779d6220 3261 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3262 jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3263 {
shoaib_ahmed 0:791a779d6220 3264 INT32 tmp0, tmp1;
shoaib_ahmed 0:791a779d6220 3265 INT32 tmp10, tmp11;
shoaib_ahmed 0:791a779d6220 3266 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3267 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3268 int ctr;
shoaib_ahmed 0:791a779d6220 3269 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3270
shoaib_ahmed 0:791a779d6220 3271 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3272 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3273
shoaib_ahmed 0:791a779d6220 3274 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3275 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3276 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3277 * We must also scale the output by (8/4)*(8/2) = 2**3, which we add here.
shoaib_ahmed 0:791a779d6220 3278 * 4-point FDCT kernel,
shoaib_ahmed 0:791a779d6220 3279 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 3280 */
shoaib_ahmed 0:791a779d6220 3281
shoaib_ahmed 0:791a779d6220 3282 dataptr = data;
shoaib_ahmed 0:791a779d6220 3283 for (ctr = 0; ctr < 2; ctr++) {
shoaib_ahmed 0:791a779d6220 3284 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3285
shoaib_ahmed 0:791a779d6220 3286 /* Even part */
shoaib_ahmed 0:791a779d6220 3287
shoaib_ahmed 0:791a779d6220 3288 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3289 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 3290
shoaib_ahmed 0:791a779d6220 3291 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3292 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 3293
shoaib_ahmed 0:791a779d6220 3294 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3295 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3296 ((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+3));
shoaib_ahmed 0:791a779d6220 3297 dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+3));
shoaib_ahmed 0:791a779d6220 3298
shoaib_ahmed 0:791a779d6220 3299 /* Odd part */
shoaib_ahmed 0:791a779d6220 3300
shoaib_ahmed 0:791a779d6220 3301 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 3302 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3303 tmp0 += ONE << (CONST_BITS-PASS1_BITS-4);
shoaib_ahmed 0:791a779d6220 3304
shoaib_ahmed 0:791a779d6220 3305 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3306 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3307 CONST_BITS-PASS1_BITS-3);
shoaib_ahmed 0:791a779d6220 3308 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3309 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 3310 CONST_BITS-PASS1_BITS-3);
shoaib_ahmed 0:791a779d6220 3311
shoaib_ahmed 0:791a779d6220 3312 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3313 }
shoaib_ahmed 0:791a779d6220 3314
shoaib_ahmed 0:791a779d6220 3315 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3316 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3317 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3318 */
shoaib_ahmed 0:791a779d6220 3319
shoaib_ahmed 0:791a779d6220 3320 dataptr = data;
shoaib_ahmed 0:791a779d6220 3321 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 3322 /* Even part */
shoaib_ahmed 0:791a779d6220 3323
shoaib_ahmed 0:791a779d6220 3324 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 3325 tmp0 = dataptr[DCTSIZE*0] + (ONE << (PASS1_BITS-1));
shoaib_ahmed 0:791a779d6220 3326 tmp1 = dataptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3327
shoaib_ahmed 0:791a779d6220 3328 dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3329
shoaib_ahmed 0:791a779d6220 3330 /* Odd part */
shoaib_ahmed 0:791a779d6220 3331
shoaib_ahmed 0:791a779d6220 3332 dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3333
shoaib_ahmed 0:791a779d6220 3334 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3335 }
shoaib_ahmed 0:791a779d6220 3336 }
shoaib_ahmed 0:791a779d6220 3337
shoaib_ahmed 0:791a779d6220 3338
shoaib_ahmed 0:791a779d6220 3339 /*
shoaib_ahmed 0:791a779d6220 3340 * Perform the forward DCT on a 2x1 sample block.
shoaib_ahmed 0:791a779d6220 3341 *
shoaib_ahmed 0:791a779d6220 3342 * 2-point FDCT in pass 1 (rows), 1-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3343 */
shoaib_ahmed 0:791a779d6220 3344
shoaib_ahmed 0:791a779d6220 3345 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3346 jpeg_fdct_2x1 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3347 {
shoaib_ahmed 0:791a779d6220 3348 DCTELEM tmp0, tmp1;
shoaib_ahmed 0:791a779d6220 3349 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3350
shoaib_ahmed 0:791a779d6220 3351 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3352 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3353
shoaib_ahmed 0:791a779d6220 3354 elemptr = sample_data[0] + start_col;
shoaib_ahmed 0:791a779d6220 3355
shoaib_ahmed 0:791a779d6220 3356 tmp0 = GETJSAMPLE(elemptr[0]);
shoaib_ahmed 0:791a779d6220 3357 tmp1 = GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 3358
shoaib_ahmed 0:791a779d6220 3359 /* We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3360 * We must also scale the output by (8/2)*(8/1) = 2**5.
shoaib_ahmed 0:791a779d6220 3361 */
shoaib_ahmed 0:791a779d6220 3362
shoaib_ahmed 0:791a779d6220 3363 /* Even part */
shoaib_ahmed 0:791a779d6220 3364
shoaib_ahmed 0:791a779d6220 3365 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3366 data[0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5;
shoaib_ahmed 0:791a779d6220 3367
shoaib_ahmed 0:791a779d6220 3368 /* Odd part */
shoaib_ahmed 0:791a779d6220 3369
shoaib_ahmed 0:791a779d6220 3370 data[1] = (tmp0 - tmp1) << 5;
shoaib_ahmed 0:791a779d6220 3371 }
shoaib_ahmed 0:791a779d6220 3372
shoaib_ahmed 0:791a779d6220 3373
shoaib_ahmed 0:791a779d6220 3374 /*
shoaib_ahmed 0:791a779d6220 3375 * Perform the forward DCT on an 8x16 sample block.
shoaib_ahmed 0:791a779d6220 3376 *
shoaib_ahmed 0:791a779d6220 3377 * 8-point FDCT in pass 1 (rows), 16-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3378 */
shoaib_ahmed 0:791a779d6220 3379
shoaib_ahmed 0:791a779d6220 3380 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3381 jpeg_fdct_8x16 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3382 {
shoaib_ahmed 0:791a779d6220 3383 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
shoaib_ahmed 0:791a779d6220 3384 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17;
shoaib_ahmed 0:791a779d6220 3385 INT32 z1;
shoaib_ahmed 0:791a779d6220 3386 DCTELEM workspace[DCTSIZE2];
shoaib_ahmed 0:791a779d6220 3387 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3388 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 3389 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3390 int ctr;
shoaib_ahmed 0:791a779d6220 3391 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3392
shoaib_ahmed 0:791a779d6220 3393 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3394 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3395 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3396 * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 3397 */
shoaib_ahmed 0:791a779d6220 3398
shoaib_ahmed 0:791a779d6220 3399 dataptr = data;
shoaib_ahmed 0:791a779d6220 3400 ctr = 0;
shoaib_ahmed 0:791a779d6220 3401 for (;;) {
shoaib_ahmed 0:791a779d6220 3402 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3403
shoaib_ahmed 0:791a779d6220 3404 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 3405 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 3406 */
shoaib_ahmed 0:791a779d6220 3407
shoaib_ahmed 0:791a779d6220 3408 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 3409 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3410 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3411 tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3412
shoaib_ahmed 0:791a779d6220 3413 tmp10 = tmp0 + tmp3;
shoaib_ahmed 0:791a779d6220 3414 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 3415 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 3416 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 3417
shoaib_ahmed 0:791a779d6220 3418 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]);
shoaib_ahmed 0:791a779d6220 3419 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3420 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3421 tmp3 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3422
shoaib_ahmed 0:791a779d6220 3423 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3424 dataptr[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3425 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3426
shoaib_ahmed 0:791a779d6220 3427 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 3428 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3429 DESCALE(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3430 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3431 dataptr[6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3432 DESCALE(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 3433 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3434
shoaib_ahmed 0:791a779d6220 3435 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 3436 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 3437 */
shoaib_ahmed 0:791a779d6220 3438
shoaib_ahmed 0:791a779d6220 3439 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 3440 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 3441
shoaib_ahmed 0:791a779d6220 3442 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 3443 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 3444 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 3445 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 3446 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 3447
shoaib_ahmed 0:791a779d6220 3448 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 3449 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 3450 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 3451 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 3452 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 3453
shoaib_ahmed 0:791a779d6220 3454 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 3455 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 3456 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 3457 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 3458 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 3459
shoaib_ahmed 0:791a779d6220 3460 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3461 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3462 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3463 dataptr[7] = (DCTELEM) DESCALE(tmp3, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3464
shoaib_ahmed 0:791a779d6220 3465 ctr++;
shoaib_ahmed 0:791a779d6220 3466
shoaib_ahmed 0:791a779d6220 3467 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 3468 if (ctr == DCTSIZE * 2)
shoaib_ahmed 0:791a779d6220 3469 break; /* Done. */
shoaib_ahmed 0:791a779d6220 3470 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3471 } else
shoaib_ahmed 0:791a779d6220 3472 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 3473 }
shoaib_ahmed 0:791a779d6220 3474
shoaib_ahmed 0:791a779d6220 3475 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3476 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3477 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3478 * We must also scale the output by 8/16 = 1/2.
shoaib_ahmed 0:791a779d6220 3479 * 16-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/32).
shoaib_ahmed 0:791a779d6220 3480 */
shoaib_ahmed 0:791a779d6220 3481
shoaib_ahmed 0:791a779d6220 3482 dataptr = data;
shoaib_ahmed 0:791a779d6220 3483 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 3484 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
shoaib_ahmed 0:791a779d6220 3485 /* Even part */
shoaib_ahmed 0:791a779d6220 3486
shoaib_ahmed 0:791a779d6220 3487 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3488 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 3489 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 3490 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 3491 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3492 tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3493 tmp6 = dataptr[DCTSIZE*6] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3494 tmp7 = dataptr[DCTSIZE*7] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3495
shoaib_ahmed 0:791a779d6220 3496 tmp10 = tmp0 + tmp7;
shoaib_ahmed 0:791a779d6220 3497 tmp14 = tmp0 - tmp7;
shoaib_ahmed 0:791a779d6220 3498 tmp11 = tmp1 + tmp6;
shoaib_ahmed 0:791a779d6220 3499 tmp15 = tmp1 - tmp6;
shoaib_ahmed 0:791a779d6220 3500 tmp12 = tmp2 + tmp5;
shoaib_ahmed 0:791a779d6220 3501 tmp16 = tmp2 - tmp5;
shoaib_ahmed 0:791a779d6220 3502 tmp13 = tmp3 + tmp4;
shoaib_ahmed 0:791a779d6220 3503 tmp17 = tmp3 - tmp4;
shoaib_ahmed 0:791a779d6220 3504
shoaib_ahmed 0:791a779d6220 3505 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3506 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 3507 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 3508 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 3509 tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3510 tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3511 tmp6 = dataptr[DCTSIZE*6] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3512 tmp7 = dataptr[DCTSIZE*7] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3513
shoaib_ahmed 0:791a779d6220 3514 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3515 DESCALE(tmp10 + tmp11 + tmp12 + tmp13, PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3516 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3517 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(1.306562965)) + /* c4[16] = c2[8] */
shoaib_ahmed 0:791a779d6220 3518 MULTIPLY(tmp11 - tmp12, FIX_0_541196100), /* c12[16] = c6[8] */
shoaib_ahmed 0:791a779d6220 3519 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3520
shoaib_ahmed 0:791a779d6220 3521 tmp10 = MULTIPLY(tmp17 - tmp15, FIX(0.275899379)) + /* c14[16] = c7[8] */
shoaib_ahmed 0:791a779d6220 3522 MULTIPLY(tmp14 - tmp16, FIX(1.387039845)); /* c2[16] = c1[8] */
shoaib_ahmed 0:791a779d6220 3523
shoaib_ahmed 0:791a779d6220 3524 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3525 DESCALE(tmp10 + MULTIPLY(tmp15, FIX(1.451774982)) /* c6+c14 */
shoaib_ahmed 0:791a779d6220 3526 + MULTIPLY(tmp16, FIX(2.172734804)), /* c2+c10 */
shoaib_ahmed 0:791a779d6220 3527 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3528 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3529 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(0.211164243)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3530 - MULTIPLY(tmp17, FIX(1.061594338)), /* c10+c14 */
shoaib_ahmed 0:791a779d6220 3531 CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3532
shoaib_ahmed 0:791a779d6220 3533 /* Odd part */
shoaib_ahmed 0:791a779d6220 3534
shoaib_ahmed 0:791a779d6220 3535 tmp11 = MULTIPLY(tmp0 + tmp1, FIX(1.353318001)) + /* c3 */
shoaib_ahmed 0:791a779d6220 3536 MULTIPLY(tmp6 - tmp7, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 3537 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(1.247225013)) + /* c5 */
shoaib_ahmed 0:791a779d6220 3538 MULTIPLY(tmp5 + tmp7, FIX(0.666655658)); /* c11 */
shoaib_ahmed 0:791a779d6220 3539 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(1.093201867)) + /* c7 */
shoaib_ahmed 0:791a779d6220 3540 MULTIPLY(tmp4 - tmp7, FIX(0.897167586)); /* c9 */
shoaib_ahmed 0:791a779d6220 3541 tmp14 = MULTIPLY(tmp1 + tmp2, FIX(0.138617169)) + /* c15 */
shoaib_ahmed 0:791a779d6220 3542 MULTIPLY(tmp6 - tmp5, FIX(1.407403738)); /* c1 */
shoaib_ahmed 0:791a779d6220 3543 tmp15 = MULTIPLY(tmp1 + tmp3, - FIX(0.666655658)) + /* -c11 */
shoaib_ahmed 0:791a779d6220 3544 MULTIPLY(tmp4 + tmp6, - FIX(1.247225013)); /* -c5 */
shoaib_ahmed 0:791a779d6220 3545 tmp16 = MULTIPLY(tmp2 + tmp3, - FIX(1.353318001)) + /* -c3 */
shoaib_ahmed 0:791a779d6220 3546 MULTIPLY(tmp5 - tmp4, FIX(0.410524528)); /* c13 */
shoaib_ahmed 0:791a779d6220 3547 tmp10 = tmp11 + tmp12 + tmp13 -
shoaib_ahmed 0:791a779d6220 3548 MULTIPLY(tmp0, FIX(2.286341144)) + /* c7+c5+c3-c1 */
shoaib_ahmed 0:791a779d6220 3549 MULTIPLY(tmp7, FIX(0.779653625)); /* c15+c13-c11+c9 */
shoaib_ahmed 0:791a779d6220 3550 tmp11 += tmp14 + tmp15 + MULTIPLY(tmp1, FIX(0.071888074)) /* c9-c3-c15+c11 */
shoaib_ahmed 0:791a779d6220 3551 - MULTIPLY(tmp6, FIX(1.663905119)); /* c7+c13+c1-c5 */
shoaib_ahmed 0:791a779d6220 3552 tmp12 += tmp14 + tmp16 - MULTIPLY(tmp2, FIX(1.125726048)) /* c7+c5+c15-c3 */
shoaib_ahmed 0:791a779d6220 3553 + MULTIPLY(tmp5, FIX(1.227391138)); /* c9-c11+c1-c13 */
shoaib_ahmed 0:791a779d6220 3554 tmp13 += tmp15 + tmp16 + MULTIPLY(tmp3, FIX(1.065388962)) /* c15+c3+c11-c7 */
shoaib_ahmed 0:791a779d6220 3555 + MULTIPLY(tmp4, FIX(2.167985692)); /* c1+c13+c5-c9 */
shoaib_ahmed 0:791a779d6220 3556
shoaib_ahmed 0:791a779d6220 3557 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3558 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3559 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3560 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS+1);
shoaib_ahmed 0:791a779d6220 3561
shoaib_ahmed 0:791a779d6220 3562 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3563 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3564 }
shoaib_ahmed 0:791a779d6220 3565 }
shoaib_ahmed 0:791a779d6220 3566
shoaib_ahmed 0:791a779d6220 3567
shoaib_ahmed 0:791a779d6220 3568 /*
shoaib_ahmed 0:791a779d6220 3569 * Perform the forward DCT on a 7x14 sample block.
shoaib_ahmed 0:791a779d6220 3570 *
shoaib_ahmed 0:791a779d6220 3571 * 7-point FDCT in pass 1 (rows), 14-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3572 */
shoaib_ahmed 0:791a779d6220 3573
shoaib_ahmed 0:791a779d6220 3574 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3575 jpeg_fdct_7x14 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3576 {
shoaib_ahmed 0:791a779d6220 3577 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6;
shoaib_ahmed 0:791a779d6220 3578 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
shoaib_ahmed 0:791a779d6220 3579 INT32 z1, z2, z3;
shoaib_ahmed 0:791a779d6220 3580 DCTELEM workspace[8*6];
shoaib_ahmed 0:791a779d6220 3581 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3582 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 3583 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3584 int ctr;
shoaib_ahmed 0:791a779d6220 3585 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3586
shoaib_ahmed 0:791a779d6220 3587 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3588 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3589
shoaib_ahmed 0:791a779d6220 3590 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3591 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3592 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3593 * 7-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/14).
shoaib_ahmed 0:791a779d6220 3594 */
shoaib_ahmed 0:791a779d6220 3595
shoaib_ahmed 0:791a779d6220 3596 dataptr = data;
shoaib_ahmed 0:791a779d6220 3597 ctr = 0;
shoaib_ahmed 0:791a779d6220 3598 for (;;) {
shoaib_ahmed 0:791a779d6220 3599 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3600
shoaib_ahmed 0:791a779d6220 3601 /* Even part */
shoaib_ahmed 0:791a779d6220 3602
shoaib_ahmed 0:791a779d6220 3603 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3604 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3605 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3606 tmp3 = GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3607
shoaib_ahmed 0:791a779d6220 3608 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[6]);
shoaib_ahmed 0:791a779d6220 3609 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3610 tmp12 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3611
shoaib_ahmed 0:791a779d6220 3612 z1 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 3613 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3614 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3615 ((z1 + tmp1 + tmp3 - 7 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3616 tmp3 += tmp3;
shoaib_ahmed 0:791a779d6220 3617 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 3618 z1 -= tmp3;
shoaib_ahmed 0:791a779d6220 3619 z1 = MULTIPLY(z1, FIX(0.353553391)); /* (c2+c6-c4)/2 */
shoaib_ahmed 0:791a779d6220 3620 z2 = MULTIPLY(tmp0 - tmp2, FIX(0.920609002)); /* (c2+c4-c6)/2 */
shoaib_ahmed 0:791a779d6220 3621 z3 = MULTIPLY(tmp1 - tmp2, FIX(0.314692123)); /* c6 */
shoaib_ahmed 0:791a779d6220 3622 dataptr[2] = (DCTELEM) DESCALE(z1 + z2 + z3, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3623 z1 -= z2;
shoaib_ahmed 0:791a779d6220 3624 z2 = MULTIPLY(tmp0 - tmp1, FIX(0.881747734)); /* c4 */
shoaib_ahmed 0:791a779d6220 3625 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3626 DESCALE(z2 + z3 - MULTIPLY(tmp1 - tmp3, FIX(0.707106781)), /* c2+c6-c4 */
shoaib_ahmed 0:791a779d6220 3627 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3628 dataptr[6] = (DCTELEM) DESCALE(z1 + z2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3629
shoaib_ahmed 0:791a779d6220 3630 /* Odd part */
shoaib_ahmed 0:791a779d6220 3631
shoaib_ahmed 0:791a779d6220 3632 tmp1 = MULTIPLY(tmp10 + tmp11, FIX(0.935414347)); /* (c3+c1-c5)/2 */
shoaib_ahmed 0:791a779d6220 3633 tmp2 = MULTIPLY(tmp10 - tmp11, FIX(0.170262339)); /* (c3+c5-c1)/2 */
shoaib_ahmed 0:791a779d6220 3634 tmp0 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 3635 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 3636 tmp2 = MULTIPLY(tmp11 + tmp12, - FIX(1.378756276)); /* -c1 */
shoaib_ahmed 0:791a779d6220 3637 tmp1 += tmp2;
shoaib_ahmed 0:791a779d6220 3638 tmp3 = MULTIPLY(tmp10 + tmp12, FIX(0.613604268)); /* c5 */
shoaib_ahmed 0:791a779d6220 3639 tmp0 += tmp3;
shoaib_ahmed 0:791a779d6220 3640 tmp2 += tmp3 + MULTIPLY(tmp12, FIX(1.870828693)); /* c3+c1-c5 */
shoaib_ahmed 0:791a779d6220 3641
shoaib_ahmed 0:791a779d6220 3642 dataptr[1] = (DCTELEM) DESCALE(tmp0, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3643 dataptr[3] = (DCTELEM) DESCALE(tmp1, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3644 dataptr[5] = (DCTELEM) DESCALE(tmp2, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3645
shoaib_ahmed 0:791a779d6220 3646 ctr++;
shoaib_ahmed 0:791a779d6220 3647
shoaib_ahmed 0:791a779d6220 3648 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 3649 if (ctr == 14)
shoaib_ahmed 0:791a779d6220 3650 break; /* Done. */
shoaib_ahmed 0:791a779d6220 3651 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3652 } else
shoaib_ahmed 0:791a779d6220 3653 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 3654 }
shoaib_ahmed 0:791a779d6220 3655
shoaib_ahmed 0:791a779d6220 3656 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3657 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3658 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3659 * We must also scale the output by (8/7)*(8/14) = 32/49, which we
shoaib_ahmed 0:791a779d6220 3660 * fold into the constant multipliers:
shoaib_ahmed 0:791a779d6220 3661 * 14-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/28) * 32/49.
shoaib_ahmed 0:791a779d6220 3662 */
shoaib_ahmed 0:791a779d6220 3663
shoaib_ahmed 0:791a779d6220 3664 dataptr = data;
shoaib_ahmed 0:791a779d6220 3665 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 3666 for (ctr = 0; ctr < 7; ctr++) {
shoaib_ahmed 0:791a779d6220 3667 /* Even part */
shoaib_ahmed 0:791a779d6220 3668
shoaib_ahmed 0:791a779d6220 3669 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 3670 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 3671 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3672 tmp13 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3673 tmp4 = dataptr[DCTSIZE*4] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3674 tmp5 = dataptr[DCTSIZE*5] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3675 tmp6 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3676
shoaib_ahmed 0:791a779d6220 3677 tmp10 = tmp0 + tmp6;
shoaib_ahmed 0:791a779d6220 3678 tmp14 = tmp0 - tmp6;
shoaib_ahmed 0:791a779d6220 3679 tmp11 = tmp1 + tmp5;
shoaib_ahmed 0:791a779d6220 3680 tmp15 = tmp1 - tmp5;
shoaib_ahmed 0:791a779d6220 3681 tmp12 = tmp2 + tmp4;
shoaib_ahmed 0:791a779d6220 3682 tmp16 = tmp2 - tmp4;
shoaib_ahmed 0:791a779d6220 3683
shoaib_ahmed 0:791a779d6220 3684 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 3685 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 3686 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3687 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3688 tmp4 = dataptr[DCTSIZE*4] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3689 tmp5 = dataptr[DCTSIZE*5] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3690 tmp6 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3691
shoaib_ahmed 0:791a779d6220 3692 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3693 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12 + tmp13,
shoaib_ahmed 0:791a779d6220 3694 FIX(0.653061224)), /* 32/49 */
shoaib_ahmed 0:791a779d6220 3695 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3696 tmp13 += tmp13;
shoaib_ahmed 0:791a779d6220 3697 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3698 DESCALE(MULTIPLY(tmp10 - tmp13, FIX(0.832106052)) + /* c4 */
shoaib_ahmed 0:791a779d6220 3699 MULTIPLY(tmp11 - tmp13, FIX(0.205513223)) - /* c12 */
shoaib_ahmed 0:791a779d6220 3700 MULTIPLY(tmp12 - tmp13, FIX(0.575835255)), /* c8 */
shoaib_ahmed 0:791a779d6220 3701 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3702
shoaib_ahmed 0:791a779d6220 3703 tmp10 = MULTIPLY(tmp14 + tmp15, FIX(0.722074570)); /* c6 */
shoaib_ahmed 0:791a779d6220 3704
shoaib_ahmed 0:791a779d6220 3705 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3706 DESCALE(tmp10 + MULTIPLY(tmp14, FIX(0.178337691)) /* c2-c6 */
shoaib_ahmed 0:791a779d6220 3707 + MULTIPLY(tmp16, FIX(0.400721155)), /* c10 */
shoaib_ahmed 0:791a779d6220 3708 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3709 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3710 DESCALE(tmp10 - MULTIPLY(tmp15, FIX(1.122795725)) /* c6+c10 */
shoaib_ahmed 0:791a779d6220 3711 - MULTIPLY(tmp16, FIX(0.900412262)), /* c2 */
shoaib_ahmed 0:791a779d6220 3712 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3713
shoaib_ahmed 0:791a779d6220 3714 /* Odd part */
shoaib_ahmed 0:791a779d6220 3715
shoaib_ahmed 0:791a779d6220 3716 tmp10 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 3717 tmp11 = tmp5 - tmp4;
shoaib_ahmed 0:791a779d6220 3718 dataptr[DCTSIZE*7] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3719 DESCALE(MULTIPLY(tmp0 - tmp10 + tmp3 - tmp11 - tmp6,
shoaib_ahmed 0:791a779d6220 3720 FIX(0.653061224)), /* 32/49 */
shoaib_ahmed 0:791a779d6220 3721 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3722 tmp3 = MULTIPLY(tmp3 , FIX(0.653061224)); /* 32/49 */
shoaib_ahmed 0:791a779d6220 3723 tmp10 = MULTIPLY(tmp10, - FIX(0.103406812)); /* -c13 */
shoaib_ahmed 0:791a779d6220 3724 tmp11 = MULTIPLY(tmp11, FIX(0.917760839)); /* c1 */
shoaib_ahmed 0:791a779d6220 3725 tmp10 += tmp11 - tmp3;
shoaib_ahmed 0:791a779d6220 3726 tmp11 = MULTIPLY(tmp0 + tmp2, FIX(0.782007410)) + /* c5 */
shoaib_ahmed 0:791a779d6220 3727 MULTIPLY(tmp4 + tmp6, FIX(0.491367823)); /* c9 */
shoaib_ahmed 0:791a779d6220 3728 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3729 DESCALE(tmp10 + tmp11 - MULTIPLY(tmp2, FIX(1.550341076)) /* c3+c5-c13 */
shoaib_ahmed 0:791a779d6220 3730 + MULTIPLY(tmp4, FIX(0.731428202)), /* c1+c11-c9 */
shoaib_ahmed 0:791a779d6220 3731 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3732 tmp12 = MULTIPLY(tmp0 + tmp1, FIX(0.871740478)) + /* c3 */
shoaib_ahmed 0:791a779d6220 3733 MULTIPLY(tmp5 - tmp6, FIX(0.305035186)); /* c11 */
shoaib_ahmed 0:791a779d6220 3734 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3735 DESCALE(tmp10 + tmp12 - MULTIPLY(tmp1, FIX(0.276965844)) /* c3-c9-c13 */
shoaib_ahmed 0:791a779d6220 3736 - MULTIPLY(tmp5, FIX(2.004803435)), /* c1+c5+c11 */
shoaib_ahmed 0:791a779d6220 3737 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3738 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3739 DESCALE(tmp11 + tmp12 + tmp3
shoaib_ahmed 0:791a779d6220 3740 - MULTIPLY(tmp0, FIX(0.735987049)) /* c3+c5-c1 */
shoaib_ahmed 0:791a779d6220 3741 - MULTIPLY(tmp6, FIX(0.082925825)), /* c9-c11-c13 */
shoaib_ahmed 0:791a779d6220 3742 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3743
shoaib_ahmed 0:791a779d6220 3744 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3745 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3746 }
shoaib_ahmed 0:791a779d6220 3747 }
shoaib_ahmed 0:791a779d6220 3748
shoaib_ahmed 0:791a779d6220 3749
shoaib_ahmed 0:791a779d6220 3750 /*
shoaib_ahmed 0:791a779d6220 3751 * Perform the forward DCT on a 6x12 sample block.
shoaib_ahmed 0:791a779d6220 3752 *
shoaib_ahmed 0:791a779d6220 3753 * 6-point FDCT in pass 1 (rows), 12-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3754 */
shoaib_ahmed 0:791a779d6220 3755
shoaib_ahmed 0:791a779d6220 3756 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3757 jpeg_fdct_6x12 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3758 {
shoaib_ahmed 0:791a779d6220 3759 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
shoaib_ahmed 0:791a779d6220 3760 INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
shoaib_ahmed 0:791a779d6220 3761 DCTELEM workspace[8*4];
shoaib_ahmed 0:791a779d6220 3762 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3763 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 3764 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3765 int ctr;
shoaib_ahmed 0:791a779d6220 3766 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3767
shoaib_ahmed 0:791a779d6220 3768 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3769 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3770
shoaib_ahmed 0:791a779d6220 3771 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3772 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3773 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3774 * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12).
shoaib_ahmed 0:791a779d6220 3775 */
shoaib_ahmed 0:791a779d6220 3776
shoaib_ahmed 0:791a779d6220 3777 dataptr = data;
shoaib_ahmed 0:791a779d6220 3778 ctr = 0;
shoaib_ahmed 0:791a779d6220 3779 for (;;) {
shoaib_ahmed 0:791a779d6220 3780 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3781
shoaib_ahmed 0:791a779d6220 3782 /* Even part */
shoaib_ahmed 0:791a779d6220 3783
shoaib_ahmed 0:791a779d6220 3784 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3785 tmp11 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3786 tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3787
shoaib_ahmed 0:791a779d6220 3788 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 3789 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 3790
shoaib_ahmed 0:791a779d6220 3791 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[5]);
shoaib_ahmed 0:791a779d6220 3792 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3793 tmp2 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3794
shoaib_ahmed 0:791a779d6220 3795 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3796 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3797 ((tmp10 + tmp11 - 6 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3798 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3799 DESCALE(MULTIPLY(tmp12, FIX(1.224744871)), /* c2 */
shoaib_ahmed 0:791a779d6220 3800 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3801 dataptr[4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3802 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(0.707106781)), /* c4 */
shoaib_ahmed 0:791a779d6220 3803 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3804
shoaib_ahmed 0:791a779d6220 3805 /* Odd part */
shoaib_ahmed 0:791a779d6220 3806
shoaib_ahmed 0:791a779d6220 3807 tmp10 = DESCALE(MULTIPLY(tmp0 + tmp2, FIX(0.366025404)), /* c5 */
shoaib_ahmed 0:791a779d6220 3808 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3809
shoaib_ahmed 0:791a779d6220 3810 dataptr[1] = (DCTELEM) (tmp10 + ((tmp0 + tmp1) << PASS1_BITS));
shoaib_ahmed 0:791a779d6220 3811 dataptr[3] = (DCTELEM) ((tmp0 - tmp1 - tmp2) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3812 dataptr[5] = (DCTELEM) (tmp10 + ((tmp2 - tmp1) << PASS1_BITS));
shoaib_ahmed 0:791a779d6220 3813
shoaib_ahmed 0:791a779d6220 3814 ctr++;
shoaib_ahmed 0:791a779d6220 3815
shoaib_ahmed 0:791a779d6220 3816 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 3817 if (ctr == 12)
shoaib_ahmed 0:791a779d6220 3818 break; /* Done. */
shoaib_ahmed 0:791a779d6220 3819 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3820 } else
shoaib_ahmed 0:791a779d6220 3821 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 3822 }
shoaib_ahmed 0:791a779d6220 3823
shoaib_ahmed 0:791a779d6220 3824 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3825 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3826 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3827 * We must also scale the output by (8/6)*(8/12) = 8/9, which we
shoaib_ahmed 0:791a779d6220 3828 * fold into the constant multipliers:
shoaib_ahmed 0:791a779d6220 3829 * 12-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/24) * 8/9.
shoaib_ahmed 0:791a779d6220 3830 */
shoaib_ahmed 0:791a779d6220 3831
shoaib_ahmed 0:791a779d6220 3832 dataptr = data;
shoaib_ahmed 0:791a779d6220 3833 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 3834 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 3835 /* Even part */
shoaib_ahmed 0:791a779d6220 3836
shoaib_ahmed 0:791a779d6220 3837 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3838 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3839 tmp2 = dataptr[DCTSIZE*2] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3840 tmp3 = dataptr[DCTSIZE*3] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3841 tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3842 tmp5 = dataptr[DCTSIZE*5] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 3843
shoaib_ahmed 0:791a779d6220 3844 tmp10 = tmp0 + tmp5;
shoaib_ahmed 0:791a779d6220 3845 tmp13 = tmp0 - tmp5;
shoaib_ahmed 0:791a779d6220 3846 tmp11 = tmp1 + tmp4;
shoaib_ahmed 0:791a779d6220 3847 tmp14 = tmp1 - tmp4;
shoaib_ahmed 0:791a779d6220 3848 tmp12 = tmp2 + tmp3;
shoaib_ahmed 0:791a779d6220 3849 tmp15 = tmp2 - tmp3;
shoaib_ahmed 0:791a779d6220 3850
shoaib_ahmed 0:791a779d6220 3851 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 3852 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 3853 tmp2 = dataptr[DCTSIZE*2] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3854 tmp3 = dataptr[DCTSIZE*3] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3855 tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3856 tmp5 = dataptr[DCTSIZE*5] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 3857
shoaib_ahmed 0:791a779d6220 3858 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3859 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(0.888888889)), /* 8/9 */
shoaib_ahmed 0:791a779d6220 3860 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3861 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3862 DESCALE(MULTIPLY(tmp13 - tmp14 - tmp15, FIX(0.888888889)), /* 8/9 */
shoaib_ahmed 0:791a779d6220 3863 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3864 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3865 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.088662108)), /* c4 */
shoaib_ahmed 0:791a779d6220 3866 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3867 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3868 DESCALE(MULTIPLY(tmp14 - tmp15, FIX(0.888888889)) + /* 8/9 */
shoaib_ahmed 0:791a779d6220 3869 MULTIPLY(tmp13 + tmp15, FIX(1.214244803)), /* c2 */
shoaib_ahmed 0:791a779d6220 3870 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3871
shoaib_ahmed 0:791a779d6220 3872 /* Odd part */
shoaib_ahmed 0:791a779d6220 3873
shoaib_ahmed 0:791a779d6220 3874 tmp10 = MULTIPLY(tmp1 + tmp4, FIX(0.481063200)); /* c9 */
shoaib_ahmed 0:791a779d6220 3875 tmp14 = tmp10 + MULTIPLY(tmp1, FIX(0.680326102)); /* c3-c9 */
shoaib_ahmed 0:791a779d6220 3876 tmp15 = tmp10 - MULTIPLY(tmp4, FIX(1.642452502)); /* c3+c9 */
shoaib_ahmed 0:791a779d6220 3877 tmp12 = MULTIPLY(tmp0 + tmp2, FIX(0.997307603)); /* c5 */
shoaib_ahmed 0:791a779d6220 3878 tmp13 = MULTIPLY(tmp0 + tmp3, FIX(0.765261039)); /* c7 */
shoaib_ahmed 0:791a779d6220 3879 tmp10 = tmp12 + tmp13 + tmp14 - MULTIPLY(tmp0, FIX(0.516244403)) /* c5+c7-c1 */
shoaib_ahmed 0:791a779d6220 3880 + MULTIPLY(tmp5, FIX(0.164081699)); /* c11 */
shoaib_ahmed 0:791a779d6220 3881 tmp11 = MULTIPLY(tmp2 + tmp3, - FIX(0.164081699)); /* -c11 */
shoaib_ahmed 0:791a779d6220 3882 tmp12 += tmp11 - tmp15 - MULTIPLY(tmp2, FIX(2.079550144)) /* c1+c5-c11 */
shoaib_ahmed 0:791a779d6220 3883 + MULTIPLY(tmp5, FIX(0.765261039)); /* c7 */
shoaib_ahmed 0:791a779d6220 3884 tmp13 += tmp11 - tmp14 + MULTIPLY(tmp3, FIX(0.645144899)) /* c1+c11-c7 */
shoaib_ahmed 0:791a779d6220 3885 - MULTIPLY(tmp5, FIX(0.997307603)); /* c5 */
shoaib_ahmed 0:791a779d6220 3886 tmp11 = tmp15 + MULTIPLY(tmp0 - tmp3, FIX(1.161389302)) /* c3 */
shoaib_ahmed 0:791a779d6220 3887 - MULTIPLY(tmp2 + tmp5, FIX(0.481063200)); /* c9 */
shoaib_ahmed 0:791a779d6220 3888
shoaib_ahmed 0:791a779d6220 3889 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3890 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp11, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3891 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3892 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp13, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3893
shoaib_ahmed 0:791a779d6220 3894 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3895 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 3896 }
shoaib_ahmed 0:791a779d6220 3897 }
shoaib_ahmed 0:791a779d6220 3898
shoaib_ahmed 0:791a779d6220 3899
shoaib_ahmed 0:791a779d6220 3900 /*
shoaib_ahmed 0:791a779d6220 3901 * Perform the forward DCT on a 5x10 sample block.
shoaib_ahmed 0:791a779d6220 3902 *
shoaib_ahmed 0:791a779d6220 3903 * 5-point FDCT in pass 1 (rows), 10-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 3904 */
shoaib_ahmed 0:791a779d6220 3905
shoaib_ahmed 0:791a779d6220 3906 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 3907 jpeg_fdct_5x10 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 3908 {
shoaib_ahmed 0:791a779d6220 3909 INT32 tmp0, tmp1, tmp2, tmp3, tmp4;
shoaib_ahmed 0:791a779d6220 3910 INT32 tmp10, tmp11, tmp12, tmp13, tmp14;
shoaib_ahmed 0:791a779d6220 3911 DCTELEM workspace[8*2];
shoaib_ahmed 0:791a779d6220 3912 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 3913 DCTELEM *wsptr;
shoaib_ahmed 0:791a779d6220 3914 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 3915 int ctr;
shoaib_ahmed 0:791a779d6220 3916 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 3917
shoaib_ahmed 0:791a779d6220 3918 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 3919 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 3920
shoaib_ahmed 0:791a779d6220 3921 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 3922 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 3923 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 3924 * 5-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/10).
shoaib_ahmed 0:791a779d6220 3925 */
shoaib_ahmed 0:791a779d6220 3926
shoaib_ahmed 0:791a779d6220 3927 dataptr = data;
shoaib_ahmed 0:791a779d6220 3928 ctr = 0;
shoaib_ahmed 0:791a779d6220 3929 for (;;) {
shoaib_ahmed 0:791a779d6220 3930 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 3931
shoaib_ahmed 0:791a779d6220 3932 /* Even part */
shoaib_ahmed 0:791a779d6220 3933
shoaib_ahmed 0:791a779d6220 3934 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3935 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3936 tmp2 = GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 3937
shoaib_ahmed 0:791a779d6220 3938 tmp10 = tmp0 + tmp1;
shoaib_ahmed 0:791a779d6220 3939 tmp11 = tmp0 - tmp1;
shoaib_ahmed 0:791a779d6220 3940
shoaib_ahmed 0:791a779d6220 3941 tmp0 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[4]);
shoaib_ahmed 0:791a779d6220 3942 tmp1 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 3943
shoaib_ahmed 0:791a779d6220 3944 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 3945 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3946 ((tmp10 + tmp2 - 5 * CENTERJSAMPLE) << PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3947 tmp11 = MULTIPLY(tmp11, FIX(0.790569415)); /* (c2+c4)/2 */
shoaib_ahmed 0:791a779d6220 3948 tmp10 -= tmp2 << 2;
shoaib_ahmed 0:791a779d6220 3949 tmp10 = MULTIPLY(tmp10, FIX(0.353553391)); /* (c2-c4)/2 */
shoaib_ahmed 0:791a779d6220 3950 dataptr[2] = (DCTELEM) DESCALE(tmp11 + tmp10, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3951 dataptr[4] = (DCTELEM) DESCALE(tmp11 - tmp10, CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3952
shoaib_ahmed 0:791a779d6220 3953 /* Odd part */
shoaib_ahmed 0:791a779d6220 3954
shoaib_ahmed 0:791a779d6220 3955 tmp10 = MULTIPLY(tmp0 + tmp1, FIX(0.831253876)); /* c3 */
shoaib_ahmed 0:791a779d6220 3956
shoaib_ahmed 0:791a779d6220 3957 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3958 DESCALE(tmp10 + MULTIPLY(tmp0, FIX(0.513743148)), /* c1-c3 */
shoaib_ahmed 0:791a779d6220 3959 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3960 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 3961 DESCALE(tmp10 - MULTIPLY(tmp1, FIX(2.176250899)), /* c1+c3 */
shoaib_ahmed 0:791a779d6220 3962 CONST_BITS-PASS1_BITS);
shoaib_ahmed 0:791a779d6220 3963
shoaib_ahmed 0:791a779d6220 3964 ctr++;
shoaib_ahmed 0:791a779d6220 3965
shoaib_ahmed 0:791a779d6220 3966 if (ctr != DCTSIZE) {
shoaib_ahmed 0:791a779d6220 3967 if (ctr == 10)
shoaib_ahmed 0:791a779d6220 3968 break; /* Done. */
shoaib_ahmed 0:791a779d6220 3969 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 3970 } else
shoaib_ahmed 0:791a779d6220 3971 dataptr = workspace; /* switch pointer to extended workspace */
shoaib_ahmed 0:791a779d6220 3972 }
shoaib_ahmed 0:791a779d6220 3973
shoaib_ahmed 0:791a779d6220 3974 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 3975 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 3976 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 3977 * We must also scale the output by (8/5)*(8/10) = 32/25, which we
shoaib_ahmed 0:791a779d6220 3978 * fold into the constant multipliers:
shoaib_ahmed 0:791a779d6220 3979 * 10-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/20) * 32/25.
shoaib_ahmed 0:791a779d6220 3980 */
shoaib_ahmed 0:791a779d6220 3981
shoaib_ahmed 0:791a779d6220 3982 dataptr = data;
shoaib_ahmed 0:791a779d6220 3983 wsptr = workspace;
shoaib_ahmed 0:791a779d6220 3984 for (ctr = 0; ctr < 5; ctr++) {
shoaib_ahmed 0:791a779d6220 3985 /* Even part */
shoaib_ahmed 0:791a779d6220 3986
shoaib_ahmed 0:791a779d6220 3987 tmp0 = dataptr[DCTSIZE*0] + wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3988 tmp1 = dataptr[DCTSIZE*1] + wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 3989 tmp12 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 3990 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 3991 tmp4 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 3992
shoaib_ahmed 0:791a779d6220 3993 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 3994 tmp13 = tmp0 - tmp4;
shoaib_ahmed 0:791a779d6220 3995 tmp11 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 3996 tmp14 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 3997
shoaib_ahmed 0:791a779d6220 3998 tmp0 = dataptr[DCTSIZE*0] - wsptr[DCTSIZE*1];
shoaib_ahmed 0:791a779d6220 3999 tmp1 = dataptr[DCTSIZE*1] - wsptr[DCTSIZE*0];
shoaib_ahmed 0:791a779d6220 4000 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 4001 tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 4002 tmp4 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 4003
shoaib_ahmed 0:791a779d6220 4004 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4005 DESCALE(MULTIPLY(tmp10 + tmp11 + tmp12, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 4006 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4007 tmp12 += tmp12;
shoaib_ahmed 0:791a779d6220 4008 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4009 DESCALE(MULTIPLY(tmp10 - tmp12, FIX(1.464477191)) - /* c4 */
shoaib_ahmed 0:791a779d6220 4010 MULTIPLY(tmp11 - tmp12, FIX(0.559380511)), /* c8 */
shoaib_ahmed 0:791a779d6220 4011 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4012 tmp10 = MULTIPLY(tmp13 + tmp14, FIX(1.064004961)); /* c6 */
shoaib_ahmed 0:791a779d6220 4013 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4014 DESCALE(tmp10 + MULTIPLY(tmp13, FIX(0.657591230)), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 4015 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4016 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4017 DESCALE(tmp10 - MULTIPLY(tmp14, FIX(2.785601151)), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 4018 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4019
shoaib_ahmed 0:791a779d6220 4020 /* Odd part */
shoaib_ahmed 0:791a779d6220 4021
shoaib_ahmed 0:791a779d6220 4022 tmp10 = tmp0 + tmp4;
shoaib_ahmed 0:791a779d6220 4023 tmp11 = tmp1 - tmp3;
shoaib_ahmed 0:791a779d6220 4024 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4025 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp2, FIX(1.28)), /* 32/25 */
shoaib_ahmed 0:791a779d6220 4026 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4027 tmp2 = MULTIPLY(tmp2, FIX(1.28)); /* 32/25 */
shoaib_ahmed 0:791a779d6220 4028 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4029 DESCALE(MULTIPLY(tmp0, FIX(1.787906876)) + /* c1 */
shoaib_ahmed 0:791a779d6220 4030 MULTIPLY(tmp1, FIX(1.612894094)) + tmp2 + /* c3 */
shoaib_ahmed 0:791a779d6220 4031 MULTIPLY(tmp3, FIX(0.821810588)) + /* c7 */
shoaib_ahmed 0:791a779d6220 4032 MULTIPLY(tmp4, FIX(0.283176630)), /* c9 */
shoaib_ahmed 0:791a779d6220 4033 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4034 tmp12 = MULTIPLY(tmp0 - tmp4, FIX(1.217352341)) - /* (c3+c7)/2 */
shoaib_ahmed 0:791a779d6220 4035 MULTIPLY(tmp1 + tmp3, FIX(0.752365123)); /* (c1-c9)/2 */
shoaib_ahmed 0:791a779d6220 4036 tmp13 = MULTIPLY(tmp10 + tmp11, FIX(0.395541753)) + /* (c3-c7)/2 */
shoaib_ahmed 0:791a779d6220 4037 MULTIPLY(tmp11, FIX(0.64)) - tmp2; /* 16/25 */
shoaib_ahmed 0:791a779d6220 4038 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp12 + tmp13, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4039 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp12 - tmp13, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4040
shoaib_ahmed 0:791a779d6220 4041 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 4042 wsptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 4043 }
shoaib_ahmed 0:791a779d6220 4044 }
shoaib_ahmed 0:791a779d6220 4045
shoaib_ahmed 0:791a779d6220 4046
shoaib_ahmed 0:791a779d6220 4047 /*
shoaib_ahmed 0:791a779d6220 4048 * Perform the forward DCT on a 4x8 sample block.
shoaib_ahmed 0:791a779d6220 4049 *
shoaib_ahmed 0:791a779d6220 4050 * 4-point FDCT in pass 1 (rows), 8-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 4051 */
shoaib_ahmed 0:791a779d6220 4052
shoaib_ahmed 0:791a779d6220 4053 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 4054 jpeg_fdct_4x8 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 4055 {
shoaib_ahmed 0:791a779d6220 4056 INT32 tmp0, tmp1, tmp2, tmp3;
shoaib_ahmed 0:791a779d6220 4057 INT32 tmp10, tmp11, tmp12, tmp13;
shoaib_ahmed 0:791a779d6220 4058 INT32 z1;
shoaib_ahmed 0:791a779d6220 4059 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 4060 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 4061 int ctr;
shoaib_ahmed 0:791a779d6220 4062 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 4063
shoaib_ahmed 0:791a779d6220 4064 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 4065 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 4066
shoaib_ahmed 0:791a779d6220 4067 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 4068 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 4069 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 4070 * We must also scale the output by 8/4 = 2, which we add here.
shoaib_ahmed 0:791a779d6220 4071 * 4-point FDCT kernel,
shoaib_ahmed 0:791a779d6220 4072 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 4073 */
shoaib_ahmed 0:791a779d6220 4074
shoaib_ahmed 0:791a779d6220 4075 dataptr = data;
shoaib_ahmed 0:791a779d6220 4076 for (ctr = 0; ctr < DCTSIZE; ctr++) {
shoaib_ahmed 0:791a779d6220 4077 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 4078
shoaib_ahmed 0:791a779d6220 4079 /* Even part */
shoaib_ahmed 0:791a779d6220 4080
shoaib_ahmed 0:791a779d6220 4081 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 4082 tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 4083
shoaib_ahmed 0:791a779d6220 4084 tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
shoaib_ahmed 0:791a779d6220 4085 tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 4086
shoaib_ahmed 0:791a779d6220 4087 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 4088 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4089 ((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 4090 dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 4091
shoaib_ahmed 0:791a779d6220 4092 /* Odd part */
shoaib_ahmed 0:791a779d6220 4093
shoaib_ahmed 0:791a779d6220 4094 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 4095 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 4096 tmp0 += ONE << (CONST_BITS-PASS1_BITS-2);
shoaib_ahmed 0:791a779d6220 4097
shoaib_ahmed 0:791a779d6220 4098 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4099 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 4100 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4101 dataptr[3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4102 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 4103 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4104
shoaib_ahmed 0:791a779d6220 4105 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 4106 }
shoaib_ahmed 0:791a779d6220 4107
shoaib_ahmed 0:791a779d6220 4108 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 4109 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 4110 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 4111 * 8-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/16).
shoaib_ahmed 0:791a779d6220 4112 */
shoaib_ahmed 0:791a779d6220 4113
shoaib_ahmed 0:791a779d6220 4114 dataptr = data;
shoaib_ahmed 0:791a779d6220 4115 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 4116 /* Even part per LL&M figure 1 --- note that published figure is faulty;
shoaib_ahmed 0:791a779d6220 4117 * rotator "c1" should be "c6".
shoaib_ahmed 0:791a779d6220 4118 */
shoaib_ahmed 0:791a779d6220 4119
shoaib_ahmed 0:791a779d6220 4120 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 4121 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 4122 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 4123 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 4124
shoaib_ahmed 0:791a779d6220 4125 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 4126 tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1));
shoaib_ahmed 0:791a779d6220 4127 tmp12 = tmp0 - tmp3;
shoaib_ahmed 0:791a779d6220 4128 tmp11 = tmp1 + tmp2;
shoaib_ahmed 0:791a779d6220 4129 tmp13 = tmp1 - tmp2;
shoaib_ahmed 0:791a779d6220 4130
shoaib_ahmed 0:791a779d6220 4131 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
shoaib_ahmed 0:791a779d6220 4132 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
shoaib_ahmed 0:791a779d6220 4133 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 4134 tmp3 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 4135
shoaib_ahmed 0:791a779d6220 4136 dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4137 dataptr[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4138
shoaib_ahmed 0:791a779d6220 4139 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 4140 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 4141 z1 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4142
shoaib_ahmed 0:791a779d6220 4143 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4144 RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 4145 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4146 dataptr[DCTSIZE*6] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4147 RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 4148 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4149
shoaib_ahmed 0:791a779d6220 4150 /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
shoaib_ahmed 0:791a779d6220 4151 * i0..i3 in the paper are tmp0..tmp3 here.
shoaib_ahmed 0:791a779d6220 4152 */
shoaib_ahmed 0:791a779d6220 4153
shoaib_ahmed 0:791a779d6220 4154 tmp12 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 4155 tmp13 = tmp1 + tmp3;
shoaib_ahmed 0:791a779d6220 4156
shoaib_ahmed 0:791a779d6220 4157 z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602); /* c3 */
shoaib_ahmed 0:791a779d6220 4158 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 4159 z1 += ONE << (CONST_BITS+PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4160
shoaib_ahmed 0:791a779d6220 4161 tmp12 = MULTIPLY(tmp12, - FIX_0_390180644); /* -c3+c5 */
shoaib_ahmed 0:791a779d6220 4162 tmp13 = MULTIPLY(tmp13, - FIX_1_961570560); /* -c3-c5 */
shoaib_ahmed 0:791a779d6220 4163 tmp12 += z1;
shoaib_ahmed 0:791a779d6220 4164 tmp13 += z1;
shoaib_ahmed 0:791a779d6220 4165
shoaib_ahmed 0:791a779d6220 4166 z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */
shoaib_ahmed 0:791a779d6220 4167 tmp0 = MULTIPLY(tmp0, FIX_1_501321110); /* c1+c3-c5-c7 */
shoaib_ahmed 0:791a779d6220 4168 tmp3 = MULTIPLY(tmp3, FIX_0_298631336); /* -c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 4169 tmp0 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 4170 tmp3 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 4171
shoaib_ahmed 0:791a779d6220 4172 z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */
shoaib_ahmed 0:791a779d6220 4173 tmp1 = MULTIPLY(tmp1, FIX_3_072711026); /* c1+c3+c5-c7 */
shoaib_ahmed 0:791a779d6220 4174 tmp2 = MULTIPLY(tmp2, FIX_2_053119869); /* c1+c3-c5+c7 */
shoaib_ahmed 0:791a779d6220 4175 tmp1 += z1 + tmp13;
shoaib_ahmed 0:791a779d6220 4176 tmp2 += z1 + tmp12;
shoaib_ahmed 0:791a779d6220 4177
shoaib_ahmed 0:791a779d6220 4178 dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4179 dataptr[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4180 dataptr[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4181 dataptr[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4182
shoaib_ahmed 0:791a779d6220 4183 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 4184 }
shoaib_ahmed 0:791a779d6220 4185 }
shoaib_ahmed 0:791a779d6220 4186
shoaib_ahmed 0:791a779d6220 4187
shoaib_ahmed 0:791a779d6220 4188 /*
shoaib_ahmed 0:791a779d6220 4189 * Perform the forward DCT on a 3x6 sample block.
shoaib_ahmed 0:791a779d6220 4190 *
shoaib_ahmed 0:791a779d6220 4191 * 3-point FDCT in pass 1 (rows), 6-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 4192 */
shoaib_ahmed 0:791a779d6220 4193
shoaib_ahmed 0:791a779d6220 4194 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 4195 jpeg_fdct_3x6 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 4196 {
shoaib_ahmed 0:791a779d6220 4197 INT32 tmp0, tmp1, tmp2;
shoaib_ahmed 0:791a779d6220 4198 INT32 tmp10, tmp11, tmp12;
shoaib_ahmed 0:791a779d6220 4199 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 4200 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 4201 int ctr;
shoaib_ahmed 0:791a779d6220 4202 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 4203
shoaib_ahmed 0:791a779d6220 4204 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 4205 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 4206
shoaib_ahmed 0:791a779d6220 4207 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 4208 * Note results are scaled up by sqrt(8) compared to a true DCT;
shoaib_ahmed 0:791a779d6220 4209 * furthermore, we scale the results by 2**PASS1_BITS.
shoaib_ahmed 0:791a779d6220 4210 * We scale the results further by 2 as part of output adaption
shoaib_ahmed 0:791a779d6220 4211 * scaling for different DCT size.
shoaib_ahmed 0:791a779d6220 4212 * 3-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/6).
shoaib_ahmed 0:791a779d6220 4213 */
shoaib_ahmed 0:791a779d6220 4214
shoaib_ahmed 0:791a779d6220 4215 dataptr = data;
shoaib_ahmed 0:791a779d6220 4216 for (ctr = 0; ctr < 6; ctr++) {
shoaib_ahmed 0:791a779d6220 4217 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 4218
shoaib_ahmed 0:791a779d6220 4219 /* Even part */
shoaib_ahmed 0:791a779d6220 4220
shoaib_ahmed 0:791a779d6220 4221 tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 4222 tmp1 = GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 4223
shoaib_ahmed 0:791a779d6220 4224 tmp2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[2]);
shoaib_ahmed 0:791a779d6220 4225
shoaib_ahmed 0:791a779d6220 4226 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 4227 dataptr[0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4228 ((tmp0 + tmp1 - 3 * CENTERJSAMPLE) << (PASS1_BITS+1));
shoaib_ahmed 0:791a779d6220 4229 dataptr[2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4230 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp1, FIX(0.707106781)), /* c2 */
shoaib_ahmed 0:791a779d6220 4231 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4232
shoaib_ahmed 0:791a779d6220 4233 /* Odd part */
shoaib_ahmed 0:791a779d6220 4234
shoaib_ahmed 0:791a779d6220 4235 dataptr[1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4236 DESCALE(MULTIPLY(tmp2, FIX(1.224744871)), /* c1 */
shoaib_ahmed 0:791a779d6220 4237 CONST_BITS-PASS1_BITS-1);
shoaib_ahmed 0:791a779d6220 4238
shoaib_ahmed 0:791a779d6220 4239 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 4240 }
shoaib_ahmed 0:791a779d6220 4241
shoaib_ahmed 0:791a779d6220 4242 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 4243 * We remove the PASS1_BITS scaling, but leave the results scaled up
shoaib_ahmed 0:791a779d6220 4244 * by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 4245 * We must also scale the output by (8/6)*(8/3) = 32/9, which we partially
shoaib_ahmed 0:791a779d6220 4246 * fold into the constant multipliers (other part was done in pass 1):
shoaib_ahmed 0:791a779d6220 4247 * 6-point FDCT kernel, cK represents sqrt(2) * cos(K*pi/12) * 16/9.
shoaib_ahmed 0:791a779d6220 4248 */
shoaib_ahmed 0:791a779d6220 4249
shoaib_ahmed 0:791a779d6220 4250 dataptr = data;
shoaib_ahmed 0:791a779d6220 4251 for (ctr = 0; ctr < 3; ctr++) {
shoaib_ahmed 0:791a779d6220 4252 /* Even part */
shoaib_ahmed 0:791a779d6220 4253
shoaib_ahmed 0:791a779d6220 4254 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 4255 tmp11 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 4256 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 4257
shoaib_ahmed 0:791a779d6220 4258 tmp10 = tmp0 + tmp2;
shoaib_ahmed 0:791a779d6220 4259 tmp12 = tmp0 - tmp2;
shoaib_ahmed 0:791a779d6220 4260
shoaib_ahmed 0:791a779d6220 4261 tmp0 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*5];
shoaib_ahmed 0:791a779d6220 4262 tmp1 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*4];
shoaib_ahmed 0:791a779d6220 4263 tmp2 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 4264
shoaib_ahmed 0:791a779d6220 4265 dataptr[DCTSIZE*0] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4266 DESCALE(MULTIPLY(tmp10 + tmp11, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 4267 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4268 dataptr[DCTSIZE*2] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4269 DESCALE(MULTIPLY(tmp12, FIX(2.177324216)), /* c2 */
shoaib_ahmed 0:791a779d6220 4270 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4271 dataptr[DCTSIZE*4] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4272 DESCALE(MULTIPLY(tmp10 - tmp11 - tmp11, FIX(1.257078722)), /* c4 */
shoaib_ahmed 0:791a779d6220 4273 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4274
shoaib_ahmed 0:791a779d6220 4275 /* Odd part */
shoaib_ahmed 0:791a779d6220 4276
shoaib_ahmed 0:791a779d6220 4277 tmp10 = MULTIPLY(tmp0 + tmp2, FIX(0.650711829)); /* c5 */
shoaib_ahmed 0:791a779d6220 4278
shoaib_ahmed 0:791a779d6220 4279 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4280 DESCALE(tmp10 + MULTIPLY(tmp0 + tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 4281 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4282 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4283 DESCALE(MULTIPLY(tmp0 - tmp1 - tmp2, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 4284 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4285 dataptr[DCTSIZE*5] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4286 DESCALE(tmp10 + MULTIPLY(tmp2 - tmp1, FIX(1.777777778)), /* 16/9 */
shoaib_ahmed 0:791a779d6220 4287 CONST_BITS+PASS1_BITS);
shoaib_ahmed 0:791a779d6220 4288
shoaib_ahmed 0:791a779d6220 4289 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 4290 }
shoaib_ahmed 0:791a779d6220 4291 }
shoaib_ahmed 0:791a779d6220 4292
shoaib_ahmed 0:791a779d6220 4293
shoaib_ahmed 0:791a779d6220 4294 /*
shoaib_ahmed 0:791a779d6220 4295 * Perform the forward DCT on a 2x4 sample block.
shoaib_ahmed 0:791a779d6220 4296 *
shoaib_ahmed 0:791a779d6220 4297 * 2-point FDCT in pass 1 (rows), 4-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 4298 */
shoaib_ahmed 0:791a779d6220 4299
shoaib_ahmed 0:791a779d6220 4300 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 4301 jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 4302 {
shoaib_ahmed 0:791a779d6220 4303 INT32 tmp0, tmp1;
shoaib_ahmed 0:791a779d6220 4304 INT32 tmp10, tmp11;
shoaib_ahmed 0:791a779d6220 4305 DCTELEM *dataptr;
shoaib_ahmed 0:791a779d6220 4306 JSAMPROW elemptr;
shoaib_ahmed 0:791a779d6220 4307 int ctr;
shoaib_ahmed 0:791a779d6220 4308 SHIFT_TEMPS
shoaib_ahmed 0:791a779d6220 4309
shoaib_ahmed 0:791a779d6220 4310 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 4311 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 4312
shoaib_ahmed 0:791a779d6220 4313 /* Pass 1: process rows.
shoaib_ahmed 0:791a779d6220 4314 * Note results are scaled up by sqrt(8) compared to a true DCT.
shoaib_ahmed 0:791a779d6220 4315 * We must also scale the output by (8/2)*(8/4) = 2**3, which we add here.
shoaib_ahmed 0:791a779d6220 4316 */
shoaib_ahmed 0:791a779d6220 4317
shoaib_ahmed 0:791a779d6220 4318 dataptr = data;
shoaib_ahmed 0:791a779d6220 4319 for (ctr = 0; ctr < 4; ctr++) {
shoaib_ahmed 0:791a779d6220 4320 elemptr = sample_data[ctr] + start_col;
shoaib_ahmed 0:791a779d6220 4321
shoaib_ahmed 0:791a779d6220 4322 /* Even part */
shoaib_ahmed 0:791a779d6220 4323
shoaib_ahmed 0:791a779d6220 4324 tmp0 = GETJSAMPLE(elemptr[0]);
shoaib_ahmed 0:791a779d6220 4325 tmp1 = GETJSAMPLE(elemptr[1]);
shoaib_ahmed 0:791a779d6220 4326
shoaib_ahmed 0:791a779d6220 4327 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 4328 dataptr[0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 3);
shoaib_ahmed 0:791a779d6220 4329
shoaib_ahmed 0:791a779d6220 4330 /* Odd part */
shoaib_ahmed 0:791a779d6220 4331
shoaib_ahmed 0:791a779d6220 4332 dataptr[1] = (DCTELEM) ((tmp0 - tmp1) << 3);
shoaib_ahmed 0:791a779d6220 4333
shoaib_ahmed 0:791a779d6220 4334 dataptr += DCTSIZE; /* advance pointer to next row */
shoaib_ahmed 0:791a779d6220 4335 }
shoaib_ahmed 0:791a779d6220 4336
shoaib_ahmed 0:791a779d6220 4337 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 4338 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 4339 * 4-point FDCT kernel,
shoaib_ahmed 0:791a779d6220 4340 * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
shoaib_ahmed 0:791a779d6220 4341 */
shoaib_ahmed 0:791a779d6220 4342
shoaib_ahmed 0:791a779d6220 4343 dataptr = data;
shoaib_ahmed 0:791a779d6220 4344 for (ctr = 0; ctr < 2; ctr++) {
shoaib_ahmed 0:791a779d6220 4345 /* Even part */
shoaib_ahmed 0:791a779d6220 4346
shoaib_ahmed 0:791a779d6220 4347 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 4348 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 4349
shoaib_ahmed 0:791a779d6220 4350 tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
shoaib_ahmed 0:791a779d6220 4351 tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
shoaib_ahmed 0:791a779d6220 4352
shoaib_ahmed 0:791a779d6220 4353 dataptr[DCTSIZE*0] = (DCTELEM) (tmp0 + tmp1);
shoaib_ahmed 0:791a779d6220 4354 dataptr[DCTSIZE*2] = (DCTELEM) (tmp0 - tmp1);
shoaib_ahmed 0:791a779d6220 4355
shoaib_ahmed 0:791a779d6220 4356 /* Odd part */
shoaib_ahmed 0:791a779d6220 4357
shoaib_ahmed 0:791a779d6220 4358 tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
shoaib_ahmed 0:791a779d6220 4359 /* Add fudge factor here for final descale. */
shoaib_ahmed 0:791a779d6220 4360 tmp0 += ONE << (CONST_BITS-1);
shoaib_ahmed 0:791a779d6220 4361
shoaib_ahmed 0:791a779d6220 4362 dataptr[DCTSIZE*1] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4363 RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
shoaib_ahmed 0:791a779d6220 4364 CONST_BITS);
shoaib_ahmed 0:791a779d6220 4365 dataptr[DCTSIZE*3] = (DCTELEM)
shoaib_ahmed 0:791a779d6220 4366 RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
shoaib_ahmed 0:791a779d6220 4367 CONST_BITS);
shoaib_ahmed 0:791a779d6220 4368
shoaib_ahmed 0:791a779d6220 4369 dataptr++; /* advance pointer to next column */
shoaib_ahmed 0:791a779d6220 4370 }
shoaib_ahmed 0:791a779d6220 4371 }
shoaib_ahmed 0:791a779d6220 4372
shoaib_ahmed 0:791a779d6220 4373
shoaib_ahmed 0:791a779d6220 4374 /*
shoaib_ahmed 0:791a779d6220 4375 * Perform the forward DCT on a 1x2 sample block.
shoaib_ahmed 0:791a779d6220 4376 *
shoaib_ahmed 0:791a779d6220 4377 * 1-point FDCT in pass 1 (rows), 2-point in pass 2 (columns).
shoaib_ahmed 0:791a779d6220 4378 */
shoaib_ahmed 0:791a779d6220 4379
shoaib_ahmed 0:791a779d6220 4380 GLOBAL(void)
shoaib_ahmed 0:791a779d6220 4381 jpeg_fdct_1x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
shoaib_ahmed 0:791a779d6220 4382 {
shoaib_ahmed 0:791a779d6220 4383 DCTELEM tmp0, tmp1;
shoaib_ahmed 0:791a779d6220 4384
shoaib_ahmed 0:791a779d6220 4385 /* Pre-zero output coefficient block. */
shoaib_ahmed 0:791a779d6220 4386 MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
shoaib_ahmed 0:791a779d6220 4387
shoaib_ahmed 0:791a779d6220 4388 /* Pass 1: empty. */
shoaib_ahmed 0:791a779d6220 4389
shoaib_ahmed 0:791a779d6220 4390 /* Pass 2: process columns.
shoaib_ahmed 0:791a779d6220 4391 * We leave the results scaled up by an overall factor of 8.
shoaib_ahmed 0:791a779d6220 4392 * We must also scale the output by (8/1)*(8/2) = 2**5.
shoaib_ahmed 0:791a779d6220 4393 */
shoaib_ahmed 0:791a779d6220 4394
shoaib_ahmed 0:791a779d6220 4395 /* Even part */
shoaib_ahmed 0:791a779d6220 4396
shoaib_ahmed 0:791a779d6220 4397 tmp0 = GETJSAMPLE(sample_data[0][start_col]);
shoaib_ahmed 0:791a779d6220 4398 tmp1 = GETJSAMPLE(sample_data[1][start_col]);
shoaib_ahmed 0:791a779d6220 4399
shoaib_ahmed 0:791a779d6220 4400 /* Apply unsigned->signed conversion. */
shoaib_ahmed 0:791a779d6220 4401 data[DCTSIZE*0] = (tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 5;
shoaib_ahmed 0:791a779d6220 4402
shoaib_ahmed 0:791a779d6220 4403 /* Odd part */
shoaib_ahmed 0:791a779d6220 4404
shoaib_ahmed 0:791a779d6220 4405 data[DCTSIZE*1] = (tmp0 - tmp1) << 5;
shoaib_ahmed 0:791a779d6220 4406 }
shoaib_ahmed 0:791a779d6220 4407
shoaib_ahmed 0:791a779d6220 4408 #endif /* DCT_SCALING_SUPPORTED */
shoaib_ahmed 0:791a779d6220 4409 #endif /* DCT_ISLOW_SUPPORTED */