From patchwork Fri Oct 13 07:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19143 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 42F6BC32B8 for ; Fri, 13 Oct 2023 07:49:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8333629AA; Fri, 13 Oct 2023 09:49:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183350; bh=3Lx2hapHthiLl5pLeRAZjJBWOhBKLgxIEHxCdgDRkQE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wwRBmdmZL0iS+/qsC7BsAQ8m0tvUJMMIhc30YhHTXAJH5k825wCrxcxkBuJp2gpFx hAwsCgZKYVNsUzno7L37Xn6Ot2x4BMPvXEp+ZrUkX7gWHEj9+DWAdCtk+79q/2Vm7C wosEKIj9n3cRgZnQXCmXT8otb8Bs8UmMn0BTlxlxoN6Fev6yZLn9uCF0gOkplLpocs bHzxOQGmDk7xbEFqUUIbjZ9a7A0fiApCqhq5vZCvvRF6Bv+iseMXtDTWjNy3rS2mJg cfAF3CL3V+pJRDF28XWiiaiyUuqIE+otAFtkkXGXnsBvQa4MliwfxRSrIcR1iY79Jh E25J9K3gH7NpA== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF315629A0 for ; Fri, 13 Oct 2023 09:49:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="LwSkK6aK"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso18580915e9.2 for ; Fri, 13 Oct 2023 00:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697183340; x=1697788140; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8iMkGXcyRbrdBdUJFvNNmrvtddhoCuMTne7mGzBmNQM=; b=LwSkK6aKuWH467HMeKt5S7LtZPyFvzGoC3kqas4Lrk05dcNzvpOAkFuiKaUkPzsp+B E41axCa/Fu3c6naFZ4tnAAvE2GjPC+AwHHEdvUU7q/1ULifgOh7h5iHCIyiLPRB7xjWL m87tGY70haZ3Q/ugHxGqLHJ3SAS+faNDVftmNSQyAH6VCfTPwrBJmpPPjlOvnAzg5aSE /LzNB/lG6GlRrn/zmrioXvrE5c7H/wlrwK/8aPMjjvl4rN6NKay6ydQIMwXU+cFwcspn 1f6aklBHDUSCsYGM0a3+uHIG/gI1YnQp47Tr+pZHifnpKkgYI7I8bmqMS2i0BFNKHOX3 3RJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183340; x=1697788140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8iMkGXcyRbrdBdUJFvNNmrvtddhoCuMTne7mGzBmNQM=; b=mP2mN3CeWLjmJeOHWOK2VP8XF9ZLh+bbnnbB1EeWXTyU9S0lwaIpviyqJRfTi+o8Xb 1Y7NPIJyZiEhjme1+mOvHW3MU5LJIotMIMyl8ewidOgJfr4ty5Ywz/BYUpBf0dhcBn88 9UA41+zWOjH7EqIFmKD5XFar2D5IXrDlqTbrLE27Qw/p/8mEyipN/arcM7/Vn90HFsIk mu8LzCp/A0iCeYk9TIQzxRdrD4Jj3GnKV34ifMJgVXKiqxURVg6ZNAXxxnKCb9mf/zYd w9No4WTN3IM551IOVUcg3cJZnCsMXtdB1VNhQfg3CL1fjJnGuR4Dk888v6ms6WFbFsyA hZTw== X-Gm-Message-State: AOJu0Yz4i2iqw2qszEjdc+zA239cro/lECEIDo7KoUzdB1l0rbs6sPcN u5aZEJkazVA9uaic8Dulw3jKetUkYJlxTMRQYRNWNA== X-Google-Smtp-Source: AGHT+IH0CiTHB91Al6PmePCSQqUx8Aq0QhRHE6wPDh0Grb44NoF9xHxvAdM07rwdRFwJ+cgITML0jQ== X-Received: by 2002:a7b:cbd4:0:b0:3fb:b3aa:1c8a with SMTP id n20-20020a7bcbd4000000b003fbb3aa1c8amr23615813wmi.16.1697183340057; Fri, 13 Oct 2023 00:49:00 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:48:59 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 13 Oct 2023 08:48:40 +0100 Message-Id: <20231013074841.16972-20-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013074841.16972-1-naush@raspberrypi.com> References: <20231013074841.16972-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 19/20] ipa: rpi: agc: Avoid overwriting caller's statistics pointer 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman The code was inadvertently overwriting the caller's StatisticsPtr, meaning that subsequent algorithms would get the wrong image statistics when AGC channels changed. This could be fix using std::ref, though I find the C-style pointer fix easier to understand! Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/ipa/rpi/controller/rpi/agc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp index 870cb4315c42..758da0719b9b 100644 --- a/src/ipa/rpi/controller/rpi/agc.cpp +++ b/src/ipa/rpi/controller/rpi/agc.cpp @@ -311,15 +311,16 @@ void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata) * exist, and call process(). We must make the agc.status metadata record correctly * which channel this is. */ + StatisticsPtr *statsPtr = &stats; if (channelData.statistics && channelData.deviceStatus) { deviceStatus = *channelData.deviceStatus; - stats = channelData.statistics; + statsPtr = &channelData.statistics; } else { /* Can also happen when new channels start. */ LOG(RPiAgc, Debug) << "process: channel " << channelIndex << " not seen yet"; } - channelData.channel.process(stats, deviceStatus, imageMetadata, channelTotalExposures_); + channelData.channel.process(*statsPtr, deviceStatus, imageMetadata, channelTotalExposures_); auto dur = setCurrentChannelIndexGetExposure(imageMetadata, "process: no AGC status found", channelIndex); if (dur)