summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp13
-rw-r--r--src/android/camera_request.cpp5
-rw-r--r--src/android/camera_request.h5
-rw-r--r--src/android/camera_stream.cpp23
-rw-r--r--src/android/camera_stream.h4
-rw-r--r--src/android/jpeg/post_processor_jpeg.cpp12
-rw-r--r--src/android/jpeg/post_processor_jpeg.h4
-rw-r--r--src/android/post_processor.h7
-rw-r--r--src/android/yuv/post_processor_yuv.cpp7
-rw-r--r--src/android/yuv/post_processor_yuv.h4
10 files changed, 44 insertions, 40 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index bf9a2e69..9155728a 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -953,6 +953,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
* once it has been processed.
*/
frameBuffer = cameraStream->getBuffer();
+ buffer.internalBuffer = frameBuffer;
LOG(HAL, Debug) << ss.str() << " (internal)";
break;
}
@@ -1133,14 +1134,16 @@ void CameraDevice::requestComplete(Request *request)
continue;
}
- int ret = stream->process(*src, buffer, descriptor);
+ buffer.srcBuffer = src;
+
+ int ret = stream->process(&buffer);
/*
- * Return the FrameBuffer to the CameraStream now that we're
- * done processing it.
+ * If the framebuffer is internal to CameraStream return it back
+ * now that we're done processing it.
*/
- if (stream->type() == CameraStream::Type::Internal)
- stream->putBuffer(src);
+ if (buffer.internalBuffer)
+ stream->putBuffer(buffer.internalBuffer);
if (ret) {
buffer.status = Camera3RequestDescriptor::Status::Error;
diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp
index 16cf266f..5bac1b8f 100644
--- a/src/android/camera_request.cpp
+++ b/src/android/camera_request.cpp
@@ -9,6 +9,8 @@
#include <libcamera/base/span.h>
+#include "camera_buffer.h"
+
using namespace libcamera;
/*
@@ -36,7 +38,8 @@ Camera3RequestDescriptor::Camera3RequestDescriptor(
static_cast<CameraStream *>(buffer.stream->priv);
buffers_.push_back({ stream, buffer.buffer, nullptr,
- buffer.acquire_fence, Status::Success });
+ buffer.acquire_fence, Status::Success,
+ nullptr, nullptr, nullptr, this });
}
/* Clone the controls associated with the camera3 request. */
diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index 4d80ef32..ebe2e89d 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -20,6 +20,7 @@
#include "camera_metadata.h"
#include "camera_worker.h"
+class CameraBuffer;
class CameraStream;
class Camera3RequestDescriptor
@@ -36,6 +37,10 @@ public:
std::unique_ptr<libcamera::FrameBuffer> frameBuffer;
int fence;
Status status;
+ libcamera::FrameBuffer *internalBuffer;
+ const libcamera::FrameBuffer *srcBuffer;
+ std::unique_ptr<CameraBuffer> dstBuffer;
+ Camera3RequestDescriptor *request;
};
Camera3RequestDescriptor(libcamera::Camera *camera,
diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
index 5d991fe5..282b19b0 100644
--- a/src/android/camera_stream.cpp
+++ b/src/android/camera_stream.cpp
@@ -146,23 +146,21 @@ int CameraStream::waitFence(int fence)
return -errno;
}
-int CameraStream::process(const FrameBuffer &source,
- Camera3RequestDescriptor::StreamBuffer &dest,
- Camera3RequestDescriptor *request)
+int CameraStream::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
{
ASSERT(type_ != Type::Direct);
/* Handle waiting on fences on the destination buffer. */
- if (dest.fence != -1) {
- int ret = waitFence(dest.fence);
+ if (streamBuffer->fence != -1) {
+ int ret = waitFence(streamBuffer->fence);
if (ret < 0) {
LOG(HAL, Error) << "Failed waiting for fence: "
- << dest.fence << ": " << strerror(-ret);
+ << streamBuffer->fence << ": " << strerror(-ret);
return ret;
}
- ::close(dest.fence);
- dest.fence = -1;
+ ::close(streamBuffer->fence);
+ streamBuffer->fence = -1;
}
/*
@@ -170,14 +168,15 @@ int CameraStream::process(const FrameBuffer &source,
* separate thread.
*/
const StreamConfiguration &output = configuration();
- CameraBuffer destBuffer(*dest.camera3Buffer, output.pixelFormat,
- output.size, PROT_READ | PROT_WRITE);
- if (!destBuffer.isValid()) {
+ streamBuffer->dstBuffer = std::make_unique<CameraBuffer>(
+ *streamBuffer->camera3Buffer, output.pixelFormat, output.size,
+ PROT_READ | PROT_WRITE);
+ if (!streamBuffer->dstBuffer->isValid()) {
LOG(HAL, Error) << "Failed to create destination buffer";
return -EINVAL;
}
- return postProcessor_->process(source, &destBuffer, request);
+ return postProcessor_->process(streamBuffer);
}
FrameBuffer *CameraStream::getBuffer()
diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
index f242336e..e74a9a3b 100644
--- a/src/android/camera_stream.h
+++ b/src/android/camera_stream.h
@@ -121,9 +121,7 @@ public:
libcamera::Stream *stream() const;
int configure();
- int process(const libcamera::FrameBuffer &source,
- Camera3RequestDescriptor::StreamBuffer &dest,
- Camera3RequestDescriptor *request);
+ int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer);
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 49483836..240e29f6 100644
--- a/src/android/jpeg/post_processor_jpeg.cpp
+++ b/src/android/jpeg/post_processor_jpeg.cpp
@@ -98,15 +98,17 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
}
}
-int PostProcessorJpeg::process(const FrameBuffer &source,
- CameraBuffer *destination,
- Camera3RequestDescriptor *request)
+int PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
{
ASSERT(encoder_);
+
+ const FrameBuffer &source = *streamBuffer->srcBuffer;
+ CameraBuffer *destination = streamBuffer->dstBuffer.get();
+
ASSERT(destination->numPlanes() == 1);
- const CameraMetadata &requestMetadata = request->settings_;
- CameraMetadata *resultMetadata = request->resultMetadata_.get();
+ const CameraMetadata &requestMetadata = streamBuffer->request->settings_;
+ CameraMetadata *resultMetadata = streamBuffer->request->resultMetadata_.get();
camera_metadata_ro_entry_t entry;
int ret;
diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h
index 0184d77e..92385548 100644
--- a/src/android/jpeg/post_processor_jpeg.h
+++ b/src/android/jpeg/post_processor_jpeg.h
@@ -22,9 +22,7 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- int process(const libcamera::FrameBuffer &source,
- CameraBuffer *destination,
- Camera3RequestDescriptor *request) override;
+ int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) override;
private:
void generateThumbnail(const libcamera::FrameBuffer &source,
diff --git a/src/android/post_processor.h b/src/android/post_processor.h
index 27eaef88..128161c8 100644
--- a/src/android/post_processor.h
+++ b/src/android/post_processor.h
@@ -11,8 +11,7 @@
#include <libcamera/stream.h>
#include "camera_buffer.h"
-
-class Camera3RequestDescriptor;
+#include "camera_request.h"
class PostProcessor
{
@@ -21,9 +20,7 @@ public:
virtual int configure(const libcamera::StreamConfiguration &inCfg,
const libcamera::StreamConfiguration &outCfg) = 0;
- virtual int process(const libcamera::FrameBuffer &source,
- CameraBuffer *destination,
- Camera3RequestDescriptor *request) = 0;
+ virtual int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) = 0;
};
#endif /* __ANDROID_POST_PROCESSOR_H__ */
diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp
index 8110a1f1..70385ab3 100644
--- a/src/android/yuv/post_processor_yuv.cpp
+++ b/src/android/yuv/post_processor_yuv.cpp
@@ -49,10 +49,11 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,
return 0;
}
-int PostProcessorYuv::process(const FrameBuffer &source,
- CameraBuffer *destination,
- [[maybe_unused]] Camera3RequestDescriptor *request)
+int PostProcessorYuv::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
{
+ const FrameBuffer &source = *streamBuffer->srcBuffer;
+ CameraBuffer *destination = streamBuffer->dstBuffer.get();
+
if (!isValidBuffers(source, *destination))
return -EINVAL;
diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h
index a4e0ff5d..5954e11b 100644
--- a/src/android/yuv/post_processor_yuv.h
+++ b/src/android/yuv/post_processor_yuv.h
@@ -18,9 +18,7 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- int process(const libcamera::FrameBuffer &source,
- CameraBuffer *destination,
- Camera3RequestDescriptor *request) override;
+ int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) override;
private:
bool isValidBuffers(const libcamera::FrameBuffer &source,