[libcamera-devel] [PATCH v1 2/6] android: post_processor: Notify post processing completion status
Umang Jain
umang.jain at ideasonboard.com
Tue Sep 7 21:57:00 CEST 2021
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 <umang.jain at ideasonboard.com>
---
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 <libcamera/base/signal.h>
+
#include <libcamera/framebuffer.h>
#include <libcamera/stream.h>
@@ -25,6 +27,12 @@ public:
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata) = 0;
+
+ enum Status {
+ Success,
+ Failed,
+ };
+ libcamera::Signal<Status> 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;
}
--
2.31.0
More information about the libcamera-devel
mailing list