From patchwork Fri Jan 22 09:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10949 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 6D650BD808 for ; Fri, 22 Jan 2021 09:25:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C67D68243; Fri, 22 Jan 2021 10:25:51 +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="DT6RU1PP"; 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 89A076823C for ; Fri, 22 Jan 2021 10:25:48 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id b5so4366721wrr.10 for ; Fri, 22 Jan 2021 01:25:48 -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=BTpjYOrcjlceLBb0AKVugpXyOog6QXBLRO6JWmeoLBw=; b=DT6RU1PPvsJPXVuoVIsHIR60t4lNKhrUpRNgQ3IRE3ylpzZDP3we79BvsmLoEasCuo ZfGfmFWZGr5VCxM0ZKgIk/KyjmYXee/xTqjhRyc2H5/mfoHTd6mBOxOwRkuR22AQEuwe MRE8N3vRwCStmVSgJ+Lll1C9+eSXUSvNSi7PsuUqceRLFYEee75BABoo+xf33/X811NW bNxKGjIKzTaaczhPX6bZP1isI8W7zXZo5LFSD67iY+tJQISiU3pXaS+PJA9IrsW9cK0q OqC0yE7BMzDeBKtvg/jp694KaIYfKNcZm1TJ+uKZdhGSWl0w2+2jt6zMwPJgyovdmBbz 6+Qg== 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=BTpjYOrcjlceLBb0AKVugpXyOog6QXBLRO6JWmeoLBw=; b=l8KwazDew36OSa9H49ifdmBbA24f+x4X0Fm5jYa2h/FThSBnET2BiUPcWG/KY7kOdL rSaXmWCLPzMP4k6U9zYOjCMBxMNTttS4sRKiq+HK9n1C80epdlJWYt2V6w8teZ6RUHRV bMCJYA9b3N9QnK73a7VUfSWI65U1RWZvNKHThWj6WkBul4grTs2BuDvVRse6c79+7wg4 WvHfxt7cDcoLom/vGyoRANXwOfrPULNAIYeMOEpZgiojySst7Rqy3khFf31sL69VhyC4 BWQwm1Q+3wPtlPdP4SBfonuJJRi/NpPIpCioDlnCNrm7vJNF7DyYbYqOBj5zcxnt2eAr s/vQ== X-Gm-Message-State: AOAM532caBbwPsXjGglqzh1D878/9ZWbqRwTe2hXy+bRSkb9/v7GqRei IJ37yaR8gNrZJ5CIO2+2yvJBx1EJhk+hzw== X-Google-Smtp-Source: ABdhPJwjqUDb38G1/QlqKCAcWkZbOi05W1mR2uu+0ipkhfOuwX64Q3LkXoHuijSckawSqKMXeAuV8A== X-Received: by 2002:a5d:55c3:: with SMTP id i3mr3505049wrw.190.1611307547988; Fri, 22 Jan 2021 01:25:47 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:47 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:36 +0000 Message-Id: <20210122092537.708375-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 --- .../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..df1f35cc9e5f --- /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 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 06d7cfb91ae8..6064cc2c192e 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 d8c1521a6633..f85a09afb380 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::ColourFast) { } @@ -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("denoise.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