{"id":15894,"url":"https://patchwork.libcamera.org/api/1.1/patches/15894/?format=json","web_url":"https://patchwork.libcamera.org/patch/15894/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220512084244.1833554-1-foss+libcamera@0leil.net>","date":"2022-05-12T08:42:43","name":"[libcamera-devel,RFC,1/2] ipa: rkisp1: awb: add support for RGB means","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f6cd1ab52a19e5a3a15f42a0435439658503d9df","submitter":{"id":120,"url":"https://patchwork.libcamera.org/api/1.1/people/120/?format=json","name":"Quentin Schulz","email":"foss+libcamera@0leil.net"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15894/mbox/","series":[{"id":3110,"url":"https://patchwork.libcamera.org/api/1.1/series/3110/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3110","date":"2022-05-12T08:42:43","name":"[libcamera-devel,RFC,1/2] ipa: rkisp1: awb: add support for RGB means","version":1,"mbox":"https://patchwork.libcamera.org/series/3110/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15894/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15894/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 A5A12C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 May 2022 08:43:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CBFC36565B;\n\tThu, 12 May 2022 10:43:03 +0200 (CEST)","from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A591A6150E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 May 2022 10:43:01 +0200 (CEST)","(Authenticated sender: foss@0leil.net)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 31E4E240010;\n\tThu, 12 May 2022 08:42:59 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652344983;\n\tbh=L5h0ZAe/G5JFrDNuWcHKooNkZSDGkSvSM7FkmL9S2Gc=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=HsYg6WSsC1mh9fu7RRFvwRCqBn9ovwTbMtWZGKQ273wWn4C54PQsgU51PXI9l5Gkr\n\t4jBG7pQgFizLv4KWo207qHkJ5NVHwGp38LCTAYDFOOXPSzhZxfThZjkSyr3l/6lExa\n\tzgnNsrRFNV3CPup7h+lnnqwu2r15hbGEPoTZPrvLnr+Af/eykByb2cNA8tJA+3BTGH\n\t/6nLSy2hiG11K0oYpimHuBSAgJwVw190I9AY6E0WxK409Hpaks4XEZnDKUNJmc2f2n\n\t0MPc2Dsm6eQwPIq3opU3xnAL9SNk5Y/U5J1xCNDiMW3H+P2/YHrbOa4YvmNcU3/lgX\n\tDVWfpzGwk2hxA==","To":"","Date":"Thu, 12 May 2022 10:42:43 +0200","Message-Id":"<20220512084244.1833554-1-foss+libcamera@0leil.net>","X-Mailer":"git-send-email 2.35.3","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 1/2] ipa: rkisp1: awb: add support for\n\tRGB means","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":"Quentin Schulz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Quentin Schulz <foss+libcamera@0leil.net>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Quentin Schulz <quentin.schulz@theobroma-systems.com>\n\nRkISP actually supports two modes for color means, RGB and YCbCr. The\nvariables where the means are stored are identically named regardless of\nthe color means mode that's been selected.\n\nSince the gains are computed in RGB mode, a conversion needs to be done\nwhen the mode is YCbCr, which is unnecessary when RGB mode is selected.\n\nThis adds support for RGB means mode too, by checking at runtime which\nmode is selected at a given time.\n\nCc: Quentin Schulz <foss+libcamera@0leil.net>\nSigned-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>\n---\n\nTo be decided if we want to keep supporting both modes or only one?\n(Given that at the moment we harcode which mode is used at compile time,\n I'm not sure it's worth keeping dead code around)\n\n src/ipa/rkisp1/algorithms/awb.cpp | 57 ++++++++++++++++++-------------\n 1 file changed, 33 insertions(+), 24 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex be4585c6..df749b9b 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -124,30 +124,39 @@ void Awb::process([[maybe_unused]] IPAContext &context, const rkisp1_stat_buffer\n \tconst rkisp1_cif_isp_stat *params = &stats->params;\n \tconst rkisp1_cif_isp_awb_stat *awb = &params->awb;\n \tIPAFrameContext &frameContext = context.frameContext;\n-\n-\t/* Get the YCbCr mean values */\n-\tdouble yMean = awb->awb_mean[0].mean_y_or_g;\n-\tdouble crMean = awb->awb_mean[0].mean_cr_or_r;\n-\tdouble cbMean = awb->awb_mean[0].mean_cb_or_b;\n-\n-\t/*\n-\t * Convert from YCbCr to RGB.\n-\t * The hardware uses the following formulas:\n-\t * Y = 16 + 0.2500 R + 0.5000 G + 0.1094 B\n-\t * Cb = 128 - 0.1406 R - 0.2969 G + 0.4375 B\n-\t * Cr = 128 + 0.4375 R - 0.3750 G - 0.0625 B\n-\t *\n-\t * The inverse matrix is thus:\n-\t * [[1,1636, -0,0623,  1,6008]\n-\t *  [1,1636, -0,4045, -0,7949]\n-\t *  [1,1636,  1,9912, -0,0250]]\n-\t */\n-\tyMean -= 16;\n-\tcbMean -= 128;\n-\tcrMean -= 128;\n-\tdouble redMean = 1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean;\n-\tdouble greenMean = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;\n-\tdouble blueMean = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;\n+\tdouble greenMean;\n+\tdouble redMean;\n+\tdouble blueMean;\n+\n+\tif (params->meas.awb_meas_config.awb_mode == RKISP1_CIF_ISP_AWB_MODE_RGB) {\n+\t\tgreenMean = awb->awb_mean[0].mean_y_or_g;\n+\t\tredMean = awb->awb_mean[0].mean_cr_or_r;\n+\t\tblueMean = awb->awb_mean[0].mean_cb_or_b;\n+\t} else {\n+\t\t/* Get the YCbCr mean values */\n+\t\tdouble yMean = awb->awb_mean[0].mean_y_or_g;\n+\t\tdouble crMean = awb->awb_mean[0].mean_cr_or_r;\n+\t\tdouble cbMean = awb->awb_mean[0].mean_cb_or_b;\n+\n+\t\t/*\n+\t\t * Convert from YCbCr to RGB.\n+\t\t * The hardware uses the following formulas:\n+\t\t * Y = 16 + 0.2500 R + 0.5000 G + 0.1094 B\n+\t\t * Cb = 128 - 0.1406 R - 0.2969 G + 0.4375 B\n+\t\t * Cr = 128 + 0.4375 R - 0.3750 G - 0.0625 B\n+\t\t *\n+\t\t * The inverse matrix is thus:\n+\t\t * [[1,1636, -0,0623,  1,6008]\n+\t\t *  [1,1636, -0,4045, -0,7949]\n+\t\t *  [1,1636,  1,9912, -0,0250]]\n+\t\t */\n+\t\tyMean -= 16;\n+\t\tcbMean -= 128;\n+\t\tcrMean -= 128;\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+\t}\n \n \t/* Estimate the red and blue gains to apply in a grey world. */\n \tdouble redGain = greenMean / (redMean + 1);\n","prefixes":["libcamera-devel","RFC","1/2"]}