JPEG compressor
Dependencies: SDL_lib SX1276Lib mbed
Diff: functions.h
- Revision:
- 2:f256eebcade8
- Parent:
- 1:f0c646dfe574
--- a/functions.h Thu Sep 22 00:01:55 2016 +0000 +++ b/functions.h Wed Jan 11 20:20:00 2017 +0000 @@ -9,6 +9,15 @@ #define DEPTH 24 #define RAIZ2 1.414214 #define PI16 0.19635 +const float coeff[8][8]={ + {1.000, 0.980658, 0.923381, 0.830384, 0.705265, 0.552863, 0.379075, 0.190623}, + {1.000000, 0.830384, 0.379075, -0.200829, -0.712605, -0.982642, -0.919336, -0.544161}, + {1.000000, 0.552863, -0.388685, -0.982642, -0.697848, 0.211013, 0.931171, 0.818607}, + {1.000000, 0.190623, -0.927326, -0.544161, 0.719867, 0.818607, -0.407777, -0.974070}, + {1.000000, -0.200829, -0.919336, 0.570086, 0.690356, -0.847373, -0.350003, 0.987954}, + {1.000000, -0.561505, -0.369424, 0.976372, -0.727052, -0.159885, 0.906605, -0.858241}, + {1.000000, -0.836138, 0.398253, 0.170150, -0.682790, 0.971663, -0.942098, 0.603785}, + {1.000000, -0.982642, 0.931171, -0.847373, 0.734158, -0.595456, 0.436082, -0.261569} }; void DCT(int matrix[8][8][3],short int f[HEIGHT][WIDTH][3],int p_fil,int p_col){ @@ -44,8 +53,11 @@ for(j=0;j<8;j++){ - dato=(float)(cos((float)(((j*2)+1)*(v-p_col)*PI16))); - dato2=(float)(cos((float)(((i*2)+1)*(u-p_fil)*PI16))); + /*dato=(float)(cos((float)(((j*2)+1)*(v-p_col)*PI16))); + dato2=(float)(cos((float)(((i*2)+1)*(u-p_fil)*PI16)));*/ + + dato=coeff[j][v-p_col];//(float)(cos((float)(((j*2)+1)*(v-p_col)*PI16)));// + dato2=coeff[i][u-p_fil]; acum0+=(float)(dato*dato2*(matrix[i][j][0]));//crominancia V acum1+=(float)(dato*dato2*(matrix[i][j][1]));//crominancia U @@ -197,10 +209,10 @@ int i,k=0,acum_y=0,acum_u=0,acum_v=0; short int y,u,v,y_ant=0,u_ant=0,v_ant=0,flag=0; - int cont[3]={1,1,1}; - acumulador[0]=0; - acumulador[1]=0; - acumulador[2]=0; + short int cont[3]={1,1,1}; + acumulador[0]=0x0000; + acumulador[1]=0x0000; + acumulador[2]=0x0000; int index=0; for(i=0;i<WIDTH*HEIGHT*3;i+=3){