00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00032 #include "libavutil/mathematics.h"
00033 #include "dctref.h"
00034
00035 static double coefficients[8 * 8];
00036
00041 av_cold void ff_ref_dct_init(void)
00042 {
00043 unsigned int i, j;
00044
00045 for (j = 0; j < 8; ++j) {
00046 coefficients[j] = sqrt(0.125);
00047 for (i = 8; i < 64; i += 8) {
00048 coefficients[i + j] = 0.5 * cos(i * (j + 0.5) * M_PI / 64.0);
00049 }
00050 }
00051 }
00052
00059 void ff_ref_fdct(short *block)
00060 {
00061
00062
00063 unsigned int i, j, k;
00064 double out[8 * 8];
00065
00066
00067 for (i = 0; i < 64; i += 8) {
00068 for (j = 0; j < 8; ++j) {
00069 double tmp = 0;
00070 for (k = 0; k < 8; ++k) {
00071 tmp += coefficients[i + k] * block[k * 8 + j];
00072 }
00073 out[i + j] = tmp * 8;
00074 }
00075 }
00076
00077
00078 for (j = 0; j < 8; ++j) {
00079 for (i = 0; i < 64; i += 8) {
00080 double tmp = 0;
00081 for (k = 0; k < 8; ++k) {
00082 tmp += out[i + k] * coefficients[j * 8 + k];
00083 }
00084 block[i + j] = floor(tmp + 0.499999999999);
00085 }
00086 }
00087 }
00088
00095 void ff_ref_idct(short *block)
00096 {
00097
00098
00099 unsigned int i, j, k;
00100 double out[8 * 8];
00101
00102
00103 for (i = 0; i < 64; i += 8) {
00104 for (j = 0; j < 8; ++j) {
00105 double tmp = 0;
00106 for (k = 0; k < 8; ++k) {
00107 tmp += block[i + k] * coefficients[k * 8 + j];
00108 }
00109 out[i + j] = tmp;
00110 }
00111 }
00112
00113
00114 for (i = 0; i < 8; ++i) {
00115 for (j = 0; j < 8; ++j) {
00116 double tmp = 0;
00117 for (k = 0; k < 64; k += 8) {
00118 tmp += coefficients[k + i] * out[k + j];
00119 }
00120 block[i * 8 + j] = floor(tmp + 0.5);
00121 }
00122 }
00123 }