{"id":17338,"url":"https://patchwork.libcamera.org/api/patches/17338/?format=json","web_url":"https://patchwork.libcamera.org/patch/17338/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220908014200.28728-30-laurent.pinchart@ideasonboard.com>","date":"2022-09-08T01:41:57","name":"[libcamera-devel,v4,29/32] ipa: rkisp1: awb: Prevent RGB means from being negative","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"276dd35b92a064400844343f4070e00a452b6d9e","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17338/mbox/","series":[{"id":3476,"url":"https://patchwork.libcamera.org/api/series/3476/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3476","date":"2022-09-08T01:41:28","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":4,"mbox":"https://patchwork.libcamera.org/series/3476/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17338/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17338/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id ECDFDC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Sep 2022 01:43:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9ACA16210E;\n\tThu,  8 Sep 2022 03:43:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C0C5620FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:58 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E362C8F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:57 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662601380;\n\tbh=7UvmQ3qSqI6o2mLkcewEM7KdUj4KP3LM/xCTrOi3RAg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=aoa6Xg6eWpxq+DFRzS6N+eCE9BIT3PJjiTpuPfkinw41Qd6xQ9eiCxtpyf72uQLdm\n\tK+BKpGi/3HCcuOAdtwlXyPXN8bjGgoA10I0gXkaw0rYokbm0K/c4dEtohzSCevlkR+\n\tov4PNK0CJRanGQ+VjDRY6UeDuKDyGhljN5SLuwnmaKBj/bAKQK0vm//q0ayC2ID529\n\tU7jiTCYr4lWDlMZIaKDDhXP1EcXihx4kYlfOhj4+Ars6yaH1xcNx2yDa9j/ntS0l6S\n\tMo8JPkfxeUR/h3qp6dJXspI1Gk+z3t5MevE0Mw/Wk8pJ+Vd4KQbVAYaz35cQNX12I6\n\t53johcu1G6D9g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662601378;\n\tbh=7UvmQ3qSqI6o2mLkcewEM7KdUj4KP3LM/xCTrOi3RAg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=tEtScMoFV83L2ZG2QJlkYel6G0CI4bSbKEQF57IHik5esgtmZZ9m9tLWyqDcDfDpt\n\tnNlsT1SmlqXVtb8IQ3eE6Oh5z1PVZoZ7/fPFfdl3Cg6zYeRKjfiNvWHUlnxHTVXZEC\n\tqwX9xOGHE54Ih1yKX52uGXaBeEj+xIQPWV+xRS+0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"tEtScMoF\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Sep 2022 04:41:57 +0300","Message-Id":"<20220908014200.28728-30-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 29/32] ipa: rkisp1: awb: Prevent RGB\n\tmeans from being negative","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Due to hardware rounding errors in the YCbCr means, the calculated RGB\nmeans may be negative. This would lead to negative gains, messing up\ncalculation. Prevent this by clamping the means to positive values.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++\n 1 file changed, 10 insertions(+)","diff":"diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex ed91e9277a16..de54c4d24650 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -242,6 +242,16 @@ void Awb::process(IPAContext &context,\n \t\tredMean = 1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean;\n \t\tgreenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;\n \t\tblueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;\n+\n+\t\t/*\n+\t\t * Due to hardware rounding errors in the YCbCr means, the\n+\t\t * calculated RGB means may be negative. This would lead to\n+\t\t * negative gains, messing up calculation. Prevent this by\n+\t\t * clamping the means to positive values.\n+\t\t */\n+\t\tredMean = std::max(redMean, 0.0);\n+\t\tgreenMean = std::max(greenMean, 0.0);\n+\t\tblueMean = std::max(blueMean, 0.0);\n \t}\n \n \t/*\n","prefixes":["libcamera-devel","v4","29/32"]}