From fb9051ff7407d6e1abcfafb40a951f55c38dafe9 Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Thu, 28 Jan 2021 22:42:15 +0000 Subject: android: post_processor: Change the type destination in process() The type of the destination buffer in PostProcessor::process() is libcamera::Span. libcamera::Span is used for one dimension buffer (e.g. blob buffer). The destination can be multiple dimensions buffer (e.g. yuv frame). Therefore, this changes the type of the destination buffer to MappedFrameBuffer. Signed-off-by: Hirokazu Honda Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Signed-off-by: Jacopo Mondi --- src/android/camera_stream.cpp | 4 ++-- src/android/camera_stream.h | 5 +++-- src/android/jpeg/post_processor_jpeg.cpp | 7 ++++--- src/android/jpeg/post_processor_jpeg.h | 2 +- src/android/post_processor.h | 5 +++-- 5 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 4c8020e5..611ec0d1 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -96,14 +96,14 @@ int CameraStream::configure() } int CameraStream::process(const libcamera::FrameBuffer &source, - MappedCamera3Buffer *dest, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { if (!postProcessor_) return 0; - return postProcessor_->process(source, dest->maps()[0], + return postProcessor_->process(source, destination, requestMetadata, resultMetadata); } diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 298ffbf6..fc242b2a 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -19,9 +19,10 @@ #include #include +#include + class CameraDevice; class CameraMetadata; -class MappedCamera3Buffer; class PostProcessor; class CameraStream @@ -119,7 +120,7 @@ public: int configure(); int process(const libcamera::FrameBuffer &source, - MappedCamera3Buffer *dest, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata); libcamera::FrameBuffer *getBuffer(); diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 1cbab30c..ab5b6384 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -83,7 +83,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source, } int PostProcessorJpeg::process(const FrameBuffer &source, - Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) { @@ -172,7 +172,8 @@ int PostProcessorJpeg::process(const FrameBuffer &source, const uint8_t quality = ret ? *entry.data.u8 : 95; resultMetadata->addEntry(ANDROID_JPEG_QUALITY, &quality, 1); - int jpeg_size = encoder_->encode(source, destination, exif.data(), quality); + int jpeg_size = encoder_->encode(source, destination->maps()[0], + exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; return jpeg_size; @@ -190,7 +191,7 @@ int PostProcessorJpeg::process(const FrameBuffer &source, * \todo Investigate if the buffer size mismatch is an issue or * expected behaviour. */ - uint8_t *resultPtr = destination.data() + + uint8_t *resultPtr = destination->maps()[0].data() + cameraDevice_->maxJpegBufferSize() - sizeof(struct camera3_jpeg_blob); auto *blob = reinterpret_cast(resultPtr); diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index d2dfa450..7689de73 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -25,7 +25,7 @@ public: int configure(const libcamera::StreamConfiguration &incfg, const libcamera::StreamConfiguration &outcfg) override; int process(const libcamera::FrameBuffer &source, - libcamera::Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) override; diff --git a/src/android/post_processor.h b/src/android/post_processor.h index bda93bb4..ac40d341 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -8,9 +8,10 @@ #define __ANDROID_POST_PROCESSOR_H__ #include -#include #include +#include + class CameraMetadata; class PostProcessor @@ -21,7 +22,7 @@ public: virtual int configure(const libcamera::StreamConfiguration &inCfg, const libcamera::StreamConfiguration &outCfg) = 0; virtual int process(const libcamera::FrameBuffer &source, - libcamera::Span destination, + libcamera::MappedBuffer *destination, const CameraMetadata &requestMetadata, CameraMetadata *resultMetadata) = 0; }; -- cgit v1.2.1