From 13986d6ce3ab64c44a8f086ef8942f56bbedff63 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 12 Jan 2023 12:10:43 +0000 Subject: libcamera: camera: Fix validateColorSpaces to choose "main" colour space The intention is that the "main" colour space is the colour space of the largest non-raw stream. Unfortunately the use of "config_[i].size" is clearly incorrect, and has been copied from prior versions of the code. This patch corrects the error. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Umang Jain Signed-off-by: Umang Jain --- src/libcamera/camera.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libcamera/camera.cpp') diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 2d947a44..0da167a7 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -361,6 +361,7 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF * largest non-raw stream with a defined color space (if there is one). */ std::optional colorSpace; + Size size; for (auto [i, cfg] : utils::enumerate(config_)) { if (!cfg.colorSpace) @@ -369,9 +370,10 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF if (cfg.colorSpace->adjust(cfg.pixelFormat)) status = Adjusted; - if (cfg.colorSpace != ColorSpace::Raw && - (!colorSpace || cfg.size > config_[i].size)) + if (cfg.colorSpace != ColorSpace::Raw && cfg.size > size) { colorSpace = cfg.colorSpace; + size = cfg.size; + } } if (!colorSpace || !(flags & ColorSpaceFlag::StreamsShareColorSpace)) -- cgit v1.2.1