Show a patch.

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

{
    "id": 26249,
    "url": "https://patchwork.libcamera.org/api/patches/26249/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26249/",
    "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": "<20260304075052.11599-2-johannes.goede@oss.qualcomm.com>",
    "date": "2026-03-04T07:50:48",
    "name": "[v5,1/5] software_isp: swstats_cpu: Prepare for multi-threading support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "0cf12c28f9da8090733e4008e68663fc2ea05468",
    "submitter": {
        "id": 242,
        "url": "https://patchwork.libcamera.org/api/people/242/?format=api",
        "name": "Hans de Goede",
        "email": "johannes.goede@oss.qualcomm.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26249/mbox/",
    "series": [
        {
            "id": 5817,
            "url": "https://patchwork.libcamera.org/api/series/5817/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5817",
            "date": "2026-03-04T07:50:47",
            "name": "software_isp: debayer_cpu: Add multi-threading support",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/5817/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26249/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26249/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 A8CF3C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Mar 2026 07:51:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD64F62393;\n\tWed,  4 Mar 2026 08:51:00 +0100 (CET)",
            "from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n\t[205.220.180.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BD59F62385\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Mar 2026 08:50:58 +0100 (CET)",
            "from pps.filterd (m0279871.ppops.net [127.0.0.1])\n\tby mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n\t6245SQc8945115 for <libcamera-devel@lists.libcamera.org>;\n\tWed, 4 Mar 2026 07:50:57 GMT",
            "from mail-qk1-f197.google.com (mail-qk1-f197.google.com\n\t[209.85.222.197])\n\tby mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cnvxfc48y-1\n\t(version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 04 Mar 2026 07:50:57 +0000 (GMT)",
            "by mail-qk1-f197.google.com with SMTP id\n\taf79cd13be357-8c70ed6c849so915904385a.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 03 Mar 2026 23:50:57 -0800 (PST)",
            "from shalem\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b935ac73a5dsm693263366b.25.2026.03.03.23.50.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 03 Mar 2026 23:50:54 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=qualcomm.com header.i=@qualcomm.com\n\theader.b=\"eThPLdMH\"; dkim=pass (2048-bit key;\n\tunprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n\theader.b=\"gDL7Ip0/\"; dkim-atps=neutral",
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n\tcc:content-transfer-encoding:date:from:in-reply-to:message-id\n\t:mime-version:references:subject:to; s=qcppdkim1; bh=Q9h8k+AeUz8\n\tt+HWwjwjc7na33VwWe6woYgARNnc/Hyc=; b=eThPLdMHVr6ANYs7SKK8ctRTPRQ\n\tb0RJwit4F08qbh/7W86/Evqkt9C6l08019JBwUOIrdfVcJZn64MIVF/voNjkFdrR\n\tXmW4VE8eGmg0Y8ckhd/Qup2rKtvq5WFSv2ALhwVmE+Bp9hM+Z+P6vC0E7pIKTYLE\n\tbS9TGk65/KG3OmvbsDc4F2iTua7b8wRIv6Id+bnCESr06AD+krfni6JMJfXASKbO\n\tkJy9mwr4m3O2qa1PfMG8keYQyliEr57HqpKqP2ZAC9UZsEBxksQ1iEBbb1IZQTtI\n\thcweV6LptiWM+3Mf4uP5hWN8xie8h9TT8mWJ8PaD0gzEkfDMV9WJfkdnoGA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=oss.qualcomm.com; s=google; t=1772610656; x=1773215456;\n\tdarn=lists.libcamera.org; \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=Q9h8k+AeUz8t+HWwjwjc7na33VwWe6woYgARNnc/Hyc=;\n\tb=gDL7Ip0/vtS3lnBXrBYPT5kUi1vm1QL44a1WOCurmQOtZO29CFfkCzmkABGOtWWvtf\n\tc0uxVNqKrwrzOOTZQA5ZcWU/KTjy7NK9y9tT19bJLmjTyu+SzX+4oPCmISUHSDoP7xCw\n\tWXt/YLnMquoDiOhpoyaTj1d1Ga4tpMnWVFskjrVQAB9QrZQ+wiUKCFXyTv7mPC92+1+P\n\twg3GMXXqxSPfsA+SHq7ON9IaGTltbmxMLBc8B3Y7erHfI9dcbInhxml2O+DxgSBnMXTo\n\tXE/zJuwv1Hv+ZUh+wqRsynTXP1LROhlMW3/erNzOm+Rr4Jt7UFOFdsmJ1p5e8LihhhfM\n\tNiAQ=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1772610656; x=1773215456;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=Q9h8k+AeUz8t+HWwjwjc7na33VwWe6woYgARNnc/Hyc=;\n\tb=vphXNA2ze8tGGVpnF6jxXIJ0b6/To6Y3Py5TJetYrbIDWFsrdWg7q5tflTo1t0hKOR\n\tm1vUHqY+H8sgt8fj25G8/e789ZsHimPAt0KhtY6TsLEseK69YU8AdoLFSygxlzwsPaY1\n\tgO7+WOC1YfAaZuQt5Z9FDyYguRE6bJkjFbIH2ZwSDMjtxEfKL7ZAFwbiMri+qBuH7y3Y\n\teUd6MUj7oHswfR83cBSDTt9Ip6LgaDsxHUU9q8rFCXjYiPCe4sGAD9yan1AbLAxJ4bXP\n\ttaJu7s1SMoHG4yjfdQaZcAOUoGhU6KDUCW8GljwOooBqjaZy4fdq2URafWXZr00CiOVN\n\tXO2A==",
        "X-Gm-Message-State": "AOJu0YwdIEmYU8MJY3a4ccma6IgpjDAJ5sdc6CkDafmVfVou3MNoPT0F\n\tOEjweThrnCdNSUJor5FHs09zmExE4/esqZODM6fqXJBMJS4zDWzZfk+Hh3C+YzmTqssoWYgjMhT\n\ttRMcP3p40pPp8sAgnMyu+yirBoARF0/wLopMm7sqq8X3pF8suoqFDQiRKCL/nmFj4LTM6+U6tUT\n\tDCaNeW+grx",
        "X-Gm-Gg": "ATEYQzyqEnP88l4seFOBe8c9XVLZJdQZiMpU5viXZ6oMfiQpFA2VZZDpClxz3Yb+WCi\n\tL8OQdJf9z+T4HR5/r91oleaSRHhhDjwG91gTr98+Pu0RAS3xuzIzY4vMCnk9Da9GUW0XKWj+WCn\n\tmLcP6DwsDU3hWIPXKWCFPEONiihA5uogYibnJ1hEEYD/eN7t1zlZoIFPDP+6tX4i2HCbAnL4mYL\n\tKElpFc+7BdDi1oJZEs3gyGKXTk+d5xzKCS5z2Y5MZjNL4A2kBTtNha+JcGDvNfqmkHDE7lC/U6r\n\tNA79/7HPO+71IuAxyGU2/iScGJh4HxCHiIwnuQ6AfgAAUpk1JRhhIMG0MU6VNOuBFeHaGySwIM4\n\tV+khj29xljfBUb0W3kYTCVR0zWKSLSJ5qKyCje1aPZnLvP6zPL53kQ9KCAzLWcdFMch4iyFySG9\n\tiyA3gpBB0Lc2OLnGUDgcndwGeEUoNTpr6pnrGp",
        "X-Received": [
            "by 2002:a05:620a:4092:b0:8ca:2cf9:819c with SMTP id\n\taf79cd13be357-8cd5af8030fmr134516485a.40.1772610656283; \n\tTue, 03 Mar 2026 23:50:56 -0800 (PST)",
            "by 2002:a05:620a:4092:b0:8ca:2cf9:819c with SMTP id\n\taf79cd13be357-8cd5af8030fmr134514385a.40.1772610655575; \n\tTue, 03 Mar 2026 23:50:55 -0800 (PST)"
        ],
        "From": "Hans de Goede <johannes.goede@oss.qualcomm.com>",
        "To": "libcamera-devel@lists.libcamera.org, Milan Zamazal <mzamazal@redhat.com>",
        "Cc": "Hans de Goede <johannes.goede@oss.qualcomm.com>",
        "Subject": "[PATCH v5 1/5] software_isp: swstats_cpu: Prepare for\n\tmulti-threading support",
        "Date": "Wed,  4 Mar 2026 08:50:48 +0100",
        "Message-ID": "<20260304075052.11599-2-johannes.goede@oss.qualcomm.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260304075052.11599-1-johannes.goede@oss.qualcomm.com>",
        "References": "<20260304075052.11599-1-johannes.goede@oss.qualcomm.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMzA0MDA2MiBTYWx0ZWRfX/g1av0/Ai38r\n\tbUP9Rd2RuKxNbGZ6M2wHV7d9OAAT5102kpT1fzy0RbdCL114AyDMUCQ0V1IOAt8yLbyvCx+3Vk8\n\tYmP7piFhiM8VlqY6wIbRZ6zTKCyEWgJHGq6zSsD3JfqXLEx0FwGyQ09F60N7w7eSCBCgNxva719\n\tGLnO+4+1OPjSdD7nXtKts9jGKVUYVc8K3/BkcrHQI7LbqJNJMSP4xJ4uFsrXyMPUI5DDMuIvevD\n\tlRWs8/2KNA7tof1c0jhRMp3UC8K33nBhOvYPNw9NeNdDwH1v/dUkGmWPp9sp9c1Zj1iSgvzaYuO\n\tO/43bpIaU0FflQAbpGVUA5cc6/giE6ik1PmxgbwWZFjcZ2kJtoALhjApKa25ph+ooFxKCQKUGV0\n\tg7wrOdrcSHj92LPcNo+uOjxTnAEkcc6ycCQqhTaXHwB4/+hvaLQu6u6ntLGxOzCzu5tXEYh7elG\n\tfClaGU5b7d5/idSTVlA==",
        "X-Proofpoint-ORIG-GUID": "L-_8Ch2F4ohKYdUAwgPDm6pbuTzh7Gkb",
        "X-Authority-Analysis": "v=2.4 cv=S+HUAYsP c=1 sm=1 tr=0 ts=69a7e461 cx=c_pps\n\ta=50t2pK5VMbmlHzFWWp8p/g==:117 a=xqWC_Br6kY4A:10 a=Yq5XynenixoA:10\n\ta=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22\n\ta=3WHJM1ZQz_JShphwDgj5:22 a=20KFwNOVAAAA:8 a=EUspDBNiAAAA:8\n\ta=VvikW9XIONpR7lsxkDIA:9 a=IoWCM6iH3mJn3m4BftBB:22",
        "X-Proofpoint-GUID": "L-_8Ch2F4ohKYdUAwgPDm6pbuTzh7Gkb",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n\tengine=ICAP:2.0.293, Aquarius:18.0.1121, Hydra:6.1.51,\n\tFMLib:17.12.100.49\n\tdefinitions=2026-03-04_02,2026-03-03_01,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tphishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0\n\tsuspectscore=0\n\tclxscore=1015 spamscore=0 priorityscore=1501 adultscore=0\n\timpostorscore=0\n\tclassifier=typeunknown authscore=0 authtc= authcc= route=outbound\n\tadjust=0\n\treason=mlx scancount=1 engine=8.22.0-2602130000\n\tdefinitions=main-2603040062",
        "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": "Make the storage used to accumulate the RGB sums and the Y histogram\nvalue a vector of SwIspStats objects instead of a single object so\nthat when using multi-threading every thread can use its own storage to\ncollect intermediate stats to avoid cache-line bouncing.\n\nBenchmarking with the GPU-ISP which does separate swstats benchmarking,\non the Arduino Uno-Q which has a weak CPU which is good for performance\ntesting, shows 20ms to generate stats for a 3272x2464 frame both before\nand after this change.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n---\nChanges in v4:\n- Use const in for (const auto &s : stats_) {} in SwStatsCpu::finishFrame()\n- Add Milan's Reviewed-by\n\nChanges in v3:\n- Use for (auto &s : stats_) {}\n\nChanges in v2:\n- Move the allocation of the vector of SwIspStats objects to inside\n  the SwStatsCpu class, controlled by a configure() arguments instead\n  of making the caller allocate the objects\n---\n .../internal/software_isp/swstats_cpu.h       | 25 ++++-----\n src/libcamera/software_isp/swstats_cpu.cpp    | 54 +++++++++++++------\n 2 files changed, 50 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\nindex 64b3e23f5..feee92f99 100644\n--- a/include/libcamera/internal/software_isp/swstats_cpu.h\n+++ b/include/libcamera/internal/software_isp/swstats_cpu.h\n@@ -12,6 +12,7 @@\n #pragma once\n \n #include <stdint.h>\n+#include <vector>\n \n #include <libcamera/base/signal.h>\n \n@@ -51,13 +52,13 @@ public:\n \n \tconst Size &patternSize() { return patternSize_; }\n \n-\tint configure(const StreamConfiguration &inputCfg);\n+\tint configure(const StreamConfiguration &inputCfg, unsigned int statsBufferCount = 1);\n \tvoid setWindow(const Rectangle &window);\n \tvoid startFrame(uint32_t frame);\n \tvoid finishFrame(uint32_t frame, uint32_t bufferId);\n \tvoid processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input);\n \n-\tvoid processLine0(uint32_t frame, unsigned int y, const uint8_t *src[])\n+\tvoid processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0)\n \t{\n \t\tif (frame % kStatPerNumFrames)\n \t\t\treturn;\n@@ -66,10 +67,10 @@ public:\n \t\t    y >= (window_.y + window_.height))\n \t\t\treturn;\n \n-\t\t(this->*stats0_)(src);\n+\t\t(this->*stats0_)(src, stats_[statsBufferIndex]);\n \t}\n \n-\tvoid processLine2(uint32_t frame, unsigned int y, const uint8_t *src[])\n+\tvoid processLine2(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0)\n \t{\n \t\tif (frame % kStatPerNumFrames)\n \t\t\treturn;\n@@ -78,25 +79,25 @@ public:\n \t\t    y >= (window_.y + window_.height))\n \t\t\treturn;\n \n-\t\t(this->*stats2_)(src);\n+\t\t(this->*stats2_)(src, stats_[statsBufferIndex]);\n \t}\n \n \tSignal<uint32_t, uint32_t> statsReady;\n \n private:\n-\tusing statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[]);\n+\tusing statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[], SwIspStats &stats);\n \tusing processFrameFn = void (SwStatsCpu::*)(MappedFrameBuffer &in);\n \n \tint setupStandardBayerOrder(BayerFormat::Order order);\n \t/* Bayer 8 bpp unpacked */\n-\tvoid statsBGGR8Line0(const uint8_t *src[]);\n+\tvoid statsBGGR8Line0(const uint8_t *src[], SwIspStats &stats);\n \t/* Bayer 10 bpp unpacked */\n-\tvoid statsBGGR10Line0(const uint8_t *src[]);\n+\tvoid statsBGGR10Line0(const uint8_t *src[], SwIspStats &stats);\n \t/* Bayer 12 bpp unpacked */\n-\tvoid statsBGGR12Line0(const uint8_t *src[]);\n+\tvoid statsBGGR12Line0(const uint8_t *src[], SwIspStats &stats);\n \t/* Bayer 10 bpp packed */\n-\tvoid statsBGGR10PLine0(const uint8_t *src[]);\n-\tvoid statsGBRG10PLine0(const uint8_t *src[]);\n+\tvoid statsBGGR10PLine0(const uint8_t *src[], SwIspStats &stats);\n+\tvoid statsGBRG10PLine0(const uint8_t *src[], SwIspStats &stats);\n \n \tvoid processBayerFrame2(MappedFrameBuffer &in);\n \n@@ -116,8 +117,8 @@ private:\n \tunsigned int xShift_;\n \tunsigned int stride_;\n \n+\tstd::vector<SwIspStats> stats_;\n \tSharedMemObject<SwIspStats> sharedStats_;\n-\tSwIspStats stats_;\n \tBenchmark bench_;\n };\n \ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 1cedcfbc1..ded0dcf1a 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -74,11 +74,12 @@ namespace libcamera {\n  */\n \n /**\n- * \\fn void SwStatsCpu::processLine0(uint32_t frame, unsigned int y, const uint8_t *src[])\n+ * \\fn void SwStatsCpu::processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0)\n  * \\brief Process line 0\n  * \\param[in] frame The frame number\n  * \\param[in] y The y coordinate.\n  * \\param[in] src The input data.\n+ * \\param[in] statsBufferIndex Index of stats buffer to use for multi-threading.\n  *\n  * This function processes line 0 for input formats with\n  * patternSize height == 1.\n@@ -97,14 +98,18 @@ namespace libcamera {\n  * to the line in plane 0, etc.\n  *\n  * For non Bayer single plane input data only a single src pointer is required.\n+ *\n+ * The statsBufferIndex value must be less than the statsBufferCount value passed\n+ * to configure().\n  */\n \n /**\n- * \\fn void SwStatsCpu::processLine2(uint32_t frame, unsigned int y, const uint8_t *src[])\n+ * \\fn void SwStatsCpu::processLine2(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0)\n  * \\brief Process line 2 and 3\n  * \\param[in] frame The frame number\n  * \\param[in] y The y coordinate.\n  * \\param[in] src The input data.\n+ * \\param[in] statsBufferIndex Index of stats buffer to use for multi-threading.\n  *\n  * This function processes line 2 and 3 for input formats with\n  * patternSize height == 4.\n@@ -182,14 +187,14 @@ static constexpr unsigned int kBlueYMul = 29; /* 0.114 * 256 */\n \tyVal = r * kRedYMul;               \\\n \tyVal += g * kGreenYMul;            \\\n \tyVal += b * kBlueYMul;             \\\n-\tstats_.yHistogram[yVal * SwIspStats::kYHistogramSize / (256 * 256 * (div))]++;\n+\tstats.yHistogram[yVal * SwIspStats::kYHistogramSize / (256 * 256 * (div))]++;\n \n #define SWSTATS_FINISH_LINE_STATS() \\\n-\tstats_.sum_.r() += sumR;    \\\n-\tstats_.sum_.g() += sumG;    \\\n-\tstats_.sum_.b() += sumB;\n+\tstats.sum_.r() += sumR;    \\\n+\tstats.sum_.g() += sumG;    \\\n+\tstats.sum_.b() += sumB;\n \n-void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[])\n+void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[], SwIspStats &stats)\n {\n \tconst uint8_t *src0 = src[1] + window_.x;\n \tconst uint8_t *src1 = src[2] + window_.x;\n@@ -214,7 +219,7 @@ void SwStatsCpu::statsBGGR8Line0(const uint8_t *src[])\n \tSWSTATS_FINISH_LINE_STATS()\n }\n \n-void SwStatsCpu::statsBGGR10Line0(const uint8_t *src[])\n+void SwStatsCpu::statsBGGR10Line0(const uint8_t *src[], SwIspStats &stats)\n {\n \tconst uint16_t *src0 = (const uint16_t *)src[1] + window_.x;\n \tconst uint16_t *src1 = (const uint16_t *)src[2] + window_.x;\n@@ -240,7 +245,7 @@ void SwStatsCpu::statsBGGR10Line0(const uint8_t *src[])\n \tSWSTATS_FINISH_LINE_STATS()\n }\n \n-void SwStatsCpu::statsBGGR12Line0(const uint8_t *src[])\n+void SwStatsCpu::statsBGGR12Line0(const uint8_t *src[], SwIspStats &stats)\n {\n \tconst uint16_t *src0 = (const uint16_t *)src[1] + window_.x;\n \tconst uint16_t *src1 = (const uint16_t *)src[2] + window_.x;\n@@ -266,7 +271,7 @@ void SwStatsCpu::statsBGGR12Line0(const uint8_t *src[])\n \tSWSTATS_FINISH_LINE_STATS()\n }\n \n-void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[])\n+void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[], SwIspStats &stats)\n {\n \tconst uint8_t *src0 = src[1] + window_.x * 5 / 4;\n \tconst uint8_t *src1 = src[2] + window_.x * 5 / 4;\n@@ -292,7 +297,7 @@ void SwStatsCpu::statsBGGR10PLine0(const uint8_t *src[])\n \tSWSTATS_FINISH_LINE_STATS()\n }\n \n-void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[])\n+void SwStatsCpu::statsGBRG10PLine0(const uint8_t *src[], SwIspStats &stats)\n {\n \tconst uint8_t *src0 = src[1] + window_.x * 5 / 4;\n \tconst uint8_t *src1 = src[2] + window_.x * 5 / 4;\n@@ -332,8 +337,10 @@ void SwStatsCpu::startFrame(uint32_t frame)\n \tif (window_.width == 0)\n \t\tLOG(SwStatsCpu, Error) << \"Calling startFrame() without setWindow()\";\n \n-\tstats_.sum_ = RGB<uint64_t>({ 0, 0, 0 });\n-\tstats_.yHistogram.fill(0);\n+\tfor (auto &s : stats_) {\n+\t\ts.sum_ = RGB<uint64_t>({ 0, 0, 0 });\n+\t\ts.yHistogram.fill(0);\n+\t}\n }\n \n /**\n@@ -345,8 +352,19 @@ void SwStatsCpu::startFrame(uint32_t frame)\n  */\n void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)\n {\n-\tstats_.valid = frame % kStatPerNumFrames == 0;\n-\t*sharedStats_ = stats_;\n+\tbool valid = frame % kStatPerNumFrames == 0;\n+\n+\tif (valid) {\n+\t\tsharedStats_->sum_ = RGB<uint64_t>({ 0, 0, 0 });\n+\t\tsharedStats_->yHistogram.fill(0);\n+\t\tfor (const auto &s : stats_) {\n+\t\t\tsharedStats_->sum_ += s.sum_;\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}\n+\n+\tsharedStats_->valid = valid;\n \tstatsReady.emit(frame, bufferId);\n }\n \n@@ -389,12 +407,14 @@ int SwStatsCpu::setupStandardBayerOrder(BayerFormat::Order order)\n /**\n  * \\brief Configure the statistics object for the passed in input format\n  * \\param[in] inputCfg The input format\n+ * \\param[in] statsBufferCount number of internal stats buffers to use for multi-threading\n  *\n  * \\return 0 on success, a negative errno value on failure\n  */\n-int SwStatsCpu::configure(const StreamConfiguration &inputCfg)\n+int SwStatsCpu::configure(const StreamConfiguration &inputCfg, unsigned int statsBufferCount)\n {\n \tstride_ = inputCfg.stride;\n+\tstats_.resize(statsBufferCount);\n \n \tBayerFormat bayerFormat =\n \t\tBayerFormat::fromPixelFormat(inputCfg.pixelFormat);\n@@ -504,7 +524,7 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in)\n \t\t/* linePointers[0] is not used by any stats0_ functions */\n \t\tlinePointers[1] = src;\n \t\tlinePointers[2] = src + stride_;\n-\t\t(this->*stats0_)(linePointers);\n+\t\t(this->*stats0_)(linePointers, stats_[0]);\n \t\tsrc += stride_ * 2;\n \t}\n }\n",
    "prefixes": [
        "v5",
        "1/5"
    ]
}