Go to the documentation of this file.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
00027
00028
00029
00030
00031
00032
00033 #define JPEG_INTERNALS
00034 #include "jinclude.h"
00035 #include "jpeglib.h"
00036 #include "jdct.h"
00037
00038 #ifdef DCT_IFAST_SUPPORTED
00039
00040
00041
00042
00043
00044
00045 #if DCTSIZE != 8
00046 Sorry, this code only copes with 8x8 DCTs.
00047 #endif
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #define CONST_BITS 8
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #if CONST_BITS == 8
00079 #define FIX_0_382683433 ((INT32) 98)
00080 #define FIX_0_541196100 ((INT32) 139)
00081 #define FIX_0_707106781 ((INT32) 181)
00082 #define FIX_1_306562965 ((INT32) 334)
00083 #else
00084 #define FIX_0_382683433 FIX(0.382683433)
00085 #define FIX_0_541196100 FIX(0.541196100)
00086 #define FIX_0_707106781 FIX(0.707106781)
00087 #define FIX_1_306562965 FIX(1.306562965)
00088 #endif
00089
00090
00091
00092
00093
00094
00095
00096 #ifndef USE_ACCURATE_ROUNDING
00097 #undef DESCALE
00098 #define DESCALE(x,n) RIGHT_SHIFT(x, n)
00099 #endif
00100
00101
00102
00103
00104
00105
00106 #define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
00107
00108
00109
00110
00111
00112
00113 GLOBAL(void)
00114 jpeg_fdct_ifast (DCTELEM * data)
00115 {
00116 DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00117 DCTELEM tmp10, tmp11, tmp12, tmp13;
00118 DCTELEM z1, z2, z3, z4, z5, z11, z13;
00119 DCTELEM *dataptr;
00120 int ctr;
00121 SHIFT_TEMPS
00122
00123
00124
00125 dataptr = data;
00126 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
00127 tmp0 = dataptr[0] + dataptr[7];
00128 tmp7 = dataptr[0] - dataptr[7];
00129 tmp1 = dataptr[1] + dataptr[6];
00130 tmp6 = dataptr[1] - dataptr[6];
00131 tmp2 = dataptr[2] + dataptr[5];
00132 tmp5 = dataptr[2] - dataptr[5];
00133 tmp3 = dataptr[3] + dataptr[4];
00134 tmp4 = dataptr[3] - dataptr[4];
00135
00136
00137
00138 tmp10 = tmp0 + tmp3;
00139 tmp13 = tmp0 - tmp3;
00140 tmp11 = tmp1 + tmp2;
00141 tmp12 = tmp1 - tmp2;
00142
00143 dataptr[0] = tmp10 + tmp11;
00144 dataptr[4] = tmp10 - tmp11;
00145
00146 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781);
00147 dataptr[2] = tmp13 + z1;
00148 dataptr[6] = tmp13 - z1;
00149
00150
00151
00152 tmp10 = tmp4 + tmp5;
00153 tmp11 = tmp5 + tmp6;
00154 tmp12 = tmp6 + tmp7;
00155
00156
00157 z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433);
00158 z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5;
00159 z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5;
00160 z3 = MULTIPLY(tmp11, FIX_0_707106781);
00161
00162 z11 = tmp7 + z3;
00163 z13 = tmp7 - z3;
00164
00165 dataptr[5] = z13 + z2;
00166 dataptr[3] = z13 - z2;
00167 dataptr[1] = z11 + z4;
00168 dataptr[7] = z11 - z4;
00169
00170 dataptr += DCTSIZE;
00171 }
00172
00173
00174
00175 dataptr = data;
00176 for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
00177 tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
00178 tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
00179 tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
00180 tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
00181 tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
00182 tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
00183 tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
00184 tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
00185
00186
00187
00188 tmp10 = tmp0 + tmp3;
00189 tmp13 = tmp0 - tmp3;
00190 tmp11 = tmp1 + tmp2;
00191 tmp12 = tmp1 - tmp2;
00192
00193 dataptr[DCTSIZE*0] = tmp10 + tmp11;
00194 dataptr[DCTSIZE*4] = tmp10 - tmp11;
00195
00196 z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781);
00197 dataptr[DCTSIZE*2] = tmp13 + z1;
00198 dataptr[DCTSIZE*6] = tmp13 - z1;
00199
00200
00201
00202 tmp10 = tmp4 + tmp5;
00203 tmp11 = tmp5 + tmp6;
00204 tmp12 = tmp6 + tmp7;
00205
00206
00207 z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433);
00208 z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5;
00209 z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5;
00210 z3 = MULTIPLY(tmp11, FIX_0_707106781);
00211
00212 z11 = tmp7 + z3;
00213 z13 = tmp7 - z3;
00214
00215 dataptr[DCTSIZE*5] = z13 + z2;
00216 dataptr[DCTSIZE*3] = z13 - z2;
00217 dataptr[DCTSIZE*1] = z11 + z4;
00218 dataptr[DCTSIZE*7] = z11 - z4;
00219
00220 dataptr++;
00221 }
00222 }
00223
00224 #endif