[libcamera-devel] [PATCH v2 1/3] libcamera: pipeline: Replace resize() with erase() in validate()
Kaaira Gupta
kgupta at es.iitr.ac.in
Sat Apr 18 14:54:19 CEST 2020
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>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/libcamera/pipeline/ipu3/ipu3.cpp | 8 ++++++--
src/libcamera/pipeline/rkisp1/rkisp1.cpp | 8 ++++++--
src/libcamera/pipeline/uvcvideo.cpp | 8 ++++++--
src/libcamera/pipeline/vimc.cpp | 8 ++++++--
4 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 1b44460..36f3990 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -298,9 +298,13 @@ 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.
+ */
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
More information about the libcamera-devel
mailing list