{"id":11340,"url":"https://patchwork.libcamera.org/api/1.1/patches/11340/?format=json","web_url":"https://patchwork.libcamera.org/patch/11340/","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":"<20210218170126.2060783-5-naush@raspberrypi.com>","date":"2021-02-18T17:01:26","name":"[libcamera-devel,v3,4/4] pipeline: raspberrypi: Allow either strict or non-strict buffer matching","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"499a32c892e06f5e699b6d3a43570de299b6e060","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11340/mbox/","series":[{"id":1708,"url":"https://patchwork.libcamera.org/api/1.1/series/1708/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1708","date":"2021-02-18T17:01:22","name":"Raspberry Pi: Embedded data usage","version":3,"mbox":"https://patchwork.libcamera.org/series/1708/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11340/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11340/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 9AB81BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Feb 2021 17:01:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 31C28689CA;\n\tThu, 18 Feb 2021 18:01:37 +0100 (CET)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00D12689C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Feb 2021 18:01:35 +0100 (CET)","by mail-wm1-x32b.google.com with SMTP id o82so4433751wme.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Feb 2021 09:01:34 -0800 (PST)","from naush-laptop.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tt30sm10504747wra.56.2021.02.18.09.01.33\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 18 Feb 2021 09:01:33 -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=\"Ww1jAaqj\"; 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=QOvqICc8HaszzrrUhEyZFOx1hnvZtHh8GWAPTiZOFQc=;\n\tb=Ww1jAaqjSAkt9u1JNCBFwGs8V8XNoXEa5/ofSqCBwuzWhmZE9OmhCutXjodrXPVRmF\n\t6VIoD6SgPhX6ZVAeT03YuwYTv09FpjZLmYpifvp9XhthsL2aAy+utNoyccljgsAAOA8M\n\tYU9mBo6a4T3+z1mKkme86aRtfUGb+dTqA5agQoklLsp3R7tUISyj82DPeDnLuud8a1rL\n\t1D8YkLoB2Y7ZryEdyef6XqrhdtQehF4HNhkuBITwGfTn9SgiPI1kgTBuYzhIopxJFHjN\n\t/9qhOJKD/EjCMGqn9bSjqfBE6OcAXOXlYUx2CLo/9m73Qc8jFFsCq60SavamLmIaDb0s\n\t4vIg==","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=QOvqICc8HaszzrrUhEyZFOx1hnvZtHh8GWAPTiZOFQc=;\n\tb=DDe5QO+UW/53NAUN3FWmvGpqGHdNU+lcgnpStGW/R68ShuxeUmJhju8t8nD1fPzEJ5\n\tSOBYToGKk8f/gfZHeH+Z1GVS3+N3xPFn0pvrFeidAkmKO3hYcDUTZAowaCtodSUyZwhB\n\tJTUyy73RGVsfDK/mM9ypqn0jJP95vEfsIj4w+mfAHvlbQcxfEqZxBB3nGmJUHLXcXq7A\n\tqYq3e/dB52+TLeKPP3JxNiboEAwFJJwVH4XkbubRtu7Gk6QH7lqVhqjmREbCWLvxru7r\n\tnZe87qF2kIo3gVO96MJ/PzCnPiTccAJK8GgR4K5nOOleV7tNtrRX9E6F8SVxyf38sJ7M\n\t5uew==","X-Gm-Message-State":"AOAM533yv+/pDTWpcgUxqnZW6DtG2s0ulF6mk73Q9RK9EFGVD+hYESQR\n\t/AlCzBa5I/QwxoFEtumddnQ0fhEXrPkFLNCT","X-Google-Smtp-Source":"ABdhPJzRLFwpwcy1dvYftgMOeTD5zlcFNLbHYYJkl3/D9bF6feG1urbJyUV1gqf7BHkK70f+Ivup1g==","X-Received":"by 2002:a1c:771a:: with SMTP id t26mr4452037wmi.37.1613667694287;\n\tThu, 18 Feb 2021 09:01:34 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 18 Feb 2021 17:01:26 +0000","Message-Id":"<20210218170126.2060783-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210218170126.2060783-1-naush@raspberrypi.com>","References":"<20210218170126.2060783-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 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>\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 d969c77993eb..7f66d6995176 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@@ -1724,13 +1740,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@@ -1744,10 +1760,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 follwing 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\tbayerQueue_.pop();\n","prefixes":["libcamera-devel","v3","4/4"]}