From 549c347d6feb2e94a810a720c97a8bf0f57317a1 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 4 May 2026 16:19:04 +0300 Subject: kms++util: Replace test-pattern generator with pixpat Switch draw_test_pattern() to call libpixpat (linked statically into libkms++util.so) instead of the in-tree pattern generator. Pixpat covers every pattern (kmstest, smpte, solid colors) and every pixel format the previous generator handled, so behavior is unchanged for all callers. Drop the now-unused machinery: conv.h and conv-*.h template writers, color16.h (RGB16/YUV16 plus conversions), the *_old / _single / _multi declarations that had no definitions or callers, and the c_draw_test_pattern C ABI which had no callers anywhere in the tree. RecStandard and ColorRange move from color16.h directly into kms++util.h, since they are still part of the public TestPatternOptions struct. --- kms++util/src/conv-yuv.h | 147 ----------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 kms++util/src/conv-yuv.h (limited to 'kms++util/src/conv-yuv.h') diff --git a/kms++util/src/conv-yuv.h b/kms++util/src/conv-yuv.h deleted file mode 100644 index 1695129..0000000 --- a/kms++util/src/conv-yuv.h +++ /dev/null @@ -1,147 +0,0 @@ -#pragma once - -#include - -#include -#include - -#include "conv-common.h" - -namespace kms -{ - -using XVUY2101010_Layout = - FormatLayout, - ComponentLayout, - ComponentLayout, - ComponentLayout>>; - -template -class YUV_Writer -{ - using Plane = typename Layout::template plane<0>; - using TStorage = typename Plane::storage_type; - - static_assert(Layout::num_planes == 1); - static_assert(Plane::num_components == 3 || Plane::num_components == 4); - - static_assert(Plane::template component_count() == 1); - static_assert(Plane::template component_count() == 1); - static_assert(Plane::template component_count() == 1); - - static constexpr bool has_alpha = Plane::template component_count(); - static constexpr bool has_padding = Plane::template component_count(); - - static constexpr bool needs_packed_access = Plane::total_bits != Plane::storage_bits; - - static constexpr size_t a_idx = Plane::template find_pos(); - static constexpr size_t x_idx = Plane::template find_pos(); - static constexpr size_t y_idx = Plane::template find_pos(); - static constexpr size_t cb_idx = Plane::template find_pos(); - static constexpr size_t cr_idx = Plane::template find_pos(); - - static constexpr size_t a_shift = has_alpha ? 16 - Plane::template component_size : 0; - static constexpr size_t x_shift = has_padding ? 16 - Plane::template component_size : 0; - static constexpr size_t y_shift = 16 - Plane::template component_size; - static constexpr size_t cb_shift = 16 - Plane::template component_size; - static constexpr size_t cr_shift = 16 - Plane::template component_size; - - static_assert(Plane::total_bits % 8 == 0); - static constexpr size_t bytes_per_pixel = Plane::total_bits / 8; - -public: - // Pack and write num_pixels pixels from src_line to dst_line - static void pack_line(HasIndexOperatorReturning auto&& dst_line, - HasIndexOperatorReturning auto&& src_line, - size_t num_pixels) - { - for (size_t x = 0; x < num_pixels; x++) { - const YUV16& pix = src_line[x]; - - std::array - components; - - if constexpr (has_alpha) - components[a_idx] = pix.a >> a_shift; - - if constexpr (has_padding) - components[x_idx] = 0; - - components[y_idx] = pix.y >> y_shift; - components[cb_idx] = pix.u >> cb_shift; - components[cr_idx] = pix.v >> cr_shift; - - if constexpr (!needs_packed_access) { - dst_line[x] = Plane::pack(components); - } else { - auto dst_bytes = reinterpret_cast(&dst_line[0]); - - TStorage packed = Plane::pack(components); - - memcpy(dst_bytes + x * bytes_per_pixel, &packed, - bytes_per_pixel); - } - } - } - - // Read and unpack num_pixels pixels from src_line to dst_line - static void unpack_line(HasIndexOperatorReturning auto&& dst_line, - HasIndexOperatorReturning auto&& src_line, - size_t num_pixels) - { - for (size_t x = 0; x < num_pixels; x++) { - decltype(Plane::unpack(src_line[x])) components; - - if constexpr (!needs_packed_access) { - components = Plane::unpack(src_line[x]); - } else { - auto src_bytes = - reinterpret_cast(&src_line[0]); - TStorage packed; - - memcpy(&packed, src_bytes + x * bytes_per_pixel, - bytes_per_pixel); - - components = Plane::unpack(packed); - } - - dst_line[x] = YUV16 { - static_cast(components[y_idx] << y_shift), - static_cast(components[cb_idx] << cb_shift), - static_cast(components[cr_idx] << cr_shift), - static_cast(has_alpha ? components[a_idx] << a_shift : 0), - }; - } - } - - static void write_pattern(IFramebuffer& fb, size_t start_y, size_t end_y, - auto&& generate_line) - { - std::vector linebuf(fb.width()); - - // View to the plane - auto view = make_strided_fb_view(fb.map(0), fb.height(), fb.width(), - fb.stride(0)); - - for (size_t y_src = start_y; y_src <= end_y; y_src++) { - generate_line(y_src, linebuf); - - auto dst = md::submdspan(view, y_src, md::full_extent); - - pack_line(dst, linebuf, fb.width()); - } - } - - static void get_line(IFramebuffer& fb, size_t w, size_t h, size_t row, std::span linebuf) - { - auto view = make_strided_fb_view(fb.map(0), fb.height(), fb.width(), - fb.stride(0)); - - auto src = md::submdspan(view, row, md::full_extent); - - unpack_line(linebuf, src); - } -}; - -} // namespace kms -- cgit v1.2.3