[{"id":24125,"web_url":"https://patchwork.libcamera.org/comment/24125/","msgid":"<Yt8C8pf0RcTIqNYl@pendragon.ideasonboard.com>","date":"2022-07-25T20:54:10","subject":"Re: [libcamera-devel] [PATCH 08/15] DNI: ipa: raspberrypi: Code\n\trefactoring to match style guidelines","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Jul 25, 2022 at 02:46:32PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Refactor the source files src/ipa/raspberrypi/controller/rps/[b|c|d]* to match the\n> recommended formatting guidelines for the libcamera project. The vast majority\n> of changes in this commit comprise of switching from snake_case to CamelCase,\n> and starting class member functions with a lower case character.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  .../controller/rpi/black_level.cpp            |  32 ++---\n>  .../controller/rpi/black_level.hpp            |  12 +-\n>  src/ipa/raspberrypi/controller/rpi/ccm.cpp    |  84 +++++++------\n>  src/ipa/raspberrypi/controller/rpi/ccm.hpp    |  12 +-\n>  .../raspberrypi/controller/rpi/contrast.cpp   | 118 +++++++++---------\n>  .../raspberrypi/controller/rpi/contrast.hpp   |  30 ++---\n>  src/ipa/raspberrypi/controller/rpi/dpc.cpp    |  18 +--\n>  src/ipa/raspberrypi/controller/rpi/dpc.hpp    |   6 +-\n>  8 files changed, 155 insertions(+), 157 deletions(-)\n> \n> diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp\n> index 6b3497f13c19..695b3129dd93 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp\n> @@ -26,38 +26,38 @@ BlackLevel::BlackLevel(Controller *controller)\n>  {\n>  }\n>  \n> -char const *BlackLevel::Name() const\n> +char const *BlackLevel::name() const\n>  {\n>  \treturn NAME;\n>  }\n>  \n> -void BlackLevel::Read(boost::property_tree::ptree const &params)\n> +void BlackLevel::read(boost::property_tree::ptree const &params)\n>  {\n> -\tuint16_t black_level = params.get<uint16_t>(\n> +\tuint16_t blackLevel = params.get<uint16_t>(\n>  \t\t\"black_level\", 4096); // 64 in 10 bits scaled to 16 bits\n> -\tblack_level_r_ = params.get<uint16_t>(\"black_level_r\", black_level);\n> -\tblack_level_g_ = params.get<uint16_t>(\"black_level_g\", black_level);\n> -\tblack_level_b_ = params.get<uint16_t>(\"black_level_b\", black_level);\n> +\tblackLevelR_ = params.get<uint16_t>(\"black_level_r\", blackLevel);\n> +\tblackLevelG_ = params.get<uint16_t>(\"black_level_g\", blackLevel);\n> +\tblackLevelB_ = params.get<uint16_t>(\"black_level_b\", blackLevel);\n>  \tLOG(RPiBlackLevel, Debug)\n> -\t\t<< \" Read black levels red \" << black_level_r_\n> -\t\t<< \" green \" << black_level_g_\n> -\t\t<< \" blue \" << black_level_b_;\n> +\t\t<< \" Read black levels red \" << blackLevelR_\n> +\t\t<< \" green \" << blackLevelG_\n> +\t\t<< \" blue \" << blackLevelB_;\n>  }\n>  \n> -void BlackLevel::Prepare(Metadata *image_metadata)\n> +void BlackLevel::prepare(Metadata *imageMetadata)\n>  {\n>  \t// Possibly we should think about doing this in a switch_mode or\n\nswitch_mode could be updated too.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \t// something?\n>  \tstruct BlackLevelStatus status;\n> -\tstatus.black_level_r = black_level_r_;\n> -\tstatus.black_level_g = black_level_g_;\n> -\tstatus.black_level_b = black_level_b_;\n> -\timage_metadata->Set(\"black_level.status\", status);\n> +\tstatus.black_level_r = blackLevelR_;\n> +\tstatus.black_level_g = blackLevelG_;\n> +\tstatus.black_level_b = blackLevelB_;\n> +\timageMetadata->set(\"black_level.status\", status);\n>  }\n>  \n>  // Register algorithm with the system.\n> -static Algorithm *Create(Controller *controller)\n> +static Algorithm *create(Controller *controller)\n>  {\n>  \treturn new BlackLevel(controller);\n>  }\n> -static RegisterAlgorithm reg(NAME, &Create);\n> +static RegisterAlgorithm reg(NAME, &create);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.hpp b/src/ipa/raspberrypi/controller/rpi/black_level.hpp\n> index 65ec4d0ed26c..0d74f6a4c49b 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/black_level.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/black_level.hpp\n> @@ -17,14 +17,14 @@ class BlackLevel : public Algorithm\n>  {\n>  public:\n>  \tBlackLevel(Controller *controller);\n> -\tchar const *Name() const override;\n> -\tvoid Read(boost::property_tree::ptree const &params) override;\n> -\tvoid Prepare(Metadata *image_metadata) override;\n> +\tchar const *name() const override;\n> +\tvoid read(boost::property_tree::ptree const &params) override;\n> +\tvoid prepare(Metadata *imageMetadata) override;\n>  \n>  private:\n> -\tdouble black_level_r_;\n> -\tdouble black_level_g_;\n> -\tdouble black_level_b_;\n> +\tdouble blackLevelR_;\n> +\tdouble blackLevelG_;\n> +\tdouble blackLevelB_;\n>  };\n>  \n>  } // namespace RPiController\n> diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp\n> index 821a4c7c98c5..24d8e5bd1fd8 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp\n> @@ -37,7 +37,7 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5,\n>  \tm[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4,\n>  \tm[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8;\n>  }\n> -void Matrix::Read(boost::property_tree::ptree const &params)\n> +void Matrix::read(boost::property_tree::ptree const &params)\n>  {\n>  \tdouble *ptr = (double *)m;\n>  \tint n = 0;\n> @@ -53,47 +53,49 @@ void Matrix::Read(boost::property_tree::ptree const &params)\n>  Ccm::Ccm(Controller *controller)\n>  \t: CcmAlgorithm(controller), saturation_(1.0) {}\n>  \n> -char const *Ccm::Name() const\n> +char const *Ccm::name() const\n>  {\n>  \treturn NAME;\n>  }\n>  \n> -void Ccm::Read(boost::property_tree::ptree const &params)\n> +void Ccm::read(boost::property_tree::ptree const &params)\n>  {\n>  \tif (params.get_child_optional(\"saturation\"))\n> -\t\tconfig_.saturation.Read(params.get_child(\"saturation\"));\n> +\t\tconfig_.saturation.read(params.get_child(\"saturation\"));\n>  \tfor (auto &p : params.get_child(\"ccms\")) {\n> -\t\tCtCcm ct_ccm;\n> -\t\tct_ccm.ct = p.second.get<double>(\"ct\");\n> -\t\tct_ccm.ccm.Read(p.second.get_child(\"ccm\"));\n> +\t\tCtCcm ctCcm;\n> +\t\tctCcm.ct = p.second.get<double>(\"ct\");\n> +\t\tctCcm.ccm.read(p.second.get_child(\"ccm\"));\n>  \t\tif (!config_.ccms.empty() &&\n> -\t\t    ct_ccm.ct <= config_.ccms.back().ct)\n> +\t\t    ctCcm.ct <= config_.ccms.back().ct)\n>  \t\t\tthrow std::runtime_error(\n>  \t\t\t\t\"Ccm: CCM not in increasing colour temperature order\");\n> -\t\tconfig_.ccms.push_back(std::move(ct_ccm));\n> +\t\tconfig_.ccms.push_back(std::move(ctCcm));\n>  \t}\n>  \tif (config_.ccms.empty())\n>  \t\tthrow std::runtime_error(\"Ccm: no CCMs specified\");\n>  }\n>  \n> -void Ccm::SetSaturation(double saturation)\n> +void Ccm::setSaturation(double saturation)\n>  {\n>  \tsaturation_ = saturation;\n>  }\n>  \n> -void Ccm::Initialise() {}\n> +void Ccm::initialise()\n> +{\n> +}\n>  \n>  template<typename T>\n> -static bool get_locked(Metadata *metadata, std::string const &tag, T &value)\n> +static bool getLocked(Metadata *metadata, std::string const &tag, T &value)\n>  {\n> -\tT *ptr = metadata->GetLocked<T>(tag);\n> +\tT *ptr = metadata->getLocked<T>(tag);\n>  \tif (ptr == nullptr)\n>  \t\treturn false;\n>  \tvalue = *ptr;\n>  \treturn true;\n>  }\n>  \n> -Matrix calculate_ccm(std::vector<CtCcm> const &ccms, double ct)\n> +Matrix calculateCcm(std::vector<CtCcm> const &ccms, double ct)\n>  {\n>  \tif (ct <= ccms.front().ct)\n>  \t\treturn ccms.front().ccm;\n> @@ -109,7 +111,7 @@ Matrix calculate_ccm(std::vector<CtCcm> const &ccms, double ct)\n>  \t}\n>  }\n>  \n> -Matrix apply_saturation(Matrix const &ccm, double saturation)\n> +Matrix applySaturation(Matrix const &ccm, double saturation)\n>  {\n>  \tMatrix RGB2Y(0.299, 0.587, 0.114, -0.169, -0.331, 0.500, 0.500, -0.419,\n>  \t\t     -0.081);\n> @@ -119,51 +121,51 @@ Matrix apply_saturation(Matrix const &ccm, double saturation)\n>  \treturn Y2RGB * S * RGB2Y * ccm;\n>  }\n>  \n> -void Ccm::Prepare(Metadata *image_metadata)\n> +void Ccm::prepare(Metadata *imageMetadata)\n>  {\n> -\tbool awb_ok = false, lux_ok = false;\n> +\tbool awbOk = false, luxOk = false;\n>  \tstruct AwbStatus awb = {};\n> -\tawb.temperature_K = 4000; // in case no metadata\n> +\tawb.temperatureK = 4000; // in case no metadata\n>  \tstruct LuxStatus lux = {};\n>  \tlux.lux = 400; // in case no metadata\n>  \t{\n>  \t\t// grab mutex just once to get everything\n> -\t\tstd::lock_guard<Metadata> lock(*image_metadata);\n> -\t\tawb_ok = get_locked(image_metadata, \"awb.status\", awb);\n> -\t\tlux_ok = get_locked(image_metadata, \"lux.status\", lux);\n> +\t\tstd::lock_guard<Metadata> lock(*imageMetadata);\n> +\t\tawbOk = getLocked(imageMetadata, \"awb.status\", awb);\n> +\t\tluxOk = getLocked(imageMetadata, \"lux.status\", lux);\n>  \t}\n> -\tif (!awb_ok)\n> +\tif (!awbOk)\n>  \t\tLOG(RPiCcm, Warning) << \"no colour temperature found\";\n> -\tif (!lux_ok)\n> +\tif (!luxOk)\n>  \t\tLOG(RPiCcm, Warning) << \"no lux value found\";\n> -\tMatrix ccm = calculate_ccm(config_.ccms, awb.temperature_K);\n> +\tMatrix ccm = calculateCcm(config_.ccms, awb.temperatureK);\n>  \tdouble saturation = saturation_;\n> -\tstruct CcmStatus ccm_status;\n> -\tccm_status.saturation = saturation;\n> -\tif (!config_.saturation.Empty())\n> -\t\tsaturation *= config_.saturation.Eval(\n> -\t\t\tconfig_.saturation.Domain().Clip(lux.lux));\n> -\tccm = apply_saturation(ccm, saturation);\n> +\tstruct CcmStatus ccmStatus;\n> +\tccmStatus.saturation = saturation;\n> +\tif (!config_.saturation.empty())\n> +\t\tsaturation *= config_.saturation.eval(\n> +\t\t\tconfig_.saturation.domain().clip(lux.lux));\n> +\tccm = applySaturation(ccm, saturation);\n>  \tfor (int j = 0; j < 3; j++)\n>  \t\tfor (int i = 0; i < 3; i++)\n> -\t\t\tccm_status.matrix[j * 3 + i] =\n> +\t\t\tccmStatus.matrix[j * 3 + i] =\n>  \t\t\t\tstd::max(-8.0, std::min(7.9999, ccm.m[j][i]));\n>  \tLOG(RPiCcm, Debug)\n> -\t\t<< \"colour temperature \" << awb.temperature_K << \"K\";\n> +\t\t<< \"colour temperature \" << awb.temperatureK << \"K\";\n>  \tLOG(RPiCcm, Debug)\n> -\t\t<< \"CCM: \" << ccm_status.matrix[0] << \" \" << ccm_status.matrix[1]\n> -\t\t<< \" \" << ccm_status.matrix[2] << \"     \"\n> -\t\t<< ccm_status.matrix[3] << \" \" << ccm_status.matrix[4]\n> -\t\t<< \" \" << ccm_status.matrix[5] << \"     \"\n> -\t\t<< ccm_status.matrix[6] << \" \" << ccm_status.matrix[7]\n> -\t\t<< \" \" << ccm_status.matrix[8];\n> -\timage_metadata->Set(\"ccm.status\", ccm_status);\n> +\t\t<< \"CCM: \" << ccmStatus.matrix[0] << \" \" << ccmStatus.matrix[1]\n> +\t\t<< \" \" << ccmStatus.matrix[2] << \"     \"\n> +\t\t<< ccmStatus.matrix[3] << \" \" << ccmStatus.matrix[4]\n> +\t\t<< \" \" << ccmStatus.matrix[5] << \"     \"\n> +\t\t<< ccmStatus.matrix[6] << \" \" << ccmStatus.matrix[7]\n> +\t\t<< \" \" << ccmStatus.matrix[8];\n> +\timageMetadata->set(\"ccm.status\", ccmStatus);\n>  }\n>  \n>  // Register algorithm with the system.\n> -static Algorithm *Create(Controller *controller)\n> +static Algorithm *create(Controller *controller)\n>  {\n>  \treturn (Algorithm *)new Ccm(controller);\n>  \t;\n>  }\n> -static RegisterAlgorithm reg(NAME, &Create);\n> +static RegisterAlgorithm reg(NAME, &create);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.hpp b/src/ipa/raspberrypi/controller/rpi/ccm.hpp\n> index 330ed51fe398..4c4807b8a942 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/ccm.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/ccm.hpp\n> @@ -20,7 +20,7 @@ struct Matrix {\n>  \t       double m6, double m7, double m8);\n>  \tMatrix();\n>  \tdouble m[3][3];\n> -\tvoid Read(boost::property_tree::ptree const &params);\n> +\tvoid read(boost::property_tree::ptree const &params);\n>  };\n>  static inline Matrix operator*(double d, Matrix const &m)\n>  {\n> @@ -61,11 +61,11 @@ class Ccm : public CcmAlgorithm\n>  {\n>  public:\n>  \tCcm(Controller *controller = NULL);\n> -\tchar const *Name() const override;\n> -\tvoid Read(boost::property_tree::ptree const &params) override;\n> -\tvoid SetSaturation(double saturation) override;\n> -\tvoid Initialise() override;\n> -\tvoid Prepare(Metadata *image_metadata) override;\n> +\tchar const *name() const override;\n> +\tvoid read(boost::property_tree::ptree const &params) override;\n> +\tvoid setSaturation(double saturation) override;\n> +\tvoid initialise() override;\n> +\tvoid prepare(Metadata *imageMetadata) override;\n>  \n>  private:\n>  \tCcmConfig config_;\n> diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp\n> index ae55aad56739..169837576678 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp\n> @@ -31,40 +31,40 @@ Contrast::Contrast(Controller *controller)\n>  {\n>  }\n>  \n> -char const *Contrast::Name() const\n> +char const *Contrast::name() const\n>  {\n>  \treturn NAME;\n>  }\n>  \n> -void Contrast::Read(boost::property_tree::ptree const &params)\n> +void Contrast::read(boost::property_tree::ptree const &params)\n>  {\n>  \t// enable adaptive enhancement by default\n> -\tconfig_.ce_enable = params.get<int>(\"ce_enable\", 1);\n> +\tconfig_.ceEnable = params.get<int>(\"ce_enable\", 1);\n>  \t// the point near the bottom of the histogram to move\n> -\tconfig_.lo_histogram = params.get<double>(\"lo_histogram\", 0.01);\n> +\tconfig_.loHistogram = params.get<double>(\"lo_histogram\", 0.01);\n>  \t// where in the range to try and move it to\n> -\tconfig_.lo_level = params.get<double>(\"lo_level\", 0.015);\n> +\tconfig_.loLevel = params.get<double>(\"lo_level\", 0.015);\n>  \t// but don't move by more than this\n> -\tconfig_.lo_max = params.get<double>(\"lo_max\", 500);\n> +\tconfig_.loMax = params.get<double>(\"lo_max\", 500);\n>  \t// equivalent values for the top of the histogram...\n> -\tconfig_.hi_histogram = params.get<double>(\"hi_histogram\", 0.95);\n> -\tconfig_.hi_level = params.get<double>(\"hi_level\", 0.95);\n> -\tconfig_.hi_max = params.get<double>(\"hi_max\", 2000);\n> -\tconfig_.gamma_curve.Read(params.get_child(\"gamma_curve\"));\n> +\tconfig_.hiHistogram = params.get<double>(\"hi_histogram\", 0.95);\n> +\tconfig_.hiLevel = params.get<double>(\"hi_level\", 0.95);\n> +\tconfig_.hiMax = params.get<double>(\"hi_max\", 2000);\n> +\tconfig_.gammaCurve.read(params.get_child(\"gamma_curve\"));\n>  }\n>  \n> -void Contrast::SetBrightness(double brightness)\n> +void Contrast::setBrightness(double brightness)\n>  {\n>  \tbrightness_ = brightness;\n>  }\n>  \n> -void Contrast::SetContrast(double contrast)\n> +void Contrast::setContrast(double contrast)\n>  {\n>  \tcontrast_ = contrast;\n>  }\n>  \n> -static void fill_in_status(ContrastStatus &status, double brightness,\n> -\t\t\t   double contrast, Pwl &gamma_curve)\n> +static void fillInStatus(ContrastStatus &status, double brightness,\n> +\t\t\t double contrast, Pwl &gammaCurve)\n>  {\n>  \tstatus.brightness = brightness;\n>  \tstatus.contrast = contrast;\n> @@ -73,104 +73,100 @@ static void fill_in_status(ContrastStatus &status, double brightness,\n>  \t\t\t       : (i < 24 ? (i - 16) * 2048 + 16384\n>  \t\t\t\t\t : (i - 24) * 4096 + 32768);\n>  \t\tstatus.points[i].x = x;\n> -\t\tstatus.points[i].y = std::min(65535.0, gamma_curve.Eval(x));\n> +\t\tstatus.points[i].y = std::min(65535.0, gammaCurve.eval(x));\n>  \t}\n>  \tstatus.points[CONTRAST_NUM_POINTS - 1].x = 65535;\n>  \tstatus.points[CONTRAST_NUM_POINTS - 1].y = 65535;\n>  }\n>  \n> -void Contrast::Initialise()\n> +void Contrast::initialise()\n>  {\n>  \t// Fill in some default values as Prepare will run before Process gets\n>  \t// called.\n> -\tfill_in_status(status_, brightness_, contrast_, config_.gamma_curve);\n> +\tfillInStatus(status_, brightness_, contrast_, config_.gammaCurve);\n>  }\n>  \n> -void Contrast::Prepare(Metadata *image_metadata)\n> +void Contrast::prepare(Metadata *imageMetadata)\n>  {\n>  \tstd::unique_lock<std::mutex> lock(mutex_);\n> -\timage_metadata->Set(\"contrast.status\", status_);\n> +\timageMetadata->set(\"contrast.status\", status_);\n>  }\n>  \n> -Pwl compute_stretch_curve(Histogram const &histogram,\n> -\t\t\t  ContrastConfig const &config)\n> +Pwl computeStretchCurve(Histogram const &histogram,\n> +\t\t\tContrastConfig const &config)\n>  {\n>  \tPwl enhance;\n> -\tenhance.Append(0, 0);\n> +\tenhance.append(0, 0);\n>  \t// If the start of the histogram is rather empty, try to pull it down a\n>  \t// bit.\n> -\tdouble hist_lo = histogram.Quantile(config.lo_histogram) *\n> -\t\t\t (65536 / NUM_HISTOGRAM_BINS);\n> -\tdouble level_lo = config.lo_level * 65536;\n> +\tdouble histLo = histogram.quantile(config.loHistogram) *\n> +\t\t\t(65536 / NUM_HISTOGRAM_BINS);\n> +\tdouble levelLo = config.loLevel * 65536;\n>  \tLOG(RPiContrast, Debug)\n> -\t\t<< \"Move histogram point \" << hist_lo << \" to \" << level_lo;\n> -\thist_lo = std::max(\n> -\t\tlevel_lo,\n> -\t\tstd::min(65535.0, std::min(hist_lo, level_lo + config.lo_max)));\n> +\t\t<< \"Move histogram point \" << histLo << \" to \" << levelLo;\n> +\thistLo = std::max(levelLo,\n> +\t\t\t  std::min(65535.0, std::min(histLo, levelLo + config.loMax)));\n>  \tLOG(RPiContrast, Debug)\n> -\t\t<< \"Final values \" << hist_lo << \" -> \" << level_lo;\n> -\tenhance.Append(hist_lo, level_lo);\n> +\t\t<< \"Final values \" << histLo << \" -> \" << levelLo;\n> +\tenhance.append(histLo, levelLo);\n>  \t// Keep the mid-point (median) in the same place, though, to limit the\n>  \t// apparent amount of global brightness shift.\n> -\tdouble mid = histogram.Quantile(0.5) * (65536 / NUM_HISTOGRAM_BINS);\n> -\tenhance.Append(mid, mid);\n> +\tdouble mid = histogram.quantile(0.5) * (65536 / NUM_HISTOGRAM_BINS);\n> +\tenhance.append(mid, mid);\n>  \n>  \t// If the top to the histogram is empty, try to pull the pixel values\n>  \t// there up.\n> -\tdouble hist_hi = histogram.Quantile(config.hi_histogram) *\n> -\t\t\t (65536 / NUM_HISTOGRAM_BINS);\n> -\tdouble level_hi = config.hi_level * 65536;\n> +\tdouble histHi = histogram.quantile(config.hiHistogram) *\n> +\t\t\t(65536 / NUM_HISTOGRAM_BINS);\n> +\tdouble levelHi = config.hiLevel * 65536;\n>  \tLOG(RPiContrast, Debug)\n> -\t\t<< \"Move histogram point \" << hist_hi << \" to \" << level_hi;\n> -\thist_hi = std::min(\n> -\t\tlevel_hi,\n> -\t\tstd::max(0.0, std::max(hist_hi, level_hi - config.hi_max)));\n> +\t\t<< \"Move histogram point \" << histHi << \" to \" << levelHi;\n> +\thistHi = std::min(levelHi,\n> +\t\t\t  std::max(0.0, std::max(histHi, levelHi - config.hiMax)));\n>  \tLOG(RPiContrast, Debug)\n> -\t\t<< \"Final values \" << hist_hi << \" -> \" << level_hi;\n> -\tenhance.Append(hist_hi, level_hi);\n> -\tenhance.Append(65535, 65535);\n> +\t\t<< \"Final values \" << histHi << \" -> \" << levelHi;\n> +\tenhance.append(histHi, levelHi);\n> +\tenhance.append(65535, 65535);\n>  \treturn enhance;\n>  }\n>  \n> -Pwl apply_manual_contrast(Pwl const &gamma_curve, double brightness,\n> -\t\t\t  double contrast)\n> +Pwl applyManualContrast(Pwl const &gammaCurve, double brightness,\n> +\t\t\tdouble contrast)\n>  {\n> -\tPwl new_gamma_curve;\n> +\tPwl newGammaCurve;\n>  \tLOG(RPiContrast, Debug)\n>  \t\t<< \"Manual brightness \" << brightness << \" contrast \" << contrast;\n> -\tgamma_curve.Map([&](double x, double y) {\n> -\t\tnew_gamma_curve.Append(\n> +\tgammaCurve.map([&](double x, double y) {\n> +\t\tnewGammaCurve.append(\n>  \t\t\tx, std::max(0.0, std::min(65535.0,\n>  \t\t\t\t\t\t  (y - 32768) * contrast +\n>  \t\t\t\t\t\t\t  32768 + brightness)));\n>  \t});\n> -\treturn new_gamma_curve;\n> +\treturn newGammaCurve;\n>  }\n>  \n> -void Contrast::Process(StatisticsPtr &stats,\n> -\t\t       [[maybe_unused]] Metadata *image_metadata)\n> +void Contrast::process(StatisticsPtr &stats,\n> +\t\t       [[maybe_unused]] Metadata *imageMetadata)\n>  {\n>  \tHistogram histogram(stats->hist[0].g_hist, NUM_HISTOGRAM_BINS);\n>  \t// We look at the histogram and adjust the gamma curve in the following\n>  \t// ways: 1. Adjust the gamma curve so as to pull the start of the\n>  \t// histogram down, and possibly push the end up.\n> -\tPwl gamma_curve = config_.gamma_curve;\n> -\tif (config_.ce_enable) {\n> -\t\tif (config_.lo_max != 0 || config_.hi_max != 0)\n> -\t\t\tgamma_curve = compute_stretch_curve(histogram, config_)\n> -\t\t\t\t\t      .Compose(gamma_curve);\n> +\tPwl gammaCurve = config_.gammaCurve;\n> +\tif (config_.ceEnable) {\n> +\t\tif (config_.loMax != 0 || config_.hiMax != 0)\n> +\t\t\tgammaCurve = computeStretchCurve(histogram, config_).compose(gammaCurve);\n>  \t\t// We could apply other adjustments (e.g. partial equalisation)\n>  \t\t// based on the histogram...?\n>  \t}\n>  \t// 2. Finally apply any manually selected brightness/contrast\n>  \t// adjustment.\n>  \tif (brightness_ != 0 || contrast_ != 1.0)\n> -\t\tgamma_curve = apply_manual_contrast(gamma_curve, brightness_,\n> -\t\t\t\t\t\t    contrast_);\n> +\t\tgammaCurve = applyManualContrast(gammaCurve, brightness_, contrast_);\n>  \t// And fill in the status for output. Use more points towards the bottom\n>  \t// of the curve.\n>  \tContrastStatus status;\n> -\tfill_in_status(status, brightness_, contrast_, gamma_curve);\n> +\tfillInStatus(status, brightness_, contrast_, gammaCurve);\n>  \t{\n>  \t\tstd::unique_lock<std::mutex> lock(mutex_);\n>  \t\tstatus_ = status;\n> @@ -178,8 +174,8 @@ void Contrast::Process(StatisticsPtr &stats,\n>  }\n>  \n>  // Register algorithm with the system.\n> -static Algorithm *Create(Controller *controller)\n> +static Algorithm *create(Controller *controller)\n>  {\n>  \treturn (Algorithm *)new Contrast(controller);\n>  }\n> -static RegisterAlgorithm reg(NAME, &Create);\n> +static RegisterAlgorithm reg(NAME, &create);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.hpp b/src/ipa/raspberrypi/controller/rpi/contrast.hpp\n> index 85624539a1da..5a6d530f63fd 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/contrast.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/contrast.hpp\n> @@ -17,27 +17,27 @@ namespace RPiController {\n>  // Back End AWB.\n>  \n>  struct ContrastConfig {\n> -\tbool ce_enable;\n> -\tdouble lo_histogram;\n> -\tdouble lo_level;\n> -\tdouble lo_max;\n> -\tdouble hi_histogram;\n> -\tdouble hi_level;\n> -\tdouble hi_max;\n> -\tPwl gamma_curve;\n> +\tbool ceEnable;\n> +\tdouble loHistogram;\n> +\tdouble loLevel;\n> +\tdouble loMax;\n> +\tdouble hiHistogram;\n> +\tdouble hiLevel;\n> +\tdouble hiMax;\n> +\tPwl gammaCurve;\n>  };\n>  \n>  class Contrast : public ContrastAlgorithm\n>  {\n>  public:\n>  \tContrast(Controller *controller = NULL);\n> -\tchar const *Name() const override;\n> -\tvoid Read(boost::property_tree::ptree const &params) override;\n> -\tvoid SetBrightness(double brightness) override;\n> -\tvoid SetContrast(double contrast) override;\n> -\tvoid Initialise() override;\n> -\tvoid Prepare(Metadata *image_metadata) override;\n> -\tvoid Process(StatisticsPtr &stats, Metadata *image_metadata) override;\n> +\tchar const *name() const override;\n> +\tvoid read(boost::property_tree::ptree const &params) override;\n> +\tvoid setBrightness(double brightness) override;\n> +\tvoid setContrast(double contrast) override;\n> +\tvoid initialise() override;\n> +\tvoid prepare(Metadata *imageMetadata) override;\n> +\tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n>  \n>  private:\n>  \tContrastConfig config_;\n> diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp\n> index 110f50560e76..42154cf300b8 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp\n> @@ -24,30 +24,30 @@ Dpc::Dpc(Controller *controller)\n>  {\n>  }\n>  \n> -char const *Dpc::Name() const\n> +char const *Dpc::name() const\n>  {\n>  \treturn NAME;\n>  }\n>  \n> -void Dpc::Read(boost::property_tree::ptree const &params)\n> +void Dpc::read(boost::property_tree::ptree const &params)\n>  {\n>  \tconfig_.strength = params.get<int>(\"strength\", 1);\n>  \tif (config_.strength < 0 || config_.strength > 2)\n>  \t\tthrow std::runtime_error(\"Dpc: bad strength value\");\n>  }\n>  \n> -void Dpc::Prepare(Metadata *image_metadata)\n> +void Dpc::prepare(Metadata *imageMetadata)\n>  {\n> -\tDpcStatus dpc_status = {};\n> +\tDpcStatus dpcStatus = {};\n>  \t// Should we vary this with lux level or analogue gain? TBD.\n> -\tdpc_status.strength = config_.strength;\n> -\tLOG(RPiDpc, Debug) << \"strength \" << dpc_status.strength;\n> -\timage_metadata->Set(\"dpc.status\", dpc_status);\n> +\tdpcStatus.strength = config_.strength;\n> +\tLOG(RPiDpc, Debug) << \"strength \" << dpcStatus.strength;\n> +\timageMetadata->set(\"dpc.status\", dpcStatus);\n>  }\n>  \n>  // Register algorithm with the system.\n> -static Algorithm *Create(Controller *controller)\n> +static Algorithm *create(Controller *controller)\n>  {\n>  \treturn (Algorithm *)new Dpc(controller);\n>  }\n> -static RegisterAlgorithm reg(NAME, &Create);\n> +static RegisterAlgorithm reg(NAME, &create);\n> diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.hpp b/src/ipa/raspberrypi/controller/rpi/dpc.hpp\n> index d90285c4eb56..039310cc8d05 100644\n> --- a/src/ipa/raspberrypi/controller/rpi/dpc.hpp\n> +++ b/src/ipa/raspberrypi/controller/rpi/dpc.hpp\n> @@ -21,9 +21,9 @@ class Dpc : public Algorithm\n>  {\n>  public:\n>  \tDpc(Controller *controller);\n> -\tchar const *Name() const override;\n> -\tvoid Read(boost::property_tree::ptree const &params) override;\n> -\tvoid Prepare(Metadata *image_metadata) override;\n> +\tchar const *name() const override;\n> +\tvoid read(boost::property_tree::ptree const &params) override;\n> +\tvoid prepare(Metadata *imageMetadata) override;\n>  \n>  private:\n>  \tDpcConfig config_;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 077BFBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 25 Jul 2022 20:54:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5439C63312;\n\tMon, 25 Jul 2022 22:54:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 597356330A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Jul 2022 22:54:15 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C1E956D1;\n\tMon, 25 Jul 2022 22:54:14 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658782457;\n\tbh=AvPlRp4MNtvqVeRZpuw0mA05sNNB5tkahWYSd+dTIps=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=gqbarC3gj4Zxng/b69O+29ADXcfrJary8DS1AN/PsHJqDLW0D7bvarm2Hs/lsKhOq\n\tVZCJL6f2Qah7eQtgHdkYVEd7A0vj6onL2AUG/0ETdCMb3G3PYPIqeqRCL4A8VGIct6\n\tptUdpfEMbGJp5dI/iHWj8sE0ufxurDDZC1PycfOxCO9+uzOmyt7ZMt62t8CS+G40CV\n\tlAoz8ceraffQhV0lXpjXm7mRJcpM8m/RKI+r+v73pHcG3SPcp3isnxIcIDGJFU3VQK\n\tuAdBuPKX0336Mli1oxpSI7Um6YWMSSEBToPyVdDL+1N3LJ8f3+S0vvl7lcvKHqr3lk\n\tQCSM6GvyQOizA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658782455;\n\tbh=AvPlRp4MNtvqVeRZpuw0mA05sNNB5tkahWYSd+dTIps=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IBaxVXD7GeEcTYqxT1EZbUeaWAFdi9tdZKuwp/YTJwTr0r+Yv1KNfzt6OF7L8Edae\n\thJkn7doT113IWJhkxiTpG/AdjRiC8QueU7iFqPYCY8qNuuTABk/NkwUbUCtY1unJFI\n\t8MaATvVdDrJhFalGAsBPqFswjUEyJmKKHkqZTPN0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"IBaxVXD7\"; dkim-atps=neutral","Date":"Mon, 25 Jul 2022 23:54:10 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Yt8C8pf0RcTIqNYl@pendragon.ideasonboard.com>","References":"<20220725134639.4572-1-naush@raspberrypi.com>\n\t<20220725134639.4572-9-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220725134639.4572-9-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 08/15] DNI: ipa: raspberrypi: Code\n\trefactoring to match style guidelines","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]