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) { }