@@ -1148,7 +1148,7 @@ void CameraDevice::requestComplete(Request *request)
continue;
}
- int ret = cameraStream->process(*src, *buffer.buffer,
+ int ret = cameraStream->process(src, *buffer.buffer,
descriptor.settings_,
resultMetadata.get());
/*
@@ -98,7 +98,7 @@ int CameraStream::configure()
return 0;
}
-int CameraStream::process(const FrameBuffer &source,
+int CameraStream::process(const FrameBuffer *source,
buffer_handle_t camera3Dest,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata)
@@ -118,7 +118,7 @@ public:
libcamera::Stream *stream() const;
int configure();
- int process(const libcamera::FrameBuffer &source,
+ int process(const libcamera::FrameBuffer *source,
buffer_handle_t camera3Dest,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata);
@@ -18,7 +18,7 @@ public:
virtual ~Encoder() = default;
virtual int configure(const libcamera::StreamConfiguration &cfg) = 0;
- virtual int encode(const libcamera::FrameBuffer &source,
+ virtual int encode(const libcamera::FrameBuffer *source,
libcamera::Span<uint8_t> destination,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) = 0;
@@ -178,10 +178,10 @@ void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes)
}
}
-int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest,
+int EncoderLibJpeg::encode(const FrameBuffer *source, Span<uint8_t> dest,
Span<const uint8_t> exifData, unsigned int quality)
{
- MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read);
+ MappedFrameBuffer frame(source, MappedFrameBuffer::MapFlag::Read);
if (!frame.isValid()) {
LOG(JPEG, Error) << "Failed to map FrameBuffer : "
<< strerror(frame.error());
@@ -22,7 +22,7 @@ public:
~EncoderLibJpeg();
int configure(const libcamera::StreamConfiguration &cfg) override;
- int encode(const libcamera::FrameBuffer &source,
+ int encode(const libcamera::FrameBuffer *source,
libcamera::Span<uint8_t> destination,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) override;
@@ -50,7 +50,7 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg,
return encoder_->configure(inCfg);
}
-void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
+void PostProcessorJpeg::generateThumbnail(const FrameBuffer *source,
const Size &targetSize,
unsigned int quality,
std::vector<unsigned char> *thumbnail)
@@ -82,7 +82,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
}
}
-int PostProcessorJpeg::process(const FrameBuffer &source,
+int PostProcessorJpeg::process(const FrameBuffer *source,
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata)
@@ -22,13 +22,13 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- int process(const libcamera::FrameBuffer &source,
+ int process(const libcamera::FrameBuffer *source,
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata) override;
private:
- void generateThumbnail(const libcamera::FrameBuffer &source,
+ void generateThumbnail(const libcamera::FrameBuffer *source,
const libcamera::Size &targetSize,
unsigned int quality,
std::vector<unsigned char> *thumbnail);
@@ -37,11 +37,11 @@ void Thumbnailer::configure(const Size &sourceSize, PixelFormat pixelFormat)
valid_ = true;
}
-void Thumbnailer::createThumbnail(const FrameBuffer &source,
+void Thumbnailer::createThumbnail(const FrameBuffer *source,
const Size &targetSize,
std::vector<unsigned char> *destination)
{
- MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read);
+ MappedFrameBuffer frame(source, MappedFrameBuffer::MapFlag::Read);
if (!frame.isValid()) {
LOG(Thumbnailer, Error)
<< "Failed to map FrameBuffer : "
@@ -19,7 +19,7 @@ public:
void configure(const libcamera::Size &sourceSize,
libcamera::PixelFormat pixelFormat);
- void createThumbnail(const libcamera::FrameBuffer &source,
+ void createThumbnail(const libcamera::FrameBuffer *source,
const libcamera::Size &targetSize,
std::vector<unsigned char> *dest);
const libcamera::PixelFormat &pixelFormat() const { return pixelFormat_; }
@@ -21,7 +21,7 @@ public:
virtual int configure(const libcamera::StreamConfiguration &inCfg,
const libcamera::StreamConfiguration &outCfg) = 0;
- virtual int process(const libcamera::FrameBuffer &source,
+ virtual int process(const libcamera::FrameBuffer *source,
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata) = 0;
@@ -49,7 +49,7 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,
return 0;
}
-int PostProcessorYuv::process(const FrameBuffer &source,
+int PostProcessorYuv::process(const FrameBuffer *source,
CameraBuffer *destination,
[[maybe_unused]] const CameraMetadata &requestMetadata,
[[maybe_unused]] CameraMetadata *metadata)
@@ -57,7 +57,7 @@ int PostProcessorYuv::process(const FrameBuffer &source,
if (!isValidBuffers(source, *destination))
return -EINVAL;
- const MappedFrameBuffer sourceMapped(&source, MappedFrameBuffer::MapFlag::Read);
+ const MappedFrameBuffer sourceMapped(source, MappedFrameBuffer::MapFlag::Read);
if (!sourceMapped.isValid()) {
LOG(YUV, Error) << "Failed to mmap camera frame buffer";
return -EINVAL;
@@ -83,12 +83,12 @@ int PostProcessorYuv::process(const FrameBuffer &source,
return 0;
}
-bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source,
+bool PostProcessorYuv::isValidBuffers(const FrameBuffer *source,
const CameraBuffer &destination) const
{
- if (source.planes().size() != 2) {
+ if (source->planes().size() != 2) {
LOG(YUV, Error) << "Invalid number of source planes: "
- << source.planes().size();
+ << source->planes().size();
return false;
}
if (destination.numPlanes() != 2) {
@@ -97,12 +97,12 @@ bool PostProcessorYuv::isValidBuffers(const FrameBuffer &source,
return false;
}
- if (source.planes()[0].length < sourceLength_[0] ||
- source.planes()[1].length < sourceLength_[1]) {
+ if (source->planes()[0].length < sourceLength_[0] ||
+ source->planes()[1].length < sourceLength_[1]) {
LOG(YUV, Error)
<< "The source planes lengths are too small, actual size: {"
- << source.planes()[0].length << ", "
- << source.planes()[1].length
+ << source->planes()[0].length << ", "
+ << source->planes()[1].length
<< "}, expected size: {"
<< sourceLength_[0] << ", "
<< sourceLength_[1] << "}";
@@ -20,13 +20,13 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- int process(const libcamera::FrameBuffer &source,
+ int process(const libcamera::FrameBuffer *source,
CameraBuffer *destination,
const CameraMetadata &requestMetadata,
CameraMetadata *metadata) override;
private:
- bool isValidBuffers(const libcamera::FrameBuffer &source,
+ bool isValidBuffers(const libcamera::FrameBuffer *source,
const CameraBuffer &destination) const;
void calculateLengths(const libcamera::StreamConfiguration &inCfg,
const libcamera::StreamConfiguration &outCfg);
Pass the libcamera::FrameBuffer pointer to the post-processor instead of passing it by reference. Passing by reference is fine as long as the post processing is done synchronously. However in subsequent commits, the post processing is planned to be moved to a separate thread. This will conflict as the reference argument (in current case 'source') is copied when we will try to invoke a method on separate thread(which will run the post-processor) using Object::invokeMethod(). The cause of conflict is the LIBCAMERA_DISABLE_COPY_AND_MOVE rule applied on the FrameBuffer class. To resolve the conflict, pass in the FrameBuffer pointer instead of reference. This requires changes to the existing PostProcessor interface and all its implemented classes. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- src/android/camera_device.cpp | 2 +- src/android/camera_stream.cpp | 2 +- src/android/camera_stream.h | 2 +- src/android/jpeg/encoder.h | 2 +- src/android/jpeg/encoder_libjpeg.cpp | 4 ++-- src/android/jpeg/encoder_libjpeg.h | 2 +- src/android/jpeg/post_processor_jpeg.cpp | 4 ++-- src/android/jpeg/post_processor_jpeg.h | 4 ++-- src/android/jpeg/thumbnailer.cpp | 4 ++-- src/android/jpeg/thumbnailer.h | 2 +- src/android/post_processor.h | 2 +- src/android/yuv/post_processor_yuv.cpp | 18 +++++++++--------- src/android/yuv/post_processor_yuv.h | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-)