From patchwork Fri Oct 6 13:19:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19111 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 0A4D5C32BB for ; Fri, 6 Oct 2023 13:20:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B126862973; Fri, 6 Oct 2023 15:20:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1696598409; bh=DjzjUWLUnAHZALJOWBNhMzRGZXmd4bbCcswnCZ87r5o=; 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=WIcT6rDyb6ikhvw8nnjVVCG5LLfiTBd2P0+yJiMncc3uH4uVMpeMB2RmkRQ2nNwCV B9D4U3RSlauQDfIgYV/wWtn/3W7m22M51QoMABDd/2GS3jwYgglnq/PfhJjcL6BJTF qDzr4khE2pcMHJqv/pDm5QCJg/BDNazL8DrYQpyg7tGrrfgosJJ6oWb03NmtHoF2Yd V1hWIMoa5/XWSxV9/6t90vSWhCgwT0hcpgnWst2ZPPVK1fbHBpdZxcDawpAMEjqntd dZjgFrZq3gpBxHP3Wn/gvFPt0Hv6mLXT3L9QMNh3nAwot+SOAD3AKF7rrG8UwP4VaF PCiWdzrTqD28Q== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0E0A62976 for ; Fri, 6 Oct 2023 15:20:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="bj35JJUW"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40651a726acso19065715e9.1 for ; Fri, 06 Oct 2023 06:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1696598407; x=1697203207; 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=kL4411ue6KUoItjo2jH8OvVljS7ZlVEJVZMzhhlz4F8=; b=bj35JJUW+s70a078WUeUBaGkx/wnQ8K+sOGl/94WvISsAqg8lBXoX5TyyU2u4lVERz Ivu0uh6sfBz+pZPDhNp2LawNNG/hdvUm6iI3FvjXbSmcLYgn4vOmiEPJcP3OaEGvvYXn u+htU69/sMYVXo1urw2J6glKFenC34f82CzaJH73Q+7QASoiQNnQMFzzvYddmUM4fBVd ngF/fmz+SivuGEQYVUzR+Ygj3ee2hy5eYbc53AscKBmHUHbwYvYqey+ZyFUnfUu8PEqG jSV/1OXFQOwOMaclLlH1tvkNii1rCgE7cPjx080mclC73vM6A3TzcfVR+F2hAZ90++gz GqsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598407; x=1697203207; 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=kL4411ue6KUoItjo2jH8OvVljS7ZlVEJVZMzhhlz4F8=; b=D8Q0Pxx6+v/z4Y5F9W6fu2zuadSK9rI2wdn04y+PG1TZi8LWF9oB8RWjSo3w2BSJyj Adcn6PAyYBjoFdNgBsSiTZii0ORYof0+UrdIEDYmUqtV9XiZZHiALxbLzRQVoVCmoZaV XSz67JBWlBu3E0Bw8Bbm5w1/JxtwdC0zON90eHkGKcwvhssO4rYi2EVabTWulgUTNWlX ltgdgKOpl7lv62Syc/GMURqGPYiQPM0ytOCmG/5fdsgiE9uvwaGCz2nyX4md4Q7CsMNz WKn352v6TH0kmJq1kQDbisEoyPXu6Ym/Xuh5TU0BTIXAKHLYNvNmeuLOCw1PaU0Hv8Vt xB9g== X-Gm-Message-State: AOJu0YykWBH+caHMjQ3oNrsWevm8t08A3tjmp1L8GwHHTnovwqsuGXfn Xt2Q523qw1bpI/KkBD5HuH/nYNYmH7OkBK7Rey8GKA== X-Google-Smtp-Source: AGHT+IEvs6BmJnde4jXeYaD5TrAUd63ci8Vff3DsQGbswiXPEgDUz7BNmTJvEF247jdVW8TmzUPV6g== X-Received: by 2002:adf:a3d6:0:b0:329:6b93:e346 with SMTP id m22-20020adfa3d6000000b003296b93e346mr1078709wrb.11.1696598407236; Fri, 06 Oct 2023 06:20:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:20:06 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Oct 2023 14:19:49 +0100 Message-Id: <20231006132000.23504-10-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 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 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)