{"id":15439,"url":"https://patchwork.libcamera.org/api/1.1/patches/15439/?format=json","web_url":"https://patchwork.libcamera.org/patch/15439/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220310205130.336361-2-umang.jain@ideasonboard.com>","date":"2022-03-10T20:51:28","name":"[libcamera-devel,1/3] libipa: algorithm: Pass frame number to prepare() and process()","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"6fb15c1553ed2161ea7b951635947a4909330213","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15439/mbox/","series":[{"id":2958,"url":"https://patchwork.libcamera.org/api/1.1/series/2958/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2958","date":"2022-03-10T20:51:27","name":"ipa: ipu3: IPAFrameContext Queue","version":1,"mbox":"https://patchwork.libcamera.org/series/2958/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15439/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15439/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\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 401FBBF415\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tThu, 10 Mar 2022 20:51:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED0BC632E2;\r\n\tThu, 10 Mar 2022 21:51:42 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\r\n\t[213.167.242.64])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35398601F8\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tThu, 10 Mar 2022 21:51:40 +0100 (CET)","from perceval.ideasonboard.com (unknown [103.251.226.203])\r\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 32F90491;\r\n\tThu, 10 Mar 2022 21:51:38 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1646945503;\r\n\tbh=6bRgsnx2Uz4G6N66Zb6iPnZZRza1TY0By0XaUzbovNM=;\r\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\r\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\r\n\tFrom;\r\n\tb=13rqmajSCDWAhoZ244LNLJ8l98x1noP9jM8Dlrzo1sX14+IYFhiRV+w9Bw7db3p/O\r\n\t7hg2V8CiQ912xylzaHx8uDy01vmkarrZBIc6bVUIQyqjxDRMQvjq6NCQAV+BxMAoEr\r\n\tUgkFxiCSDqRr+buig9wrph8Pnh2yoNCA7U5VfBbDky5QMfVOwEqtf/5kQYhCOFCth6\r\n\tswYxAqj1bdYnilRC022rxQykyYmFVq/zBabLeSlizKde8QS03xF7sNwb/Ver3mVDE3\r\n\tNOIKVCtyeOK7lhLqdoIYNKBMn8CUkl3ZVztlyIynEAAfy2+c3+Bi+RjRH6V1lzpHoC\r\n\tS5c9enxvdbLTQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\r\n\ts=mail; t=1646945500;\r\n\tbh=6bRgsnx2Uz4G6N66Zb6iPnZZRza1TY0By0XaUzbovNM=;\r\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\r\n\tb=d6kytAAyTtUHU3yEc9TjdDPJ4vTo1i0uonZqmXc7RQCYnGq8/XNJnMzLfvtLUz8zY\r\n\tbaC2dTuuH1t1OrfKYVaLQwOIZFe0WFem26hR5b0eFsZfWMheqGtmGHwg1NPstKV9Gw\r\n\txXxccpPmxxkdA52Ewqpe2ff4PF2BHTBUDfTpH3zI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \r\n\tunprotected) header.d=ideasonboard.com\r\n\theader.i=@ideasonboard.com\r\n\theader.b=\"d6kytAAy\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 11 Mar 2022 02:21:28 +0530","Message-Id":"<20220310205130.336361-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20220310205130.336361-1-umang.jain@ideasonboard.com>","References":"<20220310205130.336361-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/3] libipa: algorithm: Pass frame number\r\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>,\r\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>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","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\r\nindex 1eb1bcef..cdc1327a 100644\r\n--- a/src/ipa/ipu3/algorithms/agc.cpp\r\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\r\n@@ -315,13 +315,14 @@ double Agc::estimateLuminance(IPAFrameContext &frameContext,\r\n \r\n /**\r\n  * \\brief Process IPU3 statistics, and run AGC operations\r\n+ * \\param frame The frame number\r\n  * \\param[in] context The shared IPA context\r\n  * \\param[in] stats The IPU3 statistics and ISP results\r\n  *\r\n  * Identify the current image brightness, and use that to estimate the optimal\r\n  * new exposure and gain for the scene.\r\n  */\r\n-void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n+void Agc::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n {\r\n \t/*\r\n \t * Estimate the gain needed to have the proportion of pixels in a given\r\ndiff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\r\nindex ad705605..e48506e5 100644\r\n--- a/src/ipa/ipu3/algorithms/agc.h\r\n+++ b/src/ipa/ipu3/algorithms/agc.h\r\n@@ -28,7 +28,7 @@ public:\r\n \t~Agc() = default;\r\n \r\n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\r\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n \r\n private:\r\n \tdouble measureBrightness(const ipu3_uapi_stats_3a *stats,\r\ndiff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\r\nindex dc25be81..f1e753e6 100644\r\n--- a/src/ipa/ipu3/algorithms/awb.cpp\r\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\r\n@@ -387,7 +387,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\r\n /**\r\n  * \\copydoc libcamera::ipa::Algorithm::process\r\n  */\r\n-void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n+void Awb::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n {\r\n \tcalculateWBGains(stats);\r\n \r\n@@ -411,7 +411,7 @@ constexpr uint16_t Awb::threshold(float value)\r\n /**\r\n  * \\copydoc libcamera::ipa::Algorithm::prepare\r\n  */\r\n-void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\r\n+void Awb::prepare([[maybe_unused]] const uint32_t frame, IPAContext &context, ipu3_uapi_params *params)\r\n {\r\n \t/*\r\n \t * Green saturation thresholds are reduced because we are using the\r\ndiff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\r\nindex ab4b0a33..ef177a4a 100644\r\n--- a/src/ipa/ipu3/algorithms/awb.h\r\n+++ b/src/ipa/ipu3/algorithms/awb.h\r\n@@ -39,8 +39,8 @@ public:\r\n \t~Awb();\r\n \r\n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\r\n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\r\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\r\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n \r\n private:\r\n \t/* \\todo Make these structs available to all the ISPs ? */\r\ndiff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp\r\nindex 78ab7bff..e9b4bed8 100644\r\n--- a/src/ipa/ipu3/algorithms/blc.cpp\r\n+++ b/src/ipa/ipu3/algorithms/blc.cpp\r\n@@ -38,14 +38,16 @@ BlackLevelCorrection::BlackLevelCorrection()\r\n \r\n /**\r\n  * \\brief Fill in the parameter structure, and enable black level correction\r\n+ * \\param frame The frame number\r\n  * \\param context The shared IPA context\r\n  * \\param params The IPU3 parameters\r\n  *\r\n  * Populate the IPU3 parameter structure with the correction values for each\r\n  * channel and enable the corresponding ImgU block processing.\r\n  */\r\n-void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\r\n-\t\t\t      ipu3_uapi_params *params)\r\n+void BlackLevelCorrection::prepare([[maybe_unused]] const uint32_t frame,\r\n+\t\t\t\t   [[maybe_unused]] IPAContext &context,\r\n+\t\t\t\t   ipu3_uapi_params *params)\r\n {\r\n \t/*\r\n \t * The Optical Black Level correction values\r\ndiff --git a/src/ipa/ipu3/algorithms/blc.h b/src/ipa/ipu3/algorithms/blc.h\r\nindex d8da1748..e4c22070 100644\r\n--- a/src/ipa/ipu3/algorithms/blc.h\r\n+++ b/src/ipa/ipu3/algorithms/blc.h\r\n@@ -18,7 +18,7 @@ class BlackLevelCorrection : public Algorithm\r\n public:\r\n \tBlackLevelCorrection();\r\n \r\n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\r\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\r\n };\r\n \r\n } /* namespace ipa::ipu3::algorithms */\r\ndiff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp\r\nindex 2040eda5..bba5bc9a 100644\r\n--- a/src/ipa/ipu3/algorithms/tone_mapping.cpp\r\n+++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp\r\n@@ -49,13 +49,15 @@ int ToneMapping::configure(IPAContext &context,\r\n \r\n /**\r\n  * \\brief Fill in the parameter structure, and enable gamma control\r\n+ * \\param frame The frame number\r\n  * \\param context The shared IPA context\r\n  * \\param params The IPU3 parameters\r\n  *\r\n  * Populate the IPU3 parameter structure with our tone mapping look up table and\r\n  * enable the gamma control module in the processing blocks.\r\n  */\r\n-void ToneMapping::prepare([[maybe_unused]] IPAContext &context,\r\n+void ToneMapping::prepare([[maybe_unused]] const uint32_t frame,\r\n+\t\t\t  [[maybe_unused]] IPAContext &context,\r\n \t\t\t  ipu3_uapi_params *params)\r\n {\r\n \t/* Copy the calculated LUT into the parameters buffer. */\r\n@@ -71,13 +73,14 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,\r\n \r\n /**\r\n  * \\brief Calculate the tone mapping look up table\r\n+ * \\param frame The frame number\r\n  * \\param context The shared IPA context\r\n  * \\param stats The IPU3 statistics and ISP results\r\n  *\r\n  * The tone mapping look up table is generated as an inverse power curve from\r\n  * our gamma setting.\r\n  */\r\n-void ToneMapping::process(IPAContext &context,\r\n+void ToneMapping::process(const uint32_t frame, IPAContext &context,\r\n \t\t\t  [[maybe_unused]] const ipu3_uapi_stats_3a *stats)\r\n {\r\n \t/*\r\ndiff --git a/src/ipa/ipu3/algorithms/tone_mapping.h b/src/ipa/ipu3/algorithms/tone_mapping.h\r\nindex b727ab1e..041c9c0d 100644\r\n--- a/src/ipa/ipu3/algorithms/tone_mapping.h\r\n+++ b/src/ipa/ipu3/algorithms/tone_mapping.h\r\n@@ -19,8 +19,8 @@ public:\r\n \tToneMapping();\r\n \r\n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\r\n-\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\r\n-\tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n+\tvoid prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;\r\n+\tvoid process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\r\n \r\n private:\r\n \tdouble gamma_;\r\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\r\nindex 8f079588..81788b9a 100644\r\n--- a/src/ipa/ipu3/ipu3.cpp\r\n+++ b/src/ipa/ipu3/ipu3.cpp\r\n@@ -573,7 +573,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\r\n \tparams->use = {};\r\n \r\n \tfor (auto const &algo : algorithms_)\r\n-\t\talgo->prepare(context_, params);\r\n+\t\talgo->prepare(frame, context_, params);\r\n \r\n \tparamsBufferReady.emit(frame);\r\n }\r\n@@ -597,7 +597,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\r\n \tControlList ctrls(controls::controls);\r\n \r\n \tfor (auto const &algo : algorithms_)\r\n-\t\talgo->process(context_, stats);\r\n+\t\talgo->process(frame, context_, stats);\r\n \r\n \tsetControls(frame);\r\n \r\ndiff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\r\nindex 398d5372..01967f07 100644\r\n--- a/src/ipa/libipa/algorithm.cpp\r\n+++ b/src/ipa/libipa/algorithm.cpp\r\n@@ -48,6 +48,7 @@ namespace ipa {\r\n /**\r\n  * \\fn Algorithm::prepare()\r\n  * \\brief Fill the \\a params buffer with ISP processing parameters for a frame\r\n+ * \\param[in] frame The frame number\r\n  * \\param[in] context The shared IPA context\r\n  * \\param[out] params The ISP specific parameters.\r\n  *\r\n@@ -63,6 +64,7 @@ namespace ipa {\r\n /**\r\n  * \\fn Algorithm::process()\r\n  * \\brief Process ISP statistics, and run algorithm operations\r\n+ * \\param[in] frame The frame number\r\n  * \\param[in] context The shared IPA context\r\n  * \\param[in] stats The IPA statistics and ISP results\r\n  *\r\ndiff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\r\nindex 766aee5d..1df93625 100644\r\n--- a/src/ipa/libipa/algorithm.h\r\n+++ b/src/ipa/libipa/algorithm.h\r\n@@ -22,12 +22,14 @@ public:\r\n \t\treturn 0;\r\n \t}\r\n \r\n-\tvirtual void prepare([[maybe_unused]] Context &context,\r\n+\tvirtual void prepare([[maybe_unused]] const uint32_t frame,\r\n+\t\t\t     [[maybe_unused]] Context &context,\r\n \t\t\t     [[maybe_unused]] Params *params)\r\n \t{\r\n \t}\r\n \r\n-\tvirtual void process([[maybe_unused]] Context &context,\r\n+\tvirtual void process([[maybe_unused]] const uint32_t frame,\r\n+\t\t\t     [[maybe_unused]] Context &context,\r\n \t\t\t     [[maybe_unused]] const Stats *stats)\r\n \t{\r\n \t}","prefixes":["libcamera-devel","1/3"]}