[libcamera-devel,v3,06/11] android: camera_device: Get rid of stream counter

Message ID 20200908134142.27470-7-jacopo@jmondi.org
State Accepted
Headers show
Series
  • android: camera_device: Fix JPEG/RAW sizes
Related show

Commit Message

Jacopo Mondi Sept. 8, 2020, 1:41 p.m. UTC
Use the size() method of the CameraConfiguration class to retrieve the
index of the StreamConfiguration associated with a CameraStream and get
rid of the custom counter.

Acked-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 | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

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

Thanks for your work.

On 2020-09-08 15:41:37 +0200, Jacopo Mondi wrote:
> Use the size() method of the CameraConfiguration class to retrieve the
> index of the StreamConfiguration associated with a CameraStream and get
> rid of the custom counter.
> 
> Acked-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 | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 5f4b95987615..562cbb3c415e 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1189,12 +1189,6 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  	streams_.clear();
>  	streams_.reserve(stream_list->num_streams);
>  
> -	/*
> -	 * Track actually created streams, as there may not be a 1:1 mapping of
> -	 * camera3 streams to libcamera streams.
> -	 */
> -	unsigned int streamIndex = 0;
> -
>  	/* First handle all non-MJPEG streams. */
>  	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
>  		camera3_stream_t *stream = stream_list->streams[i];
> @@ -1225,8 +1219,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  		streamConfiguration.pixelFormat = format;
>  
>  		config_->addConfiguration(streamConfiguration);
> -
> -		streams_[i].index = streamIndex++;
> +		streams_[i].index = config_->size() - 1;
>  	}
>  
>  	/* Now handle MJPEG streams, adding a new stream if required. */
> @@ -1275,7 +1268,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  				       << " for MJPEG support";
>  
>  			config_->addConfiguration(streamConfiguration);
> -			streams_[i].index = streamIndex++;
> +			streams_[i].index = config_->size() - 1;
>  		}
>  	}
>  
> -- 
> 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:28 a.m. UTC | #2
Thanks for the patch

On Thu, Sep 10, 2020 at 7:51 PM Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> Hi Jacopo,
>
> Thanks for your work.
>
> On 2020-09-08 15:41:37 +0200, Jacopo Mondi wrote:
> > Use the size() method of the CameraConfiguration class to retrieve the
> > index of the StreamConfiguration associated with a CameraStream and get
> > rid of the custom counter.
> >
> > Acked-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 | 11 ++---------
> >  1 file changed, 2 insertions(+), 9 deletions(-)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 5f4b95987615..562cbb3c415e 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -1189,12 +1189,6 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >       streams_.clear();
> >       streams_.reserve(stream_list->num_streams);
> >
> > -     /*
> > -      * Track actually created streams, as there may not be a 1:1 mapping of
> > -      * camera3 streams to libcamera streams.
> > -      */
> > -     unsigned int streamIndex = 0;
> > -
> >       /* First handle all non-MJPEG streams. */
> >       for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
> >               camera3_stream_t *stream = stream_list->streams[i];
> > @@ -1225,8 +1219,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >               streamConfiguration.pixelFormat = format;
> >
> >               config_->addConfiguration(streamConfiguration);
> > -
> > -             streams_[i].index = streamIndex++;
> > +             streams_[i].index = config_->size() - 1;
> >       }
> >
> >       /* Now handle MJPEG streams, adding a new stream if required. */
> > @@ -1275,7 +1268,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >                                      << " for MJPEG support";
> >
> >                       config_->addConfiguration(streamConfiguration);
> > -                     streams_[i].index = streamIndex++;
> > +                     streams_[i].index = config_->size() - 1;
> >               }
> >       }
> >
> > --
> > 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 5f4b95987615..562cbb3c415e 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1189,12 +1189,6 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 	streams_.clear();
 	streams_.reserve(stream_list->num_streams);
 
-	/*
-	 * Track actually created streams, as there may not be a 1:1 mapping of
-	 * camera3 streams to libcamera streams.
-	 */
-	unsigned int streamIndex = 0;
-
 	/* First handle all non-MJPEG streams. */
 	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
 		camera3_stream_t *stream = stream_list->streams[i];
@@ -1225,8 +1219,7 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 		streamConfiguration.pixelFormat = format;
 
 		config_->addConfiguration(streamConfiguration);
-
-		streams_[i].index = streamIndex++;
+		streams_[i].index = config_->size() - 1;
 	}
 
 	/* Now handle MJPEG streams, adding a new stream if required. */
@@ -1275,7 +1268,7 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 				       << " for MJPEG support";
 
 			config_->addConfiguration(streamConfiguration);
-			streams_[i].index = streamIndex++;
+			streams_[i].index = config_->size() - 1;
 		}
 	}