summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/agc.cpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2022-07-27 09:55:23 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-27 18:12:18 +0300
commitd1c89a1824416a03da10ebd078869cba79b6015c (patch)
tree4152532504e20902e519027bea3f05ed24a92156 /src/ipa/raspberrypi/controller/rpi/agc.cpp
parent8757cc7c4291420e94047ea54a735cbaa1eb6adb (diff)
ipa: raspberrypi: Remove #define constants
Replace all #define constant values with equivalent constexpr definitions. As a drive-by, remove the CAMERA_MODE_NAME_LEN constant as it is unused. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/agc.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/agc.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp
index 37c5a269..8c1cd8b2 100644
--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp
@@ -28,17 +28,17 @@ LOG_DEFINE_CATEGORY(RPiAgc)
#define NAME "rpi.agc"
-#define PIPELINE_BITS 13 /* seems to be a 13-bit pipeline */
+static constexpr unsigned int PipelineBits = 13; /* seems to be a 13-bit pipeline */
void AgcMeteringMode::read(boost::property_tree::ptree const &params)
{
int num = 0;
for (auto &p : params.get_child("weights")) {
- if (num == AGC_STATS_SIZE)
+ if (num == AgcStatsSize)
LOG(RPiAgc, Fatal) << "AgcConfig: too many weights";
weights[num++] = p.second.get_value<double>();
}
- if (num != AGC_STATS_SIZE)
+ if (num != AgcStatsSize)
LOG(RPiAgc, Fatal) << "AgcConfig: insufficient weights";
}
@@ -525,11 +525,11 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb,
* "average" metering (i.e. all pixels equally important).
*/
double rSum = 0, gSum = 0, bSum = 0, pixelSum = 0;
- for (int i = 0; i < AGC_STATS_SIZE; i++) {
+ for (unsigned int i = 0; i < AgcStatsSize; i++) {
double counted = regions[i].counted;
- double rAcc = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);
- double gAcc = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);
- double bAcc = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);
+ double rAcc = std::min(regions[i].r_sum * gain, ((1 << PipelineBits) - 1) * counted);
+ double gAcc = std::min(regions[i].g_sum * gain, ((1 << PipelineBits) - 1) * counted);
+ double bAcc = std::min(regions[i].b_sum * gain, ((1 << PipelineBits) - 1) * counted);
rSum += rAcc * weights[i];
gSum += gAcc * weights[i];
bSum += bAcc * weights[i];
@@ -542,7 +542,7 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb,
double ySum = rSum * awb.gainR * .299 +
gSum * awb.gainG * .587 +
bSum * awb.gainB * .114;
- return ySum / pixelSum / (1 << PIPELINE_BITS);
+ return ySum / pixelSum / (1 << PipelineBits);
}
/*
@@ -553,13 +553,13 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb,
* (contrived) cases.
*/
-#define EV_GAIN_Y_TARGET_LIMIT 0.9
+static constexpr double EvGainYTargetLimit = 0.9;
static double constraintComputeGain(AgcConstraint &c, Histogram &h, double lux,
double evGain, double &targetY)
{
targetY = c.yTarget.eval(c.yTarget.domain().clip(lux));
- targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain);
+ targetY = std::min(EvGainYTargetLimit, targetY * evGain);
double iqm = h.interQuantileMean(c.qLo, c.qHi);
return (targetY * NUM_HISTOGRAM_BINS) / iqm;
}
@@ -578,7 +578,7 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata,
* that we consider the histogram constraints.
*/
targetY = config_.yTarget.eval(config_.yTarget.domain().clip(lux.lux));
- targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain);
+ targetY = std::min(EvGainYTargetLimit, targetY * evGain);
/*
* Do this calculation a few times as brightness increase can be