From patchwork Fri Oct 6 13:19:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19112 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 B3CC8C32BC for ; Fri, 6 Oct 2023 13:20:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5BB5762984; Fri, 6 Oct 2023 15:20:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1696598411; bh=0ZtfABh258FbGqVnIeOpFRQbTFa6M03BetqktijCdQc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xMrgbCYdjp8c/fBVdgjBrSTsTEXmQ1icgW7O2XC/SuVXnjmhYQd/fyZChesIU9tWG wR7CrWDsurhuy40C+Nxhj15LvXHWYqoxZXOZGoj62H2LUdVYcknR2ah4/T1qPS2f6z oDE7JLEgMx7eckCVYstk9W+2oUH1JZAieeWbLG6IddloToe96Qg+Zv4N8d7kkMklHC WzTxzl7KV4xMCa/T79U6IPwxTPsOOQLuSNydA8TW3yUw+bXDy9WSO2RmKwuWVPbO5S 3AANQ1WWIsRdNDsQ3K8mj3M50cBsutuxr2vRw9FAYWiGqR2uMNcj3mphutWVSYK6SI 0nstARljuz7Xw== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D69A16296F for ; Fri, 6 Oct 2023 15:20:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OhINF8/D"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-406609df1a6so19907235e9.3 for ; Fri, 06 Oct 2023 06:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1696598409; x=1697203209; 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=TDelLhgOpWpnzQB5HzYn4kSIXqsCbLcSZC/V78W+NJ0=; b=OhINF8/DVKp4/j2JY7qSC31wvZOEtJbyfahhHuTQKsWWMqwxUVx2XqS9kKZ7XOlCA0 AoyZ8jpukMDo/60MvdGkB9Vp5Lzml5RyKeuWcw2zVAQIxnEFnUJgbt9kEG3DGKqGLNsO gEksUpkWLFO976ZHQlqnpb5uaMyXxsi1bzBLl97F61GixY5ncK4u2cGvHp7mfixJNdTs ZAAdzfNwlccjvoGrGSK8HVmMrC9/FT7fjIJjYD3cGKoX6wTZRL2CTTl6Sjv4mhMtdZtP R26XG7TM6kLXDGKZnlWEh04wZxO7d+vbHKTJ7wL0Xxbe85wMPhUfF4sN6fQu/juQ07/U OXzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598409; x=1697203209; 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=TDelLhgOpWpnzQB5HzYn4kSIXqsCbLcSZC/V78W+NJ0=; b=ve9x28WesbxdhOtQV43AD9lpcDkh1sFRPzvdVp2tMTRNtVtytNIoKESKKw6OK9Jhlv r59W8dd8DETSzoUJfPZJ1ZKsUE6ywhuV252YReQNGmOpx1xbyWH894dPY4vW5E+rHC27 C/SGfXVLIMT613dwjHo9DxD4dd5WzfTUHLZRTF1reXLJ4TWUZ4p9LNjmVl1j6rrEi14N LKXZZvBCYh5ZAV+DFfhcfX/CV74iF6WNih+7s5n5PVQH9+gKzL3hQwL4REL38d0GDr9z E8ujHpAiT5APK1hT5Bn1Wi9iotmmWfV69IySQzgjOMW10TzIzaxkfp/JMXldgQ2YQgTF brWg== X-Gm-Message-State: AOJu0Yz9ugOheLmGIF18U87hgiwOyghcZOzXL0IRqzKQKL/M3Uc+oyOO lCuTVEQGeJm0zMuUhxbaXa4e2KxCR82tI5OFEGXdcQ== X-Google-Smtp-Source: AGHT+IHXAGvX7xx8RyD+227KhqGNxcJ2e2uewsJpXTd7Rt+BGgLy4FMAlbwSEgVQuaN24KUAAtLpUQ== X-Received: by 2002:a05:600c:21d0:b0:405:3a3b:2aa2 with SMTP id x16-20020a05600c21d000b004053a3b2aa2mr7312275wmj.37.1696598408181; Fri, 06 Oct 2023 06:20:08 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m8-20020a056000180800b00321773bb933sm1639478wrh.77.2023.10.06.06.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:20:07 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Oct 2023 14:19:50 +0100 Message-Id: <20231006132000.23504-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231006132000.23504-1-naush@raspberrypi.com> References: <20231006132000.23504-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 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.