[{"id":21108,"web_url":"https://patchwork.libcamera.org/comment/21108/","msgid":"<YZw7VOGEjQ4evJ9M@pendragon.ideasonboard.com>","date":"2021-11-23T00:52:36","subject":"Re: [libcamera-devel] [RFC PATCH 1/2] android: Document the\n\tstructures and functions for post-processing","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch, it's really useful.\n\nOn Fri, Nov 19, 2021 at 06:45:05PM +0530, Umang Jain wrote:\n> Specifically document:\n>  - CameraDevice::sendCaptureResults()\n>  - CameraDevice::completeDescriptor()\n>  - CameraDevice::streamProcessingComplete()\n> \n>  - CameraStream::PostProcessorWorker class\n>  - Camera3RequestDescriptor::StreamBuffer structure\n> \n> Signed-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(+)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 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\ns/deemed to be complete/that has completed/\n\n> + *\n> + * Marks the Camera3RequestDescriptor as 'complete'. This means all the streams\n\ns/Marks/This function marks/\ns/This means/It shall be called when/\n\n> + * in the Camera3RequestDescriptor have completed capture (or generated via\n\ns/generated/have been generated/\n\n> + * post-processing) and is ready be sent back to the framework.\n\ns/is ready/the request is ready/\n\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\nI'd be more explicit about the fact that the function loops over the\nqueue:\n\n * Iterate over the descriptors queue to send completed descriptors back to the\n * framework, in the same order as they have been queued. For each complete\n * descriptor, populate a locally-scoped camera3_capture_result_t from the\n * descriptor, send the capture result back by calling the\n * process_capture_result() callback, and remove the descriptor from the queue.\n * Stop iterating if the descriptor at the front of the queue is not complete.\n\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\ns/This/This function/\n\ns/invoked in/called from/ ?\n\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\ns/is found to be empty/is then/\ns/it is perceived that //\n\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>  {\n> diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp\n> index 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\ns/Groups/Group/\n\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\ns/StreamBuffer struct/The StreamBuffer structure/\n\nor\n\ns/StreamBuffer struct/StreamBuffer/\n\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\ns/of stream/of the stream/\ns/refer/refer to the/\n\n> + * CameraStream::Type documentation).\n> + *\n> + * \\var Camera3RequestDescriptor::StreamBuffer::stream\n> + * \\brief Corresponding pointer to CameraStream\n\n * \\brief Pointer to the corresponding CameraStream\n\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\ns/source/the source/\ns/required for/used for/\n\n> + *\n> + * \\var Camera3RequestDescriptor::StreamBuffer::dstBuffer\n> + * \\brief Pointer to destination frame buffer required for post-processing\n\ns/destination/the destination/\ns/required for/used for/\n\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)\n> diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\n> index 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\ns/Post process/Post-process/\ns/on an/in an/\n\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\ns/queued to/queued to a/\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\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>  {","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 5FFEBBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Nov 2021 00:53:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6704D6038B;\n\tTue, 23 Nov 2021 01:53:01 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A68460227\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 01:53:00 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F765A1B;\n\tTue, 23 Nov 2021 01:52:59 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"hVf2TOC/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637628779;\n\tbh=LfxdUlU3OzAhy8EtJPCzJ30tQAXmctrhW7ee3E9Fs8Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hVf2TOC/RpVaGuxjo/Cc+48KsrkQh/kK8/whc0KHc2furhtxwVwm17rtNRGTuP536\n\tn7p1ohGPfxLzQs1U01AlRZt1BpR0nRtql60KLn4HDOrlbRSnkFlJCtNhXIKE6OYQe7\n\t5i8i4FB7/slO+y4zS0N2tEnPkh0KZ2gbshWTxB9o=","Date":"Tue, 23 Nov 2021 02:52:36 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YZw7VOGEjQ4evJ9M@pendragon.ideasonboard.com>","References":"<20211119131506.382462-1-umang.jain@ideasonboard.com>\n\t<20211119131506.382462-2-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211119131506.382462-2-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH 1/2] android: Document the\n\tstructures and 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]