Patch Detail
Show a patch.
GET /api/patches/17834/?format=api
{ "id": 17834, "url": "https://patchwork.libcamera.org/api/patches/17834/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17834/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20221122112224.31691-6-naush@raspberrypi.com>", "date": "2022-11-22T11:22:24", "name": "[libcamera-devel,v1,5/5] ipa: raspberrypi: Normalise region sums to 16-bits", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7d1a5edac1dfdcf586320263767f0ca5804a0ded", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17834/mbox/", "series": [ { "id": 3627, "url": "https://patchwork.libcamera.org/api/series/3627/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3627", "date": "2022-11-22T11:22:19", "name": "Raspberry Pi: Generalise statistics", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3627/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17834/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17834/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 09348C3286\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Nov 2022 11:22:35 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBF2C632F8;\n\tTue, 22 Nov 2022 12:22:34 +0100 (CET)", "from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E03886331A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Nov 2022 12:22:30 +0100 (CET)", "by mail-wm1-x32e.google.com with SMTP id\n\tv124-20020a1cac82000000b003cf7a4ea2caso14969149wme.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Nov 2022 03:22:30 -0800 (PST)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tq125-20020a1c4383000000b003c6cd82596esm21400388wma.43.2022.11.22.03.22.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Nov 2022 03:22:29 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669116154;\n\tbh=o3ITZHbe6aFynDHRpdIvstbdwMQ8TCOwVNf8A98D2/c=;\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=AfDQfV4wNuxZDlXIzOk9v2VFrvhh25eRiAwpPaK7g+Ahkp2P0A5EcZsTmVcW86Ey1\n\tpEG3h0zgNyo3RZ+CyIeDXWcu/eOa21jKTX/MLGUx9ZbtVusvg/OYslv36J9f3KzHvB\n\t7zgl1J2PIdiM9Jk+QeTvFHaZmSI7INorfxqTnqsFW3cC0sLQXFYIu6znPT+X80oU/J\n\t8Kx9+yTF+KHV04/Ii+MsB05AduJsh4XiR5ugakn5FXaGoyMNlyKcH+fA5ktS08IDeO\n\tt/2ogvJwebAdGN1X2/Sw4BRdN/n5bpTOdkhNyi4jh2lObsydnSw/JeLSsNXcjW1tkz\n\t/DMaqvfoJOEoA==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=cEBBhUzHrYHZA7FKrwtQWXcsENcHMTeNMYFSTGUqYVw=;\n\tb=qh/ZpMeJU1CeRA9khp+YGCOojxzVgYNkSdrKDY/maoxzcAyrp67JiX9THYi/hZ4jRg\n\t1S98yOK4LjFeTjcPI3ARnZq7W7iCHvKJkJ0pqiUpnojUQ55tA6xXzrzaPD3RmXIOFjva\n\t117mL0pjb/nPLDMauiK4+aSASnEkMfn9kEPBA3VOzHA4ASZYS03xAz+C/yOSp0MJhxfW\n\t8VjQlTR3Y8Dx868vdWM0ibuDw6qxv1ASqahl5aW9rDYYlrLukmypV7CsaVCUMNyPprpy\n\t715IrHiNSXDquVdHRNq9GM+ZZwFShxuaeyrqbbvTJIypKCU1gY1DEyoeefzLhcGuw4h4\n\toQxA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"qh/ZpMeJ\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=cEBBhUzHrYHZA7FKrwtQWXcsENcHMTeNMYFSTGUqYVw=;\n\tb=FpEx1Ni/wRxeI+pAAhBKQ93mpbiAXBCiLRYrD/tG8j+Zz6hBePLwb92udtRaijklsY\n\tWHKI94fghiNddtX/bZg5X0qf8yK+bUtqBcNHuD4vQjZM/INFPrm7oXqiiBhY1oGaJv58\n\tGUgcxwAj6iAqoMlyO8chLWIau4ojTFNyJ/CtnW9Y7YHaEB8JqYPPA6qkA68nmUTVWy8F\n\tyQY053DXMdsd7qCkhkpuiY8kRgbSC44ZZ4m9iYFvxRCtS4sYm6k8neW1NHSJDexfuK9E\n\trquWhCEjSLQLCfJ+r2Zf22pK52KP6tmW57f+0nf/6ISE2PGhqKoTwGi0kSmwvn1Sho6u\n\tiXTA==", "X-Gm-Message-State": "ANoB5pn+pjjuheVsmVBeE9estYt0hntZsl58K0luLiyP2o1jM7W9WwOt\n\twBPOV9a3PnTQ8Wpexg5fUFUvx8F/xujrOQ==", "X-Google-Smtp-Source": "AA0mqf7R+tmk+7GaU/py51HBlR7+8CzvHxJEWpefABBdOOqdO+cscrTZ0CD5X7ynNzgPOeyyAaqJRA==", "X-Received": "by 2002:a7b:c2aa:0:b0:3cf:5d41:bea1 with SMTP id\n\tc10-20020a7bc2aa000000b003cf5d41bea1mr3630138wmk.118.1669116150287; \n\tTue, 22 Nov 2022 03:22:30 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 22 Nov 2022 11:22:24 +0000", "Message-Id": "<20221122112224.31691-6-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221122112224.31691-1-naush@raspberrypi.com>", "References": "<20221122112224.31691-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v1 5/5] ipa: raspberrypi: Normalise region\n\tsums to 16-bits", "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The VC4 ISP uses a pipeline bit-depth of 13-bits. The AGC algorithm needs to\nknow this bit-depth when computing the Y value for the image.\n\nInstead of hardcoding the VC4 bit-depth in the AGC source code, normalise all\nregion sums to 16-bits when filling the Statistics structure. AWB and ALSC are\nagonistic about pipline depth, so do not need chaning.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 10 ++++------\n src/ipa/raspberrypi/raspberrypi.cpp | 21 ++++++++++++++-------\n 2 files changed, 18 insertions(+), 13 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex 79c83e0a9eae..358af8f2544b 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -28,8 +28,6 @@ LOG_DEFINE_CATEGORY(RPiAgc)\n \n #define NAME \"rpi.agc\"\n \n-static constexpr unsigned int PipelineBits = 13; /* seems to be a 13-bit pipeline */\n-\n int AgcMeteringMode::read(const libcamera::YamlObject ¶ms)\n {\n \tconst YamlObject &yamlWeights = params[\"weights\"];\n@@ -593,9 +591,9 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,\n \tfor (unsigned int i = 0; i < stats->agcRegions.numRegions(); i++) {\n \t\tuint32_t counted, uncounted;\n \t\tauto s = stats->agcRegions.get(i, counted, uncounted);\n-\t\tdouble rAcc = std::min<double>(s.rSum * gain, ((1 << PipelineBits) - 1) * counted);\n-\t\tdouble gAcc = std::min<double>(s.gSum * gain, ((1 << PipelineBits) - 1) * counted);\n-\t\tdouble bAcc = std::min<double>(s.bSum * gain, ((1 << PipelineBits) - 1) * counted);\n+\t\tdouble rAcc = std::min<double>(s.rSum * gain, ((1 << 16) - 1) * counted);\n+\t\tdouble gAcc = std::min<double>(s.gSum * gain, ((1 << 16) - 1) * counted);\n+\t\tdouble bAcc = std::min<double>(s.bSum * gain, ((1 << 16) - 1) * counted);\n \t\trSum += rAcc * weights[i];\n \t\tgSum += gAcc * weights[i];\n \t\tbSum += bAcc * weights[i];\n@@ -608,7 +606,7 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,\n \tdouble ySum = rSum * awb.gainR * .299 +\n \t\t gSum * awb.gainG * .587 +\n \t\t bSum * awb.gainB * .114;\n-\treturn ySum / pixelSum / (1 << PipelineBits);\n+\treturn ySum / pixelSum / (1 << 16);\n }\n \n /*\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 8fcfa0b3ea50..fcecd60bcf6d 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1132,19 +1132,26 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\n \t/* RGB histograms are not used, so do not populate them. */\n \tstatistics->yHist = std::move(RPiController::Histogram(stats->hist[0].g_hist, NUM_HISTOGRAM_BINS));\n \n+\t/*\n+\t * All region sums are based on a 13-bit pipeline bit-depth. Normalise\n+\t * this to 16-bits for the AGC/AWB/ALSC algorithms.\n+\t */\n \tstatistics->awbRegions.init(DEFAULT_AWB_REGIONS_X, DEFAULT_AWB_REGIONS_Y);\n \tfor (i = 0; i < statistics->awbRegions.numRegions(); i++)\n-\t\tstatistics->awbRegions.set(i, { stats->awb_stats[i].r_sum,\n-\t\t\t\t\t\tstats->awb_stats[i].g_sum,\n-\t\t\t\t\t\tstats->awb_stats[i].b_sum },\n+\t\tstatistics->awbRegions.set(i, { stats->awb_stats[i].r_sum << 3,\n+\t\t\t\t\t\tstats->awb_stats[i].g_sum << 3,\n+\t\t\t\t\t\tstats->awb_stats[i].b_sum << 3 },\n \t\t\t\t\t stats->awb_stats[i].counted, stats->awb_stats[i].notcounted);\n \n-\t/* There are only ever 15 regions computed by the firmware, but the HW defines AGC_REGIONS == 16! */\n+\t/*\n+\t * There are only ever 15 regions computed by the firmware due to zoning,\n+\t * but the HW defines AGC_REGIONS == 16!\n+\t */\n \tstatistics->agcRegions.init(15);\n \tfor (i = 0; i < statistics->agcRegions.numRegions(); i++)\n-\t\tstatistics->agcRegions.set(i, { stats->agc_stats[i].r_sum,\n-\t\t\t\t\t\tstats->agc_stats[i].g_sum,\n-\t\t\t\t\t\tstats->agc_stats[i].b_sum },\n+\t\tstatistics->agcRegions.set(i, { stats->agc_stats[i].r_sum << 3,\n+\t\t\t\t\t\tstats->agc_stats[i].g_sum << 3,\n+\t\t\t\t\t\tstats->agc_stats[i].b_sum << 3 },\n \t\t\t\t\t stats->agc_stats[i].counted, 0);\n \n \tstatistics->focusRegions.init(4, 3);\n", "prefixes": [ "libcamera-devel", "v1", "5/5" ] }