{"id":15371,"url":"https://patchwork.libcamera.org/api/1.1/patches/15371/?format=json","web_url":"https://patchwork.libcamera.org/patch/15371/","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":"<20220223104824.25723-2-jeanmichel.hautbois@ideasonboard.com>","date":"2022-02-23T10:48:21","name":"[libcamera-devel,v2,1/4] ipa: rkisp1: Use frame index","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"69af1059b016cb2db21b9b9c138760108a7e26c0","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15371/mbox/","series":[{"id":2936,"url":"https://patchwork.libcamera.org/api/1.1/series/2936/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2936","date":"2022-02-23T10:48:21","name":"IPA RkISP1 awb and misc improvements","version":2,"mbox":"https://patchwork.libcamera.org/series/2936/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15371/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15371/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 0819DBE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Feb 2022 10:48:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57644610B3;\n\tWed, 23 Feb 2022 11:48:30 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87CDD610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Feb 2022 11:48:28 +0100 (CET)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:7ebc:9e38:c4df:c57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2816D929;\n\tWed, 23 Feb 2022 11:48:28 +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=\"QWE8gAfh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1645613308;\n\tbh=69evzyf5yk0B/1jNYt6LwIOVd8DSoIDQs1knjQtkDu0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QWE8gAfhxk2v8aW9FgcTKLtpsSE0Sx/IjczoexG82RxUaaJzBfQG7CYoP3Jnz+tkn\n\t5/QNXF2HWh2QBGL+wgp6rO1UZkjyjsB9N5ffeSQwxzxtPiUImKBzzlELVm6n4gOkC3\n\t/Hp6e/vobtQs8jziggOkUwqCyd+m4w68RJgtLTKo=","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 23 Feb 2022 11:48:21 +0100","Message-Id":"<20220223104824.25723-2-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20220223104824.25723-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20220223104824.25723-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/4] ipa: rkisp1: Use frame index","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":"Instead of incrementing the frameCount manually in a local counter, use\nthe frame index on the EventStatReay event and store it in a new\nIPAFrameContext variable named frameId.\n\nThe frameId may be used by other algorithms later.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nTested-by: Peter Griffin <peter.griffin@linaro.org>\n---\n src/ipa/rkisp1/algorithms/agc.cpp |  5 ++---\n src/ipa/rkisp1/ipa_context.cpp    |  5 +++++\n src/ipa/rkisp1/ipa_context.h      |  2 ++\n src/ipa/rkisp1/rkisp1.cpp         | 11 +++++------\n 4 files changed, 14 insertions(+), 9 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex dd97afc0..50980835 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -82,8 +82,6 @@ int Agc::configure(IPAContext &context,\n \telse\n \t\tnumCells_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V12;\n \n-\t/* \\todo Use actual frame index by populating it in the frameContext. */\n-\tframeCount_ = 0;\n \treturn 0;\n }\n \n@@ -255,6 +253,8 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats)\n \n \tconst rkisp1_cif_isp_ae_stat *ae = &params->ae;\n \n+\tframeCount_ = context.frameContext.frameId;\n+\n \t/*\n \t * Estimate the gain needed to achieve a relative luminance target. To\n \t * account for non-linearity caused by saturation, the value needs to be\n@@ -278,7 +278,6 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats)\n \t}\n \n \tcomputeExposure(context, yGain);\n-\tframeCount_++;\n }\n \n void Agc::prepare([[maybe_unused]] IPAContext &context,\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex 9cb2a9fd..992c9225 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -113,4 +113,9 @@ namespace libcamera::ipa::rkisp1 {\n  * \\brief Analogue gain multiplier\n  */\n \n+/**\n+ * \\var IPAFrameContext::frameId\n+ * \\brief Frame number for this frame context\n+ */\n+\n } /* namespace libcamera::ipa::rkisp1 */\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex b94ade0c..c447369f 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -43,6 +43,8 @@ struct IPAFrameContext {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n \t} sensor;\n+\n+\tunsigned int frameId;\n };\n \n struct IPAContext {\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 2d79f15f..732ca2bb 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -56,8 +56,7 @@ public:\n private:\n \tvoid queueRequest(unsigned int frame, rkisp1_params_cfg *params,\n \t\t\t  const ControlList &controls);\n-\tvoid updateStatistics(unsigned int frame,\n-\t\t\t      const rkisp1_stat_buffer *stats);\n+\tvoid updateStatistics(const rkisp1_stat_buffer *stats);\n \n \tvoid setControls(unsigned int frame);\n \tvoid metadataReady(unsigned int frame, unsigned int aeState);\n@@ -239,7 +238,6 @@ void IPARkISP1::processEvent(const RkISP1Event &event)\n {\n \tswitch (event.op) {\n \tcase EventSignalStatBuffer: {\n-\t\tunsigned int frame = event.frame;\n \t\tunsigned int bufferId = event.bufferId;\n \n \t\tconst rkisp1_stat_buffer *stats =\n@@ -250,8 +248,9 @@ void IPARkISP1::processEvent(const RkISP1Event &event)\n \t\t\tevent.sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n \t\tcontext_.frameContext.sensor.gain =\n \t\t\tcamHelper_->gain(event.sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n+\t\tcontext_.frameContext.frameId = event.frame;\n \n-\t\tupdateStatistics(frame, stats);\n+\t\tupdateStatistics(stats);\n \t\tbreak;\n \t}\n \tcase EventQueueRequest: {\n@@ -286,10 +285,10 @@ void IPARkISP1::queueRequest(unsigned int frame, rkisp1_params_cfg *params,\n \tqueueFrameAction.emit(frame, op);\n }\n \n-void IPARkISP1::updateStatistics(unsigned int frame,\n-\t\t\t\t const rkisp1_stat_buffer *stats)\n+void IPARkISP1::updateStatistics(const rkisp1_stat_buffer *stats)\n {\n \tunsigned int aeState = 0;\n+\tunsigned int frame = context_.frameContext.frameId;\n \n \tfor (auto const &algo : algorithms_)\n \t\talgo->process(context_, stats);\n","prefixes":["libcamera-devel","v2","1/4"]}