{"id":24700,"url":"https://patchwork.libcamera.org/api/1.1/patches/24700/?format=json","web_url":"https://patchwork.libcamera.org/patch/24700/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251017102704.3887-4-david.plowman@raspberrypi.com>","date":"2025-10-17T10:05:39","name":"[3/5] ipa: rpi: pisp: Use a floating region to get whole image Y statistics","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ba154e183584fc19b42cdac53848d0821a85148a","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24700/mbox/","series":[{"id":5509,"url":"https://patchwork.libcamera.org/api/1.1/series/5509/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5509","date":"2025-10-17T10:05:36","name":"Fix and improve full image Y statistics","version":1,"mbox":"https://patchwork.libcamera.org/series/5509/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24700/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24700/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 1BCA1C32CE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Oct 2025 10:27:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 134E9606CC;\n\tFri, 17 Oct 2025 12:27:15 +0200 (CEST)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 44763606BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 12:27:11 +0200 (CEST)","by mail-wm1-x336.google.com with SMTP id\n\t5b1f17b1804b1-47112edf9f7so9879155e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 03:27:11 -0700 (PDT)","from localhost.localdomain ([2a06:61c0:f337:0:8aba:2a85:b765:a23e])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-47114428dedsm73811905e9.7.2025.10.17.03.27.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Oct 2025 03:27:09 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"mzQs1u8L\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1760696830; x=1761301630;\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=zFHEnXvv4SPgv/9pwKCAUWV8dxbTetTQUiCP8syXNJc=;\n\tb=mzQs1u8LfoiHRsu1TJL++S/4h21hw7stSdFrugnoPN/nyqUxiL73uNa2YYXrunNC+R\n\tRc+tbLghf3Ck1M8s3xd/CXs6PsiOcV5f71a519DWty9UCLpoOVjDz2SpecvAiAeF/c2z\n\tSL/QYg0HSWLBVloeRW+TbIhHk1lRlimDB3qDttldrrjFX28o4en6gsUCwM6/ZxWcicD0\n\tycimiq/kT5D2SZYETQ/OOVGDq+OTq/6sXdK1EKDaPD29r0m6WdWtBC8d8iS5w3uWZ498\n\tW6PIPxVJCj5tAwzmA7B3ICnu+2u2P5x1RPJrvgRZeCU0f81atZr+0Py5SA34ogxu+LuT\n\twMRQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760696830; x=1761301630;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=zFHEnXvv4SPgv/9pwKCAUWV8dxbTetTQUiCP8syXNJc=;\n\tb=Oq21fbPOYnY6zm/X0j4Vy0oASUKbx0G05hO13vDHqp46y8aKvIhO6zorW/VNjcdwWj\n\t3pfT3Q59RqG9LSBWb/biB1n0EuZUSFP91rMNXJkWA7jwPU5lxnv7VtllYDwLS6N9Lgn6\n\toJPloO+ZuRfgoFMl8Zr0L9YtHSqN6qSLY4cnIgxPj3yOkFxXoypyNBLOaRY5Wa9L/8/y\n\tK2R8MEYcHSz/xHXSL6MBsXyJ87f7fs856PV3numSY/+RwS6SrXEIwFB9IIWicI6wL863\n\tDcu8Dxy8g8JZgZDq2lFStnFLob5tyE/xCL3lBjUxVM5NKVVn36WusNrlTzNTPJI9hHtn\n\tBGuw==","X-Gm-Message-State":"AOJu0YzhOskNAzVTp5UkKyzV7VcewpdGY9tdBqQM1LiXDeBop736iTu2\n\tZie2+yOpGrv0xcxsi0L9cVW7C+JiBhWbDNLtPQUA4wg95YBbaKRsCxEno0VoJS/uiuDQl5YRYST\n\txB2r5ZBc=","X-Gm-Gg":"ASbGncsseYRY1aiKwDa+uFHZdxEemJ8/ZoYdUleogsXDxvviVHwzPtV2472foV4l1gH\n\tiUOc3lHEre7yMLXPXNqIEO7Ogncgg4Rfl2Q2z50ReCN2LeGQwyKE/aEkDbkzMwN86BhPEvTf4k8\n\tumdiggFtkNxu8T/zOeyFmuTihP1B6QGF9KZddGMhk4epN5fbYJ65ENrkZ55ZQOw1ZMGk268g00v\n\tgopObaiyxRpuMOTLbBSeLxgWZKq6eWJE82D67TSTraW035w33XDajOX0k76tJfxGPpMxlXnkA9/\n\tD/QYqTLeaISY9GB342EKgj78cV/BfX1iKE+irJ2WjOoVu50F5juv9fsZhsrvp/mL0ZbgiQmi9x/\n\trHUbbaXbEmkiOfn7wAsQjnu60B9m35EjC0ppPuVYyY6PxQIyo/xYCj3PBPZ7osnDQfd98D/KsLC\n\tQboi4yAwXlTKm9PuYL1VK8ynOPd5Pj5Pcsd+H+k473JsXhucCvdihbKCjJaQNo5dp4GFz/tdC4H\n\taU3KTwpJ0DjMKa0StrZJ5JhELIvgqvlP3un","X-Google-Smtp-Source":"AGHT+IEelgMGpovmxCuGbCTupR1pQCmaKO4nG1sHaa779TmgnMA1Lc/2ZWmOA53lOIJ1ENsGacVxIw==","X-Received":"by 2002:a05:600c:5026:b0:46e:477a:f3dd with SMTP id\n\t5b1f17b1804b1-4711792a680mr25593295e9.36.1760696830319; \n\tFri, 17 Oct 2025 03:27:10 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole image\n\tY statistics","Date":"Fri, 17 Oct 2025 11:05:39 +0100","Message-ID":"<20251017102704.3887-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20251017102704.3887-1-david.plowman@raspberrypi.com>","References":"<20251017102704.3887-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","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":"Floating regions are currently unused on the PiSP platform, so we can\nuse one of them to get an average Y value for the whole image.\n\nIf an algorithm (such as the \"lux\" algorithm) wants a scene-referred\nestimate of absolute brightness, then this would be a better choice\nthan a value from Y histogram as the latter is not invariant to the\nmetering mode (e.g. centre-weighted, spot etc.). (So note that for the\nAGC/AEC algorithm, where the metering mode is relevant, the Y\nhistogram is the appropriate choice.)\n\nWe also fix the loop that copies the hardware's floating region values\ninto our statistics structure; it was using the wrong limit which was\ncausing it not to do anything.\n\nA future commit will update the lux algorithm to use this feature.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/pisp/pisp.cpp | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex bb50a9e0..2ba879c1 100644\n--- a/src/ipa/rpi/pisp/pisp.cpp\n+++ b/src/ipa/rpi/pisp/pisp.cpp\n@@ -467,7 +467,7 @@ RPiController::StatisticsPtr IpaPiSP::platformProcessStats(Span<uint8_t> mem)\n \n \t/* AGC region sums only get collected on floating zones. */\n \tstatistics->agcRegions.init({ 0, 0 }, PISP_FLOATING_STATS_NUM_ZONES);\n-\tfor (i = 0; i < statistics->agcRegions.numRegions(); i++)\n+\tfor (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++)\n \t\tstatistics->agcRegions.setFloating(i,\n \t\t\t\t\t\t   { { 0, 0, 0, stats->agc.floating[i].Y_sum },\n \t\t\t\t\t\t     stats->agc.floating[i].counted, 0 });\n@@ -985,6 +985,12 @@ void IpaPiSP::setStatsAndDebin()\n \t */\n \tsetHistogramWeights();\n \n+\t/* Configure the first AGC floating region to cover the whole image, for the lux algo. */\n+\tpisp_fe_floating_stats_config floatingStatsConfig = {};\n+\tfloatingStatsConfig.regions[0].size_x = mode_.width;\n+\tfloatingStatsConfig.regions[0].size_y = mode_.height;\n+\tfe_->SetFloatingStats(floatingStatsConfig);\n+\n \tpisp_be_global_config beGlobal;\n \tbe_->GetGlobal(beGlobal);\n \n","prefixes":["3/5"]}