[libcamera-devel] [PATCH 04/11] android: camera_stream: Plumb process() with Camera3RequestDescriptor
Jacopo Mondi
jacopo at jmondi.org
Mon Oct 18 17:50:59 CEST 2021
Hi Uman,
On Mon, Oct 18, 2021 at 06:59:16PM +0530, Umang Jain wrote:
> Data (or broader context) required for post processing of a camera request
> is saved via Camera3RequestDescriptor. Instead of passing individual
> arguments to CameraStream::process(), pass the Camera3RequestDescriptor
> pointer to it. All the arguments necessary to run the post-processor can
> be accessed from the descriptor.
Seems like a really good idea ;)
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Thanks
j
>
> Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
> ---
> src/android/camera_device.cpp | 5 ++---
> src/android/camera_stream.cpp | 5 ++---
> src/android/camera_stream.h | 5 ++---
> src/android/jpeg/post_processor_jpeg.cpp | 6 ++++--
> src/android/jpeg/post_processor_jpeg.h | 3 +--
> src/android/post_processor.h | 5 ++---
> src/android/yuv/post_processor_yuv.cpp | 3 +--
> src/android/yuv/post_processor_yuv.h | 3 +--
> 8 files changed, 15 insertions(+), 20 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index c6ae8930..3bddb292 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1176,9 +1176,8 @@ void CameraDevice::requestComplete(Request *request)
> continue;
> }
>
> - int ret = cameraStream->process(*src, buffer,
> - descriptor->settings_,
> - descriptor->resultMetadata_.get());
> + int ret = cameraStream->process(*src, buffer, descriptor);
> +
> /*
> * Return the FrameBuffer to the CameraStream now that we're
> * done processing it.
> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp
> index 3b96d2e9..8f47e4d8 100644
> --- a/src/android/camera_stream.cpp
> +++ b/src/android/camera_stream.cpp
> @@ -144,8 +144,7 @@ int CameraStream::waitFence(int fence)
>
> int CameraStream::process(const FrameBuffer &source,
> camera3_stream_buffer_t &camera3Dest,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *resultMetadata)
> + Camera3RequestDescriptor *request)
> {
> /* Handle waiting on fences on the destination buffer. */
> int fence = camera3Dest.acquire_fence;
> @@ -175,7 +174,7 @@ int CameraStream::process(const FrameBuffer &source,
> return -EINVAL;
> }
>
> - return postProcessor_->process(source, &dest, requestMetadata, resultMetadata);
> + return postProcessor_->process(source, &dest, request);
> }
>
> FrameBuffer *CameraStream::getBuffer()
> diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h
> index 03ecfa94..405b232d 100644
> --- a/src/android/camera_stream.h
> +++ b/src/android/camera_stream.h
> @@ -19,8 +19,8 @@
> #include <libcamera/geometry.h>
> #include <libcamera/pixel_format.h>
>
> +class Camera3RequestDescriptor;
> class CameraDevice;
> -class CameraMetadata;
> class PostProcessor;
>
> class CameraStream
> @@ -120,8 +120,7 @@ public:
> int configure();
> int process(const libcamera::FrameBuffer &source,
> camera3_stream_buffer_t &camera3Buffer,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *resultMetadata);
> + Camera3RequestDescriptor *request);
> 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 f6d47f63..699576ef 100644
> --- a/src/android/jpeg/post_processor_jpeg.cpp
> +++ b/src/android/jpeg/post_processor_jpeg.cpp
> @@ -11,6 +11,7 @@
>
> #include "../camera_device.h"
> #include "../camera_metadata.h"
> +#include "../camera_request.h"
> #include "encoder_libjpeg.h"
> #include "exif.h"
>
> @@ -99,14 +100,15 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
>
> int PostProcessorJpeg::process(const FrameBuffer &source,
> CameraBuffer *destination,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *resultMetadata)
> + Camera3RequestDescriptor *request)
> {
> if (!encoder_)
> return 0;
>
> ASSERT(destination->numPlanes() == 1);
>
> + const CameraMetadata &requestMetadata = request->settings_;
> + CameraMetadata *resultMetadata = 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 6fd31022..0184d77e 100644
> --- a/src/android/jpeg/post_processor_jpeg.h
> +++ b/src/android/jpeg/post_processor_jpeg.h
> @@ -24,8 +24,7 @@ public:
> const libcamera::StreamConfiguration &outcfg) override;
> int process(const libcamera::FrameBuffer &source,
> CameraBuffer *destination,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *resultMetadata) override;
> + Camera3RequestDescriptor *request) override;
>
> private:
> void generateThumbnail(const libcamera::FrameBuffer &source,
> diff --git a/src/android/post_processor.h b/src/android/post_processor.h
> index ab2b2c60..27eaef88 100644
> --- a/src/android/post_processor.h
> +++ b/src/android/post_processor.h
> @@ -12,7 +12,7 @@
>
> #include "camera_buffer.h"
>
> -class CameraMetadata;
> +class Camera3RequestDescriptor;
>
> class PostProcessor
> {
> @@ -23,8 +23,7 @@ public:
> const libcamera::StreamConfiguration &outCfg) = 0;
> virtual int process(const libcamera::FrameBuffer &source,
> CameraBuffer *destination,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *resultMetadata) = 0;
> + Camera3RequestDescriptor *request) = 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 7b3b4960..8110a1f1 100644
> --- a/src/android/yuv/post_processor_yuv.cpp
> +++ b/src/android/yuv/post_processor_yuv.cpp
> @@ -51,8 +51,7 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,
>
> int PostProcessorYuv::process(const FrameBuffer &source,
> CameraBuffer *destination,
> - [[maybe_unused]] const CameraMetadata &requestMetadata,
> - [[maybe_unused]] CameraMetadata *metadata)
> + [[maybe_unused]] Camera3RequestDescriptor *request)
> {
> 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 12f7af07..a4e0ff5d 100644
> --- a/src/android/yuv/post_processor_yuv.h
> +++ b/src/android/yuv/post_processor_yuv.h
> @@ -20,8 +20,7 @@ public:
> const libcamera::StreamConfiguration &outcfg) override;
> int process(const libcamera::FrameBuffer &source,
> CameraBuffer *destination,
> - const CameraMetadata &requestMetadata,
> - CameraMetadata *metadata) override;
> + Camera3RequestDescriptor *request) override;
>
> private:
> bool isValidBuffers(const libcamera::FrameBuffer &source,
> --
> 2.31.0
>
More information about the libcamera-devel
mailing list