From patchwork Fri Oct 16 20:28:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Strode X-Patchwork-Id: 28478 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 402A4C3305 for ; Fri, 16 Oct 2026 20:28:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B152F68E51; Fri, 16 Oct 2026 22:28:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iLfw5Lzq"; 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 2A4EF68E37 for ; Fri, 16 Oct 2026 22:28:36 +0200 (CEST) Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-5eaaa9b1591so190517e0c.3 for ; Fri, 16 Oct 2026 13:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792182515; x=1792787315; 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=MOPWXvnjHEaRoUjCDQjpT4jlwb+rRUMODm1OtxXGYL4=; b=iLfw5LzqaTN7b4UniSDYXyYEcQowsGI1X1odKS0u+YPDsN4ScmDnhUjUwRVC89Iu+Y ONN8WufLu/4k9f4Hp1PovX0ZEp0WRzzYqYQoo4LhiNvtyOZcavr6n2LI9CuwEPgPCne/ F6b4uVghs0FsLDDM5QZGrwhdFA5Ui0WtDiWYMb4WtnWswJysp5ePJwi7y52Tq88NlRIS Y2AgBeU31I5hkYG7rC0Vx2f1MKu9LyRo1dARJPJ+/Zw43tEmhlLstKTn1eCgPWu/isjo zOxoKWS0Llhuham4owHkXnarEXpgckxdWEXPc2lEf+2n4Eyk7YheV8MGLe/wxAzHmYVS KzHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792182515; x=1792787315; 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=MOPWXvnjHEaRoUjCDQjpT4jlwb+rRUMODm1OtxXGYL4=; b=Tm5VcP5uAuy62e31+2a4QH1Bv3gtQdgVNMODUwec+FUbCO5IySnJ5nVwVtEDx4VQso 2fcpI+H9hlFP3WEOI+P7KP1DTiNWCoaTbY2WLyzoiBLi+fWzjx2kzSL6l8Fn45/ZYGY+ dWwC8+IDAEP3N5gtFRGu43MFp7Pl9SFs3fAFGSW199SrUmgPBCGJkRiiHsMuY/CU1/OS GxzIKRKlE05ofYa6jw4rVVyIX7K2nbRnDoR4EbS842eEVmonf/P+SKmJDdGrUOOhoqRr xueDg2WXnLP11V8zopeKkZEa5Um7BgjbuRf5GJVAyPMGYxz3VlqQsMU/ZXsr5Q3+jSGm Ej0w== X-Gm-Message-State: AFq9FYJGgATIBKe/GbYp/AOtAnRJvENqxQXhRUooJwLPQzLXKTOSYEMg QG4W+4f7qIvisiSccWqx/ZOCKpCrWursVj5AO15vDAlSlqT7lapb00KKc4HhXu8Hvf4= X-Gm-Gg: AYBFou2kxeWx3RWsXwIXnt129paG/NlEEzJ/f19cPDpR7/dehBn9/4jGqLRla3mvXed ZWDAXvK0guwDaXZw3qTuLaZw31dviS03/Sa86o7dPeWPKHONwniWCd87KmAsEyg1+gha410QTag CSA5Zf3SHZBWGLmNPas66N1X7YVXoE8bCu5K47ojVgRoyD97/AYCQYf7VMZ8MZbACdxNcD2SpFB eLoFjbvAegNR6IVMmwuwRGvui+1PF0rcHkbIR7NdiAsWzdT7AD/7hloYR2IDxW8qjFg5mfAabrz pwvdcVzTn+qtvh+v5TURzC8MwUpD5hLd3cHuZYwyDSrubn+g8P3bHfp30QU6C3cWxyaJG6fMae8 FkONmAXV6mJ2U4QLgeALn/4mH3w4Tb4uDMuchNxECmum8RZqJKSA0pZO1S6uH2QNEGPBjv8JGbg ziwgzCm3aiWmq8HVWWfU1q5+D00VfWVWbN9PovuHhFA5LMKnyZsK7itqfuBN3UrpKphxvhPPVHA nP32snaYUtBl36O732dY+zaNIz9 X-Received: by 2002:a05:6122:311e:b0:5db:8e8e:41fa with SMTP id 71dfb90a1353d-5eaacc383d4mr254968e0c.7.1792182515019; Fri, 16 Oct 2026 13:28:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2026 13:28:34 -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 06/11] tests: Check the configured CPU image crop Date: Fri, 16 Oct 2026 16:28:13 -0400 Message-ID: <20261016202818.1405645-7-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 This commit checks the crop returned by CPU debayering for supported Bayer input formats and both RGB channel orders. Unpacked kernels may shift the first rendered pixel by one column depending on the Bayer pattern and output channel order. The reported image region must include that shift, while the specialized packed kernels retain their unshifted origin. The configuration-only cases cover all four standard Bayer orders at 8, 10 and 12 bits, including packed RAW10 and RAW12. Reusing the debayer across configurations also checks that changing formats clears a previous phase shift. Signed-off-by: Ray Strode --- test/meson.build | 1 + test/software_isp/debayer-crop.cpp | 102 +++++++++++++++++++++++++++++ test/software_isp/meson.build | 20 ++++++ 3 files changed, 123 insertions(+) create mode 100644 test/software_isp/debayer-crop.cpp create mode 100644 test/software_isp/meson.build diff --git a/test/meson.build b/test/meson.build index 5027b7b1..fc72d105 100644 --- a/test/meson.build +++ b/test/meson.build @@ -35,6 +35,7 @@ subdir('media_device') subdir('process') subdir('py') subdir('serialization') +subdir('software_isp') subdir('stream') subdir('v4l2_compat') subdir('v4l2_subdevice') diff --git a/test/software_isp/debayer-crop.cpp b/test/software_isp/debayer-crop.cpp new file mode 100644 index 00000000..40355b5a --- /dev/null +++ b/test/software_isp/debayer-crop.cpp @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2026, Red Hat Inc. + * + * CPU debayer crop configuration tests + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "libcamera/internal/formats.h" +#include "libcamera/internal/software_isp/swstats_cpu.h" + +#include "debayer_cpu.h" +#include "test.h" + +using namespace libcamera; + +class DebayerCropTest : public Test +{ +protected: + int run() override + { + CameraManager manager; + auto stats = std::make_unique(manager); + if (!stats->isValid()) + return TestFail; + + DebayerCpu debayer(std::move(stats), manager); + static const struct { + PixelFormat input; + int rgbShift; + int bgrShift; + } cases[] = { + { formats::SBGGR8, 0, 1 }, + { formats::SGBRG8, 1, 0 }, + { formats::SGRBG8, 0, 1 }, + { formats::SRGGB8, 1, 0 }, + { formats::SBGGR10, 0, 1 }, + { formats::SGBRG10, 1, 0 }, + { formats::SGRBG10, 0, 1 }, + { formats::SRGGB10, 1, 0 }, + { formats::SBGGR12, 0, 1 }, + { formats::SGBRG12, 1, 0 }, + { formats::SGRBG12, 0, 1 }, + { formats::SRGGB12, 1, 0 }, + /* Packed kernels use each Bayer order without a phase shift. */ + { formats::SBGGR10_CSI2P, 0, 0 }, + { formats::SGBRG10_CSI2P, 0, 0 }, + { formats::SGRBG10_CSI2P, 0, 0 }, + { formats::SRGGB10_CSI2P, 0, 0 }, + { formats::SBGGR12_CSI2P, 0, 0 }, + { formats::SGBRG12_CSI2P, 0, 0 }, + { formats::SGRBG12_CSI2P, 0, 0 }, + { formats::SRGGB12_CSI2P, 0, 0 }, + }; + + for (const auto &entry : cases) { + StreamConfiguration input; + input.pixelFormat = entry.input; + input.size = { 1928, 1092 }; + input.stride = PixelFormatInfo::info(entry.input).stride(input.size.width, 0); + + for (PixelFormat format : { formats::RGB888, formats::BGR888, + formats::XRGB8888, formats::XBGR8888 }) { + StreamConfiguration output; + output.pixelFormat = format; + output.size = { 1280, 720 }; + std::tie(output.stride, output.frameSize) = + debayer.strideAndFrameSize(format, output.size); + const std::vector> outputs{ output }; + if (debayer.configure(input, outputs, false)) { + std::cerr << "Unable to configure " << entry.input << " -> " << format + << std::endl; + return TestFail; + } + + int shift = (format == formats::RGB888 || format == formats::XRGB8888) + ? entry.rgbShift + : entry.bgrShift; + Rectangle expected(324 + shift, 186, 1280, 720); + if (debayer.inputCrop() != expected) { + std::cerr << "Crop for " << entry.input << " -> " << format << " is " + << debayer.inputCrop() << ", expected " << expected << std::endl; + return TestFail; + } + } + } + + return TestPass; + } +}; + +TEST_REGISTER(DebayerCropTest) diff --git a/test/software_isp/meson.build b/test/software_isp/meson.build new file mode 100644 index 00000000..ebabde59 --- /dev/null +++ b/test/software_isp/meson.build @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: CC0-1.0 + +if not softisp_enabled + subdir_done() +endif + +software_isp_tests = [ + {'name': 'debayer-crop', 'sources': ['debayer-crop.cpp']}, +] + +foreach test : software_isp_tests + exe = executable(test['name'], test['sources'], + dependencies : libcamera_private, + implicit_include_directories : false, + link_with : test_libraries, + include_directories : [test_includes_internal, + '../../src/libcamera/software_isp/']) + + test(test['name'], exe, suite : 'software_isp') +endforeach