[libcamera-devel,v3,05/10] android: camera_device: Store results metadata into Camera3RequestDescriptor
diff mbox series

Message ID 20210920173752.1346190-6-umang.jain@ideasonboard.com
State RFC
Delegated to: Umang Jain
Headers show
Series
  • Async post processor
Related show

Commit Message

Umang Jain Sept. 20, 2021, 5:37 p.m. UTC
Store metadata which is sent as capture results into the
Camera3RequestDescriptor. This is will remove the need to send the
result metadata pointer separately to CameraStream::process().
In the subsequent commit, a Camera3RequestDescriptor pointer
will be passed to CameraStream::process() and the result metadata
can be directly accessed from there.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_device.cpp | 6 ++++--
 src/android/camera_device.h   | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Sept. 20, 2021, 7:11 p.m. UTC | #1
Hi Uman,

Thank you for the patch.

On Mon, Sep 20, 2021 at 11:07:47PM +0530, Umang Jain wrote:
> Store metadata which is sent as capture results into the
> Camera3RequestDescriptor. This is will remove the need to send the

s/is will/will/

> result metadata pointer separately to CameraStream::process().
> In the subsequent commit, a Camera3RequestDescriptor pointer
> will be passed to CameraStream::process() and the result metadata
> can be directly accessed from there.

I'd have squashed 05/10 and 06/10 together, as this patch alone is very
small, and the combination of the two shows the intent of 05/10 better.
Up to you.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/android/camera_device.cpp | 6 ++++--
>  src/android/camera_device.h   | 1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 3d6a2bed..1ae4ac73 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1131,6 +1131,8 @@ void CameraDevice::requestComplete(Request *request)
>  		resultMetadata = std::make_unique<CameraMetadata>(0, 0);
>  	}
>  
> +	descriptor->resultMetadata_ = std::move(resultMetadata);
> +
>  	/* Handle any JPEG compression. */
>  	for (camera3_stream_buffer_t &buffer : descriptor->buffers_) {
>  		CameraStream *cameraStream =
> @@ -1150,7 +1152,7 @@ void CameraDevice::requestComplete(Request *request)
>  
>  		int ret = cameraStream->process(src, *buffer.buffer,
>  						descriptor->settings_,
> -						resultMetadata.get());
> +						descriptor->resultMetadata_.get());
>  		/*
>  		 * Return the FrameBuffer to the CameraStream now that we're
>  		 * done processing it.
> @@ -1165,7 +1167,7 @@ void CameraDevice::requestComplete(Request *request)
>  		}
>  	}
>  
> -	captureResult.result = resultMetadata->get();
> +	captureResult.result = descriptor->resultMetadata_->get();
>  	callbacks_->process_capture_result(callbacks_, &captureResult);
>  
>  	descriptors_.pop_front();
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 59d6cd39..b2871e52 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -47,6 +47,7 @@ struct Camera3RequestDescriptor {
>  	std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers_;
>  	CameraMetadata settings_;
>  	std::unique_ptr<CaptureRequest> request_;
> +	std::unique_ptr<CameraMetadata> resultMetadata_;
>  };
>  
>  class CameraDevice : protected libcamera::Loggable
Jacopo Mondi Sept. 21, 2021, 11:13 a.m. UTC | #2
Hi Umang,

On Mon, Sep 20, 2021 at 11:07:47PM +0530, Umang Jain wrote:
> Store metadata which is sent as capture results into the
> Camera3RequestDescriptor. This is will remove the need to send the
> result metadata pointer separately to CameraStream::process().
> In the subsequent commit, a Camera3RequestDescriptor pointer
> will be passed to CameraStream::process() and the result metadata
> can be directly accessed from there.
>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/android/camera_device.cpp | 6 ++++--
>  src/android/camera_device.h   | 1 +
>  2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 3d6a2bed..1ae4ac73 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1131,6 +1131,8 @@ void CameraDevice::requestComplete(Request *request)
>  		resultMetadata = std::make_unique<CameraMetadata>(0, 0);
>  	}
>
> +	descriptor->resultMetadata_ = std::move(resultMetadata);
> +

Can't you
     	descriptor->resultMetadata_ = getResultMetadata(descriptor);

>  	/* Handle any JPEG compression. */
>  	for (camera3_stream_buffer_t &buffer : descriptor->buffers_) {
>  		CameraStream *cameraStream =
> @@ -1150,7 +1152,7 @@ void CameraDevice::requestComplete(Request *request)
>
>  		int ret = cameraStream->process(src, *buffer.buffer,
>  						descriptor->settings_,
> -						resultMetadata.get());
> +						descriptor->resultMetadata_.get());

It's probably more tedious work, as it requires fixing the whole post
processor hierarchy, but this could be just

                        cameraStream->process(src, *buffer.buffer,
                                              descriptor);


>  		/*
>  		 * Return the FrameBuffer to the CameraStream now that we're
>  		 * done processing it.
> @@ -1165,7 +1167,7 @@ void CameraDevice::requestComplete(Request *request)
>  		}
>  	}
>
> -	captureResult.result = resultMetadata->get();
> +	captureResult.result = descriptor->resultMetadata_->get();
>  	callbacks_->process_capture_result(callbacks_, &captureResult);
>
>  	descriptors_.pop_front();
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 59d6cd39..b2871e52 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -47,6 +47,7 @@ struct Camera3RequestDescriptor {
>  	std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers_;
>  	CameraMetadata settings_;
>  	std::unique_ptr<CaptureRequest> request_;
> +	std::unique_ptr<CameraMetadata> resultMetadata_;
>  };
>
>  class CameraDevice : protected libcamera::Loggable
> --
> 2.31.1
>
Hirokazu Honda Sept. 27, 2021, 6:31 a.m. UTC | #3
Hi Umang, thank you for the patch.

On Tue, Sep 21, 2021 at 8:12 PM Jacopo Mondi <jacopo@jmondi.org> wrote:
>
> Hi Umang,
>
> On Mon, Sep 20, 2021 at 11:07:47PM +0530, Umang Jain wrote:
> > Store metadata which is sent as capture results into the
> > Camera3RequestDescriptor. This is will remove the need to send the
> > result metadata pointer separately to CameraStream::process().
> > In the subsequent commit, a Camera3RequestDescriptor pointer
> > will be passed to CameraStream::process() and the result metadata
> > can be directly accessed from there.
> >
> > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> > ---
> >  src/android/camera_device.cpp | 6 ++++--
> >  src/android/camera_device.h   | 1 +
> >  2 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 3d6a2bed..1ae4ac73 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -1131,6 +1131,8 @@ void CameraDevice::requestComplete(Request *request)
> >               resultMetadata = std::make_unique<CameraMetadata>(0, 0);
> >       }
> >
> > +     descriptor->resultMetadata_ = std::move(resultMetadata);
> > +
>
> Can't you
>         descriptor->resultMetadata_ = getResultMetadata(descriptor);
>
> >       /* Handle any JPEG compression. */
> >       for (camera3_stream_buffer_t &buffer : descriptor->buffers_) {
> >               CameraStream *cameraStream =
> > @@ -1150,7 +1152,7 @@ void CameraDevice::requestComplete(Request *request)
> >
> >               int ret = cameraStream->process(src, *buffer.buffer,
> >                                               descriptor->settings_,
> > -                                             resultMetadata.get());
> > +                                             descriptor->resultMetadata_.get());
>
> It's probably more tedious work, as it requires fixing the whole post
> processor hierarchy, but this could be just
>
>                         cameraStream->process(src, *buffer.buffer,
>                                               descriptor);
>
>
> >               /*
> >                * Return the FrameBuffer to the CameraStream now that we're
> >                * done processing it.
> > @@ -1165,7 +1167,7 @@ void CameraDevice::requestComplete(Request *request)
> >               }
> >       }
> >
> > -     captureResult.result = resultMetadata->get();
> > +     captureResult.result = descriptor->resultMetadata_->get();
> >       callbacks_->process_capture_result(callbacks_, &captureResult);
> >
> >       descriptors_.pop_front();
> > diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> > index 59d6cd39..b2871e52 100644
> > --- a/src/android/camera_device.h
> > +++ b/src/android/camera_device.h
> > @@ -47,6 +47,7 @@ struct Camera3RequestDescriptor {
> >       std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers_;
> >       CameraMetadata settings_;
> >       std::unique_ptr<CaptureRequest> request_;
> > +     std::unique_ptr<CameraMetadata> resultMetadata_;
> >  };
> >
> >  class CameraDevice : protected libcamera::Loggable
> > --
> > 2.31.1
> >

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 3d6a2bed..1ae4ac73 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1131,6 +1131,8 @@  void CameraDevice::requestComplete(Request *request)
 		resultMetadata = std::make_unique<CameraMetadata>(0, 0);
 	}
 
+	descriptor->resultMetadata_ = std::move(resultMetadata);
+
 	/* Handle any JPEG compression. */
 	for (camera3_stream_buffer_t &buffer : descriptor->buffers_) {
 		CameraStream *cameraStream =
@@ -1150,7 +1152,7 @@  void CameraDevice::requestComplete(Request *request)
 
 		int ret = cameraStream->process(src, *buffer.buffer,
 						descriptor->settings_,
-						resultMetadata.get());
+						descriptor->resultMetadata_.get());
 		/*
 		 * Return the FrameBuffer to the CameraStream now that we're
 		 * done processing it.
@@ -1165,7 +1167,7 @@  void CameraDevice::requestComplete(Request *request)
 		}
 	}
 
-	captureResult.result = resultMetadata->get();
+	captureResult.result = descriptor->resultMetadata_->get();
 	callbacks_->process_capture_result(callbacks_, &captureResult);
 
 	descriptors_.pop_front();
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 59d6cd39..b2871e52 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -47,6 +47,7 @@  struct Camera3RequestDescriptor {
 	std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers_;
 	CameraMetadata settings_;
 	std::unique_ptr<CaptureRequest> request_;
+	std::unique_ptr<CameraMetadata> resultMetadata_;
 };
 
 class CameraDevice : protected libcamera::Loggable