[libcamera-devel,v3,07/11] android: camera_device: Use camera3 stream format

Message ID 20200908134142.27470-8-jacopo@jmondi.org
State Superseded, archived
Delegated to: Jacopo Mondi
Headers show
Series
  • android: camera_device: Fix JPEG/RAW sizes
Related show

Commit Message

Jacopo Mondi Sept. 8, 2020, 1:41 p.m. UTC
When iterating the camera3_stream_t received from the Android camera
framework to identify the MJPEG streams, the format check was performed
on the CameraStream created when iterating the non-MJPEG streams and not
on the format actually requested by Android. As the next patches will
remove the creation of CameraStream instances for MJPEG streams, use the
camera3_stream format to prepare for that.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund Sept. 10, 2020, 10:52 a.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2020-09-08 15:41:38 +0200, Jacopo Mondi wrote:
> When iterating the camera3_stream_t received from the Android camera
> framework to identify the MJPEG streams, the format check was performed
> on the CameraStream created when iterating the non-MJPEG streams and not
> on the format actually requested by Android. As the next patches will
> remove the creation of CameraStream instances for MJPEG streams, use the
> camera3_stream format to prepare for that.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/android/camera_device.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 562cbb3c415e..2cad4fe76c3c 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1225,9 +1225,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  	/* Now handle MJPEG streams, adding a new stream if required. */
>  	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
>  		camera3_stream_t *stream = stream_list->streams[i];
> +		PixelFormat format = toPixelFormat(stream->format);
>  		bool match = false;
>  
> -		if (streams_[i].format != formats::MJPEG)
> +		if (format != formats::MJPEG)
>  			continue;
>  
>  		/* Search for a compatible stream */
> -- 
> 2.28.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Hirokazu Honda Sept. 11, 2020, 2:32 a.m. UTC | #2
On Thu, Sep 10, 2020 at 7:52 PM Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> Hi Jacopo,
>
> Thanks for your work.
>
> On 2020-09-08 15:41:38 +0200, Jacopo Mondi wrote:
> > When iterating the camera3_stream_t received from the Android camera
> > framework to identify the MJPEG streams, the format check was performed
> > on the CameraStream created when iterating the non-MJPEG streams and not
> > on the format actually requested by Android. As the next patches will
> > remove the creation of CameraStream instances for MJPEG streams, use the
> > camera3_stream format to prepare for that.
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
>

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

> > ---
> >  src/android/camera_device.cpp | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 562cbb3c415e..2cad4fe76c3c 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -1225,9 +1225,10 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >       /* Now handle MJPEG streams, adding a new stream if required. */
> >       for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
> >               camera3_stream_t *stream = stream_list->streams[i];
> > +             PixelFormat format = toPixelFormat(stream->format);
> >               bool match = false;
> >
> > -             if (streams_[i].format != formats::MJPEG)
> > +             if (format != formats::MJPEG)
> >                       continue;
> >
> >               /* Search for a compatible stream */
> > --
> > 2.28.0
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards,
> Niklas Söderlund
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 562cbb3c415e..2cad4fe76c3c 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1225,9 +1225,10 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 	/* Now handle MJPEG streams, adding a new stream if required. */
 	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
 		camera3_stream_t *stream = stream_list->streams[i];
+		PixelFormat format = toPixelFormat(stream->format);
 		bool match = false;
 
-		if (streams_[i].format != formats::MJPEG)
+		if (format != formats::MJPEG)
 			continue;
 
 		/* Search for a compatible stream */