H261 decoder
Dependencies: SDL_lib2 SX1276Lib mbed
main.cpp
- Committer:
- miruga27
- Date:
- 2016-09-22
- Revision:
- 0:5bd441b8ab2d
- Child:
- 1:1ed97958d0f3
File content as of revision 0:5bd441b8ab2d:
/* * decoder.c * * Created on: 5/7/2016 * Author: Miguel Ruiz García Company: University of Cantabria e-mail:mrg47@alumnos.unican.es */ #include <SDL.h> #include <stdio.h> #include "mbed.h" #include "functions_dec.h" #include "lora.h" #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) ; int i=0,j=0,p_x=0,p_y=0,k=0; short int m[HEIGHT][WIDTH][3]; short int *matriz=(short int *)malloc(sizeof(short int)*WIDTH*HEIGHT*3); short int acumulador[3]={0,0,0}; short int *temp1,*temp2,*temp3;//these are vectors. Memory allocations are done at lora function. lora(temp1,acumulador[0],temp2,acumulador[1],temp3,acumulador[2]);//acumulador tells the length of the respective vector(acumulador[0] -> temp1,...) int indice=0; //We must "unroll" the vectors after being processed with the RLC (in the encoder) for(i=0;i<acumulador[0]>>1;i++){ for(j=k;j<*(temp1+indice)+k;j++){ *(matriz+j*3)=*(temp1+indice+1); } k=j; indice+=2; } indice=0; k=0; for(i=0;i<acumulador[1]>>1;i++){ for(j=k;j<*(temp2+indice)+k;j++){ *(matriz+j*3+1)=*(temp2+indice+1); } k=j; indice+=2; } indice=0; k=0; for(i=0;i<acumulador[2]>>1;i++){ for(j=k;j<*(temp3+indice)+k;j++){ *(matriz+j*3+2)=*(temp3+indice+1); } k=j; indice+=2; } zig_zag_dec(m,matriz); cuantizador_dec(m); int matrix[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++){ matrix[k-i][l-j][0]=m[k][l][0]; matrix[k-i][l-j][1]=m[k][l][1]; matrix[k-i][l-j][2]=m[k][l][2]; } } IDCT(matrix,m,i,j);// i j índices de los pixeles en x e y del macrobloque } } int bpp=3; for(i=0;i<HEIGHT;i++){ for(j=0;j<WIDTH;j++){ if(m[i][j][0]>235) m[i][j][0]=235; if(m[i][j][1]>235) m[i][j][1]=235; if(m[i][j][2]>240) m[i][j][2]=240; if(m[i][j][0]<16) m[i][j][0]=16; if(m[i][j][1]<16) m[i][j][1]=16; if(m[i][j][2]<16) m[i][j][2]=16; } } yuv_to_rgb(m); for(i=0;i<8;i++){ for(j=0;j<320;j++){ while(!pc.writeable()); pc.printf("%u",(unsigned char)m[i][j][0]); while(!pc.writeable()); pc.printf("%u",(unsigned char)m[i][j][1]); while(!pc.writeable()); pc.printf("%u",(unsigned char)m[i][j][2]); } } return 0; }