Show a patch.

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

{
    "id": 18829,
    "url": "https://patchwork.libcamera.org/api/patches/18829/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18829/",
    "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": "<20230714141549.11085-8-jacopo.mondi@ideasonboard.com>",
    "date": "2023-07-14T14:15:47",
    "name": "[libcamera-devel,v2,7/9] test: Add unit test for Transform and Orientation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "836b785354e8bafd5f5a02328b688b064dc1139a",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18829/mbox/",
    "series": [
        {
            "id": 3971,
            "url": "https://patchwork.libcamera.org/api/series/3971/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3971",
            "date": "2023-07-14T14:15:40",
            "name": "libcamera: Replace CameraConfiguration::transform",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3971/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18829/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18829/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 C7848C3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Jul 2023 14:16:17 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80058628CD;\n\tFri, 14 Jul 2023 16:16:17 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F60E628CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Jul 2023 16:16:13 +0200 (CEST)",
            "from uno.localdomain (mob-5-90-9-92.net.vodafone.it [5.90.9.92])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2BFE2814;\n\tFri, 14 Jul 2023 16:15:22 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689344177;\n\tbh=4gzSlnqS6hWq5XJWMreHi/yEX6KFx2yYUkkjds4Pukw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=E/WRVSjxhupRNudRghnczYe3mxinDeWHf7CdfAjKCw9IYi1gH1HZ6vNWiXnbiCOHO\n\tYK+H1TVYCWnO8JroE7hjQspSYeJT+xmmK9O0OYOZu4IYMU6BKUyem1f9OjUR557lhU\n\tOp6Ue+HTjIVzJ9mScA/V8k6w0GmtdA5huHDqXQ7q94oQtRYLFvF7zgrpZZkwcf7x/i\n\tklr7S6tnMb+4N/EhtefVKvdAxWRCNLzhGqmTWj+pXteKQcdXWC5NE1IqLnzviOPgVV\n\t3MRdhBVyc9aW/nCeTgCBtF2dJrUrzZ0XQVDmGMlDYYIcYe/KGnmAWKTBI8b1mhjcrv\n\t+gPbMDNfteYcg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689344122;\n\tbh=4gzSlnqS6hWq5XJWMreHi/yEX6KFx2yYUkkjds4Pukw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JInbK5/fbTFCflmVGtTv7oKOhj+ohQFWo+nZvpUq2p3MjZtYXVVrr29reWBUzS/WG\n\tBOPfX1UmMOTVTq65H2RANfSa9tzj837rwvWQ3TOul3rByTkfmebfhoEZ9f8MdUzE7G\n\trumYyoGJzibfqxDB8D5NZGgUWmDQSFUTrTw22wOw="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JInbK5/f\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 14 Jul 2023 16:15:47 +0200",
        "Message-Id": "<20230714141549.11085-8-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.40.1",
        "In-Reply-To": "<20230714141549.11085-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230714141549.11085-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 7/9] test: Add unit test for Transform\n\tand Orientation",
        "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>",
        "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a unit test for Transform and Orientation to validate the\nimplementation of the operations between the two types.\n\nIn particular, test that:\n\n\to1 / o2 = t\n\tt * o2 = o1\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/transform.h |   7 +\n test/meson.build              |   1 +\n test/transform.cpp            | 338 ++++++++++++++++++++++++++++++++++\n 3 files changed, 346 insertions(+)\n create mode 100644 test/transform.cpp",
    "diff": "diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h\nindex a7470c70a755..4efb01a3b49d 100644\n--- a/include/libcamera/transform.h\n+++ b/include/libcamera/transform.h\n@@ -16,13 +16,20 @@ namespace libcamera {\n enum class Transform : int {\n \tIdentity = 0,\n \tRot0 = Identity,\n+\n \tHFlip = 1,\n+\n \tVFlip = 2,\n+\n \tHVFlip = HFlip | VFlip,\n \tRot180 = HVFlip,\n+\n \tTranspose = 4,\n+\n \tRot270 = HFlip | Transpose,\n+\n \tRot90 = VFlip | Transpose,\n+\n \tRot180Transpose = HFlip | VFlip | Transpose\n };\n \ndiff --git a/test/meson.build b/test/meson.build\nindex b227be818419..189e1428485a 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -46,6 +46,7 @@ public_tests = [\n     {'name': 'public-api', 'sources': ['public-api.cpp']},\n     {'name': 'signal', 'sources': ['signal.cpp']},\n     {'name': 'span', 'sources': ['span.cpp']},\n+    {'name': 'transform', 'sources': ['transform.cpp']},\n ]\n \n internal_tests = [\ndiff --git a/test/transform.cpp b/test/transform.cpp\nnew file mode 100644\nindex 000000000000..928d547de57d\n--- /dev/null\n+++ b/test/transform.cpp\n@@ -0,0 +1,338 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2023, Ideas On Board Oy\n+ *\n+ * transform.cpp - Transform and Orientation tests\n+ */\n+\n+#include <iostream>\n+\n+#include <libcamera/transform.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+using Orientation = CameraConfiguration::Orientation;\n+\n+class TransformTest : public Test\n+{\n+protected:\n+\tint run();\n+};\n+\n+int TransformTest::run()\n+{\n+\t/*\n+\t * RotationTestEntry collects two Orientation and one Transform that\n+\t * gets combined to validate that (o1 / o2 = T) and (o1 = o2 * T)\n+\t *\n+\t * o1 / o2 = t computes the Transform to apply to o2 to obtain o1\n+\t * o2 * t = o1 combines o2 with t by applying o2 first then t\n+\t *\n+\t * The comments on the (most complex) transform show how applying to\n+\t * an image with orientation o2 the Transform t allows to obtain o1.\n+\t *\n+\t * The image with basic rotation0 is assumed to be:\n+\t *\n+\t * \tAB\n+\t * \tCD\n+\t *\n+\t * And the Transform operators are:\n+\t *\n+\t * \tV = vertical flip\n+\t * \tH = horizontal flip\n+\t * \tT = transpose\n+\t *\n+\t * the operator '* (T|V)' applies V first then T, according to the\n+\t * canonical function composition notion implemented by\n+\t * operator*(Transpose t1, Transpose t2);\n+\t */\n+\tstruct RotationTestEntry {\n+\t\tCameraConfiguration::Orientation o1;\n+\t\tCameraConfiguration::Orientation o2;\n+\t\tTransform t;\n+\t} testEntries[] = {\n+\t\t/* Test identities transforms first. */\n+\t\t{\n+\t\t\tOrientation::rotate0, Orientation::rotate0,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate0Flip, Orientation::rotate0Flip,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate180, Orientation::rotate180,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate180Flip, Orientation::rotate180Flip,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate90, Orientation::rotate90,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate90Flip, Orientation::rotate90Flip,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate270, Orientation::rotate270,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate270Flip, Orientation::rotate270Flip,\n+\t\t\tTransform::Identity,\n+\t\t},\n+\t\t/*\n+\t\t * Combine 0 and 180 degrees rotation as they're the most common\n+\t\t * ones.\n+\t\t */\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tCD  * (H|V) =  \tBA\tAB\n+\t\t\t *\tBA\t\tCD\tCD\n+\t\t\t */\n+\t\t\tOrientation::rotate0, Orientation::rotate180,\n+\t\t\tTransform::Rot180,\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate180, Orientation::rotate180,\n+\t\t\tTransform::Identity\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tAB  * (H|V) =  \tCD\tDC\n+\t\t\t *\tCD\t\tAB\tBA\n+\t\t\t */\n+\t\t\tOrientation::rotate180, Orientation::rotate0,\n+\t\t\tTransform::Rot180\n+\t\t},\n+\t\t/* Test that transpositions are handled correctly. */\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tAB  * (T|V) =  \tCD\tCA\n+\t\t\t *\tCD\t\tAB\tDB\n+\t\t\t */\n+\t\t\tOrientation::rotate90, Orientation::rotate0,\n+\t\t\tTransform::Rot90,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tCA  * (T|H) =  \tAC\tAB\n+\t\t\t *\tDB\t\tBD\tCD\n+\t\t\t */\n+\t\t\tOrientation::rotate0, Orientation::rotate90,\n+\t\t\tTransform::Rot270,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tAB  * (T|H) =  \tBA\tBD\n+\t\t\t *\tCD\t\tDC\tAC\n+\t\t\t */\n+\t\t\tOrientation::rotate270, Orientation::rotate0,\n+\t\t\tTransform::Rot270,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tBD  * (T|V) =  \tAC\tAB\n+\t\t\t *\tAC\t\tBD\tCD\n+\t\t\t */\n+\t\t\tOrientation::rotate0, Orientation::rotate270,\n+\t\t\tTransform::Rot90,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tCD  * (T|H) =  \tDC\tDA\n+\t\t\t *\tBA\t\tAB\tCB\n+\t\t\t */\n+\t\t\tOrientation::rotate90, Orientation::rotate180,\n+\t\t\tTransform::Rot270,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tDA  * (T|V) =  \tCB\tCD\n+\t\t\t *\tCB\t\tDA\tBA\n+\t\t\t */\n+\t\t\tOrientation::rotate180, Orientation::rotate90,\n+\t\t\tTransform::Rot90,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tCD  * (T|V) =  \tBA\tBC\n+\t\t\t *\tBA\t\tCD\tAD\n+\t\t\t */\n+\t\t\tOrientation::rotate270, Orientation::rotate180,\n+\t\t\tTransform::Rot90,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tBC  * (T|H) =  \tCB\tCD\n+\t\t\t *\tAD\t\tDA\tBA\n+\t\t\t */\n+\t\t\tOrientation::rotate180, Orientation::rotate270,\n+\t\t\tTransform::Rot270,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tDA  * (V|H) =  \tAD\tBC\n+\t\t\t *\tCB\t\tBC\tAD\n+\t\t\t */\n+\t\t\tOrientation::rotate270, Orientation::rotate90,\n+\t\t\tTransform::Rot180,\n+\t\t},\n+\t\t/* Test that mirroring is handled correctly. */\n+\t\t{\n+\t\t\tOrientation::rotate0, Orientation::rotate0Flip,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate0Flip, Orientation::rotate0,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate180, Orientation::rotate180Flip,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate180Flip, Orientation::rotate180,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate90, Orientation::rotate90Flip,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate90Flip, Orientation::rotate90,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate270, Orientation::rotate270Flip,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate270Flip, Orientation::rotate270,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t{\n+\t\t\tOrientation::rotate0, Orientation::rotate0Flip,\n+\t\t\tTransform::HFlip\n+\t\t},\n+\t\t/*\n+\t\t * More exotic transforms which include Transpositions and\n+\t\t * mirroring.\n+\t\t */\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t       o1\n+\t\t\t *      ------------------\n+\t\t\t *\tBC  * (V) =  \tAD\n+\t\t\t *\tAD\t\tBC\n+\t\t\t */\n+\t\t\tOrientation::rotate90Flip, Orientation::rotate270,\n+\t\t\tTransform::VFlip,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t       o1\n+\t\t\t *      ------------------\n+\t\t\t *\tCB  * (T) =  \tCD\n+\t\t\t *\tDA\t\tBA\n+\t\t\t */\n+\t\t\tOrientation::rotate180, Orientation::rotate270Flip,\n+\t\t\tTransform::Transpose,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t       o1\n+\t\t\t *      ------------------\n+\t\t\t *\tAD  * (T) =  \tAB\n+\t\t\t *\tBC\t\tDC\n+\t\t\t */\n+\t\t\tOrientation::rotate0, Orientation::rotate90Flip,\n+\t\t\tTransform::Transpose,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t       o1\n+\t\t\t *      ------------------\n+\t\t\t *\tAD  * (V) =  \tBC\n+\t\t\t *\tBC\t\tAD\n+\t\t\t */\n+\t\t\tOrientation::rotate270, Orientation::rotate90Flip,\n+\t\t\tTransform::VFlip,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t       o1\n+\t\t\t *      ------------------\n+\t\t\t *\tDA  * (V) =  \tCB\n+\t\t\t *\tCB\t\tDA\n+\t\t\t */\n+\t\t\tOrientation::rotate270Flip, Orientation::rotate90,\n+\t\t\tTransform::VFlip,\n+\t\t},\n+\t\t{\n+\t\t\t/*\n+\t\t\t *      o2      t               o1\n+\t\t\t *      --------------------------\n+\t\t\t *\tCB  * (V|H) =\tBC  \tAD\n+\t\t\t *\tDA\t\tAD\tBC\n+\t\t\t */\n+\t\t\tOrientation::rotate90Flip, Orientation::rotate270Flip,\n+\t\t\tTransform::Rot180,\n+\t\t},\n+\t};\n+\n+\tfor (const auto &entry : testEntries) {\n+\t\tTransform transform = entry.o1 / entry.o2;\n+\t\tcout << \"Testing: \" << entry.o1 << \" / \" << entry.o2\n+\t\t     << \" = \" << transformToString(transform) << endl;\n+\t\tif (transform != entry.t) {\n+\t\t\tcerr << \"Failed to validate: \" << entry.o1\n+\t\t\t     << \" / \" << entry.o2\n+\t\t\t     << \" = \" << transformToString(entry.t) << endl;\n+\t\t\tcerr << \"Got back: \"\n+\t\t\t     << transformToString(transform) << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tOrientation adjusted = entry.o2 * entry.t;\n+\t\tif (adjusted != entry.o1) {\n+\t\t\tcerr << \"Failed to validate: \" << entry.o2\n+\t\t\t     << \" * \" << transformToString(entry.t)\n+\t\t\t     << \" = \" << entry.o1 << endl;\n+\t\t\tcerr << \"Got back: \" << adjusted << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+TEST_REGISTER(TransformTest)\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "7/9"
    ]
}