From patchwork Tue Dec 17 17:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22384 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 90882C32F6 for ; Tue, 17 Dec 2024 17:47:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AC21C67FFB; Tue, 17 Dec 2024 18:47:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="gshkXtYZ"; dkim-atps=neutral Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E096A67FD3 for ; Tue, 17 Dec 2024 18:47:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1734457636; x=1734716836; bh=pLditt3JNEejQpDLu7LxfIdnWqJm03YZUdqiX/aRgmY=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=gshkXtYZFGowEugyvhAHZtM7O7JXFgqZEICuzBvtUfH/KgwYjmUSVj9xz3BfdVvx2 Hk0aLg5l70jiQVQUVXYEfStx1wzmVsCGktD5Acj2M/mBqHyCEeH5ZizfizaIO0qZvu i8Mie8gJ/OLT01vCEHEsG3xJgSCKhx72BxYdMDRq3tzaDX6XsC27rv9vnKk61AYtsw w2olcXwPFg6eB1LQx2j7iSMIj+oFjJdkN6EF8a1J/fC/2qOoAzfrkgwHoIq/d5UXFS Yhur+tHZqb86lbccRCocHVRZK62x/avyxOzPITzFlBABEs0696ajX9QiL+5N+8ADNe J811FNv9G3JJg== Date: Tue, 17 Dec 2024 17:47:09 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Laurent Pinchart , Kieran Bingham Subject: [PATCH v2 1/3] libcamera: virtual: Avoid some copies Message-ID: <20241217174707.174777-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: a418a188be5d07292092fcf2f7f2726942aa7e10 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" There is no reason make copies, these functions return const lvalue references, access the data through those. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/virtual/image_frame_generator.cpp | 2 +- src/libcamera/pipeline/virtual/test_pattern_generator.cpp | 2 +- src/libcamera/pipeline/virtual/virtual.cpp | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/virtual/image_frame_generator.cpp b/src/libcamera/pipeline/virtual/image_frame_generator.cpp index 277efbb09..d1545b5d9 100644 --- a/src/libcamera/pipeline/virtual/image_frame_generator.cpp +++ b/src/libcamera/pipeline/virtual/image_frame_generator.cpp @@ -129,7 +129,7 @@ int ImageFrameGenerator::generateFrame(const Size &size, const FrameBuffer *buff MappedFrameBuffer mappedFrameBuffer(buffer, MappedFrameBuffer::MapFlag::Write); - auto planes = mappedFrameBuffer.planes(); + const auto &planes = mappedFrameBuffer.planes(); /* Loop only around the number of images available */ frameIndex_ %= imageFrameDatas_.size(); diff --git a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp index 7bc2b338c..47d341919 100644 --- a/src/libcamera/pipeline/virtual/test_pattern_generator.cpp +++ b/src/libcamera/pipeline/virtual/test_pattern_generator.cpp @@ -25,7 +25,7 @@ int TestPatternGenerator::generateFrame(const Size &size, MappedFrameBuffer mappedFrameBuffer(buffer, MappedFrameBuffer::MapFlag::Write); - auto planes = mappedFrameBuffer.planes(); + const auto &planes = mappedFrameBuffer.planes(); shiftLeft(size); diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index a44f286b7..ce0c38813 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -274,8 +274,7 @@ int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera, return -ENOBUFS; const StreamConfiguration &config = stream->configuration(); - - auto info = PixelFormatInfo::info(config.pixelFormat); + const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); std::vector planeSizes; for (size_t i = 0; i < info.planes.size(); ++i)