From patchwork Wed Jan 20 08:34:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10908 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 26C61C0F2B for ; Wed, 20 Jan 2021 08:35:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB26568186; Wed, 20 Jan 2021 09:35:01 +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="hyHbz7Kb"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 240C368181 for ; Wed, 20 Jan 2021 09:34:59 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id y187so2031160wmd.3 for ; Wed, 20 Jan 2021 00:34:59 -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=iQ91Dj6nDbxti4/IPz0u4olicXcOg/0dvJWfHEwzSnk=; b=hyHbz7KbPPIyVC45GOTeZ7PJxsCiWB6h7f5eGs6pN43jI9AWMtwyHmTUiCRYMK/RHY eBAHJJWaEDtM8a9EVvwzHE46ZF2Jmv2z8I383Fi7I38IMBD2QpeulNb9RV8ulhr9KY39 B4ruwZyqYKA7kBpA7iSJ3MkkJqsMpUCEgoyJrMngo933llR6xalA8PBApEF6WzbFw6pg /DmyvOkyfqsVMeJ/c/aHpL1Lm0An02D+Qj9fuVaWEK6XUYHQ0FKp2AAK+m6aC2ttkgIX RO0rOcf8hNQpEvuCfFZY3e/b4N44Erdnk/aljVeKPyh3wD8czQQ0KSDlX7cYtJ61J9Lt VBuQ== 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=iQ91Dj6nDbxti4/IPz0u4olicXcOg/0dvJWfHEwzSnk=; b=fhQWZK0fxQ/TF5oIFnC357KDjizVJWWQlaYK1dizmpjC5H3/LRH8qxOsy5K51jlSvm JZ7tSP4lq0zfM8UG9MXmAvfPzFJ2A7UYCb0yw4f0EI/1WoTcmo9VI5VOeJb/Lzpolf4l Eq447aDo9bqEh9sZWRpnDWgYGTAMtWvf1GH+uXCnboBTyg3rFdvD+wz1kX8BCYVPmquw UKcjt+CV1p9z0+Zt5fmVBWZz5l+PY1KLTgqcUKFY1QOMbWi0/f9s8LdOnJ4Ei2rJmv+M QcGinGWZItb3MylbS7V15oFvnhTDnV2KHgNA7adl83vXb8XAZUxSh4P6rrRFo6yJ0pkj jDqQ== X-Gm-Message-State: AOAM533epRU6u7pTyZMrdkz8BVWg3txlLLFXRGQoxDSVPDsbs6qF5Nv2 JUVC+P/Yj6/P2/3WoTXCnjUNf7H8SyONrg== X-Google-Smtp-Source: ABdhPJyVuiOrGvZ4oyMAp8RNK+EliQPSw/cv0sqYGUHYA3wNTLlv1UGd2Hg7JK9ulz15XI6QvlB0Gw== X-Received: by 2002:a1c:8095:: with SMTP id b143mr3121604wmd.71.1611131698550; Wed, 20 Jan 2021 00:34:58 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id 33sm2809284wrn.35.2021.01.20.00.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 00:34:57 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Jan 2021 08:34:48 +0000 Message-Id: <20210120083449.642418-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120083449.642418-1-naush@raspberrypi.com> References: <20210120083449.642418-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] 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 --- .../controller/denoise_algorithm.hpp | 23 +++++++++++++++++++ src/ipa/raspberrypi/controller/rpi/sdn.cpp | 11 +++++++-- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 5 +++- src/ipa/raspberrypi/controller/sdn_status.h | 1 + 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..05b7d46dad85 --- /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 (spatial and colour) control algorithm interface + */ +#pragma once + +#include "algorithm.hpp" + +namespace RPiController { + +enum DenoiseMode { Off, Fast, HighQuality }; + +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/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index aa82830b02b4..3a600e07b2f3 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 */ @@ -18,7 +18,7 @@ using namespace RPiController; #define NAME "rpi.sdn" Sdn::Sdn(Controller *controller) - : Algorithm(controller) + : DenoiseAlgorithm(controller), mode_(DenoiseMode::Fast) { } @@ -48,6 +48,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 = mode_; image_metadata->Set("sdn.status", status); RPI_LOG("Sdn: programmed constant " << status.noise_constant << " slope " << status.noise_slope @@ -55,6 +56,12 @@ void Sdn::Prepare(Metadata *image_metadata) << 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 diff --git a/src/ipa/raspberrypi/controller/sdn_status.h b/src/ipa/raspberrypi/controller/sdn_status.h index 871e0b62af1f..29f2a68aabff 100644 --- a/src/ipa/raspberrypi/controller/sdn_status.h +++ b/src/ipa/raspberrypi/controller/sdn_status.h @@ -16,6 +16,7 @@ struct SdnStatus { double noise_constant; double noise_slope; double strength; + unsigned int mode; }; #ifdef __cplusplus