{"id":21312,"url":"https://patchwork.libcamera.org/api/1.1/patches/21312/?format=json","web_url":"https://patchwork.libcamera.org/patch/21312/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240920183143.1674117-8-mzamazal@redhat.com>","date":"2024-09-20T18:31:32","name":"[v7,07/18] libcamera: software_isp: Track and pass frame ids","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9b5f81e0845fe29738e18b8c653c2f31ca1f43bf","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/1.1/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21312/mbox/","series":[{"id":4610,"url":"https://patchwork.libcamera.org/api/1.1/series/4610/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4610","date":"2024-09-20T18:31:25","name":"Software ISP refactoring","version":7,"mbox":"https://patchwork.libcamera.org/series/4610/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21312/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21312/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 3BB72C3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Sep 2024 18:32:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9756A63508;\n\tFri, 20 Sep 2024 20:32:28 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 19F3763503\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Sep 2024 20:32:26 +0200 (CEST)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-663-tY5Q8XPkNqavX7su5zUdog-1;\n\tFri, 20 Sep 2024 14:32:21 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown\n\t[10.30.177.17])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 6C39C1918DDD; Fri, 20 Sep 2024 18:32:20 +0000 (UTC)","from nuthatch.redhat.com (unknown [10.45.224.12])\n\tby mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 83B1F1956052; Fri, 20 Sep 2024 18:32:18 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"gws0Aki3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1726857144;\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\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Co5CX4SGAT2boDC+MDekG6eOdsMeWgfK7QFloIJQtNA=;\n\tb=gws0Aki3ul9SRcj088F9A9F4aX1uUh7qN/dVdo/5v82e5P1cnhNwJuUG0S/Gat1bgvtCGA\n\tGDnBjDiFcftDJOZbyVXi9EkKbS5AyVs0YDp3H8vWa1BUbFpTG+sO7K66G+1loH0LxvtVXA\n\tuqtFoG4wG+jLJiKseRBQVAmXZXsA3Bg=","X-MC-Unique":"tY5Q8XPkNqavX7su5zUdog-1","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH v7 07/18] libcamera: software_isp: Track and pass frame ids","Date":"Fri, 20 Sep 2024 20:31:32 +0200","Message-ID":"<20240920183143.1674117-8-mzamazal@redhat.com>","In-Reply-To":"<20240920183143.1674117-1-mzamazal@redhat.com>","References":"<20240920183143.1674117-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","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>"},"content":"A previous preparation patch implemented passing frame ids to stats\nprocessing but without actual meaningful frame id value passed there.\nThis patch extends that by actually providing the frame id and passing\nit through to the stats processor.\n\nThe frame id is taken from the request sequence number, the same as in\nhardware pipelines.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/software_isp/software_isp.h |  4 ++--\n src/libcamera/pipeline/simple/simple.cpp               |  8 +++++++-\n src/libcamera/software_isp/debayer.cpp                 |  3 ++-\n src/libcamera/software_isp/debayer.h                   |  2 +-\n src/libcamera/software_isp/debayer_cpu.cpp             |  9 ++++-----\n src/libcamera/software_isp/debayer_cpu.h               |  2 +-\n src/libcamera/software_isp/software_isp.cpp            | 10 ++++++----\n 7 files changed, 23 insertions(+), 15 deletions(-)","diff":"diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex 3602bce8..3a84418e 100644\n--- a/include/libcamera/internal/software_isp/software_isp.h\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -73,10 +73,10 @@ public:\n \tint start();\n \tvoid stop();\n \n-\tint queueBuffers(FrameBuffer *input,\n+\tint queueBuffers(uint32_t frame, FrameBuffer *input,\n \t\t\t const std::map<const Stream *, FrameBuffer *> &outputs);\n \n-\tvoid process(FrameBuffer *input, FrameBuffer *output);\n+\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output);\n \n \tSignal<FrameBuffer *> inputBufferReady;\n \tSignal<FrameBuffer *> outputBufferReady;\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 5aa52789..ff43814c 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -861,7 +861,13 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\tif (converter_)\n \t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n \t\telse\n-\t\t\tswIsp_->queueBuffers(buffer, conversionQueue_.front());\n+\t\t\t/*\n+\t\t\t * request->sequence() cannot be retrieved from `buffer' inside\n+\t\t\t * queueBuffers because unique_ptr's make buffer->request() invalid\n+\t\t\t * already here.\n+\t\t\t */\n+\t\t\tswIsp_->queueBuffers(request->sequence(), buffer,\n+\t\t\t\t\t     conversionQueue_.front());\n \n \t\tconversionQueue_.pop();\n \t\treturn;\ndiff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex db26c380..f0b83261 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -94,8 +94,9 @@ Debayer::~Debayer()\n  */\n \n /**\n- * \\fn void Debayer::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+ * \\fn void Debayer::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n  * \\brief Process the bayer data into the requested format\n+ * \\param[in] frame The frame number\n  * \\param[in] input The input buffer\n  * \\param[in] output The output buffer\n  * \\param[in] params The parameters to be used in debayering\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex c151fe5d..d7ca060d 100644\n--- a/src/libcamera/software_isp/debayer.h\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -40,7 +40,7 @@ public:\n \tvirtual std::tuple<unsigned int, unsigned int>\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n \n-\tvirtual void process(FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n+\tvirtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n \n \tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n \ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 2a2e7edb..f7b3a7d1 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -724,7 +724,7 @@ static inline int64_t timeDiff(timespec &after, timespec &before)\n \t       (int64_t)after.tv_nsec - (int64_t)before.tv_nsec;\n }\n \n-void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n {\n \ttimespec frameStartTime;\n \n@@ -778,12 +778,11 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \t}\n \n \t/*\n-\t * Frame and buffer ids are currently not used, so pass zeros as parameters.\n+\t * Buffer ids are currently not used, so pass zeros as its parameter.\n \t *\n-\t * \\todo Pass real values once frame is passed here and stats buffer passing\n-\t * is changed.\n+\t * \\todo Pass real bufferId once stats buffer passing is changed.\n \t */\n-\tstats_->finishFrame(0, 0);\n+\tstats_->finishFrame(frame, 0);\n \toutputBufferReady.emit(output);\n \tinputBufferReady.emit(input);\n }\ndiff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\nindex 8237a64b..2c47e7c6 100644\n--- a/src/libcamera/software_isp/debayer_cpu.h\n+++ b/src/libcamera/software_isp/debayer_cpu.h\n@@ -36,7 +36,7 @@ public:\n \tstd::vector<PixelFormat> formats(PixelFormat input);\n \tstd::tuple<unsigned int, unsigned int>\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n-\tvoid process(FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n+\tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n \tSizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n \n \t/**\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex a3855568..a08b0c2e 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -278,12 +278,13 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count,\n \n /**\n  * \\brief Queue buffers to Software ISP\n+ * \\param[in] frame The frame number\n  * \\param[in] input The input framebuffer\n  * \\param[in] outputs The container holding the output stream pointers and\n  * their respective frame buffer outputs\n  * \\return 0 on success, a negative errno on failure\n  */\n-int SoftwareIsp::queueBuffers(FrameBuffer *input,\n+int SoftwareIsp::queueBuffers(uint32_t frame, FrameBuffer *input,\n \t\t\t      const std::map<const Stream *, FrameBuffer *> &outputs)\n {\n \t/*\n@@ -301,7 +302,7 @@ int SoftwareIsp::queueBuffers(FrameBuffer *input,\n \t}\n \n \tfor (auto iter = outputs.begin(); iter != outputs.end(); iter++)\n-\t\tprocess(input, iter->second);\n+\t\tprocess(frame, input, iter->second);\n \n \treturn 0;\n }\n@@ -333,13 +334,14 @@ void SoftwareIsp::stop()\n \n /**\n  * \\brief Passes the input framebuffer to the ISP worker to process\n+ * \\param[in] frame The frame number\n  * \\param[in] input The input framebuffer\n  * \\param[out] output The framebuffer to write the processed frame to\n  */\n-void SoftwareIsp::process(FrameBuffer *input, FrameBuffer *output)\n+void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output)\n {\n \tdebayer_->invokeMethod(&DebayerCpu::process,\n-\t\t\t       ConnectionTypeQueued, input, output, debayerParams_);\n+\t\t\t       ConnectionTypeQueued, frame, input, output, debayerParams_);\n }\n \n void SoftwareIsp::saveIspParams()\n","prefixes":["v7","07/18"]}