From patchwork Thu Oct 15 22:36:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28470 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 F3CD5C3357 for ; Thu, 15 Oct 2026 22:36:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E33FE68E1F; Fri, 16 Oct 2026 00:36:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dvyA1RfV"; dkim-atps=neutral Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 95F6768E1C for ; Fri, 16 Oct 2026 00:36:18 +0200 (CEST) Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-7c420c2c4faso3785758137.1 for ; Thu, 15 Oct 2026 15:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792103777; x=1792708577; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=baHwsbZhar5+TW7IU/+ueixmwWLl9jAPh4Ih8iGpoLc=; b=dvyA1RfVpao/5te/mLE1NuxFSmhOfZc7WI0RZdR12sCKMmZ6Zz//pQm9GxsULa88/E YkPq7mW7RLKWZ/MXckdKLkDc93LrRxsJN11NNfOZ3Lso6/HYWpt+sY1zkgEv2c2WLHBT cG7f4YNXG3/H6lwL9EHQ1srdantUQD8uAww2RXrPZIlkr+lgxCUSzPAfmCWkPmV+14r5 KCg6HhRBBC1G2xd/JSiOhvPth9+rGngIhmaPameACl3S1DSKdfKFsvMdEgYNjWpWGRYw aToaiX15rl/OsA3tZoaRxF74ZYtziHqt2whIPpn4Ay8v/+lgcZSi4Qn7nzZ13Jx5ye3y TfCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792103777; x=1792708577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=baHwsbZhar5+TW7IU/+ueixmwWLl9jAPh4Ih8iGpoLc=; b=meonXtxTVT2YjT6nN2ys+NKZLqvz2No1SAWIwoDZdC6/5gLILXtluaXuELiHQfyKaE 7ppZUqSuhiQEvXxhjfiVku7ISVCQ+5HFRttpqDgpMdc1/O5SHd2z09S4YtE5OI+ziXLW /HKOGA3LKds2oIiQxG/5a4LbOR6LBCB8HsjVEs/b+0vjO/+JrzZtefswYwkoX7ERJ58y ixy2tUi1ysmMshpvugF4+ZY1Z+8trFES8WIuBm7U0edhkhQJA7yoR6Fpbngkl0OX+NSR ZYo5FTkuIsCmYcK8mkiHHIqYRJRgzSX4dPm4PRaimcrNnwKgUTn1pDObhuZ14mnftFqW tafw== X-Gm-Message-State: AFq9FYISDvN2JH1a6O5VdOn2LFGIuWAETBXYu91RmBhCFo5sKam7XZFO LE33IQOFzKd0zAmH6T4qqRuf+2dBPWB4eF/6zkzrST7wFO9oSu+0PXdH+gPDUEtufva0MQ== X-Gm-Gg: AYBFou2GvRSwI+CaSY2Dmc1MKfxL7qINI2NppoGKhdB9OJck0pFj9A0pANB9sc051Gi zs2PRP/8SYPwIZaQcn1QP0+dr3fUBJyD0I/cq5Vgxd7NjmO0oKW4x/InxIxNOSF3yXoZonq77VA 4XgLd174qaBpZaT9AhGsWXXFto6/rVaWO5xcA7MHGnboTxs59eTsjkfzf9hMQPD/FSae+7yF7Zw xGicT7APVRLiiUGvgnBt6bAmZt2L+HpbtwKjT6DJ4MIAixwjXhftBWLPSleg4J+MKHkNCMUCOI/ vYPa+ogyLefkWaWK+1RBz9pnmI9IlslYgvMtcXVZf8IDDlZvY7qM7yWQKaA8Co7EYS/mk/e1t8i AoGdu/NwvxSQLOKlvXfk/QkmXakrjrYOVda/lButDuy3h7qj4tZ9GGez2laLYvBdTEWAGVJWggz 0wWpDUsgvmtDKvRtwChxVOTiwOCpFvlQ8ImrgvufX0YInVBlO3EYJ7CEBVeilg8l+VDRy4NKiC8 jH1mQz2ikmGK9ZjwiBpNHfTtA+q X-Received: by 2002:a05:6102:448c:b0:7c3:99a3:314a with SMTP id ada2fe7eead31-7cb3729b087mr7508083137.9.1792103777134; Thu, 15 Oct 2026 15:36:17 -0700 (PDT) Received: from localhost ([2601:19c:4a00:897d:3391:ed89:5571:41a8]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7cc198794desm909192137.9.2026.10.15.15.36.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2026 15:36:16 -0700 (PDT) From: Ray Strode To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 4/4] tests: Validate the visible sensor crop Date: Thu, 15 Oct 2026 18:36:04 -0400 Message-ID: <20261015223604.311616-5-halfline@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261015223604.311616-1-halfline@gmail.com> References: <20261015194335.287960-1-halfline@gmail.com> <20261015223604.311616-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 | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/test/debayer-geometry.cpp b/test/debayer-geometry.cpp index 8719b9f5..706a4971 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; @@ -93,6 +93,37 @@ 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)