From patchwork Mon Sep 21 18:32:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9682 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 C7FADBF01C for ; Mon, 21 Sep 2020 18:32:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 514D962FD3; Mon, 21 Sep 2020 20:32:13 +0200 (CEST) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E5AC62B90 for ; Mon, 21 Sep 2020 20:32:12 +0200 (CEST) X-Halon-ID: c01a0436-fc38-11ea-92dc-005056917a89 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id c01a0436-fc38-11ea-92dc-005056917a89; Mon, 21 Sep 2020 20:32:10 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Sep 2020 20:32:05 +0200 Message-Id: <20200921183205.2516132-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC] libcamera: buffer: Remove copyFrom() 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 are no user left of the copyFrom() operation, remove it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/buffer.h | 2 -- src/libcamera/buffer.cpp | 59 -------------------------------------- 2 files changed, 61 deletions(-) --- Hello, I'm not sure it's wise to leave this operation in the code while we have no users. But I do fear we might need it the future, but as we don't use or test it I'm sure we will have modified FrameBuffer enough to make this incomplete at that that so I think it's best to remove it. What do you guys think? Regards Niklas diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 6bb2e4f8558f03ac..a26c8927d37a812e 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -57,8 +57,6 @@ public: unsigned int cookie() const { return cookie_; } void setCookie(unsigned int cookie) { cookie_ = cookie; } - - int copyFrom(const FrameBuffer *src); private: friend class Request; /* Needed to update request_. */ friend class V4L2VideoDevice; /* Needed to update metadata_. */ diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 03f628e8b585a1f9..75b2693281a74cdc 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -226,65 +226,6 @@ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) * core never modifies the buffer cookie. */ -/** - * \brief Copy the contents from another buffer - * \param[in] src FrameBuffer to copy - * - * Copy the buffer contents and metadata from \a src to this buffer. The - * destination FrameBuffer shall have the same number of planes as the source - * buffer, and each destination plane shall be larger than or equal to the - * corresponding source plane. - * - * The complete metadata of the source buffer is copied to the destination - * buffer. If an error occurs during the copy, the destination buffer's metadata - * status is set to FrameMetadata::FrameError, and other metadata fields are not - * modified. - * - * The operation is performed using memcpy() so is very slow, users needs to - * consider this before copying buffers. - * - * \return 0 on success or a negative error code otherwise - */ -int FrameBuffer::copyFrom(const FrameBuffer *src) -{ - if (planes_.size() != src->planes_.size()) { - LOG(Buffer, Error) << "Different number of planes"; - metadata_.status = FrameMetadata::FrameError; - return -EINVAL; - } - - for (unsigned int i = 0; i < planes_.size(); i++) { - if (planes_[i].length < src->planes_[i].length) { - LOG(Buffer, Error) << "Plane " << i << " is too small"; - metadata_.status = FrameMetadata::FrameError; - return -EINVAL; - } - } - - MappedFrameBuffer source(src, PROT_READ); - MappedFrameBuffer destination(this, PROT_WRITE); - - if (!source.isValid()) { - LOG(Buffer, Error) << "Failed to map source planes"; - return -EINVAL; - } - - if (!destination.isValid()) { - LOG(Buffer, Error) << "Failed to map destination planes"; - return -EINVAL; - } - - for (unsigned int i = 0; i < planes_.size(); i++) { - memcpy(destination.maps()[i].data(), - source.maps()[i].data(), - source.maps()[i].size()); - } - - metadata_ = src->metadata_; - - return 0; -} - /** * \class MappedBuffer * \brief Provide an interface to support managing memory mapped buffers