#include #include #include #define WIDTH 640 #define HEIGHT 360 int *yplane; int *uplane; int *vplane; char y4mheader[] = "YUV4MPEG2 W%u H%u F%s:1 Ip A1:1\n"; char frameheader[] = "FRAME\n"; int main(int argc, char **argv) { int i,w = WIDTH,h = HEIGHT; char fps[64] = "30"; int framesize; FILE *fp = stdout; if (argc > 1) { w = atoi(argv[1]); if (argc > 2) { h = atoi(argv[2]); if (argc > 3) strcpy(fps,argv[3]); } } w &= ~1; h &= ~3; framesize = (w*h)>>2; _setmode( _fileno(fp), _O_BINARY ); yplane = malloc(framesize<<2); memset(yplane,0x5F,framesize<<2); uplane = malloc(framesize); memset(uplane,0x10,framesize); vplane = malloc(framesize); memset(vplane,0x10,framesize); fprintf(fp,y4mheader,w,h,fps); while(1){ int *q; for(i=w/8;i;i--){ q = vplane + i; int j; for(j=h/2-1;j>=0;j--){ q[1] = 0x10101010; q[0] = 0xF0F0F0F0; q += w>>3; } fprintf(fp,frameheader); if (!fwrite(yplane,framesize<<2,1,fp)) return 0; if (!fwrite(uplane,framesize,1,fp)) return 0; if (!fwrite(vplane,framesize,1,fp)) return 0; } q = vplane; for(i=h/2;i;i--){ q[0] = q[1] = 0; q += w>>3; } } return 1; }