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 static double coefficients[8 * 8];
00034
00039 av_cold void ff_ref_dct_init(void)
00040 {
00041 unsigned int i, j;
00042
00043 for (j = 0; j < 8; ++j) {
00044 coefficients[j] = sqrt(0.125);
00045 for (i = 8; i < 64; i += 8) {
00046 coefficients[i + j] = 0.5 * cos(i * (j + 0.5) * M_PI / 64.0);
00047 }
00048 }
00049 }
00050
00057 void ff_ref_fdct(short *block)
00058 {
00059
00060
00061 unsigned int i, j, k;
00062 double out[8 * 8];
00063
00064
00065 for (i = 0; i < 64; i += 8) {
00066 for (j = 0; j < 8; ++j) {
00067 double tmp = 0;
00068 for (k = 0; k < 8; ++k) {
00069 tmp += coefficients[i + k] * block[k * 8 + j];
00070 }
00071 out[i + j] = tmp * 8;
00072 }
00073 }
00074
00075
00076 for (j = 0; j < 8; ++j) {
00077 for (i = 0; i < 64; i += 8) {
00078 double tmp = 0;
00079 for (k = 0; k < 8; ++k) {
00080 tmp += out[i + k] * coefficients[j * 8 + k];
00081 }
00082 block[i + j] = floor(tmp + 0.499999999999);
00083 }
00084 }
00085 }
00086
00093 void ff_ref_idct(short *block)
00094 {
00095
00096
00097 unsigned int i, j, k;
00098 double out[8 * 8];
00099
00100
00101 for (i = 0; i < 64; i += 8) {
00102 for (j = 0; j < 8; ++j) {
00103 double tmp = 0;
00104 for (k = 0; k < 8; ++k) {
00105 tmp += block[i + k] * coefficients[k * 8 + j];
00106 }
00107 out[i + j] = tmp;
00108 }
00109 }
00110
00111
00112 for (i = 0; i < 8; ++i) {
00113 for (j = 0; j < 8; ++j) {
00114 double tmp = 0;
00115 for (k = 0; k < 64; k += 8) {
00116 tmp += coefficients[k + i] * out[k + j];
00117 }
00118 block[i * 8 + j] = floor(tmp + 0.5);
00119 }
00120 }
00121 }