From patchwork Tue Sep 7 19:57: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: 13751 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 57FC4BDC71 for ; Tue, 7 Sep 2021 19:57:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 21A6769173; Tue, 7 Sep 2021 21:57: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="kfzRWD5+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F336F69173 for ; Tue, 7 Sep 2021 21:57:21 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CD149499; Tue, 7 Sep 2021 21:57:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631044641; bh=3BplGfXY1FTGqvHh7eVzwe/p1KioPek2cTP9UzC7uEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfzRWD5+8wGYlM3Fxeb7zE0pO6usdYJ45rVWKp+Ld+1FgF/h9ii4z1DC3PR47ivWg 6yocLjccXhAtba+4H1Qavkw6596rnp2Y6tA7kKyruv0TBApNqiM+TNcta+AARNbzt1 8gh6k68NCYIZcCOesvm49QWC4S9CIKO7rReDlchg= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Sep 2021 01:27:00 +0530 Message-Id: <20210907195704.338079-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210907195704.338079-1-umang.jain@ideasonboard.com> References: <20210907195704.338079-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/6] android: post_processor: Notify post processing completion status 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" We should be able to know if post-processing has been completed successfully or encountered some errors. This commit introduces a Signal<> which when connected, will notify that the post-processing has been completed. The status of PostProcessor::process() will be passed as a PostProcessor::Status argument. The signal will be required when the post-processor is meant to run asynchronously (in subsequent commits). Signed-off-by: Umang Jain --- src/android/jpeg/post_processor_jpeg.cpp | 7 ++++++- src/android/post_processor.h | 8 ++++++++ src/android/yuv/post_processor_yuv.cpp | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index fe41207a..69f3c5dd 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -87,8 +87,10 @@ int PostProcessorJpeg::process(const FrameBuffer *source, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { - if (!encoder_) + if (!encoder_) { + processComplete.emit(PostProcessor::Status::Failed); return 0; + } ASSERT(destination->numPlanes() == 1); @@ -181,6 +183,7 @@ int PostProcessorJpeg::process(const FrameBuffer *source, exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; + processComplete.emit(PostProcessor::Status::Failed); return jpeg_size; } @@ -195,5 +198,7 @@ int PostProcessorJpeg::process(const FrameBuffer *source, /* Update the JPEG result Metadata. */ resultMetadata->addEntry(ANDROID_JPEG_SIZE, jpeg_size); + processComplete.emit(PostProcessor::Status::Success); + return 0; } diff --git a/src/android/post_processor.h b/src/android/post_processor.h index 61dfb6d4..edf1a4bf 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -7,6 +7,8 @@ #ifndef __ANDROID_POST_PROCESSOR_H__ #define __ANDROID_POST_PROCESSOR_H__ +#include + #include #include @@ -25,6 +27,12 @@ public: CameraBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) = 0; + + enum Status { + Success, + Failed, + }; + libcamera::Signal processComplete; }; #endif /* __ANDROID_POST_PROCESSOR_H__ */ diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 0a874886..d1db9216 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -60,6 +60,7 @@ int PostProcessorYuv::process(const FrameBuffer *source, const MappedFrameBuffer sourceMapped(source, MappedFrameBuffer::MapFlag::Read); if (!sourceMapped.isValid()) { LOG(YUV, Error) << "Failed to mmap camera frame buffer"; + processComplete.emit(PostProcessor::Status::Failed); return -EINVAL; } @@ -77,9 +78,12 @@ int PostProcessorYuv::process(const FrameBuffer *source, libyuv::FilterMode::kFilterBilinear); if (ret) { LOG(YUV, Error) << "Failed NV12 scaling: " << ret; + processComplete.emit(PostProcessor::Status::Failed); return -EINVAL; } + processComplete.emit(PostProcessor::Status::Success); + return 0; }