Show a patch.

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

{
    "id": 10798,
    "url": "https://patchwork.libcamera.org/api/patches/10798/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10798/",
    "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": "<20201231155336.7058-5-sebastian.fricke.linux@gmail.com>",
    "date": "2020-12-31T15:53:36",
    "name": "[libcamera-devel,v2,4/4] test: Add unit tests for the BayerFormat class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8ed10042abbfac56eef75be06cee7ed088187666",
    "submitter": {
        "id": 73,
        "url": "https://patchwork.libcamera.org/api/people/73/?format=api",
        "name": "Sebastian Fricke",
        "email": "sebastian.fricke.linux@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10798/mbox/",
    "series": [
        {
            "id": 1564,
            "url": "https://patchwork.libcamera.org/api/series/1564/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1564",
            "date": "2020-12-31T15:53:32",
            "name": "Improve BayerFormat class",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1564/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10798/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10798/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 28247C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 31 Dec 2020 15:54:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E855361D25;\n\tThu, 31 Dec 2020 16:54:37 +0100 (CET)",
            "from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 11B0B6031D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 31 Dec 2020 16:54:37 +0100 (CET)",
            "by mail-wm1-x329.google.com with SMTP id r4so7512403wmh.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 31 Dec 2020 07:54:37 -0800 (PST)",
            "from basti-TUXEDO-Book-XA1510.fritz.box\n\t(p200300d1ff267500b10aabf0e84cdf75.dip0.t-ipconnect.de.\n\t[2003:d1:ff26:7500:b10a:abf0:e84c:df75])\n\tby smtp.gmail.com with ESMTPSA id\n\ts63sm14595787wms.18.2020.12.31.07.54.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 31 Dec 2020 07:54:36 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"mQcbRPzY\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=zuTY42ZMfo1siGVlU7k9dyTzIsNOKpMhoGanuRaVzjs=;\n\tb=mQcbRPzYPctM3GI3KCBLVxM6Q9Wk3es2noFD7li0ZJUSD2eXdMrJ7UOe8ddBD8TJv2\n\tDFtilakc/WvBgQ846uzlniFD74qNm3dnVUylRVh8BPzTK1gghEF2+r+nhztRdLbsf4VW\n\tPdiOocqysVPUyyqutFMbvUpbJKH6YPDziBjoa/O+aDXum5FeG/aatFlF5HHlswV7CD9/\n\tut5DrfRhg86W09g0yiXhCbzPchd+b3A8ml9oujeqE50A6DZHiFnhFA8KKv+ReI6mB7/G\n\tmeIw1aB9/B3j21uxS7qOdQa3rSDo1SVLkQXWzTi0NtLjGzt8FjCLNj6jhfpAsF/GK/2w\n\tZG0A==",
        "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=zuTY42ZMfo1siGVlU7k9dyTzIsNOKpMhoGanuRaVzjs=;\n\tb=LqkOuzfup3Eszt8dLwgJfMrVvJpBdmGCP20TnP7uCTuwdtrL1gT1fkuBiLK6mdM8Ja\n\tjliZqDDHw6VBFmbYNEm5tYAEl5rojuzFqUJVY8U/Y7LDJJUFaY1DoE0ULBoS2BO+jxDw\n\tJ9367/01MI4zOmQLNwqyYxJbj2XDWsQfKKNtUWjVXe5IG/E72mDFc/v2at2i7mwr0KdC\n\t8WNjVyy8vtXwmoxAmnMuHv6cyPg6I1n1RPJId6ByLJyFtdnyxMw2X+scVML58UahProx\n\thFdU08uQ1svglNnFInh6plA4kAd76wELzad9pxFU8R3v9EdkGaBGDltyZdMv83E0x0EB\n\tsvGw==",
        "X-Gm-Message-State": "AOAM531yNqNGyFnaw3shmeuJick9TLQOYQsxJtTSfaEiZCTT6QngsbT7\n\txza9CUWRiWVEpLJj4h/NDew6DxnMBoo=",
        "X-Google-Smtp-Source": "ABdhPJwkbJITxDzvhq/jnZwMV8rXApBDRlyFI8icMCuu5vjmujnu4wRStiTae7TxM5Au/nWU838dlw==",
        "X-Received": "by 2002:a7b:c45a:: with SMTP id\n\tl26mr12451474wmi.91.1609430076766; \n\tThu, 31 Dec 2020 07:54:36 -0800 (PST)",
        "From": "Sebastian Fricke <sebastian.fricke.linux@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 31 Dec 2020 16:53:36 +0100",
        "Message-Id": "<20201231155336.7058-5-sebastian.fricke.linux@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20201231155336.7058-1-sebastian.fricke.linux@gmail.com>",
        "References": "<20201231155336.7058-1-sebastian.fricke.linux@gmail.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 4/4] test: Add unit tests for the\n\tBayerFormat 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>",
        "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": "Test all of the present methods including the newly implemented\n`fromV4L2PixelFormat`, as well as the new operators `==/!=`.\n\nSigned-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>\n---\n test/bayer_format.cpp | 202 ++++++++++++++++++++++++++++++++++++++++++\n test/meson.build      |   1 +\n 2 files changed, 203 insertions(+)\n create mode 100644 test/bayer_format.cpp",
    "diff": "diff --git a/test/bayer_format.cpp b/test/bayer_format.cpp\nnew file mode 100644\nindex 00000000..dd7aa8cb\n--- /dev/null\n+++ b/test/bayer_format.cpp\n@@ -0,0 +1,202 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Sebastian Fricke\n+ *\n+ * bayer_format.cpp - BayerFormat class tests\n+ */\n+\n+#include <iostream>\n+\n+#include <libcamera/internal/bayer_format.h>\n+#include <libcamera/transform.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class BayerFormatTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\t/*\n+\t\t * An empty Bayer format has to be invalid.\n+\t\t */\n+\t\tBayerFormat bayerFmt = BayerFormat();\n+\t\tif (bayerFmt.isValid()) {\n+\t\t\tcout << \"An empty BayerFormat \"\n+\t\t\t     << \"has to be invalid.\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * A correct Bayer format has to be valid.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tif (!bayerFmt.isValid()) {\n+\t\t\tcout << \"A correct BayerFormat \"\n+\t\t\t     << \"has to be valid.\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Two bayer formats created with the same order and bit depth\n+\t\t * have to be equal.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tBayerFormat bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n+\t\t\t\t\t\t\t BayerFormat::None);\n+\t\tif (bayerFmt != bayerFmtExpect) {\n+\t\t\tcout << \"Two BayerFormat object created with the same \"\n+\t\t\t     << \"order and bitDepth must be equal.\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Two Bayer formats created with the same order but with a\n+\t\t * different bitDepth are not equal.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 12,\n+\t\t\t\t\t     BayerFormat::None);\n+\t\tif (bayerFmt == bayerFmtExpect) {\n+\t\t\tcout << \"Two BayerFormat object created with the same \"\n+\t\t\t     << \"order, but different bit depths are not equal.\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Create a Bayer format with a V4L2PixelFormat and check if we\n+\t\t * get the same format after converting back to the V4L2 Format.\n+\t\t */\n+\t\tV4L2PixelFormat v4l2FmtExpect = V4L2PixelFormat(\n+\t\t\tV4L2_PIX_FMT_SBGGR8);\n+\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);\n+\t\tV4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();\n+\t\tif (v4l2Fmt != v4l2FmtExpect) {\n+\t\t\tcout << \"Expected: '\" << v4l2FmtExpect.toString()\n+\t\t\t     << \"' got: '\" << v4l2Fmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Use a Bayer format that is not found in the mapping table\n+\t\t * and verify that no matching V4L2PixelFormat is found.\n+\t\t */\n+\t\tv4l2FmtExpect = V4L2PixelFormat();\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 24,\n+\t\t\t\t       BayerFormat::None);\n+\t\tv4l2Fmt = bayerFmt.toV4L2PixelFormat();\n+\t\tif (v4l2Fmt != v4l2FmtExpect) {\n+\t\t\tcout << \"Expected: empty V4L2PixelFormat got: '\"\n+\t\t\t     << v4l2Fmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Check if we get the expected Bayer format BGGR8\n+\t\t * when we convert the V4L2PixelFormat (V4L2_PIX_FMT_SBGGR8)\n+\t\t * to a Bayer format.\n+\t\t */\n+\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n+\t\t\t\t\t     BayerFormat::None);\n+\t\tv4l2Fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n+\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);\n+\t\tif (bayerFmt != bayerFmtExpect) {\n+\t\t\tcout << \"Expected BayerFormat '\"\n+\t\t\t     << bayerFmtExpect.toString() << \"',\"\n+\t\t\t     << \"got: '\" << bayerFmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Confirm that a V4L2PixelFormat that is not found in\n+\t\t * the conversion table, doesn't yield a Bayer format.\n+\t\t */\n+\t\tbayerFmtExpect = BayerFormat();\n+\t\tV4L2PixelFormat v4l2FmtUnknown = V4L2PixelFormat(\n+\t\t\tV4L2_PIX_FMT_BGRA444);\n+\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);\n+\t\tif (bayerFmt != bayerFmtExpect) {\n+\t\t\tcout << \"Expected empty BayerFormat got: '\"\n+\t\t\t     << bayerFmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test if a valid Bayer format can be converted to a\n+\t\t * string representation.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tif (bayerFmt.toString() != \"BGGR-8\") {\n+\t\t\tcout << \"String representation != 'BGGR8' (got: '\"\n+\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Determine if an empty Bayer format results in no\n+\t\t * string representation.\n+\t\t */\n+\t\tbayerFmt = BayerFormat();\n+\t\tif (bayerFmt.toString() != \"INVALID\") {\n+\t\t\tcout << \"String representation != 'INVALID' (got: '\"\n+\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Perform a horizontal Flip and make sure that the\n+\t\t * order is adjusted accordingly.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tbayerFmtExpect = BayerFormat(BayerFormat::GBRG, 8,\n+\t\t\t\t\t     BayerFormat::None);\n+\t\tBayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip);\n+\t\tif (hFlipFmt != bayerFmtExpect) {\n+\t\t\tcout << \"horizontal flip of 'BGGR-8' \"\n+\t\t\t     << \"should result in '\"\n+\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n+\t\t\t     << hFlipFmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Perform a vertical Flip and make sure that\n+\t\t * the order is adjusted accordingly.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tbayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8,\n+\t\t\t\t\t     BayerFormat::None);\n+\t\tBayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip);\n+\t\tif (vFlipFmt != bayerFmtExpect) {\n+\t\t\tcout << \"vertical flip of 'BGGR-8' \"\n+\t\t\t     << \"should result in '\"\n+\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n+\t\t\t     << vFlipFmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Perform a transposition and make sure that nothing changes.\n+\t\t * Transpositions are not implemented as sensors are not\n+\t\t * expected to support this functionality.\n+\t\t */\n+\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+\t\tBayerFormat transposeFmt = bayerFmt.transform(\n+\t\t\tTransform::Transpose);\n+\t\tif (transposeFmt.toString() != \"BGGR-8\") {\n+\t\t\tcout << \"Transposition is not supported \"\n+\t\t\t     << \"format should be 'BGGR-8', got: '\"\n+\t\t\t     << transposeFmt.toString() << \"'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(BayerFormatTest);\n+\ndiff --git a/test/meson.build b/test/meson.build\nindex 0a1d434e..e985b0a0 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -23,6 +23,7 @@ public_tests = [\n ]\n \n internal_tests = [\n+    ['bayer-format',                    'bayer_format.cpp'],\n     ['byte-stream-buffer',              'byte-stream-buffer.cpp'],\n     ['camera-sensor',                   'camera-sensor.cpp'],\n     ['event',                           'event.cpp'],\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "4/4"
    ]
}