Patch Detail
Show a patch.
GET /api/1.1/patches/17866/?format=api
{ "id": 17866, "url": "https://patchwork.libcamera.org/api/1.1/patches/17866/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17866/", "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": "<20221124103832.6172-6-naush@raspberrypi.com>", "date": "2022-11-24T10:38:32", "name": "[libcamera-devel,v2,5/5] ipa: raspberrypi: Normalise region sums to 16-bits", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "66c0e1507e72b79aa31a71cc94413305215b880b", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17866/mbox/", "series": [ { "id": 3635, "url": "https://patchwork.libcamera.org/api/1.1/series/3635/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3635", "date": "2022-11-24T10:38:27", "name": "Raspberry Pi: Generalise statistics", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3635/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17866/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17866/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 98B7BBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 10:38:48 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 500E66331B;\n\tThu, 24 Nov 2022 11:38:48 +0100 (CET)", "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB78363325\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 11:38:43 +0100 (CET)", "by mail-wr1-x42f.google.com with SMTP id bs21so1858225wrb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 02:38:43 -0800 (PST)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ts16-20020adff810000000b002368a6deaf8sm995103wrp.57.2022.11.24.02.38.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 24 Nov 2022 02:38:42 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669286328;\n\tbh=sTGi7RgxaxNbxoWSQSrBl7HG/qhIfv5sSuH0VB65uFY=;\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=gfGeBlK/DMF0aBm169KN8rlPTClmlCKAkZatj3jY3TNLJNJsj829UFIJvTNiaDAGb\n\tDCGc7Pbgnlr7TdbRP8gcBdJRfwo1VyozQyDFuqT/k4foKCPAcZJNITDBIqaisD+nvE\n\tGmr/r8KY2jFJyEp2bBSb+Pqya/B0+Z67yKI0+XxbYwt/mwAgyc0GHgjNc5jntsnWZ2\n\ttQ0nJTPZEFWlYxr6r6qxDOdfAsHoJG+uwYRSVvf1kYcwGLjXm4Bob3jjV8mxoWJdNi\n\tyPUKMWlKMuxanW/Dq3Z/n9bBuuOJdN8FTxhgDDFwgnQhi88sLs+rv6drsQHVADp9v8\n\t52j+zOUyzwE7Q==", "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=p1mDNy10gWoZUW3LMkb06Ux8rbvmE8YDIyd+biq7Yk0=;\n\tb=X8Dbr3vyosce7VXOkrNCZnu3OEldS1CUgJ/ZpBT33DvRaMaNo/ScJDZ2Zd7bzlDo6o\n\tMYLeTN7MIw/zwlOKj4vgQ7Cq/Pq5RwczXetTVQsxmm5Dip1ukqJCOVVPhmHcoV/UFu26\n\tOi3MD/9Mlo6P2Hs12vFyi9LzLtEs+Jn0QpLZ/h0qCHJg3AyNttrIG+Q0gPNaxp9KrWZi\n\t87uWnEEesyjBceAiAXzgLY2Blx/tcyEUZWSkxmehdv5Is1esQ9WlUXkUkagZxv6FmwB5\n\tN1RFYmh25w9kuqsAU8ERNwOjVir65a25/qQGzTZPOEe3uVFf7TdpOZTpkjgv5vhoAeXG\n\tuNzw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"X8Dbr3vy\"; 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=p1mDNy10gWoZUW3LMkb06Ux8rbvmE8YDIyd+biq7Yk0=;\n\tb=BRMS6OZQ1If7jcBFlzG0bTB8ifrpZk07aqcN7bzNk2kCIxjwqxT/mov979QvTuq1tY\n\tTIUtcGyx/3GT3fYZouxLLefJ7uLTX7VgjbC1GDN55OGjsaPWxM0qq73Av+BObQd9jFrT\n\tvJEuwQnFugfAThXCPX5Jh5PirSTXJbY0aYFB64gOy/y2k8K/S0PkuBU6o5IbwDg5VGG6\n\tYzEBWdBiuzqfqz01fQZAQOndHIt8s6gShEl4MavY4eG4xcqBsVKCaR3GjiuS7sZmA6Yq\n\t1KyaohrmQsKViTvEMgI1RawTRVQjvW7wTK2qxjUzCI6GDgWDGmxrZZvAVjvViAPS6XNE\n\trotQ==", "X-Gm-Message-State": "ANoB5plbHnKpVNx4KhlYb59sK779Uvc52ToeSzxqsgp+FjLxeAvY8+7q\n\t7kDxC5nIedJWSyzO07RWuEEWsFscNW6CDQ==", "X-Google-Smtp-Source": "AA0mqf494r2jvx462NG0h5HZUl4zV+rzNvbpeJJBemn7q7BlLDmgNBWer05iUfcCZ9ghtwqI6MJQOg==", "X-Received": "by 2002:a5d:68c1:0:b0:236:8a38:4deb with SMTP id\n\tp1-20020a5d68c1000000b002368a384debmr19629002wrw.487.1669286323204; \n\tThu, 24 Nov 2022 02:38:43 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 24 Nov 2022 10:38:32 +0000", "Message-Id": "<20221124103832.6172-6-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221124103832.6172-1-naush@raspberrypi.com>", "References": "<20221124103832.6172-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 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\nagnostic about pipeline depth, so do not need changing.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 10 ++++------\n src/ipa/raspberrypi/raspberrypi.cpp | 16 ++++++++++------\n 2 files changed, 14 insertions(+), 12 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex a7f0e954407d..e400e478162f 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@@ -592,9 +590,9 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,\n \tdouble rSum = 0, gSum = 0, bSum = 0, pixelSum = 0;\n \tfor (unsigned int i = 0; i < stats->agcRegions.numRegions(); i++) {\n \t\tauto ®ion = stats->agcRegions.get(i);\n-\t\tdouble rAcc = std::min<double>(region.val.rSum * gain, ((1 << PipelineBits) - 1) * region.counted);\n-\t\tdouble gAcc = std::min<double>(region.val.gSum * gain, ((1 << PipelineBits) - 1) * region.counted);\n-\t\tdouble bAcc = std::min<double>(region.val.bSum * gain, ((1 << PipelineBits) - 1) * region.counted);\n+\t\tdouble rAcc = std::min<double>(region.val.rSum * gain, ((1 << 16) - 1) * region.counted);\n+\t\tdouble gAcc = std::min<double>(region.val.gSum * gain, ((1 << 16) - 1) * region.counted);\n+\t\tdouble bAcc = std::min<double>(region.val.bSum * gain, ((1 << 16) - 1) * region.counted);\n \t\trSum += rAcc * weights[i];\n \t\tgSum += gAcc * weights[i];\n \t\tbSum += bAcc * weights[i];\n@@ -607,7 +605,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 44527357243d..ac1875d203ae 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1132,11 +1132,15 @@ 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\t stats->awb_stats[i].g_sum,\n-\t\t\t\t\t\t stats->awb_stats[i].b_sum },\n+\t\tstatistics->awbRegions.set(i, { { stats->awb_stats[i].r_sum << 3,\n+\t\t\t\t\t\t stats->awb_stats[i].g_sum << 3,\n+\t\t\t\t\t\t stats->awb_stats[i].b_sum << 3 },\n \t\t\t\t\t\tstats->awb_stats[i].counted,\n \t\t\t\t\t\tstats->awb_stats[i].notcounted });\n \n@@ -1146,9 +1150,9 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\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\t stats->agc_stats[i].g_sum,\n-\t\t\t\t\t\t stats->agc_stats[i].b_sum },\n+\t\tstatistics->agcRegions.set(i, { { stats->agc_stats[i].r_sum << 3,\n+\t\t\t\t\t\t stats->agc_stats[i].g_sum << 3,\n+\t\t\t\t\t\t stats->agc_stats[i].b_sum << 3 },\n \t\t\t\t\t\tstats->agc_stats[i].counted,\n \t\t\t\t\t\tstats->awb_stats[i].notcounted });\n \n", "prefixes": [ "libcamera-devel", "v2", "5/5" ] }