| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jfdctint.c | 2 * jfdctint.c |
| 3 * | 3 * |
| 4 * This file was part of the Independent JPEG Group's software. |
| 4 * Copyright (C) 1991-1996, Thomas G. Lane. | 5 * Copyright (C) 1991-1996, Thomas G. Lane. |
| 5 * This file is part of the Independent JPEG Group's software. | 6 * libjpeg-turbo Modifications: |
| 6 * For conditions of distribution and use, see the accompanying README file. | 7 * Copyright (C) 2015, D. R. Commander |
| 8 * For conditions of distribution and use, see the accompanying README.ijg |
| 9 * file. |
| 7 * | 10 * |
| 8 * This file contains a slow-but-accurate integer implementation of the | 11 * This file contains a slow-but-accurate integer implementation of the |
| 9 * forward DCT (Discrete Cosine Transform). | 12 * forward DCT (Discrete Cosine Transform). |
| 10 * | 13 * |
| 11 * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT | 14 * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT |
| 12 * on each column. Direct algorithms are also available, but they are | 15 * on each column. Direct algorithms are also available, but they are |
| 13 * much more complex and seem not to be any faster when reduced to code. | 16 * much more complex and seem not to be any faster when reduced to code. |
| 14 * | 17 * |
| 15 * This implementation is based on an algorithm described in | 18 * This implementation is based on an algorithm described in |
| 16 * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT | 19 * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT |
| 17 * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, | 20 * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, |
| 18 * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. | 21 * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. |
| 19 * The primary algorithm described there uses 11 multiplies and 29 adds. | 22 * The primary algorithm described there uses 11 multiplies and 29 adds. |
| 20 * We use their alternate method with 12 multiplies and 32 adds. | 23 * We use their alternate method with 12 multiplies and 32 adds. |
| 21 * The advantage of this method is that no data path contains more than one | 24 * The advantage of this method is that no data path contains more than one |
| 22 * multiplication; this allows a very simple and accurate implementation in | 25 * multiplication; this allows a very simple and accurate implementation in |
| 23 * scaled fixed-point arithmetic, with a minimal number of shifts. | 26 * scaled fixed-point arithmetic, with a minimal number of shifts. |
| 24 */ | 27 */ |
| 25 | 28 |
| 26 #define JPEG_INTERNALS | 29 #define JPEG_INTERNALS |
| 27 #include "jinclude.h" | 30 #include "jinclude.h" |
| 28 #include "jpeglib.h" | 31 #include "jpeglib.h" |
| 29 #include "jdct.h"» » /* Private declarations for DCT subsystem */ | 32 #include "jdct.h" /* Private declarations for DCT subsystem */ |
| 30 | 33 |
| 31 #ifdef DCT_ISLOW_SUPPORTED | 34 #ifdef DCT_ISLOW_SUPPORTED |
| 32 | 35 |
| 33 | 36 |
| 34 /* | 37 /* |
| 35 * This module is specialized to the case DCTSIZE = 8. | 38 * This module is specialized to the case DCTSIZE = 8. |
| 36 */ | 39 */ |
| 37 | 40 |
| 38 #if DCTSIZE != 8 | 41 #if DCTSIZE != 8 |
| 39 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ | 42 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 * multiplication we have to divide the product by CONST_SCALE, with proper | 63 * multiplication we have to divide the product by CONST_SCALE, with proper |
| 61 * rounding, to produce the correct output. This division can be done | 64 * rounding, to produce the correct output. This division can be done |
| 62 * cheaply as a right shift of CONST_BITS bits. We postpone shifting | 65 * cheaply as a right shift of CONST_BITS bits. We postpone shifting |
| 63 * as long as possible so that partial sums can be added together with | 66 * as long as possible so that partial sums can be added together with |
| 64 * full fractional precision. | 67 * full fractional precision. |
| 65 * | 68 * |
| 66 * The outputs of the first pass are scaled up by PASS1_BITS bits so that | 69 * The outputs of the first pass are scaled up by PASS1_BITS bits so that |
| 67 * they are represented to better-than-integral precision. These outputs | 70 * they are represented to better-than-integral precision. These outputs |
| 68 * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word | 71 * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word |
| 69 * with the recommended scaling. (For 12-bit sample data, the intermediate | 72 * with the recommended scaling. (For 12-bit sample data, the intermediate |
| 70 * array is INT32 anyway.) | 73 * array is JLONG anyway.) |
| 71 * | 74 * |
| 72 * To avoid overflow of the 32-bit intermediate results in pass 2, we must | 75 * To avoid overflow of the 32-bit intermediate results in pass 2, we must |
| 73 * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis | 76 * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis |
| 74 * shows that the values given below are the most effective. | 77 * shows that the values given below are the most effective. |
| 75 */ | 78 */ |
| 76 | 79 |
| 77 #if BITS_IN_JSAMPLE == 8 | 80 #if BITS_IN_JSAMPLE == 8 |
| 78 #define CONST_BITS 13 | 81 #define CONST_BITS 13 |
| 79 #define PASS1_BITS 2 | 82 #define PASS1_BITS 2 |
| 80 #else | 83 #else |
| 81 #define CONST_BITS 13 | 84 #define CONST_BITS 13 |
| 82 #define PASS1_BITS 1» » /* lose a little precision to avoid overflow */ | 85 #define PASS1_BITS 1 /* lose a little precision to avoid overflow */ |
| 83 #endif | 86 #endif |
| 84 | 87 |
| 85 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus | 88 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus |
| 86 * causing a lot of useless floating-point operations at run time. | 89 * causing a lot of useless floating-point operations at run time. |
| 87 * To get around this we use the following pre-calculated constants. | 90 * To get around this we use the following pre-calculated constants. |
| 88 * If you change CONST_BITS you may want to add appropriate values. | 91 * If you change CONST_BITS you may want to add appropriate values. |
| 89 * (With a reasonable C compiler, you can just rely on the FIX() macro...) | 92 * (With a reasonable C compiler, you can just rely on the FIX() macro...) |
| 90 */ | 93 */ |
| 91 | 94 |
| 92 #if CONST_BITS == 13 | 95 #if CONST_BITS == 13 |
| 93 #define FIX_0_298631336 ((INT32) 2446)» /* FIX(0.298631336) */ | 96 #define FIX_0_298631336 ((JLONG) 2446) /* FIX(0.298631336) */ |
| 94 #define FIX_0_390180644 ((INT32) 3196)» /* FIX(0.390180644) */ | 97 #define FIX_0_390180644 ((JLONG) 3196) /* FIX(0.390180644) */ |
| 95 #define FIX_0_541196100 ((INT32) 4433)» /* FIX(0.541196100) */ | 98 #define FIX_0_541196100 ((JLONG) 4433) /* FIX(0.541196100) */ |
| 96 #define FIX_0_765366865 ((INT32) 6270)» /* FIX(0.765366865) */ | 99 #define FIX_0_765366865 ((JLONG) 6270) /* FIX(0.765366865) */ |
| 97 #define FIX_0_899976223 ((INT32) 7373)» /* FIX(0.899976223) */ | 100 #define FIX_0_899976223 ((JLONG) 7373) /* FIX(0.899976223) */ |
| 98 #define FIX_1_175875602 ((INT32) 9633)» /* FIX(1.175875602) */ | 101 #define FIX_1_175875602 ((JLONG) 9633) /* FIX(1.175875602) */ |
| 99 #define FIX_1_501321110 ((INT32) 12299)» /* FIX(1.501321110) */ | 102 #define FIX_1_501321110 ((JLONG) 12299) /* FIX(1.501321110) */ |
| 100 #define FIX_1_847759065 ((INT32) 15137)» /* FIX(1.847759065) */ | 103 #define FIX_1_847759065 ((JLONG) 15137) /* FIX(1.847759065) */ |
| 101 #define FIX_1_961570560 ((INT32) 16069)» /* FIX(1.961570560) */ | 104 #define FIX_1_961570560 ((JLONG) 16069) /* FIX(1.961570560) */ |
| 102 #define FIX_2_053119869 ((INT32) 16819)» /* FIX(2.053119869) */ | 105 #define FIX_2_053119869 ((JLONG) 16819) /* FIX(2.053119869) */ |
| 103 #define FIX_2_562915447 ((INT32) 20995)» /* FIX(2.562915447) */ | 106 #define FIX_2_562915447 ((JLONG) 20995) /* FIX(2.562915447) */ |
| 104 #define FIX_3_072711026 ((INT32) 25172)» /* FIX(3.072711026) */ | 107 #define FIX_3_072711026 ((JLONG) 25172) /* FIX(3.072711026) */ |
| 105 #else | 108 #else |
| 106 #define FIX_0_298631336 FIX(0.298631336) | 109 #define FIX_0_298631336 FIX(0.298631336) |
| 107 #define FIX_0_390180644 FIX(0.390180644) | 110 #define FIX_0_390180644 FIX(0.390180644) |
| 108 #define FIX_0_541196100 FIX(0.541196100) | 111 #define FIX_0_541196100 FIX(0.541196100) |
| 109 #define FIX_0_765366865 FIX(0.765366865) | 112 #define FIX_0_765366865 FIX(0.765366865) |
| 110 #define FIX_0_899976223 FIX(0.899976223) | 113 #define FIX_0_899976223 FIX(0.899976223) |
| 111 #define FIX_1_175875602 FIX(1.175875602) | 114 #define FIX_1_175875602 FIX(1.175875602) |
| 112 #define FIX_1_501321110 FIX(1.501321110) | 115 #define FIX_1_501321110 FIX(1.501321110) |
| 113 #define FIX_1_847759065 FIX(1.847759065) | 116 #define FIX_1_847759065 FIX(1.847759065) |
| 114 #define FIX_1_961570560 FIX(1.961570560) | 117 #define FIX_1_961570560 FIX(1.961570560) |
| 115 #define FIX_2_053119869 FIX(2.053119869) | 118 #define FIX_2_053119869 FIX(2.053119869) |
| 116 #define FIX_2_562915447 FIX(2.562915447) | 119 #define FIX_2_562915447 FIX(2.562915447) |
| 117 #define FIX_3_072711026 FIX(3.072711026) | 120 #define FIX_3_072711026 FIX(3.072711026) |
| 118 #endif | 121 #endif |
| 119 | 122 |
| 120 | 123 |
| 121 /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. | 124 /* Multiply an JLONG variable by an JLONG constant to yield an JLONG result. |
| 122 * For 8-bit samples with the recommended scaling, all the variable | 125 * For 8-bit samples with the recommended scaling, all the variable |
| 123 * and constant values involved are no more than 16 bits wide, so a | 126 * and constant values involved are no more than 16 bits wide, so a |
| 124 * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. | 127 * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. |
| 125 * For 12-bit samples, a full 32-bit multiplication will be needed. | 128 * For 12-bit samples, a full 32-bit multiplication will be needed. |
| 126 */ | 129 */ |
| 127 | 130 |
| 128 #if BITS_IN_JSAMPLE == 8 | 131 #if BITS_IN_JSAMPLE == 8 |
| 129 #define MULTIPLY(var,const) MULTIPLY16C16(var,const) | 132 #define MULTIPLY(var,const) MULTIPLY16C16(var,const) |
| 130 #else | 133 #else |
| 131 #define MULTIPLY(var,const) ((var) * (const)) | 134 #define MULTIPLY(var,const) ((var) * (const)) |
| 132 #endif | 135 #endif |
| 133 | 136 |
| 134 | 137 |
| 135 /* | 138 /* |
| 136 * Perform the forward DCT on one block of samples. | 139 * Perform the forward DCT on one block of samples. |
| 137 */ | 140 */ |
| 138 | 141 |
| 139 GLOBAL(void) | 142 GLOBAL(void) |
| 140 jpeg_fdct_islow (DCTELEM * data) | 143 jpeg_fdct_islow (DCTELEM *data) |
| 141 { | 144 { |
| 142 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | 145 JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; |
| 143 INT32 tmp10, tmp11, tmp12, tmp13; | 146 JLONG tmp10, tmp11, tmp12, tmp13; |
| 144 INT32 z1, z2, z3, z4, z5; | 147 JLONG z1, z2, z3, z4, z5; |
| 145 DCTELEM *dataptr; | 148 DCTELEM *dataptr; |
| 146 int ctr; | 149 int ctr; |
| 147 SHIFT_TEMPS | 150 SHIFT_TEMPS |
| 148 | 151 |
| 149 /* Pass 1: process rows. */ | 152 /* Pass 1: process rows. */ |
| 150 /* Note results are scaled up by sqrt(8) compared to a true DCT; */ | 153 /* Note results are scaled up by sqrt(8) compared to a true DCT; */ |
| 151 /* furthermore, we scale the results by 2**PASS1_BITS. */ | 154 /* furthermore, we scale the results by 2**PASS1_BITS. */ |
| 152 | 155 |
| 153 dataptr = data; | 156 dataptr = data; |
| 154 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { | 157 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { |
| 155 tmp0 = dataptr[0] + dataptr[7]; | 158 tmp0 = dataptr[0] + dataptr[7]; |
| 156 tmp7 = dataptr[0] - dataptr[7]; | 159 tmp7 = dataptr[0] - dataptr[7]; |
| 157 tmp1 = dataptr[1] + dataptr[6]; | 160 tmp1 = dataptr[1] + dataptr[6]; |
| 158 tmp6 = dataptr[1] - dataptr[6]; | 161 tmp6 = dataptr[1] - dataptr[6]; |
| 159 tmp2 = dataptr[2] + dataptr[5]; | 162 tmp2 = dataptr[2] + dataptr[5]; |
| 160 tmp5 = dataptr[2] - dataptr[5]; | 163 tmp5 = dataptr[2] - dataptr[5]; |
| 161 tmp3 = dataptr[3] + dataptr[4]; | 164 tmp3 = dataptr[3] + dataptr[4]; |
| 162 tmp4 = dataptr[3] - dataptr[4]; | 165 tmp4 = dataptr[3] - dataptr[4]; |
| 163 | 166 |
| 164 /* Even part per LL&M figure 1 --- note that published figure is faulty; | 167 /* Even part per LL&M figure 1 --- note that published figure is faulty; |
| 165 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". | 168 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". |
| 166 */ | 169 */ |
| 167 | 170 |
| 168 tmp10 = tmp0 + tmp3; | 171 tmp10 = tmp0 + tmp3; |
| 169 tmp13 = tmp0 - tmp3; | 172 tmp13 = tmp0 - tmp3; |
| 170 tmp11 = tmp1 + tmp2; | 173 tmp11 = tmp1 + tmp2; |
| 171 tmp12 = tmp1 - tmp2; | 174 tmp12 = tmp1 - tmp2; |
| 172 | 175 |
| 173 dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); | 176 dataptr[0] = (DCTELEM) LEFT_SHIFT(tmp10 + tmp11, PASS1_BITS); |
| 174 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); | 177 dataptr[4] = (DCTELEM) LEFT_SHIFT(tmp10 - tmp11, PASS1_BITS); |
| 175 | 178 |
| 176 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); | 179 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); |
| 177 dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), | 180 dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), |
| 178 » » » » CONST_BITS-PASS1_BITS); | 181 CONST_BITS-PASS1_BITS); |
| 179 dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), | 182 dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), |
| 180 » » » » CONST_BITS-PASS1_BITS); | 183 CONST_BITS-PASS1_BITS); |
| 181 | 184 |
| 182 /* Odd part per figure 8 --- note paper omits factor of sqrt(2). | 185 /* Odd part per figure 8 --- note paper omits factor of sqrt(2). |
| 183 * cK represents cos(K*pi/16). | 186 * cK represents cos(K*pi/16). |
| 184 * i0..i3 in the paper are tmp4..tmp7 here. | 187 * i0..i3 in the paper are tmp4..tmp7 here. |
| 185 */ | 188 */ |
| 186 | 189 |
| 187 z1 = tmp4 + tmp7; | 190 z1 = tmp4 + tmp7; |
| 188 z2 = tmp5 + tmp6; | 191 z2 = tmp5 + tmp6; |
| 189 z3 = tmp4 + tmp6; | 192 z3 = tmp4 + tmp6; |
| 190 z4 = tmp5 + tmp7; | 193 z4 = tmp5 + tmp7; |
| 191 z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ | 194 z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ |
| 192 | 195 |
| 193 tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ | 196 tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ |
| 194 tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ | 197 tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ |
| 195 tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ | 198 tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
| 196 tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ | 199 tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ |
| 197 z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ | 200 z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ |
| 198 z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ | 201 z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ |
| 199 z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ | 202 z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ |
| 200 z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ | 203 z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ |
| 201 | 204 |
| 202 z3 += z5; | 205 z3 += z5; |
| 203 z4 += z5; | 206 z4 += z5; |
| 204 | 207 |
| 205 dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); | 208 dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); |
| 206 dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); | 209 dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); |
| 207 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); | 210 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); |
| 208 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); | 211 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); |
| 209 | 212 |
| 210 dataptr += DCTSIZE;»» /* advance pointer to next row */ | 213 dataptr += DCTSIZE; /* advance pointer to next row */ |
| 211 } | 214 } |
| 212 | 215 |
| 213 /* Pass 2: process columns. | 216 /* Pass 2: process columns. |
| 214 * We remove the PASS1_BITS scaling, but leave the results scaled up | 217 * We remove the PASS1_BITS scaling, but leave the results scaled up |
| 215 * by an overall factor of 8. | 218 * by an overall factor of 8. |
| 216 */ | 219 */ |
| 217 | 220 |
| 218 dataptr = data; | 221 dataptr = data; |
| 219 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { | 222 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { |
| 220 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; | 223 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; |
| 221 tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; | 224 tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; |
| 222 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; | 225 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; |
| 223 tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; | 226 tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; |
| 224 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; | 227 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; |
| 225 tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; | 228 tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; |
| 226 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; | 229 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; |
| 227 tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; | 230 tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; |
| 228 | 231 |
| 229 /* Even part per LL&M figure 1 --- note that published figure is faulty; | 232 /* Even part per LL&M figure 1 --- note that published figure is faulty; |
| 230 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". | 233 * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". |
| 231 */ | 234 */ |
| 232 | 235 |
| 233 tmp10 = tmp0 + tmp3; | 236 tmp10 = tmp0 + tmp3; |
| 234 tmp13 = tmp0 - tmp3; | 237 tmp13 = tmp0 - tmp3; |
| 235 tmp11 = tmp1 + tmp2; | 238 tmp11 = tmp1 + tmp2; |
| 236 tmp12 = tmp1 - tmp2; | 239 tmp12 = tmp1 - tmp2; |
| 237 | 240 |
| 238 dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); | 241 dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); |
| 239 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); | 242 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); |
| 240 | 243 |
| 241 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); | 244 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); |
| 242 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865)
, | 245 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865)
, |
| 243 » » » » » CONST_BITS+PASS1_BITS); | 246 CONST_BITS+PASS1_BITS); |
| 244 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_84775906
5), | 247 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_84775906
5), |
| 245 » » » » » CONST_BITS+PASS1_BITS); | 248 CONST_BITS+PASS1_BITS); |
| 246 | 249 |
| 247 /* Odd part per figure 8 --- note paper omits factor of sqrt(2). | 250 /* Odd part per figure 8 --- note paper omits factor of sqrt(2). |
| 248 * cK represents cos(K*pi/16). | 251 * cK represents cos(K*pi/16). |
| 249 * i0..i3 in the paper are tmp4..tmp7 here. | 252 * i0..i3 in the paper are tmp4..tmp7 here. |
| 250 */ | 253 */ |
| 251 | 254 |
| 252 z1 = tmp4 + tmp7; | 255 z1 = tmp4 + tmp7; |
| 253 z2 = tmp5 + tmp6; | 256 z2 = tmp5 + tmp6; |
| 254 z3 = tmp4 + tmp6; | 257 z3 = tmp4 + tmp6; |
| 255 z4 = tmp5 + tmp7; | 258 z4 = tmp5 + tmp7; |
| 256 z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ | 259 z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ |
| 257 | 260 |
| 258 tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ | 261 tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ |
| 259 tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ | 262 tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ |
| 260 tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ | 263 tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
| 261 tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ | 264 tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ |
| 262 z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ | 265 z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ |
| 263 z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ | 266 z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ |
| 264 z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ | 267 z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ |
| 265 z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ | 268 z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ |
| 266 | 269 |
| 267 z3 += z5; | 270 z3 += z5; |
| 268 z4 += z5; | 271 z4 += z5; |
| 269 | 272 |
| 270 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, | 273 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, |
| 271 » » » » » CONST_BITS+PASS1_BITS); | 274 CONST_BITS+PASS1_BITS); |
| 272 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, | 275 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, |
| 273 » » » » » CONST_BITS+PASS1_BITS); | 276 CONST_BITS+PASS1_BITS); |
| 274 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, | 277 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, |
| 275 » » » » » CONST_BITS+PASS1_BITS); | 278 CONST_BITS+PASS1_BITS); |
| 276 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, | 279 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, |
| 277 » » » » » CONST_BITS+PASS1_BITS); | 280 CONST_BITS+PASS1_BITS); |
| 278 | 281 |
| 279 dataptr++;» » » /* advance pointer to next column */ | 282 dataptr++; /* advance pointer to next column */ |
| 280 } | 283 } |
| 281 } | 284 } |
| 282 | 285 |
| 283 #endif /* DCT_ISLOW_SUPPORTED */ | 286 #endif /* DCT_ISLOW_SUPPORTED */ |
| OLD | NEW |