00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #define JPEG_INTERNALS
00027 #include "jinclude.h"
00028 #include "jpeglib.h"
00029 #include "jdct.h"
00030
00031 #ifdef DCT_ISLOW_SUPPORTED
00032
00033
00034
00035
00036
00037
00038 #if DCTSIZE != 8
00039 Sorry, this code only copes with 8x8 DCTs.
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #if BITS_IN_JSAMPLE == 8
00078 #define CONST_BITS 13
00079 #define PASS1_BITS 2
00080 #else
00081 #define CONST_BITS 13
00082 #define PASS1_BITS 1
00083 #endif
00084
00085
00086
00087
00088
00089
00090
00091
00092 #if CONST_BITS == 13
00093 #define FIX_0_298631336 ((INT32) 2446)
00094 #define FIX_0_390180644 ((INT32) 3196)
00095 #define FIX_0_541196100 ((INT32) 4433)
00096 #define FIX_0_765366865 ((INT32) 6270)
00097 #define FIX_0_899976223 ((INT32) 7373)
00098 #define FIX_1_175875602 ((INT32) 9633)
00099 #define FIX_1_501321110 ((INT32) 12299)
00100 #define FIX_1_847759065 ((INT32) 15137)
00101 #define FIX_1_961570560 ((INT32) 16069)
00102 #define FIX_2_053119869 ((INT32) 16819)
00103 #define FIX_2_562915447 ((INT32) 20995)
00104 #define FIX_3_072711026 ((INT32) 25172)
00105 #else
00106 #define FIX_0_298631336 FIX(0.298631336)
00107 #define FIX_0_390180644 FIX(0.390180644)
00108 #define FIX_0_541196100 FIX(0.541196100)
00109 #define FIX_0_765366865 FIX(0.765366865)
00110 #define FIX_0_899976223 FIX(0.899976223)
00111 #define FIX_1_175875602 FIX(1.175875602)
00112 #define FIX_1_501321110 FIX(1.501321110)
00113 #define FIX_1_847759065 FIX(1.847759065)
00114 #define FIX_1_961570560 FIX(1.961570560)
00115 #define FIX_2_053119869 FIX(2.053119869)
00116 #define FIX_2_562915447 FIX(2.562915447)
00117 #define FIX_3_072711026 FIX(3.072711026)
00118 #endif
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 #if BITS_IN_JSAMPLE == 8
00129 #define MULTIPLY(var,const) MULTIPLY16C16(var,const)
00130 #else
00131 #define MULTIPLY(var,const) ((var) * (const))
00132 #endif
00133
00134
00135
00136
00137
00138
00139 GLOBAL(void)
00140 jpeg_fdct_islow (DCTELEM * data)
00141 {
00142 INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00143 INT32 tmp10, tmp11, tmp12, tmp13;
00144 INT32 z1, z2, z3, z4, z5;
00145 DCTELEM *dataptr;
00146 int ctr;
00147 SHIFT_TEMPS
00148
00149
00150
00151
00152
00153 dataptr = data;
00154 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
00155 tmp0 = dataptr[0] + dataptr[7];
00156 tmp7 = dataptr[0] - dataptr[7];
00157 tmp1 = dataptr[1] + dataptr[6];
00158 tmp6 = dataptr[1] - dataptr[6];
00159 tmp2 = dataptr[2] + dataptr[5];
00160 tmp5 = dataptr[2] - dataptr[5];
00161 tmp3 = dataptr[3] + dataptr[4];
00162 tmp4 = dataptr[3] - dataptr[4];
00163
00164
00165
00166
00167
00168 tmp10 = tmp0 + tmp3;
00169 tmp13 = tmp0 - tmp3;
00170 tmp11 = tmp1 + tmp2;
00171 tmp12 = tmp1 - tmp2;
00172
00173 dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
00174 dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
00175
00176 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
00177 dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
00178 CONST_BITS-PASS1_BITS);
00179 dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
00180 CONST_BITS-PASS1_BITS);
00181
00182
00183
00184
00185
00186
00187 z1 = tmp4 + tmp7;
00188 z2 = tmp5 + tmp6;
00189 z3 = tmp4 + tmp6;
00190 z4 = tmp5 + tmp7;
00191 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
00192
00193 tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
00194 tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
00195 tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
00196 tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
00197 z1 = MULTIPLY(z1, - FIX_0_899976223);
00198 z2 = MULTIPLY(z2, - FIX_2_562915447);
00199 z3 = MULTIPLY(z3, - FIX_1_961570560);
00200 z4 = MULTIPLY(z4, - FIX_0_390180644);
00201
00202 z3 += z5;
00203 z4 += z5;
00204
00205 dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
00206 dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
00207 dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
00208 dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
00209
00210 dataptr += DCTSIZE;
00211 }
00212
00213
00214
00215
00216
00217
00218 dataptr = data;
00219 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
00220 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
00221 tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
00222 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
00223 tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
00224 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
00225 tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
00226 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
00227 tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
00228
00229
00230
00231
00232
00233 tmp10 = tmp0 + tmp3;
00234 tmp13 = tmp0 - tmp3;
00235 tmp11 = tmp1 + tmp2;
00236 tmp12 = tmp1 - tmp2;
00237
00238 dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
00239 dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
00240
00241 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
00242 dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
00243 CONST_BITS+PASS1_BITS);
00244 dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
00245 CONST_BITS+PASS1_BITS);
00246
00247
00248
00249
00250
00251
00252 z1 = tmp4 + tmp7;
00253 z2 = tmp5 + tmp6;
00254 z3 = tmp4 + tmp6;
00255 z4 = tmp5 + tmp7;
00256 z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
00257
00258 tmp4 = MULTIPLY(tmp4, FIX_0_298631336);
00259 tmp5 = MULTIPLY(tmp5, FIX_2_053119869);
00260 tmp6 = MULTIPLY(tmp6, FIX_3_072711026);
00261 tmp7 = MULTIPLY(tmp7, FIX_1_501321110);
00262 z1 = MULTIPLY(z1, - FIX_0_899976223);
00263 z2 = MULTIPLY(z2, - FIX_2_562915447);
00264 z3 = MULTIPLY(z3, - FIX_1_961570560);
00265 z4 = MULTIPLY(z4, - FIX_0_390180644);
00266
00267 z3 += z5;
00268 z4 += z5;
00269
00270 dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
00271 CONST_BITS+PASS1_BITS);
00272 dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
00273 CONST_BITS+PASS1_BITS);
00274 dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
00275 CONST_BITS+PASS1_BITS);
00276 dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
00277 CONST_BITS+PASS1_BITS);
00278
00279 dataptr++;
00280 }
00281 }
00282
00283 #endif