Show a patch.

GET /api/1.1/patches/14078/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14078,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14078/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14078/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20211011073505.243864-4-umang.jain@ideasonboard.com>",
    "date": "2021-10-11T07:35:01",
    "name": "[libcamera-devel,v4,3/7] android: Notify post processing completion via a signal",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "71537e7ca3a7483290c2e00e7f300872ba53b3ae",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": {
        "id": 12,
        "url": "https://patchwork.libcamera.org/api/1.1/users/12/?format=api",
        "username": "uajain",
        "first_name": "Umang",
        "last_name": "Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/14078/mbox/",
    "series": [
        {
            "id": 2611,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2611/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2611",
            "date": "2021-10-11T07:34:58",
            "name": "Async Post Processor",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2611/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14078/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14078/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 49528C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 07:35:24 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EF0C268F4B;\n\tMon, 11 Oct 2021 09:35:23 +0200 (CEST)",
            "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 AE29768F4C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 09:35:20 +0200 (CEST)",
            "from perceval.ideasonboard.com (unknown [103.251.226.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BC89F2BD;\n\tMon, 11 Oct 2021 09:35:19 +0200 (CEST)"
        ],
        "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=\"JJeY/8Wj\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633937720;\n\tbh=szDzWhpBohFMSPaAZGIz5VZlhTECiBT02bR/vRCPvpM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JJeY/8WjfYiwnDhOtXWXRM5WNTOuPOhbVURHtecnoISctYEnglzDIXkcSEaDk9HjK\n\td6jCE19AXGT9UUsshUhA3s8NjI3c5jC5l6FSERQkieOap+By9/TFO6R7rN7meOaBWf\n\tO4w0ebU/1dI1ehQboCN1QftJpX0iLUZ5XRY0gJxw=",
        "From": "Umang Jain <umang.jain@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 11 Oct 2021 13:05:01 +0530",
        "Message-Id": "<20211011073505.243864-4-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20211011073505.243864-1-umang.jain@ideasonboard.com>",
        "References": "<20211011073505.243864-1-umang.jain@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 3/7] android: Notify post processing\n\tcompletion via a signal",
        "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": "Notify that the post processing for a request has been completed,\nvia a signal. A pointer to the descriptor which is tracking the\ncapture request is emitted along with the status of post processing.\nThe function CameraDevice::streamProcessingComplete() will finally set\nthe status on the descriptor by reading the status of the post-processor\ncompletion (passed as an argument to the signal) and call\nsendCaptureResults().\n\nWe also need to save a pointer to any internal buffers that might have\nbeen allocated by CameraStream. The buffer should be returned back to\nCameraStream just before capture results are sent.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/android/camera_device.cpp            | 49 +++++++++++++++++-------\n src/android/camera_device.h              |  5 +++\n src/android/camera_stream.cpp            |  5 +++\n src/android/jpeg/post_processor_jpeg.cpp |  2 +\n src/android/post_processor.h             |  9 +++++\n src/android/yuv/post_processor_yuv.cpp   | 12 +++++-\n 6 files changed, 67 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex b52bdc8f..9f26c36d 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -8,7 +8,6 @@\n #include \"camera_device.h\"\n #include \"camera_hal_config.h\"\n #include \"camera_ops.h\"\n-#include \"post_processor.h\"\n \n #include <algorithm>\n #include <fstream>\n@@ -1226,20 +1225,12 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tint ret = cameraStream->process(*src, buffer, descriptor);\n-\n-\t\t/*\n-\t\t * Return the FrameBuffer to the CameraStream now that we're\n-\t\t * done processing it.\n-\t\t */\n \t\tif (cameraStream->type() == CameraStream::Type::Internal)\n-\t\t\tcameraStream->putBuffer(src);\n+\t\t\tdescriptor->internalBuffer_ = src;\n \n-\t\tif (ret) {\n-\t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n-\t\t\tnotifyError(descriptor->frameNumber_, buffer.stream,\n-\t\t\t\t    CAMERA3_MSG_ERROR_BUFFER);\n-\t\t}\n+\t\tint ret = cameraStream->process(*src, buffer, descriptor);\n+\n+\t\treturn;\n \t}\n \n \tcaptureResult.result = descriptor->resultMetadata_->get();\n@@ -1266,6 +1257,38 @@ void CameraDevice::sendCaptureResults()\n \t}\n }\n \n+void CameraDevice::streamProcessingComplete(CameraStream *cameraStream,\n+\t\t\t\t\t    Camera3RequestDescriptor *request,\n+\t\t\t\t\t    PostProcessor::Status status)\n+{\n+\tif (status == PostProcessor::Status::Error) {\n+\t\tfor (camera3_stream_buffer_t &buffer : request->buffers_) {\n+\t\t\tCameraStream *cs = static_cast<CameraStream *>(buffer.stream->priv);\n+\n+\t\t\tif (cs->type() == CameraStream::Type::Direct)\n+\t\t\t\tcontinue;\n+\n+\t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n+\t\t\tnotifyError(request->frameNumber_, buffer.stream,\n+\t\t\t\t    CAMERA3_MSG_ERROR_BUFFER);\n+\t\t}\n+\t}\n+\n+\t/*\n+\t * Return the FrameBuffer to the CameraStream now that we're\n+\t * done processing it.\n+\t */\n+\tif (cameraStream->type() == CameraStream::Type::Internal)\n+\t\tcameraStream->putBuffer(request->internalBuffer_);\n+\n+\tif (status == PostProcessor::Status::Success)\n+\t\trequest->status_ = Camera3RequestDescriptor::Status::Success;\n+\telse\n+\t\trequest->status_ = Camera3RequestDescriptor::Status::Error;\n+\n+\tsendCaptureResults();\n+}\n+\n std::string CameraDevice::logPrefix() const\n {\n \treturn \"'\" + camera_->id() + \"'\";\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 3da8dffa..eee97516 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -32,6 +32,7 @@\n #include \"camera_stream.h\"\n #include \"camera_worker.h\"\n #include \"jpeg/encoder.h\"\n+#include \"post_processor.h\"\n \n struct CameraConfigData;\n \n@@ -56,6 +57,7 @@ struct Camera3RequestDescriptor {\n \tCameraMetadata settings_;\n \tstd::unique_ptr<CaptureRequest> request_;\n \tstd::unique_ptr<CameraMetadata> resultMetadata_;\n+\tlibcamera::FrameBuffer *internalBuffer_;\n \n \tcamera3_capture_result_t captureResult_ = {};\n \tStatus status_ = Status::Pending;\n@@ -91,6 +93,9 @@ public:\n \tint configureStreams(camera3_stream_configuration_t *stream_list);\n \tint processCaptureRequest(camera3_capture_request_t *request);\n \tvoid requestComplete(libcamera::Request *request);\n+\tvoid streamProcessingComplete(CameraStream *cameraStream,\n+\t\t\t\t      Camera3RequestDescriptor *request,\n+\t\t\t\t      PostProcessor::Status status);\n \n protected:\n \tstd::string logPrefix() const override;\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 8f47e4d8..d91e7dee 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -93,6 +93,11 @@ int CameraStream::configure()\n \t\tint ret = postProcessor_->configure(configuration(), output);\n \t\tif (ret)\n \t\t\treturn ret;\n+\n+\t\tpostProcessor_->processComplete.connect(\n+\t\t\tthis, [&](Camera3RequestDescriptor *request, PostProcessor::Status status) {\n+\t\t\t\tcameraDevice_->streamProcessingComplete(this, request, status);\n+\t\t\t});\n \t}\n \n \tif (type_ == Type::Internal) {\ndiff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp\nindex 656c48b2..81d1efe6 100644\n--- a/src/android/jpeg/post_processor_jpeg.cpp\n+++ b/src/android/jpeg/post_processor_jpeg.cpp\n@@ -197,6 +197,7 @@ int PostProcessorJpeg::process(const FrameBuffer &source,\n \t\t\t\t\t exif.data(), quality);\n \tif (jpeg_size < 0) {\n \t\tLOG(JPEG, Error) << \"Failed to encode stream image\";\n+\t\tprocessComplete.emit(request, PostProcessor::Status::Error);\n \t\treturn jpeg_size;\n \t}\n \n@@ -210,6 +211,7 @@ int PostProcessorJpeg::process(const FrameBuffer &source,\n \n \t/* Update the JPEG result Metadata. */\n \tresultMetadata->addEntry(ANDROID_JPEG_SIZE, jpeg_size);\n+\tprocessComplete.emit(request, PostProcessor::Status::Success);\n \n \treturn 0;\n }\ndiff --git a/src/android/post_processor.h b/src/android/post_processor.h\nindex fa13c7e0..6e67bcba 100644\n--- a/src/android/post_processor.h\n+++ b/src/android/post_processor.h\n@@ -7,6 +7,8 @@\n #ifndef __ANDROID_POST_PROCESSOR_H__\n #define __ANDROID_POST_PROCESSOR_H__\n \n+#include <libcamera/base/signal.h>\n+\n #include <libcamera/framebuffer.h>\n #include <libcamera/stream.h>\n \n@@ -19,6 +21,11 @@ struct Camera3RequestDescriptor;\n class PostProcessor\n {\n public:\n+\tenum class Status {\n+\t\tError,\n+\t\tSuccess\n+\t};\n+\n \tvirtual ~PostProcessor() = default;\n \n \tvirtual int configure(const libcamera::StreamConfiguration &inCfg,\n@@ -26,6 +33,8 @@ public:\n \tvirtual int process(const libcamera::FrameBuffer &source,\n \t\t\t    CameraBuffer *destination,\n \t\t\t    Camera3RequestDescriptor *request) = 0;\n+\n+\tlibcamera::Signal<Camera3RequestDescriptor *, Status> processComplete;\n };\n \n #endif /* __ANDROID_POST_PROCESSOR_H__ */\ndiff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp\nindex 8110a1f1..b34b389d 100644\n--- a/src/android/yuv/post_processor_yuv.cpp\n+++ b/src/android/yuv/post_processor_yuv.cpp\n@@ -18,6 +18,8 @@\n #include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"../camera_device.h\"\n+\n using namespace libcamera;\n \n LOG_DEFINE_CATEGORY(YUV)\n@@ -51,14 +53,17 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,\n \n int PostProcessorYuv::process(const FrameBuffer &source,\n \t\t\t      CameraBuffer *destination,\n-\t\t\t      [[maybe_unused]] Camera3RequestDescriptor *request)\n+\t\t\t      Camera3RequestDescriptor *request)\n {\n-\tif (!isValidBuffers(source, *destination))\n+\tif (!isValidBuffers(source, *destination)) {\n+\t\tprocessComplete.emit(request, PostProcessor::Status::Error);\n \t\treturn -EINVAL;\n+\t}\n \n \tconst MappedFrameBuffer sourceMapped(&source, MappedFrameBuffer::MapFlag::Read);\n \tif (!sourceMapped.isValid()) {\n \t\tLOG(YUV, Error) << \"Failed to mmap camera frame buffer\";\n+\t\tprocessComplete.emit(request, PostProcessor::Status::Error);\n \t\treturn -EINVAL;\n \t}\n \n@@ -76,9 +81,12 @@ int PostProcessorYuv::process(const FrameBuffer &source,\n \t\t\t\t    libyuv::FilterMode::kFilterBilinear);\n \tif (ret) {\n \t\tLOG(YUV, Error) << \"Failed NV12 scaling: \" << ret;\n+\t\tprocessComplete.emit(request, PostProcessor::Status::Error);\n \t\treturn -EINVAL;\n \t}\n \n+\tprocessComplete.emit(request, PostProcessor::Status::Success);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "3/7"
    ]
}