summaryrefslogtreecommitdiff
path: root/subprojects/pixpat/pixpat-native/src/pipeline.h
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2026-05-08 17:22:58 +0300
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2026-05-08 17:22:58 +0300
commit4e2b291a4acdc2cbd39f005c88bda363bc06bd34 (patch)
treee90048d5973ad1164b109d575cf577af7daf50be /subprojects/pixpat/pixpat-native/src/pipeline.h
parent8f94b39040e79eccd9312ed1e467fe8ebfab8860 (diff)
parente0b7d30fd437292c88141fb08d60681870b86c6e (diff)
Merge commit 'e0b7d30fd437292c88141fb08d60681870b86c6e' as 'subprojects/pixpat'
Diffstat (limited to 'subprojects/pixpat/pixpat-native/src/pipeline.h')
-rw-r--r--subprojects/pixpat/pixpat-native/src/pipeline.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/subprojects/pixpat/pixpat-native/src/pipeline.h b/subprojects/pixpat/pixpat-native/src/pipeline.h
new file mode 100644
index 0000000..09e13bc
--- /dev/null
+++ b/subprojects/pixpat/pixpat-native/src/pipeline.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <cstddef>
+
+#include "color.h"
+#include "layout.h"
+
+// Inlined source → color → sink composition. The intermediate Pixel
+// values stay in registers across stages; there is no normalized RGB16
+// or YUV16 buffer between source and sink. Block size is dictated by
+// the sink: 1x1 for non-subsampled formats, h_sub × v_sub for chroma-
+// subsampled ones.
+
+namespace pixpat
+{
+
+template <typename Source, typename Sink>
+struct Converter {
+ using Xfm = ColorXfm<typename Source::Pixel, typename Sink::Pixel>;
+ static constexpr size_t bh = Sink::block_h;
+ static constexpr size_t bw = Sink::block_w;
+
+ static void run(const Buffer<Source::Layout::num_planes>& src,
+ Buffer<Sink::Layout::num_planes>& dst,
+ size_t W, size_t H,
+ size_t by_start, size_t by_end,
+ ColorSpec spec) noexcept
+ {
+ const ColorCoeffs c = coeffs_for(spec);
+ for (size_t by = by_start; by < by_end; by += bh) {
+ for (size_t bx = 0; bx < W; bx += bw) {
+ typename Sink::Pixel block[bh][bw];
+ for (size_t dy = 0; dy < bh; ++dy)
+ for (size_t dx = 0; dx < bw; ++dx)
+ block[dy][dx] = Xfm::apply(
+ Source::read(src, bx + dx, by + dy,
+ W, H), c);
+ Sink::write_block(dst, bx, by, block);
+ }
+ }
+ }
+};
+
+} // namespace pixpat