{"id":19143,"url":"https://patchwork.libcamera.org/api/patches/19143/?format=json","web_url":"https://patchwork.libcamera.org/patch/19143/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20231013074841.16972-20-naush@raspberrypi.com>","date":"2023-10-13T07:48:40","name":"[libcamera-devel,v2,19/20] ipa: rpi: agc: Avoid overwriting caller's statistics pointer","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b65847ae5d69934706358b88d05e51484bacc303","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19143/mbox/","series":[{"id":4049,"url":"https://patchwork.libcamera.org/api/series/4049/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4049","date":"2023-10-13T07:48:21","name":"Raspberry Pi: Preliminary PiSP support","version":2,"mbox":"https://patchwork.libcamera.org/series/4049/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19143/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19143/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 42F6BC32B8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:49:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8333629AA;\n\tFri, 13 Oct 2023 09:49:10 +0200 (CEST)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AF315629A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:49:00 +0200 (CEST)","by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-4056ce55e7eso18580915e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:49:00 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:59 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183350;\n\tbh=3Lx2hapHthiLl5pLeRAZjJBWOhBKLgxIEHxCdgDRkQE=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=wwRBmdmZL0iS+/qsC7BsAQ8m0tvUJMMIhc30YhHTXAJH5k825wCrxcxkBuJp2gpFx\n\thAwsCgZKYVNsUzno7L37Xn6Ot2x4BMPvXEp+ZrUkX7gWHEj9+DWAdCtk+79q/2Vm7C\n\twosEKIj9n3cRgZnQXCmXT8otb8Bs8UmMn0BTlxlxoN6Fev6yZLn9uCF0gOkplLpocs\n\tbHzxOQGmDk7xbEFqUUIbjZ9a7A0fiApCqhq5vZCvvRF6Bv+iseMXtDTWjNy3rS2mJg\n\tcfAF3CL3V+pJRDF28XWiiaiyUuqIE+otAFtkkXGXnsBvQa4MliwfxRSrIcR1iY79Jh\n\tE25J9K3gH7NpA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697183340; x=1697788140;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=8iMkGXcyRbrdBdUJFvNNmrvtddhoCuMTne7mGzBmNQM=;\n\tb=LwSkK6aKuWH467HMeKt5S7LtZPyFvzGoC3kqas4Lrk05dcNzvpOAkFuiKaUkPzsp+B\n\tE41axCa/Fu3c6naFZ4tnAAvE2GjPC+AwHHEdvUU7q/1ULifgOh7h5iHCIyiLPRB7xjWL\n\tm87tGY70haZ3Q/ugHxGqLHJ3SAS+faNDVftmNSQyAH6VCfTPwrBJmpPPjlOvnAzg5aSE\n\t/LzNB/lG6GlRrn/zmrioXvrE5c7H/wlrwK/8aPMjjvl4rN6NKay6ydQIMwXU+cFwcspn\n\t1f6aklBHDUSCsYGM0a3+uHIG/gI1YnQp47Tr+pZHifnpKkgYI7I8bmqMS2i0BFNKHOX3\n\t3RJw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"LwSkK6aK\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697183340; x=1697788140;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=8iMkGXcyRbrdBdUJFvNNmrvtddhoCuMTne7mGzBmNQM=;\n\tb=mP2mN3CeWLjmJeOHWOK2VP8XF9ZLh+bbnnbB1EeWXTyU9S0lwaIpviyqJRfTi+o8Xb\n\t1Y7NPIJyZiEhjme1+mOvHW3MU5LJIotMIMyl8ewidOgJfr4ty5Ywz/BYUpBf0dhcBn88\n\t9UA41+zWOjH7EqIFmKD5XFar2D5IXrDlqTbrLE27Qw/p/8mEyipN/arcM7/Vn90HFsIk\n\tmu8LzCp/A0iCeYk9TIQzxRdrD4Jj3GnKV34ifMJgVXKiqxURVg6ZNAXxxnKCb9mf/zYd\n\tw9No4WTN3IM551IOVUcg3cJZnCsMXtdB1VNhQfg3CL1fjJnGuR4Dk888v6ms6WFbFsyA\n\thZTw==","X-Gm-Message-State":"AOJu0Yz4i2iqw2qszEjdc+zA239cro/lECEIDo7KoUzdB1l0rbs6sPcN\n\tu5aZEJkazVA9uaic8Dulw3jKetUkYJlxTMRQYRNWNA==","X-Google-Smtp-Source":"AGHT+IH0CiTHB91Al6PmePCSQqUx8Aq0QhRHE6wPDh0Grb44NoF9xHxvAdM07rwdRFwJ+cgITML0jQ==","X-Received":"by 2002:a7b:cbd4:0:b0:3fb:b3aa:1c8a with SMTP id\n\tn20-20020a7bcbd4000000b003fbb3aa1c8amr23615813wmi.16.1697183340057; \n\tFri, 13 Oct 2023 00:49:00 -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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 19/20] ipa: rpi: agc: Avoid overwriting\n\tcaller's statistics pointer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: David Plowman <david.plowman@raspberrypi.com>\n\nThe code was inadvertently overwriting the caller's StatisticsPtr,\nmeaning that subsequent algorithms would get the wrong image\nstatistics when AGC channels changed.\n\nThis could be fix using std::ref, though I find the C-style pointer\nfix easier to understand!\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/rpi/controller/rpi/agc.cpp | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp\nindex 870cb4315c42..758da0719b9b 100644\n--- a/src/ipa/rpi/controller/rpi/agc.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc.cpp\n@@ -311,15 +311,16 @@ void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata)\n \t * exist, and call process(). We must make the agc.status metadata record correctly\n \t * which channel this is.\n \t */\n+\tStatisticsPtr *statsPtr = &stats;\n \tif (channelData.statistics && channelData.deviceStatus) {\n \t\tdeviceStatus = *channelData.deviceStatus;\n-\t\tstats = channelData.statistics;\n+\t\tstatsPtr = &channelData.statistics;\n \t} else {\n \t\t/* Can also happen when new channels start. */\n \t\tLOG(RPiAgc, Debug) << \"process: channel \" << channelIndex << \" not seen yet\";\n \t}\n \n-\tchannelData.channel.process(stats, deviceStatus, imageMetadata, channelTotalExposures_);\n+\tchannelData.channel.process(*statsPtr, deviceStatus, imageMetadata, channelTotalExposures_);\n \tauto dur = setCurrentChannelIndexGetExposure(imageMetadata, \"process: no AGC status found\",\n \t\t\t\t\t\t     channelIndex);\n \tif (dur)\n","prefixes":["libcamera-devel","v2","19/20"]}