From patchwork Mon Oct 11 07:35:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 14077 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 5E6CAC323E for ; Mon, 11 Oct 2021 07:35:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2ADB368F4E; Mon, 11 Oct 2021 09:35:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="k1TA4rFy"; 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 EEC3568F4C for ; Mon, 11 Oct 2021 09:35:18 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.107]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A1B3A2BD; Mon, 11 Oct 2021 09:35:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1633937718; bh=CTheA1PRCa4GFq+iWAoQIypHnIjfkEBaFYGUCjCRNmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1TA4rFyUrhrJ3so0bZxlEh7+KimQNQLxT51NZJrFpmdYVTnDFDnT3jLejRIEnNmn uX0fONBKfpK9a98e7NKgxC993jOKGuzT+gxlH5NpeuTCDkfqHQtwWEL0niED9d65A0 Z+Zv7kW11u8hMTT53YuW8xeWdwq3eNiCiiZuHfNc= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Oct 2021 13:05:00 +0530 Message-Id: <20211011073505.243864-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211011073505.243864-1-umang.jain@ideasonboard.com> References: <20211011073505.243864-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/7] android: camera_stream: Plumb process() with Camera3RequestDescriptor 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" Data (or broader context) required for post processing of a camera request is saved via Camera3RequestDescriptor. Instead of passing individual arguments to CameraStream::process(), pass the Camera3RequestDescriptor pointer to it. All the arguments necessary to run the post-processor can be accessed from the descriptor. In subsequent commits, we will prepare the post-processor to run asynchronously. Hence, it will require the Camera3RequestDescriptor pointer to be emitted back in the post-processing completion handler to finally complete the request (i.e. sending the capture results back to the framework). Store result metadata which is sent as capture results into the Camera3RequestDescriptor. This is will remove the need to send the result metadata pointer separately to CameraStream::process(). In the subsequent commit, a Camera3RequestDescriptor pointer will be passed to CameraStream::process() and the result metadata can be directly accessed from there. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda --- src/android/camera_device.cpp | 9 +++++---- src/android/camera_device.h | 1 + src/android/camera_stream.cpp | 5 ++--- src/android/camera_stream.h | 5 +++-- src/android/jpeg/post_processor_jpeg.cpp | 5 +++-- src/android/jpeg/post_processor_jpeg.h | 3 +-- src/android/post_processor.h | 5 +++-- src/android/yuv/post_processor_yuv.cpp | 3 +-- src/android/yuv/post_processor_yuv.h | 3 +-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 48a96d0c..b52bdc8f 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1207,6 +1207,8 @@ void CameraDevice::requestComplete(Request *request) resultMetadata = std::make_unique(0, 0); } + descriptor->resultMetadata_ = std::move(resultMetadata); + /* Handle post-processing. */ for (camera3_stream_buffer_t &buffer : descriptor->buffers_) { CameraStream *cameraStream = @@ -1224,9 +1226,8 @@ void CameraDevice::requestComplete(Request *request) continue; } - int ret = cameraStream->process(*src, buffer, - descriptor->settings_, - resultMetadata.get()); + int ret = cameraStream->process(*src, buffer, descriptor); + /* * Return the FrameBuffer to the CameraStream now that we're * done processing it. @@ -1241,7 +1242,7 @@ void CameraDevice::requestComplete(Request *request) } } - captureResult.result = resultMetadata->get(); + captureResult.result = descriptor->resultMetadata_->get(); descriptor->status_ = Camera3RequestDescriptor::Status::Success; sendCaptureResults(); } diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 26d1c6de..3da8dffa 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -55,6 +55,7 @@ struct Camera3RequestDescriptor { std::vector> frameBuffers_; CameraMetadata settings_; std::unique_ptr request_; + std::unique_ptr resultMetadata_; camera3_capture_result_t captureResult_ = {}; Status status_ = Status::Pending; diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 3b96d2e9..8f47e4d8 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -144,8 +144,7 @@ int CameraStream::waitFence(int fence) int CameraStream::process(const FrameBuffer &source, camera3_stream_buffer_t &camera3Dest, - const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata) + Camera3RequestDescriptor *request) { /* Handle waiting on fences on the destination buffer. */ int fence = camera3Dest.acquire_fence; @@ -175,7 +174,7 @@ int CameraStream::process(const FrameBuffer &source, return -EINVAL; } - return postProcessor_->process(source, &dest, requestMetadata, resultMetadata); + return postProcessor_->process(source, &dest, request); } FrameBuffer *CameraStream::getBuffer() diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 03ecfa94..04cfd111 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -23,6 +23,8 @@ class CameraDevice; class CameraMetadata; class PostProcessor; +struct Camera3RequestDescriptor; + class CameraStream { public: @@ -120,8 +122,7 @@ public: int configure(); int process(const libcamera::FrameBuffer &source, camera3_stream_buffer_t &camera3Buffer, - const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata); + Camera3RequestDescriptor *request); libcamera::FrameBuffer *getBuffer(); void putBuffer(libcamera::FrameBuffer *buffer); diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index f6d47f63..656c48b2 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -99,14 +99,15 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, int PostProcessorJpeg::process(const FrameBuffer &source, CameraBuffer *destination, - const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata) + Camera3RequestDescriptor *request) { if (!encoder_) return 0; ASSERT(destination->numPlanes() == 1); + const CameraMetadata &requestMetadata = request->settings_; + CameraMetadata *resultMetadata = request->resultMetadata_.get(); camera_metadata_ro_entry_t entry; int ret; diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index 6fd31022..0184d77e 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -24,8 +24,7 @@ public: const libcamera::StreamConfiguration &outcfg) override; int process(const libcamera::FrameBuffer &source, CameraBuffer *destination, - const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata) override; + Camera3RequestDescriptor *request) override; private: void generateThumbnail(const libcamera::FrameBuffer &source, diff --git a/src/android/post_processor.h b/src/android/post_processor.h index ab2b2c60..fa13c7e0 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -14,6 +14,8 @@ class CameraMetadata; +struct Camera3RequestDescriptor; + class PostProcessor { public: @@ -23,8 +25,7 @@ public: const libcamera::StreamConfiguration &outCfg) = 0; virtual int process(const libcamera::FrameBuffer &source, CameraBuffer *destination, - const CameraMetadata &requestMetadata, - CameraMetadata *resultMetadata) = 0; + Camera3RequestDescriptor *request) = 0; }; #endif /* __ANDROID_POST_PROCESSOR_H__ */ diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 7b3b4960..8110a1f1 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -51,8 +51,7 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg, int PostProcessorYuv::process(const FrameBuffer &source, CameraBuffer *destination, - [[maybe_unused]] const CameraMetadata &requestMetadata, - [[maybe_unused]] CameraMetadata *metadata) + [[maybe_unused]] Camera3RequestDescriptor *request) { if (!isValidBuffers(source, *destination)) return -EINVAL; diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h index 12f7af07..a4e0ff5d 100644 --- a/src/android/yuv/post_processor_yuv.h +++ b/src/android/yuv/post_processor_yuv.h @@ -20,8 +20,7 @@ public: const libcamera::StreamConfiguration &outcfg) override; int process(const libcamera::FrameBuffer &source, CameraBuffer *destination, - const CameraMetadata &requestMetadata, - CameraMetadata *metadata) override; + Camera3RequestDescriptor *request) override; private: bool isValidBuffers(const libcamera::FrameBuffer &source,