📄 raw_number_select.c
字号:
/*--------------------------------------------------------
brief : select N frame from X frame
author : Jun Wang
data : 2008.08.8
--------------------------------------------------------*/
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <malloc.h>
typedef unsigned char UCHAR;
typedef unsigned long ULONG;
#define Width 1280 //352, 1920, 1280
#define Height 720 //288, 1080, 720
#define RAW_FILE "720p50_shields_ter.yuv"
#define RAW_CUT_FILE "shields_720p500f.yuv"
#define SIZE (Width*Height)
#define Frame_num 500
#define Start_num 2 // count from 0
/*-----------------------------------------
brief : Main function.
-----------------------------------------*/
void main()
{
int i;
FILE *fraw, *fraw_t;
UCHAR *Y, *Cr, *Cb;
Y = (UCHAR*)malloc(Width * Height);
Cr = (UCHAR*)malloc((Width/2)*(Height/2));
Cb = (UCHAR*)malloc((Width/2)*(Height/2));
if ((fraw = fopen(RAW_FILE, "rb")) ==NULL)
{
fprintf(stderr, "error: cannot open raw file!\n");
exit(1);
}
fraw_t = fopen(RAW_CUT_FILE, "wb");
for (i=0; i < (Frame_num+Start_num); i++)
{
fread(Y , 1, SIZE , fraw);
fread(Cr, 1, SIZE/4, fraw);
fread(Cb, 1, SIZE/4, fraw);
if(i>=Start_num)
{
fwrite(Y , 1, SIZE , fraw_t);
fwrite(Cr, 1, SIZE/4, fraw_t);
fwrite(Cb, 1, SIZE/4, fraw_t);
}
}
fclose (fraw);
fclose (fraw_t);
free(Y);
free(Cr);
free(Cb);
printf ("raw2bmp is success!!!\nyou are great!!!\n");
} //the end of main //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -