[libcamera-devel] [PATCH 1/2] android: post_processor: Change the type destination in process()
Hirokazu Honda
hiroh at chromium.org
Fri Jan 22 10:23:34 CET 2021
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 <hiroh at chromium.org>
---
src/android/camera_stream.cpp | 5 +++--
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 | 3 ++-
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index dba351a4..33d0e005 100644
--- a/src/android/camera_stream.cpp
+++ b/src/android/camera_stream.cpp
@@ -96,12 +96,13 @@ int CameraStream::configure()
}
int CameraStream::process(const libcamera::FrameBuffer &source,
- MappedCamera3Buffer *dest, CameraMetadata *metadata)
+ libcamera::MappedBuffer *destination,
+ CameraMetadata *metadata)
{
if (!postProcessor_)
return 0;
- return postProcessor_->process(source, dest->maps()[0], metadata);
+ return postProcessor_->process(source, destination, metadata);
}
FrameBuffer *CameraStream::getBuffer()
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index cc9d5470..7d7b2b16 100644
--- a/src/android/camera_stream.h
+++ b/src/android/camera_stream.h
@@ -17,11 +17,11 @@
#include <libcamera/camera.h>
#include <libcamera/framebuffer_allocator.h>
#include <libcamera/geometry.h>
+#include <libcamera/internal/buffer.h>
#include <libcamera/pixel_format.h>
class CameraDevice;
class CameraMetadata;
-class MappedCamera3Buffer;
class PostProcessor;
class CameraStream
@@ -119,7 +119,8 @@ public:
int configure();
int process(const libcamera::FrameBuffer &source,
- MappedCamera3Buffer *dest, CameraMetadata *metadata);
+ libcamera::MappedBuffer *destination,
+ CameraMetadata *metadata);
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 436a50f8..2374716d 100644
--- a/src/android/jpeg/post_processor_jpeg.cpp
+++ b/src/android/jpeg/post_processor_jpeg.cpp
@@ -79,7 +79,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
}
int PostProcessorJpeg::process(const FrameBuffer &source,
- Span<uint8_t> destination,
+ libcamera::MappedBuffer *destination,
CameraMetadata *metadata)
{
if (!encoder_)
@@ -107,7 +107,8 @@ int PostProcessorJpeg::process(const FrameBuffer &source,
if (exif.generate() != 0)
LOG(JPEG, Error) << "Failed to generate valid EXIF data";
- int jpeg_size = encoder_->encode(source, destination, exif.data());
+ int jpeg_size = encoder_->encode(source, destination->maps()[0],
+ exif.data());
if (jpeg_size < 0) {
LOG(JPEG, Error) << "Failed to encode stream image";
return jpeg_size;
@@ -125,7 +126,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<struct camera3_jpeg_blob *>(resultPtr);
diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h
index 5afa831c..68a38410 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<uint8_t> destination,
+ libcamera::MappedBuffer *destination,
CameraMetadata *metadata) override;
private:
diff --git a/src/android/post_processor.h b/src/android/post_processor.h
index e0f91880..368e0fe5 100644
--- a/src/android/post_processor.h
+++ b/src/android/post_processor.h
@@ -7,6 +7,7 @@
#ifndef __ANDROID_POST_PROCESSOR_H__
#define __ANDROID_POST_PROCESSOR_H__
+#include <libcamera/internal/buffer.h>
#include <libcamera/buffer.h>
#include <libcamera/span.h>
#include <libcamera/stream.h>
@@ -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<uint8_t> destination,
+ libcamera::MappedBuffer *destination,
CameraMetadata *metadata) = 0;
};
--
2.30.0.280.ga3ce27912f-goog
More information about the libcamera-devel
mailing list