{"id":10603,"url":"https://patchwork.libcamera.org/api/patches/10603/?format=json","web_url":"https://patchwork.libcamera.org/patch/10603/","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":"<20201207180121.6374-7-david.plowman@raspberrypi.com>","date":"2020-12-07T18:01:21","name":"[libcamera-devel,v2,6/6] src: ipa: raspberrypi: Move initial frame drop decision to AGC/AWB","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6d80a45dfa1c53ef485269769e0d5968c3c6f353","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10603/mbox/","series":[{"id":1511,"url":"https://patchwork.libcamera.org/api/series/1511/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1511","date":"2020-12-07T18:01:15","name":"Raspberry Pi AGC: initial frame drop count","version":2,"mbox":"https://patchwork.libcamera.org/series/1511/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10603/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10603/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 822D0BDB1F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Dec 2020 18:02:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A64967E6E;\n\tMon,  7 Dec 2020 19:02:39 +0100 (CET)","from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com\n\t[IPv6:2a00:1450:4864:20::62d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A755267E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Dec 2020 19:02:37 +0100 (CET)","by mail-ej1-x62d.google.com with SMTP id x16so20769098ejj.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Dec 2020 10:02:37 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tbe6sm14657977edb.29.2020.12.07.10.02.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Dec 2020 10:02:33 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"qVGZKTh1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=GUZ3CHBFUgzFpk0zl/qO1zEra+JQmulzfklWh6O0kWA=;\n\tb=qVGZKTh1bHWtkAskB52Urx6XmpZVMzyIQRMzXEutZof/FohfyBkFGJjNcjNFCnCyTV\n\tp9COUlaggoru19ZVYUobSsI7xw+2KtODv5BUQEw7Yiz6V/6r9plcJWjpf09Qz2szhVsF\n\tyQbpmS8yLMFufggcuWF2BekcZrZGdANzDmv+0BYBTRMiyxEOxSbhZ524U+VYym15Bigo\n\t1WhgccuWXu9/2BKKyC8eX4eccRhXs+pR+WebXxuKPVqr637ljEGHuMoZ2u7AeUrUVphL\n\tLlR+jkX9kuFGnQINpspaehRvoET3Gy/fHIge2MPHwGjMqYi6n8IEfu8NUPzkR5UP3nzI\n\tCtXQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=GUZ3CHBFUgzFpk0zl/qO1zEra+JQmulzfklWh6O0kWA=;\n\tb=Aedy00ZUfnqLOn63CCMj3i3MZ2x94E5c5IR7GQZfjYv7dwKi36QuH9pT1MnshXKs/D\n\tr1J4231KeNsKs/58R+0LlIzjr8f7DMRsViABObYUBcXhqP2tXfwOVVFHD+JiLvyWZa4+\n\tsd9gPYiCFTQwaq0+6u4FXfxBJqWFj/ceISZTZuXN3pJaatAu12cuqcnJXHty+HUR/7ey\n\tajTu86LESoCVaQLcGDV0QdwOrPgy/aN7v48PTQbdMIkoXqx3e9hsOyiEe3kyCI4q9e9p\n\tN5ktsL+APfhB1A6PRivUaQ+smSEZaaL+F/8cyMNCkFYqqwrv8M/MXjPe0RoWX5uX5qNP\n\tEKAA==","X-Gm-Message-State":"AOAM5330ViDEsUDC1x7f9mhsBCGxoOl5tndGkAVgJlvqLHZ+rnOwkfn5\n\tagxk+mZQbaQ4S5XJ3jBT9r9L0B84HVeia2Ow","X-Google-Smtp-Source":"ABdhPJzoomxM7azf4Zk4JbyXW9YHCosPP+nQ/QyKFnZirw9pxmUIrJTxWRmVEpJD4pYNm57e7BTpkQ==","X-Received":"by 2002:a17:906:c20f:: with SMTP id\n\td15mr19828842ejz.341.1607364156876; \n\tMon, 07 Dec 2020 10:02:36 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  7 Dec 2020 18:01:21 +0000","Message-Id":"<20201207180121.6374-7-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20201207180121.6374-1-david.plowman@raspberrypi.com>","References":"<20201207180121.6374-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 6/6] src: ipa: raspberrypi: Move\n\tinitial frame drop decision to AGC/AWB","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Previously the CamHelper was returning the number of frames to drop\n(on account of AGC/AWB converging). This wasn't really appropriate,\nit's better for the algorithms to do it as they know how many frames\nthey might need.\n\nThe CamHelper::HideFramesStartup method should now just be returning\nthe number of frames to hide because they're bad/invalid in some way,\nnot worrying about the AGC/AWB. For many sensors, the correct value\nfor this is zero. But the ov5647 needs updating as it must return 2.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/cam_helper.cpp        |  6 +++---\n src/ipa/raspberrypi/cam_helper_ov5647.cpp | 10 ++++++++++\n src/ipa/raspberrypi/raspberrypi.cpp       | 16 ++++++++++++++++\n 3 files changed, 29 insertions(+), 3 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\nindex c8ac3232..6efa0d7f 100644\n--- a/src/ipa/raspberrypi/cam_helper.cpp\n+++ b/src/ipa/raspberrypi/cam_helper.cpp\n@@ -82,10 +82,10 @@ bool CamHelper::SensorEmbeddedDataPresent() const\n unsigned int CamHelper::HideFramesStartup() const\n {\n \t/*\n-\t * By default, hide 6 frames completely at start-up while AGC etc. sort\n-\t * themselves out (converge).\n+\t * The number of frames when a camera first starts that shouldn't be\n+\t * displayed as they are invalid in some way.\n \t */\n-\treturn 6;\n+\treturn 0;\n }\n \n unsigned int CamHelper::HideFramesModeSwitch() const\ndiff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\nindex dc5d8275..0b841cd1 100644\n--- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n@@ -19,6 +19,7 @@ public:\n \tuint32_t GainCode(double gain) const override;\n \tdouble Gain(uint32_t gain_code) const override;\n \tvoid GetDelays(int &exposure_delay, int &gain_delay) const override;\n+\tunsigned int HideFramesStartup() const override;\n \tunsigned int HideFramesModeSwitch() const override;\n \tunsigned int MistrustFramesStartup() const override;\n \tunsigned int MistrustFramesModeSwitch() const override;\n@@ -54,6 +55,15 @@ void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay) const\n \tgain_delay = 2;\n }\n \n+unsigned int CamHelperOv5647::HideFramesStartup() const\n+{\n+\t/*\n+\t * On startup, we get a couple of under-exposed frames which\n+\t * we don't want shown.\n+\t */\n+\treturn 2;\n+}\n+\n unsigned int CamHelperOv5647::HideFramesModeSwitch() const\n {\n \t/*\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0e89af00..da92e492 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -193,6 +193,22 @@ int IPARPi::start(const IPAOperationData &ipaConfig, IPAOperationData *result)\n \tif (firstStart_) {\n \t\tdropFrame = helper_->HideFramesStartup();\n \t\tmistrustCount_ = helper_->MistrustFramesStartup();\n+\n+\t\t/* The AGC and/or AWB algorithms may want us to drop more frames. */\n+\t\tunsigned int convergence_frames = 0;\n+\t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n+\t\t\tcontroller_.GetAlgorithm(\"agc\"));\n+\t\tif (agc)\n+\t\t\tconvergence_frames = agc->GetConvergenceFrames(mistrustCount_);\n+\n+\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n+\t\t\tcontroller_.GetAlgorithm(\"awb\"));\n+\t\tif (awb)\n+\t\t\tconvergence_frames = std::max(convergence_frames,\n+\t\t\t\t\t\t      awb->GetConvergenceFrames(mistrustCount_));\n+\n+\t\tdropFrame = std::max(dropFrame, convergence_frames);\n+\t\tLOG(IPARPI, Debug) << \"Drop \" << dropFrame << \" frames on startup\";\n \t} else {\n \t\tdropFrame = helper_->HideFramesModeSwitch();\n \t\tmistrustCount_ = helper_->MistrustFramesModeSwitch();\n","prefixes":["libcamera-devel","v2","6/6"]}