blob: 8b0d0d57933375109f691540f33e9b453f550b89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
}
|