{"id":19121,"url":"https://patchwork.libcamera.org/api/patches/19121/?format=json","web_url":"https://patchwork.libcamera.org/patch/19121/","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":"<20231006132000.23504-20-naush@raspberrypi.com>","date":"2023-10-06T13:19:59","name":"[libcamera-devel,19/20] ipa: rpi: agc: Avoid overwriting caller's statistics pointer","commit_ref":null,"pull_url":null,"state":"superseded","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/19121/mbox/","series":[{"id":4047,"url":"https://patchwork.libcamera.org/api/series/4047/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4047","date":"2023-10-06T13:19:40","name":"Raspberry Pi: Preliminary PiSP support","version":1,"mbox":"https://patchwork.libcamera.org/series/4047/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19121/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19121/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 2E29DC32C1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Oct 2023 13:20:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C66B462963;\n\tFri,  6 Oct 2023 15:20:22 +0200 (CEST)","from mail-wr1-x434.google.com (mail-wr1-x434.google.com\n\t[IPv6:2a00:1450:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AFF462969\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Oct 2023 15:20:21 +0200 (CEST)","by mail-wr1-x434.google.com with SMTP id\n\tffacd0b85a97d-317c3ac7339so1867532f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 06 Oct 2023 06:20:21 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm8-20020a056000180800b00321773bb933sm1639478wrh.77.2023.10.06.06.20.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 06 Oct 2023 06:20:19 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1696598422;\n\tbh=g0p94eYnymjkLMt3XLjiCvHtkzKp0QFmMWMNtcKxvcE=;\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:\n\tFrom;\n\tb=a+3ZaSRPeUjXY1/dQdYhQlW+xxFAJgfkwd7qQv14AzcNc4uiaCBJdN0+0T3vHr0eh\n\tDqjWNtelc0azi7o2oRuQr1bUOAVWXSpPGrbiPonNtP6qpwLn6p197GR1pFA2Z/qAJi\n\tfPlLLM0vdQBtxuSYjHnvoMr/pVduV0m5FGPoGK9i0rb48CVzWBJ0iclUo2V0Fpdnm5\n\tVyIv/SPDhZ/Ilw49Fvi6hPyETPSRtU/Nh0xv9UR3SVKGEHelglb7qOvo/11jzOs4NL\n\ttAGHP766M69n68JW7R3ORHJ12FWw/0i6VyxeskkooRtF4ITEY2aREz4mpg8R7FiVUO\n\tRHVn1zSfB6Q4g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1696598420; x=1697203220;\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=wX6bWO/uDRnRFXGdanoRa7WRWmc0W9jFOPexu58lLy8=;\n\tb=pFKtpafjJk40xxqt/ku+pBgfeLO1yepcJx8E1yKjI+0GcBIiy3nGTgXzLovMJlrVSX\n\tan+/H8lq87lqcHYdTvk3ZAL5Ug9r7HjaYES4zExsLY+eICcVAf87sU3to1vqrSVuUe3G\n\thxbqN05mUpNUx5/MILder6V34r2g2wGglAJAYskd0qS/XV6thrECFY/LKuezcxttTMPm\n\tPZ/8iL2F77TUejACYTusVcVBkXNOtLStOZXfvqF1WHLToVQn4k7JjLQ/1zr6Lxerz0Nb\n\tbw4rMwEX4ExQvJI66Vs/Tj/pjrFCBTO2/LQ3H05qWOpIiOjeE0kImuEabtZrBGOpETJ3\n\tJnvQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"pFKtpafj\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1696598420; x=1697203220;\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=wX6bWO/uDRnRFXGdanoRa7WRWmc0W9jFOPexu58lLy8=;\n\tb=g4Nc3lgig7HTBfolxiCedVUejFV4WAcsRfOpDNw7NiZ0wmBWRFYV5luK7cdC7eCv7x\n\tRHz8SEeqhNs5J2UwhJtNv1psL6Wm4sC+nHauW8IylrByzIuNPT9Ck8Dwpgh7hq93XGTE\n\tQB0Va+UHbzaiwxysr6iL+38ju/o6V+HNjRKcm/UHb7I3//mwIQ7WTosjsHVf6oE3ZJyv\n\tfrS4iS2ueyG4JbmI4CLTzuERDOjPNF85bFLjsDpv0EkKPSdCq++H7tD3EN7kIfuDFMGP\n\tZI0TzqDLRZ8t5kvhfMEy8jo/FSWYtyhBsQHCoTxwb5uD7KHNiFvBaMjtEyTW4/TpRnI5\n\tIIeg==","X-Gm-Message-State":"AOJu0Yx5ie10kFwNtfEc3uXj3F4s22Cn2XGe3sEMSc2u0sKmjPIb3pPq\n\t7un5lMEfRdybz4+wmQCj1z+gS0zPzOS3ZStH3TJd6A==","X-Google-Smtp-Source":"AGHT+IGEIspYzvmqFi9ifORU42ujjKZ1tTt6JZfU+irJoH6zVUcR2cQ1eCJcx+10aJubiwhEpdNu8A==","X-Received":"by 2002:adf:e8ca:0:b0:31f:e1b4:583d with SMTP id\n\tk10-20020adfe8ca000000b0031fe1b4583dmr8183927wrn.56.1696598420605; \n\tFri, 06 Oct 2023 06:20:20 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  6 Oct 2023 14:19:59 +0100","Message-Id":"<20231006132000.23504-20-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231006132000.23504-1-naush@raspberrypi.com>","References":"<20231006132000.23504-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 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>","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>\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","19/20"]}