{"id":11465,"url":"https://patchwork.libcamera.org/api/patches/11465/?format=json","web_url":"https://patchwork.libcamera.org/patch/11465/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210302151111.212591-5-naush@raspberrypi.com>","date":"2021-03-02T15:11:11","name":"[libcamera-devel,v4,4/4] pipeline: raspberrypi: Allow either strict or non-strict buffer matching","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"58b07f4f7d606f7ed7ff073606cf40990841e250","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11465/mbox/","series":[{"id":1742,"url":"https://patchwork.libcamera.org/api/series/1742/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1742","date":"2021-03-02T15:11:07","name":"Raspberry Pi: Embedded data usage","version":4,"mbox":"https://patchwork.libcamera.org/series/1742/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11465/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11465/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 CF03DBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Mar 2021 15:11:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 98C9B68A9A;\n\tTue,  2 Mar 2021 16:11:29 +0100 (CET)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D61668AA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Mar 2021 16:11:28 +0100 (CET)","by mail-wm1-x335.google.com with SMTP id m1so3107227wml.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Mar 2021 07:11:28 -0800 (PST)","from naush-laptop.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tw6sm7561062wrl.49.2021.03.02.07.11.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 02 Mar 2021 07:11:26 -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=\"Q1H2WZdy\"; 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=VM2nJZYIxUbh0H6j3sg6aGAGAOyrxfuBY7kCfr0KnlE=;\n\tb=Q1H2WZdyUvSQCowTXEGmEeUSbHbcSU/QTewABRTdr7P97RHTlIh6r9JA9x01IN5aRd\n\t2S7QU2Xhyv7UX+Eaijj8ZiqQFwGzwFNCt1eDu5f3+sfx8QJotMyqe0URmq+UYou6g+AA\n\tbOSSmsoqSUHtIUZTuMehM407609J3yLDyjJMFTnpUn2/9RWpVYSSnpbHXEZcj9RIgVcd\n\tnXKbKGofVNASKBp0c3U5T4Cd9pAExnHf5xZCdze9tAdC7CVxqV0MPpS+jMwLGH6mxDu9\n\tT/RM5tCDmSPjSOHwFOj4OqlZ/uqJScdeRdbZzellMnX1d1VhCYHIjGntyfQrUjqPaFhJ\n\twucg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=VM2nJZYIxUbh0H6j3sg6aGAGAOyrxfuBY7kCfr0KnlE=;\n\tb=ommN8YpG92iuF79cSW2i/Zh9wYdR7guOiXf23ZkgvTwV6PB0TF1AZRycmIIUqYHaq9\n\tj8s6bvsTF4i87tKMlCuH6EeTGDrU4UfduDjaCyb6LBBN+g12X1CmLCI6zFm3FrjtYALO\n\tbLe/9gjVV7WdnNIwVAfB9oXqVCGN/ZLfEz2dKYrniMUuXwUFB9fWLXe9yY8UWaXfPMEn\n\tHFdBWWp7JhzeSoO3c46slh65aNuYbnAJNADl4Jfdqk6C5r34OdNYP88PmsNod6DTJmn2\n\tS3+Qhl/JhYjlyI7WL7F67JsB++eauIchhmFUWvAmGMsXHZLb13e4woKvHrxCbCOqNVKG\n\t7csA==","X-Gm-Message-State":"AOAM531CzZounBHyQXcCX1fONIRHkOn8AZ/mmIu2luHGaEMAusVWeRTA\n\tUbD/zjZ+BV97W1dwusmqtnzNWgv4NEbRJdZs","X-Google-Smtp-Source":"ABdhPJzlwBJENnZAvxGNQ730GdwxXZaO5gNRxSJr7gLJEnsbYLSGM/1OLcln+RqUVGzAGuNjpmeHew==","X-Received":"by 2002:a05:600c:2dda:: with SMTP id\n\te26mr4574260wmh.155.1614697887695; \n\tTue, 02 Mar 2021 07:11:27 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  2 Mar 2021 15:11:11 +0000","Message-Id":"<20210302151111.212591-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210302151111.212591-1-naush@raspberrypi.com>","References":"<20210302151111.212591-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 4/4] pipeline: raspberrypi: Allow\n\teither strict or non-strict buffer matching","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A new flag, StrictBufferMatching, is used to control the behavior of\nthe embedded and bayer buffer matching routine.\n\nIf set to true (default), we reject and drop all bayer frames that do\nnot have a matching embedded data buffer and vice-versa. This guarantees\nthe IPA will always have the correct frame exposure and gain values to\nuse.\n\nIf set to false, we use bayer frames that do not have a matching\nembedded data buffer. In this case, IPA will use use the ControlList\npassed to it for gain and exposure values.\n\nAdditionally, allow external stream buffers to behave as if\nStrictBufferMatching = false since we are not allowed to drop them.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 31 ++++++++++++++++---\n 1 file changed, 26 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 5ae2551957f8..549d6147cd60 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -46,6 +46,22 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(RPI)\n \n+/*\n+ * Set this to true to reject and drop all bayer frames that do not have a\n+ * matching embedded data buffer and vice-versa. This guarantees the IPA will\n+ * always have the correct frame exposure and gain values to use.\n+ *\n+ * Set this to false to use bayer frames that do not have a matching embedded\n+ * data buffer. In this case, IPA will use use our local history for gain and\n+ * exposure values, occasional frame drops may cause these number to be out of\n+ * sync for a short period.\n+ *\n+ * \\todo Ideally, this property should be set by the application, but we don't\n+ * have any mechanism to pass generic properties into a pipeline handler at\n+ * present.\n+ */\n+static const bool StrictBufferMatching = true;\n+\n namespace {\n \n bool isRaw(PixelFormat &pixFmt)\n@@ -1725,13 +1741,13 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em\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\tif (b->metadata().timestamp < ts) {\n \t\t\t\tembeddedQueue_.pop();\n \t\t\t\tunicam_[Unicam::Embedded].queueBuffer(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} else if (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@@ -1745,10 +1761,15 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em\n \n \t\t\tLOG(RPI, Debug) << \"Could not find matching embedded buffer\";\n \n-\t\t\tif (!sensorMetadata_) {\n+\t\t\tif (unicam_[Unicam::Embedded].isExternal() ||\n+\t\t\t    !StrictBufferMatching || !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 * If any of the following is true:\n+\t\t\t\t * - This is an external stream buffer (so cannot be dropped).\n+\t\t\t\t * - We do not care about strict buffer matching.\n+\t\t\t\t * - There is no sensor metadata present.\n+\t\t\t\t * we can simply return the first bayer frame in the queue\n+\t\t\t\t * without a matching embedded buffer.\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","prefixes":["libcamera-devel","v4","4/4"]}