summaryrefslogtreecommitdiff
path: root/kms++util
diff options
context:
space:
mode:
Diffstat (limited to 'kms++util')
-rw-r--r--kms++util/inc/kms++util/endian.h18
-rw-r--r--kms++util/src/color.cpp3
-rw-r--r--kms++util/src/drawing.cpp14
3 files changed, 19 insertions, 16 deletions
diff --git a/kms++util/inc/kms++util/endian.h b/kms++util/inc/kms++util/endian.h
index 0f7aecd..e77b3bd 100644
--- a/kms++util/inc/kms++util/endian.h
+++ b/kms++util/inc/kms++util/endian.h
@@ -5,7 +5,7 @@
#include <stdint.h>
static_assert((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) ||
- (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__),
+ (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__),
"Unable to detect endianness");
enum class endian {
@@ -19,14 +19,17 @@ constexpr T byteswap(T value) noexcept
{
static_assert(std::is_integral<T>(), "Type is not integral");
static_assert(sizeof(T) == 2 ||
- sizeof(T) == 4 ||
- sizeof(T) == 8,
+ sizeof(T) == 4 ||
+ sizeof(T) == 8,
"Illegal value size");
switch (sizeof(T)) {
- case 2: return bswap_16(value);
- case 4: return bswap_32(value);
- case 8: return bswap_64(value);
+ case 2:
+ return bswap_16(value);
+ case 4:
+ return bswap_32(value);
+ case 8:
+ return bswap_64(value);
}
}
@@ -39,8 +42,7 @@ static void write_endian(T* dst, T val)
*dst = val;
}
-[[maybe_unused]]
-static void write16le(uint16_t* dst, uint16_t val)
+[[maybe_unused]] static void write16le(uint16_t* dst, uint16_t val)
{
write_endian<endian::little, uint16_t>(dst, val);
}
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 74ff8c9..c761e40 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -114,7 +114,8 @@ YUV RGB::yuv(YUVType type) const
{ \
((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 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)] = {
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 2631f14..862638b 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -181,7 +181,7 @@ static void draw_yuv422_packed_macropixel(IFramebuffer& buf, unsigned x, unsigne
}
static void draw_y2xx_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
- YUV yuv1, YUV yuv2)
+ YUV yuv1, YUV yuv2)
{
const uint32_t macro_size = 4;
uint16_t* p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * macro_size);
@@ -191,8 +191,8 @@ static void draw_y2xx_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned
// XXX naive expansion to 10 bits, similar to 10-bit funcs in class RGB
uint16_t y0 = yuv1.y << 2;
uint16_t y1 = yuv2.y << 2;
- uint16_t cb = ((yuv1.u << 2) + (yuv2.u << 2)) / 2;
- uint16_t cr = ((yuv1.v << 2) + (yuv2.v << 2)) / 2;
+ uint16_t cb = ((yuv1.u << 2) + (yuv2.u << 2)) / 2;
+ uint16_t cr = ((yuv1.v << 2) + (yuv2.v << 2)) / 2;
// The 10 bits occupy the msb, so we shift left by 16-10 = 6
write16le(&p[0], y0 << 6);
@@ -206,8 +206,8 @@ static void draw_y2xx_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned
// XXX naive expansion to 12 bits
uint16_t y0 = yuv1.y << 4;
uint16_t y1 = yuv2.y << 4;
- uint16_t cb = ((yuv1.u << 4) + (yuv2.u << 4)) / 2;
- uint16_t cr = ((yuv1.v << 4) + (yuv2.v << 4)) / 2;
+ uint16_t cb = ((yuv1.u << 4) + (yuv2.u << 4)) / 2;
+ uint16_t cr = ((yuv1.v << 4) + (yuv2.v << 4)) / 2;
// The 10 bits occupy the msb, so we shift left by 16-12 = 4
write16le(&p[0], y0 << 4);
@@ -221,8 +221,8 @@ static void draw_y2xx_packed_macropixel(IFramebuffer& buf, unsigned x, unsigned
// XXX naive expansion to 16 bits
uint16_t y0 = yuv1.y << 8;
uint16_t y1 = yuv2.y << 8;
- uint16_t cb = ((yuv1.u << 8) + (yuv2.u << 8)) / 2;
- uint16_t cr = ((yuv1.v << 8) + (yuv2.v << 8)) / 2;
+ uint16_t cb = ((yuv1.u << 8) + (yuv2.u << 8)) / 2;
+ uint16_t cr = ((yuv1.v << 8) + (yuv2.v << 8)) / 2;
write16le(&p[0], y0);
write16le(&p[1], cb);