From patchwork Mon Oct 11 07:35:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 14079 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 1BC4AC323E for ; Mon, 11 Oct 2021 07:35:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5905468F57; Mon, 11 Oct 2021 09:35:24 +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="rzDq+zON"; 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 748E068F4C for ; Mon, 11 Oct 2021 09:35:22 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.107]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E3CA2BD; Mon, 11 Oct 2021 09:35:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1633937722; bh=OH/IvMPL/5DidY8odwhuRRvjKOYw6D41+284OpPODSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rzDq+zONXkP/LsakH8wTAMQx9Q5YXEZlrUELvv74nvnEOfZLFDHBtWdlricyw0sFw nSLAf3L5sDVtIrBpgfNhFXnxNoS8ikYXgg03P6u9Ryptu+kx5/1Tda+ABHk8heS8xG 1GHtTr+vtBZk7j2twW40PhQIgeJP97LcJAJgZJOM= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Oct 2021 13:05:02 +0530 Message-Id: <20211011073505.243864-5-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 4/7] android: camera_stream: Drop return value for process() 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" CameraStream::process() is invoked by CameraDevice::requestComplete() in case any post-processing is required for the camera stream. The failure or success is checked via the value returned by CameraStream::process(). Now that the post-processor notifies about the post-processing completion operation, we can drop the return value of CameraStream::process(). The status of post-processing is passed to CameraDevice::streamProcessingComplete() by the PostProcessor::processComplete slot. Signed-off-by: Umang Jain --- src/android/camera_device.cpp | 2 +- src/android/camera_stream.cpp | 14 +++++++------- src/android/camera_stream.h | 6 +++--- src/android/jpeg/post_processor_jpeg.cpp | 12 +++++------- src/android/jpeg/post_processor_jpeg.h | 6 +++--- src/android/post_processor.h | 6 +++--- src/android/yuv/post_processor_yuv.cpp | 14 ++++++-------- src/android/yuv/post_processor_yuv.h | 6 +++--- 8 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9f26c36d..eba370ea 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1228,7 +1228,7 @@ void CameraDevice::requestComplete(Request *request) if (cameraStream->type() == CameraStream::Type::Internal) descriptor->internalBuffer_ = src; - int ret = cameraStream->process(*src, buffer, descriptor); + cameraStream->process(*src, buffer, descriptor); return; } diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index d91e7dee..cec07269 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -147,9 +147,9 @@ int CameraStream::waitFence(int fence) return -errno; } -int CameraStream::process(const FrameBuffer &source, - camera3_stream_buffer_t &camera3Dest, - Camera3RequestDescriptor *request) +void CameraStream::process(const FrameBuffer &source, + camera3_stream_buffer_t &camera3Dest, + Camera3RequestDescriptor *request) { /* Handle waiting on fences on the destination buffer. */ int fence = camera3Dest.acquire_fence; @@ -160,12 +160,12 @@ int CameraStream::process(const FrameBuffer &source, if (ret < 0) { LOG(HAL, Error) << "Failed waiting for fence: " << fence << ": " << strerror(-ret); - return ret; + return; } } if (!postProcessor_) - return 0; + return; /* * \todo Buffer mapping and processing should be moved to a @@ -176,10 +176,10 @@ int CameraStream::process(const FrameBuffer &source, PROT_READ | PROT_WRITE); if (!dest.isValid()) { LOG(HAL, Error) << "Failed to create destination buffer"; - return -EINVAL; + return; } - return postProcessor_->process(source, &dest, request); + postProcessor_->process(source, &dest, request); } FrameBuffer *CameraStream::getBuffer() diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 04cfd111..a0c5f166 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -120,9 +120,9 @@ public: libcamera::Stream *stream() const; int configure(); - int process(const libcamera::FrameBuffer &source, - camera3_stream_buffer_t &camera3Buffer, - Camera3RequestDescriptor *request); + void process(const libcamera::FrameBuffer &source, + camera3_stream_buffer_t &camera3Buffer, + 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 81d1efe6..eb87931b 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -97,12 +97,12 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, } } -int PostProcessorJpeg::process(const FrameBuffer &source, - CameraBuffer *destination, - Camera3RequestDescriptor *request) +void PostProcessorJpeg::process(const FrameBuffer &source, + CameraBuffer *destination, + Camera3RequestDescriptor *request) { if (!encoder_) - return 0; + return; ASSERT(destination->numPlanes() == 1); @@ -198,7 +198,7 @@ int PostProcessorJpeg::process(const FrameBuffer &source, if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; processComplete.emit(request, PostProcessor::Status::Error); - return jpeg_size; + return; } /* Fill in the JPEG blob header. */ @@ -212,6 +212,4 @@ int PostProcessorJpeg::process(const FrameBuffer &source, /* Update the JPEG result Metadata. */ resultMetadata->addEntry(ANDROID_JPEG_SIZE, jpeg_size); processComplete.emit(request, PostProcessor::Status::Success); - - return 0; } diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index 0184d77e..5dab14e1 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -22,9 +22,9 @@ public: int configure(const libcamera::StreamConfiguration &incfg, const libcamera::StreamConfiguration &outcfg) override; - int process(const libcamera::FrameBuffer &source, - CameraBuffer *destination, - Camera3RequestDescriptor *request) override; + void process(const libcamera::FrameBuffer &source, + CameraBuffer *destination, + 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 6e67bcba..88a5f985 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -30,9 +30,9 @@ public: virtual int configure(const libcamera::StreamConfiguration &inCfg, const libcamera::StreamConfiguration &outCfg) = 0; - virtual int process(const libcamera::FrameBuffer &source, - CameraBuffer *destination, - Camera3RequestDescriptor *request) = 0; + virtual void process(const libcamera::FrameBuffer &source, + CameraBuffer *destination, + Camera3RequestDescriptor *request) = 0; libcamera::Signal processComplete; }; diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index b34b389d..860a1a7f 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -51,20 +51,20 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg, return 0; } -int PostProcessorYuv::process(const FrameBuffer &source, - CameraBuffer *destination, - Camera3RequestDescriptor *request) +void PostProcessorYuv::process(const FrameBuffer &source, + CameraBuffer *destination, + Camera3RequestDescriptor *request) { if (!isValidBuffers(source, *destination)) { processComplete.emit(request, PostProcessor::Status::Error); - return -EINVAL; + return; } const MappedFrameBuffer sourceMapped(&source, MappedFrameBuffer::MapFlag::Read); if (!sourceMapped.isValid()) { LOG(YUV, Error) << "Failed to mmap camera frame buffer"; processComplete.emit(request, PostProcessor::Status::Error); - return -EINVAL; + return; } int ret = libyuv::NV12Scale(sourceMapped.planes()[0].data(), @@ -82,12 +82,10 @@ int PostProcessorYuv::process(const FrameBuffer &source, if (ret) { LOG(YUV, Error) << "Failed NV12 scaling: " << ret; processComplete.emit(request, PostProcessor::Status::Error); - return -EINVAL; + return; } processComplete.emit(request, PostProcessor::Status::Success); - - return 0; } bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source, diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h index a4e0ff5d..1278843b 100644 --- a/src/android/yuv/post_processor_yuv.h +++ b/src/android/yuv/post_processor_yuv.h @@ -18,9 +18,9 @@ public: int configure(const libcamera::StreamConfiguration &incfg, const libcamera::StreamConfiguration &outcfg) override; - int process(const libcamera::FrameBuffer &source, - CameraBuffer *destination, - Camera3RequestDescriptor *request) override; + void process(const libcamera::FrameBuffer &source, + CameraBuffer *destination, + Camera3RequestDescriptor *request) override; private: bool isValidBuffers(const libcamera::FrameBuffer &source,