From patchwork Fri Oct 13 07:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19134 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 90A9CC3274 for ; Fri, 13 Oct 2023 07:49:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38B4B629AB; Fri, 13 Oct 2023 09:49:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183342; bh=tp/MwLhP6gZ1z/A6Ll2u9PkxFUFlzobD3MPo84nfCtg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=cLkm0GLBt+jQwNDfZKOCqU113O37TKOFnXUQmeJUmbaucjs6yVoOQdjDPr+3bkNGt N3sHAB/q2nnL0bIkKssJUGGbO4vgvS+iaRBx5vRwcNk++az1XZDyWtF08m3MblRBiZ bXXScOb1i3SWCkjnjoaBg8WZD5ojxbAC4WbALBQoYP18qEMmARlRaMspIgrPS1Vh61 YjaKbNDOZD7cUg5GtIpDMdU8PIpQJ8K1kuu2N4RTf28YcjkdWLISn8XVu8PSayXUI1 BbGk1pXU+FbU6psrijCuQfxFJTnwyTGIB7rPRvjjHk4spXOuB0JPvrnI/poVil5EhB 4sRaJm4g+iayw== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 304C362991 for ; Fri, 13 Oct 2023 09:48:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dQNaEGxL"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40666aa674fso18810165e9.0 for ; Fri, 13 Oct 2023 00:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697183333; x=1697788133; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1uiXMJfgz2P+0kPDj41SLrSF7nj0Ja1wBeD8+vQd89M=; b=dQNaEGxLBNMGFmLAqGNd7wrkJQ/PnBN6nSf3O4lzs8RwrtCIyD0Re3GHK1TvFlg+5r FGcGL7OMDh2TcgA16BnvVSYjAhttz2sZWPA9MSKq2uvIHHSssZ5k98LmLVZp8zuMQKBn eo2M/AmfIZti6jFshkvAGNFC5iOIaV4EQ9N7qrhYLV3ZkoTGLk3bK6uuckQcU2JXNagp Ep+F5SiEM7IM/wMPRnakGV6/zwzlwAmBOvqs05LtQVi3Mj7qrOEJSM39dDNE4OJFVhDw /Uu3HYF4HlaPtS2ekLLeaF5VyC01QaThYxWkqBnzWfH+NSDTUCguuuC35MgWsxUdAeCu 0Lnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183333; x=1697788133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1uiXMJfgz2P+0kPDj41SLrSF7nj0Ja1wBeD8+vQd89M=; b=Px88crImV5Vdba70E174bqV5GxwpqCgFjwY1Y1hMKLCa+EErayZruiOMjMFpiei8J+ 6C6XeSj+w0DjArFdPZ2pZxcYeZPJ2ZsWxeUThFaBQ5c24s1PoUTP5JlCKqv8cPsJvAqO sbj1syx7XSqYbw7zmNhRrXeFo4rbi3npYPQJcUvPwlLI4BLdSyGu87cB1xPaBgnwxZuo XxYkoMJo/vo3EFmw/gM4wysjEInsggKO6cOWCyoqOq6iypzQTKv5btkjUNrC/nxGQMPi ylDi7aCibQ8wC97Dc3gqbx0vNsMH3f1widzMPbTfzlHUQvWd0KHPtWSh5I+8cxpxtj+v 81Fw== X-Gm-Message-State: AOJu0Ywexn0oybOCKo/WiNMWUQkBTcV/HUTuDO4kL0xwzz2+FosbbhcT c4EtLRJHUknGAs/I6HF6K3T3t3giszp39A3H1RyE1g== X-Google-Smtp-Source: AGHT+IEV6TSzJEQsjfX8UMMPZu0hqnM2Z763yppl3EwmdFTMwQ4AtfzoQfrcUmvkmR3cIbVFKXg9+g== X-Received: by 2002:a05:600c:2146:b0:401:daf2:2735 with SMTP id v6-20020a05600c214600b00401daf22735mr21997420wml.31.1697183333548; Fri, 13 Oct 2023 00:48:53 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:48:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Oct 2023 08:48:31 +0100 Message-Id: <20231013074841.16972-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013074841.16972-1-naush@raspberrypi.com> References: <20231013074841.16972-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/20] ipa: rpi: Prepare AWB for PiSP support 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Prepare the AWB algorithm to support the PiSP hardware. The key change is to factor in the LS correction in the AWB zone statistics. This is different from VC4 where the LS correction happens before statistics gathering. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi --- src/ipa/rpi/controller/rpi/awb.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp index ef3435d66106..5ae0c2fad6e9 100644 --- a/src/ipa/rpi/controller/rpi/awb.cpp +++ b/src/ipa/rpi/controller/rpi/awb.cpp @@ -12,6 +12,7 @@ #include "../lux_status.h" +#include "alsc_status.h" #include "awb.h" using namespace RPiController; @@ -398,18 +399,28 @@ void Awb::asyncFunc() } static void generateStats(std::vector &zones, - RgbyRegions &stats, double minPixels, - double minG) + StatisticsPtr &stats, double minPixels, + double minG, Metadata &globalMetadata) { - for (auto const ®ion : stats) { + std::scoped_lock l(globalMetadata); + + for (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) { Awb::RGB zone; + auto ®ion = stats->awbRegions.get(i); if (region.counted >= minPixels) { zone.G = region.val.gSum / region.counted; - if (zone.G >= minG) { - zone.R = region.val.rSum / region.counted; - zone.B = region.val.bSum / region.counted; - zones.push_back(zone); + if (zone.G < minG) + continue; + zone.R = region.val.rSum / region.counted; + zone.B = region.val.bSum / region.counted; + /* Factor in the ALSC applied colour shading correction if required. */ + const AlscStatus *alscStatus = globalMetadata.getLocked("alsc.status"); + if (stats->colourStatsPos == Statistics::ColourStatsPos::PreLsc && alscStatus) { + zone.R *= alscStatus->r[i]; + zone.G *= alscStatus->g[i]; + zone.B *= alscStatus->b[i]; } + zones.push_back(zone); } } } @@ -421,8 +432,8 @@ void Awb::prepareStats() * LSC has already been applied to the stats in this pipeline, so stop * any LSC compensation. We also ignore config_.fast in this version. */ - generateStats(zones_, statistics_->awbRegions, config_.minPixels, - config_.minG); + generateStats(zones_, statistics_, config_.minPixels, + config_.minG, getGlobalMetadata()); /* * apply sensitivities, so values appear to come from our "canonical" * sensor.