summaryrefslogtreecommitdiff
path: root/src/ipa/simple/algorithms/lut.cpp
diff options
context:
space:
mode:
authorMilan Zamazal <mzamazal@redhat.com>2025-03-26 10:08:39 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2025-03-26 10:45:01 +0000
commit94e849bcf7fd6e3f7a21b16a2a81d2929f9d5323 (patch)
tree60d3a91b08cefb7f5f2e1cf04b5190ce08eff08e /src/ipa/simple/algorithms/lut.cpp
parent84f82c6b3ca9c90d6fc8e55678a39968f16b255c (diff)
libcamera: software_isp: Use RGB type to represent gains
Rather than using a custom struct to represent RGB values, let's use the corresponding type and its facilities. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/simple/algorithms/lut.cpp')
-rw-r--r--src/ipa/simple/algorithms/lut.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp
index a2e11d3b..83df71a9 100644
--- a/src/ipa/simple/algorithms/lut.cpp
+++ b/src/ipa/simple/algorithms/lut.cpp
@@ -103,16 +103,10 @@ void Lut::prepare(IPAContext &context,
const double div = static_cast<double>(DebayerParams::kRGBLookupSize) /
gammaTableSize;
/* Apply gamma after gain! */
- unsigned int idx;
- idx = std::min({ static_cast<unsigned int>(i * gains.red / div),
- gammaTableSize - 1 });
- params->red[i] = gammaTable[idx];
- idx = std::min({ static_cast<unsigned int>(i * gains.green / div),
- gammaTableSize - 1 });
- params->green[i] = gammaTable[idx];
- idx = std::min({ static_cast<unsigned int>(i * gains.blue / div),
- gammaTableSize - 1 });
- params->blue[i] = gammaTable[idx];
+ const RGB<double> lutGains = (gains * i / div).min(gammaTableSize - 1);
+ params->red[i] = gammaTable[static_cast<unsigned int>(lutGains.r())];
+ params->green[i] = gammaTable[static_cast<unsigned int>(lutGains.g())];
+ params->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];
}
}