Patch Detail
Show a patch.
GET /api/1.1/patches/18849/?format=api
{ "id": 18849, "url": "https://patchwork.libcamera.org/api/1.1/patches/18849/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18849/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230718105210.83558-9-jacopo.mondi@ideasonboard.com>", "date": "2023-07-18T10:52:08", "name": "[libcamera-devel,v3,08/10] test: Add unit test for Transform and Orientation", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "352afa02668d10a563c10c8b0e1c36e7b38c618a", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18849/mbox/", "series": [ { "id": 3976, "url": "https://patchwork.libcamera.org/api/1.1/series/3976/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3976", "date": "2023-07-18T10:52:00", "name": "libcamera: Replace CameraConfiguration::transform", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3976/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18849/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18849/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 3D5FDC32AC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Jul 2023 10:52:32 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6A5E628E0;\n\tTue, 18 Jul 2023 12:52:31 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D429628C0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jul 2023 12:52:28 +0200 (CEST)", "from uno.localdomain (mob-5-90-54-150.net.vodafone.it\n\t[5.90.54.150])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 672B1838;\n\tTue, 18 Jul 2023 12:51:34 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689677551;\n\tbh=rHECqQXSuBFFChP6fsCWWExJnx2HNzOorTkOkQ2f/kw=;\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=3nyufN5TXO6kY1e+cuJNKmkTafp6k5ooHfV3mMUO4/ZmWP7ET4hnhUFg4nSfmP/2+\n\tJC3ZkWokw7ajAgbyjsMcwNrHRHb5Xj8coSy/evk5AKhTrP45GvHLoS+xJiCmujGE0M\n\t4+cx8ybK+Un6XK80W6aF5N6U9UQc5tq0slPkO0FYLuPxvhpHDVPgNUBY3Y2DZZ3r+l\n\tMVPVXmoOHebJNE9LYd5GTZtszh2JB81diuGdCdZK5DQacNljLOIWPZCXZPaN3I4gdF\n\tokZYKeRJsOvFIlqvX8KUu4MG02L7c8xeVZUzqO+4VMhJvrYwGf7PfFmxZc3B3myuQz\n\twa9ShEO81+Wzg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689677495;\n\tbh=rHECqQXSuBFFChP6fsCWWExJnx2HNzOorTkOkQ2f/kw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=HYMQWrQecUIIR58oSwWBYl+ecpr+O2d4fFVyL3TyC9SxVXRu7/37/RU810lNXCVEY\n\tsRFTGCjv1HGpBaLUsN3f983vOkK04ZAtaJrQk9X8Lf++deGiqo7Fs7q3gOhZA9UF6+\n\tP6LxPO3lsdhzg++PTgkY3pfoY16mlOMz1YsSjF8Q=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"HYMQWrQe\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 18 Jul 2023 12:52:08 +0200", "Message-Id": "<20230718105210.83558-9-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "In-Reply-To": "<20230718105210.83558-1-jacopo.mondi@ideasonboard.com>", "References": "<20230718105210.83558-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 08/10] test: Add unit test for\n\tTransform and 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\to2 * t = 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 | 335 ++++++++++++++++++++++++++++++++++\n 3 files changed, 343 insertions(+)\n create mode 100644 test/transform.cpp", "diff": "diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h\nindex 847a1f94713c..833b50d46fd0 100644\n--- a/include/libcamera/transform.h\n+++ b/include/libcamera/transform.h\n@@ -16,13 +16,20 @@ enum class Orientation;\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..f79a1a892d16\n--- /dev/null\n+++ b/test/transform.cpp\n@@ -0,0 +1,335 @@\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/orientation.h>\n+#include <libcamera/transform.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\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.\n+\t */\n+\tstruct RotationTestEntry {\n+\t\tOrientation o1;\n+\t\tOrientation 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", "v3", "08/10" ] }