{"id":14382,"url":"https://patchwork.libcamera.org/api/1.1/patches/14382/?format=json","web_url":"https://patchwork.libcamera.org/patch/14382/","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":"<20211028084646.453775-7-naush@raspberrypi.com>","date":"2021-10-28T08:46:42","name":"[libcamera-devel,v4,06/10] libcamera: bayer_format: Add PixelFormat conversion helpers to BayerFormat class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"55e76b3b24bd0410f80e669e7b7296782bd857d3","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/14382/mbox/","series":[{"id":2671,"url":"https://patchwork.libcamera.org/api/1.1/series/2671/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2671","date":"2021-10-28T08:46:36","name":"Raspberry Pi: Conversion to media controller","version":4,"mbox":"https://patchwork.libcamera.org/series/2671/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14382/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14382/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 9FE51BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Oct 2021 08:47:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43A3260158;\n\tThu, 28 Oct 2021 10:47:04 +0200 (CEST)","from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61212600B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 10:46:57 +0200 (CEST)","by mail-wm1-x32f.google.com with SMTP id 192so3458055wme.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 01:46:57 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:b894:feb0:b828:13b])\n\tby smtp.gmail.com with ESMTPSA id\n\tz2sm1955281wmk.19.2021.10.28.01.46.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 28 Oct 2021 01:46:56 -0700 (PDT)"],"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=\"RuTlLia2\"; 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=YPq00NOuoRgq46bBhppDBKpNY7cAdhvldaSzvXvOLbo=;\n\tb=RuTlLia2DBcIksf1GDNyjNuQUhVW1x2Xp/FE4BTPeWs4wwQjtrZzLmloxgX37RtSRR\n\tBp1q4IJc6o33Tru6yrmOPmRxR/4MFxFYBjto4xwINc1nwZrOuQCnBlMmTVuNwHgBG8i1\n\tvI75rlfqjEA4TnRe61gwXVjJcKZMmiJnZ+/Kw5j9IN+7ARyM1GI3Hj0SnNm9G3xhYF/i\n\tUr6Pp++nY/EKEXw2CAqgZpfvHNYYLfw+rKUWt15CdVJIxW0cMLpTAOhbU6DXBuOH7jke\n\tAXsGfg1uP6sKW4lKdDjbudEQhfycY/jt+mPakUS53oU9LHtBfiRnHfUt4/p7ynm4kPR2\n\tZEOg==","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=YPq00NOuoRgq46bBhppDBKpNY7cAdhvldaSzvXvOLbo=;\n\tb=3ZNuxzxXzPvfQeu6hwsfTeI4szzYbnfi8zeJxX6o6j9l7QyEEiKUSKyLt9xzQf9EVb\n\tVeifo5x8ETAhvdTrmKo9YqBTS/dh/MQc5ZC8Cw2KJzvvJjQtNFJlS5UEqYUq5Aw8yPvD\n\t0CeE+Ow95xFuKffuiXt3YOQbbxTrfanFIzc9v7q9cxyFZdcvILqUsuVq6ZJG8j7d2VoS\n\tD3eGYiAU6XjstOs0y9gExp+PPUmpIJP4+bB6+NTgiO+0lZCo1oKYWVtoERxJDTTTJ1Hy\n\tWKXyNsqWdzCU++5SVfY8kzjYBptCvQjitgavyTkECbHTZVj0/T2niNNN1UKOV79t/0pB\n\tNGsw==","X-Gm-Message-State":"AOAM531bmEC6y53dYaDq0q+2UaedyquSDCeJLKnT8o3HuSIaeChmTYEO\n\tn6ubri91H20XWlX1Xu1/kDfMW3BPb9wZJMZQ","X-Google-Smtp-Source":"ABdhPJzSkUjhXmqMP+MI9FvkWilAEB5Mmv6MIjdfVOxFjynnQyST7Hg9SPsLLScv61Xt08bD5pmAmQ==","X-Received":"by 2002:a1c:2541:: with SMTP id\n\tl62mr11048667wml.11.1635410816905; \n\tThu, 28 Oct 2021 01:46:56 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Oct 2021 09:46:42 +0100","Message-Id":"<20211028084646.453775-7-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20211028084646.453775-1-naush@raspberrypi.com>","References":"<20211028084646.453775-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 06/10] libcamera: bayer_format: Add\n\tPixelFormat conversion helpers to BayerFormat class","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":"Add BayerFormat::toPixelFormat() and BayerFormat::fromPixelFormat() helper\nfunctions to convert between BayerFormat and PixelFormat types.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/bayer_format.h |  4 ++++\n src/libcamera/bayer_format.cpp            | 29 +++++++++++++++++++++++\n 2 files changed, 33 insertions(+)","diff":"diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\nindex d9a56d744a25..79a25b52582d 100644\n--- a/include/libcamera/internal/bayer_format.h\n+++ b/include/libcamera/internal/bayer_format.h\n@@ -10,6 +10,8 @@\n #include <stdint.h>\n #include <string>\n \n+#include <libcamera/pixel_format.h>\n+\n #include \"libcamera/internal/v4l2_pixelformat.h\"\n \n namespace libcamera {\n@@ -50,6 +52,8 @@ public:\n \n \tV4L2PixelFormat toV4L2PixelFormat() const;\n \tstatic BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);\n+\tPixelFormat toPixelFormat() const;\n+\tstatic BayerFormat fromPixelFormat(PixelFormat format);\n \tBayerFormat transform(Transform t) const;\n \n \tOrder order;\ndiff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex 8665a025f7e0..1805d6fbbab9 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -307,6 +307,35 @@ BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)\n \treturn BayerFormat();\n }\n \n+/**\n+ * \\brief Convert a BayerFormat into the corresponding PixelFormat\n+ * \\return The PixelFormat corresponding to this BayerFormat\n+ */\n+PixelFormat BayerFormat::toPixelFormat() const\n+{\n+\tconst auto it = bayerToFormat.find(*this);\n+\tif (it != bayerToFormat.end())\n+\t\treturn it->second.pixelFormat;\n+\n+\treturn PixelFormat();\n+}\n+\n+/**\n+ * \\brief Convert a PixelFormat into the corresponding BayerFormat\n+ * \\return The BayerFormat corresponding to this PixelFormat\n+ */\n+BayerFormat BayerFormat::fromPixelFormat(PixelFormat format)\n+{\n+\tconst auto it = std::find_if(bayerToFormat.begin(), bayerToFormat.end(),\n+\t\t\t\t     [format](const auto &i) {\n+\t\t\t\t\treturn i.second.pixelFormat == format;\n+\t\t\t\t     });\n+\tif (it != bayerToFormat.end())\n+\t\treturn it->first;\n+\n+\treturn BayerFormat();\n+}\n+\n /**\n  * \\brief Apply a transform to this BayerFormat\n  * \\param[in] t The transform to apply\n","prefixes":["libcamera-devel","v4","06/10"]}