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
00034 #include "dsputil.h"
00035 #include "faandct.h"
00036
00037 #define FLOAT float
00038 #ifdef FAAN_POSTSCALE
00039 # define SCALE(x) postscale[x]
00040 #else
00041 # define SCALE(x) 1
00042 #endif
00043
00044
00045
00046
00047
00048
00049
00050 #define B0 1.00000000000000000000
00051 #define B1 0.72095982200694791383 // (cos(pi*1/16)sqrt(2))^-1
00052 #define B2 0.76536686473017954350 // (cos(pi*2/16)sqrt(2))^-1
00053 #define B3 0.85043009476725644878 // (cos(pi*3/16)sqrt(2))^-1
00054 #define B4 1.00000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
00055 #define B5 1.27275858057283393842 // (cos(pi*5/16)sqrt(2))^-1
00056 #define B6 1.84775906502257351242 // (cos(pi*6/16)sqrt(2))^-1
00057 #define B7 3.62450978541155137218 // (cos(pi*7/16)sqrt(2))^-1
00058
00059
00060 #define A1 0.70710678118654752438 // cos(pi*4/16)
00061 #define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
00062 #define A5 0.38268343236508977170 // cos(pi*6/16)
00063 #define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
00064
00065 static const FLOAT postscale[64]={
00066 B0*B0, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B6, B0*B7,
00067 B1*B0, B1*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B6, B1*B7,
00068 B2*B0, B2*B1, B2*B2, B2*B3, B2*B4, B2*B5, B2*B6, B2*B7,
00069 B3*B0, B3*B1, B3*B2, B3*B3, B3*B4, B3*B5, B3*B6, B3*B7,
00070 B4*B0, B4*B1, B4*B2, B4*B3, B4*B4, B4*B5, B4*B6, B4*B7,
00071 B5*B0, B5*B1, B5*B2, B5*B3, B5*B4, B5*B5, B5*B6, B5*B7,
00072 B6*B0, B6*B1, B6*B2, B6*B3, B6*B4, B6*B5, B6*B6, B6*B7,
00073 B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7,
00074 };
00075
00076 static av_always_inline void row_fdct(FLOAT temp[64], DCTELEM * data)
00077 {
00078 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00079 FLOAT tmp10, tmp11, tmp12, tmp13;
00080 FLOAT z2, z4, z11, z13;
00081 FLOAT av_unused z5;
00082 int i;
00083
00084 for (i=0; i<8*8; i+=8) {
00085 tmp0= data[0 + i] + data[7 + i];
00086 tmp7= data[0 + i] - data[7 + i];
00087 tmp1= data[1 + i] + data[6 + i];
00088 tmp6= data[1 + i] - data[6 + i];
00089 tmp2= data[2 + i] + data[5 + i];
00090 tmp5= data[2 + i] - data[5 + i];
00091 tmp3= data[3 + i] + data[4 + i];
00092 tmp4= data[3 + i] - data[4 + i];
00093
00094 tmp10= tmp0 + tmp3;
00095 tmp13= tmp0 - tmp3;
00096 tmp11= tmp1 + tmp2;
00097 tmp12= tmp1 - tmp2;
00098
00099 temp[0 + i]= tmp10 + tmp11;
00100 temp[4 + i]= tmp10 - tmp11;
00101
00102 tmp12 += tmp13;
00103 tmp12 *= A1;
00104 temp[2 + i]= tmp13 + tmp12;
00105 temp[6 + i]= tmp13 - tmp12;
00106
00107 tmp4 += tmp5;
00108 tmp5 += tmp6;
00109 tmp6 += tmp7;
00110
00111 #if 0
00112 z5= (tmp4 - tmp6) * A5;
00113 z2= tmp4*A2 + z5;
00114 z4= tmp6*A4 + z5;
00115 #else
00116 z2= tmp4*(A2+A5) - tmp6*A5;
00117 z4= tmp6*(A4-A5) + tmp4*A5;
00118 #endif
00119 tmp5*=A1;
00120
00121 z11= tmp7 + tmp5;
00122 z13= tmp7 - tmp5;
00123
00124 temp[5 + i]= z13 + z2;
00125 temp[3 + i]= z13 - z2;
00126 temp[1 + i]= z11 + z4;
00127 temp[7 + i]= z11 - z4;
00128 }
00129 }
00130
00131 void ff_faandct(DCTELEM * data)
00132 {
00133 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00134 FLOAT tmp10, tmp11, tmp12, tmp13;
00135 FLOAT z2, z4, z11, z13;
00136 FLOAT av_unused z5;
00137 FLOAT temp[64];
00138 int i;
00139
00140 emms_c();
00141
00142 row_fdct(temp, data);
00143
00144 for (i=0; i<8; i++) {
00145 tmp0= temp[8*0 + i] + temp[8*7 + i];
00146 tmp7= temp[8*0 + i] - temp[8*7 + i];
00147 tmp1= temp[8*1 + i] + temp[8*6 + i];
00148 tmp6= temp[8*1 + i] - temp[8*6 + i];
00149 tmp2= temp[8*2 + i] + temp[8*5 + i];
00150 tmp5= temp[8*2 + i] - temp[8*5 + i];
00151 tmp3= temp[8*3 + i] + temp[8*4 + i];
00152 tmp4= temp[8*3 + i] - temp[8*4 + i];
00153
00154 tmp10= tmp0 + tmp3;
00155 tmp13= tmp0 - tmp3;
00156 tmp11= tmp1 + tmp2;
00157 tmp12= tmp1 - tmp2;
00158
00159 data[8*0 + i]= lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
00160 data[8*4 + i]= lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
00161
00162 tmp12 += tmp13;
00163 tmp12 *= A1;
00164 data[8*2 + i]= lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
00165 data[8*6 + i]= lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
00166
00167 tmp4 += tmp5;
00168 tmp5 += tmp6;
00169 tmp6 += tmp7;
00170
00171 #if 0
00172 z5= (tmp4 - tmp6) * A5;
00173 z2= tmp4*A2 + z5;
00174 z4= tmp6*A4 + z5;
00175 #else
00176 z2= tmp4*(A2+A5) - tmp6*A5;
00177 z4= tmp6*(A4-A5) + tmp4*A5;
00178 #endif
00179 tmp5*=A1;
00180
00181 z11= tmp7 + tmp5;
00182 z13= tmp7 - tmp5;
00183
00184 data[8*5 + i]= lrintf(SCALE(8*5 + i) * (z13 + z2));
00185 data[8*3 + i]= lrintf(SCALE(8*3 + i) * (z13 - z2));
00186 data[8*1 + i]= lrintf(SCALE(8*1 + i) * (z11 + z4));
00187 data[8*7 + i]= lrintf(SCALE(8*7 + i) * (z11 - z4));
00188 }
00189 }
00190
00191 void ff_faandct248(DCTELEM * data)
00192 {
00193 FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
00194 FLOAT tmp10, tmp11, tmp12, tmp13;
00195 FLOAT temp[64];
00196 int i;
00197
00198 emms_c();
00199
00200 row_fdct(temp, data);
00201
00202 for (i=0; i<8; i++) {
00203 tmp0 = temp[8*0 + i] + temp[8*1 + i];
00204 tmp1 = temp[8*2 + i] + temp[8*3 + i];
00205 tmp2 = temp[8*4 + i] + temp[8*5 + i];
00206 tmp3 = temp[8*6 + i] + temp[8*7 + i];
00207 tmp4 = temp[8*0 + i] - temp[8*1 + i];
00208 tmp5 = temp[8*2 + i] - temp[8*3 + i];
00209 tmp6 = temp[8*4 + i] - temp[8*5 + i];
00210 tmp7 = temp[8*6 + i] - temp[8*7 + i];
00211
00212 tmp10 = tmp0 + tmp3;
00213 tmp11 = tmp1 + tmp2;
00214 tmp12 = tmp1 - tmp2;
00215 tmp13 = tmp0 - tmp3;
00216
00217 data[8*0 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
00218 data[8*4 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
00219
00220 tmp12 += tmp13;
00221 tmp12 *= A1;
00222 data[8*2 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
00223 data[8*6 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
00224
00225 tmp10 = tmp4 + tmp7;
00226 tmp11 = tmp5 + tmp6;
00227 tmp12 = tmp5 - tmp6;
00228 tmp13 = tmp4 - tmp7;
00229
00230 data[8*1 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
00231 data[8*5 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
00232
00233 tmp12 += tmp13;
00234 tmp12 *= A1;
00235 data[8*3 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + tmp12));
00236 data[8*7 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - tmp12));
00237 }
00238 }