Patch Detail
Show a patch.
GET /api/1.1/patches/12740/?format=api
{ "id": 12740, "url": "https://patchwork.libcamera.org/api/1.1/patches/12740/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12740/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210628202255.138874-6-jeanmichel.hautbois@ideasonboard.com>", "date": "2021-06-28T20:22:53", "name": "[libcamera-devel,v1,5/7] ipa: ipu3: Improve AWB behaviour", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "2d04e97ed22f33a81c54593d6a4567dc15aad9f6", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12740/mbox/", "series": [ { "id": 2190, "url": "https://patchwork.libcamera.org/api/1.1/series/2190/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2190", "date": "2021-06-28T20:22:48", "name": "ipa: Introduce a new open AGC", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2190/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12740/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12740/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 20E76C321F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 20:23:08 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0323684D8;\n\tMon, 28 Jun 2021 22:23:07 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A526A60508\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 22:23:00 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:c3ad:78d0:405e:fc33])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D829E1A;\n\tMon, 28 Jun 2021 22:23:00 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"T+qxM5m8\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624911780;\n\tbh=tBFLU0Yeg3WjK5ACTVDZvPYeav6Mg9xubS1dBFY8Yuo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=T+qxM5m8xllxmC27Vs9iib5ZxfmY5yvvmU6vCCyegNLzkj17wk9gYiZqfS5utvA+Q\n\t4PejKKi8DPzoL39W1m4SykaWUrTCetJdRATgTeVqLVT6mtxSztDN3hHPy2wPAgWrKk\n\tSRF53GRGhkni2Eoj6yIXdKN4o/1YDYJvdb7kZZZ8=", "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 28 Jun 2021 22:22:53 +0200", "Message-Id": "<20210628202255.138874-6-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20210628202255.138874-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v1 5/7] ipa: ipu3: Improve AWB behaviour", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In order to use a better grid, clamp the values calculated from the BDS\nresolution to at least 2 times the minimum grid size.\nThe number of zones needed to have sufficiently relevant statistics is\nnow based on the region sizes and not on an arbitrary value.\nLast, the default green gains where not properly used, it should be 8192\nand not 4096 to have a multiplier of 1.0 on the R/G/B gains.\n\nThe default CCM is adjusted for Surface Go2 only, and should eventually be\ncalculated in the CameraSensorHelper class.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/ipu3.cpp | 12 ++++++++----\n src/ipa/ipu3/ipu3_awb.cpp | 23 +++++++++++------------\n src/ipa/ipu3/ipu3_awb.h | 1 +\n 3 files changed, 20 insertions(+), 16 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 4466391a..9a2def64 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -123,12 +123,16 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)\n \tbdsGrid_ = {};\n \n \tfor (uint32_t widthShift = 3; widthShift <= 7; ++widthShift) {\n-\t\tuint32_t width = std::min(kMaxCellWidthPerSet,\n-\t\t\t\t\t bdsOutputSize.width >> widthShift);\n+\t\tuint32_t width = std::clamp(bdsOutputSize.width >> widthShift,\n+\t\t\t\t\t 2 * kAwbStatsSizeX,\n+\t\t\t\t\t kMaxCellWidthPerSet);\n+\n \t\twidth = width << widthShift;\n \t\tfor (uint32_t heightShift = 3; heightShift <= 7; ++heightShift) {\n-\t\t\tint32_t height = std::min(kMaxCellHeightPerSet,\n-\t\t\t\t\t\t bdsOutputSize.height >> heightShift);\n+\t\t\tuint32_t height = std::clamp(bdsOutputSize.height >> heightShift,\n+\t\t\t\t\t\t 2 * kAwbStatsSizeY,\n+\t\t\t\t\t\t kMaxCellHeightPerSet);\n+\n \t\t\theight = height << heightShift;\n \t\t\tuint32_t error = std::abs(static_cast<int>(width - bdsOutputSize.width))\n \t\t\t\t\t\t\t+ std::abs(static_cast<int>(height - bdsOutputSize.height));\ndiff --git a/src/ipa/ipu3/ipu3_awb.cpp b/src/ipa/ipu3/ipu3_awb.cpp\nindex a94935c5..a39536b0 100644\n--- a/src/ipa/ipu3/ipu3_awb.cpp\n+++ b/src/ipa/ipu3/ipu3_awb.cpp\n@@ -18,9 +18,6 @@ namespace ipa::ipu3 {\n \n LOG_DEFINE_CATEGORY(IPU3Awb)\n \n-static constexpr uint32_t kMinZonesCounted = 16;\n-static constexpr uint32_t kMinGreenLevelInZone = 32;\n-\n /**\n * \\struct IspStatsRegion\n * \\brief RGB statistics for a given region\n@@ -92,7 +89,7 @@ static constexpr uint32_t kMinGreenLevelInZone = 32;\n \n /* Default settings for Bayer noise reduction replicated from the Kernel */\n static const struct ipu3_uapi_bnr_static_config imguCssBnrDefaults = {\n-\t.wb_gains = { 16, 16, 16, 16 },\n+\t.wb_gains = { 8192, 8192, 8192, 8192 },\n \t.wb_gains_thr = { 255, 255, 255, 255 },\n \t.thr_coeffs = { 1700, 0, 31, 31, 0, 16 },\n \t.thr_ctrl_shd = { 26, 26, 26, 26 },\n@@ -130,7 +127,7 @@ static const struct ipu3_uapi_awb_config_s imguCssAwbDefaults = {\n /* Default color correction matrix defined as an identity matrix */\n static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {\n \t8191, 0, 0, 0,\n-\t0, 8191, 0, 0,\n+\t0, 6000, 0, 0,\n \t0, 0, 8191, 0\n };\n \n@@ -166,6 +163,7 @@ IPU3Awb::IPU3Awb()\n \tasyncResults_.greenGain = 1.0;\n \tasyncResults_.redGain = 1.0;\n \tasyncResults_.temperatureK = 4500;\n+\tminZonesCounted_ = 0;\n }\n \n IPU3Awb::~IPU3Awb()\n@@ -241,7 +239,7 @@ void IPU3Awb::generateZones(std::vector<RGB> &zones)\n \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n \t\tRGB zone;\n \t\tdouble counted = awbStats_[i].counted;\n-\t\tif (counted >= kMinZonesCounted) {\n+\t\tif (counted >= minZonesCounted_) {\n \t\t\tzone.G = awbStats_[i].gSum / counted;\n \t\t\tif (zone.G >= kMinGreenLevelInZone) {\n \t\t\t\tzone.R = awbStats_[i].rSum / counted;\n@@ -258,6 +256,7 @@ void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n \tuint32_t regionWidth = round(awbGrid_.width / static_cast<double>(kAwbStatsSizeX));\n \tuint32_t regionHeight = round(awbGrid_.height / static_cast<double>(kAwbStatsSizeY));\n \n+\tminZonesCounted_ = ((regionWidth * regionHeight) * 4) / 5;\n \t/*\n \t * Generate a (kAwbStatsSizeX x kAwbStatsSizeY) array from the IPU3 grid which is\n \t * (awbGrid_.width x awbGrid_.height).\n@@ -269,7 +268,7 @@ void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n \t\t\tuint32_t cellY = ((cellPosition / awbGrid_.width) / regionHeight) % kAwbStatsSizeY;\n \n \t\t\tuint32_t awbRegionPosition = cellY * kAwbStatsSizeX + cellX;\n-\t\t\tcellPosition *= 8;\n+\t\t\tcellPosition *= sizeof(Ipu3AwbCell);\n \n \t\t\t/* Cast the initial IPU3 structure to simplify the reading */\n \t\t\tIpu3AwbCell *currentCell = reinterpret_cast<Ipu3AwbCell *>(const_cast<uint8_t *>(&stats->awb_raw_buffer.meta_data[cellPosition]));\n@@ -361,12 +360,12 @@ void IPU3Awb::updateWbParameters(ipu3_uapi_params ¶ms, double agcGamma)\n \t/*\n \t * Green gains should not be touched and considered 1.\n \t * Default is 16, so do not change it at all.\n-\t * 4096 is the value for a gain of 1.0\n+\t * 8192 is the value for a gain of 1.0\n \t */\n-\tparams.acc_param.bnr.wb_gains.gr = 16;\n-\tparams.acc_param.bnr.wb_gains.r = 4096 * asyncResults_.redGain;\n-\tparams.acc_param.bnr.wb_gains.b = 4096 * asyncResults_.blueGain;\n-\tparams.acc_param.bnr.wb_gains.gb = 16;\n+\tparams.acc_param.bnr.wb_gains.gr = 8192;\n+\tparams.acc_param.bnr.wb_gains.r = 8192 * asyncResults_.redGain;\n+\tparams.acc_param.bnr.wb_gains.b = 8192 * asyncResults_.blueGain;\n+\tparams.acc_param.bnr.wb_gains.gb = 8192;\n \n \tLOG(IPU3Awb, Debug) << \"Color temperature estimated: \" << asyncResults_.temperatureK\n \t\t\t << \" and gamma calculated: \" << agcGamma;\ndiff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/ipu3_awb.h\nindex 795e32e3..23865c21 100644\n--- a/src/ipa/ipu3/ipu3_awb.h\n+++ b/src/ipa/ipu3/ipu3_awb.h\n@@ -49,6 +49,7 @@ private:\n \tstd::vector<RGB> zones_;\n \tIspStatsRegion awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n \tAwbStatus asyncResults_;\n+\tuint32_t minZonesCounted_;\n };\n \n } /* namespace ipa::ipu3 */\n", "prefixes": [ "libcamera-devel", "v1", "5/7" ] }