From patchwork Thu Mar 2 15:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18335 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 4A0EDBF415 for ; Thu, 2 Mar 2023 15:39:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89A7F6269C; Thu, 2 Mar 2023 16:39:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677771542; bh=9WDWFwLyGwdprabpgY4e6oLCte4YPBkypoeJLxilEW0=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ov5w8rSXUavIpxhYN37uXxdzTrNe+ljEMiT0sGIInUe6ZqLezzSCwWeUjHA0kRFfc LnBm1X3LyCFXM2GiVUVFKhglTFyE7TkD2Zj42+jPbVO7K1XE3pPFrPPB52fk56GBO5 5Mkvh6LMh8m519oORpQ8jiEvEcIXN+mUFHfYSbn7AELBcyftbY55DW8Oo9nattREyF dOPMrlJbQozK3E4TmAtJ8RiHm/gtkBRAtjhK5YyZrT+BXdDDKrr0b34U64X9Yw/1G4 x8Ew6TWx3vwz4oXKz5CPKsQ+ASmOJ0GvI6HTbd7anl40UCrcJb2L2+PvreDOazFIkN wOAItyNZZrIuQ== 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 F0C7C6267E for ; Thu, 2 Mar 2023 16:39:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iVqMAaqY"; dkim-atps=neutral Received: from uno.homenet.telecomitalia.it (host-87-18-61-24.retail.telecomitalia.it [87.18.61.24]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4512156A; Thu, 2 Mar 2023 16:39:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1677771540; bh=9WDWFwLyGwdprabpgY4e6oLCte4YPBkypoeJLxilEW0=; h=From:To:Cc:Subject:Date:From; b=iVqMAaqYB23hzih5okYku2/m3N349feHzb37/DCF5eitX0iI6vWPffbeEJ2UNHJck S0R2ISf3fqz4FodApG6Laz3rRvV0Q+lzLb9sdsRC0koeg6RT446+RXydNU0jmA112I 7BJ7fSWbY/4FtnCC4FTsTUsPZbm/4AaIMMKjN2Hs= To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Mar 2023 16:38:52 +0100 Message-Id: <20230302153852.63619-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] ipa: rkisp1: lsc: Fix integer division error 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The RkISP1 implementation of the LensShadinCorrection algorithm has been made adaptive to the scene color temperature in commit 14c869c00fdd ("ipa: rkisp1: Take into account color temperature during LSC algorithm"). The LSC algorithm interpolates the correction factors using the table's reference color temperatures. When calculating the interpolation coefficients, an unintended integer division makes both coefficient zeros resulting in a completely black image. Fix this by type casting to double one of the division operands. Fixes: 14c869c00fdd ("ipa: rkisp1: Take into account color temperature during LSC algorithm") Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/lsc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.39.0 diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 3a443e776a53..a7ccedb1ed3b 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -216,8 +216,8 @@ void LensShadingCorrection::interpolateTable(rkisp1_cif_isp_lsc_config &config, const Components &set1, const uint32_t ct) { - double coeff0 = (set1.ct - ct) / (set1.ct - set0.ct); - double coeff1 = (ct - set0.ct) / (set1.ct - set0.ct); + double coeff0 = (set1.ct - ct) / static_cast(set1.ct - set0.ct); + double coeff1 = (ct - set0.ct) / static_cast(set1.ct - set0.ct); for (unsigned int i = 0; i < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; ++i) { for (unsigned int j = 0; j < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; ++j) {