From patchwork Tue Nov 26 18:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22103 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5CEFEC3200 for ; Tue, 26 Nov 2024 18:03:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C00466084; Tue, 26 Nov 2024 19:03:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="PdT/xg4f"; dkim-atps=neutral Received: from mail-10630.protonmail.ch (mail-10630.protonmail.ch [79.135.106.30]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C94C665FC9 for ; Tue, 26 Nov 2024 19:03:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732644191; x=1732903391; bh=JmUP8o0i9WGI1KB7pfbtZt+zNHFItTb8O419XnxdwbY=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=PdT/xg4fAG/N/5ZIV1K0GzVrTQkAH2MHBT2tFib5Plv/dA6HxGDqSnrvo5OuWusRV E2Q4BCNSZ+ZFdPFp/sB39dDMjPgfIrDdtgoHekToXTqYCNOfzfaHcCE3NbJ53BAxvW dVCmIKZj3AJtCQaKQTb/s5Ye7D1cn0pf+TjAhnqFMUjesjdR94xPfz31q+jKs48q7S C0QdtahscijWhu1MU5+MIYtEs/86XSrwYuUUoniT1awA9SSfMcuFdJoEK32J8rqaHE +fDepfxVTidGymEq9TIJcvocuSkXbSBkBW8TmTOYYa6GaTtEfEYJ8cDx94G01OwXjq HhAM+WsoMmQ0w== Date: Tue, 26 Nov 2024 18:03:05 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v1] libcamera: Don't copy `StreamConfiguration` when iterating Message-ID: <20241126180302.685265-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 1092274ac55c45e4b3db78d4957c5b9025092fcc MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A copy is made in the range-based for loop, and thus all modifications done in the for loop body are lost, and not actually applied to the object in the container. Fix that by taking a reference in the range-based for loop. Fixes: 4217c9f1aa863c ("libcamera: camera: Zero streams before validate()") Fixes: 613d5402673eb9 ("pipeline: raspberrypi: Fix handling of colour spaces") Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Naushir Patuck --- src/libcamera/camera.cpp | 4 ++-- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 7507e9dd..4c865a46 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1178,8 +1178,8 @@ int Camera::configure(CameraConfiguration *config) if (ret < 0) return ret; - for (auto it : *config) - it.setStream(nullptr); + for (auto &cfg : *config) + cfg.setStream(nullptr); if (config->validate() != CameraConfiguration::Valid) { LOG(Camera, Error) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 9e2d9d23..6f278b29 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -105,7 +105,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_ Status status = Valid; yuvColorSpace_.reset(); - for (auto cfg : config_) { + for (auto &cfg : config_) { /* First fix up raw streams to have the "raw" colour space. */ if (PipelineHandlerBase::isRaw(cfg.pixelFormat)) { /* If there was no value here, that doesn't count as "adjusted". */ @@ -130,7 +130,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_ rgbColorSpace_->range = ColorSpace::Range::Full; /* Go through the streams again and force everyone to the same colour space. */ - for (auto cfg : config_) { + for (auto &cfg : config_) { if (cfg.colorSpace == ColorSpace::Raw) continue;