{"id":15235,"url":"https://patchwork.libcamera.org/api/patches/15235/?format=json","web_url":"https://patchwork.libcamera.org/patch/15235/","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":"<20220103170956.323025-2-umang.jain@ideasonboard.com>","date":"2022-01-03T17:09:53","name":"[libcamera-devel,1/4] libipa: algorithm: Pass frame number to prepare() and process()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"75cc7ce75c9ec07c5f0e065f755e0b6bd09194a1","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15235/mbox/","series":[{"id":2873,"url":"https://patchwork.libcamera.org/api/series/2873/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2873","date":"2022-01-03T17:09:52","name":"IPAIPU3 - Rework interface and introduce context","version":1,"mbox":"https://patchwork.libcamera.org/series/2873/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15235/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15235/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 C3157C3258\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Jan 2022 17:10:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C95F60913;\n\tMon,  3 Jan 2022 18:10:11 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 702F2604F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Jan 2022 18:10:09 +0100 (CET)","from perceval.ideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3e:193e:9a73:f356:8c6a:a1aa])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C725CC;\n\tMon,  3 Jan 2022 18:10:07 +0100 (CET)"],"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=\"THRqp/Yx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1641229809;\n\tbh=o768ONRMiGpPQx6mMtiV4b5RR9Md3sAfMrkAH+/FKUA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=THRqp/Yxo4WY3/YdpgHGsfSqluj+sUkeHj8WT/1iGFQfXhctR+y14hgt2y3eQaKyA\n\tdqxcw/fLMs8+uuZTH0/XWTycDa/gPshM/Q7Stcd9bxUuD2FuLtzchQvaiXYanStW4e\n\t3rTJvBzsaGM8xK9Usqh7+93pY2ZHdNhjfLdNKT0w=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  3 Jan 2022 22:39:53 +0530","Message-Id":"<20220103170956.323025-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20220103170956.323025-1-umang.jain@ideasonboard.com>","References":"<20220103170956.323025-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/4] libipa: algorithm: Pass frame number\n\tto prepare() and process()","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":"The frame number will be used to retrieve their respective\nIPAFrameContext from a container in subsequent commits.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp          | 3 ++-\n src/ipa/ipu3/algorithms/agc.h            | 2 +-\n src/ipa/ipu3/algorithms/awb.cpp          | 4 ++--\n src/ipa/ipu3/algorithms/awb.h            | 4 ++--\n src/ipa/ipu3/algorithms/blc.cpp          | 6 ++++--\n src/ipa/ipu3/algorithms/blc.h            | 2 +-\n src/ipa/ipu3/algorithms/tone_mapping.cpp | 7 +++++--\n src/ipa/ipu3/algorithms/tone_mapping.h   | 4 ++--\n src/ipa/ipu3/ipu3.cpp                    | 4 ++--\n src/ipa/libipa/algorithm.cpp             | 2 ++\n src/ipa/libipa/algorithm.h               | 6 ++++--\n 11 files changed, 27 insertions(+), 17 deletions(-)","diff":"diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 8d6f18f6..1d0778d8 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -307,13 +307,14 @@ double Agc::estimateLuminance(IPAFrameContext &frameContext,\n \n /**\n  * \\brief Process IPU3 statistics, and run AGC operations\n+ * \\param frame The frame number\n  * \\param[in] context The shared IPA context\n  * \\param[in] stats The IPU3 statistics and ISP results\n  *\n  * Identify the current image brightness, and use that to estimate the optimal\n  * new exposure and gain for the scene.\n  */\n-void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n+void Agc::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)\n {\n \t/*\n \t * Estimate the gain needed to have the proportion of pixels in a given\ndiff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\nindex 96ec7005..c6ab8e91 100644\n--- a/src/ipa/ipu3/algorithms/agc.h\n+++ b/src/ipa/ipu3/algorithms/agc.h\n@@ -28,7 +28,7 @@ public:\n \t~Agc() = default;\n \n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n \n private:\n \tdouble measureBrightness(const ipu3_uapi_stats_3a *stats,\ndiff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex 1dc27fc9..99fb5305 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -379,7 +379,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n /**\n  * \\copydoc libcamera::ipa::Algorithm::process\n  */\n-void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n+void Awb::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)\n {\n \tcalculateWBGains(stats);\n \n@@ -403,7 +403,7 @@ constexpr uint16_t Awb::threshold(float value)\n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n-void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n+void Awb::prepare([[maybe_unused]] const uint32_t frame, IPAContext &context, ipu3_uapi_params *params)\n {\n \t/*\n \t * Green saturation thresholds are reduced because we are using the\ndiff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\nindex ab4b0a33..ef177a4a 100644\n--- a/src/ipa/ipu3/algorithms/awb.h\n+++ b/src/ipa/ipu3/algorithms/awb.h\n@@ -39,8 +39,8 @@ public:\n \t~Awb();\n \n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n \n private:\n \t/* \\todo Make these structs available to all the ISPs ? */\ndiff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp\nindex 78ab7bff..e9b4bed8 100644\n--- a/src/ipa/ipu3/algorithms/blc.cpp\n+++ b/src/ipa/ipu3/algorithms/blc.cpp\n@@ -38,14 +38,16 @@ BlackLevelCorrection::BlackLevelCorrection()\n \n /**\n  * \\brief Fill in the parameter structure, and enable black level correction\n+ * \\param frame The frame number\n  * \\param context The shared IPA context\n  * \\param params The IPU3 parameters\n  *\n  * Populate the IPU3 parameter structure with the correction values for each\n  * channel and enable the corresponding ImgU block processing.\n  */\n-void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n-\t\t\t      ipu3_uapi_params *params)\n+void BlackLevelCorrection::prepare([[maybe_unused]] const uint32_t frame,\n+\t\t\t\t   [[maybe_unused]] IPAContext &context,\n+\t\t\t\t   ipu3_uapi_params *params)\n {\n \t/*\n \t * The Optical Black Level correction values\ndiff --git a/src/ipa/ipu3/algorithms/blc.h b/src/ipa/ipu3/algorithms/blc.h\nindex d8da1748..e4c22070 100644\n--- a/src/ipa/ipu3/algorithms/blc.h\n+++ b/src/ipa/ipu3/algorithms/blc.h\n@@ -18,7 +18,7 @@ class BlackLevelCorrection : public Algorithm\n public:\n \tBlackLevelCorrection();\n \n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\n };\n \n } /* namespace ipa::ipu3::algorithms */\ndiff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp\nindex 2040eda5..bba5bc9a 100644\n--- a/src/ipa/ipu3/algorithms/tone_mapping.cpp\n+++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp\n@@ -49,13 +49,15 @@ int ToneMapping::configure(IPAContext &context,\n \n /**\n  * \\brief Fill in the parameter structure, and enable gamma control\n+ * \\param frame The frame number\n  * \\param context The shared IPA context\n  * \\param params The IPU3 parameters\n  *\n  * Populate the IPU3 parameter structure with our tone mapping look up table and\n  * enable the gamma control module in the processing blocks.\n  */\n-void ToneMapping::prepare([[maybe_unused]] IPAContext &context,\n+void ToneMapping::prepare([[maybe_unused]] const uint32_t frame,\n+\t\t\t  [[maybe_unused]] IPAContext &context,\n \t\t\t  ipu3_uapi_params *params)\n {\n \t/* Copy the calculated LUT into the parameters buffer. */\n@@ -71,13 +73,14 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,\n \n /**\n  * \\brief Calculate the tone mapping look up table\n+ * \\param frame The frame number\n  * \\param context The shared IPA context\n  * \\param stats The IPU3 statistics and ISP results\n  *\n  * The tone mapping look up table is generated as an inverse power curve from\n  * our gamma setting.\n  */\n-void ToneMapping::process(IPAContext &context,\n+void ToneMapping::process(const uint32_t frame, IPAContext &context,\n \t\t\t  [[maybe_unused]] const ipu3_uapi_stats_3a *stats)\n {\n \t/*\ndiff --git a/src/ipa/ipu3/algorithms/tone_mapping.h b/src/ipa/ipu3/algorithms/tone_mapping.h\nindex b727ab1e..041c9c0d 100644\n--- a/src/ipa/ipu3/algorithms/tone_mapping.h\n+++ b/src/ipa/ipu3/algorithms/tone_mapping.h\n@@ -19,8 +19,8 @@ public:\n \tToneMapping();\n \n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n \n private:\n \tdouble gamma_;\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 3d307708..aef232c3 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -595,7 +595,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \tparams->use = {};\n \n \tfor (auto const &algo : algorithms_)\n-\t\talgo->prepare(context_, params);\n+\t\talgo->prepare(frame, context_, params);\n \n \tIPU3Action op;\n \top.op = ActionParamFilled;\n@@ -620,7 +620,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n \tControlList ctrls(controls::controls);\n \n \tfor (auto const &algo : algorithms_)\n-\t\talgo->process(context_, stats);\n+\t\talgo->process(frame, context_, stats);\n \n \tsetControls(frame);\n \ndiff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\nindex 398d5372..01967f07 100644\n--- a/src/ipa/libipa/algorithm.cpp\n+++ b/src/ipa/libipa/algorithm.cpp\n@@ -48,6 +48,7 @@ namespace ipa {\n /**\n  * \\fn Algorithm::prepare()\n  * \\brief Fill the \\a params buffer with ISP processing parameters for a frame\n+ * \\param[in] frame The frame number\n  * \\param[in] context The shared IPA context\n  * \\param[out] params The ISP specific parameters.\n  *\n@@ -63,6 +64,7 @@ namespace ipa {\n /**\n  * \\fn Algorithm::process()\n  * \\brief Process ISP statistics, and run algorithm operations\n+ * \\param[in] frame The frame number\n  * \\param[in] context The shared IPA context\n  * \\param[in] stats The IPA statistics and ISP results\n  *\ndiff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\nindex 766aee5d..1df93625 100644\n--- a/src/ipa/libipa/algorithm.h\n+++ b/src/ipa/libipa/algorithm.h\n@@ -22,12 +22,14 @@ public:\n \t\treturn 0;\n \t}\n \n-\tvirtual void prepare([[maybe_unused]] Context &context,\n+\tvirtual void prepare([[maybe_unused]] const uint32_t frame,\n+\t\t\t     [[maybe_unused]] Context &context,\n \t\t\t     [[maybe_unused]] Params *params)\n \t{\n \t}\n \n-\tvirtual void process([[maybe_unused]] Context &context,\n+\tvirtual void process([[maybe_unused]] const uint32_t frame,\n+\t\t\t     [[maybe_unused]] Context &context,\n \t\t\t     [[maybe_unused]] const Stats *stats)\n \t{\n \t}\n","prefixes":["libcamera-devel","1/4"]}