JPEG compressor
Dependencies: SDL_lib SX1276Lib mbed
encoder.cpp
- Committer:
- miruga27
- Date:
- 2016-09-22
- Revision:
- 1:f0c646dfe574
- Parent:
- 0:1076a8b67c6c
- Child:
- 2:f256eebcade8
File content as of revision 1:f0c646dfe574:
//Author: Miguel Ruiz García //Company: University of Cantabria. 2016 //mail: mrg47@alumnos.unican.es #include "mbed.h" #include "stdio.h" #include <math.h> #include "SDL_lib/SDL.h" #include "functions.h" //#include "lora2.h" #include "lora_tansc.h" DigitalOut myled(LED1); DigitalIn button(PC_13); Serial uart(PA_2, PA_3); #define BPS 128000 #define BITS 8 #define STOP_BITS 1 int main(int argc, char *argv[]){ Serial pc(USBTX, USBRX); pc.baud(BPS); pc.format (BITS,SerialBase::None, STOP_BITS) ; myled=1; wait (5); myled=0; short int m[HEIGHT][WIDTH][3]; int i,j,veces=0; for(veces=0;veces<120;veces++){ myled=0; for(i=0;i<8;i++){ for(j=0;j<320;j++){ while(!pc.readable()); m[i][j][0]=(char)pc.getc(); while(!pc.readable()); m[i][j][1]=(char)pc.getc(); while(!pc.readable()); m[i][j][2]=(char)pc.getc(); } } myled=1; rgb_to_yuv(m); int mat[8][8][3]; for(i=0;i<HEIGHT;i+=8){ for(j=0;j<WIDTH;j+=8){ int k=0,l=0; for(k=i;k<i+8;k++){ for(l=j;l<j+8;l++){ mat[k-i][l-j][0]=m[k][l][0]; mat[k-i][l-j][1]=m[k][l][1]; mat[k-i][l-j][2]=m[k][l][2]; } } DCT(mat,m,i,j);// 'i' 'j' índices de los pixeles en x e y del macrobloque } } cuantizador(m); short int *matriz =(short int *) malloc(sizeof(short int)*HEIGHT*WIDTH*3); zig_zag(m,matriz);//OJO!!!!! short int acumulador[3]={0,0,0}; RLC(matriz,acumulador); short int * temp1= (short int *) malloc(sizeof(short int)*acumulador[0]);//reserva de memoria exacta para cada una de las componenetes y u v short int * temp2= (short int *) malloc(sizeof(short int)*acumulador[1]); short int * temp3= (short int *) malloc(sizeof(short int)*acumulador[2]); RLC2(matriz,temp1,temp2,temp3); free(matriz); lora(temp1,acumulador[0],temp2,acumulador[1],temp3,acumulador[2]); free(temp1); free(temp2); free(temp3); while(!pc.writeable()); pc.printf("1");//OJO con ponerlo aqui arriba } //http://www.martin-gardner.co.uk/how-to-connect-your-old-sd-card-to-an-arduino/ while(1){ myled=1; wait(0.2); myled=0; wait(0.2); } }