process.c
来自「足球机器人自动程序」· C语言 代码 · 共 61 行
C
61 行
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/mman.h>#include "global.h"#include "dec.h"char *filename;unsigned char src[YUV_SIZE];static inline void print_help(char *argv0) { fprintf(stderr, "Usage: %s file\n", argv0);}void process(int argc, char *argv[]) { if (argc != 2) { print_help(argv[0]); exit(-1); } if (!strcmp(argv[1], "-h")) { print_help(argv[0]); exit(0); } filename = argv[1]; int fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(-1); } char *suffix = strrchr(filename, '.'); if (suffix == NULL) { fprintf(stderr, "unknown filename: %s\n", filename); exit(-1); } ++suffix; if (!strcmp(suffix, "raw")) { unsigned char *raw = mmap(NULL, RAW_SIZE, PROT_READ, MAP_SHARED, fd, 0); if (raw == MAP_FAILED) { perror("mmap"); exit(-1); } dec_init(); dec_process(raw, src); } else { fprintf(stderr, "unknown filename: %s\n", filename); exit(-1); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?