{"id":13518,"url":"https://patchwork.libcamera.org/api/patches/13518/?format=json","web_url":"https://patchwork.libcamera.org/patch/13518/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210826213016.1829504-4-umang.jain@ideasonboard.com>","date":"2021-08-26T21:30:14","name":"[libcamera-devel,RFC,3/5] android: post_processor: Notify post processing completion status","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bc86809f6934898778c6a5f4db44a0a349be5dd8","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/13518/mbox/","series":[{"id":2401,"url":"https://patchwork.libcamera.org/api/series/2401/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2401","date":"2021-08-26T21:30:11","name":"android: Async post-processing","version":1,"mbox":"https://patchwork.libcamera.org/series/2401/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13518/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13518/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2F668BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Aug 2021 21:30:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D8A2668943;\n\tThu, 26 Aug 2021 23:30:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB04968931\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 23:30:31 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.246])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 11B42191F;\n\tThu, 26 Aug 2021 23:30:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ulKAsixm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630013431;\n\tbh=M42B9kLwVCcmVbGJtLD4xOGosrGKST6FW4kQbHpYZZE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ulKAsixml9dC1bF+mFTQNH9Y+cDMvkIzkJuFdxPLm7HfLlnWuYQY0YOidRJ3tqBv9\n\tFyGI1HM8IPc5kU1wjmu51v5MuEWnWRC3L4Rg1MLKzOZ4HyEqgSN3pg1YOQqBr23RR6\n\trGoHf4hJiQYm9aVEe8+RvTepltGL6OxmzAEqAmCU=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 27 Aug 2021 03:00:14 +0530","Message-Id":"<20210826213016.1829504-4-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210826213016.1829504-1-umang.jain@ideasonboard.com>","References":"<20210826213016.1829504-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 3/5] android: post_processor: Notify\n\tpost processing completion status","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When a post-processor is running asynchronously, we should be able to\nknow whether the post-processing operation on the stream has been\ncompleted or not. Secondly, we should be able to know if it completed\nsuccessfully or encountered some errors. This commit introduces a\nSignal<> which when connected, will notify that the post-processing\nhas been completed. The status of PostProcessor::process() will be\npassed as a PostProcessor::Status argument. The populated\nCameraMetadata shall also be available in the signal-handler.\n\n/*\n * DNI: I do not like the multiple places of signal emission.\n * We need to use goto but first we need to make a single point\n * of return somehow, and restructure the error paths a bit.\n */\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/android/jpeg/post_processor_jpeg.cpp | 9 ++++++++-\n src/android/post_processor.h             | 7 +++++++\n src/android/yuv/post_processor_yuv.cpp   | 4 ++++\n 3 files changed, 19 insertions(+), 1 deletion(-)","diff":"diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 723e8d18..9366934d 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -87,8 +87,11 @@ int PostProcessorJpeg::process(const FrameBuffer *source,\n \t\t\t       const CameraMetadata &requestMetadata,\n \t\t\t       CameraMetadata *resultMetadata)\n {\n-\tif (!encoder_)\n+\tif (!encoder_) {\n+\t\tprocessComplete.emit(PostProcessor::Status::Failed,\n+\t\t\t\t     resultMetadata);\n \t\treturn 0;\n+\t}\n \n \tASSERT(destination->numPlanes() == 1);\n \n@@ -181,6 +184,8 @@ int PostProcessorJpeg::process(const FrameBuffer *source,\n \t\t\t\t\t exif.data(), quality);\n \tif (jpeg_size < 0) {\n \t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n+\t\tprocessComplete.emit(PostProcessor::Status::Failed,\n+\t\t\t\t     resultMetadata);\n \t\treturn jpeg_size;\n \t}\n \n@@ -195,5 +200,7 @@ int PostProcessorJpeg::process(const FrameBuffer *source,\n \t/* Update the JPEG result Metadata. */\n \tresultMetadata->addEntry(ANDROID_JPEG_SIZE, jpeg_size);\n \n+\tprocessComplete.emit(PostProcessor::Status::Success, resultMetadata);\n+\n \treturn 0;\n }\ndiff --git a/src/android/post_processor.h b/src/android/post_processor.h\nindex 5b8f1ab8..73fa79e9 100644\n--- a/src/android/post_processor.h\n+++ b/src/android/post_processor.h\n@@ -8,6 +8,7 @@\n #define __ANDROID_POST_PROCESSOR_H__\n \n #include <libcamera/base/object.h>\n+#include <libcamera/base/signal.h>\n \n #include <libcamera/framebuffer.h>\n #include <libcamera/stream.h>\n@@ -27,6 +28,12 @@ public:\n \t\t\t    CameraBuffer *destination,\n \t\t\t    const CameraMetadata &requestMetadata,\n \t\t\t    CameraMetadata *resultMetadata) = 0;\n+\n+\tenum Status {\n+\t\tSuccess,\n+\t\tFailed,\n+\t};\n+\tlibcamera::Signal<Status, CameraMetadata *> processComplete;\n };\n \n #endif /* __ANDROID_POST_PROCESSOR_H__ */\ndiff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\nindex 4b507d33..1877e54b 100644\n--- a/src/android/yuv/post_processor_yuv.cpp\n+++ b/src/android/yuv/post_processor_yuv.cpp\n@@ -60,6 +60,7 @@ int PostProcessorYuv::process(const FrameBuffer *source,\n \tconst MappedFrameBuffer sourceMapped(source, MappedFrameBuffer::MapFlag::Read);\n \tif (!sourceMapped.isValid()) {\n \t\tLOG(YUV, Error) << \"Failed to mmap camera frame buffer\";\n+\t\tprocessComplete.emit(PostProcessor::Status::Failed, metadata);\n \t\treturn -EINVAL;\n \t}\n \n@@ -77,9 +78,12 @@ int PostProcessorYuv::process(const FrameBuffer *source,\n \t\t\t\t    libyuv::FilterMode::kFilterBilinear);\n \tif (ret) {\n \t\tLOG(YUV, Error) << \"Failed NV12 scaling: \" << ret;\n+\t\tprocessComplete.emit(PostProcessor::Status::Failed, metadata);\n \t\treturn -EINVAL;\n \t}\n \n+\tprocessComplete.emit(PostProcessor::Status::Success, metadata);\n+\n \treturn 0;\n }\n \n","prefixes":["libcamera-devel","RFC","3/5"]}