Patch Detail
Show a patch.
GET /api/patches/13902/?format=api
{ "id": 13902, "url": "https://patchwork.libcamera.org/api/patches/13902/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13902/", "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": "<20210923081625.60276-12-jeanmichel.hautbois@ideasonboard.com>", "date": "2021-09-23T08:16:24", "name": "[libcamera-devel,11/12] ipa: ipu3: agc: Rewrite and simplify the brightness loop", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "57d1c712eead427a10f744f4a505d7c43bcf2fc0", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13902/mbox/", "series": [ { "id": 2548, "url": "https://patchwork.libcamera.org/api/series/2548/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2548", "date": "2021-09-23T08:16:13", "name": "Improve ImgU statistics usage", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2548/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13902/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13902/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 A09C3BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Sep 2021 08:16:45 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E7AB6918A;\n\tThu, 23 Sep 2021 10:16:45 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DD0B6919B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Sep 2021 10:16:32 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:392e:dcd2:2bf6:d61c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1F35345E;\n\tThu, 23 Sep 2021 10:16:32 +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=\"XlLGokvp\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632384992;\n\tbh=1+qVrKTyOdcy2B4Wx7mj6SrfOSCsBrFI/cjkk98t5/0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XlLGokvpwBd7QdYMgUixI6ItRbm5prekzTinwLpkovasi/6szFUhSp578WJ5JvHDs\n\tFvalBuR3uZ8B0ABhWgtkFunqOFLQfi3Nv/pW2qeKPXsulrhqsqC12SrIaHy4gHEjvN\n\tpAH7KxCfihhdGYOOdgKUZ0qclakF759JG8BONNDk=", "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 23 Sep 2021 10:16:24 +0200", "Message-Id": "<20210923081625.60276-12-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210923081625.60276-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20210923081625.60276-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 11/12] ipa: ipu3: agc: Rewrite and\n\tsimplify the brightness loop", "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": "Now that we know how exactly the AWB statistics are formatted, use a\nsimplified loop in processBrightness() to parse the green values and get the\nhistogram.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 54 +++++++++++++--------------------\n src/ipa/ipu3/algorithms/agc.h | 2 ++\n 2 files changed, 23 insertions(+), 33 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 5ff50f4a..ebbc5676 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -6,6 +6,7 @@\n */\n \n #include \"agc.h\"\n+#include \"awb.h\"\n \n #include <algorithm>\n #include <chrono>\n@@ -47,9 +48,6 @@ static constexpr uint32_t kMaxExposure = 1976;\n static constexpr uint32_t knumHistogramBins = 256;\n static constexpr double kEvGainTarget = 0.5;\n \n-/* A cell is 8 bytes and contains averages for RGB values and saturation ratio */\n-static constexpr uint8_t kCellSize = 8;\n-\n Agc::Agc()\n \t: frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n \t maxExposureTime_(0s), prevExposure_(0s), prevExposureNoDg_(0s),\n@@ -60,6 +58,10 @@ Agc::Agc()\n int Agc::configure([[maybe_unused]] IPAContext &context,\n \t\t const IPAConfigInfo &configInfo)\n {\n+\tconst ipu3_uapi_grid_config &grid = context.configuration.grid.bdsGrid;\n+\t/* The grid is aligned to the next multiple of 4 */\n+\tstride_ = (grid.width + 3) / 4 * 4;\n+\n \tlineDuration_ = configInfo.sensorInfo.lineLength * 1.0s\n \t\t / configInfo.sensorInfo.pixelRate;\n \tmaxExposureTime_ = kMaxExposure * lineDuration_;\n@@ -70,37 +72,23 @@ int Agc::configure([[maybe_unused]] IPAContext &context,\n void Agc::processBrightness(const ipu3_uapi_stats_3a *stats,\n \t\t\t const ipu3_uapi_grid_config &grid)\n {\n-\tconst struct ipu3_uapi_grid_config statsAeGrid = stats->stats_4a_config.awb_config.grid;\n-\tRectangle aeRegion = { statsAeGrid.x_start,\n-\t\t\t statsAeGrid.y_start,\n-\t\t\t static_cast<unsigned int>(statsAeGrid.x_end - statsAeGrid.x_start) + 1,\n-\t\t\t static_cast<unsigned int>(statsAeGrid.y_end - statsAeGrid.y_start) + 1 };\n-\tPoint topleft = aeRegion.topLeft();\n-\tint topleftX = topleft.x >> grid.block_width_log2;\n-\tint topleftY = topleft.y >> grid.block_height_log2;\n-\n-\t/* Align to the grid cell width and height */\n-\tuint32_t startX = topleftX << grid.block_width_log2;\n-\tuint32_t startY = topleftY * grid.width << grid.block_width_log2;\n-\tuint32_t endX = (startX + (aeRegion.size().width >> grid.block_width_log2)) << grid.block_width_log2;\n-\tuint32_t i, j;\n-\tuint32_t count = 0;\n-\n \tuint32_t hist[knumHistogramBins] = { 0 };\n-\tfor (j = topleftY;\n-\t j < topleftY + (aeRegion.size().height >> grid.block_height_log2);\n-\t j++) {\n-\t\tfor (i = startX + startY; i < endX + startY; i += kCellSize) {\n-\t\t\t/*\n-\t\t\t * The grid width (and maybe height) is not reliable.\n-\t\t\t * We observed a bit shift which makes the value 160 to be 32 in the stats grid.\n-\t\t\t * Use the one passed at init time.\n-\t\t\t */\n-\t\t\tif (stats->awb_raw_buffer.meta_data[i + 4 + j * grid.width] == 0) {\n-\t\t\t\tuint8_t Gr = stats->awb_raw_buffer.meta_data[i + 0 + j * grid.width];\n-\t\t\t\tuint8_t Gb = stats->awb_raw_buffer.meta_data[i + 3 + j * grid.width];\n-\t\t\t\thist[(Gr + Gb) / 2]++;\n-\t\t\t\tcount++;\n+\n+\tfor (unsigned int cellY = 0; cellY < grid.height; cellY++) {\n+\t\tfor (unsigned int cellX = 0; cellX < stride_; cellX++) {\n+\t\t\tuint32_t cellPosition = cellY * stride_ + cellX\n+\t\t\t\t\t * sizeof(Ipu3AwbCell);\n+\n+\t\t\t/* Cast the initial IPU3 structure to simplify the reading */\n+\t\t\tconst Ipu3AwbCell *cell =\n+\t\t\t\treinterpret_cast<const Ipu3AwbCell *>(\n+\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]\n+\t\t\t\t);\n+\n+\t\t\tif (cell->satRatio == 0) {\n+\t\t\t\tuint8_t gr = cell->greenRedAvg;\n+\t\t\t\tuint8_t gb = cell->greenBlueAvg;\n+\t\t\t\thist[(gr + gb) / 2]++;\n \t\t\t}\n \t\t}\n \t}\ndiff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\nindex e36797d3..64b71c65 100644\n--- a/src/ipa/ipu3/algorithms/agc.h\n+++ b/src/ipa/ipu3/algorithms/agc.h\n@@ -50,6 +50,8 @@ private:\n \tDuration prevExposureNoDg_;\n \tDuration currentExposure_;\n \tDuration currentExposureNoDg_;\n+\n+\tuint32_t stride_;\n };\n \n } /* namespace ipa::ipu3::algorithms */\n", "prefixes": [ "libcamera-devel", "11/12" ] }