From patchwork Mon Nov 18 22:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21977 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 92873C32F0 for ; Mon, 18 Nov 2024 22:17:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F345A65EDF; Mon, 18 Nov 2024 23:17:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HTdlQL5s"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6701065EDD for ; Mon, 18 Nov 2024 23:16:51 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5F1148DB for ; Mon, 18 Nov 2024 23:16:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1731968194; bh=/XTcCf7GgzVrQeALl6c200OUkd+x2DRlPNXv8XuCRrw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HTdlQL5sw3lPK6h3QECNUM7ucWDkJzfhcDmZ6/RgdZymg6RZtnZPtJk0tGUO/HHsc LOjDN4NUvNlOph/fcTbzRgLaLiMRPUwUAw8booGKmLrvpSfkiFhBJqQRJta0OkfyoI b764ccTh+1CY8UE6wbx4HUBUUghh0sIEhWMW2SlQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 17/17] ipa: rkisp1: awb: Expand comment Date: Tue, 19 Nov 2024 00:16:18 +0200 Message-ID: <20241118221618.13953-18-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118221618.13953-1-laurent.pinchart@ideasonboard.com> References: <20241118221618.13953-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The RGB to YCbCr conversion matrix mentioned in a comment, coming from the hardware documentation, does not match any of the canonical matrices specified by any standard. While researching where the values came from, it became apparent they are likely Bt.601 limited range coefficients rounded to 6 bits of decimal precision. Record this in comments. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal --- src/ipa/rkisp1/algorithms/awb.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 26d7b8138f17..4bb4f5b88375 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -210,13 +210,18 @@ void Awb::process(IPAContext &context, }); /* - * Convert from YCbCr to RGB. - * The hardware uses the following formulas: - * Y = 16 + 0.2500 R + 0.5000 G + 0.1094 B + * Convert from YCbCr to RGB. The hardware uses the following + * formulas: + * + * Y = 16 + 0.2500 R + 0.5000 G + 0.1094 B * Cb = 128 - 0.1406 R - 0.2969 G + 0.4375 B * Cr = 128 + 0.4375 R - 0.3750 G - 0.0625 B * - * The inverse matrix is thus: + * This seems to be based on limited range BT.601 with Q1.6 + * precision. + * + * The inverse matrix is: + * * [[1,1636, -0,0623, 1,6008] * [1,1636, -0,4045, -0,7949] * [1,1636, 1,9912, -0,0250]]