Patch Detail
Show a patch.
GET /api/1.1/patches/18000/?format=api
{ "id": 18000, "url": "https://patchwork.libcamera.org/api/1.1/patches/18000/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18000/", "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": "<20221213114836.15473-6-naush@raspberrypi.com>", "date": "2022-12-13T11:48:36", "name": "[libcamera-devel,v3,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/18000/mbox/", "series": [ { "id": 3670, "url": "https://patchwork.libcamera.org/api/1.1/series/3670/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3670", "date": "2022-12-13T11:48:31", "name": "Raspberry Pi: Generalise statistics", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3670/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18000/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18000/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 DDD06BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Dec 2022 11:48:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4AA26336B;\n\tTue, 13 Dec 2022 12:48:54 +0100 (CET)", "from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB6F163364\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Dec 2022 12:48:51 +0100 (CET)", "by mail-wr1-x430.google.com with SMTP id i7so691759wrv.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Dec 2022 03:48:51 -0800 (PST)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tj8-20020a5d4528000000b0024287d9d4a8sm11574541wra.74.2022.12.13.03.48.50\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 13 Dec 2022 03:48:50 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670932134;\n\tbh=WCd5Yg2ao//5cMiTWI7RL+O49Lp+oN5KbKipJ45uZ20=;\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=utLrL6MqrjLxGawt8JEZBTS3EXI0GzeELX3GmY+p+fCckWQoNYfS7Y4tsuaDSsFG2\n\t/DbjMOCDuxi2LmE86JeS+VNSPEe2TAGoFQxAQYUmOHg6URY+x0o7k/T2ow790eyDFv\n\tKWLFXXOkTBTDB5USpGImE4ngVMfMui8aelSGhixQJmuzDUpXdBugYbPj+ucCFXpORI\n\t3UHrzUhHlI96mtc5u+UV83TcYQ5vb6BzAoq+DmPGmj54do+hWmPcjPJJBaFCFaylJZ\n\tx4ahB61C+Rw81dgZ2YS8SWgAYGw+Zque0ngZ+PATP4jUbshJV+xMbLYfO3fNEsRrZ6\n\tNYMd2zjQL7YOw==", "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=FaD2be+yF2ADNeJbCXDRJDi2/VL2T516BxJINXKCmzU=;\n\tb=q/fWJoBymzUZHc6DKcKhCEf9HsIsm5E5VAUleIx3Dxh2sGxcywexv2niDkVbDPoUIj\n\tP27JMh6ajBXZQBfcIwqOgA/SCm7FdaK2L1XgZMSiCpPEwVYoSp0XGKtv18+ZQ/Zy1Z1w\n\tpXmCuBossnBlbu4BChpvYsixUWh/9N4aHymhGDFJPvnED3qYrvZhX0CpJyoXdboCOMfB\n\tx9Pq9F7TUk6n59Aib2yEw1++DwQ/sjp+qio25ggJvnbCr7SoRZYkhLtTQ4aSF11aFhRE\n\tINY9c8gVJx9QMtBS6CIUrT22o4pd+EOkaY2+CET9OR/oDI6FiUKiDxh3IwE63qC8FiWT\n\tAVSQ==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"q/fWJoBy\"; 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=FaD2be+yF2ADNeJbCXDRJDi2/VL2T516BxJINXKCmzU=;\n\tb=5ZIIBQehTwRhKEOm2S1YYfAXZnyupCTMcGcv4Si9+jEsQhEAYhlXOwU+DSiNjiBrZv\n\tz5wOZrKpJ1njzq1aGpqdGluS8w5rN3bgg7OSI9MstYvkH+0TsaT/5DRG0ILLQxAn5Jnm\n\tf7X9i9sJkwo9acmnGRKytOJ69n98fAce2Dd0TtAq/O4ehbC1hrNBRoXSYVsrJLIqeD58\n\t7SwUIbzLq30GaHmQfDapN/OA6E6hUrwRBpu42y3Gi5zisQ7ds2HRSRF+oOv8HufWY+oy\n\tP9moX/nwWIxeWOBJMKkVNOxn+F/A6u7OJCMNmh2ZoocCSgH0hAGI2rjIyis18wzLXvAo\n\tb9cQ==", "X-Gm-Message-State": "ANoB5pkhVLJfIV9FMflZCQo58xjHeUqRu9gC5KtTDrSfRXzV4XkV74NU\n\t+UuUIhJzz9Wyln39M8T1z3RN6oI79YTBQo4j", "X-Google-Smtp-Source": "AA0mqf75dQdM6gw9cfiZc+Z/779n+ldVMgptmeuTECkh5DrFSJJOIegVLwTe0Pi1pf0z9u3WgJs+3Q==", "X-Received": "by 2002:adf:a193:0:b0:246:e6df:86ea with SMTP id\n\tu19-20020adfa193000000b00246e6df86eamr13618219wru.25.1670932131289; \n\tTue, 13 Dec 2022 03:48:51 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 13 Dec 2022 11:48:36 +0000", "Message-Id": "<20221213114836.15473-6-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221213114836.15473-1-naush@raspberrypi.com>", "References": "<20221213114836.15473-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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 868c30f03d66..7ec8292d32ff 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 \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@@ -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 cff079bbafb3..50fdeb4f0478 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1154,11 +1154,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@@ -1168,9 +1172,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", "v3", "5/5" ] }