Patch Detail
Show a patch.
GET /api/patches/26656/?format=api
{ "id": 26656, "url": "https://patchwork.libcamera.org/api/patches/26656/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26656/", "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": "<20260506230649.1040794-7-devve.3@gmail.com>", "date": "2026-05-06T23:06:45", "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/26656/mbox/", "series": [ { "id": 5914, "url": "https://patchwork.libcamera.org/api/series/5914/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5914", "date": "2026-05-06T23:06:39", "name": "OV01A10 sensor support and simple IPA improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5914/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26656/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26656/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 E237EC32FB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 6 May 2026 23:07:08 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 635116302F;\n\tThu, 7 May 2026 01:07:02 +0200 (CEST)", "from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33BC363025\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 7 May 2026 01:06:53 +0200 (CEST)", "by mail-wm1-x32e.google.com with SMTP id\n\t5b1f17b1804b1-488a8ca4aadso2087445e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 06 May 2026 16:06:53 -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\t5b1f17b1804b1-48e538a547bsm85951935e9.5.2026.05.06.16.06.52\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:06:52 -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=\"YpC9thUs\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20251104; t=1778108813; x=1778713613;\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=YpC9thUsGro8sLSmKRWLMYPstbZmHs1D2nJ6VZNjNn07Mwr3Px28b2lVzjYQ5OpaBJ\n\tJHmR7Ins111cX2NFDhav5MiktIhNFAoaNKc2ZDkbw2+NGH3rkmolaBdOj0oPFVLDQ7R4\n\t37z10eYhFpLqGpQPdqKTNyDY0tiP9ebUTsOPmXYPtPyM0456ztjxsvCsPRr9q6rnBRuM\n\tKU+xTjmxaia+YAClXzioXhwpsSirycK5kh/axwZNyW9wXMoV+yURhmL63yxEjCAUBUTk\n\tGj3R5cvojsiDUoZDwCijUv4+3YM8lIgnJzmN3AlX1uGZfAS8MxruqlI24QEjImRTzvNC\n\ti9Yw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1778108813; x=1778713613;\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=PsiHexaxQ/gHGyTPeF7pq0Em41BlEB2Zza31MAYpJ05llBhlESm0fp+gID08CfJL1r\n\t3QaPyKFn46dEc4UCIcrLTRkKhQCkLnT7hhU4RC4DL4scqrP03cECymp3CwLfW+gPFDVs\n\tw2BEz8VlZbvVdtQqgFfXhJWOYTIyYdOvPpIrvP+y1/b/AT62PzNu/cmDSyNbuJ8yoSj1\n\t2Nw8LJu/waluS10nxZSFMZiq6U86sEvH9pFLL8v8Z/NjZPQ9J+mMBiY72J3cm3WGNeRC\n\tO27ynpc2+U+/9EusqvvaG0aCpy7fSRl1IZaklcoGAYzY5OmnJv7BdU9kLNnQqnnOJL9P\n\tnpUw==", "X-Gm-Message-State": "AOJu0YyJy3yHcjc90ryIwLwrYQb1kO2IMIz4NeuypCJzkX+RbRkSW8tH\n\tHxE5U8fVBD3aeuf2mJWqgy3X8A3Myu8aOiMSqAjwFZZvTi/rU4n1qpM6hyYwfQ==", "X-Gm-Gg": "AeBDiesi4gcZAnzHRJYIXzcS0RlewMx/goLbFH95TDaOreCJ7d2yrgF6hRgtpQp8OwA\n\tIag+IxpBlLDwcUugOqMMaJILphhaYa1cyTfqInJgKDZv65LtalwOtlKxOfG5ZjPmRODAZZ358Rh\n\tXt5cChnC1rVhFKxY7WwA/m0IgJ0qiicYM0xySx47g9ureFWtBcUVjcE8L3fMbHrMFWHLbvHeq+s\n\tTtkMEk4I5POLTQQpmw59KY312xGzpWhYlr5jF9Dd0gbJGEaud3NWEN33Sd34093sluMJ72OkfxT\n\ttCgAFRb51BEqyWT5/Yry/QSILtLBcA3xYuHkgpx5Da/uHwmXloqm63v6c3tQ30CIsYzvVseXnys\n\tx6mp378cWjCyiwAXelMHBQ03H9QRNIZVMMsvLzJU6TItwTCfUA/ThezqnGlUEVgjm3z7WPqJJjX\n\tjn+kVmPkpGaT6mVT9mM3hscf7uhivehVTdyUmL7xXYlkl9KeDQwPrrb4tzrCnXI+ZbEYaIPsnAQ\n\t9Dpq3x4zcXCxb8afpXCS/nd5KLuFAsa", "X-Received": "by 2002:a05:600c:c094:b0:487:5c0:671f with SMTP id\n\t5b1f17b1804b1-48e51e1a7c4mr66305185e9.9.1778108812642; \n\tWed, 06 May 2026 16:06:52 -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:06:45 +0200", "Message-ID": "<20260506230649.1040794-7-devve.3@gmail.com>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260506230649.1040794-1-devve.3@gmail.com>", "References": "<20260506230649.1040794-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" ] }