From patchwork Fri Oct 13 07:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19133 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 59CEEC32BC for ; Fri, 13 Oct 2023 07:49:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8808362992; Fri, 13 Oct 2023 09:49:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183340; bh=Jjo/F25/0Dv7zcg7UHN1vZt7o6yjnm8ekVoHAswsCJA=; 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=O3ug6L9750ao9wlgp+WeSoC3NgcJPZ6vaXIM4M375UD0/iMC9p0c+SeArXtmVK4Pu vAU+bw149+sioVmj+sCuVEdD4WoUevjt/qAau5calpXp7k/BshJu/mdPrF60OJKUiy FOSTDonB2sx0uLXmaIVJ1Hh7TB91rqbdnEAbLjyepqvlvc66bA6Wc2N1KpFO5XoJau sXKQw9HnA+DtceEnqEWfvaZXAL5eZN/ggCHprsyHZDw0igkAGt54xp2I7yvqDNZQF8 n145uRI+2vkONKsZ8iFWqJIrvtsUYMPbPOKI1+Nd0KVG6pKtcr855m28eKNFFSyHzZ LpStTjivlR8Ew== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BBD1462986 for ; Fri, 13 Oct 2023 09:48:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PmWkNhh2"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40666aa674fso18810115e9.0 for ; Fri, 13 Oct 2023 00:48:53 -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=v0nbS29QoQ7yqrDXklQ2NX32XLs3Z77SCfUCSFVZHik=; b=PmWkNhh2iRfW84fnVWud+Vq7Xi+qEAsv9i1POq6L/EREinY9vFvWxFW35gKSGTJZxf J/mfxTu4RMspOQxsyRgToCXntqMNFak45CwFhd8kwgvFhCypkwKb13jQwXt2I0KZvoZP OYsvIwWvvfG62DM5s2iU0LJ+h3SQJMdZkQK2/pieWX6+etbK3WcsIxAfeoZMroveidQy +0F9wHVMUl4KGDqdTbjRR13Rd6xPwCeefsOFLKEeyCdh0BzpxV563IqebE/to/YCLFbp 53IKOyGMW7Qv+UZ+oAnVmrnQRs6Pq2b8JdmV1/aUhAbczTHQM3OUbDmv1/6p6J1QMn3g /PwQ== 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=v0nbS29QoQ7yqrDXklQ2NX32XLs3Z77SCfUCSFVZHik=; b=hAtaZIK4lW0KLnl0UQgcubBll2+dgwuCK380oRrDV8zvz7WdTC8BubcBjz/dDoR2Av siBPEl1X8yloQsk7PlziYNfr+NlT30zWNVv+u1ju/kqrw2keB0ojOX/QJbb1G1LQHdt8 Nip/loLsudKXWDvPMLEGr+jI7CyyENciyJmM7el9d0Op8wJYYlnaRPak/Q9Y9DuBKNCn JIkWj5iQaR/WDV998fg2DU8qQPCp3sO325PbQzn5PYNVgcinCkI5Jbg/z1dTbuH66U5J oKOys9+gnZBeOMoukJdwBmQdxhqP9tcvmPlEaEMNlC3EXV7ZS7dHUtPeKINRi4kQTYnI vqFA== X-Gm-Message-State: AOJu0YxfybKQulQCj4d5QuFCwR6bhDHbtoKkDJxB5SwkyXZ6hU18RNfb F7Vq+9Sf1GRwC7723HCGEmrIuM1nIA/MqFDiczOR9Q== X-Google-Smtp-Source: AGHT+IHi2pG37WGEmkyxneBt1cC3Aj5Bm3QyI+GyPBNd2Mwg+/QcOhD7ENu+leXEZsTNzpSVe7y9tw== X-Received: by 2002:a7b:c393:0:b0:401:bd2e:49fc with SMTP id s19-20020a7bc393000000b00401bd2e49fcmr23748595wmj.24.1697183332983; Fri, 13 Oct 2023 00:48:52 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:48:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Oct 2023 08:48:30 +0100 Message-Id: <20231013074841.16972-10-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 09/20] ipa: rpi: Prepare ALSC 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 ALSC algorithm to support the PiSP hardware. The key change is to avoid factoring out the WB correction in the AWB zone statistics. Add the ALSC correction to the global metadata so that AWB can use it to factor the gains back in for the AWB calculations. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi --- src/ipa/rpi/controller/rpi/alsc.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp index 3a2e8fe00ca6..f1ccef87c70c 100644 --- a/src/ipa/rpi/controller/rpi/alsc.cpp +++ b/src/ipa/rpi/controller/rpi/alsc.cpp @@ -348,9 +348,11 @@ static void copyStats(RgbyRegions ®ions, StatisticsPtr &stats, const std::vector &bTable = status.b; for (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) { auto r = stats->awbRegions.get(i); - r.val.rSum = static_cast(r.val.rSum / rTable[i]); - r.val.gSum = static_cast(r.val.gSum / gTable[i]); - r.val.bSum = static_cast(r.val.bSum / bTable[i]); + if (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc) { + r.val.rSum = static_cast(r.val.rSum / rTable[i]); + r.val.gSum = static_cast(r.val.gSum / gTable[i]); + r.val.bSum = static_cast(r.val.bSum / bTable[i]); + } regions.set(i, r); } } @@ -368,7 +370,8 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata) * the LSC table that the pipeline applied to them. */ AlscStatus alscStatus; - if (imageMetadata->get("alsc.status", alscStatus) != 0) { + if (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc && + imageMetadata->get("alsc.status", alscStatus) != 0) { LOG(RPiAlsc, Warning) << "No ALSC status found for applied gains!"; alscStatus.r.resize(config_.tableSize.width * config_.tableSize.height, 1.0); @@ -414,6 +417,11 @@ void Alsc::prepare(Metadata *imageMetadata) status.g = prevSyncResults_[1].data(); status.b = prevSyncResults_[2].data(); imageMetadata->set("alsc.status", status); + /* + * Put the results in the global metadata as well. This will be used by + * AWB to factor in the colour shading correction. + */ + getGlobalMetadata().set("alsc.status", status); } void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata)