From patchwork Tue Sep 27 02:36:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17437 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 BEA69C0DA4 for ; Tue, 27 Sep 2022 02:37:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8074B622E7; Tue, 27 Sep 2022 04:37:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664246262; bh=GcSa94Jrazj/EAi+vuDxoDwbhhojdBEJ8UWXSrd03HA=; 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=cUq8F6Tq3TcsRZPgQWaNDyli6X9ok/TgbqLksOSlEGtHI08cq/SVRBVKufvGqs+vj gPa0q9ILTM/1xPLQbTPur0sTthNGPl6PlVd80stRBykzU8p/s+UvKZXm1gBkeMZDrW TVGhxTNnLYw88KB3dwltToLiBpiXDeKn06NlSjDLiUGRMhburWz1tr0J9H90a3Dpfb 4Wxd127SIYh+5k4u5PG+4TdK6Lpb/ggBmG7lSQL8Ypy3JsyiG+pnlFt4CP3YHKiTfA ZzYSXcfQ4gYhK3BeHoJC1PIql1rZl/XNg51dknZKP4NmabkEDynKSfM/qi1onAEVYO 7Oaq8EnlqDP7Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B50F76227A for ; Tue, 27 Sep 2022 04:37:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aYn8SXbl"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 38607E5 for ; Tue, 27 Sep 2022 04:37:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664246260; bh=GcSa94Jrazj/EAi+vuDxoDwbhhojdBEJ8UWXSrd03HA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aYn8SXblmJUy7BsusBKQqnnzfVFnMEbVOPeLCfKNYS/RU17yV2hZTnLLqXXBWOs/D NmL44y9qydpsvRy04P4uyyUOcnYdpfo8G9eq8eq4SJ2qz7KL7xcnXGKynTxIvKlOFL TFAOFlHZoQ+2mDbTM1EVlEWYby7QjgQFIH9X4ILU= To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Sep 2022 05:36:35 +0300 Message-Id: <20220927023642.12341-27-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220927023642.12341-1-laurent.pinchart@ideasonboard.com> References: <20220927023642.12341-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 26/33] ipa: rkisp1: awb: Use frame context to fix gains calculations 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The AWB statistics are computed after the ISP applies the colour gains. This means that the red, green and blue means do not match the data coming directly from the sensor, but are multiplied by the colour gains that were used for the frame on which the statistics have been computed. The AWB algorithm needs to take this into account when calculating the colour gains for the next frame. Do so by dividing the means by the gains that were applied to the frame, retrieved from the frame context. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/awb.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index e491cf7507e0..694d97cccc07 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -207,6 +207,15 @@ void Awb::process(IPAContext &context, double greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean; double blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean; + /* + * The ISP computes the AWB means after applying the colour gains, + * divide by the gains that were used to get the raw means from the + * sensor. + */ + redMean /= frameContext.awb.gains.red; + greenMean /= frameContext.awb.gains.green; + blueMean /= frameContext.awb.gains.blue; + frameContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean); /* Estimate the red and blue gains to apply in a grey world. */