From patchwork Fri Oct 16 20:28:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28476 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 5A1E4C3305 for ; Fri, 16 Oct 2026 20:28:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A96B968E55; Fri, 16 Oct 2026 22:28:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pgoPypZj"; dkim-atps=neutral Received: from mail-vk1-xa35.google.com (mail-vk1-xa35.google.com [IPv6:2607:f8b0:4864:20::a35]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E544E68E40 for ; Fri, 16 Oct 2026 22:28:33 +0200 (CEST) Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-5ea63f01606so181532e0c.1 for ; Fri, 16 Oct 2026 13:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792182513; x=1792787313; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=02JAMWKdRQ16U0IDieCwBskgchSrhlfOdgVL8lNlzgI=; b=pgoPypZjcqXBzFtXH3ON41WN63ULwRrxW/rrcFGeL7ooPfZczrgasbz/xyjmGGNajX Finn/Aku7mLfHv1nlEgpph3OGnBD5lwiikAfIpYRTmu0V+6ZUi9gym7pL0/KELeSJBK8 r9Kt5msEI9pNaCl0tQKJcapqqN4HU6hOzpPu6T4rtM49KU7WyDuf7lyNRsgO47jCCv8W jzvUtAReb497Te7gJ2bsAmWaH+RNdnw8fCRjn5/SGpAknfUJfFUR7H++yM8+86m7oo4o 2SQvyA4R6inSmGkJHIxahWHgMKRErDEgBvitMf23K/KitI/jMQGPJgMaKpqP5N/n0ALX PVkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792182513; x=1792787313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=02JAMWKdRQ16U0IDieCwBskgchSrhlfOdgVL8lNlzgI=; b=m8gdpm6HGLuFLHjg1CiRMuTHHEjfJJ8L0PerSPgH6qHB4ze1vAil1JVoFt+h2Apm6n /n8SykR6IaQsOaRQqbqoSE/+Rz6SMi/eZ7laEng9jEnjjPj+ElM/BRFpEIMrcUbxr6v4 NhztC7MC4cLQRhZYUFZlh3aMd7e1PgA4ZizpraTJ1l/aYVkGIYoEW3bnWEX/LepX+l0h qUthCNgpDUtoQ4xe9i9uQGjYevED0/TVFz84UlnwMFWDOXsycHLVyCAjSSm1DAOSBRo+ 2oz3seET2QwV0mgKWs4GLLXaUEHB3KxY+JWF+9P8fz17qYNy3CzPmUsCcSMje3qjFcak Iogg== X-Gm-Message-State: AFq9FYLMRR338EmlofAnlmjp2Lnjw4pKsMNBwA5IhOpBVgHsOmd6drmf SUogZbkWZEzBvr0MxyOLkNpL3mU3azM3x9coImTmJiJ3wYvDwyLF2PtvNKQhZKEjUOU= X-Gm-Gg: AYBFou0Xx6Ln23KAAEJdB3rUZcEvzHLJxPXUEV2WvGBtEJ1B4VcgWiIM5Cj/ENkQdPP obFF8A3FyxW6FVmI/kYhUDSlMXTwdUHLwsCtAoLp/j/MqWGmL6Gx810LmPLvyexZyllZta+gk71 8CGl9Q6/l3rfAHLwNRnFG+Z9G4AnuR6F0Qnpfsyy5xSYYDCeETECkUSiOL5EGi9Kbonduz1Qt3F xxpURA0ezJEOwEtq34nR6rd2G+phS+JpoTKirbnYsfuYt+WQyDhxxge3NL0seyeWdreRl41NSRt iwH9FVg5zc4bMjDWaCsquV5IJ5GG+z/Fm/nxaL0qAYCZDcQfiC0vcshRkHgJPuxcupZYBF4JWzd hTn1iAwhN9yPDQt62aa17I6q+31bsOgiXYEhEboUc3d3vwHnBARazNtx4U4AAtbG47pRKB3Jn/p tFVucJiPXxVYoPWmsUUvyBxLMe0wdzmyW/DF32HXFMis120FP3ahDDyIYlxUvIMG1nmVBUMb0/1 DHd7CIBLvmYmkCdnLc0pWq6sdE4 X-Received: by 2002:a05:6122:3383:b0:5e4:f6c8:b0a5 with SMTP id 71dfb90a1353d-5eaa9eb7173mr541171e0c.0.1792182512734; Fri, 16 Oct 2026 13:28:32 -0700 (PDT) Received: from localhost ([2601:19c:4a00:897d:3391:ed89:5571:41a8]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5ea9b2fef79sm2422500e0c.1.2026.10.16.13.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 13:28:31 -0700 (PDT) From: Ray Strode To: libcamera-devel@lists.libcamera.org Cc: kieran.bingham@ideasonboard.com, bod.linux@nxsw.ie, laurent.pinchart@ideasonboard.com Subject: [PATCH v3 04/11] tests: Validate the visible sensor crop Date: Fri, 16 Oct 2026 16:28:11 -0400 Message-ID: <20261016202818.1405645-5-halfline@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261016202818.1405645-1-halfline@gmail.com> References: <20261015223604.311616-1-halfline@gmail.com> <20261016202818.1405645-1-halfline@gmail.com> 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" From: Ray Strode The GPU debayer path selects its statistics window from the visible sensor crop. The geometry unit test checks the projection used for rendering. The project lacks a direct check that the sensor crop remains centered and follows the output aspect ratio without shrinking to the output resolution. This commit extends the geometry unit test with expected sensor rectangles for native, downscaled, wider, narrower, and portrait outputs. It also checks integer rounding that leaves an odd top coordinate before Bayer alignment. Signed-off-by: Ray Strode --- test/debayer-geometry.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/test/debayer-geometry.cpp b/test/debayer-geometry.cpp index 27458aa1..86d4248f 100644 --- a/test/debayer-geometry.cpp +++ b/test/debayer-geometry.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2026, Red Hat Inc. * - * Debayer projection tests + * Debayer projection and sensor crop tests */ #include @@ -23,7 +23,7 @@ class DebayerGeometryTest : public Test protected: int run() override { - if (testProjection()) + if (testProjection() || testCrop()) return TestFail; return TestPass; @@ -91,6 +91,38 @@ private: return TestPass; } + + int testCrop() + { + static const struct { + Size input; + Size native; + Size output; + Rectangle expected; + } cases[] = { + { { 1920, 1080 }, { 1920, 1080 }, { 1920, 1080 }, { 0, 0, 1920, 1080 } }, + { { 1928, 1092 }, { 1920, 1092 }, { 1920, 1092 }, { 4, 0, 1920, 1092 } }, + /* Output resolution changes must not shrink the sensor window. */ + { { 1928, 1092 }, { 1920, 1092 }, { 1920, 1080 }, { 4, 6, 1920, 1080 } }, + { { 1928, 1092 }, { 1920, 1092 }, { 1280, 720 }, { 4, 6, 1920, 1080 } }, + { { 1928, 1092 }, { 1920, 1092 }, { 640, 480 }, { 236, 0, 1456, 1092 } }, + { { 1928, 1092 }, { 1920, 1092 }, { 512, 768 }, { 600, 0, 728, 1092 } }, + { { 1928, 1092 }, { 1920, 1092 }, { 1280, 640 }, { 4, 66, 1920, 960 } }, + /* A smaller Bayer border leaves an odd top coordinate. */ + { { 1928, 1092 }, { 1924, 1092 }, { 1280, 720 }, { 2, 5, 1924, 1082 } }, + }; + + for (const auto &entry : cases) { + Rectangle crop = debayerCrop(entry.input, entry.native, entry.output); + if (crop != entry.expected) { + std::cerr << "Crop " << entry.input << " -> " << entry.output + << " is " << crop << ", expected " << entry.expected << std::endl; + return TestFail; + } + } + + return TestPass; + } }; TEST_REGISTER(DebayerGeometryTest)