From patchwork Thu Dec 12 17:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22300 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 A3283C3260 for ; Thu, 12 Dec 2024 17:56:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 59B7067EDB; Thu, 12 Dec 2024 18:56:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="T0wnppRv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B87E608B6 for ; Thu, 12 Dec 2024 18:56:43 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5CBAD18D; Thu, 12 Dec 2024 18:56:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734026169; bh=pwl5hD8uohDtgFFWnBC2oz1YAgD4XpeuhrKv58sQ9VA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0wnppRveks8H5pS7cwZFugT4atlyOTmLnLrZFEVMwjDiKBixsdzerSjalXUVbHVi KJxdXE9FvHR3pbAZjJNpctR7ZMl2JjpiM4V819iDhknwbIF+BewEUf7RmzpbRDXIzw KMg2J3CFZoB5r3KWqriZ+KJczjFIpnTscOL1zUyo= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: stefan.klug@ideasonboard.com, paul.elder@ideasonboard.com, Jacopo Mondi Subject: [PATCH v3.1 09/17] fixup! libcamera: converter: Add functions to adjust config Date: Thu, 12 Dec 2024 18:56:35 +0100 Message-ID: <20241212175635.99625-1-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206101344.767170-10-stefan.klug@ideasonboard.com> References: <20241206101344.767170-10-stefan.klug@ideasonboard.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" Signed-off-by: Jacopo Mondi --- include/libcamera/internal/converter.h | 10 ++++------ .../libcamera/internal/converter/converter_v4l2_m2m.h | 8 ++++---- src/libcamera/converter.cpp | 11 ++++------- src/libcamera/converter/converter_v4l2_m2m.cpp | 10 +++++----- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index 9213ae5b9c33..12de6aef0e40 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -43,11 +43,9 @@ public: enum class Alignment { Down = 0, - Up = (1 << 0), + Up, }; - using Alignments = Flags; - Converter(MediaDevice *media, Features features = Feature::None); virtual ~Converter(); @@ -60,16 +58,16 @@ public: virtual Size adjustInputSize(const PixelFormat &pixFmt, const Size &size, - Alignments align = Alignment::Down) = 0; + Alignment align = Alignment::Down) = 0; virtual Size adjustOutputSize(const PixelFormat &pixFmt, const Size &size, - Alignments align = Alignment::Down) = 0; + Alignment align = Alignment::Down) = 0; virtual std::tuple strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0; virtual int validateOutput(StreamConfiguration *cfg, bool *adjusted, - Alignments align = Alignment::Down) = 0; + Alignment align = Alignment::Down) = 0; virtual int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs) = 0; diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index 89bd2878b190..89c398614006 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -48,9 +48,9 @@ public: strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size); Size adjustInputSize(const PixelFormat &pixFmt, - const Size &size, Alignments align = Alignment::Down) override; + const Size &size, Alignment align = Alignment::Down) override; Size adjustOutputSize(const PixelFormat &pixFmt, - const Size &size, Alignments align = Alignment::Down) override; + const Size &size, Alignment align = Alignment::Down) override; int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfg); @@ -61,7 +61,7 @@ public: void stop(); int validateOutput(StreamConfiguration *cfg, bool *adjusted, - Alignments align = Alignment::Down) override; + Alignment align = Alignment::Down) override; int queueBuffers(FrameBuffer *input, const std::map &outputs); @@ -110,7 +110,7 @@ private: }; Size adjustSizes(const Size &size, const std::vector &ranges, - Alignments align); + Alignment align); std::unique_ptr m2m_; diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index c3da162b7de7..c373564d6007 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -60,11 +60,6 @@ LOG_DEFINE_CATEGORY(Converter) * \brief Adjust the Converter sizes to a larger valid size */ -/** - * \typedef Converter::Alignments - * \brief A bitwise combination of alignments supported by the converter - */ - /** * \brief Construct a Converter instance * \param[in] media The media device implementing the converter @@ -131,7 +126,8 @@ Converter::~Converter() * \param[in] pixFmt The pixel format of the converter input stream * \param[in] size The converter input size to adjust to a valid value * \param[in] align The desired alignment - * \return The adjusted converter input size + * \return The adjusted converter input size or a null Size if \a size cannot + * be adjusted */ /** @@ -140,7 +136,8 @@ Converter::~Converter() * \param[in] pixFmt The pixel format of the converter output stream * \param[in] size The converter output size to adjust to a valid value * \param[in] align The desired alignment - * \return The adjusted converter output size + * \return The adjusted converter output size or a null Size if \a size cannot + * be adjusted */ /** diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index 6857472b29f2..17098f69c934 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -405,7 +405,7 @@ V4L2M2MConverter::strideAndFrameSize(const PixelFormat &pixelFormat, * \copydoc libcamera::Converter::adjustInputSize */ Size V4L2M2MConverter::adjustInputSize(const PixelFormat &pixFmt, - const Size &size, Alignments align) + const Size &size, Alignment align) { auto formats = m2m_->output()->formats(); V4L2PixelFormat v4l2PixFmt = m2m_->output()->toV4L2PixelFormat(pixFmt); @@ -424,7 +424,7 @@ Size V4L2M2MConverter::adjustInputSize(const PixelFormat &pixFmt, * \copydoc libcamera::Converter::adjustOutputSize */ Size V4L2M2MConverter::adjustOutputSize(const PixelFormat &pixFmt, - const Size &size, Alignments align) + const Size &size, Alignment align) { auto formats = m2m_->capture()->formats(); V4L2PixelFormat v4l2PixFmt = m2m_->capture()->toV4L2PixelFormat(pixFmt); @@ -441,7 +441,7 @@ Size V4L2M2MConverter::adjustOutputSize(const PixelFormat &pixFmt, Size V4L2M2MConverter::adjustSizes(const Size &cfgSize, const std::vector &ranges, - Alignments align) + Alignment align) { Size size = cfgSize; @@ -495,7 +495,7 @@ Size V4L2M2MConverter::adjustSizes(const Size &cfgSize, * alignment: smaller than s1 if we align down, larger than s1 * if we align up. */ - auto nextSizeValid = [](const Size &s1, const Size &s2, Alignments a) { + auto nextSizeValid = [](const Size &s1, const Size &s2, Alignment a) { return a == Alignment::Down ? (s1.width > s2.width && s1.height > s2.height) : (s1.width < s2.width && s1.height < s2.height); @@ -633,7 +633,7 @@ void V4L2M2MConverter::stop() * \copydoc libcamera::Converter::validateOutput */ int V4L2M2MConverter::validateOutput(StreamConfiguration *cfg, bool *adjusted, - Alignments align) + Alignment align) { V4L2VideoDevice *capture = m2m_->capture(); V4L2VideoDevice::Formats fmts = capture->formats();