From patchwork Fri Oct 17 10:05:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24697 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2CD3BC3259 for ; Fri, 17 Oct 2025 10:27:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DD0CD606AD; Fri, 17 Oct 2025 12:27:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UAmrRe9o"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90EEB60697 for ; Fri, 17 Oct 2025 12:27:08 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-47114a40161so17063875e9.3 for ; Fri, 17 Oct 2025 03:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1760696828; x=1761301628; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FOuj0EWFAuykVD/HHPch7Lkl11X3dJ1hzUyfv+tY05o=; b=UAmrRe9oJV64a4ommZTqSNnLAk1TUanKgQoz+fxZSaYAC+nGgxlpezv8+b0VFz6EfF yKjQB42siWU6a2eZKHuxtx9mRgoiLVBxruC8mMmcNPsgay7bWPIcZP2w8xlk2sPnVZCv 4ccmSJGraRmussd4M+yaU8WUivLCk/3XuOKcSUDmgIaIORAlouEoWW+bOPte1paKWwpu SCeWGFjyCRvZhVHiNW40HimyrOicXV5NA0qpCK2IGBOUM3ufrY/R2xSTQ5a3M9n/xQLB 0BOaW5+zSteIaquWgoiMAmXpOHhMq8/eHv5CboeqR6R8ssqRnxzqrWkeNn2XLIoZ/2BJ EXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760696828; x=1761301628; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FOuj0EWFAuykVD/HHPch7Lkl11X3dJ1hzUyfv+tY05o=; b=BAiRgW3t2cn5yWiIoQoYiPetu6Pm0LEFQbjqE1gy0A1zL1QjJ2zljp+2VcRA33ULwU VhkbqmmadyZ5D/eixNkHEaMIFShYn6v11vabPHvmJQnIf5qyvdl8icBSy84T0gpZvugZ H/3+ViUSw+QcKuAuJYCwsW3oOPrwZQ6mzJYZ2bcsx1pYWxmTlgoe9mdGG3oWFuDulqO1 52KAkMt2kDjL/gtbE2oSLGC34on80iAPyhq5oSXWtzEWNoLCDeLtIKU6O1UyBu1/n3ZX lUUkfLBgoGCCYVvBOmtyK43ZuXXMudWP6EAWKX1mlgbhRNjCm31RAadq8vsa+8zLhcbx Cmiw== X-Gm-Message-State: AOJu0Yz6ZvKL4GXhTho8aZ8jIwmjE+qD3WJ+O+T6HfHGOubGNKeoCDn8 wPBU0SncLJsMwWHSJLjtDIGPjsmbvVP3XPvnDvcx+Mwf1lmfHKwIGMXRpHnCPg5TaAyif+UPvS3 lJV38I2o= X-Gm-Gg: ASbGnctMvXqC068uNnfdApngac69lml9Yyh6GhkwNK1NhnUeU/xsbGhTNZ5CBj94U/Y rDqQD8U2cwcXaW4vVZqT1OUkIGRa5wEYFwvwyDqnUu1eonGFa9+PZuWn/Pq0Xyxwin2v0bwhv/+ uhAyhixlh2QKR3k6pjIUhtj3QEBay+UPHea09/9CcWfJEovXnzIwVOAMTEvpkpvSNy6JAVGj83N goM05vXApStf+HD9vbPzz8vYH+sJTeqHCMXyRkrfJ2oMywIJGUeL4BY9xK15TpoFtZBYkm6+hRu kqJQKuWHx7HI3KLDQQhtNqAOCxlF1D6jSTQbUmWc3O0on8p8AbzNsKWrAgGVRIdYUAc5iQrFL1+ xN9XR2X9vx+p8vh0pODh1IEJDrvekkjpRQpmHDB17YsM9/c0wd05f7+9CEkxh53u6e0niP324b+ edWIOVnukHQZEZTuoAwa7di7czR15cuf8U8O5xY9zpeFLwhxMB8YMDXkgzuK9dSgIdL7lE7NmqQ 4KY/3D2rvNUU22g4S19K420UQ== X-Google-Smtp-Source: AGHT+IE2x4WJJ38Yosvls2T/qWJNLoY6DSLvBS/bLv47dle0i5poYzJ+tqnBxnM/AvoBe9E5Fpq51Q== X-Received: by 2002:a05:600c:37ce:b0:471:ff3:a87e with SMTP id 5b1f17b1804b1-4711791d205mr24317035e9.36.1760696827520; Fri, 17 Oct 2025 03:27:07 -0700 (PDT) Received: from localhost.localdomain ([2a06:61c0:f337:0:8aba:2a85:b765:a23e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47114428dedsm73811905e9.7.2025.10.17.03.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Oct 2025 03:27:07 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 0/5] Fix and improve full image Y statistics Date: Fri, 17 Oct 2025 11:05:36 +0100 Message-ID: <20251017102704.3887-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi This small set of patches improves the calculation of the scene average Y value as used by the "lux" algorithm. The previous calculation had some problems, most glaringly that it wasn't invariant to the AGC metering mode - and the whole point of the "lux" algorithm is supposed to be to calculate a purely scene dependent number! So we update both VC4 and PiSP platforms to have a "floating statistics region" where we can accumulate a full image Y value. We actually have hardware for this on the PiSP, but for VC4 we are able to "synthesize" such a floating region from the other statistics that we have. These changes are good in themselves, but were also motivated by wanting more reliable lux measurements for the forthcoming neural network AWB algorithm. A couple of other minor related things are fixed in passing, such as making the lux algorithm use the camera mode sensitivity correctly (as it was simply being ignored). Thanks! David David Plowman (5): ipa: rpi: Fix the set function for floating statistics regions ipa: rpi: lux: Handle camera mode sensitivity correctly ipa: rpi: pisp: Use a floating region to get whole image Y statistics ipa: rpi: vc4: Use a floating statistics region for a full image Y sum ipa: rpi: lux: Use floating statistics region to obtain the current Y value src/ipa/rpi/controller/region_stats.h | 2 +- src/ipa/rpi/controller/rpi/lux.cpp | 24 +++++++++++++++---- src/ipa/rpi/controller/rpi/lux.h | 3 +++ src/ipa/rpi/pisp/pisp.cpp | 8 ++++++- src/ipa/rpi/vc4/vc4.cpp | 33 +++++++++++++++++++++++++-- 5 files changed, 62 insertions(+), 8 deletions(-)