{"id":21400,"url":"https://patchwork.libcamera.org/api/1.1/patches/21400/?format=json","web_url":"https://patchwork.libcamera.org/patch/21400/","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":"<20240927134624.801004-8-mzamazal@redhat.com>","date":"2024-09-27T13:46:13","name":"[v8,07/18] libcamera: software_isp: Track and pass frame ids","commit_ref":"f06c344bd5cfc3ae1492b73a82b1d4050bec06fc","pull_url":null,"state":"accepted","archived":false,"hash":"fd768115559d0dc200982570fd676b1659d5a1d5","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/21400/mbox/","series":[{"id":4634,"url":"https://patchwork.libcamera.org/api/1.1/series/4634/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4634","date":"2024-09-27T13:46:06","name":"Software ISP refactoring","version":8,"mbox":"https://patchwork.libcamera.org/series/4634/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21400/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21400/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 C3378C32D4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Sep 2024 13:46:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB47863526;\n\tFri, 27 Sep 2024 15:46:58 +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 8D9D563517\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Sep 2024 15:46:54 +0200 (CEST)","from mx-prod-mc-05.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-471-J9D1JbygP2Wic8U1iLOaNA-1;\n\tFri, 27 Sep 2024 09:46:50 -0400","from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (unknown\n\t[10.30.177.40])\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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 3CAEA18F368E; Fri, 27 Sep 2024 13:46:49 +0000 (UTC)","from nuthatch.redhat.com (unknown [10.45.224.123])\n\tby mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 43A311944E45; Fri, 27 Sep 2024 13:46:47 +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=\"hsLKm9ZD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1727444813;\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=bYGkC7lMOCVp4ehOsLzkQfuivEgkcbqA2NSlf1JBhyQ=;\n\tb=hsLKm9ZDNSxC2QlYOtBC+tuNI4oUk4PDysi7ICkDE1m4al5v6A2dscU6e7sAoGmMGPGfAJ\n\ttmnfqIhH+osUtgHc9Hyv5e6lVA3YS6ItWuom0REURDLgZR9YtnH1TFOi+1lGmle5Y6xr2N\n\tmkWUlLShbg2K65RsjNoCBBEj+h289GU=","X-MC-Unique":"J9D1JbygP2Wic8U1iLOaNA-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 v8 07/18] libcamera: software_isp: Track and pass frame ids","Date":"Fri, 27 Sep 2024 15:46:13 +0200","Message-ID":"<20240927134624.801004-8-mzamazal@redhat.com>","In-Reply-To":"<20240927134624.801004-1-mzamazal@redhat.com>","References":"<20240927134624.801004-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.40","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 .../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           | 12 +++++-------\n src/libcamera/software_isp/debayer_cpu.h             |  2 +-\n src/libcamera/software_isp/software_isp.cpp          | 10 ++++++----\n 7 files changed, 24 insertions(+), 17 deletions(-)","diff":"diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex 3602bce85..3a84418ed 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 5aa52789f..ff43814c6 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 db26c3809..f0b832619 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 c151fe5d3..d7ca060da 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 6cc6946c7..cf5ecdf7a 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -611,8 +611,7 @@ void DebayerCpu::memcpyNextLine(const uint8_t *linePointers[])\n \tmemcpy(lineBuffers_[lineBufferIndex_].data(),\n \t       linePointers[patternHeight] - lineBufferPadding_,\n \t       lineBufferLength_);\n-\tlinePointers[patternHeight] = lineBuffers_[lineBufferIndex_].data()\n-\t\t\t\t    + lineBufferPadding_;\n+\tlinePointers[patternHeight] = lineBuffers_[lineBufferIndex_].data() + lineBufferPadding_;\n \n \tlineBufferIndex_ = (lineBufferIndex_ + 1) % (patternHeight + 1);\n }\n@@ -748,7 +747,7 @@ inline int64_t timeDiff(timespec &after, timespec &before)\n \n } /* namespace */\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@@ -808,12 +807,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 8237a64be..2c47e7c6e 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 a38555684..a08b0c2ec 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":["v8","07/18"]}