Final 350 project
Dependencies: uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed
includes/jidctint.c@0:791a779d6220, 2017-07-31 (annotated)
- Committer:
- shoaib_ahmed
- Date:
- Mon Jul 31 09:16:35 2017 +0000
- Revision:
- 0:791a779d6220
final project;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shoaib_ahmed | 0:791a779d6220 | 1 | /* |
shoaib_ahmed | 0:791a779d6220 | 2 | * jidctint.c |
shoaib_ahmed | 0:791a779d6220 | 3 | * |
shoaib_ahmed | 0:791a779d6220 | 4 | * Copyright (C) 1991-1998, Thomas G. Lane. |
shoaib_ahmed | 0:791a779d6220 | 5 | * Modification developed 2002-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 | * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine |
shoaib_ahmed | 0:791a779d6220 | 11 | * must also perform dequantization of the input coefficients. |
shoaib_ahmed | 0:791a779d6220 | 12 | * |
shoaib_ahmed | 0:791a779d6220 | 13 | * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT |
shoaib_ahmed | 0:791a779d6220 | 14 | * on each row (or vice versa, but it's more convenient to emit a row at |
shoaib_ahmed | 0:791a779d6220 | 15 | * a time). Direct algorithms are also available, but they are much more |
shoaib_ahmed | 0:791a779d6220 | 16 | * complex and seem not to be any faster when reduced to code. |
shoaib_ahmed | 0:791a779d6220 | 17 | * |
shoaib_ahmed | 0:791a779d6220 | 18 | * This implementation is based on an algorithm described in |
shoaib_ahmed | 0:791a779d6220 | 19 | * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT |
shoaib_ahmed | 0:791a779d6220 | 20 | * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, |
shoaib_ahmed | 0:791a779d6220 | 21 | * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. |
shoaib_ahmed | 0:791a779d6220 | 22 | * The primary algorithm described there uses 11 multiplies and 29 adds. |
shoaib_ahmed | 0:791a779d6220 | 23 | * We use their alternate method with 12 multiplies and 32 adds. |
shoaib_ahmed | 0:791a779d6220 | 24 | * The advantage of this method is that no data path contains more than one |
shoaib_ahmed | 0:791a779d6220 | 25 | * multiplication; this allows a very simple and accurate implementation in |
shoaib_ahmed | 0:791a779d6220 | 26 | * scaled fixed-point arithmetic, with a minimal number of shifts. |
shoaib_ahmed | 0:791a779d6220 | 27 | * |
shoaib_ahmed | 0:791a779d6220 | 28 | * We also provide IDCT routines with various output sample block sizes for |
shoaib_ahmed | 0:791a779d6220 | 29 | * direct resolution reduction or enlargement and for direct resolving the |
shoaib_ahmed | 0:791a779d6220 | 30 | * common 2x1 and 1x2 subsampling cases without additional resampling: NxN |
shoaib_ahmed | 0:791a779d6220 | 31 | * (N=1...16), 2NxN, and Nx2N (N=1...8) pixels for one 8x8 input DCT block. |
shoaib_ahmed | 0:791a779d6220 | 32 | * |
shoaib_ahmed | 0:791a779d6220 | 33 | * For N<8 we simply take the corresponding low-frequency coefficients of |
shoaib_ahmed | 0:791a779d6220 | 34 | * the 8x8 input DCT block and apply an NxN point IDCT on the sub-block |
shoaib_ahmed | 0:791a779d6220 | 35 | * to yield the downscaled outputs. |
shoaib_ahmed | 0:791a779d6220 | 36 | * This can be seen as direct low-pass downsampling from the DCT domain |
shoaib_ahmed | 0:791a779d6220 | 37 | * point of view rather than the usual spatial domain point of view, |
shoaib_ahmed | 0:791a779d6220 | 38 | * yielding significant computational savings and results at least |
shoaib_ahmed | 0:791a779d6220 | 39 | * as good as common bilinear (averaging) spatial downsampling. |
shoaib_ahmed | 0:791a779d6220 | 40 | * |
shoaib_ahmed | 0:791a779d6220 | 41 | * For N>8 we apply a partial NxN IDCT on the 8 input coefficients as |
shoaib_ahmed | 0:791a779d6220 | 42 | * lower frequencies and higher frequencies assumed to be zero. |
shoaib_ahmed | 0:791a779d6220 | 43 | * It turns out that the computational effort is similar to the 8x8 IDCT |
shoaib_ahmed | 0:791a779d6220 | 44 | * regarding the output size. |
shoaib_ahmed | 0:791a779d6220 | 45 | * Furthermore, the scaling and descaling is the same for all IDCT sizes. |
shoaib_ahmed | 0:791a779d6220 | 46 | * |
shoaib_ahmed | 0:791a779d6220 | 47 | * CAUTION: We rely on the FIX() macro except for the N=1,2,4,8 cases |
shoaib_ahmed | 0:791a779d6220 | 48 | * since there would be too many additional constants to pre-calculate. |
shoaib_ahmed | 0:791a779d6220 | 49 | */ |
shoaib_ahmed | 0:791a779d6220 | 50 | |
shoaib_ahmed | 0:791a779d6220 | 51 | #define JPEG_INTERNALS |
shoaib_ahmed | 0:791a779d6220 | 52 | #include "jinclude.h" |
shoaib_ahmed | 0:791a779d6220 | 53 | #include "jpeglib.h" |
shoaib_ahmed | 0:791a779d6220 | 54 | #include "jdct.h" /* Private declarations for DCT subsystem */ |
shoaib_ahmed | 0:791a779d6220 | 55 | |
shoaib_ahmed | 0:791a779d6220 | 56 | #ifdef DCT_ISLOW_SUPPORTED |
shoaib_ahmed | 0:791a779d6220 | 57 | |
shoaib_ahmed | 0:791a779d6220 | 58 | |
shoaib_ahmed | 0:791a779d6220 | 59 | /* |
shoaib_ahmed | 0:791a779d6220 | 60 | * This module is specialized to the case DCTSIZE = 8. |
shoaib_ahmed | 0:791a779d6220 | 61 | */ |
shoaib_ahmed | 0:791a779d6220 | 62 | |
shoaib_ahmed | 0:791a779d6220 | 63 | #if DCTSIZE != 8 |
shoaib_ahmed | 0:791a779d6220 | 64 | Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ |
shoaib_ahmed | 0:791a779d6220 | 65 | #endif |
shoaib_ahmed | 0:791a779d6220 | 66 | |
shoaib_ahmed | 0:791a779d6220 | 67 | |
shoaib_ahmed | 0:791a779d6220 | 68 | /* |
shoaib_ahmed | 0:791a779d6220 | 69 | * The poop on this scaling stuff is as follows: |
shoaib_ahmed | 0:791a779d6220 | 70 | * |
shoaib_ahmed | 0:791a779d6220 | 71 | * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) |
shoaib_ahmed | 0:791a779d6220 | 72 | * larger than the true IDCT outputs. The final outputs are therefore |
shoaib_ahmed | 0:791a779d6220 | 73 | * a factor of N larger than desired; since N=8 this can be cured by |
shoaib_ahmed | 0:791a779d6220 | 74 | * a simple right shift at the end of the algorithm. The advantage of |
shoaib_ahmed | 0:791a779d6220 | 75 | * this arrangement is that we save two multiplications per 1-D IDCT, |
shoaib_ahmed | 0:791a779d6220 | 76 | * because the y0 and y4 inputs need not be divided by sqrt(N). |
shoaib_ahmed | 0:791a779d6220 | 77 | * |
shoaib_ahmed | 0:791a779d6220 | 78 | * We have to do addition and subtraction of the integer inputs, which |
shoaib_ahmed | 0:791a779d6220 | 79 | * is no problem, and multiplication by fractional constants, which is |
shoaib_ahmed | 0:791a779d6220 | 80 | * a problem to do in integer arithmetic. We multiply all the constants |
shoaib_ahmed | 0:791a779d6220 | 81 | * by CONST_SCALE and convert them to integer constants (thus retaining |
shoaib_ahmed | 0:791a779d6220 | 82 | * CONST_BITS bits of precision in the constants). After doing a |
shoaib_ahmed | 0:791a779d6220 | 83 | * multiplication we have to divide the product by CONST_SCALE, with proper |
shoaib_ahmed | 0:791a779d6220 | 84 | * rounding, to produce the correct output. This division can be done |
shoaib_ahmed | 0:791a779d6220 | 85 | * cheaply as a right shift of CONST_BITS bits. We postpone shifting |
shoaib_ahmed | 0:791a779d6220 | 86 | * as long as possible so that partial sums can be added together with |
shoaib_ahmed | 0:791a779d6220 | 87 | * full fractional precision. |
shoaib_ahmed | 0:791a779d6220 | 88 | * |
shoaib_ahmed | 0:791a779d6220 | 89 | * The outputs of the first pass are scaled up by PASS1_BITS bits so that |
shoaib_ahmed | 0:791a779d6220 | 90 | * they are represented to better-than-integral precision. These outputs |
shoaib_ahmed | 0:791a779d6220 | 91 | * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word |
shoaib_ahmed | 0:791a779d6220 | 92 | * with the recommended scaling. (To scale up 12-bit sample data further, an |
shoaib_ahmed | 0:791a779d6220 | 93 | * intermediate INT32 array would be needed.) |
shoaib_ahmed | 0:791a779d6220 | 94 | * |
shoaib_ahmed | 0:791a779d6220 | 95 | * To avoid overflow of the 32-bit intermediate results in pass 2, we must |
shoaib_ahmed | 0:791a779d6220 | 96 | * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis |
shoaib_ahmed | 0:791a779d6220 | 97 | * shows that the values given below are the most effective. |
shoaib_ahmed | 0:791a779d6220 | 98 | */ |
shoaib_ahmed | 0:791a779d6220 | 99 | |
shoaib_ahmed | 0:791a779d6220 | 100 | #if BITS_IN_JSAMPLE == 8 |
shoaib_ahmed | 0:791a779d6220 | 101 | #define CONST_BITS 13 |
shoaib_ahmed | 0:791a779d6220 | 102 | #define PASS1_BITS 2 |
shoaib_ahmed | 0:791a779d6220 | 103 | #else |
shoaib_ahmed | 0:791a779d6220 | 104 | #define CONST_BITS 13 |
shoaib_ahmed | 0:791a779d6220 | 105 | #define PASS1_BITS 1 /* lose a little precision to avoid overflow */ |
shoaib_ahmed | 0:791a779d6220 | 106 | #endif |
shoaib_ahmed | 0:791a779d6220 | 107 | |
shoaib_ahmed | 0:791a779d6220 | 108 | /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus |
shoaib_ahmed | 0:791a779d6220 | 109 | * causing a lot of useless floating-point operations at run time. |
shoaib_ahmed | 0:791a779d6220 | 110 | * To get around this we use the following pre-calculated constants. |
shoaib_ahmed | 0:791a779d6220 | 111 | * If you change CONST_BITS you may want to add appropriate values. |
shoaib_ahmed | 0:791a779d6220 | 112 | * (With a reasonable C compiler, you can just rely on the FIX() macro...) |
shoaib_ahmed | 0:791a779d6220 | 113 | */ |
shoaib_ahmed | 0:791a779d6220 | 114 | |
shoaib_ahmed | 0:791a779d6220 | 115 | #if CONST_BITS == 13 |
shoaib_ahmed | 0:791a779d6220 | 116 | #define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ |
shoaib_ahmed | 0:791a779d6220 | 117 | #define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ |
shoaib_ahmed | 0:791a779d6220 | 118 | #define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ |
shoaib_ahmed | 0:791a779d6220 | 119 | #define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ |
shoaib_ahmed | 0:791a779d6220 | 120 | #define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ |
shoaib_ahmed | 0:791a779d6220 | 121 | #define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ |
shoaib_ahmed | 0:791a779d6220 | 122 | #define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ |
shoaib_ahmed | 0:791a779d6220 | 123 | #define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ |
shoaib_ahmed | 0:791a779d6220 | 124 | #define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ |
shoaib_ahmed | 0:791a779d6220 | 125 | #define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ |
shoaib_ahmed | 0:791a779d6220 | 126 | #define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ |
shoaib_ahmed | 0:791a779d6220 | 127 | #define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ |
shoaib_ahmed | 0:791a779d6220 | 128 | #else |
shoaib_ahmed | 0:791a779d6220 | 129 | #define FIX_0_298631336 FIX(0.298631336) |
shoaib_ahmed | 0:791a779d6220 | 130 | #define FIX_0_390180644 FIX(0.390180644) |
shoaib_ahmed | 0:791a779d6220 | 131 | #define FIX_0_541196100 FIX(0.541196100) |
shoaib_ahmed | 0:791a779d6220 | 132 | #define FIX_0_765366865 FIX(0.765366865) |
shoaib_ahmed | 0:791a779d6220 | 133 | #define FIX_0_899976223 FIX(0.899976223) |
shoaib_ahmed | 0:791a779d6220 | 134 | #define FIX_1_175875602 FIX(1.175875602) |
shoaib_ahmed | 0:791a779d6220 | 135 | #define FIX_1_501321110 FIX(1.501321110) |
shoaib_ahmed | 0:791a779d6220 | 136 | #define FIX_1_847759065 FIX(1.847759065) |
shoaib_ahmed | 0:791a779d6220 | 137 | #define FIX_1_961570560 FIX(1.961570560) |
shoaib_ahmed | 0:791a779d6220 | 138 | #define FIX_2_053119869 FIX(2.053119869) |
shoaib_ahmed | 0:791a779d6220 | 139 | #define FIX_2_562915447 FIX(2.562915447) |
shoaib_ahmed | 0:791a779d6220 | 140 | #define FIX_3_072711026 FIX(3.072711026) |
shoaib_ahmed | 0:791a779d6220 | 141 | #endif |
shoaib_ahmed | 0:791a779d6220 | 142 | |
shoaib_ahmed | 0:791a779d6220 | 143 | |
shoaib_ahmed | 0:791a779d6220 | 144 | /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. |
shoaib_ahmed | 0:791a779d6220 | 145 | * For 8-bit samples with the recommended scaling, all the variable |
shoaib_ahmed | 0:791a779d6220 | 146 | * and constant values involved are no more than 16 bits wide, so a |
shoaib_ahmed | 0:791a779d6220 | 147 | * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. |
shoaib_ahmed | 0:791a779d6220 | 148 | * For 12-bit samples, a full 32-bit multiplication will be needed. |
shoaib_ahmed | 0:791a779d6220 | 149 | */ |
shoaib_ahmed | 0:791a779d6220 | 150 | |
shoaib_ahmed | 0:791a779d6220 | 151 | #if BITS_IN_JSAMPLE == 8 |
shoaib_ahmed | 0:791a779d6220 | 152 | #define MULTIPLY(var,const) MULTIPLY16C16(var,const) |
shoaib_ahmed | 0:791a779d6220 | 153 | #else |
shoaib_ahmed | 0:791a779d6220 | 154 | #define MULTIPLY(var,const) ((var) * (const)) |
shoaib_ahmed | 0:791a779d6220 | 155 | #endif |
shoaib_ahmed | 0:791a779d6220 | 156 | |
shoaib_ahmed | 0:791a779d6220 | 157 | |
shoaib_ahmed | 0:791a779d6220 | 158 | /* Dequantize a coefficient by multiplying it by the multiplier-table |
shoaib_ahmed | 0:791a779d6220 | 159 | * entry; produce an int result. In this module, both inputs and result |
shoaib_ahmed | 0:791a779d6220 | 160 | * are 16 bits or less, so either int or short multiply will work. |
shoaib_ahmed | 0:791a779d6220 | 161 | */ |
shoaib_ahmed | 0:791a779d6220 | 162 | |
shoaib_ahmed | 0:791a779d6220 | 163 | #define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) |
shoaib_ahmed | 0:791a779d6220 | 164 | |
shoaib_ahmed | 0:791a779d6220 | 165 | |
shoaib_ahmed | 0:791a779d6220 | 166 | /* |
shoaib_ahmed | 0:791a779d6220 | 167 | * Perform dequantization and inverse DCT on one block of coefficients. |
shoaib_ahmed | 0:791a779d6220 | 168 | * |
shoaib_ahmed | 0:791a779d6220 | 169 | * cK represents sqrt(2) * cos(K*pi/16). |
shoaib_ahmed | 0:791a779d6220 | 170 | */ |
shoaib_ahmed | 0:791a779d6220 | 171 | |
shoaib_ahmed | 0:791a779d6220 | 172 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 173 | jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 174 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 175 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 176 | { |
shoaib_ahmed | 0:791a779d6220 | 177 | INT32 tmp0, tmp1, tmp2, tmp3; |
shoaib_ahmed | 0:791a779d6220 | 178 | INT32 tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 179 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 180 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 181 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 182 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 183 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 184 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 185 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 186 | int workspace[DCTSIZE2]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 187 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 188 | |
shoaib_ahmed | 0:791a779d6220 | 189 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 190 | * Note results are scaled up by sqrt(8) compared to a true IDCT; |
shoaib_ahmed | 0:791a779d6220 | 191 | * furthermore, we scale the results by 2**PASS1_BITS. |
shoaib_ahmed | 0:791a779d6220 | 192 | */ |
shoaib_ahmed | 0:791a779d6220 | 193 | |
shoaib_ahmed | 0:791a779d6220 | 194 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 195 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 196 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 197 | for (ctr = DCTSIZE; ctr > 0; ctr--) { |
shoaib_ahmed | 0:791a779d6220 | 198 | /* Due to quantization, we will usually find that many of the input |
shoaib_ahmed | 0:791a779d6220 | 199 | * coefficients are zero, especially the AC terms. We can exploit this |
shoaib_ahmed | 0:791a779d6220 | 200 | * by short-circuiting the IDCT calculation for any column in which all |
shoaib_ahmed | 0:791a779d6220 | 201 | * the AC terms are zero. In that case each output is equal to the |
shoaib_ahmed | 0:791a779d6220 | 202 | * DC coefficient (with scale factor as needed). |
shoaib_ahmed | 0:791a779d6220 | 203 | * With typical images and quantization tables, half or more of the |
shoaib_ahmed | 0:791a779d6220 | 204 | * column DCT calculations can be simplified this way. |
shoaib_ahmed | 0:791a779d6220 | 205 | */ |
shoaib_ahmed | 0:791a779d6220 | 206 | |
shoaib_ahmed | 0:791a779d6220 | 207 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 208 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 209 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 210 | inptr[DCTSIZE*7] == 0) { |
shoaib_ahmed | 0:791a779d6220 | 211 | /* AC terms all zero */ |
shoaib_ahmed | 0:791a779d6220 | 212 | int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 213 | |
shoaib_ahmed | 0:791a779d6220 | 214 | wsptr[DCTSIZE*0] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 215 | wsptr[DCTSIZE*1] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 216 | wsptr[DCTSIZE*2] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 217 | wsptr[DCTSIZE*3] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 218 | wsptr[DCTSIZE*4] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 219 | wsptr[DCTSIZE*5] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 220 | wsptr[DCTSIZE*6] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 221 | wsptr[DCTSIZE*7] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 222 | |
shoaib_ahmed | 0:791a779d6220 | 223 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 224 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 225 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 226 | continue; |
shoaib_ahmed | 0:791a779d6220 | 227 | } |
shoaib_ahmed | 0:791a779d6220 | 228 | |
shoaib_ahmed | 0:791a779d6220 | 229 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 230 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 231 | */ |
shoaib_ahmed | 0:791a779d6220 | 232 | |
shoaib_ahmed | 0:791a779d6220 | 233 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 234 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 235 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 236 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 237 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 238 | z2 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 239 | |
shoaib_ahmed | 0:791a779d6220 | 240 | tmp0 = z2 + z3; |
shoaib_ahmed | 0:791a779d6220 | 241 | tmp1 = z2 - z3; |
shoaib_ahmed | 0:791a779d6220 | 242 | |
shoaib_ahmed | 0:791a779d6220 | 243 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 244 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 245 | |
shoaib_ahmed | 0:791a779d6220 | 246 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 247 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 248 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 249 | |
shoaib_ahmed | 0:791a779d6220 | 250 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 251 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 252 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 253 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 254 | |
shoaib_ahmed | 0:791a779d6220 | 255 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 256 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 257 | */ |
shoaib_ahmed | 0:791a779d6220 | 258 | |
shoaib_ahmed | 0:791a779d6220 | 259 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 260 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 261 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 262 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 263 | |
shoaib_ahmed | 0:791a779d6220 | 264 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 265 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 266 | |
shoaib_ahmed | 0:791a779d6220 | 267 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 268 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 269 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 270 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 271 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 272 | |
shoaib_ahmed | 0:791a779d6220 | 273 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 274 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 275 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 276 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 277 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 278 | |
shoaib_ahmed | 0:791a779d6220 | 279 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 280 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 281 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 282 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 283 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 284 | |
shoaib_ahmed | 0:791a779d6220 | 285 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 286 | |
shoaib_ahmed | 0:791a779d6220 | 287 | wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 288 | wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 289 | wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 290 | wsptr[DCTSIZE*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 291 | wsptr[DCTSIZE*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 292 | wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 293 | wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 294 | wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 295 | |
shoaib_ahmed | 0:791a779d6220 | 296 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 297 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 298 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 299 | } |
shoaib_ahmed | 0:791a779d6220 | 300 | |
shoaib_ahmed | 0:791a779d6220 | 301 | /* Pass 2: process rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 302 | * Note that we must descale the results by a factor of 8 == 2**3, |
shoaib_ahmed | 0:791a779d6220 | 303 | * and also undo the PASS1_BITS scaling. |
shoaib_ahmed | 0:791a779d6220 | 304 | */ |
shoaib_ahmed | 0:791a779d6220 | 305 | |
shoaib_ahmed | 0:791a779d6220 | 306 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 307 | for (ctr = 0; ctr < DCTSIZE; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 308 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 309 | |
shoaib_ahmed | 0:791a779d6220 | 310 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 311 | z2 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 312 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 313 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 314 | |
shoaib_ahmed | 0:791a779d6220 | 315 | /* Rows of zeroes can be exploited in the same way as we did with columns. |
shoaib_ahmed | 0:791a779d6220 | 316 | * However, the column calculation has created many nonzero AC terms, so |
shoaib_ahmed | 0:791a779d6220 | 317 | * the simplification applies less often (typically 5% to 10% of the time). |
shoaib_ahmed | 0:791a779d6220 | 318 | * On machines with very fast multiplication, it's possible that the |
shoaib_ahmed | 0:791a779d6220 | 319 | * test takes more time than it's worth. In that case this section |
shoaib_ahmed | 0:791a779d6220 | 320 | * may be commented out. |
shoaib_ahmed | 0:791a779d6220 | 321 | */ |
shoaib_ahmed | 0:791a779d6220 | 322 | |
shoaib_ahmed | 0:791a779d6220 | 323 | #ifndef NO_ZERO_ROW_TEST |
shoaib_ahmed | 0:791a779d6220 | 324 | if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 325 | wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { |
shoaib_ahmed | 0:791a779d6220 | 326 | /* AC terms all zero */ |
shoaib_ahmed | 0:791a779d6220 | 327 | JSAMPLE dcval = range_limit[(int) RIGHT_SHIFT(z2, PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 328 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 329 | |
shoaib_ahmed | 0:791a779d6220 | 330 | outptr[0] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 331 | outptr[1] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 332 | outptr[2] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 333 | outptr[3] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 334 | outptr[4] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 335 | outptr[5] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 336 | outptr[6] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 337 | outptr[7] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 338 | |
shoaib_ahmed | 0:791a779d6220 | 339 | wsptr += DCTSIZE; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 340 | continue; |
shoaib_ahmed | 0:791a779d6220 | 341 | } |
shoaib_ahmed | 0:791a779d6220 | 342 | #endif |
shoaib_ahmed | 0:791a779d6220 | 343 | |
shoaib_ahmed | 0:791a779d6220 | 344 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 345 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 346 | */ |
shoaib_ahmed | 0:791a779d6220 | 347 | |
shoaib_ahmed | 0:791a779d6220 | 348 | z3 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 349 | |
shoaib_ahmed | 0:791a779d6220 | 350 | tmp0 = (z2 + z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 351 | tmp1 = (z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 352 | |
shoaib_ahmed | 0:791a779d6220 | 353 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 354 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 355 | |
shoaib_ahmed | 0:791a779d6220 | 356 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 357 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 358 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 359 | |
shoaib_ahmed | 0:791a779d6220 | 360 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 361 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 362 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 363 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 364 | |
shoaib_ahmed | 0:791a779d6220 | 365 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 366 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 367 | */ |
shoaib_ahmed | 0:791a779d6220 | 368 | |
shoaib_ahmed | 0:791a779d6220 | 369 | tmp0 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 370 | tmp1 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 371 | tmp2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 372 | tmp3 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 373 | |
shoaib_ahmed | 0:791a779d6220 | 374 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 375 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 376 | |
shoaib_ahmed | 0:791a779d6220 | 377 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 378 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 379 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 380 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 381 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 382 | |
shoaib_ahmed | 0:791a779d6220 | 383 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 384 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 385 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 386 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 387 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 388 | |
shoaib_ahmed | 0:791a779d6220 | 389 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 390 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 391 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 392 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 393 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 394 | |
shoaib_ahmed | 0:791a779d6220 | 395 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 396 | |
shoaib_ahmed | 0:791a779d6220 | 397 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 398 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 399 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 400 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 401 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 402 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 403 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 404 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 405 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 406 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 407 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 408 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 409 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 410 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 411 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 412 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 413 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 414 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 415 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 416 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 417 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 418 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 419 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 420 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 421 | |
shoaib_ahmed | 0:791a779d6220 | 422 | wsptr += DCTSIZE; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 423 | } |
shoaib_ahmed | 0:791a779d6220 | 424 | } |
shoaib_ahmed | 0:791a779d6220 | 425 | |
shoaib_ahmed | 0:791a779d6220 | 426 | #ifdef IDCT_SCALING_SUPPORTED |
shoaib_ahmed | 0:791a779d6220 | 427 | |
shoaib_ahmed | 0:791a779d6220 | 428 | |
shoaib_ahmed | 0:791a779d6220 | 429 | /* |
shoaib_ahmed | 0:791a779d6220 | 430 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 431 | * producing a 7x7 output block. |
shoaib_ahmed | 0:791a779d6220 | 432 | * |
shoaib_ahmed | 0:791a779d6220 | 433 | * Optimized algorithm with 12 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 434 | * cK represents sqrt(2) * cos(K*pi/14). |
shoaib_ahmed | 0:791a779d6220 | 435 | */ |
shoaib_ahmed | 0:791a779d6220 | 436 | |
shoaib_ahmed | 0:791a779d6220 | 437 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 438 | jpeg_idct_7x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 439 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 440 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 441 | { |
shoaib_ahmed | 0:791a779d6220 | 442 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 443 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 444 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 445 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 446 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 447 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 448 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 449 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 450 | int workspace[7*7]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 451 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 452 | |
shoaib_ahmed | 0:791a779d6220 | 453 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 454 | |
shoaib_ahmed | 0:791a779d6220 | 455 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 456 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 457 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 458 | for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 459 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 460 | |
shoaib_ahmed | 0:791a779d6220 | 461 | tmp13 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 462 | tmp13 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 463 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 464 | tmp13 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 465 | |
shoaib_ahmed | 0:791a779d6220 | 466 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 467 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 468 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 469 | |
shoaib_ahmed | 0:791a779d6220 | 470 | tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 471 | tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 472 | tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 473 | tmp0 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 474 | z2 -= tmp0; |
shoaib_ahmed | 0:791a779d6220 | 475 | tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 476 | tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 477 | tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 478 | tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 479 | |
shoaib_ahmed | 0:791a779d6220 | 480 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 481 | |
shoaib_ahmed | 0:791a779d6220 | 482 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 483 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 484 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 485 | |
shoaib_ahmed | 0:791a779d6220 | 486 | tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 487 | tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 488 | tmp0 = tmp1 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 489 | tmp1 += tmp2; |
shoaib_ahmed | 0:791a779d6220 | 490 | tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
shoaib_ahmed | 0:791a779d6220 | 491 | tmp1 += tmp2; |
shoaib_ahmed | 0:791a779d6220 | 492 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 493 | tmp0 += z2; |
shoaib_ahmed | 0:791a779d6220 | 494 | tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 495 | |
shoaib_ahmed | 0:791a779d6220 | 496 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 497 | |
shoaib_ahmed | 0:791a779d6220 | 498 | wsptr[7*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 499 | wsptr[7*6] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 500 | wsptr[7*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 501 | wsptr[7*5] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 502 | wsptr[7*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 503 | wsptr[7*4] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 504 | wsptr[7*3] = (int) RIGHT_SHIFT(tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 505 | } |
shoaib_ahmed | 0:791a779d6220 | 506 | |
shoaib_ahmed | 0:791a779d6220 | 507 | /* Pass 2: process 7 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 508 | |
shoaib_ahmed | 0:791a779d6220 | 509 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 510 | for (ctr = 0; ctr < 7; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 511 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 512 | |
shoaib_ahmed | 0:791a779d6220 | 513 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 514 | |
shoaib_ahmed | 0:791a779d6220 | 515 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 516 | tmp13 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 517 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 518 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 519 | tmp13 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 520 | |
shoaib_ahmed | 0:791a779d6220 | 521 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 522 | z2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 523 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 524 | |
shoaib_ahmed | 0:791a779d6220 | 525 | tmp10 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 526 | tmp12 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 527 | tmp11 = tmp10 + tmp12 + tmp13 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 528 | tmp0 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 529 | z2 -= tmp0; |
shoaib_ahmed | 0:791a779d6220 | 530 | tmp0 = MULTIPLY(tmp0, FIX(1.274162392)) + tmp13; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 531 | tmp10 += tmp0 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 532 | tmp12 += tmp0 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 533 | tmp13 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 534 | |
shoaib_ahmed | 0:791a779d6220 | 535 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 536 | |
shoaib_ahmed | 0:791a779d6220 | 537 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 538 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 539 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 540 | |
shoaib_ahmed | 0:791a779d6220 | 541 | tmp1 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 542 | tmp2 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 543 | tmp0 = tmp1 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 544 | tmp1 += tmp2; |
shoaib_ahmed | 0:791a779d6220 | 545 | tmp2 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
shoaib_ahmed | 0:791a779d6220 | 546 | tmp1 += tmp2; |
shoaib_ahmed | 0:791a779d6220 | 547 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 548 | tmp0 += z2; |
shoaib_ahmed | 0:791a779d6220 | 549 | tmp2 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 550 | |
shoaib_ahmed | 0:791a779d6220 | 551 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 552 | |
shoaib_ahmed | 0:791a779d6220 | 553 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 554 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 555 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 556 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 557 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 558 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 559 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 560 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 561 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 562 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 563 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 564 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 565 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 566 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 567 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 568 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 569 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 570 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 571 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13, |
shoaib_ahmed | 0:791a779d6220 | 572 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 573 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 574 | |
shoaib_ahmed | 0:791a779d6220 | 575 | wsptr += 7; /* advance pointer to next row */ |
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 dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 582 | * producing a reduced-size 6x6 output block. |
shoaib_ahmed | 0:791a779d6220 | 583 | * |
shoaib_ahmed | 0:791a779d6220 | 584 | * Optimized algorithm with 3 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 585 | * cK represents sqrt(2) * cos(K*pi/12). |
shoaib_ahmed | 0:791a779d6220 | 586 | */ |
shoaib_ahmed | 0:791a779d6220 | 587 | |
shoaib_ahmed | 0:791a779d6220 | 588 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 589 | jpeg_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 590 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 591 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 592 | { |
shoaib_ahmed | 0:791a779d6220 | 593 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 594 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 595 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 596 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 597 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 598 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 599 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 600 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 601 | int workspace[6*6]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 602 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 603 | |
shoaib_ahmed | 0:791a779d6220 | 604 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 605 | |
shoaib_ahmed | 0:791a779d6220 | 606 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 607 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 608 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 609 | for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 610 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 611 | |
shoaib_ahmed | 0:791a779d6220 | 612 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 613 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 614 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 615 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 616 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 617 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 618 | tmp1 = tmp0 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 619 | tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 620 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 621 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 622 | tmp10 = tmp1 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 623 | tmp12 = tmp1 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 624 | |
shoaib_ahmed | 0:791a779d6220 | 625 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 626 | |
shoaib_ahmed | 0:791a779d6220 | 627 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 628 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 629 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 630 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 631 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 632 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 633 | tmp1 = (z1 - z2 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 634 | |
shoaib_ahmed | 0:791a779d6220 | 635 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 636 | |
shoaib_ahmed | 0:791a779d6220 | 637 | wsptr[6*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 638 | wsptr[6*5] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 639 | wsptr[6*1] = (int) (tmp11 + tmp1); |
shoaib_ahmed | 0:791a779d6220 | 640 | wsptr[6*4] = (int) (tmp11 - tmp1); |
shoaib_ahmed | 0:791a779d6220 | 641 | wsptr[6*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 642 | wsptr[6*3] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 643 | } |
shoaib_ahmed | 0:791a779d6220 | 644 | |
shoaib_ahmed | 0:791a779d6220 | 645 | /* Pass 2: process 6 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 646 | |
shoaib_ahmed | 0:791a779d6220 | 647 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 648 | for (ctr = 0; ctr < 6; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 649 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 650 | |
shoaib_ahmed | 0:791a779d6220 | 651 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 652 | |
shoaib_ahmed | 0:791a779d6220 | 653 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 654 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 655 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 656 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 657 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 658 | tmp2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 659 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 660 | tmp1 = tmp0 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 661 | tmp11 = tmp0 - tmp10 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 662 | tmp10 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 663 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 664 | tmp10 = tmp1 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 665 | tmp12 = tmp1 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 666 | |
shoaib_ahmed | 0:791a779d6220 | 667 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 668 | |
shoaib_ahmed | 0:791a779d6220 | 669 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 670 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 671 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 672 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 673 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 674 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 675 | tmp1 = (z1 - z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 676 | |
shoaib_ahmed | 0:791a779d6220 | 677 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 678 | |
shoaib_ahmed | 0:791a779d6220 | 679 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 680 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 681 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 682 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 683 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 684 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 685 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 686 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 687 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 688 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 689 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 690 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 691 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 692 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 693 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 694 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 695 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 696 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 697 | |
shoaib_ahmed | 0:791a779d6220 | 698 | wsptr += 6; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 699 | } |
shoaib_ahmed | 0:791a779d6220 | 700 | } |
shoaib_ahmed | 0:791a779d6220 | 701 | |
shoaib_ahmed | 0:791a779d6220 | 702 | |
shoaib_ahmed | 0:791a779d6220 | 703 | /* |
shoaib_ahmed | 0:791a779d6220 | 704 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 705 | * producing a reduced-size 5x5 output block. |
shoaib_ahmed | 0:791a779d6220 | 706 | * |
shoaib_ahmed | 0:791a779d6220 | 707 | * Optimized algorithm with 5 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 708 | * cK represents sqrt(2) * cos(K*pi/10). |
shoaib_ahmed | 0:791a779d6220 | 709 | */ |
shoaib_ahmed | 0:791a779d6220 | 710 | |
shoaib_ahmed | 0:791a779d6220 | 711 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 712 | jpeg_idct_5x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 713 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 714 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 715 | { |
shoaib_ahmed | 0:791a779d6220 | 716 | INT32 tmp0, tmp1, tmp10, tmp11, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 717 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 718 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 719 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 720 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 721 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 722 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 723 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 724 | int workspace[5*5]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 725 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 726 | |
shoaib_ahmed | 0:791a779d6220 | 727 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 728 | |
shoaib_ahmed | 0:791a779d6220 | 729 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 730 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 731 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 732 | for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 733 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 734 | |
shoaib_ahmed | 0:791a779d6220 | 735 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 736 | tmp12 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 737 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 738 | tmp12 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 739 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 740 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 741 | z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 742 | z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 743 | z3 = tmp12 + z2; |
shoaib_ahmed | 0:791a779d6220 | 744 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 745 | tmp11 = z3 - z1; |
shoaib_ahmed | 0:791a779d6220 | 746 | tmp12 -= z2 << 2; |
shoaib_ahmed | 0:791a779d6220 | 747 | |
shoaib_ahmed | 0:791a779d6220 | 748 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 749 | |
shoaib_ahmed | 0:791a779d6220 | 750 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 751 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 752 | |
shoaib_ahmed | 0:791a779d6220 | 753 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 754 | tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 755 | tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
shoaib_ahmed | 0:791a779d6220 | 756 | |
shoaib_ahmed | 0:791a779d6220 | 757 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 758 | |
shoaib_ahmed | 0:791a779d6220 | 759 | wsptr[5*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 760 | wsptr[5*4] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 761 | wsptr[5*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 762 | wsptr[5*3] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 763 | wsptr[5*2] = (int) RIGHT_SHIFT(tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 764 | } |
shoaib_ahmed | 0:791a779d6220 | 765 | |
shoaib_ahmed | 0:791a779d6220 | 766 | /* Pass 2: process 5 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 767 | |
shoaib_ahmed | 0:791a779d6220 | 768 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 769 | for (ctr = 0; ctr < 5; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 770 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 771 | |
shoaib_ahmed | 0:791a779d6220 | 772 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 773 | |
shoaib_ahmed | 0:791a779d6220 | 774 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 775 | tmp12 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 776 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 777 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 778 | tmp12 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 779 | tmp0 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 780 | tmp1 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 781 | z1 = MULTIPLY(tmp0 + tmp1, FIX(0.790569415)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 782 | z2 = MULTIPLY(tmp0 - tmp1, FIX(0.353553391)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 783 | z3 = tmp12 + z2; |
shoaib_ahmed | 0:791a779d6220 | 784 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 785 | tmp11 = z3 - z1; |
shoaib_ahmed | 0:791a779d6220 | 786 | tmp12 -= z2 << 2; |
shoaib_ahmed | 0:791a779d6220 | 787 | |
shoaib_ahmed | 0:791a779d6220 | 788 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 789 | |
shoaib_ahmed | 0:791a779d6220 | 790 | z2 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 791 | z3 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 792 | |
shoaib_ahmed | 0:791a779d6220 | 793 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 794 | tmp0 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 795 | tmp1 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
shoaib_ahmed | 0:791a779d6220 | 796 | |
shoaib_ahmed | 0:791a779d6220 | 797 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 798 | |
shoaib_ahmed | 0:791a779d6220 | 799 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 800 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 801 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 802 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 803 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 804 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 805 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 806 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 807 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 808 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 809 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 810 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 811 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12, |
shoaib_ahmed | 0:791a779d6220 | 812 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 813 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 814 | |
shoaib_ahmed | 0:791a779d6220 | 815 | wsptr += 5; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 816 | } |
shoaib_ahmed | 0:791a779d6220 | 817 | } |
shoaib_ahmed | 0:791a779d6220 | 818 | |
shoaib_ahmed | 0:791a779d6220 | 819 | |
shoaib_ahmed | 0:791a779d6220 | 820 | /* |
shoaib_ahmed | 0:791a779d6220 | 821 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 822 | * producing a reduced-size 4x4 output block. |
shoaib_ahmed | 0:791a779d6220 | 823 | * |
shoaib_ahmed | 0:791a779d6220 | 824 | * Optimized algorithm with 3 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 825 | * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. |
shoaib_ahmed | 0:791a779d6220 | 826 | */ |
shoaib_ahmed | 0:791a779d6220 | 827 | |
shoaib_ahmed | 0:791a779d6220 | 828 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 829 | jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 830 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 831 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 832 | { |
shoaib_ahmed | 0:791a779d6220 | 833 | INT32 tmp0, tmp2, tmp10, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 834 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 835 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 836 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 837 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 838 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 839 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 840 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 841 | int workspace[4*4]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 842 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 843 | |
shoaib_ahmed | 0:791a779d6220 | 844 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 845 | |
shoaib_ahmed | 0:791a779d6220 | 846 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 847 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 848 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 849 | for (ctr = 0; ctr < 4; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 850 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 851 | |
shoaib_ahmed | 0:791a779d6220 | 852 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 853 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 854 | |
shoaib_ahmed | 0:791a779d6220 | 855 | tmp10 = (tmp0 + tmp2) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 856 | tmp12 = (tmp0 - tmp2) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 857 | |
shoaib_ahmed | 0:791a779d6220 | 858 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 859 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 860 | |
shoaib_ahmed | 0:791a779d6220 | 861 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 862 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 863 | |
shoaib_ahmed | 0:791a779d6220 | 864 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 865 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 866 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 867 | tmp0 = RIGHT_SHIFT(z1 + MULTIPLY(z2, FIX_0_765366865), /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 868 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 869 | tmp2 = RIGHT_SHIFT(z1 - MULTIPLY(z3, FIX_1_847759065), /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 870 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 871 | |
shoaib_ahmed | 0:791a779d6220 | 872 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 873 | |
shoaib_ahmed | 0:791a779d6220 | 874 | wsptr[4*0] = (int) (tmp10 + tmp0); |
shoaib_ahmed | 0:791a779d6220 | 875 | wsptr[4*3] = (int) (tmp10 - tmp0); |
shoaib_ahmed | 0:791a779d6220 | 876 | wsptr[4*1] = (int) (tmp12 + tmp2); |
shoaib_ahmed | 0:791a779d6220 | 877 | wsptr[4*2] = (int) (tmp12 - tmp2); |
shoaib_ahmed | 0:791a779d6220 | 878 | } |
shoaib_ahmed | 0:791a779d6220 | 879 | |
shoaib_ahmed | 0:791a779d6220 | 880 | /* Pass 2: process 4 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 881 | |
shoaib_ahmed | 0:791a779d6220 | 882 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 883 | for (ctr = 0; ctr < 4; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 884 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 885 | |
shoaib_ahmed | 0:791a779d6220 | 886 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 887 | |
shoaib_ahmed | 0:791a779d6220 | 888 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 889 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 890 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 891 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 892 | tmp2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 893 | |
shoaib_ahmed | 0:791a779d6220 | 894 | tmp10 = (tmp0 + tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 895 | tmp12 = (tmp0 - tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 896 | |
shoaib_ahmed | 0:791a779d6220 | 897 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 898 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 899 | |
shoaib_ahmed | 0:791a779d6220 | 900 | z2 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 901 | z3 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 902 | |
shoaib_ahmed | 0:791a779d6220 | 903 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 904 | tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 905 | tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 906 | |
shoaib_ahmed | 0:791a779d6220 | 907 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 908 | |
shoaib_ahmed | 0:791a779d6220 | 909 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 910 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 911 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 912 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 913 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 914 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 915 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 916 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 917 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 918 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 919 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 920 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 921 | |
shoaib_ahmed | 0:791a779d6220 | 922 | wsptr += 4; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 923 | } |
shoaib_ahmed | 0:791a779d6220 | 924 | } |
shoaib_ahmed | 0:791a779d6220 | 925 | |
shoaib_ahmed | 0:791a779d6220 | 926 | |
shoaib_ahmed | 0:791a779d6220 | 927 | /* |
shoaib_ahmed | 0:791a779d6220 | 928 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 929 | * producing a reduced-size 3x3 output block. |
shoaib_ahmed | 0:791a779d6220 | 930 | * |
shoaib_ahmed | 0:791a779d6220 | 931 | * Optimized algorithm with 2 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 932 | * cK represents sqrt(2) * cos(K*pi/6). |
shoaib_ahmed | 0:791a779d6220 | 933 | */ |
shoaib_ahmed | 0:791a779d6220 | 934 | |
shoaib_ahmed | 0:791a779d6220 | 935 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 936 | jpeg_idct_3x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 937 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 938 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 939 | { |
shoaib_ahmed | 0:791a779d6220 | 940 | INT32 tmp0, tmp2, tmp10, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 941 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 942 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 943 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 944 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 945 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 946 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 947 | int workspace[3*3]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 948 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 949 | |
shoaib_ahmed | 0:791a779d6220 | 950 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 951 | |
shoaib_ahmed | 0:791a779d6220 | 952 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 953 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 954 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 955 | for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 956 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 957 | |
shoaib_ahmed | 0:791a779d6220 | 958 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 959 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 960 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 961 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 962 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 963 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 964 | tmp10 = tmp0 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 965 | tmp2 = tmp0 - tmp12 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 966 | |
shoaib_ahmed | 0:791a779d6220 | 967 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 968 | |
shoaib_ahmed | 0:791a779d6220 | 969 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 970 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 971 | |
shoaib_ahmed | 0:791a779d6220 | 972 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 973 | |
shoaib_ahmed | 0:791a779d6220 | 974 | wsptr[3*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 975 | wsptr[3*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 976 | wsptr[3*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 977 | } |
shoaib_ahmed | 0:791a779d6220 | 978 | |
shoaib_ahmed | 0:791a779d6220 | 979 | /* Pass 2: process 3 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 980 | |
shoaib_ahmed | 0:791a779d6220 | 981 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 982 | for (ctr = 0; ctr < 3; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 983 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 984 | |
shoaib_ahmed | 0:791a779d6220 | 985 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 986 | |
shoaib_ahmed | 0:791a779d6220 | 987 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 988 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 989 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 990 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 991 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 992 | tmp2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 993 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 994 | tmp10 = tmp0 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 995 | tmp2 = tmp0 - tmp12 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 996 | |
shoaib_ahmed | 0:791a779d6220 | 997 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 998 | |
shoaib_ahmed | 0:791a779d6220 | 999 | tmp12 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 1000 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1001 | |
shoaib_ahmed | 0:791a779d6220 | 1002 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1003 | |
shoaib_ahmed | 0:791a779d6220 | 1004 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 1005 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1006 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1007 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 1008 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1009 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1010 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2, |
shoaib_ahmed | 0:791a779d6220 | 1011 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1012 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1013 | |
shoaib_ahmed | 0:791a779d6220 | 1014 | wsptr += 3; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 1015 | } |
shoaib_ahmed | 0:791a779d6220 | 1016 | } |
shoaib_ahmed | 0:791a779d6220 | 1017 | |
shoaib_ahmed | 0:791a779d6220 | 1018 | |
shoaib_ahmed | 0:791a779d6220 | 1019 | /* |
shoaib_ahmed | 0:791a779d6220 | 1020 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1021 | * producing a reduced-size 2x2 output block. |
shoaib_ahmed | 0:791a779d6220 | 1022 | * |
shoaib_ahmed | 0:791a779d6220 | 1023 | * Multiplication-less algorithm. |
shoaib_ahmed | 0:791a779d6220 | 1024 | */ |
shoaib_ahmed | 0:791a779d6220 | 1025 | |
shoaib_ahmed | 0:791a779d6220 | 1026 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1027 | jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1028 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1029 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1030 | { |
shoaib_ahmed | 0:791a779d6220 | 1031 | DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; |
shoaib_ahmed | 0:791a779d6220 | 1032 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1033 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1034 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1035 | ISHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1036 | |
shoaib_ahmed | 0:791a779d6220 | 1037 | /* Pass 1: process columns from input. */ |
shoaib_ahmed | 0:791a779d6220 | 1038 | |
shoaib_ahmed | 0:791a779d6220 | 1039 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1040 | |
shoaib_ahmed | 0:791a779d6220 | 1041 | /* Column 0 */ |
shoaib_ahmed | 0:791a779d6220 | 1042 | tmp4 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1043 | tmp5 = DEQUANTIZE(coef_block[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1044 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1045 | tmp4 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); |
shoaib_ahmed | 0:791a779d6220 | 1046 | |
shoaib_ahmed | 0:791a779d6220 | 1047 | tmp0 = tmp4 + tmp5; |
shoaib_ahmed | 0:791a779d6220 | 1048 | tmp2 = tmp4 - tmp5; |
shoaib_ahmed | 0:791a779d6220 | 1049 | |
shoaib_ahmed | 0:791a779d6220 | 1050 | /* Column 1 */ |
shoaib_ahmed | 0:791a779d6220 | 1051 | tmp4 = DEQUANTIZE(coef_block[DCTSIZE*0+1], quantptr[DCTSIZE*0+1]); |
shoaib_ahmed | 0:791a779d6220 | 1052 | tmp5 = DEQUANTIZE(coef_block[DCTSIZE*1+1], quantptr[DCTSIZE*1+1]); |
shoaib_ahmed | 0:791a779d6220 | 1053 | |
shoaib_ahmed | 0:791a779d6220 | 1054 | tmp1 = tmp4 + tmp5; |
shoaib_ahmed | 0:791a779d6220 | 1055 | tmp3 = tmp4 - tmp5; |
shoaib_ahmed | 0:791a779d6220 | 1056 | |
shoaib_ahmed | 0:791a779d6220 | 1057 | /* Pass 2: process 2 rows, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 1058 | |
shoaib_ahmed | 0:791a779d6220 | 1059 | /* Row 0 */ |
shoaib_ahmed | 0:791a779d6220 | 1060 | outptr = output_buf[0] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1061 | |
shoaib_ahmed | 0:791a779d6220 | 1062 | outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1063 | outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1064 | |
shoaib_ahmed | 0:791a779d6220 | 1065 | /* Row 1 */ |
shoaib_ahmed | 0:791a779d6220 | 1066 | outptr = output_buf[1] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1067 | |
shoaib_ahmed | 0:791a779d6220 | 1068 | outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp3, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1069 | outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp3, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1070 | } |
shoaib_ahmed | 0:791a779d6220 | 1071 | |
shoaib_ahmed | 0:791a779d6220 | 1072 | |
shoaib_ahmed | 0:791a779d6220 | 1073 | /* |
shoaib_ahmed | 0:791a779d6220 | 1074 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1075 | * producing a reduced-size 1x1 output block. |
shoaib_ahmed | 0:791a779d6220 | 1076 | * |
shoaib_ahmed | 0:791a779d6220 | 1077 | * We hardly need an inverse DCT routine for this: just take the |
shoaib_ahmed | 0:791a779d6220 | 1078 | * average pixel value, which is one-eighth of the DC coefficient. |
shoaib_ahmed | 0:791a779d6220 | 1079 | */ |
shoaib_ahmed | 0:791a779d6220 | 1080 | |
shoaib_ahmed | 0:791a779d6220 | 1081 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1082 | jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1083 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1084 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1085 | { |
shoaib_ahmed | 0:791a779d6220 | 1086 | DCTELEM dcval; |
shoaib_ahmed | 0:791a779d6220 | 1087 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1088 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1089 | ISHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1090 | |
shoaib_ahmed | 0:791a779d6220 | 1091 | /* 1x1 is trivial: just take the DC coefficient divided by 8. */ |
shoaib_ahmed | 0:791a779d6220 | 1092 | |
shoaib_ahmed | 0:791a779d6220 | 1093 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1094 | |
shoaib_ahmed | 0:791a779d6220 | 1095 | dcval = DEQUANTIZE(coef_block[0], quantptr[0]); |
shoaib_ahmed | 0:791a779d6220 | 1096 | /* Add range center and fudge factor for descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1097 | dcval += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); |
shoaib_ahmed | 0:791a779d6220 | 1098 | |
shoaib_ahmed | 0:791a779d6220 | 1099 | output_buf[0][output_col] = |
shoaib_ahmed | 0:791a779d6220 | 1100 | range_limit[(int) IRIGHT_SHIFT(dcval, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1101 | } |
shoaib_ahmed | 0:791a779d6220 | 1102 | |
shoaib_ahmed | 0:791a779d6220 | 1103 | |
shoaib_ahmed | 0:791a779d6220 | 1104 | /* |
shoaib_ahmed | 0:791a779d6220 | 1105 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1106 | * producing a 9x9 output block. |
shoaib_ahmed | 0:791a779d6220 | 1107 | * |
shoaib_ahmed | 0:791a779d6220 | 1108 | * Optimized algorithm with 10 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 1109 | * cK represents sqrt(2) * cos(K*pi/18). |
shoaib_ahmed | 0:791a779d6220 | 1110 | */ |
shoaib_ahmed | 0:791a779d6220 | 1111 | |
shoaib_ahmed | 0:791a779d6220 | 1112 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1113 | jpeg_idct_9x9 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1114 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1115 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1116 | { |
shoaib_ahmed | 0:791a779d6220 | 1117 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1118 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 1119 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 1120 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1121 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 1122 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1123 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1124 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 1125 | int workspace[8*9]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 1126 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1127 | |
shoaib_ahmed | 0:791a779d6220 | 1128 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 1129 | |
shoaib_ahmed | 0:791a779d6220 | 1130 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 1131 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1132 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1133 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 1134 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1135 | |
shoaib_ahmed | 0:791a779d6220 | 1136 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1137 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1138 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 1139 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 1140 | |
shoaib_ahmed | 0:791a779d6220 | 1141 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 1142 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 1143 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 1144 | |
shoaib_ahmed | 0:791a779d6220 | 1145 | tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1146 | tmp1 = tmp0 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1147 | tmp2 = tmp0 - tmp3 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1148 | |
shoaib_ahmed | 0:791a779d6220 | 1149 | tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1150 | tmp11 = tmp2 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 1151 | tmp14 = tmp2 - tmp0 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 1152 | |
shoaib_ahmed | 0:791a779d6220 | 1153 | tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1154 | tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1155 | tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1156 | |
shoaib_ahmed | 0:791a779d6220 | 1157 | tmp10 = tmp1 + tmp0 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1158 | tmp12 = tmp1 - tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 1159 | tmp13 = tmp1 - tmp2 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1160 | |
shoaib_ahmed | 0:791a779d6220 | 1161 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1162 | |
shoaib_ahmed | 0:791a779d6220 | 1163 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1164 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 1165 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 1166 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 1167 | |
shoaib_ahmed | 0:791a779d6220 | 1168 | z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1169 | |
shoaib_ahmed | 0:791a779d6220 | 1170 | tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1171 | tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1172 | tmp0 = tmp2 + tmp3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1173 | tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1174 | tmp2 += z2 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 1175 | tmp3 += z2 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 1176 | tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1177 | |
shoaib_ahmed | 0:791a779d6220 | 1178 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1179 | |
shoaib_ahmed | 0:791a779d6220 | 1180 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1181 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1182 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp11 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1183 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp11 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1184 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1185 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1186 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp13 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1187 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp13 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1188 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1189 | } |
shoaib_ahmed | 0:791a779d6220 | 1190 | |
shoaib_ahmed | 0:791a779d6220 | 1191 | /* Pass 2: process 9 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 1192 | |
shoaib_ahmed | 0:791a779d6220 | 1193 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1194 | for (ctr = 0; ctr < 9; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 1195 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1196 | |
shoaib_ahmed | 0:791a779d6220 | 1197 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1198 | |
shoaib_ahmed | 0:791a779d6220 | 1199 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1200 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 1201 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 1202 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 1203 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1204 | |
shoaib_ahmed | 0:791a779d6220 | 1205 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 1206 | z2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 1207 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 1208 | |
shoaib_ahmed | 0:791a779d6220 | 1209 | tmp3 = MULTIPLY(z3, FIX(0.707106781)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1210 | tmp1 = tmp0 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1211 | tmp2 = tmp0 - tmp3 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1212 | |
shoaib_ahmed | 0:791a779d6220 | 1213 | tmp0 = MULTIPLY(z1 - z2, FIX(0.707106781)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1214 | tmp11 = tmp2 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 1215 | tmp14 = tmp2 - tmp0 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 1216 | |
shoaib_ahmed | 0:791a779d6220 | 1217 | tmp0 = MULTIPLY(z1 + z2, FIX(1.328926049)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1218 | tmp2 = MULTIPLY(z1, FIX(1.083350441)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1219 | tmp3 = MULTIPLY(z2, FIX(0.245575608)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1220 | |
shoaib_ahmed | 0:791a779d6220 | 1221 | tmp10 = tmp1 + tmp0 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1222 | tmp12 = tmp1 - tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 1223 | tmp13 = tmp1 - tmp2 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 1224 | |
shoaib_ahmed | 0:791a779d6220 | 1225 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1226 | |
shoaib_ahmed | 0:791a779d6220 | 1227 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 1228 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 1229 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 1230 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 1231 | |
shoaib_ahmed | 0:791a779d6220 | 1232 | z2 = MULTIPLY(z2, - FIX(1.224744871)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1233 | |
shoaib_ahmed | 0:791a779d6220 | 1234 | tmp2 = MULTIPLY(z1 + z3, FIX(0.909038955)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1235 | tmp3 = MULTIPLY(z1 + z4, FIX(0.483689525)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1236 | tmp0 = tmp2 + tmp3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1237 | tmp1 = MULTIPLY(z3 - z4, FIX(1.392728481)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1238 | tmp2 += z2 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 1239 | tmp3 += z2 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 1240 | tmp1 = MULTIPLY(z1 - z3 - z4, FIX(1.224744871)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1241 | |
shoaib_ahmed | 0:791a779d6220 | 1242 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1243 | |
shoaib_ahmed | 0:791a779d6220 | 1244 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 1245 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1246 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1247 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 1248 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1249 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1250 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 1251 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1252 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1253 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 1254 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1255 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1256 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 1257 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1258 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1259 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 1260 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1261 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1262 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 1263 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1264 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1265 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 1266 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1267 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1268 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1269 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1270 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1271 | |
shoaib_ahmed | 0:791a779d6220 | 1272 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 1273 | } |
shoaib_ahmed | 0:791a779d6220 | 1274 | } |
shoaib_ahmed | 0:791a779d6220 | 1275 | |
shoaib_ahmed | 0:791a779d6220 | 1276 | |
shoaib_ahmed | 0:791a779d6220 | 1277 | /* |
shoaib_ahmed | 0:791a779d6220 | 1278 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1279 | * producing a 10x10 output block. |
shoaib_ahmed | 0:791a779d6220 | 1280 | * |
shoaib_ahmed | 0:791a779d6220 | 1281 | * Optimized algorithm with 12 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 1282 | * cK represents sqrt(2) * cos(K*pi/20). |
shoaib_ahmed | 0:791a779d6220 | 1283 | */ |
shoaib_ahmed | 0:791a779d6220 | 1284 | |
shoaib_ahmed | 0:791a779d6220 | 1285 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1286 | jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1287 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1288 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1289 | { |
shoaib_ahmed | 0:791a779d6220 | 1290 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1291 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24; |
shoaib_ahmed | 0:791a779d6220 | 1292 | INT32 z1, z2, z3, z4, z5; |
shoaib_ahmed | 0:791a779d6220 | 1293 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 1294 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1295 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 1296 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1297 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1298 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 1299 | int workspace[8*10]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 1300 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1301 | |
shoaib_ahmed | 0:791a779d6220 | 1302 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 1303 | |
shoaib_ahmed | 0:791a779d6220 | 1304 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 1305 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1306 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1307 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 1308 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1309 | |
shoaib_ahmed | 0:791a779d6220 | 1310 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1311 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1312 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 1313 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 1314 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 1315 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1316 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1317 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 1318 | tmp11 = z3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1319 | |
shoaib_ahmed | 0:791a779d6220 | 1320 | tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 1321 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1322 | |
shoaib_ahmed | 0:791a779d6220 | 1323 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 1324 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 1325 | |
shoaib_ahmed | 0:791a779d6220 | 1326 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1327 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1328 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1329 | |
shoaib_ahmed | 0:791a779d6220 | 1330 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1331 | tmp24 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1332 | tmp21 = tmp11 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 1333 | tmp23 = tmp11 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 1334 | |
shoaib_ahmed | 0:791a779d6220 | 1335 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1336 | |
shoaib_ahmed | 0:791a779d6220 | 1337 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1338 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 1339 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 1340 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 1341 | |
shoaib_ahmed | 0:791a779d6220 | 1342 | tmp11 = z2 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1343 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 1344 | |
shoaib_ahmed | 0:791a779d6220 | 1345 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1346 | z5 = z3 << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1347 | |
shoaib_ahmed | 0:791a779d6220 | 1348 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1349 | z4 = z5 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1350 | |
shoaib_ahmed | 0:791a779d6220 | 1351 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1352 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1353 | |
shoaib_ahmed | 0:791a779d6220 | 1354 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1355 | z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
shoaib_ahmed | 0:791a779d6220 | 1356 | |
shoaib_ahmed | 0:791a779d6220 | 1357 | tmp12 = (z1 - tmp13 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1358 | |
shoaib_ahmed | 0:791a779d6220 | 1359 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1360 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1361 | |
shoaib_ahmed | 0:791a779d6220 | 1362 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1363 | |
shoaib_ahmed | 0:791a779d6220 | 1364 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1365 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1366 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1367 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1368 | wsptr[8*2] = (int) (tmp22 + tmp12); |
shoaib_ahmed | 0:791a779d6220 | 1369 | wsptr[8*7] = (int) (tmp22 - tmp12); |
shoaib_ahmed | 0:791a779d6220 | 1370 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1371 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1372 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1373 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1374 | } |
shoaib_ahmed | 0:791a779d6220 | 1375 | |
shoaib_ahmed | 0:791a779d6220 | 1376 | /* Pass 2: process 10 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 1377 | |
shoaib_ahmed | 0:791a779d6220 | 1378 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1379 | for (ctr = 0; ctr < 10; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 1380 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1381 | |
shoaib_ahmed | 0:791a779d6220 | 1382 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1383 | |
shoaib_ahmed | 0:791a779d6220 | 1384 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1385 | z3 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 1386 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 1387 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 1388 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1389 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 1390 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1391 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1392 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 1393 | tmp11 = z3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1394 | |
shoaib_ahmed | 0:791a779d6220 | 1395 | tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 1396 | |
shoaib_ahmed | 0:791a779d6220 | 1397 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 1398 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 1399 | |
shoaib_ahmed | 0:791a779d6220 | 1400 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1401 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1402 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1403 | |
shoaib_ahmed | 0:791a779d6220 | 1404 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1405 | tmp24 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1406 | tmp21 = tmp11 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 1407 | tmp23 = tmp11 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 1408 | |
shoaib_ahmed | 0:791a779d6220 | 1409 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1410 | |
shoaib_ahmed | 0:791a779d6220 | 1411 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 1412 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 1413 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 1414 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1415 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 1416 | |
shoaib_ahmed | 0:791a779d6220 | 1417 | tmp11 = z2 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1418 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 1419 | |
shoaib_ahmed | 0:791a779d6220 | 1420 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1421 | |
shoaib_ahmed | 0:791a779d6220 | 1422 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1423 | z4 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1424 | |
shoaib_ahmed | 0:791a779d6220 | 1425 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1426 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1427 | |
shoaib_ahmed | 0:791a779d6220 | 1428 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1429 | z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
shoaib_ahmed | 0:791a779d6220 | 1430 | |
shoaib_ahmed | 0:791a779d6220 | 1431 | tmp12 = ((z1 - tmp13) << CONST_BITS) - z3; |
shoaib_ahmed | 0:791a779d6220 | 1432 | |
shoaib_ahmed | 0:791a779d6220 | 1433 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1434 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1435 | |
shoaib_ahmed | 0:791a779d6220 | 1436 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1437 | |
shoaib_ahmed | 0:791a779d6220 | 1438 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1439 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1440 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1441 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1442 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1443 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1444 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1445 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1446 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1447 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1448 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1449 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1450 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1451 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1452 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1453 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1454 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1455 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1456 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1457 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1458 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1459 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1460 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1461 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1462 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1463 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1464 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1465 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1466 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1467 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1468 | |
shoaib_ahmed | 0:791a779d6220 | 1469 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 1470 | } |
shoaib_ahmed | 0:791a779d6220 | 1471 | } |
shoaib_ahmed | 0:791a779d6220 | 1472 | |
shoaib_ahmed | 0:791a779d6220 | 1473 | |
shoaib_ahmed | 0:791a779d6220 | 1474 | /* |
shoaib_ahmed | 0:791a779d6220 | 1475 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1476 | * producing a 11x11 output block. |
shoaib_ahmed | 0:791a779d6220 | 1477 | * |
shoaib_ahmed | 0:791a779d6220 | 1478 | * Optimized algorithm with 24 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 1479 | * cK represents sqrt(2) * cos(K*pi/22). |
shoaib_ahmed | 0:791a779d6220 | 1480 | */ |
shoaib_ahmed | 0:791a779d6220 | 1481 | |
shoaib_ahmed | 0:791a779d6220 | 1482 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1483 | jpeg_idct_11x11 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1484 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1485 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1486 | { |
shoaib_ahmed | 0:791a779d6220 | 1487 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1488 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
shoaib_ahmed | 0:791a779d6220 | 1489 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 1490 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 1491 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1492 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 1493 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1494 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1495 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 1496 | int workspace[8*11]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 1497 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1498 | |
shoaib_ahmed | 0:791a779d6220 | 1499 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 1500 | |
shoaib_ahmed | 0:791a779d6220 | 1501 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 1502 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1503 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1504 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 1505 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1506 | |
shoaib_ahmed | 0:791a779d6220 | 1507 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1508 | tmp10 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1509 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 1510 | tmp10 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 1511 | |
shoaib_ahmed | 0:791a779d6220 | 1512 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 1513 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 1514 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 1515 | |
shoaib_ahmed | 0:791a779d6220 | 1516 | tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1517 | tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1518 | z4 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 1519 | tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ |
shoaib_ahmed | 0:791a779d6220 | 1520 | z4 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 1521 | tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1522 | tmp21 = tmp20 + tmp23 + tmp25 - |
shoaib_ahmed | 0:791a779d6220 | 1523 | MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1524 | tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1525 | tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1526 | tmp24 += tmp25; |
shoaib_ahmed | 0:791a779d6220 | 1527 | tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 1528 | tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1529 | MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 1530 | tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 1531 | |
shoaib_ahmed | 0:791a779d6220 | 1532 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1533 | |
shoaib_ahmed | 0:791a779d6220 | 1534 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1535 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 1536 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 1537 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 1538 | |
shoaib_ahmed | 0:791a779d6220 | 1539 | tmp11 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 1540 | tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1541 | tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1542 | tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1543 | tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1544 | tmp10 = tmp11 + tmp12 + tmp13 - |
shoaib_ahmed | 0:791a779d6220 | 1545 | MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1546 | z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1547 | tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1548 | tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1549 | z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ |
shoaib_ahmed | 0:791a779d6220 | 1550 | tmp11 += z1; |
shoaib_ahmed | 0:791a779d6220 | 1551 | tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1552 | tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ |
shoaib_ahmed | 0:791a779d6220 | 1553 | MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1554 | MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1555 | |
shoaib_ahmed | 0:791a779d6220 | 1556 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1557 | |
shoaib_ahmed | 0:791a779d6220 | 1558 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1559 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1560 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1561 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1562 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1563 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1564 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1565 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1566 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1567 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1568 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1569 | } |
shoaib_ahmed | 0:791a779d6220 | 1570 | |
shoaib_ahmed | 0:791a779d6220 | 1571 | /* Pass 2: process 11 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 1572 | |
shoaib_ahmed | 0:791a779d6220 | 1573 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1574 | for (ctr = 0; ctr < 11; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 1575 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1576 | |
shoaib_ahmed | 0:791a779d6220 | 1577 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1578 | |
shoaib_ahmed | 0:791a779d6220 | 1579 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1580 | tmp10 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 1581 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 1582 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 1583 | tmp10 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1584 | |
shoaib_ahmed | 0:791a779d6220 | 1585 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 1586 | z2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 1587 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 1588 | |
shoaib_ahmed | 0:791a779d6220 | 1589 | tmp20 = MULTIPLY(z2 - z3, FIX(2.546640132)); /* c2+c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1590 | tmp23 = MULTIPLY(z2 - z1, FIX(0.430815045)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1591 | z4 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 1592 | tmp24 = MULTIPLY(z4, - FIX(1.155664402)); /* -(c2-c10) */ |
shoaib_ahmed | 0:791a779d6220 | 1593 | z4 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 1594 | tmp25 = tmp10 + MULTIPLY(z4, FIX(1.356927976)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1595 | tmp21 = tmp20 + tmp23 + tmp25 - |
shoaib_ahmed | 0:791a779d6220 | 1596 | MULTIPLY(z2, FIX(1.821790775)); /* c2+c4+c10-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1597 | tmp20 += tmp25 + MULTIPLY(z3, FIX(2.115825087)); /* c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1598 | tmp23 += tmp25 - MULTIPLY(z1, FIX(1.513598477)); /* c6+c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1599 | tmp24 += tmp25; |
shoaib_ahmed | 0:791a779d6220 | 1600 | tmp22 = tmp24 - MULTIPLY(z3, FIX(0.788749120)); /* c8+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 1601 | tmp24 += MULTIPLY(z2, FIX(1.944413522)) - /* c2+c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1602 | MULTIPLY(z1, FIX(1.390975730)); /* c4+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 1603 | tmp25 = tmp10 - MULTIPLY(z4, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 1604 | |
shoaib_ahmed | 0:791a779d6220 | 1605 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1606 | |
shoaib_ahmed | 0:791a779d6220 | 1607 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 1608 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 1609 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 1610 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 1611 | |
shoaib_ahmed | 0:791a779d6220 | 1612 | tmp11 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 1613 | tmp14 = MULTIPLY(tmp11 + z3 + z4, FIX(0.398430003)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1614 | tmp11 = MULTIPLY(tmp11, FIX(0.887983902)); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1615 | tmp12 = MULTIPLY(z1 + z3, FIX(0.670361295)); /* c5-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1616 | tmp13 = tmp14 + MULTIPLY(z1 + z4, FIX(0.366151574)); /* c7-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1617 | tmp10 = tmp11 + tmp12 + tmp13 - |
shoaib_ahmed | 0:791a779d6220 | 1618 | MULTIPLY(z1, FIX(0.923107866)); /* c7+c5+c3-c1-2*c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1619 | z1 = tmp14 - MULTIPLY(z2 + z3, FIX(1.163011579)); /* c7+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1620 | tmp11 += z1 + MULTIPLY(z2, FIX(2.073276588)); /* c1+c7+3*c9-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1621 | tmp12 += z1 - MULTIPLY(z3, FIX(1.192193623)); /* c3+c5-c7-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1622 | z1 = MULTIPLY(z2 + z4, - FIX(1.798248910)); /* -(c1+c9) */ |
shoaib_ahmed | 0:791a779d6220 | 1623 | tmp11 += z1; |
shoaib_ahmed | 0:791a779d6220 | 1624 | tmp13 += z1 + MULTIPLY(z4, FIX(2.102458632)); /* c1+c5+c9-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1625 | tmp14 += MULTIPLY(z2, - FIX(1.467221301)) + /* -(c5+c9) */ |
shoaib_ahmed | 0:791a779d6220 | 1626 | MULTIPLY(z3, FIX(1.001388905)) - /* c1-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1627 | MULTIPLY(z4, FIX(1.684843907)); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1628 | |
shoaib_ahmed | 0:791a779d6220 | 1629 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1630 | |
shoaib_ahmed | 0:791a779d6220 | 1631 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1632 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1633 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1634 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1635 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1636 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1637 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1638 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1639 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1640 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1641 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1642 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1643 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1644 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1645 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1646 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1647 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1648 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1649 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1650 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1651 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1652 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1653 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1654 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1655 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1656 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1657 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1658 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1659 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1660 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1661 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25, |
shoaib_ahmed | 0:791a779d6220 | 1662 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1663 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1664 | |
shoaib_ahmed | 0:791a779d6220 | 1665 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 1666 | } |
shoaib_ahmed | 0:791a779d6220 | 1667 | } |
shoaib_ahmed | 0:791a779d6220 | 1668 | |
shoaib_ahmed | 0:791a779d6220 | 1669 | |
shoaib_ahmed | 0:791a779d6220 | 1670 | /* |
shoaib_ahmed | 0:791a779d6220 | 1671 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1672 | * producing a 12x12 output block. |
shoaib_ahmed | 0:791a779d6220 | 1673 | * |
shoaib_ahmed | 0:791a779d6220 | 1674 | * Optimized algorithm with 15 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 1675 | * cK represents sqrt(2) * cos(K*pi/24). |
shoaib_ahmed | 0:791a779d6220 | 1676 | */ |
shoaib_ahmed | 0:791a779d6220 | 1677 | |
shoaib_ahmed | 0:791a779d6220 | 1678 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1679 | jpeg_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1680 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1681 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1682 | { |
shoaib_ahmed | 0:791a779d6220 | 1683 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
shoaib_ahmed | 0:791a779d6220 | 1684 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
shoaib_ahmed | 0:791a779d6220 | 1685 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 1686 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 1687 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1688 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 1689 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1690 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1691 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 1692 | int workspace[8*12]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 1693 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1694 | |
shoaib_ahmed | 0:791a779d6220 | 1695 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 1696 | |
shoaib_ahmed | 0:791a779d6220 | 1697 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 1698 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1699 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1700 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 1701 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1702 | |
shoaib_ahmed | 0:791a779d6220 | 1703 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1704 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1705 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 1706 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 1707 | |
shoaib_ahmed | 0:791a779d6220 | 1708 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 1709 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1710 | |
shoaib_ahmed | 0:791a779d6220 | 1711 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1712 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 1713 | |
shoaib_ahmed | 0:791a779d6220 | 1714 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 1715 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1716 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1717 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 1718 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1719 | |
shoaib_ahmed | 0:791a779d6220 | 1720 | tmp12 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1721 | |
shoaib_ahmed | 0:791a779d6220 | 1722 | tmp21 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1723 | tmp24 = z3 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1724 | |
shoaib_ahmed | 0:791a779d6220 | 1725 | tmp12 = z4 + z2; |
shoaib_ahmed | 0:791a779d6220 | 1726 | |
shoaib_ahmed | 0:791a779d6220 | 1727 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1728 | tmp25 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1729 | |
shoaib_ahmed | 0:791a779d6220 | 1730 | tmp12 = z4 - z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1731 | |
shoaib_ahmed | 0:791a779d6220 | 1732 | tmp22 = tmp11 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1733 | tmp23 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1734 | |
shoaib_ahmed | 0:791a779d6220 | 1735 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1736 | |
shoaib_ahmed | 0:791a779d6220 | 1737 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1738 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 1739 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 1740 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 1741 | |
shoaib_ahmed | 0:791a779d6220 | 1742 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1743 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1744 | |
shoaib_ahmed | 0:791a779d6220 | 1745 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 1746 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1747 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1748 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1749 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
shoaib_ahmed | 0:791a779d6220 | 1750 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1751 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1752 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1753 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1754 | |
shoaib_ahmed | 0:791a779d6220 | 1755 | z1 -= z4; |
shoaib_ahmed | 0:791a779d6220 | 1756 | z2 -= z3; |
shoaib_ahmed | 0:791a779d6220 | 1757 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1758 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1759 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1760 | |
shoaib_ahmed | 0:791a779d6220 | 1761 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1762 | |
shoaib_ahmed | 0:791a779d6220 | 1763 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1764 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1765 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1766 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1767 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1768 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1769 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1770 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1771 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1772 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1773 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1774 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1775 | } |
shoaib_ahmed | 0:791a779d6220 | 1776 | |
shoaib_ahmed | 0:791a779d6220 | 1777 | /* Pass 2: process 12 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 1778 | |
shoaib_ahmed | 0:791a779d6220 | 1779 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1780 | for (ctr = 0; ctr < 12; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 1781 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 1782 | |
shoaib_ahmed | 0:791a779d6220 | 1783 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1784 | |
shoaib_ahmed | 0:791a779d6220 | 1785 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 1786 | z3 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 1787 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 1788 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 1789 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1790 | |
shoaib_ahmed | 0:791a779d6220 | 1791 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 1792 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1793 | |
shoaib_ahmed | 0:791a779d6220 | 1794 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1795 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 1796 | |
shoaib_ahmed | 0:791a779d6220 | 1797 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 1798 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1799 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1800 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 1801 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1802 | |
shoaib_ahmed | 0:791a779d6220 | 1803 | tmp12 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1804 | |
shoaib_ahmed | 0:791a779d6220 | 1805 | tmp21 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1806 | tmp24 = z3 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1807 | |
shoaib_ahmed | 0:791a779d6220 | 1808 | tmp12 = z4 + z2; |
shoaib_ahmed | 0:791a779d6220 | 1809 | |
shoaib_ahmed | 0:791a779d6220 | 1810 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1811 | tmp25 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1812 | |
shoaib_ahmed | 0:791a779d6220 | 1813 | tmp12 = z4 - z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 1814 | |
shoaib_ahmed | 0:791a779d6220 | 1815 | tmp22 = tmp11 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1816 | tmp23 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 1817 | |
shoaib_ahmed | 0:791a779d6220 | 1818 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1819 | |
shoaib_ahmed | 0:791a779d6220 | 1820 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 1821 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 1822 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 1823 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 1824 | |
shoaib_ahmed | 0:791a779d6220 | 1825 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1826 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1827 | |
shoaib_ahmed | 0:791a779d6220 | 1828 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 1829 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1830 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1831 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1832 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
shoaib_ahmed | 0:791a779d6220 | 1833 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1834 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1835 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1836 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1837 | |
shoaib_ahmed | 0:791a779d6220 | 1838 | z1 -= z4; |
shoaib_ahmed | 0:791a779d6220 | 1839 | z2 -= z3; |
shoaib_ahmed | 0:791a779d6220 | 1840 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1841 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1842 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1843 | |
shoaib_ahmed | 0:791a779d6220 | 1844 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1845 | |
shoaib_ahmed | 0:791a779d6220 | 1846 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1847 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1848 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1849 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 1850 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1851 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1852 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1853 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1854 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1855 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 1856 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1857 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1858 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1859 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1860 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1861 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 1862 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1863 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1864 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1865 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1866 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1867 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 1868 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1869 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1870 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1871 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1872 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1873 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 1874 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1875 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1876 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 1877 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1878 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1879 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 1880 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 1881 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 1882 | |
shoaib_ahmed | 0:791a779d6220 | 1883 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 1884 | } |
shoaib_ahmed | 0:791a779d6220 | 1885 | } |
shoaib_ahmed | 0:791a779d6220 | 1886 | |
shoaib_ahmed | 0:791a779d6220 | 1887 | |
shoaib_ahmed | 0:791a779d6220 | 1888 | /* |
shoaib_ahmed | 0:791a779d6220 | 1889 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 1890 | * producing a 13x13 output block. |
shoaib_ahmed | 0:791a779d6220 | 1891 | * |
shoaib_ahmed | 0:791a779d6220 | 1892 | * Optimized algorithm with 29 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 1893 | * cK represents sqrt(2) * cos(K*pi/26). |
shoaib_ahmed | 0:791a779d6220 | 1894 | */ |
shoaib_ahmed | 0:791a779d6220 | 1895 | |
shoaib_ahmed | 0:791a779d6220 | 1896 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 1897 | jpeg_idct_13x13 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 1898 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 1899 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 1900 | { |
shoaib_ahmed | 0:791a779d6220 | 1901 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
shoaib_ahmed | 0:791a779d6220 | 1902 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
shoaib_ahmed | 0:791a779d6220 | 1903 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 1904 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 1905 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 1906 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 1907 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 1908 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 1909 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 1910 | int workspace[8*13]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 1911 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 1912 | |
shoaib_ahmed | 0:791a779d6220 | 1913 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 1914 | |
shoaib_ahmed | 0:791a779d6220 | 1915 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 1916 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 1917 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 1918 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 1919 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 1920 | |
shoaib_ahmed | 0:791a779d6220 | 1921 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 1922 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 1923 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 1924 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 1925 | |
shoaib_ahmed | 0:791a779d6220 | 1926 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 1927 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 1928 | z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 1929 | |
shoaib_ahmed | 0:791a779d6220 | 1930 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1931 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 1932 | |
shoaib_ahmed | 0:791a779d6220 | 1933 | tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1934 | tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1935 | |
shoaib_ahmed | 0:791a779d6220 | 1936 | tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 1937 | tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 1938 | |
shoaib_ahmed | 0:791a779d6220 | 1939 | tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1940 | tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1941 | |
shoaib_ahmed | 0:791a779d6220 | 1942 | tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 1943 | tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 1944 | |
shoaib_ahmed | 0:791a779d6220 | 1945 | tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1946 | tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 1947 | |
shoaib_ahmed | 0:791a779d6220 | 1948 | tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 1949 | tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 1950 | |
shoaib_ahmed | 0:791a779d6220 | 1951 | tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 1952 | |
shoaib_ahmed | 0:791a779d6220 | 1953 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 1954 | |
shoaib_ahmed | 0:791a779d6220 | 1955 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 1956 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 1957 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 1958 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 1959 | |
shoaib_ahmed | 0:791a779d6220 | 1960 | tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1961 | tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1962 | tmp15 = z1 + z4; |
shoaib_ahmed | 0:791a779d6220 | 1963 | tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1964 | tmp10 = tmp11 + tmp12 + tmp13 - |
shoaib_ahmed | 0:791a779d6220 | 1965 | MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 1966 | tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1967 | tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 1968 | tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1969 | tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 1970 | tmp11 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1971 | tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1972 | tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 1973 | tmp12 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1974 | tmp13 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 1975 | tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1976 | tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1977 | MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1978 | z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1979 | tmp14 += z1; |
shoaib_ahmed | 0:791a779d6220 | 1980 | tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 1981 | MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 1982 | |
shoaib_ahmed | 0:791a779d6220 | 1983 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 1984 | |
shoaib_ahmed | 0:791a779d6220 | 1985 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1986 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1987 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1988 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1989 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1990 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1991 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1992 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1993 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1994 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1995 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1996 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1997 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 1998 | } |
shoaib_ahmed | 0:791a779d6220 | 1999 | |
shoaib_ahmed | 0:791a779d6220 | 2000 | /* Pass 2: process 13 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 2001 | |
shoaib_ahmed | 0:791a779d6220 | 2002 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2003 | for (ctr = 0; ctr < 13; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 2004 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 2005 | |
shoaib_ahmed | 0:791a779d6220 | 2006 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2007 | |
shoaib_ahmed | 0:791a779d6220 | 2008 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 2009 | z1 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 2010 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 2011 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 2012 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2013 | |
shoaib_ahmed | 0:791a779d6220 | 2014 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 2015 | z3 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 2016 | z4 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 2017 | |
shoaib_ahmed | 0:791a779d6220 | 2018 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 2019 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2020 | |
shoaib_ahmed | 0:791a779d6220 | 2021 | tmp12 = MULTIPLY(tmp10, FIX(1.155388986)); /* (c4+c6)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2022 | tmp13 = MULTIPLY(tmp11, FIX(0.096834934)) + z1; /* (c4-c6)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2023 | |
shoaib_ahmed | 0:791a779d6220 | 2024 | tmp20 = MULTIPLY(z2, FIX(1.373119086)) + tmp12 + tmp13; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 2025 | tmp22 = MULTIPLY(z2, FIX(0.501487041)) - tmp12 + tmp13; /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 2026 | |
shoaib_ahmed | 0:791a779d6220 | 2027 | tmp12 = MULTIPLY(tmp10, FIX(0.316450131)); /* (c8-c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2028 | tmp13 = MULTIPLY(tmp11, FIX(0.486914739)) + z1; /* (c8+c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2029 | |
shoaib_ahmed | 0:791a779d6220 | 2030 | tmp21 = MULTIPLY(z2, FIX(1.058554052)) - tmp12 + tmp13; /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2031 | tmp25 = MULTIPLY(z2, - FIX(1.252223920)) + tmp12 + tmp13; /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 2032 | |
shoaib_ahmed | 0:791a779d6220 | 2033 | tmp12 = MULTIPLY(tmp10, FIX(0.435816023)); /* (c2-c10)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2034 | tmp13 = MULTIPLY(tmp11, FIX(0.937303064)) - z1; /* (c2+c10)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2035 | |
shoaib_ahmed | 0:791a779d6220 | 2036 | tmp23 = MULTIPLY(z2, - FIX(0.170464608)) - tmp12 - tmp13; /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2037 | tmp24 = MULTIPLY(z2, - FIX(0.803364869)) + tmp12 - tmp13; /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 2038 | |
shoaib_ahmed | 0:791a779d6220 | 2039 | tmp26 = MULTIPLY(tmp11 - z2, FIX(1.414213562)) + z1; /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 2040 | |
shoaib_ahmed | 0:791a779d6220 | 2041 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2042 | |
shoaib_ahmed | 0:791a779d6220 | 2043 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 2044 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 2045 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 2046 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 2047 | |
shoaib_ahmed | 0:791a779d6220 | 2048 | tmp11 = MULTIPLY(z1 + z2, FIX(1.322312651)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2049 | tmp12 = MULTIPLY(z1 + z3, FIX(1.163874945)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2050 | tmp15 = z1 + z4; |
shoaib_ahmed | 0:791a779d6220 | 2051 | tmp13 = MULTIPLY(tmp15, FIX(0.937797057)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2052 | tmp10 = tmp11 + tmp12 + tmp13 - |
shoaib_ahmed | 0:791a779d6220 | 2053 | MULTIPLY(z1, FIX(2.020082300)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2054 | tmp14 = MULTIPLY(z2 + z3, - FIX(0.338443458)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2055 | tmp11 += tmp14 + MULTIPLY(z2, FIX(0.837223564)); /* c5+c9+c11-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2056 | tmp12 += tmp14 - MULTIPLY(z3, FIX(1.572116027)); /* c1+c5-c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2057 | tmp14 = MULTIPLY(z2 + z4, - FIX(1.163874945)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2058 | tmp11 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2059 | tmp13 += tmp14 + MULTIPLY(z4, FIX(2.205608352)); /* c3+c5+c9-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2060 | tmp14 = MULTIPLY(z3 + z4, - FIX(0.657217813)); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2061 | tmp12 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2062 | tmp13 += tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2063 | tmp15 = MULTIPLY(tmp15, FIX(0.338443458)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2064 | tmp14 = tmp15 + MULTIPLY(z1, FIX(0.318774355)) - /* c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2065 | MULTIPLY(z2, FIX(0.466105296)); /* c1-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2066 | z1 = MULTIPLY(z3 - z2, FIX(0.937797057)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2067 | tmp14 += z1; |
shoaib_ahmed | 0:791a779d6220 | 2068 | tmp15 += z1 + MULTIPLY(z3, FIX(0.384515595)) - /* c3-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2069 | MULTIPLY(z4, FIX(1.742345811)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2070 | |
shoaib_ahmed | 0:791a779d6220 | 2071 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2072 | |
shoaib_ahmed | 0:791a779d6220 | 2073 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2074 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2075 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2076 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2077 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2078 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2079 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2080 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2081 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2082 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2083 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2084 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2085 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2086 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2087 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2088 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2089 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2090 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2091 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2092 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2093 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2094 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2095 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2096 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2097 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2098 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2099 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2100 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2101 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2102 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2103 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2104 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2105 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2106 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2107 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2108 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2109 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26, |
shoaib_ahmed | 0:791a779d6220 | 2110 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2111 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2112 | |
shoaib_ahmed | 0:791a779d6220 | 2113 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 2114 | } |
shoaib_ahmed | 0:791a779d6220 | 2115 | } |
shoaib_ahmed | 0:791a779d6220 | 2116 | |
shoaib_ahmed | 0:791a779d6220 | 2117 | |
shoaib_ahmed | 0:791a779d6220 | 2118 | /* |
shoaib_ahmed | 0:791a779d6220 | 2119 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 2120 | * producing a 14x14 output block. |
shoaib_ahmed | 0:791a779d6220 | 2121 | * |
shoaib_ahmed | 0:791a779d6220 | 2122 | * Optimized algorithm with 20 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 2123 | * cK represents sqrt(2) * cos(K*pi/28). |
shoaib_ahmed | 0:791a779d6220 | 2124 | */ |
shoaib_ahmed | 0:791a779d6220 | 2125 | |
shoaib_ahmed | 0:791a779d6220 | 2126 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 2127 | jpeg_idct_14x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 2128 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 2129 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 2130 | { |
shoaib_ahmed | 0:791a779d6220 | 2131 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
shoaib_ahmed | 0:791a779d6220 | 2132 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
shoaib_ahmed | 0:791a779d6220 | 2133 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 2134 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 2135 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 2136 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 2137 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 2138 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 2139 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 2140 | int workspace[8*14]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 2141 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 2142 | |
shoaib_ahmed | 0:791a779d6220 | 2143 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 2144 | |
shoaib_ahmed | 0:791a779d6220 | 2145 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 2146 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 2147 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2148 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 2149 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2150 | |
shoaib_ahmed | 0:791a779d6220 | 2151 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 2152 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2153 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 2154 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 2155 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 2156 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 2157 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2158 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 2159 | |
shoaib_ahmed | 0:791a779d6220 | 2160 | tmp10 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2161 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2162 | tmp12 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2163 | |
shoaib_ahmed | 0:791a779d6220 | 2164 | tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2165 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2166 | |
shoaib_ahmed | 0:791a779d6220 | 2167 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 2168 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 2169 | |
shoaib_ahmed | 0:791a779d6220 | 2170 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2171 | |
shoaib_ahmed | 0:791a779d6220 | 2172 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2173 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 2174 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 2175 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 2176 | |
shoaib_ahmed | 0:791a779d6220 | 2177 | tmp20 = tmp10 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2178 | tmp26 = tmp10 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2179 | tmp21 = tmp11 + tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2180 | tmp25 = tmp11 - tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2181 | tmp22 = tmp12 + tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2182 | tmp24 = tmp12 - tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2183 | |
shoaib_ahmed | 0:791a779d6220 | 2184 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2185 | |
shoaib_ahmed | 0:791a779d6220 | 2186 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 2187 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 2188 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 2189 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 2190 | tmp13 = z4 << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2191 | |
shoaib_ahmed | 0:791a779d6220 | 2192 | tmp14 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2193 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2194 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2195 | tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2196 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2197 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2198 | z1 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 2199 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2200 | tmp16 += tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2201 | z1 += z4; |
shoaib_ahmed | 0:791a779d6220 | 2202 | z4 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - tmp13; /* -c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2203 | tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2204 | tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2205 | z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2206 | tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2207 | tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2208 | |
shoaib_ahmed | 0:791a779d6220 | 2209 | tmp13 = (z1 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2210 | |
shoaib_ahmed | 0:791a779d6220 | 2211 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2212 | |
shoaib_ahmed | 0:791a779d6220 | 2213 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2214 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2215 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2216 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2217 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2218 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2219 | wsptr[8*3] = (int) (tmp23 + tmp13); |
shoaib_ahmed | 0:791a779d6220 | 2220 | wsptr[8*10] = (int) (tmp23 - tmp13); |
shoaib_ahmed | 0:791a779d6220 | 2221 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2222 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2223 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2224 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2225 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2226 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2227 | } |
shoaib_ahmed | 0:791a779d6220 | 2228 | |
shoaib_ahmed | 0:791a779d6220 | 2229 | /* Pass 2: process 14 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 2230 | |
shoaib_ahmed | 0:791a779d6220 | 2231 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2232 | for (ctr = 0; ctr < 14; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 2233 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 2234 | |
shoaib_ahmed | 0:791a779d6220 | 2235 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2236 | |
shoaib_ahmed | 0:791a779d6220 | 2237 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 2238 | z1 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 2239 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 2240 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 2241 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2242 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 2243 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 2244 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2245 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 2246 | |
shoaib_ahmed | 0:791a779d6220 | 2247 | tmp10 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2248 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2249 | tmp12 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2250 | |
shoaib_ahmed | 0:791a779d6220 | 2251 | tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2252 | |
shoaib_ahmed | 0:791a779d6220 | 2253 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 2254 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 2255 | |
shoaib_ahmed | 0:791a779d6220 | 2256 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2257 | |
shoaib_ahmed | 0:791a779d6220 | 2258 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2259 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 2260 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 2261 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 2262 | |
shoaib_ahmed | 0:791a779d6220 | 2263 | tmp20 = tmp10 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2264 | tmp26 = tmp10 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2265 | tmp21 = tmp11 + tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2266 | tmp25 = tmp11 - tmp14; |
shoaib_ahmed | 0:791a779d6220 | 2267 | tmp22 = tmp12 + tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2268 | tmp24 = tmp12 - tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2269 | |
shoaib_ahmed | 0:791a779d6220 | 2270 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2271 | |
shoaib_ahmed | 0:791a779d6220 | 2272 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 2273 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 2274 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 2275 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 2276 | z4 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2277 | |
shoaib_ahmed | 0:791a779d6220 | 2278 | tmp14 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2279 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2280 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2281 | tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2282 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2283 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2284 | z1 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 2285 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2286 | tmp16 += tmp15; |
shoaib_ahmed | 0:791a779d6220 | 2287 | tmp13 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - z4; /* -c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2288 | tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2289 | tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2290 | tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2291 | tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2292 | tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2293 | |
shoaib_ahmed | 0:791a779d6220 | 2294 | tmp13 = ((z1 - z3) << CONST_BITS) + z4; |
shoaib_ahmed | 0:791a779d6220 | 2295 | |
shoaib_ahmed | 0:791a779d6220 | 2296 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2297 | |
shoaib_ahmed | 0:791a779d6220 | 2298 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2299 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2300 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2301 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2302 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2303 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2304 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2305 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2306 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2307 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2308 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2309 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2310 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2311 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2312 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2313 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2314 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2315 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2316 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2317 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2318 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2319 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2320 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2321 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2322 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2323 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2324 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2325 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2326 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2327 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2328 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2329 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2330 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2331 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2332 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2333 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2334 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, |
shoaib_ahmed | 0:791a779d6220 | 2335 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2336 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2337 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, |
shoaib_ahmed | 0:791a779d6220 | 2338 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2339 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2340 | |
shoaib_ahmed | 0:791a779d6220 | 2341 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 2342 | } |
shoaib_ahmed | 0:791a779d6220 | 2343 | } |
shoaib_ahmed | 0:791a779d6220 | 2344 | |
shoaib_ahmed | 0:791a779d6220 | 2345 | |
shoaib_ahmed | 0:791a779d6220 | 2346 | /* |
shoaib_ahmed | 0:791a779d6220 | 2347 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 2348 | * producing a 15x15 output block. |
shoaib_ahmed | 0:791a779d6220 | 2349 | * |
shoaib_ahmed | 0:791a779d6220 | 2350 | * Optimized algorithm with 22 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 2351 | * cK represents sqrt(2) * cos(K*pi/30). |
shoaib_ahmed | 0:791a779d6220 | 2352 | */ |
shoaib_ahmed | 0:791a779d6220 | 2353 | |
shoaib_ahmed | 0:791a779d6220 | 2354 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 2355 | jpeg_idct_15x15 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 2356 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 2357 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 2358 | { |
shoaib_ahmed | 0:791a779d6220 | 2359 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
shoaib_ahmed | 0:791a779d6220 | 2360 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
shoaib_ahmed | 0:791a779d6220 | 2361 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 2362 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 2363 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 2364 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 2365 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 2366 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 2367 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 2368 | int workspace[8*15]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 2369 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 2370 | |
shoaib_ahmed | 0:791a779d6220 | 2371 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 2372 | |
shoaib_ahmed | 0:791a779d6220 | 2373 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 2374 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 2375 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2376 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 2377 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2378 | |
shoaib_ahmed | 0:791a779d6220 | 2379 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 2380 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2381 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 2382 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 2383 | |
shoaib_ahmed | 0:791a779d6220 | 2384 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 2385 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 2386 | z4 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 2387 | |
shoaib_ahmed | 0:791a779d6220 | 2388 | tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2389 | tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2390 | |
shoaib_ahmed | 0:791a779d6220 | 2391 | tmp12 = z1 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 2392 | tmp13 = z1 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2393 | z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2394 | |
shoaib_ahmed | 0:791a779d6220 | 2395 | z4 = z2 - z3; |
shoaib_ahmed | 0:791a779d6220 | 2396 | z3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2397 | tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2398 | tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2399 | z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ |
shoaib_ahmed | 0:791a779d6220 | 2400 | |
shoaib_ahmed | 0:791a779d6220 | 2401 | tmp20 = tmp13 + tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2402 | tmp23 = tmp12 - tmp10 + tmp11 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2403 | |
shoaib_ahmed | 0:791a779d6220 | 2404 | tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2405 | tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2406 | |
shoaib_ahmed | 0:791a779d6220 | 2407 | tmp25 = tmp13 - tmp10 - tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2408 | tmp26 = tmp12 + tmp10 - tmp11 - z2; |
shoaib_ahmed | 0:791a779d6220 | 2409 | |
shoaib_ahmed | 0:791a779d6220 | 2410 | tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2411 | tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2412 | |
shoaib_ahmed | 0:791a779d6220 | 2413 | tmp21 = tmp12 + tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2414 | tmp24 = tmp13 - tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2415 | tmp11 += tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2416 | tmp22 = z1 + tmp11; /* c10 = c6-c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2417 | tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2418 | |
shoaib_ahmed | 0:791a779d6220 | 2419 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2420 | |
shoaib_ahmed | 0:791a779d6220 | 2421 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 2422 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 2423 | z4 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 2424 | z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2425 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 2426 | |
shoaib_ahmed | 0:791a779d6220 | 2427 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2428 | tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2429 | tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2430 | tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2431 | |
shoaib_ahmed | 0:791a779d6220 | 2432 | tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2433 | tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2434 | z2 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2435 | tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2436 | |
shoaib_ahmed | 0:791a779d6220 | 2437 | tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2438 | tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2439 | tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2440 | z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2441 | tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2442 | tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2443 | |
shoaib_ahmed | 0:791a779d6220 | 2444 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2445 | |
shoaib_ahmed | 0:791a779d6220 | 2446 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2447 | wsptr[8*14] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2448 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2449 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2450 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2451 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2452 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2453 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2454 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2455 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2456 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2457 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2458 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2459 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2460 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2461 | } |
shoaib_ahmed | 0:791a779d6220 | 2462 | |
shoaib_ahmed | 0:791a779d6220 | 2463 | /* Pass 2: process 15 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 2464 | |
shoaib_ahmed | 0:791a779d6220 | 2465 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2466 | for (ctr = 0; ctr < 15; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 2467 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 2468 | |
shoaib_ahmed | 0:791a779d6220 | 2469 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2470 | |
shoaib_ahmed | 0:791a779d6220 | 2471 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 2472 | z1 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 2473 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 2474 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 2475 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2476 | |
shoaib_ahmed | 0:791a779d6220 | 2477 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 2478 | z3 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 2479 | z4 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 2480 | |
shoaib_ahmed | 0:791a779d6220 | 2481 | tmp10 = MULTIPLY(z4, FIX(0.437016024)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2482 | tmp11 = MULTIPLY(z4, FIX(1.144122806)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2483 | |
shoaib_ahmed | 0:791a779d6220 | 2484 | tmp12 = z1 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 2485 | tmp13 = z1 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2486 | z1 -= (tmp11 - tmp10) << 1; /* c0 = (c6-c12)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2487 | |
shoaib_ahmed | 0:791a779d6220 | 2488 | z4 = z2 - z3; |
shoaib_ahmed | 0:791a779d6220 | 2489 | z3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2490 | tmp10 = MULTIPLY(z3, FIX(1.337628990)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2491 | tmp11 = MULTIPLY(z4, FIX(0.045680613)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2492 | z2 = MULTIPLY(z2, FIX(1.439773946)); /* c4+c14 */ |
shoaib_ahmed | 0:791a779d6220 | 2493 | |
shoaib_ahmed | 0:791a779d6220 | 2494 | tmp20 = tmp13 + tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2495 | tmp23 = tmp12 - tmp10 + tmp11 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2496 | |
shoaib_ahmed | 0:791a779d6220 | 2497 | tmp10 = MULTIPLY(z3, FIX(0.547059574)); /* (c8+c14)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2498 | tmp11 = MULTIPLY(z4, FIX(0.399234004)); /* (c8-c14)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2499 | |
shoaib_ahmed | 0:791a779d6220 | 2500 | tmp25 = tmp13 - tmp10 - tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2501 | tmp26 = tmp12 + tmp10 - tmp11 - z2; |
shoaib_ahmed | 0:791a779d6220 | 2502 | |
shoaib_ahmed | 0:791a779d6220 | 2503 | tmp10 = MULTIPLY(z3, FIX(0.790569415)); /* (c6+c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2504 | tmp11 = MULTIPLY(z4, FIX(0.353553391)); /* (c6-c12)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 2505 | |
shoaib_ahmed | 0:791a779d6220 | 2506 | tmp21 = tmp12 + tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2507 | tmp24 = tmp13 - tmp10 + tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2508 | tmp11 += tmp11; |
shoaib_ahmed | 0:791a779d6220 | 2509 | tmp22 = z1 + tmp11; /* c10 = c6-c12 */ |
shoaib_ahmed | 0:791a779d6220 | 2510 | tmp27 = z1 - tmp11 - tmp11; /* c0 = (c6-c12)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 2511 | |
shoaib_ahmed | 0:791a779d6220 | 2512 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2513 | |
shoaib_ahmed | 0:791a779d6220 | 2514 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 2515 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 2516 | z4 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 2517 | z3 = MULTIPLY(z4, FIX(1.224744871)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2518 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 2519 | |
shoaib_ahmed | 0:791a779d6220 | 2520 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2521 | tmp15 = MULTIPLY(z1 + tmp13, FIX(0.831253876)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2522 | tmp11 = tmp15 + MULTIPLY(z1, FIX(0.513743148)); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2523 | tmp14 = tmp15 - MULTIPLY(tmp13, FIX(2.176250899)); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2524 | |
shoaib_ahmed | 0:791a779d6220 | 2525 | tmp13 = MULTIPLY(z2, - FIX(0.831253876)); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2526 | tmp15 = MULTIPLY(z2, - FIX(1.344997024)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2527 | z2 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 2528 | tmp12 = z3 + MULTIPLY(z2, FIX(1.406466353)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2529 | |
shoaib_ahmed | 0:791a779d6220 | 2530 | tmp10 = tmp12 + MULTIPLY(z4, FIX(2.457431844)) - tmp15; /* c1+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2531 | tmp16 = tmp12 - MULTIPLY(z1, FIX(1.112434820)) + tmp13; /* c1-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2532 | tmp12 = MULTIPLY(z2, FIX(1.224744871)) - z3; /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2533 | z2 = MULTIPLY(z1 + z4, FIX(0.575212477)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2534 | tmp13 += z2 + MULTIPLY(z1, FIX(0.475753014)) - z3; /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2535 | tmp15 += z2 - MULTIPLY(z4, FIX(0.869244010)) + z3; /* c11+c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2536 | |
shoaib_ahmed | 0:791a779d6220 | 2537 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2538 | |
shoaib_ahmed | 0:791a779d6220 | 2539 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2540 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2541 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2542 | outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2543 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2544 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2545 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2546 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2547 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2548 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2549 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2550 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2551 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2552 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2553 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2554 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2555 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2556 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2557 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2558 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2559 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2560 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2561 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2562 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2563 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2564 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2565 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2566 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 2567 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2568 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2569 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2570 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2571 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2572 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 2573 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2574 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2575 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, |
shoaib_ahmed | 0:791a779d6220 | 2576 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2577 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2578 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, |
shoaib_ahmed | 0:791a779d6220 | 2579 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2580 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2581 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27, |
shoaib_ahmed | 0:791a779d6220 | 2582 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2583 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2584 | |
shoaib_ahmed | 0:791a779d6220 | 2585 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 2586 | } |
shoaib_ahmed | 0:791a779d6220 | 2587 | } |
shoaib_ahmed | 0:791a779d6220 | 2588 | |
shoaib_ahmed | 0:791a779d6220 | 2589 | |
shoaib_ahmed | 0:791a779d6220 | 2590 | /* |
shoaib_ahmed | 0:791a779d6220 | 2591 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 2592 | * producing a 16x16 output block. |
shoaib_ahmed | 0:791a779d6220 | 2593 | * |
shoaib_ahmed | 0:791a779d6220 | 2594 | * Optimized algorithm with 28 multiplications in the 1-D kernel. |
shoaib_ahmed | 0:791a779d6220 | 2595 | * cK represents sqrt(2) * cos(K*pi/32). |
shoaib_ahmed | 0:791a779d6220 | 2596 | */ |
shoaib_ahmed | 0:791a779d6220 | 2597 | |
shoaib_ahmed | 0:791a779d6220 | 2598 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 2599 | jpeg_idct_16x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 2600 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 2601 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 2602 | { |
shoaib_ahmed | 0:791a779d6220 | 2603 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2604 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
shoaib_ahmed | 0:791a779d6220 | 2605 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 2606 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 2607 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 2608 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 2609 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 2610 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 2611 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 2612 | int workspace[8*16]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 2613 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 2614 | |
shoaib_ahmed | 0:791a779d6220 | 2615 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 2616 | |
shoaib_ahmed | 0:791a779d6220 | 2617 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 2618 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 2619 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2620 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 2621 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2622 | |
shoaib_ahmed | 0:791a779d6220 | 2623 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 2624 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2625 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 2626 | tmp0 += 1 << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 2627 | |
shoaib_ahmed | 0:791a779d6220 | 2628 | z1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 2629 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2630 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2631 | |
shoaib_ahmed | 0:791a779d6220 | 2632 | tmp10 = tmp0 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2633 | tmp11 = tmp0 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2634 | tmp12 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2635 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2636 | |
shoaib_ahmed | 0:791a779d6220 | 2637 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 2638 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 2639 | z3 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 2640 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2641 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2642 | |
shoaib_ahmed | 0:791a779d6220 | 2643 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2644 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2645 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2646 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2647 | |
shoaib_ahmed | 0:791a779d6220 | 2648 | tmp20 = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 2649 | tmp27 = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 2650 | tmp21 = tmp12 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2651 | tmp26 = tmp12 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2652 | tmp22 = tmp13 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2653 | tmp25 = tmp13 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2654 | tmp23 = tmp11 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2655 | tmp24 = tmp11 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2656 | |
shoaib_ahmed | 0:791a779d6220 | 2657 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2658 | |
shoaib_ahmed | 0:791a779d6220 | 2659 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 2660 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 2661 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 2662 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 2663 | |
shoaib_ahmed | 0:791a779d6220 | 2664 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2665 | |
shoaib_ahmed | 0:791a779d6220 | 2666 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2667 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2668 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2669 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2670 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2671 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2672 | tmp0 = tmp1 + tmp2 + tmp3 - |
shoaib_ahmed | 0:791a779d6220 | 2673 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2674 | tmp13 = tmp10 + tmp11 + tmp12 - |
shoaib_ahmed | 0:791a779d6220 | 2675 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2676 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2677 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2678 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2679 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2680 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2681 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2682 | z2 += z4; |
shoaib_ahmed | 0:791a779d6220 | 2683 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2684 | tmp1 += z1; |
shoaib_ahmed | 0:791a779d6220 | 2685 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2686 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2687 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2688 | tmp12 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2689 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2690 | tmp2 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2691 | tmp3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2692 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2693 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2694 | tmp11 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2695 | |
shoaib_ahmed | 0:791a779d6220 | 2696 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2697 | |
shoaib_ahmed | 0:791a779d6220 | 2698 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2699 | wsptr[8*15] = (int) RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2700 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2701 | wsptr[8*14] = (int) RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2702 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2703 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2704 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2705 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2706 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2707 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2708 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2709 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2710 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2711 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2712 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2713 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2714 | } |
shoaib_ahmed | 0:791a779d6220 | 2715 | |
shoaib_ahmed | 0:791a779d6220 | 2716 | /* Pass 2: process 16 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 2717 | |
shoaib_ahmed | 0:791a779d6220 | 2718 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2719 | for (ctr = 0; ctr < 16; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 2720 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 2721 | |
shoaib_ahmed | 0:791a779d6220 | 2722 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 2723 | |
shoaib_ahmed | 0:791a779d6220 | 2724 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 2725 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 2726 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 2727 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 2728 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2729 | |
shoaib_ahmed | 0:791a779d6220 | 2730 | z1 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 2731 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2732 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2733 | |
shoaib_ahmed | 0:791a779d6220 | 2734 | tmp10 = tmp0 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2735 | tmp11 = tmp0 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2736 | tmp12 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2737 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2738 | |
shoaib_ahmed | 0:791a779d6220 | 2739 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 2740 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 2741 | z3 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 2742 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2743 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2744 | |
shoaib_ahmed | 0:791a779d6220 | 2745 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2746 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2747 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2748 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 2749 | |
shoaib_ahmed | 0:791a779d6220 | 2750 | tmp20 = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 2751 | tmp27 = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 2752 | tmp21 = tmp12 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2753 | tmp26 = tmp12 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 2754 | tmp22 = tmp13 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2755 | tmp25 = tmp13 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2756 | tmp23 = tmp11 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2757 | tmp24 = tmp11 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2758 | |
shoaib_ahmed | 0:791a779d6220 | 2759 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 2760 | |
shoaib_ahmed | 0:791a779d6220 | 2761 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 2762 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 2763 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 2764 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 2765 | |
shoaib_ahmed | 0:791a779d6220 | 2766 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2767 | |
shoaib_ahmed | 0:791a779d6220 | 2768 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2769 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2770 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2771 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 2772 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2773 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2774 | tmp0 = tmp1 + tmp2 + tmp3 - |
shoaib_ahmed | 0:791a779d6220 | 2775 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2776 | tmp13 = tmp10 + tmp11 + tmp12 - |
shoaib_ahmed | 0:791a779d6220 | 2777 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2778 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2779 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 2780 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2781 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 2782 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2783 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2784 | z2 += z4; |
shoaib_ahmed | 0:791a779d6220 | 2785 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 2786 | tmp1 += z1; |
shoaib_ahmed | 0:791a779d6220 | 2787 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2788 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2789 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2790 | tmp12 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2791 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2792 | tmp2 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2793 | tmp3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2794 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 2795 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2796 | tmp11 += z2; |
shoaib_ahmed | 0:791a779d6220 | 2797 | |
shoaib_ahmed | 0:791a779d6220 | 2798 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 2799 | |
shoaib_ahmed | 0:791a779d6220 | 2800 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 2801 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2802 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2803 | outptr[15] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 2804 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2805 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2806 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 2807 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2808 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2809 | outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 2810 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2811 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2812 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 2813 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2814 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2815 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 2816 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2817 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2818 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 2819 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2820 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2821 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 2822 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2823 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2824 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2825 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2826 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2827 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 2828 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2829 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2830 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2831 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2832 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2833 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 2834 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2835 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2836 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2837 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2838 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2839 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 2840 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2841 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2842 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2843 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2844 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2845 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp27 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 2846 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 2847 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 2848 | |
shoaib_ahmed | 0:791a779d6220 | 2849 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 2850 | } |
shoaib_ahmed | 0:791a779d6220 | 2851 | } |
shoaib_ahmed | 0:791a779d6220 | 2852 | |
shoaib_ahmed | 0:791a779d6220 | 2853 | |
shoaib_ahmed | 0:791a779d6220 | 2854 | /* |
shoaib_ahmed | 0:791a779d6220 | 2855 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 2856 | * producing a 16x8 output block. |
shoaib_ahmed | 0:791a779d6220 | 2857 | * |
shoaib_ahmed | 0:791a779d6220 | 2858 | * 8-point IDCT in pass 1 (columns), 16-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 2859 | */ |
shoaib_ahmed | 0:791a779d6220 | 2860 | |
shoaib_ahmed | 0:791a779d6220 | 2861 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 2862 | jpeg_idct_16x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 2863 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 2864 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 2865 | { |
shoaib_ahmed | 0:791a779d6220 | 2866 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 2867 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
shoaib_ahmed | 0:791a779d6220 | 2868 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 2869 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 2870 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 2871 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 2872 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 2873 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 2874 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 2875 | int workspace[8*8]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 2876 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 2877 | |
shoaib_ahmed | 0:791a779d6220 | 2878 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 2879 | * Note results are scaled up by sqrt(8) compared to a true IDCT; |
shoaib_ahmed | 0:791a779d6220 | 2880 | * furthermore, we scale the results by 2**PASS1_BITS. |
shoaib_ahmed | 0:791a779d6220 | 2881 | * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). |
shoaib_ahmed | 0:791a779d6220 | 2882 | */ |
shoaib_ahmed | 0:791a779d6220 | 2883 | |
shoaib_ahmed | 0:791a779d6220 | 2884 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 2885 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 2886 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2887 | for (ctr = DCTSIZE; ctr > 0; ctr--) { |
shoaib_ahmed | 0:791a779d6220 | 2888 | /* Due to quantization, we will usually find that many of the input |
shoaib_ahmed | 0:791a779d6220 | 2889 | * coefficients are zero, especially the AC terms. We can exploit this |
shoaib_ahmed | 0:791a779d6220 | 2890 | * by short-circuiting the IDCT calculation for any column in which all |
shoaib_ahmed | 0:791a779d6220 | 2891 | * the AC terms are zero. In that case each output is equal to the |
shoaib_ahmed | 0:791a779d6220 | 2892 | * DC coefficient (with scale factor as needed). |
shoaib_ahmed | 0:791a779d6220 | 2893 | * With typical images and quantization tables, half or more of the |
shoaib_ahmed | 0:791a779d6220 | 2894 | * column DCT calculations can be simplified this way. |
shoaib_ahmed | 0:791a779d6220 | 2895 | */ |
shoaib_ahmed | 0:791a779d6220 | 2896 | |
shoaib_ahmed | 0:791a779d6220 | 2897 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 2898 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 2899 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 2900 | inptr[DCTSIZE*7] == 0) { |
shoaib_ahmed | 0:791a779d6220 | 2901 | /* AC terms all zero */ |
shoaib_ahmed | 0:791a779d6220 | 2902 | int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2903 | |
shoaib_ahmed | 0:791a779d6220 | 2904 | wsptr[DCTSIZE*0] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2905 | wsptr[DCTSIZE*1] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2906 | wsptr[DCTSIZE*2] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2907 | wsptr[DCTSIZE*3] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2908 | wsptr[DCTSIZE*4] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2909 | wsptr[DCTSIZE*5] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2910 | wsptr[DCTSIZE*6] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2911 | wsptr[DCTSIZE*7] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 2912 | |
shoaib_ahmed | 0:791a779d6220 | 2913 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 2914 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 2915 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 2916 | continue; |
shoaib_ahmed | 0:791a779d6220 | 2917 | } |
shoaib_ahmed | 0:791a779d6220 | 2918 | |
shoaib_ahmed | 0:791a779d6220 | 2919 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 2920 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 2921 | */ |
shoaib_ahmed | 0:791a779d6220 | 2922 | |
shoaib_ahmed | 0:791a779d6220 | 2923 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 2924 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 2925 | |
shoaib_ahmed | 0:791a779d6220 | 2926 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2927 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2928 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 2929 | |
shoaib_ahmed | 0:791a779d6220 | 2930 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 2931 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 2932 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2933 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 2934 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 2935 | z2 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 2936 | |
shoaib_ahmed | 0:791a779d6220 | 2937 | tmp0 = z2 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2938 | tmp1 = z2 - z3; |
shoaib_ahmed | 0:791a779d6220 | 2939 | |
shoaib_ahmed | 0:791a779d6220 | 2940 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2941 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2942 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2943 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2944 | |
shoaib_ahmed | 0:791a779d6220 | 2945 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 2946 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 2947 | */ |
shoaib_ahmed | 0:791a779d6220 | 2948 | |
shoaib_ahmed | 0:791a779d6220 | 2949 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 2950 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 2951 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 2952 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 2953 | |
shoaib_ahmed | 0:791a779d6220 | 2954 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 2955 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 2956 | |
shoaib_ahmed | 0:791a779d6220 | 2957 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2958 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2959 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 2960 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 2961 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 2962 | |
shoaib_ahmed | 0:791a779d6220 | 2963 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2964 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2965 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2966 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2967 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2968 | |
shoaib_ahmed | 0:791a779d6220 | 2969 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 2970 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2971 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 2972 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 2973 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 2974 | |
shoaib_ahmed | 0:791a779d6220 | 2975 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 2976 | |
shoaib_ahmed | 0:791a779d6220 | 2977 | wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2978 | wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2979 | wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2980 | wsptr[DCTSIZE*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2981 | wsptr[DCTSIZE*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2982 | wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2983 | wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2984 | wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 2985 | |
shoaib_ahmed | 0:791a779d6220 | 2986 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 2987 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 2988 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 2989 | } |
shoaib_ahmed | 0:791a779d6220 | 2990 | |
shoaib_ahmed | 0:791a779d6220 | 2991 | /* Pass 2: process 8 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 2992 | * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32). |
shoaib_ahmed | 0:791a779d6220 | 2993 | */ |
shoaib_ahmed | 0:791a779d6220 | 2994 | |
shoaib_ahmed | 0:791a779d6220 | 2995 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 2996 | for (ctr = 0; ctr < 8; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 2997 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 2998 | |
shoaib_ahmed | 0:791a779d6220 | 2999 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3000 | |
shoaib_ahmed | 0:791a779d6220 | 3001 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3002 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3003 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3004 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3005 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3006 | |
shoaib_ahmed | 0:791a779d6220 | 3007 | z1 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3008 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3009 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3010 | |
shoaib_ahmed | 0:791a779d6220 | 3011 | tmp10 = tmp0 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 3012 | tmp11 = tmp0 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 3013 | tmp12 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3014 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3015 | |
shoaib_ahmed | 0:791a779d6220 | 3016 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3017 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 3018 | z3 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 3019 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3020 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3021 | |
shoaib_ahmed | 0:791a779d6220 | 3022 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3023 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3024 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3025 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 3026 | |
shoaib_ahmed | 0:791a779d6220 | 3027 | tmp20 = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3028 | tmp27 = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3029 | tmp21 = tmp12 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 3030 | tmp26 = tmp12 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 3031 | tmp22 = tmp13 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3032 | tmp25 = tmp13 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3033 | tmp23 = tmp11 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3034 | tmp24 = tmp11 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3035 | |
shoaib_ahmed | 0:791a779d6220 | 3036 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3037 | |
shoaib_ahmed | 0:791a779d6220 | 3038 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3039 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3040 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3041 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 3042 | |
shoaib_ahmed | 0:791a779d6220 | 3043 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3044 | |
shoaib_ahmed | 0:791a779d6220 | 3045 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3046 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3047 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3048 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3049 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3050 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3051 | tmp0 = tmp1 + tmp2 + tmp3 - |
shoaib_ahmed | 0:791a779d6220 | 3052 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3053 | tmp13 = tmp10 + tmp11 + tmp12 - |
shoaib_ahmed | 0:791a779d6220 | 3054 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 3055 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
shoaib_ahmed | 0:791a779d6220 | 3056 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 3057 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3058 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3059 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3060 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3061 | z2 += z4; |
shoaib_ahmed | 0:791a779d6220 | 3062 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3063 | tmp1 += z1; |
shoaib_ahmed | 0:791a779d6220 | 3064 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3065 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3066 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3067 | tmp12 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3068 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3069 | tmp2 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3070 | tmp3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3071 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3072 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3073 | tmp11 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3074 | |
shoaib_ahmed | 0:791a779d6220 | 3075 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3076 | |
shoaib_ahmed | 0:791a779d6220 | 3077 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3078 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3079 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3080 | outptr[15] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3081 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3082 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3083 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3084 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3085 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3086 | outptr[14] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3087 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3088 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3089 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3090 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3091 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3092 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3093 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3094 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3095 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 3096 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3097 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3098 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 3099 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3100 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3101 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3102 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3103 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3104 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3105 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3106 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3107 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3108 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3109 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3110 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3111 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3112 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3113 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3114 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3115 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3116 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3117 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3118 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3119 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp27 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3120 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3121 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3122 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp27 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3123 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3124 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3125 | |
shoaib_ahmed | 0:791a779d6220 | 3126 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3127 | } |
shoaib_ahmed | 0:791a779d6220 | 3128 | } |
shoaib_ahmed | 0:791a779d6220 | 3129 | |
shoaib_ahmed | 0:791a779d6220 | 3130 | |
shoaib_ahmed | 0:791a779d6220 | 3131 | /* |
shoaib_ahmed | 0:791a779d6220 | 3132 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3133 | * producing a 14x7 output block. |
shoaib_ahmed | 0:791a779d6220 | 3134 | * |
shoaib_ahmed | 0:791a779d6220 | 3135 | * 7-point IDCT in pass 1 (columns), 14-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3136 | */ |
shoaib_ahmed | 0:791a779d6220 | 3137 | |
shoaib_ahmed | 0:791a779d6220 | 3138 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3139 | jpeg_idct_14x7 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3140 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3141 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3142 | { |
shoaib_ahmed | 0:791a779d6220 | 3143 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
shoaib_ahmed | 0:791a779d6220 | 3144 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
shoaib_ahmed | 0:791a779d6220 | 3145 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 3146 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3147 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3148 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3149 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3150 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3151 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3152 | int workspace[8*7]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3153 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3154 | |
shoaib_ahmed | 0:791a779d6220 | 3155 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 3156 | * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14). |
shoaib_ahmed | 0:791a779d6220 | 3157 | */ |
shoaib_ahmed | 0:791a779d6220 | 3158 | |
shoaib_ahmed | 0:791a779d6220 | 3159 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3160 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3161 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3162 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3163 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3164 | |
shoaib_ahmed | 0:791a779d6220 | 3165 | tmp23 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3166 | tmp23 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3167 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 3168 | tmp23 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 3169 | |
shoaib_ahmed | 0:791a779d6220 | 3170 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 3171 | z2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 3172 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 3173 | |
shoaib_ahmed | 0:791a779d6220 | 3174 | tmp20 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3175 | tmp22 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3176 | tmp21 = tmp20 + tmp22 + tmp23 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3177 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3178 | z2 -= tmp10; |
shoaib_ahmed | 0:791a779d6220 | 3179 | tmp10 = MULTIPLY(tmp10, FIX(1.274162392)) + tmp23; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3180 | tmp20 += tmp10 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3181 | tmp22 += tmp10 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3182 | tmp23 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 3183 | |
shoaib_ahmed | 0:791a779d6220 | 3184 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3185 | |
shoaib_ahmed | 0:791a779d6220 | 3186 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3187 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 3188 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 3189 | |
shoaib_ahmed | 0:791a779d6220 | 3190 | tmp11 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3191 | tmp12 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3192 | tmp10 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3193 | tmp11 += tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3194 | tmp12 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3195 | tmp11 += tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3196 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3197 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 3198 | tmp12 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3199 | |
shoaib_ahmed | 0:791a779d6220 | 3200 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3201 | |
shoaib_ahmed | 0:791a779d6220 | 3202 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3203 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3204 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3205 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3206 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3207 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3208 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3209 | } |
shoaib_ahmed | 0:791a779d6220 | 3210 | |
shoaib_ahmed | 0:791a779d6220 | 3211 | /* Pass 2: process 7 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3212 | * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28). |
shoaib_ahmed | 0:791a779d6220 | 3213 | */ |
shoaib_ahmed | 0:791a779d6220 | 3214 | |
shoaib_ahmed | 0:791a779d6220 | 3215 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3216 | for (ctr = 0; ctr < 7; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3217 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 3218 | |
shoaib_ahmed | 0:791a779d6220 | 3219 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3220 | |
shoaib_ahmed | 0:791a779d6220 | 3221 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3222 | z1 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3223 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3224 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3225 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3226 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3227 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3228 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 3229 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 3230 | |
shoaib_ahmed | 0:791a779d6220 | 3231 | tmp10 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 3232 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3233 | tmp12 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 3234 | |
shoaib_ahmed | 0:791a779d6220 | 3235 | tmp23 = z1 - ((z2 + z3 - z4) << 1); /* c0 = (c4+c12-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 3236 | |
shoaib_ahmed | 0:791a779d6220 | 3237 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3238 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 3239 | |
shoaib_ahmed | 0:791a779d6220 | 3240 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3241 | |
shoaib_ahmed | 0:791a779d6220 | 3242 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3243 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 3244 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 3245 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3246 | |
shoaib_ahmed | 0:791a779d6220 | 3247 | tmp20 = tmp10 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 3248 | tmp26 = tmp10 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 3249 | tmp21 = tmp11 + tmp14; |
shoaib_ahmed | 0:791a779d6220 | 3250 | tmp25 = tmp11 - tmp14; |
shoaib_ahmed | 0:791a779d6220 | 3251 | tmp22 = tmp12 + tmp15; |
shoaib_ahmed | 0:791a779d6220 | 3252 | tmp24 = tmp12 - tmp15; |
shoaib_ahmed | 0:791a779d6220 | 3253 | |
shoaib_ahmed | 0:791a779d6220 | 3254 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3255 | |
shoaib_ahmed | 0:791a779d6220 | 3256 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3257 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3258 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3259 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 3260 | z4 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3261 | |
shoaib_ahmed | 0:791a779d6220 | 3262 | tmp14 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3263 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3264 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3265 | tmp10 = tmp11 + tmp12 + z4 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3266 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3267 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3268 | z1 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 3269 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - z4; /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3270 | tmp16 += tmp15; |
shoaib_ahmed | 0:791a779d6220 | 3271 | tmp13 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - z4; /* -c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3272 | tmp11 += tmp13 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3273 | tmp12 += tmp13 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 3274 | tmp13 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3275 | tmp14 += tmp13 + z4 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3276 | tmp15 += tmp13 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3277 | |
shoaib_ahmed | 0:791a779d6220 | 3278 | tmp13 = ((z1 - z3) << CONST_BITS) + z4; |
shoaib_ahmed | 0:791a779d6220 | 3279 | |
shoaib_ahmed | 0:791a779d6220 | 3280 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3281 | |
shoaib_ahmed | 0:791a779d6220 | 3282 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3283 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3284 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3285 | outptr[13] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3286 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3287 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3288 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3289 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3290 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3291 | outptr[12] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3292 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3293 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3294 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3295 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3296 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3297 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3298 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3299 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3300 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3301 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3302 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3303 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3304 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3305 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3306 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3307 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3308 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3309 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3310 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3311 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3312 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 3313 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3314 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3315 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 3316 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3317 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3318 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp26 + tmp16, |
shoaib_ahmed | 0:791a779d6220 | 3319 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3320 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3321 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp26 - tmp16, |
shoaib_ahmed | 0:791a779d6220 | 3322 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3323 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3324 | |
shoaib_ahmed | 0:791a779d6220 | 3325 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3326 | } |
shoaib_ahmed | 0:791a779d6220 | 3327 | } |
shoaib_ahmed | 0:791a779d6220 | 3328 | |
shoaib_ahmed | 0:791a779d6220 | 3329 | |
shoaib_ahmed | 0:791a779d6220 | 3330 | /* |
shoaib_ahmed | 0:791a779d6220 | 3331 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3332 | * producing a 12x6 output block. |
shoaib_ahmed | 0:791a779d6220 | 3333 | * |
shoaib_ahmed | 0:791a779d6220 | 3334 | * 6-point IDCT in pass 1 (columns), 12-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3335 | */ |
shoaib_ahmed | 0:791a779d6220 | 3336 | |
shoaib_ahmed | 0:791a779d6220 | 3337 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3338 | jpeg_idct_12x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3339 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3340 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3341 | { |
shoaib_ahmed | 0:791a779d6220 | 3342 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
shoaib_ahmed | 0:791a779d6220 | 3343 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
shoaib_ahmed | 0:791a779d6220 | 3344 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 3345 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3346 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3347 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3348 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3349 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3350 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3351 | int workspace[8*6]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3352 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3353 | |
shoaib_ahmed | 0:791a779d6220 | 3354 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 3355 | * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). |
shoaib_ahmed | 0:791a779d6220 | 3356 | */ |
shoaib_ahmed | 0:791a779d6220 | 3357 | |
shoaib_ahmed | 0:791a779d6220 | 3358 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3359 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3360 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3361 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3362 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3363 | |
shoaib_ahmed | 0:791a779d6220 | 3364 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3365 | tmp10 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3366 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 3367 | tmp10 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 3368 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 3369 | tmp20 = MULTIPLY(tmp12, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3370 | tmp11 = tmp10 + tmp20; |
shoaib_ahmed | 0:791a779d6220 | 3371 | tmp21 = RIGHT_SHIFT(tmp10 - tmp20 - tmp20, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3372 | tmp20 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 3373 | tmp10 = MULTIPLY(tmp20, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3374 | tmp20 = tmp11 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 3375 | tmp22 = tmp11 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 3376 | |
shoaib_ahmed | 0:791a779d6220 | 3377 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3378 | |
shoaib_ahmed | 0:791a779d6220 | 3379 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3380 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 3381 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 3382 | tmp11 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3383 | tmp10 = tmp11 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3384 | tmp12 = tmp11 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3385 | tmp11 = (z1 - z2 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3386 | |
shoaib_ahmed | 0:791a779d6220 | 3387 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3388 | |
shoaib_ahmed | 0:791a779d6220 | 3389 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3390 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3391 | wsptr[8*1] = (int) (tmp21 + tmp11); |
shoaib_ahmed | 0:791a779d6220 | 3392 | wsptr[8*4] = (int) (tmp21 - tmp11); |
shoaib_ahmed | 0:791a779d6220 | 3393 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3394 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3395 | } |
shoaib_ahmed | 0:791a779d6220 | 3396 | |
shoaib_ahmed | 0:791a779d6220 | 3397 | /* Pass 2: process 6 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3398 | * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24). |
shoaib_ahmed | 0:791a779d6220 | 3399 | */ |
shoaib_ahmed | 0:791a779d6220 | 3400 | |
shoaib_ahmed | 0:791a779d6220 | 3401 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3402 | for (ctr = 0; ctr < 6; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3403 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 3404 | |
shoaib_ahmed | 0:791a779d6220 | 3405 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3406 | |
shoaib_ahmed | 0:791a779d6220 | 3407 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3408 | z3 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3409 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3410 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3411 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3412 | |
shoaib_ahmed | 0:791a779d6220 | 3413 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3414 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3415 | |
shoaib_ahmed | 0:791a779d6220 | 3416 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 3417 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 3418 | |
shoaib_ahmed | 0:791a779d6220 | 3419 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3420 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3421 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3422 | z2 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 3423 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3424 | |
shoaib_ahmed | 0:791a779d6220 | 3425 | tmp12 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 3426 | |
shoaib_ahmed | 0:791a779d6220 | 3427 | tmp21 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3428 | tmp24 = z3 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3429 | |
shoaib_ahmed | 0:791a779d6220 | 3430 | tmp12 = z4 + z2; |
shoaib_ahmed | 0:791a779d6220 | 3431 | |
shoaib_ahmed | 0:791a779d6220 | 3432 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3433 | tmp25 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3434 | |
shoaib_ahmed | 0:791a779d6220 | 3435 | tmp12 = z4 - z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 3436 | |
shoaib_ahmed | 0:791a779d6220 | 3437 | tmp22 = tmp11 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3438 | tmp23 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3439 | |
shoaib_ahmed | 0:791a779d6220 | 3440 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3441 | |
shoaib_ahmed | 0:791a779d6220 | 3442 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3443 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3444 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3445 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 3446 | |
shoaib_ahmed | 0:791a779d6220 | 3447 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3448 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3449 | |
shoaib_ahmed | 0:791a779d6220 | 3450 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3451 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3452 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3453 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3454 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
shoaib_ahmed | 0:791a779d6220 | 3455 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3456 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3457 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 3458 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3459 | |
shoaib_ahmed | 0:791a779d6220 | 3460 | z1 -= z4; |
shoaib_ahmed | 0:791a779d6220 | 3461 | z2 -= z3; |
shoaib_ahmed | 0:791a779d6220 | 3462 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3463 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3464 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3465 | |
shoaib_ahmed | 0:791a779d6220 | 3466 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3467 | |
shoaib_ahmed | 0:791a779d6220 | 3468 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3469 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3470 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3471 | outptr[11] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3472 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3473 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3474 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3475 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3476 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3477 | outptr[10] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3478 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3479 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3480 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3481 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3482 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3483 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3484 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3485 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3486 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3487 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3488 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3489 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3490 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3491 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3492 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3493 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3494 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3495 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3496 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3497 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3498 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp25 + tmp15, |
shoaib_ahmed | 0:791a779d6220 | 3499 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3500 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3501 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp25 - tmp15, |
shoaib_ahmed | 0:791a779d6220 | 3502 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3503 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3504 | |
shoaib_ahmed | 0:791a779d6220 | 3505 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3506 | } |
shoaib_ahmed | 0:791a779d6220 | 3507 | } |
shoaib_ahmed | 0:791a779d6220 | 3508 | |
shoaib_ahmed | 0:791a779d6220 | 3509 | |
shoaib_ahmed | 0:791a779d6220 | 3510 | /* |
shoaib_ahmed | 0:791a779d6220 | 3511 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3512 | * producing a 10x5 output block. |
shoaib_ahmed | 0:791a779d6220 | 3513 | * |
shoaib_ahmed | 0:791a779d6220 | 3514 | * 5-point IDCT in pass 1 (columns), 10-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3515 | */ |
shoaib_ahmed | 0:791a779d6220 | 3516 | |
shoaib_ahmed | 0:791a779d6220 | 3517 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3518 | jpeg_idct_10x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3519 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3520 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3521 | { |
shoaib_ahmed | 0:791a779d6220 | 3522 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
shoaib_ahmed | 0:791a779d6220 | 3523 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24; |
shoaib_ahmed | 0:791a779d6220 | 3524 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 3525 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3526 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3527 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3528 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3529 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3530 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3531 | int workspace[8*5]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3532 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3533 | |
shoaib_ahmed | 0:791a779d6220 | 3534 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 3535 | * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10). |
shoaib_ahmed | 0:791a779d6220 | 3536 | */ |
shoaib_ahmed | 0:791a779d6220 | 3537 | |
shoaib_ahmed | 0:791a779d6220 | 3538 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3539 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3540 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3541 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3542 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3543 | |
shoaib_ahmed | 0:791a779d6220 | 3544 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3545 | tmp12 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3546 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 3547 | tmp12 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 3548 | tmp13 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 3549 | tmp14 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 3550 | z1 = MULTIPLY(tmp13 + tmp14, FIX(0.790569415)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3551 | z2 = MULTIPLY(tmp13 - tmp14, FIX(0.353553391)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3552 | z3 = tmp12 + z2; |
shoaib_ahmed | 0:791a779d6220 | 3553 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 3554 | tmp11 = z3 - z1; |
shoaib_ahmed | 0:791a779d6220 | 3555 | tmp12 -= z2 << 2; |
shoaib_ahmed | 0:791a779d6220 | 3556 | |
shoaib_ahmed | 0:791a779d6220 | 3557 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3558 | |
shoaib_ahmed | 0:791a779d6220 | 3559 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3560 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 3561 | |
shoaib_ahmed | 0:791a779d6220 | 3562 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3563 | tmp13 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3564 | tmp14 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3565 | |
shoaib_ahmed | 0:791a779d6220 | 3566 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3567 | |
shoaib_ahmed | 0:791a779d6220 | 3568 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp10 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3569 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp10 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3570 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp11 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3571 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp11 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3572 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3573 | } |
shoaib_ahmed | 0:791a779d6220 | 3574 | |
shoaib_ahmed | 0:791a779d6220 | 3575 | /* Pass 2: process 5 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3576 | * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20). |
shoaib_ahmed | 0:791a779d6220 | 3577 | */ |
shoaib_ahmed | 0:791a779d6220 | 3578 | |
shoaib_ahmed | 0:791a779d6220 | 3579 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3580 | for (ctr = 0; ctr < 5; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3581 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 3582 | |
shoaib_ahmed | 0:791a779d6220 | 3583 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3584 | |
shoaib_ahmed | 0:791a779d6220 | 3585 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3586 | z3 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3587 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3588 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3589 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3590 | z4 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3591 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3592 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 3593 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 3594 | tmp11 = z3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 3595 | |
shoaib_ahmed | 0:791a779d6220 | 3596 | tmp22 = z3 - ((z1 - z2) << 1); /* c0 = (c4-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 3597 | |
shoaib_ahmed | 0:791a779d6220 | 3598 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3599 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 3600 | |
shoaib_ahmed | 0:791a779d6220 | 3601 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3602 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3603 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3604 | |
shoaib_ahmed | 0:791a779d6220 | 3605 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3606 | tmp24 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3607 | tmp21 = tmp11 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 3608 | tmp23 = tmp11 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 3609 | |
shoaib_ahmed | 0:791a779d6220 | 3610 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3611 | |
shoaib_ahmed | 0:791a779d6220 | 3612 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3613 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3614 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3615 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3616 | z4 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 3617 | |
shoaib_ahmed | 0:791a779d6220 | 3618 | tmp11 = z2 + z4; |
shoaib_ahmed | 0:791a779d6220 | 3619 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 3620 | |
shoaib_ahmed | 0:791a779d6220 | 3621 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3622 | |
shoaib_ahmed | 0:791a779d6220 | 3623 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3624 | z4 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3625 | |
shoaib_ahmed | 0:791a779d6220 | 3626 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3627 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 3628 | |
shoaib_ahmed | 0:791a779d6220 | 3629 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 3630 | z4 = z3 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
shoaib_ahmed | 0:791a779d6220 | 3631 | |
shoaib_ahmed | 0:791a779d6220 | 3632 | tmp12 = ((z1 - tmp13) << CONST_BITS) - z3; |
shoaib_ahmed | 0:791a779d6220 | 3633 | |
shoaib_ahmed | 0:791a779d6220 | 3634 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3635 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3636 | |
shoaib_ahmed | 0:791a779d6220 | 3637 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3638 | |
shoaib_ahmed | 0:791a779d6220 | 3639 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3640 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3641 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3642 | outptr[9] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 3643 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3644 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3645 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3646 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3647 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3648 | outptr[8] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 3649 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3650 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3651 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3652 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3653 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3654 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 3655 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3656 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3657 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3658 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3659 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3660 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp23 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 3661 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3662 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3663 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp24 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3664 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3665 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3666 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp24 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 3667 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3668 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3669 | |
shoaib_ahmed | 0:791a779d6220 | 3670 | wsptr += 8; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3671 | } |
shoaib_ahmed | 0:791a779d6220 | 3672 | } |
shoaib_ahmed | 0:791a779d6220 | 3673 | |
shoaib_ahmed | 0:791a779d6220 | 3674 | |
shoaib_ahmed | 0:791a779d6220 | 3675 | /* |
shoaib_ahmed | 0:791a779d6220 | 3676 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3677 | * producing a 8x4 output block. |
shoaib_ahmed | 0:791a779d6220 | 3678 | * |
shoaib_ahmed | 0:791a779d6220 | 3679 | * 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3680 | */ |
shoaib_ahmed | 0:791a779d6220 | 3681 | |
shoaib_ahmed | 0:791a779d6220 | 3682 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3683 | jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3684 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3685 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3686 | { |
shoaib_ahmed | 0:791a779d6220 | 3687 | INT32 tmp0, tmp1, tmp2, tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3688 | INT32 tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 3689 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 3690 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3691 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3692 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3693 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3694 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3695 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3696 | int workspace[8*4]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3697 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3698 | |
shoaib_ahmed | 0:791a779d6220 | 3699 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 3700 | * 4-point IDCT kernel, |
shoaib_ahmed | 0:791a779d6220 | 3701 | * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. |
shoaib_ahmed | 0:791a779d6220 | 3702 | */ |
shoaib_ahmed | 0:791a779d6220 | 3703 | |
shoaib_ahmed | 0:791a779d6220 | 3704 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3705 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3706 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3707 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3708 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3709 | |
shoaib_ahmed | 0:791a779d6220 | 3710 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3711 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 3712 | |
shoaib_ahmed | 0:791a779d6220 | 3713 | tmp10 = (tmp0 + tmp2) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3714 | tmp12 = (tmp0 - tmp2) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3715 | |
shoaib_ahmed | 0:791a779d6220 | 3716 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3717 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 3718 | |
shoaib_ahmed | 0:791a779d6220 | 3719 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3720 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 3721 | |
shoaib_ahmed | 0:791a779d6220 | 3722 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3723 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 3724 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 3725 | tmp0 = RIGHT_SHIFT(z1 + MULTIPLY(z2, FIX_0_765366865), /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3726 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3727 | tmp2 = RIGHT_SHIFT(z1 - MULTIPLY(z3, FIX_1_847759065), /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3728 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3729 | |
shoaib_ahmed | 0:791a779d6220 | 3730 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3731 | |
shoaib_ahmed | 0:791a779d6220 | 3732 | wsptr[8*0] = (int) (tmp10 + tmp0); |
shoaib_ahmed | 0:791a779d6220 | 3733 | wsptr[8*3] = (int) (tmp10 - tmp0); |
shoaib_ahmed | 0:791a779d6220 | 3734 | wsptr[8*1] = (int) (tmp12 + tmp2); |
shoaib_ahmed | 0:791a779d6220 | 3735 | wsptr[8*2] = (int) (tmp12 - tmp2); |
shoaib_ahmed | 0:791a779d6220 | 3736 | } |
shoaib_ahmed | 0:791a779d6220 | 3737 | |
shoaib_ahmed | 0:791a779d6220 | 3738 | /* Pass 2: process rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3739 | * Note that we must descale the results by a factor of 8 == 2**3, |
shoaib_ahmed | 0:791a779d6220 | 3740 | * and also undo the PASS1_BITS scaling. |
shoaib_ahmed | 0:791a779d6220 | 3741 | * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). |
shoaib_ahmed | 0:791a779d6220 | 3742 | */ |
shoaib_ahmed | 0:791a779d6220 | 3743 | |
shoaib_ahmed | 0:791a779d6220 | 3744 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3745 | for (ctr = 0; ctr < 4; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3746 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 3747 | |
shoaib_ahmed | 0:791a779d6220 | 3748 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 3749 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 3750 | */ |
shoaib_ahmed | 0:791a779d6220 | 3751 | |
shoaib_ahmed | 0:791a779d6220 | 3752 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3753 | z2 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3754 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3755 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3756 | z3 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3757 | |
shoaib_ahmed | 0:791a779d6220 | 3758 | tmp0 = (z2 + z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3759 | tmp1 = (z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3760 | |
shoaib_ahmed | 0:791a779d6220 | 3761 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3762 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 3763 | |
shoaib_ahmed | 0:791a779d6220 | 3764 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3765 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3766 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 3767 | |
shoaib_ahmed | 0:791a779d6220 | 3768 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3769 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3770 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3771 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3772 | |
shoaib_ahmed | 0:791a779d6220 | 3773 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 3774 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 3775 | */ |
shoaib_ahmed | 0:791a779d6220 | 3776 | |
shoaib_ahmed | 0:791a779d6220 | 3777 | tmp0 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 3778 | tmp1 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3779 | tmp2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3780 | tmp3 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3781 | |
shoaib_ahmed | 0:791a779d6220 | 3782 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 3783 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 3784 | |
shoaib_ahmed | 0:791a779d6220 | 3785 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3786 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3787 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3788 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 3789 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 3790 | |
shoaib_ahmed | 0:791a779d6220 | 3791 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3792 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3793 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3794 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 3795 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3796 | |
shoaib_ahmed | 0:791a779d6220 | 3797 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 3798 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3799 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 3800 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 3801 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 3802 | |
shoaib_ahmed | 0:791a779d6220 | 3803 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 3804 | |
shoaib_ahmed | 0:791a779d6220 | 3805 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 3806 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3807 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3808 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 3809 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3810 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3811 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3812 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3813 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3814 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3815 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3816 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3817 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3818 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3819 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3820 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3821 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3822 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3823 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3824 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3825 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3826 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3827 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3828 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3829 | |
shoaib_ahmed | 0:791a779d6220 | 3830 | wsptr += DCTSIZE; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3831 | } |
shoaib_ahmed | 0:791a779d6220 | 3832 | } |
shoaib_ahmed | 0:791a779d6220 | 3833 | |
shoaib_ahmed | 0:791a779d6220 | 3834 | |
shoaib_ahmed | 0:791a779d6220 | 3835 | /* |
shoaib_ahmed | 0:791a779d6220 | 3836 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3837 | * producing a reduced-size 6x3 output block. |
shoaib_ahmed | 0:791a779d6220 | 3838 | * |
shoaib_ahmed | 0:791a779d6220 | 3839 | * 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3840 | */ |
shoaib_ahmed | 0:791a779d6220 | 3841 | |
shoaib_ahmed | 0:791a779d6220 | 3842 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3843 | jpeg_idct_6x3 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3844 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3845 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3846 | { |
shoaib_ahmed | 0:791a779d6220 | 3847 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3848 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 3849 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3850 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3851 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3852 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3853 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3854 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3855 | int workspace[6*3]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3856 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3857 | |
shoaib_ahmed | 0:791a779d6220 | 3858 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 3859 | * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6). |
shoaib_ahmed | 0:791a779d6220 | 3860 | */ |
shoaib_ahmed | 0:791a779d6220 | 3861 | |
shoaib_ahmed | 0:791a779d6220 | 3862 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3863 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3864 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3865 | for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3866 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3867 | |
shoaib_ahmed | 0:791a779d6220 | 3868 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3869 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3870 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 3871 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 3872 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 3873 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3874 | tmp10 = tmp0 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3875 | tmp2 = tmp0 - tmp12 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3876 | |
shoaib_ahmed | 0:791a779d6220 | 3877 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3878 | |
shoaib_ahmed | 0:791a779d6220 | 3879 | tmp12 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3880 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 3881 | |
shoaib_ahmed | 0:791a779d6220 | 3882 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3883 | |
shoaib_ahmed | 0:791a779d6220 | 3884 | wsptr[6*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3885 | wsptr[6*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3886 | wsptr[6*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3887 | } |
shoaib_ahmed | 0:791a779d6220 | 3888 | |
shoaib_ahmed | 0:791a779d6220 | 3889 | /* Pass 2: process 3 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3890 | * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). |
shoaib_ahmed | 0:791a779d6220 | 3891 | */ |
shoaib_ahmed | 0:791a779d6220 | 3892 | |
shoaib_ahmed | 0:791a779d6220 | 3893 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3894 | for (ctr = 0; ctr < 3; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3895 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 3896 | |
shoaib_ahmed | 0:791a779d6220 | 3897 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3898 | |
shoaib_ahmed | 0:791a779d6220 | 3899 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 3900 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 3901 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 3902 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 3903 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3904 | tmp2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 3905 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 3906 | tmp1 = tmp0 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 3907 | tmp11 = tmp0 - tmp10 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 3908 | tmp10 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 3909 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 3910 | tmp10 = tmp1 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3911 | tmp12 = tmp1 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3912 | |
shoaib_ahmed | 0:791a779d6220 | 3913 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3914 | |
shoaib_ahmed | 0:791a779d6220 | 3915 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 3916 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 3917 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 3918 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 3919 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3920 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 3921 | tmp1 = (z1 - z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 3922 | |
shoaib_ahmed | 0:791a779d6220 | 3923 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3924 | |
shoaib_ahmed | 0:791a779d6220 | 3925 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3926 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3927 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3928 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 3929 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3930 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3931 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3932 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3933 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3934 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 3935 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3936 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3937 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3938 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3939 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3940 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 3941 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 3942 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 3943 | |
shoaib_ahmed | 0:791a779d6220 | 3944 | wsptr += 6; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 3945 | } |
shoaib_ahmed | 0:791a779d6220 | 3946 | } |
shoaib_ahmed | 0:791a779d6220 | 3947 | |
shoaib_ahmed | 0:791a779d6220 | 3948 | |
shoaib_ahmed | 0:791a779d6220 | 3949 | /* |
shoaib_ahmed | 0:791a779d6220 | 3950 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 3951 | * producing a 4x2 output block. |
shoaib_ahmed | 0:791a779d6220 | 3952 | * |
shoaib_ahmed | 0:791a779d6220 | 3953 | * 2-point IDCT in pass 1 (columns), 4-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 3954 | */ |
shoaib_ahmed | 0:791a779d6220 | 3955 | |
shoaib_ahmed | 0:791a779d6220 | 3956 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 3957 | jpeg_idct_4x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 3958 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 3959 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 3960 | { |
shoaib_ahmed | 0:791a779d6220 | 3961 | INT32 tmp0, tmp2, tmp10, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 3962 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 3963 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 3964 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 3965 | INT32 * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 3966 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 3967 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 3968 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 3969 | INT32 workspace[4*2]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 3970 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 3971 | |
shoaib_ahmed | 0:791a779d6220 | 3972 | /* Pass 1: process columns from input, store into work array. */ |
shoaib_ahmed | 0:791a779d6220 | 3973 | |
shoaib_ahmed | 0:791a779d6220 | 3974 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 3975 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 3976 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3977 | for (ctr = 0; ctr < 4; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 3978 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 3979 | |
shoaib_ahmed | 0:791a779d6220 | 3980 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 3981 | |
shoaib_ahmed | 0:791a779d6220 | 3982 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 3983 | |
shoaib_ahmed | 0:791a779d6220 | 3984 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 3985 | |
shoaib_ahmed | 0:791a779d6220 | 3986 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 3987 | |
shoaib_ahmed | 0:791a779d6220 | 3988 | wsptr[4*0] = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3989 | wsptr[4*1] = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 3990 | } |
shoaib_ahmed | 0:791a779d6220 | 3991 | |
shoaib_ahmed | 0:791a779d6220 | 3992 | /* Pass 2: process 2 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 3993 | * 4-point IDCT kernel, |
shoaib_ahmed | 0:791a779d6220 | 3994 | * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. |
shoaib_ahmed | 0:791a779d6220 | 3995 | */ |
shoaib_ahmed | 0:791a779d6220 | 3996 | |
shoaib_ahmed | 0:791a779d6220 | 3997 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 3998 | for (ctr = 0; ctr < 2; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 3999 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4000 | |
shoaib_ahmed | 0:791a779d6220 | 4001 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4002 | |
shoaib_ahmed | 0:791a779d6220 | 4003 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4004 | tmp0 = wsptr[0] + ((((INT32) RANGE_CENTER) << 3) + (ONE << 2)); |
shoaib_ahmed | 0:791a779d6220 | 4005 | tmp2 = wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4006 | |
shoaib_ahmed | 0:791a779d6220 | 4007 | tmp10 = (tmp0 + tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4008 | tmp12 = (tmp0 - tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4009 | |
shoaib_ahmed | 0:791a779d6220 | 4010 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4011 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 4012 | |
shoaib_ahmed | 0:791a779d6220 | 4013 | z2 = wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4014 | z3 = wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4015 | |
shoaib_ahmed | 0:791a779d6220 | 4016 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4017 | tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4018 | tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4019 | |
shoaib_ahmed | 0:791a779d6220 | 4020 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4021 | |
shoaib_ahmed | 0:791a779d6220 | 4022 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4023 | CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4024 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4025 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4026 | CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4027 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4028 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4029 | CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4030 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4031 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4032 | CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4033 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4034 | |
shoaib_ahmed | 0:791a779d6220 | 4035 | wsptr += 4; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 4036 | } |
shoaib_ahmed | 0:791a779d6220 | 4037 | } |
shoaib_ahmed | 0:791a779d6220 | 4038 | |
shoaib_ahmed | 0:791a779d6220 | 4039 | |
shoaib_ahmed | 0:791a779d6220 | 4040 | /* |
shoaib_ahmed | 0:791a779d6220 | 4041 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4042 | * producing a 2x1 output block. |
shoaib_ahmed | 0:791a779d6220 | 4043 | * |
shoaib_ahmed | 0:791a779d6220 | 4044 | * 1-point IDCT in pass 1 (columns), 2-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4045 | */ |
shoaib_ahmed | 0:791a779d6220 | 4046 | |
shoaib_ahmed | 0:791a779d6220 | 4047 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4048 | jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4049 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4050 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4051 | { |
shoaib_ahmed | 0:791a779d6220 | 4052 | DCTELEM tmp0, tmp1; |
shoaib_ahmed | 0:791a779d6220 | 4053 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4054 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4055 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4056 | ISHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4057 | |
shoaib_ahmed | 0:791a779d6220 | 4058 | /* Pass 1: empty. */ |
shoaib_ahmed | 0:791a779d6220 | 4059 | |
shoaib_ahmed | 0:791a779d6220 | 4060 | /* Pass 2: process 1 row from input, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 4061 | |
shoaib_ahmed | 0:791a779d6220 | 4062 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4063 | outptr = output_buf[0] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4064 | |
shoaib_ahmed | 0:791a779d6220 | 4065 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4066 | |
shoaib_ahmed | 0:791a779d6220 | 4067 | tmp0 = DEQUANTIZE(coef_block[0], quantptr[0]); |
shoaib_ahmed | 0:791a779d6220 | 4068 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4069 | tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); |
shoaib_ahmed | 0:791a779d6220 | 4070 | |
shoaib_ahmed | 0:791a779d6220 | 4071 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4072 | |
shoaib_ahmed | 0:791a779d6220 | 4073 | tmp1 = DEQUANTIZE(coef_block[1], quantptr[1]); |
shoaib_ahmed | 0:791a779d6220 | 4074 | |
shoaib_ahmed | 0:791a779d6220 | 4075 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4076 | |
shoaib_ahmed | 0:791a779d6220 | 4077 | outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4078 | outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4079 | } |
shoaib_ahmed | 0:791a779d6220 | 4080 | |
shoaib_ahmed | 0:791a779d6220 | 4081 | |
shoaib_ahmed | 0:791a779d6220 | 4082 | /* |
shoaib_ahmed | 0:791a779d6220 | 4083 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4084 | * producing a 8x16 output block. |
shoaib_ahmed | 0:791a779d6220 | 4085 | * |
shoaib_ahmed | 0:791a779d6220 | 4086 | * 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4087 | */ |
shoaib_ahmed | 0:791a779d6220 | 4088 | |
shoaib_ahmed | 0:791a779d6220 | 4089 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4090 | jpeg_idct_8x16 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4091 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4092 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4093 | { |
shoaib_ahmed | 0:791a779d6220 | 4094 | INT32 tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4095 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27; |
shoaib_ahmed | 0:791a779d6220 | 4096 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 4097 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 4098 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4099 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 4100 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4101 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4102 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 4103 | int workspace[8*16]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 4104 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4105 | |
shoaib_ahmed | 0:791a779d6220 | 4106 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 4107 | * 16-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/32). |
shoaib_ahmed | 0:791a779d6220 | 4108 | */ |
shoaib_ahmed | 0:791a779d6220 | 4109 | |
shoaib_ahmed | 0:791a779d6220 | 4110 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 4111 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4112 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4113 | for (ctr = 0; ctr < 8; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 4114 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4115 | |
shoaib_ahmed | 0:791a779d6220 | 4116 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 4117 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4118 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 4119 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 4120 | |
shoaib_ahmed | 0:791a779d6220 | 4121 | z1 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 4122 | tmp1 = MULTIPLY(z1, FIX(1.306562965)); /* c4[16] = c2[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4123 | tmp2 = MULTIPLY(z1, FIX_0_541196100); /* c12[16] = c6[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4124 | |
shoaib_ahmed | 0:791a779d6220 | 4125 | tmp10 = tmp0 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 4126 | tmp11 = tmp0 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 4127 | tmp12 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4128 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4129 | |
shoaib_ahmed | 0:791a779d6220 | 4130 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 4131 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 4132 | z3 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 4133 | z4 = MULTIPLY(z3, FIX(0.275899379)); /* c14[16] = c7[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4134 | z3 = MULTIPLY(z3, FIX(1.387039845)); /* c2[16] = c1[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4135 | |
shoaib_ahmed | 0:791a779d6220 | 4136 | tmp0 = z3 + MULTIPLY(z2, FIX_2_562915447); /* (c6+c2)[16] = (c3+c1)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4137 | tmp1 = z4 + MULTIPLY(z1, FIX_0_899976223); /* (c6-c14)[16] = (c3-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4138 | tmp2 = z3 - MULTIPLY(z1, FIX(0.601344887)); /* (c2-c10)[16] = (c1-c5)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4139 | tmp3 = z4 - MULTIPLY(z2, FIX(0.509795579)); /* (c10-c14)[16] = (c5-c7)[8] */ |
shoaib_ahmed | 0:791a779d6220 | 4140 | |
shoaib_ahmed | 0:791a779d6220 | 4141 | tmp20 = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 4142 | tmp27 = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 4143 | tmp21 = tmp12 + tmp1; |
shoaib_ahmed | 0:791a779d6220 | 4144 | tmp26 = tmp12 - tmp1; |
shoaib_ahmed | 0:791a779d6220 | 4145 | tmp22 = tmp13 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4146 | tmp25 = tmp13 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4147 | tmp23 = tmp11 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4148 | tmp24 = tmp11 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4149 | |
shoaib_ahmed | 0:791a779d6220 | 4150 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4151 | |
shoaib_ahmed | 0:791a779d6220 | 4152 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 4153 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 4154 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 4155 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 4156 | |
shoaib_ahmed | 0:791a779d6220 | 4157 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4158 | |
shoaib_ahmed | 0:791a779d6220 | 4159 | tmp1 = MULTIPLY(z1 + z2, FIX(1.353318001)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4160 | tmp2 = MULTIPLY(tmp11, FIX(1.247225013)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4161 | tmp3 = MULTIPLY(z1 + z4, FIX(1.093201867)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4162 | tmp10 = MULTIPLY(z1 - z4, FIX(0.897167586)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4163 | tmp11 = MULTIPLY(tmp11, FIX(0.666655658)); /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4164 | tmp12 = MULTIPLY(z1 - z2, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4165 | tmp0 = tmp1 + tmp2 + tmp3 - |
shoaib_ahmed | 0:791a779d6220 | 4166 | MULTIPLY(z1, FIX(2.286341144)); /* c7+c5+c3-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4167 | tmp13 = tmp10 + tmp11 + tmp12 - |
shoaib_ahmed | 0:791a779d6220 | 4168 | MULTIPLY(z1, FIX(1.835730603)); /* c9+c11+c13-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 4169 | z1 = MULTIPLY(z2 + z3, FIX(0.138617169)); /* c15 */ |
shoaib_ahmed | 0:791a779d6220 | 4170 | tmp1 += z1 + MULTIPLY(z2, FIX(0.071888074)); /* c9+c11-c3-c15 */ |
shoaib_ahmed | 0:791a779d6220 | 4171 | tmp2 += z1 - MULTIPLY(z3, FIX(1.125726048)); /* c5+c7+c15-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4172 | z1 = MULTIPLY(z3 - z2, FIX(1.407403738)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4173 | tmp11 += z1 - MULTIPLY(z3, FIX(0.766367282)); /* c1+c11-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4174 | tmp12 += z1 + MULTIPLY(z2, FIX(1.971951411)); /* c1+c5+c13-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4175 | z2 += z4; |
shoaib_ahmed | 0:791a779d6220 | 4176 | z1 = MULTIPLY(z2, - FIX(0.666655658)); /* -c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4177 | tmp1 += z1; |
shoaib_ahmed | 0:791a779d6220 | 4178 | tmp3 += z1 + MULTIPLY(z4, FIX(1.065388962)); /* c3+c11+c15-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4179 | z2 = MULTIPLY(z2, - FIX(1.247225013)); /* -c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4180 | tmp10 += z2 + MULTIPLY(z4, FIX(3.141271809)); /* c1+c5+c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4181 | tmp12 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4182 | z2 = MULTIPLY(z3 + z4, - FIX(1.353318001)); /* -c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4183 | tmp2 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4184 | tmp3 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4185 | z2 = MULTIPLY(z4 - z3, FIX(0.410524528)); /* c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4186 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4187 | tmp11 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4188 | |
shoaib_ahmed | 0:791a779d6220 | 4189 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4190 | |
shoaib_ahmed | 0:791a779d6220 | 4191 | wsptr[8*0] = (int) RIGHT_SHIFT(tmp20 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4192 | wsptr[8*15] = (int) RIGHT_SHIFT(tmp20 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4193 | wsptr[8*1] = (int) RIGHT_SHIFT(tmp21 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4194 | wsptr[8*14] = (int) RIGHT_SHIFT(tmp21 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4195 | wsptr[8*2] = (int) RIGHT_SHIFT(tmp22 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4196 | wsptr[8*13] = (int) RIGHT_SHIFT(tmp22 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4197 | wsptr[8*3] = (int) RIGHT_SHIFT(tmp23 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4198 | wsptr[8*12] = (int) RIGHT_SHIFT(tmp23 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4199 | wsptr[8*4] = (int) RIGHT_SHIFT(tmp24 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4200 | wsptr[8*11] = (int) RIGHT_SHIFT(tmp24 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4201 | wsptr[8*5] = (int) RIGHT_SHIFT(tmp25 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4202 | wsptr[8*10] = (int) RIGHT_SHIFT(tmp25 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4203 | wsptr[8*6] = (int) RIGHT_SHIFT(tmp26 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4204 | wsptr[8*9] = (int) RIGHT_SHIFT(tmp26 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4205 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4206 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4207 | } |
shoaib_ahmed | 0:791a779d6220 | 4208 | |
shoaib_ahmed | 0:791a779d6220 | 4209 | /* Pass 2: process rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 4210 | * Note that we must descale the results by a factor of 8 == 2**3, |
shoaib_ahmed | 0:791a779d6220 | 4211 | * and also undo the PASS1_BITS scaling. |
shoaib_ahmed | 0:791a779d6220 | 4212 | * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). |
shoaib_ahmed | 0:791a779d6220 | 4213 | */ |
shoaib_ahmed | 0:791a779d6220 | 4214 | |
shoaib_ahmed | 0:791a779d6220 | 4215 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4216 | for (ctr = 0; ctr < 16; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 4217 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4218 | |
shoaib_ahmed | 0:791a779d6220 | 4219 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 4220 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 4221 | */ |
shoaib_ahmed | 0:791a779d6220 | 4222 | |
shoaib_ahmed | 0:791a779d6220 | 4223 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4224 | z2 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 4225 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 4226 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 4227 | z3 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 4228 | |
shoaib_ahmed | 0:791a779d6220 | 4229 | tmp0 = (z2 + z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4230 | tmp1 = (z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4231 | |
shoaib_ahmed | 0:791a779d6220 | 4232 | z2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4233 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 4234 | |
shoaib_ahmed | 0:791a779d6220 | 4235 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4236 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4237 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4238 | |
shoaib_ahmed | 0:791a779d6220 | 4239 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4240 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4241 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4242 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4243 | |
shoaib_ahmed | 0:791a779d6220 | 4244 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 4245 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 4246 | */ |
shoaib_ahmed | 0:791a779d6220 | 4247 | |
shoaib_ahmed | 0:791a779d6220 | 4248 | tmp0 = (INT32) wsptr[7]; |
shoaib_ahmed | 0:791a779d6220 | 4249 | tmp1 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 4250 | tmp2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4251 | tmp3 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4252 | |
shoaib_ahmed | 0:791a779d6220 | 4253 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4254 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4255 | |
shoaib_ahmed | 0:791a779d6220 | 4256 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4257 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4258 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4259 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 4260 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 4261 | |
shoaib_ahmed | 0:791a779d6220 | 4262 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4263 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4264 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4265 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4266 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4267 | |
shoaib_ahmed | 0:791a779d6220 | 4268 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4269 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4270 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4271 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4272 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4273 | |
shoaib_ahmed | 0:791a779d6220 | 4274 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 4275 | |
shoaib_ahmed | 0:791a779d6220 | 4276 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, |
shoaib_ahmed | 0:791a779d6220 | 4277 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4278 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4279 | outptr[7] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp3, |
shoaib_ahmed | 0:791a779d6220 | 4280 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4281 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4282 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4283 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4284 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4285 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4286 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4287 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4288 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp1, |
shoaib_ahmed | 0:791a779d6220 | 4289 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4290 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4291 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp1, |
shoaib_ahmed | 0:791a779d6220 | 4292 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4293 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4294 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp13 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4295 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4296 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4297 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4298 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4299 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4300 | |
shoaib_ahmed | 0:791a779d6220 | 4301 | wsptr += DCTSIZE; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 4302 | } |
shoaib_ahmed | 0:791a779d6220 | 4303 | } |
shoaib_ahmed | 0:791a779d6220 | 4304 | |
shoaib_ahmed | 0:791a779d6220 | 4305 | |
shoaib_ahmed | 0:791a779d6220 | 4306 | /* |
shoaib_ahmed | 0:791a779d6220 | 4307 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4308 | * producing a 7x14 output block. |
shoaib_ahmed | 0:791a779d6220 | 4309 | * |
shoaib_ahmed | 0:791a779d6220 | 4310 | * 14-point IDCT in pass 1 (columns), 7-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4311 | */ |
shoaib_ahmed | 0:791a779d6220 | 4312 | |
shoaib_ahmed | 0:791a779d6220 | 4313 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4314 | jpeg_idct_7x14 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4315 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4316 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4317 | { |
shoaib_ahmed | 0:791a779d6220 | 4318 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16; |
shoaib_ahmed | 0:791a779d6220 | 4319 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26; |
shoaib_ahmed | 0:791a779d6220 | 4320 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 4321 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 4322 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4323 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 4324 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4325 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4326 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 4327 | int workspace[7*14]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 4328 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4329 | |
shoaib_ahmed | 0:791a779d6220 | 4330 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 4331 | * 14-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/28). |
shoaib_ahmed | 0:791a779d6220 | 4332 | */ |
shoaib_ahmed | 0:791a779d6220 | 4333 | |
shoaib_ahmed | 0:791a779d6220 | 4334 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 4335 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4336 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4337 | for (ctr = 0; ctr < 7; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 4338 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4339 | |
shoaib_ahmed | 0:791a779d6220 | 4340 | z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 4341 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4342 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 4343 | z1 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 4344 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 4345 | z2 = MULTIPLY(z4, FIX(1.274162392)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 4346 | z3 = MULTIPLY(z4, FIX(0.314692123)); /* c12 */ |
shoaib_ahmed | 0:791a779d6220 | 4347 | z4 = MULTIPLY(z4, FIX(0.881747734)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 4348 | |
shoaib_ahmed | 0:791a779d6220 | 4349 | tmp10 = z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4350 | tmp11 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4351 | tmp12 = z1 - z4; |
shoaib_ahmed | 0:791a779d6220 | 4352 | |
shoaib_ahmed | 0:791a779d6220 | 4353 | tmp23 = RIGHT_SHIFT(z1 - ((z2 + z3 - z4) << 1), /* c0 = (c4+c12-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 4354 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4355 | |
shoaib_ahmed | 0:791a779d6220 | 4356 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 4357 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 4358 | |
shoaib_ahmed | 0:791a779d6220 | 4359 | z3 = MULTIPLY(z1 + z2, FIX(1.105676686)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4360 | |
shoaib_ahmed | 0:791a779d6220 | 4361 | tmp13 = z3 + MULTIPLY(z1, FIX(0.273079590)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4362 | tmp14 = z3 - MULTIPLY(z2, FIX(1.719280954)); /* c6+c10 */ |
shoaib_ahmed | 0:791a779d6220 | 4363 | tmp15 = MULTIPLY(z1, FIX(0.613604268)) - /* c10 */ |
shoaib_ahmed | 0:791a779d6220 | 4364 | MULTIPLY(z2, FIX(1.378756276)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 4365 | |
shoaib_ahmed | 0:791a779d6220 | 4366 | tmp20 = tmp10 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4367 | tmp26 = tmp10 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4368 | tmp21 = tmp11 + tmp14; |
shoaib_ahmed | 0:791a779d6220 | 4369 | tmp25 = tmp11 - tmp14; |
shoaib_ahmed | 0:791a779d6220 | 4370 | tmp22 = tmp12 + tmp15; |
shoaib_ahmed | 0:791a779d6220 | 4371 | tmp24 = tmp12 - tmp15; |
shoaib_ahmed | 0:791a779d6220 | 4372 | |
shoaib_ahmed | 0:791a779d6220 | 4373 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4374 | |
shoaib_ahmed | 0:791a779d6220 | 4375 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 4376 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 4377 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 4378 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 4379 | tmp13 = z4 << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4380 | |
shoaib_ahmed | 0:791a779d6220 | 4381 | tmp14 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4382 | tmp11 = MULTIPLY(z1 + z2, FIX(1.334852607)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4383 | tmp12 = MULTIPLY(tmp14, FIX(1.197448846)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4384 | tmp10 = tmp11 + tmp12 + tmp13 - MULTIPLY(z1, FIX(1.126980169)); /* c3+c5-c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4385 | tmp14 = MULTIPLY(tmp14, FIX(0.752406978)); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4386 | tmp16 = tmp14 - MULTIPLY(z1, FIX(1.061150426)); /* c9+c11-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4387 | z1 -= z2; |
shoaib_ahmed | 0:791a779d6220 | 4388 | tmp15 = MULTIPLY(z1, FIX(0.467085129)) - tmp13; /* c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4389 | tmp16 += tmp15; |
shoaib_ahmed | 0:791a779d6220 | 4390 | z1 += z4; |
shoaib_ahmed | 0:791a779d6220 | 4391 | z4 = MULTIPLY(z2 + z3, - FIX(0.158341681)) - tmp13; /* -c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4392 | tmp11 += z4 - MULTIPLY(z2, FIX(0.424103948)); /* c3-c9-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4393 | tmp12 += z4 - MULTIPLY(z3, FIX(2.373959773)); /* c3+c5-c13 */ |
shoaib_ahmed | 0:791a779d6220 | 4394 | z4 = MULTIPLY(z3 - z2, FIX(1.405321284)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4395 | tmp14 += z4 + tmp13 - MULTIPLY(z3, FIX(1.6906431334)); /* c1+c9-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4396 | tmp15 += z4 + MULTIPLY(z2, FIX(0.674957567)); /* c1+c11-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4397 | |
shoaib_ahmed | 0:791a779d6220 | 4398 | tmp13 = (z1 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4399 | |
shoaib_ahmed | 0:791a779d6220 | 4400 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4401 | |
shoaib_ahmed | 0:791a779d6220 | 4402 | wsptr[7*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4403 | wsptr[7*13] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4404 | wsptr[7*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4405 | wsptr[7*12] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4406 | wsptr[7*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4407 | wsptr[7*11] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4408 | wsptr[7*3] = (int) (tmp23 + tmp13); |
shoaib_ahmed | 0:791a779d6220 | 4409 | wsptr[7*10] = (int) (tmp23 - tmp13); |
shoaib_ahmed | 0:791a779d6220 | 4410 | wsptr[7*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4411 | wsptr[7*9] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4412 | wsptr[7*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4413 | wsptr[7*8] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4414 | wsptr[7*6] = (int) RIGHT_SHIFT(tmp26 + tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4415 | wsptr[7*7] = (int) RIGHT_SHIFT(tmp26 - tmp16, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4416 | } |
shoaib_ahmed | 0:791a779d6220 | 4417 | |
shoaib_ahmed | 0:791a779d6220 | 4418 | /* Pass 2: process 14 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 4419 | * 7-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/14). |
shoaib_ahmed | 0:791a779d6220 | 4420 | */ |
shoaib_ahmed | 0:791a779d6220 | 4421 | |
shoaib_ahmed | 0:791a779d6220 | 4422 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4423 | for (ctr = 0; ctr < 14; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 4424 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4425 | |
shoaib_ahmed | 0:791a779d6220 | 4426 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4427 | |
shoaib_ahmed | 0:791a779d6220 | 4428 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4429 | tmp23 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 4430 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 4431 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 4432 | tmp23 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4433 | |
shoaib_ahmed | 0:791a779d6220 | 4434 | z1 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4435 | z2 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 4436 | z3 = (INT32) wsptr[6]; |
shoaib_ahmed | 0:791a779d6220 | 4437 | |
shoaib_ahmed | 0:791a779d6220 | 4438 | tmp20 = MULTIPLY(z2 - z3, FIX(0.881747734)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 4439 | tmp22 = MULTIPLY(z1 - z2, FIX(0.314692123)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4440 | tmp21 = tmp20 + tmp22 + tmp23 - MULTIPLY(z2, FIX(1.841218003)); /* c2+c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4441 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4442 | z2 -= tmp10; |
shoaib_ahmed | 0:791a779d6220 | 4443 | tmp10 = MULTIPLY(tmp10, FIX(1.274162392)) + tmp23; /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 4444 | tmp20 += tmp10 - MULTIPLY(z3, FIX(0.077722536)); /* c2-c4-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4445 | tmp22 += tmp10 - MULTIPLY(z1, FIX(2.470602249)); /* c2+c4+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4446 | tmp23 += MULTIPLY(z2, FIX(1.414213562)); /* c0 */ |
shoaib_ahmed | 0:791a779d6220 | 4447 | |
shoaib_ahmed | 0:791a779d6220 | 4448 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4449 | |
shoaib_ahmed | 0:791a779d6220 | 4450 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4451 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4452 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 4453 | |
shoaib_ahmed | 0:791a779d6220 | 4454 | tmp11 = MULTIPLY(z1 + z2, FIX(0.935414347)); /* (c3+c1-c5)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4455 | tmp12 = MULTIPLY(z1 - z2, FIX(0.170262339)); /* (c3+c5-c1)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4456 | tmp10 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4457 | tmp11 += tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4458 | tmp12 = MULTIPLY(z2 + z3, - FIX(1.378756276)); /* -c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4459 | tmp11 += tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4460 | z2 = MULTIPLY(z1 + z3, FIX(0.613604268)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4461 | tmp10 += z2; |
shoaib_ahmed | 0:791a779d6220 | 4462 | tmp12 += z2 + MULTIPLY(z3, FIX(1.870828693)); /* c3+c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4463 | |
shoaib_ahmed | 0:791a779d6220 | 4464 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4465 | |
shoaib_ahmed | 0:791a779d6220 | 4466 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 4467 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4468 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4469 | outptr[6] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 4470 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4471 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4472 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 4473 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4474 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4475 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 4476 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4477 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4478 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 4479 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4480 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4481 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 4482 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4483 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4484 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp23, |
shoaib_ahmed | 0:791a779d6220 | 4485 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4486 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4487 | |
shoaib_ahmed | 0:791a779d6220 | 4488 | wsptr += 7; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 4489 | } |
shoaib_ahmed | 0:791a779d6220 | 4490 | } |
shoaib_ahmed | 0:791a779d6220 | 4491 | |
shoaib_ahmed | 0:791a779d6220 | 4492 | |
shoaib_ahmed | 0:791a779d6220 | 4493 | /* |
shoaib_ahmed | 0:791a779d6220 | 4494 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4495 | * producing a 6x12 output block. |
shoaib_ahmed | 0:791a779d6220 | 4496 | * |
shoaib_ahmed | 0:791a779d6220 | 4497 | * 12-point IDCT in pass 1 (columns), 6-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4498 | */ |
shoaib_ahmed | 0:791a779d6220 | 4499 | |
shoaib_ahmed | 0:791a779d6220 | 4500 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4501 | jpeg_idct_6x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4502 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4503 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4504 | { |
shoaib_ahmed | 0:791a779d6220 | 4505 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14, tmp15; |
shoaib_ahmed | 0:791a779d6220 | 4506 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24, tmp25; |
shoaib_ahmed | 0:791a779d6220 | 4507 | INT32 z1, z2, z3, z4; |
shoaib_ahmed | 0:791a779d6220 | 4508 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 4509 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4510 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 4511 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4512 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4513 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 4514 | int workspace[6*12]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 4515 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4516 | |
shoaib_ahmed | 0:791a779d6220 | 4517 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 4518 | * 12-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/24). |
shoaib_ahmed | 0:791a779d6220 | 4519 | */ |
shoaib_ahmed | 0:791a779d6220 | 4520 | |
shoaib_ahmed | 0:791a779d6220 | 4521 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 4522 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4523 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4524 | for (ctr = 0; ctr < 6; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 4525 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4526 | |
shoaib_ahmed | 0:791a779d6220 | 4527 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 4528 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4529 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 4530 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 4531 | |
shoaib_ahmed | 0:791a779d6220 | 4532 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 4533 | z4 = MULTIPLY(z4, FIX(1.224744871)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 4534 | |
shoaib_ahmed | 0:791a779d6220 | 4535 | tmp10 = z3 + z4; |
shoaib_ahmed | 0:791a779d6220 | 4536 | tmp11 = z3 - z4; |
shoaib_ahmed | 0:791a779d6220 | 4537 | |
shoaib_ahmed | 0:791a779d6220 | 4538 | z1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 4539 | z4 = MULTIPLY(z1, FIX(1.366025404)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 4540 | z1 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4541 | z2 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 4542 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4543 | |
shoaib_ahmed | 0:791a779d6220 | 4544 | tmp12 = z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 4545 | |
shoaib_ahmed | 0:791a779d6220 | 4546 | tmp21 = z3 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4547 | tmp24 = z3 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4548 | |
shoaib_ahmed | 0:791a779d6220 | 4549 | tmp12 = z4 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4550 | |
shoaib_ahmed | 0:791a779d6220 | 4551 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4552 | tmp25 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4553 | |
shoaib_ahmed | 0:791a779d6220 | 4554 | tmp12 = z4 - z1 - z2; |
shoaib_ahmed | 0:791a779d6220 | 4555 | |
shoaib_ahmed | 0:791a779d6220 | 4556 | tmp22 = tmp11 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4557 | tmp23 = tmp11 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4558 | |
shoaib_ahmed | 0:791a779d6220 | 4559 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4560 | |
shoaib_ahmed | 0:791a779d6220 | 4561 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 4562 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 4563 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 4564 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 4565 | |
shoaib_ahmed | 0:791a779d6220 | 4566 | tmp11 = MULTIPLY(z2, FIX(1.306562965)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4567 | tmp14 = MULTIPLY(z2, - FIX_0_541196100); /* -c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4568 | |
shoaib_ahmed | 0:791a779d6220 | 4569 | tmp10 = z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4570 | tmp15 = MULTIPLY(tmp10 + z4, FIX(0.860918669)); /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4571 | tmp12 = tmp15 + MULTIPLY(tmp10, FIX(0.261052384)); /* c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4572 | tmp10 = tmp12 + tmp11 + MULTIPLY(z1, FIX(0.280143716)); /* c1-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4573 | tmp13 = MULTIPLY(z3 + z4, - FIX(1.045510580)); /* -(c7+c11) */ |
shoaib_ahmed | 0:791a779d6220 | 4574 | tmp12 += tmp13 + tmp14 - MULTIPLY(z3, FIX(1.478575242)); /* c1+c5-c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4575 | tmp13 += tmp15 - tmp11 + MULTIPLY(z4, FIX(1.586706681)); /* c1+c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4576 | tmp15 += tmp14 - MULTIPLY(z1, FIX(0.676326758)) - /* c7-c11 */ |
shoaib_ahmed | 0:791a779d6220 | 4577 | MULTIPLY(z4, FIX(1.982889723)); /* c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4578 | |
shoaib_ahmed | 0:791a779d6220 | 4579 | z1 -= z4; |
shoaib_ahmed | 0:791a779d6220 | 4580 | z2 -= z3; |
shoaib_ahmed | 0:791a779d6220 | 4581 | z3 = MULTIPLY(z1 + z2, FIX_0_541196100); /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4582 | tmp11 = z3 + MULTIPLY(z1, FIX_0_765366865); /* c3-c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4583 | tmp14 = z3 - MULTIPLY(z2, FIX_1_847759065); /* c3+c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4584 | |
shoaib_ahmed | 0:791a779d6220 | 4585 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4586 | |
shoaib_ahmed | 0:791a779d6220 | 4587 | wsptr[6*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4588 | wsptr[6*11] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4589 | wsptr[6*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4590 | wsptr[6*10] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4591 | wsptr[6*2] = (int) RIGHT_SHIFT(tmp22 + tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4592 | wsptr[6*9] = (int) RIGHT_SHIFT(tmp22 - tmp12, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4593 | wsptr[6*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4594 | wsptr[6*8] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4595 | wsptr[6*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4596 | wsptr[6*7] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4597 | wsptr[6*5] = (int) RIGHT_SHIFT(tmp25 + tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4598 | wsptr[6*6] = (int) RIGHT_SHIFT(tmp25 - tmp15, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4599 | } |
shoaib_ahmed | 0:791a779d6220 | 4600 | |
shoaib_ahmed | 0:791a779d6220 | 4601 | /* Pass 2: process 12 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 4602 | * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). |
shoaib_ahmed | 0:791a779d6220 | 4603 | */ |
shoaib_ahmed | 0:791a779d6220 | 4604 | |
shoaib_ahmed | 0:791a779d6220 | 4605 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4606 | for (ctr = 0; ctr < 12; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 4607 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4608 | |
shoaib_ahmed | 0:791a779d6220 | 4609 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4610 | |
shoaib_ahmed | 0:791a779d6220 | 4611 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4612 | tmp10 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 4613 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 4614 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 4615 | tmp10 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4616 | tmp12 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 4617 | tmp20 = MULTIPLY(tmp12, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 4618 | tmp11 = tmp10 + tmp20; |
shoaib_ahmed | 0:791a779d6220 | 4619 | tmp21 = tmp10 - tmp20 - tmp20; |
shoaib_ahmed | 0:791a779d6220 | 4620 | tmp20 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4621 | tmp10 = MULTIPLY(tmp20, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 4622 | tmp20 = tmp11 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 4623 | tmp22 = tmp11 - tmp10; |
shoaib_ahmed | 0:791a779d6220 | 4624 | |
shoaib_ahmed | 0:791a779d6220 | 4625 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4626 | |
shoaib_ahmed | 0:791a779d6220 | 4627 | z1 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4628 | z2 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4629 | z3 = (INT32) wsptr[5]; |
shoaib_ahmed | 0:791a779d6220 | 4630 | tmp11 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4631 | tmp10 = tmp11 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4632 | tmp12 = tmp11 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4633 | tmp11 = (z1 - z2 - z3) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4634 | |
shoaib_ahmed | 0:791a779d6220 | 4635 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4636 | |
shoaib_ahmed | 0:791a779d6220 | 4637 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp20 + tmp10, |
shoaib_ahmed | 0:791a779d6220 | 4638 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4639 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4640 | outptr[5] = range_limit[(int) RIGHT_SHIFT(tmp20 - tmp10, |
shoaib_ahmed | 0:791a779d6220 | 4641 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4642 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4643 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp21 + tmp11, |
shoaib_ahmed | 0:791a779d6220 | 4644 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4645 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4646 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp21 - tmp11, |
shoaib_ahmed | 0:791a779d6220 | 4647 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4648 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4649 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp22 + tmp12, |
shoaib_ahmed | 0:791a779d6220 | 4650 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4651 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4652 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp22 - tmp12, |
shoaib_ahmed | 0:791a779d6220 | 4653 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4654 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4655 | |
shoaib_ahmed | 0:791a779d6220 | 4656 | wsptr += 6; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 4657 | } |
shoaib_ahmed | 0:791a779d6220 | 4658 | } |
shoaib_ahmed | 0:791a779d6220 | 4659 | |
shoaib_ahmed | 0:791a779d6220 | 4660 | |
shoaib_ahmed | 0:791a779d6220 | 4661 | /* |
shoaib_ahmed | 0:791a779d6220 | 4662 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4663 | * producing a 5x10 output block. |
shoaib_ahmed | 0:791a779d6220 | 4664 | * |
shoaib_ahmed | 0:791a779d6220 | 4665 | * 10-point IDCT in pass 1 (columns), 5-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4666 | */ |
shoaib_ahmed | 0:791a779d6220 | 4667 | |
shoaib_ahmed | 0:791a779d6220 | 4668 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4669 | jpeg_idct_5x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4670 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4671 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4672 | { |
shoaib_ahmed | 0:791a779d6220 | 4673 | INT32 tmp10, tmp11, tmp12, tmp13, tmp14; |
shoaib_ahmed | 0:791a779d6220 | 4674 | INT32 tmp20, tmp21, tmp22, tmp23, tmp24; |
shoaib_ahmed | 0:791a779d6220 | 4675 | INT32 z1, z2, z3, z4, z5; |
shoaib_ahmed | 0:791a779d6220 | 4676 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 4677 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4678 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 4679 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4680 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4681 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 4682 | int workspace[5*10]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 4683 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4684 | |
shoaib_ahmed | 0:791a779d6220 | 4685 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 4686 | * 10-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/20). |
shoaib_ahmed | 0:791a779d6220 | 4687 | */ |
shoaib_ahmed | 0:791a779d6220 | 4688 | |
shoaib_ahmed | 0:791a779d6220 | 4689 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 4690 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4691 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4692 | for (ctr = 0; ctr < 5; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 4693 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4694 | |
shoaib_ahmed | 0:791a779d6220 | 4695 | z3 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 4696 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4697 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 4698 | z3 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 4699 | z4 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 4700 | z1 = MULTIPLY(z4, FIX(1.144122806)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 4701 | z2 = MULTIPLY(z4, FIX(0.437016024)); /* c8 */ |
shoaib_ahmed | 0:791a779d6220 | 4702 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 4703 | tmp11 = z3 - z2; |
shoaib_ahmed | 0:791a779d6220 | 4704 | |
shoaib_ahmed | 0:791a779d6220 | 4705 | tmp22 = RIGHT_SHIFT(z3 - ((z1 - z2) << 1), /* c0 = (c4-c8)*2 */ |
shoaib_ahmed | 0:791a779d6220 | 4706 | CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4707 | |
shoaib_ahmed | 0:791a779d6220 | 4708 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 4709 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 4710 | |
shoaib_ahmed | 0:791a779d6220 | 4711 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4712 | tmp12 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4713 | tmp13 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4714 | |
shoaib_ahmed | 0:791a779d6220 | 4715 | tmp20 = tmp10 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4716 | tmp24 = tmp10 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4717 | tmp21 = tmp11 + tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4718 | tmp23 = tmp11 - tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4719 | |
shoaib_ahmed | 0:791a779d6220 | 4720 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4721 | |
shoaib_ahmed | 0:791a779d6220 | 4722 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 4723 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 4724 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 4725 | z4 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 4726 | |
shoaib_ahmed | 0:791a779d6220 | 4727 | tmp11 = z2 + z4; |
shoaib_ahmed | 0:791a779d6220 | 4728 | tmp13 = z2 - z4; |
shoaib_ahmed | 0:791a779d6220 | 4729 | |
shoaib_ahmed | 0:791a779d6220 | 4730 | tmp12 = MULTIPLY(tmp13, FIX(0.309016994)); /* (c3-c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4731 | z5 = z3 << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4732 | |
shoaib_ahmed | 0:791a779d6220 | 4733 | z2 = MULTIPLY(tmp11, FIX(0.951056516)); /* (c3+c7)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4734 | z4 = z5 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 4735 | |
shoaib_ahmed | 0:791a779d6220 | 4736 | tmp10 = MULTIPLY(z1, FIX(1.396802247)) + z2 + z4; /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 4737 | tmp14 = MULTIPLY(z1, FIX(0.221231742)) - z2 + z4; /* c9 */ |
shoaib_ahmed | 0:791a779d6220 | 4738 | |
shoaib_ahmed | 0:791a779d6220 | 4739 | z2 = MULTIPLY(tmp11, FIX(0.587785252)); /* (c1-c9)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4740 | z4 = z5 - tmp12 - (tmp13 << (CONST_BITS - 1)); |
shoaib_ahmed | 0:791a779d6220 | 4741 | |
shoaib_ahmed | 0:791a779d6220 | 4742 | tmp12 = (z1 - tmp13 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4743 | |
shoaib_ahmed | 0:791a779d6220 | 4744 | tmp11 = MULTIPLY(z1, FIX(1.260073511)) - z2 - z4; /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4745 | tmp13 = MULTIPLY(z1, FIX(0.642039522)) - z2 + z4; /* c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4746 | |
shoaib_ahmed | 0:791a779d6220 | 4747 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4748 | |
shoaib_ahmed | 0:791a779d6220 | 4749 | wsptr[5*0] = (int) RIGHT_SHIFT(tmp20 + tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4750 | wsptr[5*9] = (int) RIGHT_SHIFT(tmp20 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4751 | wsptr[5*1] = (int) RIGHT_SHIFT(tmp21 + tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4752 | wsptr[5*8] = (int) RIGHT_SHIFT(tmp21 - tmp11, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4753 | wsptr[5*2] = (int) (tmp22 + tmp12); |
shoaib_ahmed | 0:791a779d6220 | 4754 | wsptr[5*7] = (int) (tmp22 - tmp12); |
shoaib_ahmed | 0:791a779d6220 | 4755 | wsptr[5*3] = (int) RIGHT_SHIFT(tmp23 + tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4756 | wsptr[5*6] = (int) RIGHT_SHIFT(tmp23 - tmp13, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4757 | wsptr[5*4] = (int) RIGHT_SHIFT(tmp24 + tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4758 | wsptr[5*5] = (int) RIGHT_SHIFT(tmp24 - tmp14, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4759 | } |
shoaib_ahmed | 0:791a779d6220 | 4760 | |
shoaib_ahmed | 0:791a779d6220 | 4761 | /* Pass 2: process 10 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 4762 | * 5-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/10). |
shoaib_ahmed | 0:791a779d6220 | 4763 | */ |
shoaib_ahmed | 0:791a779d6220 | 4764 | |
shoaib_ahmed | 0:791a779d6220 | 4765 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4766 | for (ctr = 0; ctr < 10; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 4767 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4768 | |
shoaib_ahmed | 0:791a779d6220 | 4769 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4770 | |
shoaib_ahmed | 0:791a779d6220 | 4771 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4772 | tmp12 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 4773 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 4774 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 4775 | tmp12 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4776 | tmp13 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4777 | tmp14 = (INT32) wsptr[4]; |
shoaib_ahmed | 0:791a779d6220 | 4778 | z1 = MULTIPLY(tmp13 + tmp14, FIX(0.790569415)); /* (c2+c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4779 | z2 = MULTIPLY(tmp13 - tmp14, FIX(0.353553391)); /* (c2-c4)/2 */ |
shoaib_ahmed | 0:791a779d6220 | 4780 | z3 = tmp12 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4781 | tmp10 = z3 + z1; |
shoaib_ahmed | 0:791a779d6220 | 4782 | tmp11 = z3 - z1; |
shoaib_ahmed | 0:791a779d6220 | 4783 | tmp12 -= z2 << 2; |
shoaib_ahmed | 0:791a779d6220 | 4784 | |
shoaib_ahmed | 0:791a779d6220 | 4785 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4786 | |
shoaib_ahmed | 0:791a779d6220 | 4787 | z2 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4788 | z3 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4789 | |
shoaib_ahmed | 0:791a779d6220 | 4790 | z1 = MULTIPLY(z2 + z3, FIX(0.831253876)); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4791 | tmp13 = z1 + MULTIPLY(z2, FIX(0.513743148)); /* c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4792 | tmp14 = z1 - MULTIPLY(z3, FIX(2.176250899)); /* c1+c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4793 | |
shoaib_ahmed | 0:791a779d6220 | 4794 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4795 | |
shoaib_ahmed | 0:791a779d6220 | 4796 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp13, |
shoaib_ahmed | 0:791a779d6220 | 4797 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4798 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4799 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp13, |
shoaib_ahmed | 0:791a779d6220 | 4800 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4801 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4802 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp11 + tmp14, |
shoaib_ahmed | 0:791a779d6220 | 4803 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4804 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4805 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp11 - tmp14, |
shoaib_ahmed | 0:791a779d6220 | 4806 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4807 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4808 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12, |
shoaib_ahmed | 0:791a779d6220 | 4809 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4810 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4811 | |
shoaib_ahmed | 0:791a779d6220 | 4812 | wsptr += 5; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 4813 | } |
shoaib_ahmed | 0:791a779d6220 | 4814 | } |
shoaib_ahmed | 0:791a779d6220 | 4815 | |
shoaib_ahmed | 0:791a779d6220 | 4816 | |
shoaib_ahmed | 0:791a779d6220 | 4817 | /* |
shoaib_ahmed | 0:791a779d6220 | 4818 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 4819 | * producing a 4x8 output block. |
shoaib_ahmed | 0:791a779d6220 | 4820 | * |
shoaib_ahmed | 0:791a779d6220 | 4821 | * 8-point IDCT in pass 1 (columns), 4-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 4822 | */ |
shoaib_ahmed | 0:791a779d6220 | 4823 | |
shoaib_ahmed | 0:791a779d6220 | 4824 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 4825 | jpeg_idct_4x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 4826 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 4827 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 4828 | { |
shoaib_ahmed | 0:791a779d6220 | 4829 | INT32 tmp0, tmp1, tmp2, tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4830 | INT32 tmp10, tmp11, tmp12, tmp13; |
shoaib_ahmed | 0:791a779d6220 | 4831 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 4832 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 4833 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 4834 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 4835 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 4836 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 4837 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 4838 | int workspace[4*8]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 4839 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 4840 | |
shoaib_ahmed | 0:791a779d6220 | 4841 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 4842 | * Note results are scaled up by sqrt(8) compared to a true IDCT; |
shoaib_ahmed | 0:791a779d6220 | 4843 | * furthermore, we scale the results by 2**PASS1_BITS. |
shoaib_ahmed | 0:791a779d6220 | 4844 | * 8-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/16). |
shoaib_ahmed | 0:791a779d6220 | 4845 | */ |
shoaib_ahmed | 0:791a779d6220 | 4846 | |
shoaib_ahmed | 0:791a779d6220 | 4847 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 4848 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 4849 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4850 | for (ctr = 4; ctr > 0; ctr--) { |
shoaib_ahmed | 0:791a779d6220 | 4851 | /* Due to quantization, we will usually find that many of the input |
shoaib_ahmed | 0:791a779d6220 | 4852 | * coefficients are zero, especially the AC terms. We can exploit this |
shoaib_ahmed | 0:791a779d6220 | 4853 | * by short-circuiting the IDCT calculation for any column in which all |
shoaib_ahmed | 0:791a779d6220 | 4854 | * the AC terms are zero. In that case each output is equal to the |
shoaib_ahmed | 0:791a779d6220 | 4855 | * DC coefficient (with scale factor as needed). |
shoaib_ahmed | 0:791a779d6220 | 4856 | * With typical images and quantization tables, half or more of the |
shoaib_ahmed | 0:791a779d6220 | 4857 | * column DCT calculations can be simplified this way. |
shoaib_ahmed | 0:791a779d6220 | 4858 | */ |
shoaib_ahmed | 0:791a779d6220 | 4859 | |
shoaib_ahmed | 0:791a779d6220 | 4860 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 4861 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 4862 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
shoaib_ahmed | 0:791a779d6220 | 4863 | inptr[DCTSIZE*7] == 0) { |
shoaib_ahmed | 0:791a779d6220 | 4864 | /* AC terms all zero */ |
shoaib_ahmed | 0:791a779d6220 | 4865 | int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4866 | |
shoaib_ahmed | 0:791a779d6220 | 4867 | wsptr[4*0] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4868 | wsptr[4*1] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4869 | wsptr[4*2] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4870 | wsptr[4*3] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4871 | wsptr[4*4] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4872 | wsptr[4*5] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4873 | wsptr[4*6] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4874 | wsptr[4*7] = dcval; |
shoaib_ahmed | 0:791a779d6220 | 4875 | |
shoaib_ahmed | 0:791a779d6220 | 4876 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 4877 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 4878 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 4879 | continue; |
shoaib_ahmed | 0:791a779d6220 | 4880 | } |
shoaib_ahmed | 0:791a779d6220 | 4881 | |
shoaib_ahmed | 0:791a779d6220 | 4882 | /* Even part: reverse the even part of the forward DCT. |
shoaib_ahmed | 0:791a779d6220 | 4883 | * The rotator is c(-6). |
shoaib_ahmed | 0:791a779d6220 | 4884 | */ |
shoaib_ahmed | 0:791a779d6220 | 4885 | |
shoaib_ahmed | 0:791a779d6220 | 4886 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 4887 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
shoaib_ahmed | 0:791a779d6220 | 4888 | |
shoaib_ahmed | 0:791a779d6220 | 4889 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4890 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4891 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4892 | |
shoaib_ahmed | 0:791a779d6220 | 4893 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 4894 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 4895 | z2 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4896 | z3 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4897 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 4898 | z2 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 4899 | |
shoaib_ahmed | 0:791a779d6220 | 4900 | tmp0 = z2 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4901 | tmp1 = z2 - z3; |
shoaib_ahmed | 0:791a779d6220 | 4902 | |
shoaib_ahmed | 0:791a779d6220 | 4903 | tmp10 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4904 | tmp13 = tmp0 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4905 | tmp11 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4906 | tmp12 = tmp1 - tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4907 | |
shoaib_ahmed | 0:791a779d6220 | 4908 | /* Odd part per figure 8; the matrix is unitary and hence its |
shoaib_ahmed | 0:791a779d6220 | 4909 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
shoaib_ahmed | 0:791a779d6220 | 4910 | */ |
shoaib_ahmed | 0:791a779d6220 | 4911 | |
shoaib_ahmed | 0:791a779d6220 | 4912 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
shoaib_ahmed | 0:791a779d6220 | 4913 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 4914 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 4915 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 4916 | |
shoaib_ahmed | 0:791a779d6220 | 4917 | z2 = tmp0 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 4918 | z3 = tmp1 + tmp3; |
shoaib_ahmed | 0:791a779d6220 | 4919 | |
shoaib_ahmed | 0:791a779d6220 | 4920 | z1 = MULTIPLY(z2 + z3, FIX_1_175875602); /* c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4921 | z2 = MULTIPLY(z2, - FIX_1_961570560); /* -c3-c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4922 | z3 = MULTIPLY(z3, - FIX_0_390180644); /* -c3+c5 */ |
shoaib_ahmed | 0:791a779d6220 | 4923 | z2 += z1; |
shoaib_ahmed | 0:791a779d6220 | 4924 | z3 += z1; |
shoaib_ahmed | 0:791a779d6220 | 4925 | |
shoaib_ahmed | 0:791a779d6220 | 4926 | z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223); /* -c3+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4927 | tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* -c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4928 | tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* c1+c3-c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4929 | tmp0 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4930 | tmp3 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4931 | |
shoaib_ahmed | 0:791a779d6220 | 4932 | z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447); /* -c1-c3 */ |
shoaib_ahmed | 0:791a779d6220 | 4933 | tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* c1+c3-c5+c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4934 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* c1+c3+c5-c7 */ |
shoaib_ahmed | 0:791a779d6220 | 4935 | tmp1 += z1 + z3; |
shoaib_ahmed | 0:791a779d6220 | 4936 | tmp2 += z1 + z2; |
shoaib_ahmed | 0:791a779d6220 | 4937 | |
shoaib_ahmed | 0:791a779d6220 | 4938 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
shoaib_ahmed | 0:791a779d6220 | 4939 | |
shoaib_ahmed | 0:791a779d6220 | 4940 | wsptr[4*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4941 | wsptr[4*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4942 | wsptr[4*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4943 | wsptr[4*6] = (int) RIGHT_SHIFT(tmp11 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4944 | wsptr[4*2] = (int) RIGHT_SHIFT(tmp12 + tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4945 | wsptr[4*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4946 | wsptr[4*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4947 | wsptr[4*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 4948 | |
shoaib_ahmed | 0:791a779d6220 | 4949 | inptr++; /* advance pointers to next column */ |
shoaib_ahmed | 0:791a779d6220 | 4950 | quantptr++; |
shoaib_ahmed | 0:791a779d6220 | 4951 | wsptr++; |
shoaib_ahmed | 0:791a779d6220 | 4952 | } |
shoaib_ahmed | 0:791a779d6220 | 4953 | |
shoaib_ahmed | 0:791a779d6220 | 4954 | /* Pass 2: process 8 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 4955 | * 4-point IDCT kernel, |
shoaib_ahmed | 0:791a779d6220 | 4956 | * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. |
shoaib_ahmed | 0:791a779d6220 | 4957 | */ |
shoaib_ahmed | 0:791a779d6220 | 4958 | |
shoaib_ahmed | 0:791a779d6220 | 4959 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 4960 | for (ctr = 0; ctr < 8; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 4961 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 4962 | |
shoaib_ahmed | 0:791a779d6220 | 4963 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 4964 | |
shoaib_ahmed | 0:791a779d6220 | 4965 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 4966 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 4967 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 4968 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 4969 | tmp2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 4970 | |
shoaib_ahmed | 0:791a779d6220 | 4971 | tmp10 = (tmp0 + tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4972 | tmp12 = (tmp0 - tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 4973 | |
shoaib_ahmed | 0:791a779d6220 | 4974 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 4975 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 4976 | |
shoaib_ahmed | 0:791a779d6220 | 4977 | z2 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 4978 | z3 = (INT32) wsptr[3]; |
shoaib_ahmed | 0:791a779d6220 | 4979 | |
shoaib_ahmed | 0:791a779d6220 | 4980 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4981 | tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4982 | tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 4983 | |
shoaib_ahmed | 0:791a779d6220 | 4984 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 4985 | |
shoaib_ahmed | 0:791a779d6220 | 4986 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4987 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4988 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4989 | outptr[3] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 4990 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4991 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4992 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp12 + tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4993 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4994 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4995 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
shoaib_ahmed | 0:791a779d6220 | 4996 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 4997 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 4998 | |
shoaib_ahmed | 0:791a779d6220 | 4999 | wsptr += 4; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 5000 | } |
shoaib_ahmed | 0:791a779d6220 | 5001 | } |
shoaib_ahmed | 0:791a779d6220 | 5002 | |
shoaib_ahmed | 0:791a779d6220 | 5003 | |
shoaib_ahmed | 0:791a779d6220 | 5004 | /* |
shoaib_ahmed | 0:791a779d6220 | 5005 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 5006 | * producing a reduced-size 3x6 output block. |
shoaib_ahmed | 0:791a779d6220 | 5007 | * |
shoaib_ahmed | 0:791a779d6220 | 5008 | * 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 5009 | */ |
shoaib_ahmed | 0:791a779d6220 | 5010 | |
shoaib_ahmed | 0:791a779d6220 | 5011 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 5012 | jpeg_idct_3x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 5013 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 5014 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 5015 | { |
shoaib_ahmed | 0:791a779d6220 | 5016 | INT32 tmp0, tmp1, tmp2, tmp10, tmp11, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 5017 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 5018 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 5019 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 5020 | int * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 5021 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 5022 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 5023 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 5024 | int workspace[3*6]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 5025 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 5026 | |
shoaib_ahmed | 0:791a779d6220 | 5027 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 5028 | * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). |
shoaib_ahmed | 0:791a779d6220 | 5029 | */ |
shoaib_ahmed | 0:791a779d6220 | 5030 | |
shoaib_ahmed | 0:791a779d6220 | 5031 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 5032 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 5033 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 5034 | for (ctr = 0; ctr < 3; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 5035 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 5036 | |
shoaib_ahmed | 0:791a779d6220 | 5037 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 5038 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 5039 | /* Add fudge factor here for final descale. */ |
shoaib_ahmed | 0:791a779d6220 | 5040 | tmp0 += ONE << (CONST_BITS-PASS1_BITS-1); |
shoaib_ahmed | 0:791a779d6220 | 5041 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
shoaib_ahmed | 0:791a779d6220 | 5042 | tmp10 = MULTIPLY(tmp2, FIX(0.707106781)); /* c4 */ |
shoaib_ahmed | 0:791a779d6220 | 5043 | tmp1 = tmp0 + tmp10; |
shoaib_ahmed | 0:791a779d6220 | 5044 | tmp11 = RIGHT_SHIFT(tmp0 - tmp10 - tmp10, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5045 | tmp10 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 5046 | tmp0 = MULTIPLY(tmp10, FIX(1.224744871)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 5047 | tmp10 = tmp1 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 5048 | tmp12 = tmp1 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 5049 | |
shoaib_ahmed | 0:791a779d6220 | 5050 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 5051 | |
shoaib_ahmed | 0:791a779d6220 | 5052 | z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 5053 | z2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 5054 | z3 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
shoaib_ahmed | 0:791a779d6220 | 5055 | tmp1 = MULTIPLY(z1 + z3, FIX(0.366025404)); /* c5 */ |
shoaib_ahmed | 0:791a779d6220 | 5056 | tmp0 = tmp1 + ((z1 + z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5057 | tmp2 = tmp1 + ((z3 - z2) << CONST_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5058 | tmp1 = (z1 - z2 - z3) << PASS1_BITS; |
shoaib_ahmed | 0:791a779d6220 | 5059 | |
shoaib_ahmed | 0:791a779d6220 | 5060 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 5061 | |
shoaib_ahmed | 0:791a779d6220 | 5062 | wsptr[3*0] = (int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5063 | wsptr[3*5] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5064 | wsptr[3*1] = (int) (tmp11 + tmp1); |
shoaib_ahmed | 0:791a779d6220 | 5065 | wsptr[3*4] = (int) (tmp11 - tmp1); |
shoaib_ahmed | 0:791a779d6220 | 5066 | wsptr[3*2] = (int) RIGHT_SHIFT(tmp12 + tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5067 | wsptr[3*3] = (int) RIGHT_SHIFT(tmp12 - tmp2, CONST_BITS-PASS1_BITS); |
shoaib_ahmed | 0:791a779d6220 | 5068 | } |
shoaib_ahmed | 0:791a779d6220 | 5069 | |
shoaib_ahmed | 0:791a779d6220 | 5070 | /* Pass 2: process 6 rows from work array, store into output array. |
shoaib_ahmed | 0:791a779d6220 | 5071 | * 3-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/6). |
shoaib_ahmed | 0:791a779d6220 | 5072 | */ |
shoaib_ahmed | 0:791a779d6220 | 5073 | |
shoaib_ahmed | 0:791a779d6220 | 5074 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 5075 | for (ctr = 0; ctr < 6; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 5076 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 5077 | |
shoaib_ahmed | 0:791a779d6220 | 5078 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 5079 | |
shoaib_ahmed | 0:791a779d6220 | 5080 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 5081 | tmp0 = (INT32) wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 5082 | ((((INT32) RANGE_CENTER) << (PASS1_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 5083 | (ONE << (PASS1_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 5084 | tmp0 <<= CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 5085 | tmp2 = (INT32) wsptr[2]; |
shoaib_ahmed | 0:791a779d6220 | 5086 | tmp12 = MULTIPLY(tmp2, FIX(0.707106781)); /* c2 */ |
shoaib_ahmed | 0:791a779d6220 | 5087 | tmp10 = tmp0 + tmp12; |
shoaib_ahmed | 0:791a779d6220 | 5088 | tmp2 = tmp0 - tmp12 - tmp12; |
shoaib_ahmed | 0:791a779d6220 | 5089 | |
shoaib_ahmed | 0:791a779d6220 | 5090 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 5091 | |
shoaib_ahmed | 0:791a779d6220 | 5092 | tmp12 = (INT32) wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 5093 | tmp0 = MULTIPLY(tmp12, FIX(1.224744871)); /* c1 */ |
shoaib_ahmed | 0:791a779d6220 | 5094 | |
shoaib_ahmed | 0:791a779d6220 | 5095 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 5096 | |
shoaib_ahmed | 0:791a779d6220 | 5097 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, |
shoaib_ahmed | 0:791a779d6220 | 5098 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 5099 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5100 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, |
shoaib_ahmed | 0:791a779d6220 | 5101 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 5102 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5103 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp2, |
shoaib_ahmed | 0:791a779d6220 | 5104 | CONST_BITS+PASS1_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 5105 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5106 | |
shoaib_ahmed | 0:791a779d6220 | 5107 | wsptr += 3; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 5108 | } |
shoaib_ahmed | 0:791a779d6220 | 5109 | } |
shoaib_ahmed | 0:791a779d6220 | 5110 | |
shoaib_ahmed | 0:791a779d6220 | 5111 | |
shoaib_ahmed | 0:791a779d6220 | 5112 | /* |
shoaib_ahmed | 0:791a779d6220 | 5113 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 5114 | * producing a 2x4 output block. |
shoaib_ahmed | 0:791a779d6220 | 5115 | * |
shoaib_ahmed | 0:791a779d6220 | 5116 | * 4-point IDCT in pass 1 (columns), 2-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 5117 | */ |
shoaib_ahmed | 0:791a779d6220 | 5118 | |
shoaib_ahmed | 0:791a779d6220 | 5119 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 5120 | jpeg_idct_2x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 5121 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 5122 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 5123 | { |
shoaib_ahmed | 0:791a779d6220 | 5124 | INT32 tmp0, tmp2, tmp10, tmp12; |
shoaib_ahmed | 0:791a779d6220 | 5125 | INT32 z1, z2, z3; |
shoaib_ahmed | 0:791a779d6220 | 5126 | JCOEFPTR inptr; |
shoaib_ahmed | 0:791a779d6220 | 5127 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 5128 | INT32 * wsptr; |
shoaib_ahmed | 0:791a779d6220 | 5129 | JSAMPROW outptr; |
shoaib_ahmed | 0:791a779d6220 | 5130 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 5131 | int ctr; |
shoaib_ahmed | 0:791a779d6220 | 5132 | INT32 workspace[2*4]; /* buffers data between passes */ |
shoaib_ahmed | 0:791a779d6220 | 5133 | SHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 5134 | |
shoaib_ahmed | 0:791a779d6220 | 5135 | /* Pass 1: process columns from input, store into work array. |
shoaib_ahmed | 0:791a779d6220 | 5136 | * 4-point IDCT kernel, |
shoaib_ahmed | 0:791a779d6220 | 5137 | * cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point IDCT]. |
shoaib_ahmed | 0:791a779d6220 | 5138 | */ |
shoaib_ahmed | 0:791a779d6220 | 5139 | |
shoaib_ahmed | 0:791a779d6220 | 5140 | inptr = coef_block; |
shoaib_ahmed | 0:791a779d6220 | 5141 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 5142 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 5143 | for (ctr = 0; ctr < 2; ctr++, inptr++, quantptr++, wsptr++) { |
shoaib_ahmed | 0:791a779d6220 | 5144 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 5145 | |
shoaib_ahmed | 0:791a779d6220 | 5146 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 5147 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
shoaib_ahmed | 0:791a779d6220 | 5148 | |
shoaib_ahmed | 0:791a779d6220 | 5149 | tmp10 = (tmp0 + tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 5150 | tmp12 = (tmp0 - tmp2) << CONST_BITS; |
shoaib_ahmed | 0:791a779d6220 | 5151 | |
shoaib_ahmed | 0:791a779d6220 | 5152 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 5153 | /* Same rotation as in the even part of the 8x8 LL&M IDCT */ |
shoaib_ahmed | 0:791a779d6220 | 5154 | |
shoaib_ahmed | 0:791a779d6220 | 5155 | z2 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 5156 | z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
shoaib_ahmed | 0:791a779d6220 | 5157 | |
shoaib_ahmed | 0:791a779d6220 | 5158 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */ |
shoaib_ahmed | 0:791a779d6220 | 5159 | tmp0 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */ |
shoaib_ahmed | 0:791a779d6220 | 5160 | tmp2 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */ |
shoaib_ahmed | 0:791a779d6220 | 5161 | |
shoaib_ahmed | 0:791a779d6220 | 5162 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 5163 | |
shoaib_ahmed | 0:791a779d6220 | 5164 | wsptr[2*0] = tmp10 + tmp0; |
shoaib_ahmed | 0:791a779d6220 | 5165 | wsptr[2*3] = tmp10 - tmp0; |
shoaib_ahmed | 0:791a779d6220 | 5166 | wsptr[2*1] = tmp12 + tmp2; |
shoaib_ahmed | 0:791a779d6220 | 5167 | wsptr[2*2] = tmp12 - tmp2; |
shoaib_ahmed | 0:791a779d6220 | 5168 | } |
shoaib_ahmed | 0:791a779d6220 | 5169 | |
shoaib_ahmed | 0:791a779d6220 | 5170 | /* Pass 2: process 4 rows from work array, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 5171 | |
shoaib_ahmed | 0:791a779d6220 | 5172 | wsptr = workspace; |
shoaib_ahmed | 0:791a779d6220 | 5173 | for (ctr = 0; ctr < 4; ctr++) { |
shoaib_ahmed | 0:791a779d6220 | 5174 | outptr = output_buf[ctr] + output_col; |
shoaib_ahmed | 0:791a779d6220 | 5175 | |
shoaib_ahmed | 0:791a779d6220 | 5176 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 5177 | |
shoaib_ahmed | 0:791a779d6220 | 5178 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 5179 | tmp10 = wsptr[0] + |
shoaib_ahmed | 0:791a779d6220 | 5180 | ((((INT32) RANGE_CENTER) << (CONST_BITS+3)) + |
shoaib_ahmed | 0:791a779d6220 | 5181 | (ONE << (CONST_BITS+2))); |
shoaib_ahmed | 0:791a779d6220 | 5182 | |
shoaib_ahmed | 0:791a779d6220 | 5183 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 5184 | |
shoaib_ahmed | 0:791a779d6220 | 5185 | tmp0 = wsptr[1]; |
shoaib_ahmed | 0:791a779d6220 | 5186 | |
shoaib_ahmed | 0:791a779d6220 | 5187 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 5188 | |
shoaib_ahmed | 0:791a779d6220 | 5189 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp0, CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 5190 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5191 | outptr[1] = range_limit[(int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS+3) |
shoaib_ahmed | 0:791a779d6220 | 5192 | & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5193 | |
shoaib_ahmed | 0:791a779d6220 | 5194 | wsptr += 2; /* advance pointer to next row */ |
shoaib_ahmed | 0:791a779d6220 | 5195 | } |
shoaib_ahmed | 0:791a779d6220 | 5196 | } |
shoaib_ahmed | 0:791a779d6220 | 5197 | |
shoaib_ahmed | 0:791a779d6220 | 5198 | |
shoaib_ahmed | 0:791a779d6220 | 5199 | /* |
shoaib_ahmed | 0:791a779d6220 | 5200 | * Perform dequantization and inverse DCT on one block of coefficients, |
shoaib_ahmed | 0:791a779d6220 | 5201 | * producing a 1x2 output block. |
shoaib_ahmed | 0:791a779d6220 | 5202 | * |
shoaib_ahmed | 0:791a779d6220 | 5203 | * 2-point IDCT in pass 1 (columns), 1-point in pass 2 (rows). |
shoaib_ahmed | 0:791a779d6220 | 5204 | */ |
shoaib_ahmed | 0:791a779d6220 | 5205 | |
shoaib_ahmed | 0:791a779d6220 | 5206 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 5207 | jpeg_idct_1x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
shoaib_ahmed | 0:791a779d6220 | 5208 | JCOEFPTR coef_block, |
shoaib_ahmed | 0:791a779d6220 | 5209 | JSAMPARRAY output_buf, JDIMENSION output_col) |
shoaib_ahmed | 0:791a779d6220 | 5210 | { |
shoaib_ahmed | 0:791a779d6220 | 5211 | DCTELEM tmp0, tmp1; |
shoaib_ahmed | 0:791a779d6220 | 5212 | ISLOW_MULT_TYPE * quantptr; |
shoaib_ahmed | 0:791a779d6220 | 5213 | JSAMPLE *range_limit = IDCT_range_limit(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 5214 | ISHIFT_TEMPS |
shoaib_ahmed | 0:791a779d6220 | 5215 | |
shoaib_ahmed | 0:791a779d6220 | 5216 | /* Process 1 column from input, store into output array. */ |
shoaib_ahmed | 0:791a779d6220 | 5217 | |
shoaib_ahmed | 0:791a779d6220 | 5218 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
shoaib_ahmed | 0:791a779d6220 | 5219 | |
shoaib_ahmed | 0:791a779d6220 | 5220 | /* Even part */ |
shoaib_ahmed | 0:791a779d6220 | 5221 | |
shoaib_ahmed | 0:791a779d6220 | 5222 | tmp0 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]); |
shoaib_ahmed | 0:791a779d6220 | 5223 | /* Add range center and fudge factor for final descale and range-limit. */ |
shoaib_ahmed | 0:791a779d6220 | 5224 | tmp0 += (((DCTELEM) RANGE_CENTER) << 3) + (1 << 2); |
shoaib_ahmed | 0:791a779d6220 | 5225 | |
shoaib_ahmed | 0:791a779d6220 | 5226 | /* Odd part */ |
shoaib_ahmed | 0:791a779d6220 | 5227 | |
shoaib_ahmed | 0:791a779d6220 | 5228 | tmp1 = DEQUANTIZE(coef_block[DCTSIZE*1], quantptr[DCTSIZE*1]); |
shoaib_ahmed | 0:791a779d6220 | 5229 | |
shoaib_ahmed | 0:791a779d6220 | 5230 | /* Final output stage */ |
shoaib_ahmed | 0:791a779d6220 | 5231 | |
shoaib_ahmed | 0:791a779d6220 | 5232 | output_buf[0][output_col] = |
shoaib_ahmed | 0:791a779d6220 | 5233 | range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5234 | output_buf[1][output_col] = |
shoaib_ahmed | 0:791a779d6220 | 5235 | range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp1, 3) & RANGE_MASK]; |
shoaib_ahmed | 0:791a779d6220 | 5236 | } |
shoaib_ahmed | 0:791a779d6220 | 5237 | |
shoaib_ahmed | 0:791a779d6220 | 5238 | #endif /* IDCT_SCALING_SUPPORTED */ |
shoaib_ahmed | 0:791a779d6220 | 5239 | #endif /* DCT_ISLOW_SUPPORTED */ |