From e0b7d30fd437292c88141fb08d60681870b86c6e Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 8 May 2026 17:22:58 +0300 Subject: Squashed 'subprojects/pixpat/' content from commit d444626 git-subtree-dir: subprojects/pixpat git-subtree-split: d444626e6ba988ec6d487800721e447f94b1eaf5 --- pixpat-native/src/formats/grayscale.h | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 pixpat-native/src/formats/grayscale.h (limited to 'pixpat-native/src/formats/grayscale.h') diff --git a/pixpat-native/src/formats/grayscale.h b/pixpat-native/src/formats/grayscale.h new file mode 100644 index 0000000..b1cd294 --- /dev/null +++ b/pixpat-native/src/formats/grayscale.h @@ -0,0 +1,78 @@ +#pragma once + +// Single-component-per-pixel formats. Most are grayscale (Y) modeled as +// a YUV format with synthesized neutral chroma; R8 is the RGB-kind +// counterpart, modeled grey-style with G=B=R on read. Y10/Y12 carry an +// explicit X padding bitfield. XYYY2101010 is multi-pixel-per-word: 3 Y +// samples in 32 bits. + +#include "../layout.h" +#include "../io/gray.h" +#include "../io/gray_packed.h" +#include "../io/mono_rgb.h" + +namespace pixpat::formats +{ + +#define PIXPAT_GRAY(name, ...) \ + struct name : Layout { \ + using Source = GraySource; \ + using Sink = GraySink; \ + } + +PIXPAT_GRAY(Y8, + Plane); + +PIXPAT_GRAY(Y10, + Plane); + +PIXPAT_GRAY(Y12, + Plane); + +PIXPAT_GRAY(Y16, + Plane); + +#undef PIXPAT_GRAY + +// R8: single 8-bit R channel. Read synthesizes G=B=R; write encodes R +// and drops G/B/A. Symmetric to Y8 but ColorKind::RGB so cross-pipeline +// conversions go through the RGB->YUV ColorXfm direction. +struct R8 : Layout > { + using Source = MonoRGBSource; + using Sink = MonoRGBSink; +}; + +struct XYYY2101010 : Layout > { + using Source = MultiPixelGraySource; + using Sink = MultiPixelGraySink; +}; + +// MIPI CSI-2 packed grayscale (Y10P / Y12P). The Layout doesn't capture +// the packed bit layout — GrayPackedSource/Sink delegate to the shared +// CSI-2 helper (io/csi2.h). uint8_t plane shape is a placeholder so +// dispatch plumbing is uniform (mirrors bayer_detail::Bayer10P/12P). +namespace gray_csi2_detail +{ +using Gray10P = Layout >; +using Gray12P = Layout >; +} // namespace gray_csi2_detail + +struct Y10P : gray_csi2_detail::Gray10P { + using Source = GrayPackedSource; + using Sink = GrayPackedSink; +}; + +struct Y12P : gray_csi2_detail::Gray12P { + using Source = GrayPackedSource; + using Sink = GrayPackedSink; +}; + +} // namespace pixpat::formats -- cgit v1.2.3