{"id":14659,"url":"https://patchwork.libcamera.org/api/1.1/patches/14659/?format=json","web_url":"https://patchwork.libcamera.org/patch/14659/","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":"<20211119131506.382462-2-umang.jain@ideasonboard.com>","date":"2021-11-19T13:15:05","name":"[libcamera-devel,RFC,1/2] android: Document the structures and functions for post-processing","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"4a1bcb800686b21b7e329bbd2038f5028de5cb37","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14659/mbox/","series":[{"id":2736,"url":"https://patchwork.libcamera.org/api/1.1/series/2736/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2736","date":"2021-11-19T13:15:04","name":"Document post-processing","version":1,"mbox":"https://patchwork.libcamera.org/series/2736/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14659/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14659/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 80995BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Nov 2021 13:15:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 37F096038B;\n\tFri, 19 Nov 2021 14:15:24 +0100 (CET)","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 6B69460233\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Nov 2021 14:15:23 +0100 (CET)","from perceval.ideasonboard.com (unknown [103.238.109.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B14741959;\n\tFri, 19 Nov 2021 14:15:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"C5etcH7W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637327723;\n\tbh=58Z3SQwHRGnHnO2jwIudlDet8HwYzd65YgRqh3OmxYQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=C5etcH7W3bRlYOtynhwDxEzlldRKOPvJp2CalQHrY/JWmaSxKOEZJDY5vnr42IBNG\n\t5R9E2VvbSxBnmZ4zquFI6E9BGreDfnf8iXoXs0hAGYzFJrCQUfIcDojAJYpdIqwY4c\n\tW8xTKTp4nZs8TV/YZIKymDWbFSiGwLIP5KbVynWY=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 19 Nov 2021 18:45:05 +0530","Message-Id":"<20211119131506.382462-2-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20211119131506.382462-1-umang.jain@ideasonboard.com>","References":"<20211119131506.382462-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 1/2] android: Document the structures\n\tand functions for post-processing","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":"Specifically document:\n - CameraDevice::sendCaptureResults()\n - CameraDevice::completeDescriptor()\n - CameraDevice::streamProcessingComplete()\n\n - CameraStream::PostProcessorWorker class\n - Camera3RequestDescriptor::StreamBuffer structure\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/android/camera_device.cpp  | 35 +++++++++++++++++++++++++++++++\n src/android/camera_request.cpp | 38 ++++++++++++++++++++++++++++++++++\n src/android/camera_stream.cpp  | 12 +++++++++++\n 3 files changed, 85 insertions(+)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex f2e0bdbd..fb46be4d 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1147,6 +1147,16 @@ void CameraDevice::requestComplete(Request *request)\n \t}\n }\n \n+/**\n+ * \\brief Complete the Camera3RequestDescriptor\n+ * \\param[in] descriptor The Camera3RequestDescriptor deemed to be complete\n+ *\n+ * Marks the Camera3RequestDescriptor as 'complete'. This means all the streams\n+ * in the Camera3RequestDescriptor have completed capture (or generated via\n+ * post-processing) and is ready be sent back to the framework.\n+ *\n+ * \\context This function is \\threadsafe.\n+ */\n void CameraDevice::completeDescriptor(Camera3RequestDescriptor *descriptor)\n {\n \tMutexLocker lock(descriptorsMutex_);\n@@ -1155,6 +1165,17 @@ void CameraDevice::completeDescriptor(Camera3RequestDescriptor *descriptor)\n \tsendCaptureResults();\n }\n \n+/**\n+ * \\brief Sequentially send capture results to the framework\n+ *\n+ * Inspect the head of the descriptors' queue and see if it is ready to be sent\n+ * back to the framework. Populate a locally-scoped camera3_capture_result_t\n+ * using the fields of the descriptor and send the capture result back by\n+ * calling the process_capture_result() callback.\n+ *\n+ * This function should never be called directly in the codebase. Use\n+ * completeDescriptor() instead.\n+ */\n void CameraDevice::sendCaptureResults()\n {\n \twhile (!descriptors_.empty() && !descriptors_.front()->isPending()) {\n@@ -1214,6 +1235,20 @@ void CameraDevice::setBufferStatus(Camera3RequestDescriptor::StreamBuffer &strea\n \t}\n }\n \n+/**\n+ * \\brief Handle post-processing completion of a stream in a capture request\n+ * \\param[in] streamBuffer The StreamBuffer for which processing is complete\n+ * \\param[in] status Stream post-processing status\n+ *\n+ * This is invoked in the post-processor's thread whenever a camera stream has\n+ * finished post processing. The corresponding entry is dropped from the\n+ * descriptor's pendingStreamsToProcess_ map.\n+ *\n+ * If the pendingStreamsToProcess_ map is found to be empty, it is perceived\n+ * that all the streams requiring to be generated from post-processing have been\n+ * completed. Mark the descriptor as complete using completeDescriptor() in that\n+ * case.\n+ */\n void CameraDevice::streamProcessingComplete(Camera3RequestDescriptor::StreamBuffer *streamBuffer,\n \t\t\t\t\t    Camera3RequestDescriptor::Status status)\n {\ndiff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp\nindex 8162aa78..4e017792 100644\n--- a/src/android/camera_request.cpp\n+++ b/src/android/camera_request.cpp\n@@ -53,6 +53,44 @@ Camera3RequestDescriptor::Camera3RequestDescriptor(\n \n Camera3RequestDescriptor::~Camera3RequestDescriptor() = default;\n \n+/**\n+ * \\struct Camera3RequestDescriptor::StreamBuffer\n+ * \\brief Groups information for per-stream buffer of Camera3RequestDescriptor\n+ *\n+ * A capture request placed to the libcamera HAL can contain multiple streams.\n+ * Each stream will have an associated buffer to be filled. StreamBuffer struct\n+ * tracks this buffer with contextual information which aids in the stream's\n+ * generation. The generation of stream will depend on its type (refer\n+ * CameraStream::Type documentation).\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::stream\n+ * \\brief Corresponding pointer to CameraStream\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::camera3Buffer\n+ * \\brief Native handle to the buffer\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::frameBuffer\n+ * \\brief Encapsulate the dmabuf handle inside a libcamera::FrameBuffer for\n+ * direct streams\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::fence\n+ * \\brief Acquire fence of the buffer\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::status\n+ * \\brief Track the status of the buffer\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::internalBuffer\n+ * \\brief Pointer to a buffer internally handled by CameraStream (if any)\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::srcBuffer\n+ * \\brief Pointer to source frame buffer required for post-processing\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::dstBuffer\n+ * \\brief Pointer to destination frame buffer required for post-processing\n+ *\n+ * \\var Camera3RequestDescriptor::StreamBuffer::request\n+ * \\brief Back pointer to Camera3RequestDescriptor to which StreamBuffer belongs\n+ */\n Camera3RequestDescriptor::StreamBuffer::StreamBuffer(\n \tCameraStream *cameraStream, const camera3_stream_buffer_t &buffer,\n \tCamera3RequestDescriptor *requestDescriptor)\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 9023c13c..3cda58c9 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -231,6 +231,18 @@ void CameraStream::putBuffer(FrameBuffer *buffer)\n \tbuffers_.push_back(buffer);\n }\n \n+/**\n+ * \\class CameraStream::PostProcessorWorker\n+ * \\brief Post process a CameraStream on an internal thread\n+ *\n+ * If the association between CameraStream and camera3_stream_t dictated by\n+ * CameraStream::Type is internal or mapped, the stream is generated by post\n+ * processing of a libcamera stream. Such a request is queued to\n+ * PostProcessorWorker in CameraStream::process(). A queue of post-processing\n+ * requests is maintained by the PostProcessorWorker and it will run the\n+ * post-processing on an internal thread as soon as any request is available on\n+ * its queue.\n+ */\n CameraStream::PostProcessorWorker::PostProcessorWorker(PostProcessor *postProcessor)\n \t: postProcessor_(postProcessor)\n {\n","prefixes":["libcamera-devel","RFC","1/2"]}