Show a patch.

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

{
    "id": 15341,
    "url": "https://patchwork.libcamera.org/api/patches/15341/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15341/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20220207151214.887140-2-naush@raspberrypi.com>",
    "date": "2022-02-07T15:12:13",
    "name": "[libcamera-devel,2/3] pipeline: raspberrypi: Simplify image/embedded buffer matching logic",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f96c48fca55dea3486f303419f4222554ebd1537",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15341/mbox/",
    "series": [
        {
            "id": 2921,
            "url": "https://patchwork.libcamera.org/api/series/2921/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2921",
            "date": "2022-02-07T15:12:12",
            "name": "[libcamera-devel,1/3] pipeline: raspberrypi: Allow Stream::returnBuffer() to handle internal buffers",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2921/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15341/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15341/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 E6B6BBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Feb 2022 15:12:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2E9FE61085;\n\tMon,  7 Feb 2022 16:12:21 +0100 (CET)",
            "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ADD396105F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Feb 2022 16:12:19 +0100 (CET)",
            "by mail-wm1-x32c.google.com with SMTP id v129so6564154wme.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Feb 2022 07:12:19 -0800 (PST)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:4a96:1adf:459f:8a7e])\n\tby smtp.gmail.com with ESMTPSA id\n\ti19sm21463085wmq.45.2022.02.07.07.12.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 07 Feb 2022 07:12:18 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"TLJtr/GO\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Ldwwezxd1MbR/3Abq8SKMJrIDtvxWlFxRAk2j3Obmr4=;\n\tb=TLJtr/GOsncYL+3DHUixneHDa+yRxH+lFEEPKM2KZTsGCrYojXjWd8HRn7ev6cETCs\n\t5EaUBpuAowSUDW+W16NsvDM4Oh8GZSlFC+NL9RKObhJx1cdyCOe9DmGnDWNp4BuFhlNx\n\tCO9AjymvPEA0Z3CRy6p75DMjla6GueqOZ/i6jwqmsVjlolI/P4iXaqm4tNqhJUtGT5xY\n\t8uurklDTxYUFoZFXTVAxcskCDNpwMFkE5HrgzHZdYgyKeG/Cunk95JpY9kyvoBVneNJQ\n\tOSXCnvpvK4XsX8WkEKK0/ug6ctMU0h0+ApDoO6RV093pVD6sgsv9+NN+BHK0aFSdbgZE\n\t6ocA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Ldwwezxd1MbR/3Abq8SKMJrIDtvxWlFxRAk2j3Obmr4=;\n\tb=foARRTQX2iKMVZRZ5dZRX93Aw4Fa/b4+4gmz7AG5iNnKfjJw6Dh7tZdp6B1gIhoMAn\n\tvVQxpyd2IN72Xoa/FT/DBNIoi5VP9VjAFj2SwN3u7qO1EsxTswtUC0b7jF3gCpSfU62g\n\tGjj6tXl3AzOSRCqIG8DYO9oDKplWGRchglrLVlZk2SeQUxo/5csuP5prb2e6r+uEH3D+\n\ts9os73oQLqhOae25ZxctgedhG3Xc7R6d6UqsivaBLMZ/yKe4xILBgM9IEfcsQmqOwIfT\n\t4oa2ytaELOXaBPrqqXKhNmEibeK4aIhZOTWBvYYcEYu6sCqRSc++CmSVlKX+Wxst6Omo\n\tskuQ==",
        "X-Gm-Message-State": "AOAM530UpUAGAmISMIr2ckh6psZXJHS93pVa3ZDM7XmdhOZWiTEdllLt\n\tBsaPyYR1iw9duaF66AaAQgJNhcLGmuWrkQ==",
        "X-Google-Smtp-Source": "ABdhPJxwzU1Rt+onGgYtFfEc0U2r3zU28SDPnIclztj4VeVnglwXrF4fApsog5sFcVOtpWGdIyOtdw==",
        "X-Received": "by 2002:a1c:f312:: with SMTP id\n\tq18mr11788533wmq.13.1644246739142; \n\tMon, 07 Feb 2022 07:12:19 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  7 Feb 2022 15:12:13 +0000",
        "Message-Id": "<20220207151214.887140-2-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220207151214.887140-1-naush@raspberrypi.com>",
        "References": "<20220207151214.887140-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/3] pipeline: raspberrypi: Simplify\n\timage/embedded buffer matching logic",
        "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": "Simplify the image and embedded buffer matching logic by removing the assumption\nthat we require a buffer match between the two streams. Instead, if an image\nbuffer does not match with an embedded data buffer, simply use the ControlList\nprovided by DelayedControls for the sensor parameters.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 141 ++++--------------\n 1 file changed, 31 insertions(+), 110 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 0755de84c70c..af234bd18c5b 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -2081,122 +2081,43 @@ void RPiCameraData::tryRunPipeline()\n \n bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&embeddedBuffer)\n {\n-\tunsigned int embeddedRequeueCount = 0, bayerRequeueCount = 0;\n-\n-\t/* Loop until we find a matching bayer and embedded data buffer. */\n-\twhile (!bayerQueue_.empty()) {\n-\t\t/* Start with the front of the bayer queue. */\n-\t\tFrameBuffer *bayerBuffer = bayerQueue_.front().buffer;\n-\n-\t\t/*\n-\t\t * Find the embedded data buffer with a matching timestamp to pass to\n-\t\t * the IPA. Any embedded buffers with a timestamp lower than the\n-\t\t * current bayer buffer will be removed and re-queued to the driver.\n-\t\t */\n-\t\tuint64_t ts = bayerBuffer->metadata().timestamp;\n-\t\tembeddedBuffer = nullptr;\n-\t\twhile (!embeddedQueue_.empty()) {\n-\t\t\tFrameBuffer *b = embeddedQueue_.front();\n-\t\t\tif (!unicam_[Unicam::Embedded].isExternal() && b->metadata().timestamp < ts) {\n-\t\t\t\tembeddedQueue_.pop();\n-\t\t\t\tunicam_[Unicam::Embedded].returnBuffer(b);\n-\t\t\t\tembeddedRequeueCount++;\n-\t\t\t\tLOG(RPI, Warning) << \"Dropping unmatched input frame in stream \"\n-\t\t\t\t\t\t  << unicam_[Unicam::Embedded].name();\n-\t\t\t} else if (unicam_[Unicam::Embedded].isExternal() || b->metadata().timestamp == ts) {\n-\t\t\t\t/* We pop the item from the queue lower down. */\n-\t\t\t\tembeddedBuffer = b;\n-\t\t\t\tbreak;\n-\t\t\t} else {\n-\t\t\t\tbreak; /* Only higher timestamps from here. */\n-\t\t\t}\n-\t\t}\n-\n-\t\tif (!embeddedBuffer) {\n-\t\t\tbool flushedBuffers = false;\n-\n-\t\t\tLOG(RPI, Debug) << \"Could not find matching embedded buffer\";\n-\n-\t\t\tif (!sensorMetadata_) {\n-\t\t\t\t/*\n-\t\t\t\t * If there is no sensor metadata, simply return the\n-\t\t\t\t * first bayer frame in the queue.\n-\t\t\t\t */\n-\t\t\t\tLOG(RPI, Debug) << \"Returning bayer frame without a match\";\n-\t\t\t\tbayerFrame = std::move(bayerQueue_.front());\n-\t\t\t\tbayerQueue_.pop();\n-\t\t\t\tembeddedBuffer = nullptr;\n-\t\t\t\treturn true;\n-\t\t\t}\n-\n-\t\t\tif (!embeddedQueue_.empty()) {\n-\t\t\t\t/*\n-\t\t\t\t * Not found a matching embedded buffer for the bayer buffer in\n-\t\t\t\t * the front of the queue. This buffer is now orphaned, so requeue\n-\t\t\t\t * it back to the device.\n-\t\t\t\t */\n-\t\t\t\tunicam_[Unicam::Image].returnBuffer(bayerQueue_.front().buffer);\n-\t\t\t\tbayerQueue_.pop();\n-\t\t\t\tbayerRequeueCount++;\n-\t\t\t\tLOG(RPI, Warning) << \"Dropping unmatched input frame in stream \"\n-\t\t\t\t\t\t  << unicam_[Unicam::Image].name();\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * If we have requeued all available embedded data buffers in this loop,\n-\t\t\t * then we are fully out of sync, so might as well requeue all the pending\n-\t\t\t * bayer buffers.\n-\t\t\t */\n-\t\t\tif (embeddedRequeueCount == unicam_[Unicam::Embedded].getBuffers().size()) {\n-\t\t\t\t/* The embedded queue must be empty at this point! */\n-\t\t\t\tASSERT(embeddedQueue_.empty());\n-\n-\t\t\t\tLOG(RPI, Warning) << \"Flushing bayer stream!\";\n-\t\t\t\twhile (!bayerQueue_.empty()) {\n-\t\t\t\t\tunicam_[Unicam::Image].returnBuffer(bayerQueue_.front().buffer);\n-\t\t\t\t\tbayerQueue_.pop();\n-\t\t\t\t}\n-\t\t\t\tflushedBuffers = true;\n-\t\t\t}\n+\tif (bayerQueue_.empty())\n+\t\treturn false;\n \n-\t\t\t/*\n-\t\t\t * Similar to the above, if we have requeued all available bayer buffers in\n-\t\t\t * the loop, then we are fully out of sync, so might as well requeue all the\n-\t\t\t * pending embedded data buffers.\n-\t\t\t */\n-\t\t\tif (bayerRequeueCount == unicam_[Unicam::Image].getBuffers().size()) {\n-\t\t\t\t/* The bayer queue must be empty at this point! */\n-\t\t\t\tASSERT(bayerQueue_.empty());\n-\n-\t\t\t\tLOG(RPI, Warning) << \"Flushing embedded data stream!\";\n-\t\t\t\twhile (!embeddedQueue_.empty()) {\n-\t\t\t\t\tunicam_[Unicam::Embedded].returnBuffer(embeddedQueue_.front());\n-\t\t\t\t\tembeddedQueue_.pop();\n-\t\t\t\t}\n-\t\t\t\tflushedBuffers = true;\n-\t\t\t}\n+\t/* Start with the front of the bayer queue. */\n+\tbayerFrame = std::move(bayerQueue_.front());\n+\tbayerQueue_.pop();\n \n-\t\t\t/*\n-\t\t\t * If the embedded queue has become empty, we cannot do any more.\n-\t\t\t * Similarly, if we have flushed any one of our queues, we cannot do\n-\t\t\t * any more. Return from here without a buffer pair.\n-\t\t\t */\n-\t\t\tif (embeddedQueue_.empty() || flushedBuffers)\n-\t\t\t\treturn false;\n-\t\t} else {\n-\t\t\t/*\n-\t\t\t * We have found a matching bayer and embedded data buffer, so\n-\t\t\t * nothing more to do apart from assigning the bayer frame and\n-\t\t\t * popping the buffers from the queue.\n-\t\t\t */\n-\t\t\tbayerFrame = std::move(bayerQueue_.front());\n-\t\t\tbayerQueue_.pop();\n+\t/*\n+\t * Find the embedded data buffer with a matching timestamp to pass to\n+\t * the IPA. Any embedded buffers with a timestamp lower than the\n+\t * current bayer buffer will be removed and re-queued to the driver.\n+\t */\n+\tuint64_t ts = bayerFrame.buffer->metadata().timestamp;\n+\tembeddedBuffer = nullptr;\n+\twhile (!embeddedQueue_.empty()) {\n+\t\tFrameBuffer *b = embeddedQueue_.front();\n+\t\tif (b->metadata().timestamp < ts) {\n+\t\t\tembeddedQueue_.pop();\n+\t\t\tunicam_[Unicam::Embedded].returnBuffer(b);\n+\t\t\tLOG(RPI, Debug) << \"Dropping unmatched input frame in stream \"\n+\t\t\t\t\t<< unicam_[Unicam::Embedded].name();\n+\t\t} else if (b->metadata().timestamp == ts) {\n+\t\t\t/* Found a match! */\n+\t\t\tembeddedBuffer = b;\n \t\t\tembeddedQueue_.pop();\n-\t\t\treturn true;\n+\t\t\tbreak;\n+\t\t} else {\n+\t\t\tbreak; /* Only higher timestamps from here. */\n \t\t}\n \t}\n \n-\treturn false;\n+\tif (!embeddedBuffer && sensorMetadata_) {\n+\t\t/* Log if there is no matching embedded data buffer found. */\n+\t\tLOG(RPI, Debug) << \"Returning bayer frame without a matching embedded buffer.\";\n+\t}\n+\n+\treturn true;\n }\n \n REGISTER_PIPELINE_HANDLER(PipelineHandlerRPi)\n",
    "prefixes": [
        "libcamera-devel",
        "2/3"
    ]
}