From patchwork Mon Feb 8 15:07:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11193 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 396D2BD160 for ; Mon, 8 Feb 2021 15:08:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0607760D2A; Mon, 8 Feb 2021 16:08:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="oynFR6Wy"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC57160D21 for ; Mon, 8 Feb 2021 16:08:10 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id u14so17570041wri.3 for ; Mon, 08 Feb 2021 07:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Eib4zDANaA6JZXba1QgQGfirur2ZBzw8jt8Oj+tjQE=; b=oynFR6WyE3i9iD9IZoL3/6ltKptPrDd7O2jAjXKjMTLLRKc/wenZWisPhtueVR7PKS nkfAgWqwfR9nUbPcada5baf5wzpp0lVupUVV3JA1+AXtJ3CTXXsrLoqtAUoScOOOTeJM i21McJanX2srNt7S3mR8qNKExs6G3gHQBex0DVIzYblUPy5xGLMAT3JDHS3THw0cSbjn GfWrXCPrasFFk70qlk8P3VriBbPZeecQR9IJgZDlNLVtwfWb6CVGmHQVUiXuX3FviHsE 669ar94OfrVulpcPKzCysvl/7AFZ14okM3MQhykZyD+nbKdkYUxd2VX31QDRvz/WpOD3 YnHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Eib4zDANaA6JZXba1QgQGfirur2ZBzw8jt8Oj+tjQE=; b=lB9QPeA0zGXxgtQtyBMSOwkpIeUPYoY3RcTsAOLGgHmjr6oyMVu9WuzmtPPo5ra0bT nN6EmTzkNCpVsGOOfI68RUozQ9I7oKMrPb2jZzRcihr1X1S+DF/d7lTIuXf7soUrLxpZ qTIBSFTr2udLT0DE2wu2YrJGFBw8mb5UX4/jsmAuqq2vq9zMn/Ym/Rg5rQfKWc8CX25O C4mS2pdlwTvaHWb5r/tjvrwzurlpP+WgjLXn8FjJpmF4UXTQeNsmIcQQ9EZfEglo/Tma IxTKdQqEaHhmqASFy1TfP/OEOtX2xTo1yOwKVvRhhTSo3/qGrQ+W+W10/VQdVZRmvdFK UYSA== X-Gm-Message-State: AOAM532YLzorIsVg2T+45X3U121uSGSv5bT54W8JOelivDbcnYgVlxnM +ikHn2ctKANjNk8/y8g83Ktc02sjt7ZwpkUQ X-Google-Smtp-Source: ABdhPJzecF1i7owsGGUyogsWJGt3OhT0zON6NmQok6WaByx8096mcv/fWS6whK1UPDcrcUFpU+GDzw== X-Received: by 2002:adf:d852:: with SMTP id k18mr20688998wrl.262.1612796890416; Mon, 08 Feb 2021 07:08:10 -0800 (PST) Received: from naush-laptop.pitowers.org (cust51-dsl50.idnet.net. [212.69.50.51]) by smtp.gmail.com with ESMTPSA id a17sm31261389wrx.63.2021.02.08.07.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 07:08:09 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Feb 2021 15:07:37 +0000 Message-Id: <20210208150738.2293520-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208150738.2293520-1-naush@raspberrypi.com> References: <20210208150738.2293520-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 5/6] ipa: raspberrypi: Add a DenoiseAlgorithm class to the Controller X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This denoise algorithm class will be used to pass in the user requested denoise operating mode to the controller. The existing Denoise controller will derive from this new DenoiseAlgorithm class. Add a denoise mode field in the denoise status metadata object for the IPA to use when configuring the ISP. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- .../controller/denoise_algorithm.hpp | 23 +++++++++++++++++++ .../raspberrypi/controller/denoise_status.h | 1 + src/ipa/raspberrypi/controller/rpi/sdn.cpp | 11 +++++++-- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 5 +++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/ipa/raspberrypi/controller/denoise_algorithm.hpp diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp new file mode 100644 index 000000000000..39fcd7e94df2 --- /dev/null +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * + * denoise.hpp - Denoise control algorithm interface + */ +#pragma once + +#include "algorithm.hpp" + +namespace RPiController { + +enum class DenoiseMode { Off, ColourOff, ColourFast, ColourHighQuality }; + +class DenoiseAlgorithm : public Algorithm +{ +public: + DenoiseAlgorithm(Controller *controller) : Algorithm(controller) {} + // A Denoise algorithm must provide the following: + virtual void SetMode(DenoiseMode mode) = 0; +}; + +} // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index 94f5df200ffd..4f1ca71e5f5a 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -16,6 +16,7 @@ struct DenoiseStatus { double noise_constant; double noise_slope; double strength; + unsigned int mode; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index ef84a2dcbf86..899a38417695 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * * sdn.cpp - SDN (spatial denoise) control algorithm */ @@ -23,7 +23,7 @@ LOG_DEFINE_CATEGORY(RPiSdn) #define NAME "rpi.sdn" Sdn::Sdn(Controller *controller) - : Algorithm(controller) + : DenoiseAlgorithm(controller), mode_(DenoiseMode::ColourOff) { } @@ -53,6 +53,7 @@ void Sdn::Prepare(Metadata *image_metadata) status.noise_constant = noise_status.noise_constant * deviation_; status.noise_slope = noise_status.noise_slope * deviation_; status.strength = strength_; + status.mode = static_cast>(mode_); image_metadata->Set("sdn.status", status); LOG(RPiSdn, Debug) << "programmed constant " << status.noise_constant @@ -60,6 +61,12 @@ void Sdn::Prepare(Metadata *image_metadata) << " strength " << status.strength; } +void Sdn::SetMode(DenoiseMode mode) +{ + // We only distinguish between off and all other modes. + mode_ = mode; +} + // Register algorithm with the system. static Algorithm *Create(Controller *controller) { diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp index 486c000d7b77..2371ce04163f 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp @@ -7,12 +7,13 @@ #pragma once #include "../algorithm.hpp" +#include "../denoise_algorithm.hpp" namespace RPiController { // Algorithm to calculate correct spatial denoise (SDN) settings. -class Sdn : public Algorithm +class Sdn : public DenoiseAlgorithm { public: Sdn(Controller *controller = NULL); @@ -20,10 +21,12 @@ public: void Read(boost::property_tree::ptree const ¶ms) override; void Initialise() override; void Prepare(Metadata *image_metadata) override; + void SetMode(DenoiseMode mode) override; private: double deviation_; double strength_; + DenoiseMode mode_; }; } // namespace RPiController