summaryrefslogtreecommitdiff
path: root/kms++util
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2020-10-07 08:58:35 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-10-09 15:54:43 +0300
commitd9a1ffe56d0beb9cdd048d0e83f7d0177b31411a (patch)
tree6227b71ee23bfa344b4cd5896ec485409158a0bc /kms++util
parent37d27443432b7b84d256bd5a7c505e7ef8e09bbd (diff)
Bulk format of all files
Diffstat (limited to 'kms++util')
-rw-r--r--kms++util/inc/kms++util/color.h8
-rw-r--r--kms++util/inc/kms++util/cpuframebuffer.h8
-rw-r--r--kms++util/inc/kms++util/extcpuframebuffer.h5
-rw-r--r--kms++util/inc/kms++util/kms++util.h42
-rw-r--r--kms++util/inc/kms++util/opts.h1
-rw-r--r--kms++util/inc/kms++util/resourcemanager.h6
-rw-r--r--kms++util/inc/kms++util/strhelpers.h4
-rw-r--r--kms++util/inc/kms++util/videodevice.h3
-rw-r--r--kms++util/src/color.cpp58
-rw-r--r--kms++util/src/colorbar.cpp8
-rw-r--r--kms++util/src/cpuframebuffer.cpp10
-rw-r--r--kms++util/src/drawing.cpp113
-rw-r--r--kms++util/src/extcpuframebuffer.cpp3
-rw-r--r--kms++util/src/font_8x8.h1
-rw-r--r--kms++util/src/opts.cpp2
-rw-r--r--kms++util/src/testpat.cpp5
-rw-r--r--kms++util/src/videodevice.cpp39
17 files changed, 142 insertions, 174 deletions
diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h
index fa05fbc..5232b37 100644
--- a/kms++util/inc/kms++util/color.h
+++ b/kms++util/inc/kms++util/color.h
@@ -14,8 +14,7 @@ enum class YUVType {
MAX,
};
-struct RGB
-{
+struct RGB {
RGB();
RGB(uint8_t r, uint8_t g, uint8_t b);
RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
@@ -47,8 +46,7 @@ struct RGB
uint8_t a;
};
-struct YUV
-{
+struct YUV {
YUV();
YUV(uint8_t y, uint8_t u, uint8_t v);
YUV(const RGB& rgb, YUVType type = YUVType::BT601_Lim);
@@ -58,4 +56,4 @@ struct YUV
uint8_t y;
uint8_t a;
};
-}
+} // namespace kms
diff --git a/kms++util/inc/kms++util/cpuframebuffer.h b/kms++util/inc/kms++util/cpuframebuffer.h
index 4273e0d..e4de150 100644
--- a/kms++util/inc/kms++util/cpuframebuffer.h
+++ b/kms++util/inc/kms++util/cpuframebuffer.h
@@ -4,8 +4,8 @@
namespace kms
{
-
-class CPUFramebuffer : public IFramebuffer {
+class CPUFramebuffer : public IFramebuffer
+{
public:
CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format);
@@ -30,7 +30,7 @@ private:
uint32_t size;
uint32_t stride;
uint32_t offset;
- uint8_t *map;
+ uint8_t* map;
};
uint32_t m_width;
@@ -41,4 +41,4 @@ private:
struct FramebufferPlane m_planes[4];
};
-}
+} // namespace kms
diff --git a/kms++util/inc/kms++util/extcpuframebuffer.h b/kms++util/inc/kms++util/extcpuframebuffer.h
index 92ca43a..29a06c0 100644
--- a/kms++util/inc/kms++util/extcpuframebuffer.h
+++ b/kms++util/inc/kms++util/extcpuframebuffer.h
@@ -4,7 +4,6 @@
namespace kms
{
-
class ExtCPUFramebuffer : public IFramebuffer
{
public:
@@ -30,7 +29,7 @@ private:
uint32_t size;
uint32_t stride;
uint32_t offset;
- uint8_t *map;
+ uint8_t* map;
};
uint32_t m_width;
@@ -40,4 +39,4 @@ private:
unsigned m_num_planes;
struct FramebufferPlane m_planes[4];
};
-}
+} // namespace kms
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h
index 8fc6c8b..52b6ce9 100644
--- a/kms++util/inc/kms++util/kms++util.h
+++ b/kms++util/inc/kms++util/kms++util.h
@@ -21,15 +21,15 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color);
void draw_yuv444_pixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv);
void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2);
void draw_yuv420_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
- YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4);
-void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
+ YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4);
+void draw_rect(IFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
void draw_circle(IFramebuffer& fb, int32_t xCenter, int32_t yCenter, int32_t radius, RGB color);
void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str, RGB color);
void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width);
-void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim);
-}
+void draw_test_pattern(IFramebuffer& fb, YUVType yuvt = YUVType::BT601_Lim);
+} // namespace kms
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -42,32 +42,32 @@ void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim);
#define __STRING(x) #x
#endif
-#define ASSERT(x) \
- if (unlikely(!(x))) { \
+#define ASSERT(x) \
+ if (unlikely(!(x))) { \
fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(x)); \
- abort(); \
+ abort(); \
}
-#define FAIL(fmt, ...) \
- do { \
+#define FAIL(fmt, ...) \
+ do { \
fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
- abort(); \
- } while(0)
+ abort(); \
+ } while (0)
-#define FAIL_IF(x, fmt, ...) \
- if (unlikely(x)) { \
+#define FAIL_IF(x, fmt, ...) \
+ if (unlikely(x)) { \
fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
- abort(); \
+ abort(); \
}
-#define EXIT(fmt, ...) \
- do { \
+#define EXIT(fmt, ...) \
+ do { \
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
- exit(-1); \
- } while(0)
+ exit(-1); \
+ } while (0)
-#define EXIT_IF(x, fmt, ...) \
- if (unlikely(x)) { \
+#define EXIT_IF(x, fmt, ...) \
+ if (unlikely(x)) { \
fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
- exit(-1); \
+ exit(-1); \
}
diff --git a/kms++util/inc/kms++util/opts.h b/kms++util/inc/kms++util/opts.h
index 1b0fd22..6058b27 100644
--- a/kms++util/inc/kms++util/opts.h
+++ b/kms++util/inc/kms++util/opts.h
@@ -7,6 +7,7 @@
class Option
{
friend class OptionSet;
+
public:
Option(const std::string& str, std::function<void()> func);
Option(const std::string& str, std::function<void(const std::string)> func);
diff --git a/kms++util/inc/kms++util/resourcemanager.h b/kms++util/inc/kms++util/resourcemanager.h
index 3301da2..11c11b3 100644
--- a/kms++util/inc/kms++util/resourcemanager.h
+++ b/kms++util/inc/kms++util/resourcemanager.h
@@ -2,8 +2,8 @@
#include <set>
#include <string>
-namespace kms {
-
+namespace kms
+{
class ResourceManager
{
public:
@@ -32,4 +32,4 @@ private:
std::set<Plane*> m_reserved_planes;
};
-}
+} // namespace kms
diff --git a/kms++util/inc/kms++util/strhelpers.h b/kms++util/inc/kms++util/strhelpers.h
index 2d35e93..c4032d7 100644
--- a/kms++util/inc/kms++util/strhelpers.h
+++ b/kms++util/inc/kms++util/strhelpers.h
@@ -5,7 +5,7 @@
std::string to_lower(const std::string& str);
-template <typename T>
+template<typename T>
std::string join(const T& values, const std::string& delim)
{
std::ostringstream ss;
@@ -17,7 +17,7 @@ std::string join(const T& values, const std::string& delim)
return ss.str();
}
-template <typename T>
+template<typename T>
std::string join(const std::vector<T>& values, const std::string& delim, std::function<std::string(T)> func)
{
std::ostringstream ss;
diff --git a/kms++util/inc/kms++util/videodevice.h b/kms++util/inc/kms++util/videodevice.h
index 0aaa103..3bce4a9 100644
--- a/kms++util/inc/kms++util/videodevice.h
+++ b/kms++util/inc/kms++util/videodevice.h
@@ -9,8 +9,7 @@ class VideoStreamer;
class VideoDevice
{
public:
- struct VideoFrameSize
- {
+ struct VideoFrameSize {
uint32_t min_w, max_w, step_w;
uint32_t min_h, max_h, step_h;
};
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 2d45eff..74ff8c9 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -9,7 +9,7 @@ RGB::RGB()
}
RGB::RGB(uint8_t r, uint8_t g, uint8_t b)
- :RGB(255, r, g, b)
+ : RGB(255, r, g, b)
{
}
@@ -110,33 +110,27 @@ YUV RGB::yuv(YUVType type) const
}
#define CF_ONE (256)
-#define CF(a, b, c) { ((int) ((a) * CF_ONE)), ((int) ((b) * CF_ONE)), ((int) ((c) * CF_ONE)) }
-#define CLAMP(a) ((a) > (CF_ONE-1) ? (CF_ONE-1) : (a) < 0 ? 0 : (a))
+#define CF(a, b, c) \
+ { \
+ ((int)((a)*CF_ONE)), ((int)((b)*CF_ONE)), ((int)((c)*CF_ONE)) \
+ }
+#define CLAMP(a) ((a) > (CF_ONE - 1) ? (CF_ONE - 1) : (a) < 0 ? 0 : (a))
const int YUVcoef[static_cast<unsigned>(YUVType::MAX)][3][3] = {
[static_cast<unsigned>(YUVType::BT601_Lim)] = {
- CF( 0.257, 0.504, 0.098),
- CF(-0.148, -0.291, 0.439),
- CF( 0.439, -0.368, -0.071) },
- [static_cast<unsigned>(YUVType::BT601_Full)] = {
- CF( 0.299, 0.587, 0.114),
- CF(-0.169, -0.331, 0.500),
- CF( 0.500, -0.419, -0.081) },
- [static_cast<unsigned>(YUVType::BT709_Lim)] = {
- CF( 0.1826, 0.6142, 0.0620),
- CF(-0.1006, -0.3386, 0.4392),
- CF( 0.4392, -0.3989, -0.0403) },
- [static_cast<unsigned>(YUVType::BT709_Full)] = {
- CF( 0.2126, 0.7152, 0.0722),
- CF(-0.1146, -0.3854, 0.5000),
- CF( 0.5000, -0.4542, -0.0468) },
+ CF(0.257, 0.504, 0.098),
+ CF(-0.148, -0.291, 0.439),
+ CF(0.439, -0.368, -0.071) },
+ [static_cast<unsigned>(YUVType::BT601_Full)] = { CF(0.299, 0.587, 0.114), CF(-0.169, -0.331, 0.500), CF(0.500, -0.419, -0.081) },
+ [static_cast<unsigned>(YUVType::BT709_Lim)] = { CF(0.1826, 0.6142, 0.0620), CF(-0.1006, -0.3386, 0.4392), CF(0.4392, -0.3989, -0.0403) },
+ [static_cast<unsigned>(YUVType::BT709_Full)] = { CF(0.2126, 0.7152, 0.0722), CF(-0.1146, -0.3854, 0.5000), CF(0.5000, -0.4542, -0.0468) },
};
const int YUVoffset[static_cast<unsigned>(YUVType::MAX)][3] = {
- [static_cast<unsigned>(YUVType::BT601_Lim)] = CF(0.0625, 0.5, 0.5),
- [static_cast<unsigned>(YUVType::BT601_Full)] = CF( 0, 0.5, 0.5),
- [static_cast<unsigned>(YUVType::BT709_Lim)] = CF(0.0625, 0.5, 0.5),
- [static_cast<unsigned>(YUVType::BT709_Full)] = CF( 0, 0.5, 0.5),
+ [static_cast<unsigned>(YUVType::BT601_Lim)] = CF(0.0625, 0.5, 0.5),
+ [static_cast<unsigned>(YUVType::BT601_Full)] = CF(0, 0.5, 0.5),
+ [static_cast<unsigned>(YUVType::BT709_Lim)] = CF(0.0625, 0.5, 0.5),
+ [static_cast<unsigned>(YUVType::BT709_Full)] = CF(0, 0.5, 0.5),
};
YUV::YUV()
@@ -152,33 +146,33 @@ YUV::YUV(uint8_t y, uint8_t u, uint8_t v)
this->a = 0;
}
-static inline
-uint8_t MAKE_YUV_Y(uint8_t r, uint8_t g, uint8_t b, YUVType type)
+static inline uint8_t MAKE_YUV_Y(uint8_t r, uint8_t g, uint8_t b, YUVType type)
{
unsigned tidx = static_cast<unsigned>(type);
return CLAMP(((YUVcoef[tidx][0][0] * r + YUVcoef[tidx][0][1] * g +
- YUVcoef[tidx][0][2] * b + CF_ONE/2) / CF_ONE) +
+ YUVcoef[tidx][0][2] * b + CF_ONE / 2) /
+ CF_ONE) +
YUVoffset[tidx][0]);
}
-static inline
-uint8_t MAKE_YUV_U(uint8_t r, uint8_t g, uint8_t b, YUVType type)
+static inline uint8_t MAKE_YUV_U(uint8_t r, uint8_t g, uint8_t b, YUVType type)
{
unsigned tidx = static_cast<unsigned>(type);
return CLAMP(((YUVcoef[tidx][1][0] * r + YUVcoef[tidx][1][1] * g +
- YUVcoef[tidx][1][2] * b + CF_ONE/2) / CF_ONE) +
+ YUVcoef[tidx][1][2] * b + CF_ONE / 2) /
+ CF_ONE) +
YUVoffset[tidx][1]);
}
-static inline
-uint8_t MAKE_YUV_V(uint8_t r, uint8_t g, uint8_t b, YUVType type)
+static inline uint8_t MAKE_YUV_V(uint8_t r, uint8_t g, uint8_t b, YUVType type)
{
unsigned tidx = static_cast<unsigned>(type);
return CLAMP(((YUVcoef[tidx][2][0] * r + YUVcoef[tidx][2][1] * g +
- YUVcoef[tidx][2][2] * b + CF_ONE/2) / CF_ONE) +
+ YUVcoef[tidx][2][2] * b + CF_ONE / 2) /
+ CF_ONE) +
YUVoffset[tidx][2]);
}
@@ -189,4 +183,4 @@ YUV::YUV(const RGB& rgb, YUVType type)
this->v = MAKE_YUV_V(rgb.r, rgb.g, rgb.b, type);
this->a = rgb.a;
}
-}
+} // namespace kms
diff --git a/kms++util/src/colorbar.cpp b/kms++util/src/colorbar.cpp
index c08ed9d..cd0b978 100644
--- a/kms++util/src/colorbar.cpp
+++ b/kms++util/src/colorbar.cpp
@@ -39,7 +39,7 @@ static void drm_draw_color_bar_rgb888(IFramebuffer& buf, int old_xpos, int xpos,
{
for (unsigned y = 0; y < buf.height(); ++y) {
RGB bcol = colors32[y * ARRAY_SIZE(colors32) / buf.height()];
- uint32_t *line = (uint32_t*)(buf.map(0) + buf.stride(0) * y);
+ uint32_t* line = (uint32_t*)(buf.map(0) + buf.stride(0) * y);
if (old_xpos >= 0) {
for (int x = old_xpos; x < old_xpos + width; ++x)
@@ -57,7 +57,7 @@ static void drm_draw_color_bar_rgb565(IFramebuffer& buf, int old_xpos, int xpos,
for (unsigned y = 0; y < buf.height(); ++y) {
uint16_t bcol = colors16[y * ARRAY_SIZE(colors16) / buf.height()];
- uint16_t *line = (uint16_t*)(buf.map(0) + buf.stride(0) * y);
+ uint16_t* line = (uint16_t*)(buf.map(0) + buf.stride(0) * y);
if (old_xpos >= 0) {
for (int x = old_xpos; x < old_xpos + width; ++x)
@@ -85,7 +85,7 @@ static void drm_draw_color_bar_semiplanar_yuv(IFramebuffer& buf, int old_xpos, i
for (unsigned y = 0; y < buf.height(); ++y) {
unsigned int bcol = colors[y * ARRAY_SIZE(colors) / buf.height()];
- uint8_t *line = (uint8_t*)(buf.map(0) + buf.stride(0) * y);
+ uint8_t* line = (uint8_t*)(buf.map(0) + buf.stride(0) * y);
if (old_xpos >= 0) {
for (int x = old_xpos; x < old_xpos + width; ++x)
@@ -129,4 +129,4 @@ void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width)
ASSERT(false);
}
}
-}
+} // namespace kms
diff --git a/kms++util/src/cpuframebuffer.cpp b/kms++util/src/cpuframebuffer.cpp
index 33f8f97..c3bc248 100644
--- a/kms++util/src/cpuframebuffer.cpp
+++ b/kms++util/src/cpuframebuffer.cpp
@@ -4,8 +4,8 @@
using namespace std;
-namespace kms {
-
+namespace kms
+{
CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format)
: m_width(width), m_height(height), m_format(format)
{
@@ -18,7 +18,7 @@ CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat form
FramebufferPlane& plane = m_planes[i];
plane.stride = width * pi.bitspp / 8;
- plane.size = plane.stride * height/ pi.ysub;
+ plane.size = plane.stride * height / pi.ysub;
plane.offset = 0;
plane.map = new uint8_t[plane.size];
}
@@ -29,8 +29,8 @@ CPUFramebuffer::~CPUFramebuffer()
for (unsigned i = 0; i < m_num_planes; ++i) {
FramebufferPlane& plane = m_planes[i];
- delete [] plane.map;
+ delete[] plane.map;
}
}
-}
+} // namespace kms
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 3752f94..79e0d90 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -15,106 +15,91 @@ void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color)
switch (buf.format()) {
case PixelFormat::XRGB8888:
- case PixelFormat::ARGB8888:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::ARGB8888: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.argb8888();
break;
}
case PixelFormat::XBGR8888:
- case PixelFormat::ABGR8888:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::ABGR8888: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.abgr8888();
break;
}
case PixelFormat::RGBX8888:
- case PixelFormat::RGBA8888:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::RGBA8888: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.rgba8888();
break;
}
case PixelFormat::BGRX8888:
- case PixelFormat::BGRA8888:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::BGRA8888: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.bgra8888();
break;
}
case PixelFormat::XRGB2101010:
- case PixelFormat::ARGB2101010:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::ARGB2101010: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.argb2101010();
break;
}
case PixelFormat::XBGR2101010:
- case PixelFormat::ABGR2101010:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::ABGR2101010: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.abgr2101010();
break;
}
case PixelFormat::RGBX1010102:
- case PixelFormat::RGBA1010102:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::RGBA1010102: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.rgba1010102();
break;
}
case PixelFormat::BGRX1010102:
- case PixelFormat::BGRA1010102:
- {
- uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
+ case PixelFormat::BGRA1010102: {
+ uint32_t* p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
*p = color.bgra1010102();
break;
}
- case PixelFormat::RGB888:
- {
- uint8_t *p = buf.map(0) + buf.stride(0) * y + x * 3;
+ case PixelFormat::RGB888: {
+ uint8_t* p = buf.map(0) + buf.stride(0) * y + x * 3;
p[0] = color.b;
p[1] = color.g;
p[2] = color.r;
break;
}
- case PixelFormat::BGR888:
- {
- uint8_t *p = buf.map(0) + buf.stride(0) * y + x * 3;
+ case PixelFormat::BGR888: {
+ uint8_t* p = buf.map(0) + buf.stride(0) * y + x * 3;
p[0] = color.r;
p[1] = color.g;
p[2] = color.b;
break;
}
- case PixelFormat::RGB332:
- {
- uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
+ case PixelFormat::RGB332: {
+ uint8_t* p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
*p = color.rgb332();
break;
}
- case PixelFormat::RGB565:
- {
- uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ case PixelFormat::RGB565: {
+ uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.rgb565();
break;
}
- case PixelFormat::BGR565:
- {
- uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ case PixelFormat::BGR565: {
+ uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.bgr565();
break;
}
case PixelFormat::XRGB4444:
- case PixelFormat::ARGB4444:
- {
- uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ case PixelFormat::ARGB4444: {
+ uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.argb4444();
break;
}
case PixelFormat::XRGB1555:
- case PixelFormat::ARGB1555:
- {
- uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ case PixelFormat::ARGB1555: {
+ uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.argb1555();
break;
}
@@ -128,9 +113,9 @@ void draw_yuv444_pixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv)
if (x >= buf.width() || y >= buf.height())
throw runtime_error("attempt to draw outside the buffer");
- uint8_t *py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
- uint8_t *pu = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x);
- uint8_t *pv = (uint8_t*)(buf.map(2) + buf.stride(2) * y + x);
+ uint8_t* py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
+ uint8_t* pu = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x);
+ uint8_t* pv = (uint8_t*)(buf.map(2) + buf.stride(2) * y + x);
switch (buf.format()) {
case PixelFormat::YUV444:
@@ -153,7 +138,7 @@ void draw_yuv444_pixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv)
static void draw_yuv422_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2)
{
- uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ uint8_t* p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
uint8_t y0 = yuv1.y;
uint8_t y1 = yuv2.y;
@@ -197,8 +182,8 @@ static void draw_yuv422_packed_macropixel(IFramebuffer& buf, unsigned x, unsigne
static void draw_yuv422_semiplanar_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2)
{
- uint8_t *py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
- uint8_t *puv = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x);
+ uint8_t* py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
+ uint8_t* puv = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x);
uint8_t y0 = yuv1.y;
uint8_t y1 = yuv2.y;
@@ -228,9 +213,9 @@ static void draw_yuv422_semiplanar_macropixel(IFramebuffer& buf, unsigned x, uns
static void draw_yuv422_planar_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2)
{
- uint8_t *py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
- uint8_t *pu = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x / 2);
- uint8_t *pv = (uint8_t*)(buf.map(2) + buf.stride(2) * y + x / 2);
+ uint8_t* py = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x);
+ uint8_t* pu = (uint8_t*)(buf.map(1) + buf.stride(1) * y + x / 2);
+ uint8_t* pv = (uint8_t*)(buf.map(2) + buf.stride(2) * y + x / 2);
uint8_t y0 = yuv1.y;
uint8_t y1 = yuv2.y;
@@ -290,10 +275,10 @@ void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1,
static void draw_yuv420_semiplanar_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4)
{
- uint8_t *py1 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 0) + x);
- uint8_t *py2 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 1) + x);
+ uint8_t* py1 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 0) + x);
+ uint8_t* py2 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 1) + x);
- uint8_t *puv = (uint8_t*)(buf.map(1) + buf.stride(1) * (y / 2) + x);
+ uint8_t* puv = (uint8_t*)(buf.map(1) + buf.stride(1) * (y / 2) + x);
uint8_t y0 = yuv1.y;
uint8_t y1 = yuv2.y;
@@ -329,11 +314,11 @@ static void draw_yuv420_semiplanar_macropixel(IFramebuffer& buf, unsigned x, uns
static void draw_yuv420_planar_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4)
{
- uint8_t *py1 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 0) + x);
- uint8_t *py2 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 1) + x);
+ uint8_t* py1 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 0) + x);
+ uint8_t* py2 = (uint8_t*)(buf.map(0) + buf.stride(0) * (y + 1) + x);
- uint8_t *pu = (uint8_t*)(buf.map(1) + buf.stride(1) * (y / 2) + x / 2);
- uint8_t *pv = (uint8_t*)(buf.map(2) + buf.stride(2) * (y / 2) + x / 2);
+ uint8_t* pu = (uint8_t*)(buf.map(1) + buf.stride(1) * (y / 2) + x / 2);
+ uint8_t* pv = (uint8_t*)(buf.map(2) + buf.stride(2) * (y / 2) + x / 2);
uint8_t y0 = yuv1.y;
uint8_t y1 = yuv2.y;
@@ -391,7 +376,7 @@ void draw_yuv420_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
}
}
-void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color)
+void draw_rect(IFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color)
{
unsigned i, j;
YUV yuvcolor = color.yuv();
@@ -565,8 +550,8 @@ static void draw_char(IFramebuffer& buf, uint32_t xpos, uint32_t ypos, char c, R
void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const string& str, RGB color)
{
- for(unsigned i = 0; i < str.size(); i++)
+ for (unsigned i = 0; i < str.size(); i++)
draw_char(buf, (x + 8 * i), y, str[i], color);
}
-}
+} // namespace kms
diff --git a/kms++util/src/extcpuframebuffer.cpp b/kms++util/src/extcpuframebuffer.cpp
index feb3add..0ee79ee 100644
--- a/kms++util/src/extcpuframebuffer.cpp
+++ b/kms++util/src/extcpuframebuffer.cpp
@@ -5,7 +5,6 @@ using namespace std;
namespace kms
{
-
ExtCPUFramebuffer::ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
uint8_t* buffer, uint32_t size, uint32_t pitch, uint32_t offset)
: m_width(width), m_height(height), m_format(format)
@@ -46,4 +45,4 @@ ExtCPUFramebuffer::~ExtCPUFramebuffer()
{
}
-}
+} // namespace kms
diff --git a/kms++util/src/font_8x8.h b/kms++util/src/font_8x8.h
index 2a2a1ea..ed9bf3f 100644
--- a/kms++util/src/font_8x8.h
+++ b/kms++util/src/font_8x8.h
@@ -2567,4 +2567,3 @@ const uint8_t fontdata_8x8[] = {
0x00, /* 00000000 */
};
-
diff --git a/kms++util/src/opts.cpp b/kms++util/src/opts.cpp
index 5a14b84..ba49995 100644
--- a/kms++util/src/opts.cpp
+++ b/kms++util/src/opts.cpp
@@ -75,7 +75,7 @@ void OptionSet::parse(int argc, char** argv)
}
}
- longopts.push_back(option {});
+ longopts.push_back(option{});
while (1) {
int long_idx = 0;
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index ac38673..78c9d19 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -15,7 +15,6 @@ using namespace std;
namespace kms
{
-
static RGB get_test_pattern_pixel(IFramebuffer& fb, unsigned x, unsigned y)
{
const unsigned w = fb.width();
@@ -198,7 +197,7 @@ static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt)
#endif
}
-void draw_test_pattern(IFramebuffer &fb, YUVType yuvt)
+void draw_test_pattern(IFramebuffer& fb, YUVType yuvt)
{
#ifdef DRAW_PERF_PRINT
Stopwatch sw;
@@ -213,4 +212,4 @@ void draw_test_pattern(IFramebuffer &fb, YUVType yuvt)
#endif
}
-}
+} // namespace kms
diff --git a/kms++util/src/videodevice.cpp b/kms++util/src/videodevice.cpp
index 0121c7c..9530d60 100644
--- a/kms++util/src/videodevice.cpp
+++ b/kms++util/src/videodevice.cpp
@@ -32,7 +32,7 @@ static vector<PixelFormat> v4l2_get_formats(int fd, uint32_t buf_type)
{
vector<PixelFormat> v;
- v4l2_fmtdesc desc { };
+ v4l2_fmtdesc desc{};
desc.type = buf_type;
while (ioctl(fd, VIDIOC_ENUM_FMT, &desc) == 0) {
@@ -51,7 +51,7 @@ static void v4l2_set_format(int fd, PixelFormat fmt, uint32_t width, uint32_t he
{
int r;
- v4l2_format v4lfmt { };
+ v4l2_format v4lfmt{};
v4lfmt.type = buf_type;
r = ioctl(fd, VIDIOC_G_FMT, &v4lfmt);
@@ -177,7 +177,7 @@ static void v4l2_set_selection(int fd, uint32_t& left, uint32_t& top, uint32_t&
static void v4l2_request_bufs(int fd, uint32_t queue_size, uint32_t buf_type)
{
- v4l2_requestbuffers v4lreqbuf { };
+ v4l2_requestbuffers v4lreqbuf{};
v4lreqbuf.type = buf_type;
v4lreqbuf.memory = V4L2_MEMORY_DMABUF;
v4lreqbuf.count = queue_size;
@@ -188,7 +188,7 @@ static void v4l2_request_bufs(int fd, uint32_t queue_size, uint32_t buf_type)
static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint32_t buf_type)
{
- v4l2_buffer buf { };
+ v4l2_buffer buf{};
buf.type = buf_type;
buf.memory = V4L2_MEMORY_DMABUF;
buf.index = index;
@@ -200,7 +200,7 @@ static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint3
if (mplane) {
buf.length = pfi.num_planes;
- v4l2_plane planes[4] { };
+ v4l2_plane planes[4]{};
buf.m.planes = planes;
for (unsigned i = 0; i < pfi.num_planes; ++i) {
@@ -221,12 +221,12 @@ static void v4l2_queue_dmabuf(int fd, uint32_t index, DumbFramebuffer* fb, uint3
static uint32_t v4l2_dequeue(int fd, uint32_t buf_type)
{
- v4l2_buffer buf { };
+ v4l2_buffer buf{};
buf.type = buf_type;
buf.memory = V4L2_MEMORY_DMABUF;
// V4L2 crashes if planes are not set
- v4l2_plane planes[4] { };
+ v4l2_plane planes[4]{};
buf.m.planes = planes;
buf.length = 4;
@@ -237,11 +237,8 @@ static uint32_t v4l2_dequeue(int fd, uint32_t buf_type)
return buf.index;
}
-
-
-
VideoDevice::VideoDevice(const string& dev)
- :VideoDevice(::open(dev.c_str(), O_RDWR | O_NONBLOCK))
+ : VideoDevice(::open(dev.c_str(), O_RDWR | O_NONBLOCK))
{
}
@@ -251,7 +248,7 @@ VideoDevice::VideoDevice(int fd)
if (fd < 0)
throw runtime_error("bad fd");
- struct v4l2_capability cap = { };
+ struct v4l2_capability cap = {};
int r = ioctl(fd, VIDIOC_QUERYCAP, &cap);
ASSERT(r == 0);
@@ -321,7 +318,7 @@ vector<tuple<uint32_t, uint32_t>> VideoDevice::get_discrete_frame_sizes(PixelFor
{
vector<tuple<uint32_t, uint32_t>> v;
- v4l2_frmsizeenum v4lfrms { };
+ v4l2_frmsizeenum v4lfrms{};
v4lfrms.pixel_format = (uint32_t)fmt;
int r = ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms);
@@ -339,7 +336,7 @@ vector<tuple<uint32_t, uint32_t>> VideoDevice::get_discrete_frame_sizes(PixelFor
VideoDevice::VideoFrameSize VideoDevice::get_frame_sizes(PixelFormat fmt)
{
- v4l2_frmsizeenum v4lfrms { };
+ v4l2_frmsizeenum v4lfrms{};
v4lfrms.pixel_format = (uint32_t)fmt;
int r = ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms);
@@ -406,11 +403,9 @@ vector<string> VideoDevice::get_m2m_devices()
return v;
}
-
VideoStreamer::VideoStreamer(int fd, StreamerType type)
: m_fd(fd), m_type(type)
{
-
}
std::vector<string> VideoStreamer::get_ports()
@@ -419,9 +414,9 @@ std::vector<string> VideoStreamer::get_ports()
switch (m_type) {
case StreamerType::CaptureSingle:
- case StreamerType::CaptureMulti:
- {
- struct v4l2_input input { };
+ case StreamerType::CaptureMulti: {
+ struct v4l2_input input {
+ };
while (ioctl(m_fd, VIDIOC_ENUMINPUT, &input) == 0) {
v.push_back(string((char*)&input.name));
@@ -432,9 +427,9 @@ std::vector<string> VideoStreamer::get_ports()
}
case StreamerType::OutputSingle:
- case StreamerType::OutputMulti:
- {
- struct v4l2_output output { };
+ case StreamerType::OutputMulti: {
+ struct v4l2_output output {
+ };
while (ioctl(m_fd, VIDIOC_ENUMOUTPUT, &output) == 0) {
v.push_back(string((char*)&output.name));