Patch Detail
Show a patch.
GET /api/patches/26663/?format=api
{ "id": 26663, "url": "https://patchwork.libcamera.org/api/patches/26663/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26663/", "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": "<20260506230722.1041596-7-devve.3@gmail.com>", "date": "2026-05-06T23:07:18", "name": "[v2,06/10] libcamera: software_isp: Normalize statistics sums to 8-bit", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "36c2c7766837054af0cca7c964f5cd537e5b7907", "submitter": { "id": 271, "url": "https://patchwork.libcamera.org/api/people/271/?format=api", "name": "devve", "email": "devve.3@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26663/mbox/", "series": [ { "id": 5915, "url": "https://patchwork.libcamera.org/api/series/5915/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5915", "date": "2026-05-06T23:07:12", "name": "OV01A10 sensor support and simple IPA improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5915/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26663/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26663/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 16D69C3303\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 6 May 2026 23:07:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CAF1A630BB;\n\tThu, 7 May 2026 01:07:37 +0200 (CEST)", "from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com\n\t[IPv6:2607:f8b0:4864:20::72f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC7D16303C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 7 May 2026 01:07:33 +0200 (CEST)", "by mail-qk1-x72f.google.com with SMTP id\n\taf79cd13be357-8d6d5e45c43so26538485a.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 May 2026 16:07:33 -0700 (PDT)", "from dexps.speedport.ip\n\t(p200300eda74453cf3cf3f7929e513b94.dip0.t-ipconnect.de.\n\t[2003:ed:a744:53cf:3cf3:f792:9e51:3b94])\n\tby smtp.gmail.com with ESMTPSA id\n\taf79cd13be357-8fc2c25324esm2035266385a.23.2026.05.06.16.07.31\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 06 May 2026 16:07:32 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"LCoBA+YH\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20251104; t=1778108853; x=1778713653;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=ANVPg7VR/jgoiN08fPKUsvHJnWWyqQ90OtjRAf9XFxo=;\n\tb=LCoBA+YH38KGgrhMeYE0Gv0ax5e0GYrslyQTqphthDwtB922cUGqJtC5LlM6T3Kq3E\n\t4Cw895OhdaxO3Gm5J6ABJKXcdvKBl2UDN/rP/GKFzIgYBpPmE7ENwChpaugA34LsDPkn\n\tos+NVxM7E31b55t101sOZ2jeb68yiDSY07D3sFChpvXkIcrvsRzrAcv+YAk50IZ65DT3\n\t0o64sZqcrSpUwQyb5jGj0UvOBZZfJPqbJFXTSN7IHxl5ChAAR/GQXn4RPQmf9ORsBm4X\n\tMqEgT0D6dx3h3askibqpOcKKsJTi5XP1jYXiXPtGXEW0FCZxodpyg8R7naQ7odTUH1w8\n\tX9hQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1778108853; x=1778713653;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to\n\t:cc:subject:date:message-id:reply-to;\n\tbh=ANVPg7VR/jgoiN08fPKUsvHJnWWyqQ90OtjRAf9XFxo=;\n\tb=FPCTe/0ovqki5IvHE0oin0v9bd1Glrp4p5IFTARZYHNEQr7yKMJMHi09AuwO6hrdt8\n\thT40wGUV/At57HI01YkCcxJYxDXZ2GfXjoufJLdnCgKPeCjAL20dnGAQy6ODMaZU1aeV\n\tnZ/EbeuUSSoq5VussOBM3YnDwavKU/fXCtsCsFfhHAa7/J0th7xOQkl+zdB0EIPEjYck\n\tXTFFFU9wNyK9Gcer/gsBAXaG86D50Lv+uLMihH36BjAIIakixjXflRkedX4ohU/ytrsm\n\tiR4Cy1R7YzjLW0js0iESHAeO/P3NvSkUuFnU00dZjVLuZ7P9zYPFmu3RgbtmF/4U9IeM\n\tpQnw==", "X-Gm-Message-State": "AOJu0Yz+UCriO52Z5K5V248Z1UOoM5sVa1UbR5TA6XL/F6UjquFPXykh\n\t8G01b6A5PgS0qyS2QUjNrbZ0Ifu9hiJbpwTmDWU2yV1MY+DqLYjMjFoSmWWeEw==", "X-Gm-Gg": "AeBDieuFcP3iaA5bC9d97ydgFjytMmL3HhHnI9mntWdMnadrsrW/esIjAjRT/bY6jVw\n\tiJHys/Lf/LVEtlBdPAstpMBnTJZAee4Le4dywb24In1daWH7wBwjrTBXPBDaYKrpUoY2DxC1VgM\n\tlYx8S328kP1p5AtehRkOkoIUu7DTM0vwIdScc2VS/44hKojqQt96eu6o68KfXq3R7+RCL8Teguw\n\tN13JUSNSF8VTlQuXq/YW+FEbHI1dOBRb7TktyWc0ONmgSSYoecqXwsv5iETewkPZtw/qSmNF7T5\n\taPO/PFcdYEXfj8dW30KNgp1d/7WTyKMIr88mrr/Gi+kqi5Ys2SHB50GEOyrFP6bTp1i9l8jI/8m\n\tAJSExotYiuaa8X3m+6jBsaDdaaEIu+kQU56rlhpNTUXPnPPSwb1co6Pr9hePWhut3q4OhrYev1/\n\teP2Kvua3Rmj7zWoxS1ZE4SPNJp7wsyyG/+Fd8z++Dkkv8teJca9RhyLEtmJyiLQWZgPXd/95XUo\n\tpYgEV7WuDM3adtwTaO8Pp5c/eNHo0my", "X-Received": "by 2002:a05:620a:408e:b0:8ee:30e:cb97 with SMTP id\n\taf79cd13be357-904d4a61c65mr785228685a.21.1778108852492; \n\tWed, 06 May 2026 16:07:32 -0700 (PDT)", "From": "d3vv3 <devve.3@gmail.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v2 06/10] libcamera: software_isp: Normalize statistics sums\n\tto 8-bit", "Date": "Thu, 7 May 2026 01:07:18 +0200", "Message-ID": "<20260506230722.1041596-7-devve.3@gmail.com>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260506230722.1041596-1-devve.3@gmail.com>", "References": "<20260506230722.1041596-1-devve.3@gmail.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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": "From: Javier Tia <floss@jetm.me>\n\nThe SWSTATS_ACCUMULATE_LINE_STATS() macro divides the luminance value\nfor the histogram to normalize it to 8-bit range, but does not apply\nthe same normalization to the RGB sums. For 10-bit and 12-bit unpacked\nBayer formats this means the sums are accumulated at native bit depth\n(0-1023 or 0-4095 per pixel) while the AWB algorithm subtracts an\n8-bit black level from them, under-correcting by 4x or 16x\nrespectively.\nFix this by right-shifting the RGB sums in finishFrame() to normalize\nthem to 8-bit scale, matching the histogram and the 8-bit black level\nused by AWB. A per-format sumShift_ value is set in configure():\n0 for 8-bit and CSI-2 packed formats (already 8-bit), 2 for 10-bit,\nand 4 for 12-bit unpacked formats.\nSigned-off-by: Javier Tia <floss@jetm.me>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nTested-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nTested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nSigned-off-by: d3vv3 <devve.3@gmail.com>\n---\n include/libcamera/internal/software_isp/swstats_cpu.h | 1 +\n src/libcamera/software_isp/swstats_cpu.cpp | 7 +++++++\n 2 files changed, 8 insertions(+)", "diff": "diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\nindex 802370bd..2dac6945 100644\n--- a/include/libcamera/internal/software_isp/swstats_cpu.h\n+++ b/include/libcamera/internal/software_isp/swstats_cpu.h\n@@ -116,6 +116,7 @@ private:\n \n \tunsigned int xShift_;\n \tunsigned int stride_;\n+\tunsigned int sumShift_;\n \n \tstd::vector<SwIspStats> stats_;\n \tSharedMemObject<SwIspStats> sharedStats_;\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 5366e019..2ed906e1 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -362,6 +362,11 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)\n \t\t\tfor (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++)\n \t\t\t\tsharedStats_->yHistogram[j] += s.yHistogram[j];\n \t\t}\n+\t\tif (sumShift_) {\n+\t\t\tsharedStats_->sum_.r() >>= sumShift_;\n+\t\t\tsharedStats_->sum_.g() >>= sumShift_;\n+\t\t\tsharedStats_->sum_.b() >>= sumShift_;\n+\t\t}\n \t}\n \n \tsharedStats_->valid = valid;\n@@ -422,6 +427,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat\n \tif (bayerFormat.packing == BayerFormat::Packing::None &&\n \t setupStandardBayerOrder(bayerFormat.order) == 0) {\n \t\tprocessFrame_ = &SwStatsCpu::processBayerFrame2;\n+\t\tsumShift_ = bayerFormat.bitDepth - 8;\n \t\tswitch (bayerFormat.bitDepth) {\n \t\tcase 8:\n \t\t\tstats0_ = &SwStatsCpu::statsBGGR8Line0;\n@@ -442,6 +448,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int stat\n \t\t/* Skip every 3th and 4th line, sample every other 2x2 block */\n \t\tySkipMask_ = 0x02;\n \t\txShift_ = 0;\n+\t\tsumShift_ = 0;\n \t\tprocessFrame_ = &SwStatsCpu::processBayerFrame2;\n \n \t\tswitch (bayerFormat.order) {\n", "prefixes": [ "v2", "06/10" ] }