[{"id":34978,"web_url":"https://patchwork.libcamera.org/comment/34978/","msgid":"<175311851972.50296.3780425026702469847@ping.linuxembedded.co.uk>","date":"2025-07-21T17:21:59","subject":"Re: [PATCH 2/2] libcamera: software_isp: Reduce statistics image\n\tarea","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-07-18 15:44:56)\n> The statistics in software ISP is computed basically over the whole\n> image area, although only on part of the pixels.  It is not necessary to\n> cover the whole image area, it's sufficient to compute the statistics\n> let's say over the central area of 2/3 of the image width and height,\n> which should be both sufficient and faster.  The speedup is not that\n> important with the CPU implementation but it may save CPU work\n> more noticeably with GPU debayering implementation.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/libcamera/software_isp/debayer_egl.cpp | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index 9ec966608..534e36050 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -393,8 +393,11 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n>         window_.width = outputCfg.size.width;\n>         window_.height = outputCfg.size.height;\n>  \n> -       /* Don't pass x,y since process() already adjusts src before passing it */\n> -       stats_->setWindow(Rectangle(window_.size()));\n> +       /*\n> +        * Don't pass x,y since process() already adjusts src before passing it.\n> +        * But reduce the width and height by 2/3 for speedup.\n> +        */\n> +       stats_->setWindow(Rectangle(window_.size()).croppedBy(2, 3));\n\nWhat does the comment about x,y mean now? what x,y adjustment is made?\n\nIf croppedBy() is made to keep the initial x,y correctly - would this\nthe nmake the correct final window?\n\n\n\n>  \n>         LOG(Debayer, Debug) << \"Input width \" << inputCfg.size.width << \" height \" << inputCfg.size.height;\n>         LOG(Debayer, Debug) << \"Output width \" << outputCfg.size.width << \" height \" << outputCfg.size.height;\n> -- \n> 2.50.1\n>","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 A9C8CBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Jul 2025 17:22:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8335268FF7;\n\tMon, 21 Jul 2025 19:22:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B39A068FB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 19:22:02 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 74CAA7939;\n\tMon, 21 Jul 2025 19:21:25 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"NonXVyMm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753118485;\n\tbh=d49vjTdVdH0GfQeJxbnBYzNQ7Z2u4xCP5iW46sc1tIs=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=NonXVyMmyCeuvEOMPmIfG1L0xjCngE82hpP8bO2PtN1Wz9ZUsgDQpLsbLmYOMwTvQ\n\tjyWxVxO4wH5MvzBXTl91UgkrHgbaSprO31LLhCUXk+z4qKwYehjhCRUr64mH+ASPu+\n\tKcogQEpjCOX9Fk03+o2EqwtyK2vmwa3yj6W1ooqk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250718144456.58625-2-mzamazal@redhat.com>","References":"<20250718144456.58625-1-mzamazal@redhat.com>\n\t<20250718144456.58625-2-mzamazal@redhat.com>","Subject":"Re: [PATCH 2/2] libcamera: software_isp: Reduce statistics image\n\tarea","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Mon, 21 Jul 2025 18:21:59 +0100","Message-ID":"<175311851972.50296.3780425026702469847@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35000,"web_url":"https://patchwork.libcamera.org/comment/35000/","msgid":"<85jz41baun.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-07-21T19:30:24","subject":"Re: [PATCH 2/2] libcamera: software_isp: Reduce statistics image\n\tarea","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Kieran,\n\nKieran Bingham <kieran.bingham@ideasonboard.com> writes:\n\n> Quoting Milan Zamazal (2025-07-18 15:44:56)\n>> The statistics in software ISP is computed basically over the whole\n>> image area, although only on part of the pixels.  It is not necessary to\n>\n>> cover the whole image area, it's sufficient to compute the statistics\n>> let's say over the central area of 2/3 of the image width and height,\n>> which should be both sufficient and faster.  The speedup is not that\n>> important with the CPU implementation but it may save CPU work\n>> more noticeably with GPU debayering implementation.\n>> \n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>  src/libcamera/software_isp/debayer_egl.cpp | 7 +++++--\n>>  1 file changed, 5 insertions(+), 2 deletions(-)\n>> \n>> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n>> index 9ec966608..534e36050 100644\n>> --- a/src/libcamera/software_isp/debayer_egl.cpp\n>> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n>> @@ -393,8 +393,11 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,\n>>         window_.width = outputCfg.size.width;\n>>         window_.height = outputCfg.size.height;\n>>  \n>> -       /* Don't pass x,y since process() already adjusts src before passing it */\n>> -       stats_->setWindow(Rectangle(window_.size()));\n>> +       /*\n>> +        * Don't pass x,y since process() already adjusts src before passing it.\n>> +        * But reduce the width and height by 2/3 for speedup.\n>> +        */\n>> +       stats_->setWindow(Rectangle(window_.size()).croppedBy(2, 3));\n>\n> What does the comment about x,y mean now? what x,y adjustment is made?\n\nwindow_ can be a crop.  Its top left corner is not passed to\nstats_->setWindow() because the window_ corner is handled in process(),\nfor both the stats and debayering.  I'll try to make it clearer in v2\n(reminder to myself: the original comment should be improved in\ndebayer_cpu.cpp as well).\n\n> If croppedBy() is made to keep the initial x,y correctly - would this\n> the nmake the correct final window?\n\ncroppedBy() is applied here on a rectangle constructed from size only,\nwhich means the top left corner is (0, 0).\n\n>\n>\n>>  \n>>         LOG(Debayer, Debug) << \"Input width \" << inputCfg.size.width << \" height \" <<\n>> inputCfg.size.height;\n>>         LOG(Debayer, Debug) << \"Output width \" << outputCfg.size.width << \" height \" <<\n>> outputCfg.size.height;\n>> -- \n>> 2.50.1\n>>","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 52D10C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Jul 2025 19:30:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F3C2E69018;\n\tMon, 21 Jul 2025 21:30:30 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE4C268FB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 21:30:29 +0200 (CEST)","from mail-wm1-f71.google.com (mail-wm1-f71.google.com\n\t[209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-636-yxXZg1wKPdycsce0tGe5Bg-1; Mon, 21 Jul 2025 15:30:27 -0400","by mail-wm1-f71.google.com with SMTP id\n\t5b1f17b1804b1-4561bc2f477so28367645e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 12:30:26 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-3b61ca2bcc3sm11421885f8f.27.2025.07.21.12.30.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Jul 2025 12:30:24 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"E85kn7Ua\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1753126228;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=bKDPO5SGXiuFQ6lrK/dP2eonYq8ZLCzeJDScJlIsln0=;\n\tb=E85kn7Ua4HxdtHkrFOdawZfjDyQOGxmPbUVJFvhG56Jj1DmotBA3nNCCa243pHokUpSjje\n\toitRVkJE69V2zByoCeVkxuhoKdGf/HtMKEC9vFel4CpFCWzUtwgFNSknMWYMexoeBLkisj\n\t2wVqipKAFsSXdA4q0IyAUKtz+CvEmHE=","X-MC-Unique":"yxXZg1wKPdycsce0tGe5Bg-1","X-Mimecast-MFC-AGG-ID":"yxXZg1wKPdycsce0tGe5Bg_1753126226","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1753126226; x=1753731026;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=bKDPO5SGXiuFQ6lrK/dP2eonYq8ZLCzeJDScJlIsln0=;\n\tb=sLEtAQnFMxF23z7ulTulgzfSf3XrzR1UEiPyI6yOllyrdtLhwzDQIpmKVYdCSs6ODP\n\tnE+yEqfbNr07AchjilEgGD54EEg68aRZ5NvOA3dgbRZXqDEhgjtfLkwliwjMZ3KEcO8K\n\tuiUzM3R0aSzyXN9Cu/xE4H49yjUpTqIVyLNee9EjlBiCqgcwusRwB4URGunRa3WzF6wq\n\twHUGsUl2T0z3BTkPE8D0mB0t1Q2jRSut9N5wRwZv1/3GJHxoOa7bhDiLACUmxssF+N0M\n\tJ1VYU6Ng2BxrgciWh0oi6iAETfXShC8ZivmIYFN6/lGYzPRt59Am030EfpwtVxly9p8w\n\tSIgg==","X-Gm-Message-State":"AOJu0Ywqb+oYeBfmnYdKOGNmR3ZtSPYQ4rsFm3ypcYG73MsfxZ9+w1jM\n\tu9yEHc3eD1nNWX/DPlN2CbfW9hra1enJE4IfNVkEvYqRGe3LlOReSEJFCOYfFUfq1arBiutUKpm\n\tXTJ8vtNIlVYqtrEqL2kCDSZ30Eq9oSmAOvlOnbGqgt7Ma+qgqLgivGR03vORQZkzTe6UXyvjLmf\n\ts=","X-Gm-Gg":"ASbGncttorC+mIM8IgCa4/XtnHAppYCsqg9fqpQ8zyvPgzmiALXVyhQVXYdtN/pI/Hv\n\t2fz+2bk6/n/rREARBrrIDIH34IJlU8uM7mLQIpokXNZay+sCyvAPZeIB0yRK9vsaQBWrWYaRBXF\n\te0rQeezWiMzp9gT5CMBfpdrKh0HyynZFCEYncaoHv8yKghHEXzi9h14ckqq/P2b0PfTSpcGAvFx\n\tvdcmfAsBfZu8KZMCRdiB0Vr/dVU2q/YhevC1hN7+iuhQb0nrZA0P5uWySKWsuQCjlAycTWzZl4w\n\txHNDMcjMvHc/coO+9NG9tXfemIdxYjrOw49yPRgBdgs8wqAqz5dRhTOps66ZMUznW9cqVWMY689\n\tHNZ/otUsTWPOkbD2n","X-Received":["by 2002:a05:6000:2485:b0:3b5:e2c9:fa05 with SMTP id\n\tffacd0b85a97d-3b60e4d0290mr14773573f8f.18.1753126225790; \n\tMon, 21 Jul 2025 12:30:25 -0700 (PDT)","by 2002:a05:6000:2485:b0:3b5:e2c9:fa05 with SMTP id\n\tffacd0b85a97d-3b60e4d0290mr14773564f8f.18.1753126225397; \n\tMon, 21 Jul 2025 12:30:25 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IF4zm8hiKBpFPZs+h6Sex/iNXWCQ5tXr+BnUSAXbteFH/KnYWtRFZ2BazRNS7E9ott7NVEH0A==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Bryan O'Donoghue\n\t<bryan.odonoghue@linaro.org>","Subject":"Re: [PATCH 2/2] libcamera: software_isp: Reduce statistics image\n\tarea","In-Reply-To":"<175311851972.50296.3780425026702469847@ping.linuxembedded.co.uk>\n\t(Kieran Bingham's message of \"Mon, 21 Jul 2025 18:21:59 +0100\")","References":"<20250718144456.58625-1-mzamazal@redhat.com>\n\t<20250718144456.58625-2-mzamazal@redhat.com>\n\t<175311851972.50296.3780425026702469847@ping.linuxembedded.co.uk>","Date":"Mon, 21 Jul 2025 21:30:24 +0200","Message-ID":"<85jz41baun.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"ow1AbMTDrFa8SZI0kqVExXNRMbXoWuAL2KixrBqDUgY_1753126226","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]