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>
This commit is contained in:
parent
8757cc7c42
commit
d1c89a1824
10 changed files with 41 additions and 43 deletions
|
@ -11,11 +11,11 @@
|
|||
* "alsc.status" metadata.
|
||||
*/
|
||||
|
||||
#define ALSC_CELLS_X 16
|
||||
#define ALSC_CELLS_Y 12
|
||||
constexpr unsigned int AlscCellsX = 16;
|
||||
constexpr unsigned int AlscCellsY = 12;
|
||||
|
||||
struct AlscStatus {
|
||||
double r[ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double g[ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double b[ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double r[AlscCellsY][AlscCellsX];
|
||||
double g[AlscCellsY][AlscCellsX];
|
||||
double b[AlscCellsY][AlscCellsX];
|
||||
};
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
* including binning, scaling, cropping etc.
|
||||
*/
|
||||
|
||||
#define CAMERA_MODE_NAME_LEN 32
|
||||
|
||||
struct CameraMode {
|
||||
/* bit depth of the raw camera output */
|
||||
uint32_t bitdepth;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* of contrast stretching based on the AGC histogram.
|
||||
*/
|
||||
|
||||
#define CONTRAST_NUM_POINTS 33
|
||||
constexpr unsigned int ContrastNumPoints = 33;
|
||||
|
||||
struct ContrastPoint {
|
||||
uint16_t x;
|
||||
|
@ -19,7 +19,7 @@ struct ContrastPoint {
|
|||
};
|
||||
|
||||
struct ContrastStatus {
|
||||
struct ContrastPoint points[CONTRAST_NUM_POINTS];
|
||||
struct ContrastPoint points[ContrastNumPoints];
|
||||
double brightness;
|
||||
double contrast;
|
||||
};
|
||||
|
|
|
@ -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 ¶ms)
|
||||
{
|
||||
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
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
* number (which is 16).
|
||||
*/
|
||||
|
||||
#define AGC_STATS_SIZE 15
|
||||
constexpr unsigned int AgcStatsSize = 15;
|
||||
|
||||
namespace RPiController {
|
||||
|
||||
struct AgcMeteringMode {
|
||||
double weights[AGC_STATS_SIZE];
|
||||
double weights[AgcStatsSize];
|
||||
void read(boost::property_tree::ptree const ¶ms);
|
||||
};
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ LOG_DEFINE_CATEGORY(RPiAlsc)
|
|||
|
||||
#define NAME "rpi.alsc"
|
||||
|
||||
static const int X = ALSC_CELLS_X;
|
||||
static const int Y = ALSC_CELLS_Y;
|
||||
static const int X = AlscCellsX;
|
||||
static const int Y = AlscCellsY;
|
||||
static const int XY = X * Y;
|
||||
static const double InsufficientData = -1.0;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace RPiController {
|
|||
|
||||
struct AlscCalibration {
|
||||
double ct;
|
||||
double table[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double table[AlscCellsX * AlscCellsY];
|
||||
};
|
||||
|
||||
struct AlscConfig {
|
||||
|
@ -35,7 +35,7 @@ struct AlscConfig {
|
|||
uint16_t minG;
|
||||
double omega;
|
||||
uint32_t nIter;
|
||||
double luminanceLut[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double luminanceLut[AlscCellsX * AlscCellsY];
|
||||
double luminanceStrength;
|
||||
std::vector<AlscCalibration> calibrationsCr;
|
||||
std::vector<AlscCalibration> calibrationsCb;
|
||||
|
@ -61,7 +61,7 @@ private:
|
|||
AlscConfig config_;
|
||||
bool firstTime_;
|
||||
CameraMode cameraMode_;
|
||||
double luminanceTable_[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double luminanceTable_[AlscCellsX * AlscCellsY];
|
||||
std::thread asyncThread_;
|
||||
void asyncFunc(); /* asynchronous thread function */
|
||||
std::mutex mutex_;
|
||||
|
@ -87,8 +87,8 @@ private:
|
|||
int frameCount_;
|
||||
/* counts up to startupFrames for Process function */
|
||||
int frameCount2_;
|
||||
double syncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double prevSyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double syncResults_[3][AlscCellsY][AlscCellsX];
|
||||
double prevSyncResults_[3][AlscCellsY][AlscCellsX];
|
||||
void waitForAysncThread();
|
||||
/*
|
||||
* The following are for the asynchronous thread to use, though the main
|
||||
|
@ -98,13 +98,13 @@ private:
|
|||
/* copy out the results from the async thread so that it can be restarted */
|
||||
void fetchAsyncResults();
|
||||
double ct_;
|
||||
bcm2835_isp_stats_region statistics_[ALSC_CELLS_Y * ALSC_CELLS_X];
|
||||
double asyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];
|
||||
double asyncLambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double asyncLambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
bcm2835_isp_stats_region statistics_[AlscCellsY * AlscCellsX];
|
||||
double asyncResults_[3][AlscCellsY][AlscCellsX];
|
||||
double asyncLambdaR_[AlscCellsX * AlscCellsY];
|
||||
double asyncLambdaB_[AlscCellsX * AlscCellsY];
|
||||
void doAlsc();
|
||||
double lambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double lambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y];
|
||||
double lambdaR_[AlscCellsX * AlscCellsY];
|
||||
double lambdaB_[AlscCellsX * AlscCellsY];
|
||||
};
|
||||
|
||||
} /* namespace RPiController */
|
||||
|
|
|
@ -18,8 +18,8 @@ LOG_DEFINE_CATEGORY(RPiAwb)
|
|||
|
||||
#define NAME "rpi.awb"
|
||||
|
||||
#define AWB_STATS_SIZE_X DEFAULT_AWB_REGIONS_X
|
||||
#define AWB_STATS_SIZE_Y DEFAULT_AWB_REGIONS_Y
|
||||
static constexpr unsigned int AwbStatsSizeX = DEFAULT_AWB_REGIONS_X;
|
||||
static constexpr unsigned int AwbStatsSizeY = DEFAULT_AWB_REGIONS_Y;
|
||||
|
||||
/*
|
||||
* todo - the locking in this algorithm needs some tidying up as has been done
|
||||
|
@ -357,7 +357,7 @@ static void generateStats(std::vector<Awb::RGB> &zones,
|
|||
bcm2835_isp_stats_region *stats, double minPixels,
|
||||
double minG)
|
||||
{
|
||||
for (int i = 0; i < AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y; i++) {
|
||||
for (unsigned int i = 0; i < AwbStatsSizeX * AwbStatsSizeY; i++) {
|
||||
Awb::RGB zone;
|
||||
double counted = stats[i].counted;
|
||||
if (counted >= minPixels) {
|
||||
|
@ -599,7 +599,7 @@ void Awb::awbBayes()
|
|||
* valid... not entirely sure about this.
|
||||
*/
|
||||
Pwl prior = interpolatePrior();
|
||||
prior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y);
|
||||
prior *= zones_.size() / (double)(AwbStatsSizeX * AwbStatsSizeY);
|
||||
prior.map([](double x, double y) {
|
||||
LOG(RPiAwb, Debug) << "(" << x << "," << y << ")";
|
||||
});
|
||||
|
|
|
@ -70,15 +70,15 @@ static void fillInStatus(ContrastStatus &status, double brightness,
|
|||
{
|
||||
status.brightness = brightness;
|
||||
status.contrast = contrast;
|
||||
for (int i = 0; i < CONTRAST_NUM_POINTS - 1; i++) {
|
||||
for (unsigned int i = 0; i < ContrastNumPoints - 1; i++) {
|
||||
int x = i < 16 ? i * 1024
|
||||
: (i < 24 ? (i - 16) * 2048 + 16384
|
||||
: (i - 24) * 4096 + 32768);
|
||||
status.points[i].x = x;
|
||||
status.points[i].y = std::min(65535.0, gammaCurve.eval(x));
|
||||
}
|
||||
status.points[CONTRAST_NUM_POINTS - 1].x = 65535;
|
||||
status.points[CONTRAST_NUM_POINTS - 1].y = 65535;
|
||||
status.points[ContrastNumPoints - 1].x = 65535;
|
||||
status.points[ContrastNumPoints - 1].y = 65535;
|
||||
}
|
||||
|
||||
void Contrast::initialise()
|
||||
|
|
|
@ -1235,7 +1235,7 @@ void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList
|
|||
struct bcm2835_isp_gamma gamma;
|
||||
|
||||
gamma.enabled = 1;
|
||||
for (int i = 0; i < CONTRAST_NUM_POINTS; i++) {
|
||||
for (unsigned int i = 0; i < ContrastNumPoints; i++) {
|
||||
gamma.x[i] = contrastStatus->points[i].x;
|
||||
gamma.y[i] = contrastStatus->points[i].y;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue