Show a patch.

GET /api/1.1/patches/14063/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14063,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14063/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14063/",
    "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": "<20211006140041.964542-12-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-10-06T14:00:41",
    "name": "[libcamera-devel,v3,11/12] ipa: ipu3: agc: Rewrite and simplify the brightness loop",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "61b5b5fc98bf711ee0aac2954ab41d8060a7bbd3",
    "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/14063/mbox/",
    "series": [
        {
            "id": 2605,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2605/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2605",
            "date": "2021-10-06T14:00:30",
            "name": "Improve ImgU statistics usage",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2605/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14063/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14063/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 03A21C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Oct 2021 14:01:12 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C53D8691BD;\n\tWed,  6 Oct 2021 16:01:11 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7455C691C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Oct 2021 16:01:03 +0200 (CEST)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:843b:c831:54de:6e8c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBCF51B40;\n\tWed,  6 Oct 2021 16:01:02 +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=\"F1HD3mKl\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633528863;\n\tbh=RCQm71BtPRF8XwombeKR8j13lqIYjNbSGR++XWfr/cM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=F1HD3mKl+zgmy5YatsennODyxWDBQK2q6zASi7Z63OYpvE6ICHFEsWdk0+lNP2Hm6\n\t2g6c/Y85zLyZI7tD46pI1fMMQRq349tWV/HfkxJkeHN0lRxlgMZDUq463fn4XXTVkz\n\tOTKd505kI1QogNAsKUUDZXYTvo4DHEWu6hGXimgY=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  6 Oct 2021 16:00:41 +0200",
        "Message-Id": "<20211006140041.964542-12-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20211006140041.964542-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20211006140041.964542-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 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 the AWB statistics are formatted, use a simplified\nloop in processBrightness() to parse the green values and get the\nhistogram.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 54 ++++++++++++---------------------\n src/ipa/ipu3/algorithms/agc.h   |  2 ++\n 2 files changed, 21 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 5ff50f4a..4f0d16c6 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@@ -57,9 +55,10 @@ Agc::Agc()\n {\n }\n \n-int Agc::configure([[maybe_unused]] IPAContext &context,\n-\t\t   const IPAConfigInfo &configInfo)\n+int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n {\n+\tstride_ = context.configuration.grid.stride;\n+\n \tlineDuration_ = configInfo.sensorInfo.lineLength * 1.0s\n \t\t      / configInfo.sensorInfo.pixelRate;\n \tmaxExposureTime_ = kMaxExposure * lineDuration_;\n@@ -70,37 +69,22 @@ 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 < grid.width; cellX++) {\n+\t\t\tuint32_t cellPosition = (cellY * stride_ + cellX)\n+\t\t\t\t\t      * sizeof(Ipu3AwbCell);\n+\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",
        "v3",
        "11/12"
    ]
}