From 2bd85abc108e0688384f42b0ec83dcd5a622d50d Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 22 Dec 2022 12:04:50 +0200 Subject: Code formatting fixes Signed-off-by: Tomi Valkeinen --- kms++util/inc/kms++util/endian.h | 18 ++++++++++-------- kms++util/src/color.cpp | 3 ++- kms++util/src/drawing.cpp | 14 +++++++------- 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'kms++util') 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 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(), "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(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(YUVType::MAX)][3][3] = { [static_cast(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); -- cgit v1.2.3