tvl-depot/users/flokli/ipu6-softisp/libcamera/0021-libcamera-swstats_cpu-Add-support-for-10bpp-IGIG_GBG.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

132 lines
3.9 KiB
Diff
Raw Normal View History

From f939e68a3ef556e572f0140df6d7ef17d72f457e Mon Sep 17 00:00:00 2001
From: Marttico <g.martti@gmail.com>
Date: Wed, 20 Dec 2023 20:26:15 +0100
Subject: [PATCH 21/25] libcamera: swstats_cpu: Add support for 10bpp
IGIG_GBGR_IGIG_GRGB input
Add support to SwStatsCpu for 10bpp IGIG_GBGR_IGIG_GRGB input
generated by the Omnivision ov01a1s sensor.
Co-authored-by: Dennis Bonke <admin@dennisbonke.com>
Signed-off-by: Dennis Bonke <admin@dennisbonke.com>
Co-authored-by: Toon Langendam <t.langendam@gmail.com>
Signed-off-by: Toon Langendam <t.langendam@gmail.com>
Signed-off-by: Marttico <g.martti@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
.../internal/software_isp/swstats_cpu.h | 3 +
src/libcamera/software_isp/swstats_cpu.cpp | 76 +++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h
index e7abc6bb..a47241e1 100644
--- a/include/libcamera/internal/software_isp/swstats_cpu.h
+++ b/include/libcamera/internal/software_isp/swstats_cpu.h
@@ -42,6 +42,9 @@ private:
/* Bayer 10 bpp packed */
void statsBGGR10PLine0(const uint8_t *src[]);
void statsGBRG10PLine0(const uint8_t *src[]);
+ /* IGIG_GBGR_IGIG_GRGB 10 bpp unpacked */
+ void statsRGBIR10Line0(const uint8_t *src[]);
+ void statsRGBIR10Line2(const uint8_t *src[]);
void resetStats(void);
void finishStats(void);
diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
index 87550371..96e21be5 100644
--- a/src/libcamera/software_isp/swstats_cpu.cpp
+++ b/src/libcamera/software_isp/swstats_cpu.cpp
@@ -187,6 +187,68 @@ void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[])
statsBayer10P(window_.width, src0, src1, false, stats_);
}
+void SwStatsCpu::statsRGBIR10Line0(const uint8_t *src[])
+{
+ const uint16_t *src0_16 = (const uint16_t *)src[2] + window_.x;
+ const uint16_t *src1_16 = (const uint16_t *)src[3] + window_.x;
+ uint16_t g3, g4;
+
+ SWISP_LINARO_START_LINE_STATS(uint16_t)
+
+ /* x += 8 sample every other 4x4 block */
+ for (int x = 0; x < (int)window_.width; x += 8) {
+ /* IGIG */
+ //i = src0_16[x];
+ g2 = src0_16[x + 1];
+ //i = src0_16[x + 2];
+ g4 = src0_16[x + 3];
+
+ /* GBGR */
+ g = src1_16[x];
+ b = src1_16[x + 1];
+ g3 = src1_16[x + 2];
+ r = src1_16[x + 3];
+
+ g = (g + g2 + g3 + g4) / 4;
+
+ /* divide Y by 4 for 10 -> 8 bpp value */
+ SWISP_LINARO_ACCUMULATE_LINE_STATS(4)
+ }
+
+ SWISP_LINARO_FINISH_LINE_STATS()
+}
+
+void SwStatsCpu::statsRGBIR10Line2(const uint8_t *src[])
+{
+ const uint16_t *src0_16 = (const uint16_t *)src[2] + window_.x;
+ const uint16_t *src1_16 = (const uint16_t *)src[3] + window_.x;
+ uint16_t g3, g4;
+
+ SWISP_LINARO_START_LINE_STATS(uint16_t)
+
+ /* x += 8 sample every other 4x4 block */
+ for (int x = 0; x < (int)window_.width; x += 8) {
+ /* IGIG */
+ //i = src0_16[x];
+ g2 = src0_16[x + 1];
+ //i = src0_16[x + 2];
+ g4 = src0_16[x + 3];
+
+ /* GRGB */
+ g = src1_16[x];
+ r = src1_16[x + 1];
+ g3 = src1_16[x + 2];
+ b = src1_16[x + 3];
+
+ g = (g + g2 + g3 + g4) / 4;
+
+ /* divide Y by 4 for 10 -> 8 bpp value */
+ SWISP_LINARO_ACCUMULATE_LINE_STATS(4)
+ }
+
+ SWISP_LINARO_FINISH_LINE_STATS()
+}
+
void SwStatsCpu::resetStats(void)
{
stats_.sumR_ = 0;
@@ -282,6 +344,20 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg)
}
}
+ if (bayerFormat.bitDepth == 10 &&
+ bayerFormat.packing == BayerFormat::Packing::None &&
+ bayerFormat.order == BayerFormat::IGIG_GBGR_IGIG_GRGB) {
+ bpp_ = 16;
+ patternSize_.height = 4;
+ patternSize_.width = 4;
+ y_skip_mask_ = 0x04;
+ x_shift_ = 0;
+ swap_lines_ = false;
+ stats0_ = (SwStats::statsProcessFn)&SwStatsCpu::statsRGBIR10Line0;
+ stats2_ = (SwStats::statsProcessFn)&SwStatsCpu::statsRGBIR10Line2;
+ return 0;
+ }
+
LOG(SwStats, Info)
<< "Unsupported input format " << inputCfg.pixelFormat.toString();
return -EINVAL;
--
2.43.0