[libcamera-devel] [PATCH 1/3] libcamera: pipeline: Replace resize() with erase() in validate()
Jacopo Mondi
jacopo at jmondi.org
Tue Mar 24 09:08:17 CET 2020
Hi Kaaira,
On Tue, Mar 24, 2020 at 04:58:59AM +0530, Kaaira Gupta wrote:
> Replace .resize() with .erase() in validate() calls in all pipelines,
> because resize() calls default constructor StreamConfiguration() when it
> tries to increase the size.
>
> Signed-off-by: Kaaira Gupta <kgupta at es.iitr.ac.in>
> ---
> src/libcamera/pipeline/ipu3/ipu3.cpp | 9 +++++++--
> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 8 ++++++--
> src/libcamera/pipeline/uvcvideo.cpp | 8 ++++++--
> src/libcamera/pipeline/vimc.cpp | 8 ++++++--
> 4 files changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 1b44460..7feb44c 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -298,9 +298,14 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
> if (config_.empty())
> return Invalid;
>
> - /* Cap the number of entries to the available streams. */
> + /*
> + * Cap the number of entries to the available streams.
> + * Use erase() instead of resize() because resize() uses default constructor
> + * when it increases config_'s size, which we wish to avoid.
> + */
> +
Additional blank line. Please drop it.
Apart from this
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Thanks
j
> if (config_.size() > 2) {
> - config_.resize(2);
> + config_.erase(config_.begin() + 2, config_.end());
> status = Adjusted;
> }
>
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 2f909ce..04b0ed3 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -447,9 +447,13 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
> if (config_.empty())
> return Invalid;
>
> - /* Cap the number of entries to the available streams. */
> + /*
> + * Cap the number of entries to the available streams.
> + * Use erase() instead of resize() because resize() uses default constructor
> + * when it increases config_'s size, which we wish to avoid.
> + */
> if (config_.size() > 1) {
> - config_.resize(1);
> + config_.erase(config_.begin() + 1, config_.end());
> status = Adjusted;
> }
>
> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> index ffbddf2..462eae2 100644
> --- a/src/libcamera/pipeline/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo.cpp
> @@ -97,9 +97,13 @@ CameraConfiguration::Status UVCCameraConfiguration::validate()
> if (config_.empty())
> return Invalid;
>
> - /* Cap the number of entries to the available streams. */
> + /*
> + * Cap the number of entries to the available streams.
> + * Use erase() instead of resize() because resize() uses default constructor
> + * when it increases config_'s size, which we wish to avoid.
> + */
> if (config_.size() > 1) {
> - config_.resize(1);
> + config_.erase(config_.begin() + 1, config_.end());
> status = Adjusted;
> }
>
> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
> index b04a972..4c991ff 100644
> --- a/src/libcamera/pipeline/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc.cpp
> @@ -123,9 +123,13 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
> if (config_.empty())
> return Invalid;
>
> - /* Cap the number of entries to the available streams. */
> + /*
> + * Cap the number of entries to the available streams.
> + * Use erase() instead of resize() because resize() uses default constructor
> + * when it increases config_'s size, which we wish to avoid.
> + */
> if (config_.size() > 1) {
> - config_.resize(1);
> + config_.erase(config_.begin() + 1, config_.end());
> status = Adjusted;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
More information about the libcamera-devel
mailing list