📄 dct.c
字号:
#include <stdlib.h> #include <stdio.h>#include <string.h> #include <SDL.h> #include <fftw3.h>#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h>#include <unistd.h>#include <pthread.h>#include <semaphore.h>#include <sys/ipc.h> #define N4 6#define N3 3#define N2 2#define N1 1#define W 768#define H 432 #define FILENAME "source.yuv" #define OUTPUT "SVC.yuv" unsigned char data[H*W*3/2];unsigned char data3[H*W*27/128];int flag=0;int main(){ FILE *f,*output; double *in,*out; unsigned char *point,*point1; fftw_plan p1,p2,p3,p4,p14; int i,j,a,yblock,uvblock,count_yblk,count_uvblk,pix,piy,gop,pix3,piy3,qt; if ((f = fopen(FILENAME, "rb")) == NULL) { perror("fopen"); exit(1); } if ((output = fopen(OUTPUT, "wb")) == NULL) { perror("fopen"); exit(1); } in =(double *)fftw_malloc(sizeof(double)*N4*N4); out =(double *)fftw_malloc(sizeof(double)*N4*N4); p4=fftw_plan_r2r_2d(N4, N4, in, out, FFTW_REDFT10, FFTW_REDFT10, FFTW_ESTIMATE); p14=fftw_plan_r2r_2d(N4, N4, out, in, FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE); p3=fftw_plan_r2r_2d(N3, N3, out, in, FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE); p2=fftw_plan_r2r_2d(N2, N2, out, in, FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE); p1=fftw_plan_r2r_2d(N1, N1, out, in, FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE); yblock=H*W/64; uvblock=yblock>>2; count_yblk=W>>3; count_uvblk=count_yblk>>1; for(gop=0;gop<300;gop++){ if(fread(data, H*W*3/2, 1, f) != 1){ return; } /* Y component DCT*/ pix=piy=pix3=piy3=0; for(a=0;a<yblock;a++){ fftw_execute(p4); } /* UV component DCT*/ pix=piy=pix3=piy3=0; for(a=0;a<uvblock;a++){ fftw_execute(p4); fftw_execute(p4); pix+=8; pix3+=3; if((a+1)%count_uvblk==0){ pix=0; pix3=0; piy+=8; piy3+=3; } } if(fwrite(data3, H*W*27/128, 1, output) != 1){ return; } } fftw_destroy_plan(p4); fftw_destroy_plan(p3); fftw_free(in); fftw_free(out); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -