diff options
Diffstat (limited to 'kms++util/inc/kms++util/kms++util.h')
-rw-r--r-- | kms++util/inc/kms++util/kms++util.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h new file mode 100644 index 0000000..8e45b0d --- /dev/null +++ b/kms++util/inc/kms++util/kms++util.h | |||
@@ -0,0 +1,71 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <kms++/kms++.h> | ||
4 | |||
5 | #include <kms++util/color.h> | ||
6 | #include <kms++util/strhelpers.h> | ||
7 | #include <kms++util/cpuframebuffer.h> | ||
8 | #include <kms++util/extcpuframebuffer.h> | ||
9 | #include <kms++util/stopwatch.h> | ||
10 | #include <kms++util/opts.h> | ||
11 | #include <kms++util/resourcemanager.h> | ||
12 | |||
13 | #include <cstdio> | ||
14 | #include <cstdlib> | ||
15 | |||
16 | namespace kms | ||
17 | { | ||
18 | class IFramebuffer; | ||
19 | |||
20 | void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color); | ||
21 | void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2); | ||
22 | void draw_yuv420_macropixel(IFramebuffer& buf, unsigned x, unsigned y, | ||
23 | YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4); | ||
24 | void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color); | ||
25 | void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str, RGB color); | ||
26 | |||
27 | void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width); | ||
28 | |||
29 | void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim); | ||
30 | } | ||
31 | |||
32 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
33 | |||
34 | #define unlikely(x) __builtin_expect(!!(x), 0) | ||
35 | |||
36 | /* __STRING(x) is a glibcism (i.e. not standard), which happens to also | ||
37 | * be available in uClibc. However, musl does not define it. Do it here. | ||
38 | */ | ||
39 | #ifndef __STRING | ||
40 | #define __STRING(x) #x | ||
41 | #endif | ||
42 | |||
43 | #define ASSERT(x) \ | ||
44 | if (unlikely(!(x))) { \ | ||
45 | fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(x)); \ | ||
46 | abort(); \ | ||
47 | } | ||
48 | |||
49 | #define FAIL(fmt, ...) \ | ||
50 | do { \ | ||
51 | fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \ | ||
52 | abort(); \ | ||
53 | } while(0) | ||
54 | |||
55 | #define FAIL_IF(x, fmt, ...) \ | ||
56 | if (unlikely(x)) { \ | ||
57 | fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \ | ||
58 | abort(); \ | ||
59 | } | ||
60 | |||
61 | #define EXIT(fmt, ...) \ | ||
62 | do { \ | ||
63 | fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ | ||
64 | exit(-1); \ | ||
65 | } while(0) | ||
66 | |||
67 | #define EXIT_IF(x, fmt, ...) \ | ||
68 | if (unlikely(x)) { \ | ||
69 | fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ | ||
70 | exit(-1); \ | ||
71 | } | ||