From patchwork Thu Sep 8 01:41:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17334 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 9B3D8C327E for ; Thu, 8 Sep 2022 01:42:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 463E9620FD; Thu, 8 Sep 2022 03:42:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662601374; bh=q0RfxFnDYGcvT+madUJOOXtY91wIaKNuVkh+9HZ6tYE=; 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=AvMM1/ulGwJ74qoBk3TDT2PPUn59HvsmiKozy4vivVyepO9GSVQlEsge8yx5ZifEk AY9mzwjThLIQ5L6FFHpvjsIoYQTAhAQ/UvtWI4eyafoP2VZ8Ao7GiVt8p454umMgji utxHykvTl/FTvACrgg2EsZhV/bw+aUqQuZPkcHA2zkAlbuk5kb3Ol2YS/lWXkxfvdE ShBbA9Q9kYaue9wYtyZ7uuPqy2ornvlfxuOLZ+sirMEfz7XRINRSY4PGvjJvWMmjt9 X8OATSEmiL8PhF91JO8VrzvmhULidNhuEPxfiV9YszctVwbPg90JGK+W1YvMEl4ttp CNqHwFJ8ZSeyQ== 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 D6827620F1 for ; Thu, 8 Sep 2022 03:42:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ItjpbF9x"; 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 63BC2888 for ; Thu, 8 Sep 2022 03:42:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1662601372; bh=q0RfxFnDYGcvT+madUJOOXtY91wIaKNuVkh+9HZ6tYE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ItjpbF9xKKLgJYFlwSyJOAW4OaP2Guv1vVuUemGIGcdT8jmpVuCqB3tCEU5zGcmqG jDvVX43BflpDmwfCZKPHulVfvp4CQHYFepFp5ok3nb6+Eq57xrl+1xkbacWifpWqau 4XntrpMelRMTVCkBHzOh7UR11LinmhzQtgQ2wE98= To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Sep 2022 04:41:53 +0300 Message-Id: <20220908014200.28728-26-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220908014200.28728-1-laurent.pinchart@ideasonboard.com> References: <20220908014200.28728-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 25/32] 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 bb0f6c27fc7d..b711e93b73ba 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. */