From patchwork Thu Jun 23 23:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16348 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 B532EBD808 for ; Thu, 23 Jun 2022 23:22:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 70C7765637; Fri, 24 Jun 2022 01:22:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656026552; bh=0wpZYTfLk/Mcc6U4ycBHRlBVzwvx/QvEUATQ8Os0Nes=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NmRxF9zTc3Stjcol2eD0MUXbr9fj4YFhtok5TqgIE22HX2rwHNBOPKFjAGNow+yAs +L6PV8H7DIaF8LylBf4IEWCDuT+02EH2ncp2320YQ580ZOcG+KhxFrbzHJR/PYRqXu K5au1Y9ujTeuNN4cSH4YUwTC1Wc31EG+xfGvpoAElzXTeHiYLM4b9xSjeHahVw+7KX xGQNEJ1jiZpdRT+79con6ETrQbZUDSpsZeMJKKaMTaCzlQT1PDLhdcAoPbB34kp/sy D13xoadveagajpJg0Ry0tK2TpHbL7yNfUn4krmyeopXia4NFNEEZeD09RvKF9CNTmu Iv2Utx9Lk5EAA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9AFA61FB2 for ; Fri, 24 Jun 2022 01:22:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CMjoRpaV"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A1D680A; Fri, 24 Jun 2022 01:22:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656026549; bh=0wpZYTfLk/Mcc6U4ycBHRlBVzwvx/QvEUATQ8Os0Nes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CMjoRpaVgc+qKYe4dzNa2jAscxBrleGV76UGYGTW//VPzL88tYvCPo8XF3Mj1hmwg 4MQnC97+tumuLXyS7GdkGq0mCP+ijhULfNhep/CWt7tHL1Fl4VstLSqpd0lAlO3v6R 1UvsQ7erqT3PXVktEeV0A1LT/T04ZfQLNiPUXGWE= To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Jun 2022 02:21:59 +0300 Message-Id: <20220623232210.18742-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220623232210.18742-1-laurent.pinchart@ideasonboard.com> References: <20220623232210.18742-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/13] gstreamer: Inline gst_libcamera_buffer_get_frame_buffer() 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Nicolas Dufresne , Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The gst_libcamera_buffer_get_frame_buffer() function retrieves a FrameBuffer corresponding to the GstBuffer. While the GstLibcameraPool class allocates the GstBuffer instances, associating them to a FrameBuffer is handled by GstLibcameraAllocator. The gst_libcamera_buffer_get_frame_buffer() function is ill-placed in gstlibcamerapool.cpp. Move it to gstlibcameraallocator.cpp, which allows inlining it in its single caller, simplifying the code flow. Signed-off-by: Laurent Pinchart --- src/gstreamer/gstlibcameraallocator.cpp | 3 ++- src/gstreamer/gstlibcameraallocator.h | 2 +- src/gstreamer/gstlibcamerapool.cpp | 7 ------- src/gstreamer/gstlibcamerapool.h | 2 -- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp index c740b8fc82a8..53693834eeff 100644 --- a/src/gstreamer/gstlibcameraallocator.cpp +++ b/src/gstreamer/gstlibcameraallocator.cpp @@ -252,8 +252,9 @@ gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *self, } FrameBuffer * -gst_libcamera_memory_get_frame_buffer(GstMemory *mem) +gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer) { + GstMemory *mem = gst_buffer_peek_memory(buffer, 0); auto *frame = reinterpret_cast(gst_mini_object_get_qdata(GST_MINI_OBJECT_CAST(mem), FrameWrap::getQuark())); return frame->buffer_; diff --git a/src/gstreamer/gstlibcameraallocator.h b/src/gstreamer/gstlibcameraallocator.h index 0a08c3bb3bbe..b1c038c50257 100644 --- a/src/gstreamer/gstlibcameraallocator.h +++ b/src/gstreamer/gstlibcameraallocator.h @@ -28,4 +28,4 @@ bool gst_libcamera_allocator_prepare_buffer(GstLibcameraAllocator *self, gsize gst_libcamera_allocator_get_pool_size(GstLibcameraAllocator *allocator, libcamera::Stream *stream); -libcamera::FrameBuffer *gst_libcamera_memory_get_frame_buffer(GstMemory *mem); +libcamera::FrameBuffer *gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer); diff --git a/src/gstreamer/gstlibcamerapool.cpp b/src/gstreamer/gstlibcamerapool.cpp index 1fde42135119..118bc6db7067 100644 --- a/src/gstreamer/gstlibcamerapool.cpp +++ b/src/gstreamer/gstlibcamerapool.cpp @@ -140,10 +140,3 @@ gst_libcamera_buffer_get_stream(GstBuffer *buffer) auto *self = (GstLibcameraPool *)buffer->pool; return self->stream; } - -FrameBuffer * -gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer) -{ - GstMemory *mem = gst_buffer_peek_memory(buffer, 0); - return gst_libcamera_memory_get_frame_buffer(mem); -} diff --git a/src/gstreamer/gstlibcamerapool.h b/src/gstreamer/gstlibcamerapool.h index 05795d21223e..06b38cb296fc 100644 --- a/src/gstreamer/gstlibcamerapool.h +++ b/src/gstreamer/gstlibcamerapool.h @@ -26,5 +26,3 @@ GstLibcameraPool *gst_libcamera_pool_new(GstLibcameraAllocator *allocator, libcamera::Stream *gst_libcamera_pool_get_stream(GstLibcameraPool *self); libcamera::Stream *gst_libcamera_buffer_get_stream(GstBuffer *buffer); - -libcamera::FrameBuffer *gst_libcamera_buffer_get_frame_buffer(GstBuffer *buffer);