Patch Detail
Show a patch.
GET /api/patches/23610/?format=api
{ "id": 23610, "url": "https://patchwork.libcamera.org/api/patches/23610/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23610/", "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": "<20250620124452.557855-3-naush@raspberrypi.com>", "date": "2025-06-20T12:42:23", "name": "[v1,2/8] ipa: rpi: controller: Improve findPeak() function in AF algorithm", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "311a5c6fde40123015d803b0271ecbb42889f2d2", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23610/mbox/", "series": [ { "id": 5235, "url": "https://patchwork.libcamera.org/api/series/5235/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5235", "date": "2025-06-20T12:42:21", "name": "Raspberry Pi: AF improvements", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5235/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23610/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23610/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 5477DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Jun 2025 12:45:09 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77F8B61535;\n\tFri, 20 Jun 2025 14:45:06 +0200 (CEST)", "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C39E61535\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Jun 2025 14:44:59 +0200 (CEST)", "by mail-wr1-x42f.google.com with SMTP id\n\tffacd0b85a97d-3a4e749d7b2so353163f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Jun 2025 05:44:59 -0700 (PDT)", "from NAUSH-P-DELL.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-45361461375sm41561525e9.14.2025.06.20.05.44.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 20 Jun 2025 05:44:58 -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=\"ZR7n+Sw/\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1750423498; x=1751028298;\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=1fgw5gWlXRgAGINCK27+v1vEnL5TJfgKBKWPe1uS9M8=;\n\tb=ZR7n+Sw/JdmA9+GKE1/oTpY15ePHs6Zto+8BjGsxV47aZ9/uTcWW61J3cvg0U295VZ\n\tkHviOaNPNUzXJZ+5RGRzyKIRYoW9HcYJ5uqSQYiK4QcjUClX6ZxA0PkifWopO1gEIAOH\n\tQOmGgphipz9tfivmxJ4dCCUyJF4PTq9F9nfPziGhFb1iiOtDYUYpE3Ays6YN1S+d+xCr\n\tnVB3O0SDZbz1xQkJBQgBBIQXOaW6rtT4Rmz3edKZS4ykZUOcAAn4llVMAOSbnty6HKT3\n\tBtp9NWGWrmsPGncUPZa9MPQTDTb3nd2hjs9w1JBNdTlCfq5GFs/ay5ZFDjH1BepgYSms\n\tX3AA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1750423498; x=1751028298;\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=1fgw5gWlXRgAGINCK27+v1vEnL5TJfgKBKWPe1uS9M8=;\n\tb=awZxYmqU4O6CalbirDCe0Nq1vk6MCRg2+TYWQOkLJkvhVNR3Bot0DxSL2ZRHFHA69w\n\tbYXo202+Li4xvU4n8O/4XKeTo6YKrZqFM2HBL1PtSvpge5gUqjHgfno9bvilTao92hDh\n\taRAr1LZwi7r4UmhY6i/yGmg5C7j4wAglRUU2QmOsHB0VjB91uYpdnxRGAg27dFfr1YMn\n\tv5wDICs9GTc5ojJkffV0ZfCgLq8BR/djdsb9V0dpSWXK9lI+ErjRx0BJ9gURj1zkoTbd\n\tH9WSAELSeHnVLaKcLf65LGH8/hza+9qM2MwhNFVLOelrWa9l/K6Van+52q8QS4JNn/cE\n\tRykg==", "X-Gm-Message-State": "AOJu0Yx94m4rPGPmkuifRtlDIxzqX7bPZN3t/9ytFeXXDvkejO/tzErR\n\tXhSbX/Lhi/AGvOxgsppWjG9n/MtE2IrDYE6h8siKHs6BZ0L2bctnimfqtX3zohYnWlcFlwuH7BU\n\tKtDba", "X-Gm-Gg": "ASbGncsELat11iL/sTKNCOSWJUswpgV8LIMCkOzJScwFheelpoKWT2lcVMkknTE9JeR\n\t2oi37NGQyDR/1C7Nsa/U3Ir1DkhhOptsTwJ556vwCHKUUZ+SXHeAgE1tHV8oV6wTYxvf6/3OPe1\n\t+/SdPBJyCs49kbvD+UYJYZapcDnONtvMNufqzP7SUzjSOb9IUZXqRVod2jmCDZYSjc40IIjsoNm\n\tdUtRCgFVZguIZBJtUaVq3hKbog89oH7MYsM+yyxDB3+1JVUFhxqfd/5BPZ6TnKfewB0LdcazZyA\n\tKRQyvGkLXqlyDi0HyBQLOhb1zyFSVUbl9FyT6HBT4+1NDJRjuOufZkLuTJw1Tx+Tp/vjDSk15dE\n\tlmXAI3g==", "X-Google-Smtp-Source": "AGHT+IG+V2QnXhGMLGsz1b49YX+JWTlKouCpYcyTJsmce+nG18y0Jrqq3ike0fb0OGRjnqBKBY0kpQ==", "X-Received": "by 2002:a05:600c:c087:b0:439:a30f:2e49 with SMTP id\n\t5b1f17b1804b1-453657bd470mr7316525e9.5.1750423498446; \n\tFri, 20 Jun 2025 05:44:58 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>", "Subject": "[PATCH v1 2/8] ipa: rpi: controller: Improve findPeak() function in\n\tAF algorithm", "Date": "Fri, 20 Jun 2025 13:42:23 +0100", "Message-ID": "<20250620124452.557855-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250620124452.557855-1-naush@raspberrypi.com>", "References": "<20250620124452.557855-1-naush@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": "From: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nImprove quadratic peak fitting in findPeak(). The old approximation\nwas good but only valid when points were equally spaced and the\nMAX was not at one end of the series.\n\nSigned-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/af.cpp | 31 ++++++++++++++++++++++---------\n 1 file changed, 22 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp\nindex 041cb51db277..8df614ed7b6b 100644\n--- a/src/ipa/rpi/controller/rpi/af.cpp\n+++ b/src/ipa/rpi/controller/rpi/af.cpp\n@@ -436,15 +436,28 @@ double Af::findPeak(unsigned i) const\n {\n \tdouble f = scanData_[i].focus;\n \n-\tif (i > 0 && i + 1 < scanData_.size()) {\n-\t\tdouble dropLo = scanData_[i].contrast - scanData_[i - 1].contrast;\n-\t\tdouble dropHi = scanData_[i].contrast - scanData_[i + 1].contrast;\n-\t\tif (0.0 <= dropLo && dropLo < dropHi) {\n-\t\t\tdouble param = 0.3125 * (1.0 - dropLo / dropHi) * (1.6 - dropLo / dropHi);\n-\t\t\tf += param * (scanData_[i - 1].focus - f);\n-\t\t} else if (0.0 <= dropHi && dropHi < dropLo) {\n-\t\t\tdouble param = 0.3125 * (1.0 - dropHi / dropLo) * (1.6 - dropHi / dropLo);\n-\t\t\tf += param * (scanData_[i + 1].focus - f);\n+\tif (scanData_.size() >= 3) {\n+\t\t/*\n+\t\t * Given the sample with the highest contrast score and its two\n+\t\t * neighbours either side (or same side if at the end of a scan),\n+\t\t * solve for the best lens position by fitting a parabola.\n+\t\t * Adapted from awb.cpp: interpolateQaudaratic()\n+\t\t */\n+\n+\t\tif (i == 0)\n+\t\t\ti++;\n+\t\telse if (i + 1 >= scanData_.size())\n+\t\t\ti--;\n+\n+\t\tdouble abx = scanData_[i - 1].focus - scanData_[i].focus;\n+\t\tdouble aby = scanData_[i - 1].contrast - scanData_[i].contrast;\n+\t\tdouble cbx = scanData_[i + 1].focus - scanData_[i].focus;\n+\t\tdouble cby = scanData_[i + 1].contrast - scanData_[i].contrast;\n+\t\tdouble denom = 2.0 * (aby * cbx - cby * abx);\n+\t\tif (std::abs(denom) >= (1.0 / 64.0) && denom * abx > 0.0) {\n+\t\t\tf = (aby * cbx * cbx - cby * abx * abx) / denom;\n+\t\t\tf = std::clamp(f, std::min(abx, cbx), std::max(abx, cbx));\n+\t\t\tf += scanData_[i].focus;\n \t\t}\n \t}\n \n", "prefixes": [ "v1", "2/8" ] }