summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-12-01 15:42:15 +0100
committerJacopo Mondi <jacopo@jmondi.org>2020-12-02 11:23:18 +0100
commitc268e4f2e8dd45d3538489fa164a043cd25b0453 (patch)
tree5073e77fe34d5ff41fe1614d0403f9bd8573d235 /src
parent5815bd0397bc63772642820a3c296b2c5fd7c791 (diff)
android: camera_mode: Reserve 'data' vectors
The CameraDevice::getStaticMetadata() function populates the entries for Android's static metadata by walking the ControlInfo supported values reported by the libcamera pipeline. The number of entries to be passed to Android is computed using the vector's size which is initialized at vector creation time to the maximum number of available entries. In order to report the correct number of metadata do not create the vector with the largest possible number of elements but only reserve space for them using std::vector::reserve() which does not modify the vector's size. This patch fixes cros_camera_test: Camera3DeviceTest/Camera3DeviceDefaultSettings.ConstructDefaultSettings/1 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 4690346e..4eb05df0 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -596,7 +596,8 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
/* Color correction static metadata. */
{
- std::vector<uint8_t> data(3);
+ std::vector<uint8_t> data;
+ data.reserve(3);
const auto &infoMap = controlsInfo.find(&controls::draft::ColorCorrectionAberrationMode);
if (infoMap != controlsInfo.end()) {
for (const auto &value : infoMap->second.values())
@@ -782,7 +783,8 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
&maxFaceCount, 1);
{
- std::vector<uint8_t> data(2);
+ std::vector<uint8_t> data;
+ data.reserve(2);
const auto &infoMap = controlsInfo.find(&controls::draft::LensShadingMapMode);
if (infoMap != controlsInfo.end()) {
for (const auto &value : infoMap->second.values())
@@ -850,7 +852,8 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
/* Noise reduction modes. */
{
- std::vector<uint8_t> data(5);
+ std::vector<uint8_t> data;
+ data.reserve(5);
const auto &infoMap = controlsInfo.find(&controls::draft::NoiseReductionMode);
if (infoMap != controlsInfo.end()) {
for (const auto &value : infoMap->second.values())