diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2026-02-25 20:43:25 -0600 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2026-02-25 20:43:25 -0600 |
| commit | 89926aaf654f9edd79f58eb4e39d826f9690c456 (patch) | |
| tree | f6156f6fe1703d08eb73ba152edcab0194840308 | |
| parent | 45cbc68f2fc76cc7da81b9cf3cf4a1692786e86b (diff) | |
yuvbench: Test
| -rwxr-xr-x | yuvbench/build-linux-x86_64-gcc.sh | 7 | ||||
| -rw-r--r-- | yuvbench/yuvbench.c | 55 | ||||
| -rw-r--r-- | yuvbench/yuvbench.h | 7 | ||||
| -rw-r--r-- | yuvbench/yuvbench_bad.c | 0 |
4 files changed, 69 insertions, 0 deletions
diff --git a/yuvbench/build-linux-x86_64-gcc.sh b/yuvbench/build-linux-x86_64-gcc.sh new file mode 100755 index 0000000..555a195 --- /dev/null +++ b/yuvbench/build-linux-x86_64-gcc.sh @@ -0,0 +1,7 @@ +#!/bin/sh +CFLAGS="-Wall -Wextra -Wpedantic -O3 -g -DYUVBENCH_BAD" +LFLAGS="" +mkdir -p build +gcc -o build/yuvbench.o $CFLAGS -c ./yuvbench.c +gcc -o build/yuvbench_bad.o $CFLAGS -c ./yuvbench_bad.c +gcc -o build/yuvbench $LFLAGS build/yuvbench.o build/yuvbench_bad.o diff --git a/yuvbench/yuvbench.c b/yuvbench/yuvbench.c new file mode 100644 index 0000000..8b0d0d5 --- /dev/null +++ b/yuvbench/yuvbench.c @@ -0,0 +1,55 @@ +#include "yuvbench.h" + +int main(int argc, char** argv) +{ + // The source file should be raw YUV 4:2:0 pixel data packed with no padding. + // File name should be [whatever]-<width>x<height>.yuv + if (argc < 2) { + printf("No file supplied\n"); + return 1; + } + + // Decode with and height from file name + int inp_w = 0; + int inp_h = 0; + { + // Scan for last "-" + const char* suffix = 0; + for (const char* s = argv[1]; *s; ++s) { + if (*s == '-') { + suffix = s + 1; + } + } + if (!suffix) { + printf("Invalid file name. See comments in yuvbench.c\n"); + return 1; + } + // Decode width and height + for (; *suffix; ++suffix) { + const char c = *suffix; + if (c >= '0' && c <= '9') { + inp_w *= 10; + inp_w += (int)(c - '0'); + } else if (c == 'x') { + ++suffix; + break; + } else { + printf("Invalid file name. See comments in yuvbench.c\n"); + return 1; + } + } + for (; *suffix; ++suffix) { + const char c = *suffix; + if (c >= '0' && c <= '9') { + inp_h *= 10; + inp_h += (int)(c - '0'); + } else if (c == '.') { + break; + } else { + printf("Invalid file name. See comments in yuvbench.c\n"); + return 1; + } + } + } + printf("Input image is %dx%d YUV 4:2:0\n", inp_w, inp_h); +} diff --git a/yuvbench/yuvbench.h b/yuvbench/yuvbench.h new file mode 100644 index 0000000..fafa933 --- /dev/null +++ b/yuvbench/yuvbench.h @@ -0,0 +1,7 @@ +#ifndef _YUVBENCH_H_ +#define _YUVBENCH_H_ + +#include <stdio.h> + +#endif // _YUVBENCH_H_ + diff --git a/yuvbench/yuvbench_bad.c b/yuvbench/yuvbench_bad.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/yuvbench/yuvbench_bad.c |