cvt_test.c

来自「足球机器人自动程序」· C语言 代码 · 共 43 行

C
43
字号
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <sys/mman.h>#include "global.h"#include "cvt.h"int main(int argc, char *argv[]) {	int fdi = open("../data/test.yuv", O_RDONLY);	if (fdi < 0) {		perror("open input file");		return -1;	}	int fdo = open("test.bgr", O_CREAT | O_WRONLY | O_TRUNC, 00644);	if (fdo < 0) {		perror("open output file");		return -1;	}	unsigned char *src = (unsigned char *)mmap(NULL, YUV_SIZE, PROT_READ, MAP_SHARED, fdi, 0);	if (!(src + 1)) {		perror("mmap");		return -1;	}	unsigned char dst[Y_SIZE*4];	cvt(src, dst);	if (write(fdo, dst, sizeof(dst)) < 0) {		perror("write");	}	close(fdo);	close(fdi);	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?