{"id":13412,"url":"https://patchwork.libcamera.org/api/patches/13412/?format=json","web_url":"https://patchwork.libcamera.org/patch/13412/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210820065316.44343-9-jeanmichel.hautbois@ideasonboard.com>","date":"2021-08-20T06:53:15","name":"[libcamera-devel,v5,8/9] ipa: ipu3: Move IPU3 awb into algorithms","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"6c7d603e138cc61a8c95f4e39a156c3491f9beb5","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13412/mbox/","series":[{"id":2374,"url":"https://patchwork.libcamera.org/api/series/2374/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2374","date":"2021-08-20T06:53:07","name":"IPU3: Introduce modularity for algorithms","version":5,"mbox":"https://patchwork.libcamera.org/series/2374/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13412/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13412/checks/","tags":{},"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 3AB3FC3244\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Aug 2021 06:53:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7B13468930;\n\tFri, 20 Aug 2021 08:53:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A5FDC68911\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Aug 2021 08:53:22 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:e43b:edb2:932:6b0a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 54BB3150A;\n\tFri, 20 Aug 2021 08:53:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PvmylGMO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629442402;\n\tbh=BElcLdYoTow6ihnYzZIMZNuVR1sgLJP9zFru0V/qV7w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=PvmylGMO8056LFYHj/vBJZSNZdxWuZ0hDUTxdZ7DXZOa63joaFM20GQt36qloAEG/\n\tpa0v39nBCn7ReICLVGMlrzSoU1/BnpHp37m8a778CDThpCSF16IhtOdNeWlMhiKA/u\n\t15lHjWkftR3fDVf94PdnBSThe4hVY6IAPtctYHDc=","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 20 Aug 2021 08:53:15 +0200","Message-Id":"<20210820065316.44343-9-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20210820065316.44343-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20210820065316.44343-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 8/9] ipa: ipu3: Move IPU3 awb into\n\talgorithms","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Now that the interface is properly used by the AWB class, move it into\nipa::ipu3::algorithms and let the loops do the calls.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n .../ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} | 28 +++++++++----------\n src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} | 20 ++++++-------\n src/ipa/ipu3/algorithms/meson.build           |  1 +\n src/ipa/ipu3/ipu3.cpp                         | 10 ++-----\n src/ipa/ipu3/meson.build                      |  1 -\n 5 files changed, 27 insertions(+), 33 deletions(-)\n rename src/ipa/ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} (94%)\n rename src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} (84%)","diff":"diff --git a/src/ipa/ipu3/ipu3_awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nsimilarity index 94%\nrename from src/ipa/ipu3/ipu3_awb.cpp\nrename to src/ipa/ipu3/algorithms/awb.cpp\nindex 728162fe..e15f7406 100644\n--- a/src/ipa/ipu3/ipu3_awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -2,9 +2,9 @@\n /*\n  * Copyright (C) 2021, Ideas On Board\n  *\n- * ipu3_awb.cpp - AWB control algorithm\n+ * awb.cpp - AWB control algorithm\n  */\n-#include \"ipu3_awb.h\"\n+#include \"awb.h\"\n \n #include <algorithm>\n #include <cmath>\n@@ -13,7 +13,7 @@\n \n namespace libcamera {\n \n-namespace ipa::ipu3 {\n+namespace ipa::ipu3::algorithms {\n \n LOG_DEFINE_CATEGORY(IPU3Awb)\n \n@@ -114,7 +114,7 @@ static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {\n \t0, 0, 8191, 0\n };\n \n-IPU3Awb::IPU3Awb()\n+Awb::Awb()\n \t: Algorithm()\n {\n \tasyncResults_.blueGain = 1.0;\n@@ -125,7 +125,7 @@ IPU3Awb::IPU3Awb()\n \tzones_.reserve(kAwbStatsSizeX * kAwbStatsSizeY);\n }\n \n-IPU3Awb::~IPU3Awb() = default;\n+Awb::~Awb() = default;\n \n /**\n  * The function estimates the correlated color temperature using\n@@ -141,7 +141,7 @@ IPU3Awb::~IPU3Awb() = default;\n  * More detailed information can be found in:\n  * https://en.wikipedia.org/wiki/Color_temperature#Approximation\n  */\n-uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n+uint32_t Awb::estimateCCT(double red, double green, double blue)\n {\n \t/* Convert the RGB values to CIE tristimulus values (XYZ) */\n \tdouble X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);\n@@ -158,7 +158,7 @@ uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n }\n \n /* Generate an RGB vector with the average values for each region */\n-void IPU3Awb::generateZones(std::vector<RGB> &zones)\n+void Awb::generateZones(std::vector<RGB> &zones)\n {\n \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n \t\tRGB zone;\n@@ -175,7 +175,7 @@ void IPU3Awb::generateZones(std::vector<RGB> &zones)\n }\n \n /* Translate the IPU3 statistics into the default statistics region array */\n-void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n+void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n {\n \tuint32_t regionWidth = round(awbGrid_.width / static_cast<double>(kAwbStatsSizeX));\n \tuint32_t regionHeight = round(awbGrid_.height / static_cast<double>(kAwbStatsSizeY));\n@@ -207,7 +207,7 @@ void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n \t}\n }\n \n-void IPU3Awb::clearAwbStats()\n+void Awb::clearAwbStats()\n {\n \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n \t\tawbStats_[i].bSum = 0;\n@@ -218,7 +218,7 @@ void IPU3Awb::clearAwbStats()\n \t}\n }\n \n-void IPU3Awb::awbGreyWorld()\n+void Awb::awbGreyWorld()\n {\n \tLOG(IPU3Awb, Debug) << \"Grey world AWB\";\n \t/*\n@@ -258,7 +258,7 @@ void IPU3Awb::awbGreyWorld()\n \tasyncResults_.blueGain = blueGain;\n }\n \n-void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n+void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n {\n \tASSERT(stats->stats_3a_status.awb_en);\n \tzones_.clear();\n@@ -273,7 +273,7 @@ void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n \t}\n }\n \n-void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n+void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n {\n \tcalculateWBGains(stats);\n \n@@ -287,7 +287,7 @@ void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n \tcontext.frameContext.awb.gains.red = asyncResults_.redGain;\n }\n \n-void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n+void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n {\n \tparams->acc_param.awb.config.rgbs_thr_gr = 8191;\n \tparams->acc_param.awb.config.rgbs_thr_r = 8191;\n@@ -336,6 +336,6 @@ void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n \tparams->use.acc_ccm = 1;\n }\n \n-} /* namespace ipa::ipu3 */\n+} /* namespace ipa::ipu3::algorithms */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/algorithms/awb.h\nsimilarity index 84%\nrename from src/ipa/ipu3/ipu3_awb.h\nrename to src/ipa/ipu3/algorithms/awb.h\nindex 12703489..fac54e45 100644\n--- a/src/ipa/ipu3/ipu3_awb.h\n+++ b/src/ipa/ipu3/algorithms/awb.h\n@@ -2,10 +2,10 @@\n /*\n  * Copyright (C) 2021, Ideas On Board\n  *\n- * ipu3_awb.h - IPU3 AWB control algorithm\n+ * awb.h - IPU3 AWB control algorithm\n  */\n-#ifndef __LIBCAMERA_IPU3_AWB_H__\n-#define __LIBCAMERA_IPU3_AWB_H__\n+#ifndef __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n+#define __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n \n #include <vector>\n \n@@ -13,21 +13,21 @@\n \n #include <libcamera/geometry.h>\n \n-#include \"algorithms/algorithm.h\"\n+#include \"algorithm.h\"\n \n namespace libcamera {\n \n-namespace ipa::ipu3 {\n+namespace ipa::ipu3::algorithms {\n \n /* Region size for the statistics generation algorithm */\n static constexpr uint32_t kAwbStatsSizeX = 16;\n static constexpr uint32_t kAwbStatsSizeY = 12;\n \n-class IPU3Awb : public Algorithm\n+class Awb : public Algorithm\n {\n public:\n-\tIPU3Awb();\n-\t~IPU3Awb();\n+\tAwb();\n+\t~Awb();\n \n \tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\n \tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n@@ -85,7 +85,7 @@ private:\n \tAwbStatus asyncResults_;\n };\n \n-} /* namespace ipa::ipu3 */\n+} /* namespace ipa::ipu3::algorithms */\n \n } /* namespace libcamera*/\n-#endif /* __LIBCAMERA_IPU3_AWB_H__ */\n+#endif /* __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__ */\ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nindex 71eedfa4..fa004df4 100644\n--- a/src/ipa/ipu3/algorithms/meson.build\n+++ b/src/ipa/ipu3/algorithms/meson.build\n@@ -2,5 +2,6 @@\n \n ipu3_ipa_algorithms = files([\n     'algorithm.cpp',\n+    'awb.cpp',\n     'tone_mapping.cpp',\n ])\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 2468e94a..5fc358fa 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -30,9 +30,9 @@\n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n #include \"algorithms/algorithm.h\"\n+#include \"algorithms/awb.h\"\n #include \"algorithms/tone_mapping.h\"\n #include \"ipu3_agc.h\"\n-#include \"ipu3_awb.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n /**\n@@ -187,8 +187,6 @@ private:\n \tuint32_t minGain_;\n \tuint32_t maxGain_;\n \n-\t/* Interface to the AWB algorithm */\n-\tstd::unique_ptr<IPU3Awb> awbAlgo_;\n \t/* Interface to the AEC/AGC algorithm */\n \tstd::unique_ptr<IPU3Agc> agcAlgo_;\n \t/* Interface to the Camera Helper */\n@@ -270,6 +268,7 @@ int IPAIPU3::init(const IPASettings &settings,\n \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n \n \t/* Construct our Algorithms */\n+\talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n \talgorithms_.push_back(std::make_unique<algorithms::ToneMapping>());\n \n \treturn 0;\n@@ -387,7 +386,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \t\t\treturn ret;\n \t}\n \n-\tawbAlgo_ = std::make_unique<IPU3Awb>();\n \tagcAlgo_ = std::make_unique<IPU3Agc>();\n \tagcAlgo_->configure(context_, configInfo);\n \n@@ -466,8 +464,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \tfor (auto const &algo : algorithms_)\n \t\talgo->prepare(context_, params);\n \n-\tawbAlgo_->prepare(context_, params);\n-\n \tIPU3Action op;\n \top.op = ActionParamFilled;\n \n@@ -490,8 +486,6 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n \texposure_ = context_.frameContext.agc.exposure;\n \tgain_ = camHelper_->gainCode(context_.frameContext.agc.gain);\n \n-\tawbAlgo_->process(context_, stats);\n-\n \tsetControls(frame);\n \n \t/* \\todo Use VBlank value calculated from each frame exposure. */\ndiff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build\nindex fcb27d68..d1126947 100644\n--- a/src/ipa/ipu3/meson.build\n+++ b/src/ipa/ipu3/meson.build\n@@ -7,7 +7,6 @@ ipa_name = 'ipa_ipu3'\n ipu3_ipa_sources = files([\n     'ipu3.cpp',\n     'ipu3_agc.cpp',\n-    'ipu3_awb.cpp',\n ])\n \n ipu3_ipa_sources += ipu3_ipa_algorithms\n","prefixes":["libcamera-devel","v5","8/9"]}