From patchwork Thu Feb 25 17:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11381 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 99281BD1F1 for ; Thu, 25 Feb 2021 17:01:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20B7468A56; Thu, 25 Feb 2021 18:01:49 +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="DxedQmy4"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 08F7E6040F for ; Thu, 25 Feb 2021 18:01:48 +0100 (CET) Received: by mail-wr1-x42c.google.com with SMTP id 7so5974172wrz.0 for ; Thu, 25 Feb 2021 09:01: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=7kFYrabkLQwEOQ8GxfmBl8oPqftFuK/vgroR+kL72fw=; b=DxedQmy4hpEiKNdPSu3iQoHx+X0sXCuCLh9DBxv/PKn4Yj7rrfU2AOKQT8flbPNHgp LYBW6YjIlAhfzbmNBocbgRciXSa7/hS3hY/CaFEpQLV98jbuVxLOQ1+vjM+xOzhfNDyb l7K72Aj0aHC/IrFIeWZyIeRMYOkz/xhDx1AhuIV582Qtq7LDZBQqQLnoqAeQ2rVFExha HNOq72GQbkB29XdpsHVFZnPofZ0mUmQc/NK6KzgQLHvRYpSlH3hL4N8fuEQCy+1+pD0W jET5+t0GisEbwH6J0poG8VNL5/Ua6UAQtQYx7/h2oNpu1QsXIfqeG77eNzdQiHuIBB+0 Lt4g== 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=7kFYrabkLQwEOQ8GxfmBl8oPqftFuK/vgroR+kL72fw=; b=GkCHGWXejpFAarlLNig2Tmjm40xAq0gZ1y/xgc646OWx1jS6y/va03Ft7/tOp25ATK L9r+h+c1Q7sf/HU5UOWBaxBmcExDeze+P36gkPgp9rX4sqDpXr14aF3NkbL0Nt7Poy6v d3CAblaqgsaXf7vvLRSSh7QMqc6tREYL7BT1zzIv4+6DwLTLzzcMHLgbYeYYQSgJfYji KxF+GELhbuGmh81QjZTK/2hHWQEGJ3Bgp63R0FEIpDf6zCVL+COPOo+Fzxset1gzp/LV d2vPcT68RWXTQGPuN82g4cRX/4+w0FxlICgOrAodD8ayDanS3WVoVN2+VSRkvZ8e3Rpo 8AsQ== X-Gm-Message-State: AOAM530J6RQz5+g0Ak0ixcEcR3AmVpCtS2LlxlMUIp0+xVdg1Yomp59a 64g2pTOg+sihu8E9k1NcLkYw86E19v3yYLsS X-Google-Smtp-Source: ABdhPJz97Cc5f0kZUnASRMS32NjkEYAvNVTVqHeGtAge4OCcwvLJW6AohsDs+3/dg6Ra9W+FGBKmAA== X-Received: by 2002:adf:a703:: with SMTP id c3mr4363247wrd.379.1614272507482; Thu, 25 Feb 2021 09:01:47 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id e3sm1526337wrt.12.2021.02.25.09.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 09:01:46 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Feb 2021 17:01:40 +0000 Message-Id: <20210225170141.5184-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210225170141.5184-1-david.plowman@raspberrypi.com> References: <20210225170141.5184-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] ipa: raspberrypi: AWB: Remove unused code 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" Some more code from pre-libcamera versions is removed. There is no functional change. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/controller/rpi/awb.cpp | 4 +--- src/ipa/raspberrypi/controller/rpi/awb.hpp | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index bb637f10..791a7039 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -21,8 +21,6 @@ LOG_DEFINE_CATEGORY(RPiAwb) #define AWB_STATS_SIZE_X DEFAULT_AWB_REGIONS_X #define AWB_STATS_SIZE_Y DEFAULT_AWB_REGIONS_Y -const double Awb::RGB::INVALID = -1.0; - // todo - the locking in this algorithm needs some tidying up as has been done // elsewhere (ALSC and AGC). @@ -340,7 +338,7 @@ static void generate_stats(std::vector &zones, double min_G) { for (int i = 0; i < AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y; i++) { - Awb::RGB zone; // this is "invalid", unless R gets overwritten later + Awb::RGB zone; double counted = stats[i].counted; if (counted >= min_pixels) { zone.G = stats[i].g_sum / counted; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index 45ba9e25..2fe59c37 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -90,21 +90,16 @@ public: void Prepare(Metadata *image_metadata) override; void Process(StatisticsPtr &stats, Metadata *image_metadata) override; struct RGB { - RGB(double _R = INVALID, double _G = INVALID, - double _B = INVALID) + RGB(double _R = -1.0, double _G = -1.0, double _B = -1.0) : R(_R), G(_G), B(_B) { } double R, G, B; - static const double INVALID; - bool Valid() const { return G != INVALID; } - bool Invalid() const { return G == INVALID; } RGB &operator+=(RGB const &other) { R += other.R, G += other.G, B += other.B; return *this; } - RGB Square() const { return RGB(R * R, G * G, B * B); } }; private: From patchwork Thu Feb 25 17:01:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11382 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 29F51BD1F1 for ; Thu, 25 Feb 2021 17:01:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA7A468A4E; Thu, 25 Feb 2021 18:01: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="i+5N5+CG"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECD7D68A53 for ; Thu, 25 Feb 2021 18:01:48 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id g11so1491342wmh.1 for ; Thu, 25 Feb 2021 09:01: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=jPus3FcP5etJB05ijHlMi7zYjv7msj437AOXSM+Y2Dw=; b=i+5N5+CGRzIHN+4MudmPpDNcggBjnsyJnc2RoSWgqDWHAt76m+WNqnNj+/80Tc8aYT j9VE0YS84mp8wV729BmC+uRSR6T2JdL3EWgr/R19fNkM18YwIP//ciOzuURRr6ORr3Me 6DzrryOOb93PkYOEzefRovs8Lm1gICv74ABAT87IAB6T/v3U8WEO3QWBQo2mFIziQDDp 57+lTCbZSlPSP3vP7XQpDj1HPmXynF/WEH3Fe3SCSEdkd2L8+ujEnUqZXcm0rl+r4DtJ UmHo9ycdgTBQzWFPFCiDK0kKODE7VXke7wz0ENGMwJLLfxA34012SD5kRa0j69OHMQeo sSJQ== 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=jPus3FcP5etJB05ijHlMi7zYjv7msj437AOXSM+Y2Dw=; b=bgniO6+DMV3EQesDFTPiEvy7UxuHwu3QLPCZI/mll4/URYiKbt0wXuAmll5Z+CwXC0 Z3iAfnGSQTAmi+Lpu72qJhqEZyttrQvSO1JFtBBjrbCg9J7xbY/ifl02ULFp0VGm2YU0 7WWn+l57g6ihdst8ZuaXqslBNmZ8VxiUpccZySS6VjTooj0ERuN+zi3I1nryUtA5niff dZbxZczdsc8V1mjS8jxlyMExgEk9/LL/hmgKBR3oLFl7ro6mN/QLg7Ve0zuIHgxAwa4x 9WkhR3kb1MyoCsi499YCAN2qX9ZbiY9A5jpxEBbG8OCmRpHunfAg9hG/bhS/HSiRriGR phtA== X-Gm-Message-State: AOAM532Q7CgcLuKqZq6HtMF2f/p8TF1GuP3xghEFtBCnuNeMdnPXpgGs Sy4cOIlvrjpAwdafWHVbf8qdtGjifm54Q/j8 X-Google-Smtp-Source: ABdhPJwew+emIjPcPrpWUplOiFv1z4VXdh1w15Na+xTBlOHca9NGCj16MRnsRzaLS084r2dclI+hMA== X-Received: by 2002:a1c:1d42:: with SMTP id d63mr4059292wmd.26.1614272508304; Thu, 25 Feb 2021 09:01:48 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id e3sm1526337wrt.12.2021.02.25.09.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 09:01:47 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Feb 2021 17:01:41 +0000 Message-Id: <20210225170141.5184-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210225170141.5184-1-david.plowman@raspberrypi.com> References: <20210225170141.5184-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: AWB: Ignore invalid statistics zones correctly 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" Regions of the image where the statistics are not trusted should not be put in the zones_ list. This also means that the AWB may fail to run initially, so async_results_ needs to be initialised to some kind of default. Finally, the RGB zone structures can be zero-initialised safely now, the previous value of -1 would seem unusual. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/controller/rpi/awb.cpp | 3 ++- src/ipa/raspberrypi/controller/rpi/awb.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index 791a7039..1c917e4f 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -169,6 +169,7 @@ void Awb::Initialise() sync_results_.gain_b = 1.0; } prev_sync_results_ = sync_results_; + async_results_ = sync_results_; } unsigned int Awb::GetConvergenceFrames() const @@ -345,9 +346,9 @@ static void generate_stats(std::vector &zones, if (zone.G >= min_G) { zone.R = stats[i].r_sum / counted; zone.B = stats[i].b_sum / counted; + zones.push_back(zone); } } - zones.push_back(zone); } } diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index 2fe59c37..8af1f27c 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -90,7 +90,7 @@ public: void Prepare(Metadata *image_metadata) override; void Process(StatisticsPtr &stats, Metadata *image_metadata) override; struct RGB { - RGB(double _R = -1.0, double _G = -1.0, double _B = -1.0) + RGB(double _R = 0, double _G = 0, double _B = 0) : R(_R), G(_G), B(_B) { }