00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <math.h>
00024
00025 #include "config.h"
00026
00027 #ifndef PI
00028 # define PI 3.14159265358979323846
00029 #endif
00030
00031
00032 void init_idctref _ANSI_ARGS_((void));
00033 void idctref _ANSI_ARGS_((short *block));
00034
00035
00036
00037
00038 static double c[8][8];
00039
00040
00041
00042 void init_idctref()
00043 {
00044 int freq, time;
00045 double scale;
00046
00047 for (freq=0; freq < 8; freq++)
00048 {
00049 scale = (freq == 0) ? sqrt(0.125) : 0.5;
00050 for (time=0; time<8; time++)
00051 c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
00052 }
00053 }
00054
00055
00056
00057 void idctref(block)
00058 short *block;
00059 {
00060 int i, j, k, v;
00061 double partial_product;
00062 double tmp[64];
00063
00064 for (i=0; i<8; i++)
00065 for (j=0; j<8; j++)
00066 {
00067 partial_product = 0.0;
00068
00069 for (k=0; k<8; k++)
00070 partial_product+= c[k][j]*block[8*i+k];
00071
00072 tmp[8*i+j] = partial_product;
00073 }
00074
00075
00076
00077
00078 for (j=0; j<8; j++)
00079 for (i=0; i<8; i++)
00080 {
00081 partial_product = 0.0;
00082
00083 for (k=0; k<8; k++)
00084 partial_product+= c[k][i]*tmp[8*k+j];
00085
00086 v = floor(partial_product+0.5);
00087 block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
00088 }
00089 }