[{"id":38961,"web_url":"https://patchwork.libcamera.org/comment/38961/","msgid":"<177987438981.3957074.9091739799109029763@ping.linuxembedded.co.uk>","date":"2026-05-27T09:33:09","subject":"Re: [PATCH v5 4/5] libcamera: swstats_cpu: Take MappedFrameBuffer in\n\tprocessFrame()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Robert Mader (2026-05-27 09:15:33)\n> As the only current user - DebayerEGL::process() - already has the buffer\n> mapped. Currently this shouldn't impact performance as the kernel should\n> already avoid remapping the dmabuf - i.e. we implicitly benefit from the\n> fact that the mentioned function holds its mapping during the runtime of\n> processFrame(). In a following commit DebayerEGL::process() will change\n> in a way that would make keeping the mapping counter-intuitive. Thus\n> this change ensures we'll not accidentally start mapping the buffer\n> twice per frame.\n> \n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n> ---\n>  include/libcamera/internal/software_isp/swstats_cpu.h |  2 +-\n>  src/libcamera/software_isp/debayer_egl.cpp            |  2 +-\n>  src/libcamera/software_isp/swstats_cpu.cpp            | 11 ++---------\n>  3 files changed, 4 insertions(+), 11 deletions(-)\n> \n> diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h\n> index b5348c6fe..686e3d981 100644\n> --- a/include/libcamera/internal/software_isp/swstats_cpu.h\n> +++ b/include/libcamera/internal/software_isp/swstats_cpu.h\n> @@ -56,7 +56,7 @@ public:\n>         void setWindow(const Rectangle &window);\n>         void startFrame(uint32_t frame);\n>         void finishFrame(uint32_t frame, uint32_t bufferId);\n> -       void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input);\n> +       void processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input);\n>  \n>         void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0)\n>         {\n> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp\n> index 696498a58..d08634640 100644\n> --- a/src/libcamera/software_isp/debayer_egl.cpp\n> +++ b/src/libcamera/software_isp/debayer_egl.cpp\n> @@ -555,7 +555,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>         metadata.planes()[0].bytesused = output->planes()[0].length;\n>  \n>         /* Calculate stats for the whole frame */\n> -       stats_->processFrame(frame, 0, input);\n> +       stats_->processFrame(frame, 0, in);\n>         dmaSyncers.clear();\n>  \n>         egl_.syncOutput();\n> diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\n> index 0815ec9a3..fb7a5301d 100644\n> --- a/src/libcamera/software_isp/swstats_cpu.cpp\n> +++ b/src/libcamera/software_isp/swstats_cpu.cpp\n> @@ -543,7 +543,7 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in)\n>   *\n>   * This may only be called after a successful setWindow() call.\n>   */\n> -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input)\n> +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer &input)\n>  {\n>         if (frame % kStatPerNumFrames) {\n>                 finishFrame(frame, bufferId);\n> @@ -552,14 +552,7 @@ void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *in\n>  \n>         bench_.startFrame();\n>         startFrame(frame);\n> -\n> -       MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read);\n> -       if (!in.isValid()) {\n> -               LOG(SwStatsCpu, Error) << \"mmap-ing buffer(s) failed\";\n> -               return;\n> -       }\n> -\n> -       (this->*processFrame_)(in);\n> +       (this->*processFrame_)(input);\n>         finishFrame(frame, bufferId);\n>         bench_.finishFrame();\n>  }\n> -- \n> 2.54.0\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 68D22BDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 May 2026 09:33:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DA5B63024;\n\tWed, 27 May 2026 11:33:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7630B62E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 May 2026 11:33:12 +0200 (CEST)","from monstersaurus.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 9461C55;\n\tWed, 27 May 2026 11:32:53 +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=\"QKSQtL7H\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1779874373;\n\tbh=iBKuP3MmGbPC3iJjJej1XxYPoccLQz9W0sgl9CAfl5w=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QKSQtL7HgKMDANOvqzldVKooFczQbX2wnQyLvrY7toheHYRAsUR/ni5KFV0kQ5uP9\n\t9PD5rbmSRJEgjapQdnc9EPgK46A2vJffhCtvq7TIKoHg+j+2U+qI5pIBAKLto/J0uC\n\tNCF/nhzCZnqi3peaUZ6tWFqymIu8WdqOCimbEM34=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260527081534.20245-5-robert.mader@collabora.com>","References":"<20260527081534.20245-1-robert.mader@collabora.com>\n\t<20260527081534.20245-5-robert.mader@collabora.com>","Subject":"Re: [PATCH v5 4/5] libcamera: swstats_cpu: Take MappedFrameBuffer in\n\tprocessFrame()","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Robert Mader <robert.mader@collabora.com>","To":"Robert Mader <robert.mader@collabora.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 27 May 2026 10:33:09 +0100","Message-ID":"<177987438981.3957074.9091739799109029763@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>"}}]