Show a patch.

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

{
    "id": 9060,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9060/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9060/",
    "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": "<20200729093154.12296-2-david.plowman@raspberrypi.com>",
    "date": "2020-07-29T09:31:50",
    "name": "[libcamera-devel,1/5] libcamera: Add Transform class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "06ba94a723cda7906e6c79c04dada055b8148fae",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9060/mbox/",
    "series": [
        {
            "id": 1160,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1160/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1160",
            "date": "2020-07-29T09:31:50",
            "name": "Transform implementation",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1160/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9060/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9060/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 29FE8BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jul 2020 09:32:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0F3E36185C;\n\tWed, 29 Jul 2020 11:32:04 +0200 (CEST)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 220D7605B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 11:32:02 +0200 (CEST)",
            "by mail-wm1-x32a.google.com with SMTP id k8so2249328wma.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 02:32:02 -0700 (PDT)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tc15sm3709921wme.23.2020.07.29.02.32.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 29 Jul 2020 02:32:00 -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=\"cNyMNGL1\"; 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=xonQ42icnoeM5+ZjLptP5FX3WqLgo0G6u2lfNy8TDyY=;\n\tb=cNyMNGL1xHiJJEqO5zgRqrA2N+QFkyduLP9e9BL0OxDgutrXmaotcRXAnifN3ET962\n\tnnouRU1jBgGgCf2nwEf71qUkI+5avCVrE+2J2faqItdd9aWppo18F9+RPvRgUogMfamn\n\ts6WlCTVq8GjZqdbyVRMEuCGFgiq8UhVe86mHiR15Bct2KglEN673kXAv6QU8qECpa1Go\n\tu1Uu+GwQT/Hi7CqcNFeIr0m2D6YFDrLGbL02mznGuOWnDYMk5sDwbSLf7Fdxe0889a/O\n\tSGHH+8S17YO7qsrqowBLEj0lQ1T59a4iE9Cf4OfhUoAR3gAVPXEAHCp95arxBj92aFhT\n\tWr0w==",
        "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=xonQ42icnoeM5+ZjLptP5FX3WqLgo0G6u2lfNy8TDyY=;\n\tb=Ji0CLc6bEstNdAv0pyU24IEjYLy3lDXDbSa+i7OUxXKXtVMCly0ayD1rNN7v30WgJj\n\tbVXfjmWzWdgTGFDWXt4xXVtONT/pJ7mAFHs/C/Gj2nUlbo7UxNCCcq7TUP8girZF+8m/\n\thWLXSN3Gnuv1MrcGpSxQhHhrudJVZXzsKxYtWLVNU4c0MwzTnHJz4uK0iuGfA8thKAvo\n\t56bOGs4a4tmxxpj4btlHYiyUastLjS583W0pdpeAlXgcJH9NUYNzHgSydHbPkRHUVZi1\n\t65LEfAdYuJGlNpQM51UcZY2Qc864C8kAEgb/bjY/XuKzIAjIdDvKyW8CpRIVajOuQIMo\n\t+iPw==",
        "X-Gm-Message-State": "AOAM5303D+z99ZbUAIXQGzHRSidS1rBiGoRPTLcuLVUyiiQhoJVvUjxa\n\tNEKFDcvmbGaiEi6llgczy64lJJAVh/2PiA==",
        "X-Google-Smtp-Source": "ABdhPJyr9oVy0aclePILz269u8DZCDXDXkh+LmEofO+OW9D/Q3OX0MaEAA6bu3HtrOx19jS9t03wcQ==",
        "X-Received": "by 2002:a1c:3b06:: with SMTP id i6mr7903903wma.42.1596015121151; \n\tWed, 29 Jul 2020 02:32:01 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 29 Jul 2020 10:31:50 +0100",
        "Message-Id": "<20200729093154.12296-2-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20200729093154.12296-1-david.plowman@raspberrypi.com>",
        "References": "<20200729093154.12296-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 1/5] libcamera: Add Transform 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": "Add implementation of 2d plane transforms, and include a Transform\nfield in the CameraConfiguration to record the application's choice of\nimage transform for this session.\n---\n include/libcamera/camera.h    |   3 +\n include/libcamera/meson.build |   1 +\n include/libcamera/transform.h | 193 ++++++++++++++++++++++++++++++++++\n 3 files changed, 197 insertions(+)\n create mode 100644 include/libcamera/transform.h",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 4d1a4a9..fd9355e 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -16,6 +16,7 @@\n #include <libcamera/request.h>\n #include <libcamera/signal.h>\n #include <libcamera/stream.h>\n+#include <libcamera/transform.h>\n \n namespace libcamera {\n \n@@ -60,6 +61,8 @@ public:\n \tbool empty() const;\n \tstd::size_t size() const;\n \n+\tTransform userTransform;\n+\n protected:\n \tCameraConfiguration();\n \ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex cdb8e03..7fae5e5 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -19,6 +19,7 @@ libcamera_public_headers = files([\n     'span.h',\n     'stream.h',\n     'timer.h',\n+    'transform.h',\n ])\n \n include_dir = join_paths(libcamera_include_dir, 'libcamera')\ndiff --git a/include/libcamera/transform.h b/include/libcamera/transform.h\nnew file mode 100644\nindex 0000000..cfd5026\n--- /dev/null\n+++ b/include/libcamera/transform.h\n@@ -0,0 +1,193 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * transform.h - Implementation of 2d plane transforms\n+ */\n+\n+#ifndef __LIBCAMERA_TRANSFORM_H__\n+#define __LIBCAMERA_TRANSFORM_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+class Transform\n+{\n+public:\n+\tconstexpr Transform()\n+\t\t: Transform(Identity)\n+\t{\n+\t}\n+\n+\tconstexpr static Transform identity()\n+\t{\n+\t\treturn Transform(Identity);\n+\t}\n+\n+\tconstexpr static Transform rot0()\n+\t{\n+\t\treturn identity();\n+\t}\n+\n+\tconstexpr static Transform hflip()\n+\t{\n+\t\treturn Transform(HFlip);\n+\t}\n+\n+\tconstexpr static Transform vflip()\n+\t{\n+\t\treturn Transform(VFlip);\n+\t}\n+\n+\tconstexpr static Transform hvflip()\n+\t{\n+\t\treturn Transform(HVFlip);\n+\t}\n+\n+\tconstexpr static Transform rot180()\n+\t{\n+\t\treturn hvflip();\n+\t}\n+\n+\tconstexpr static Transform transpose()\n+\t{\n+\t\treturn Transform(Transpose);\n+\t}\n+\n+\tconstexpr static Transform rot270()\n+\t{\n+\t\treturn Transform(Rot270);\n+\t}\n+\n+\tconstexpr static Transform rot90()\n+\t{\n+\t\treturn Transform(Rot90);\n+\t}\n+\n+\tconstexpr static Transform rot180Transpose()\n+\t{\n+\t\treturn Transform(Rot180Transpose);\n+\t}\n+\n+\tconstexpr static Transform hvflipTranspose()\n+\t{\n+\t\treturn rot180Transpose();\n+\t}\n+\n+\tconstexpr static bool rotation(int32_t angle, Transform &xfm)\n+\t{\n+\t\tbool success = true;\n+\t\tangle = angle % 360;\n+\t\tif (angle < 0)\n+\t\t\tangle += 360;\n+\n+\t\tif (angle == 0)\n+\t\t\txfm = identity();\n+\t\telse if (angle == 90)\n+\t\t\txfm = rot90();\n+\t\telse if (angle == 180)\n+\t\t\txfm = rot180();\n+\t\telse if (angle == 270)\n+\t\t\txfm = rot270();\n+\t\telse\n+\t\t\tsuccess = false;\n+\n+\t\treturn success;\n+\t}\n+\n+\tconstexpr bool rotation(int32_t &angle) const\n+\t{\n+\t\tbool success = true;\n+\n+\t\tif (type_ == Identity)\n+\t\t\tangle = 0;\n+\t\telse if (type_ == Rot90)\n+\t\t\tangle = 90;\n+\t\telse if (type_ == HVFlip)\n+\t\t\tangle = 180;\n+\t\telse if (type_ == Rot270)\n+\t\t\tangle = 270;\n+\t\telse\n+\t\t\tsuccess = false;\n+\n+\t\treturn success;\n+\t}\n+\n+\tconstexpr bool contains(Transform xfm) const\n+\t{\n+\t\treturn (type_ & xfm.type_) == xfm.type_;\n+\t}\n+\n+\tconstexpr Transform inverse() const\n+\t{\n+\t\t/* They're all self-inverses, except for Rot90 and Rot270. */\n+\t\tconst Type inverses[] = { Identity, HFlip, VFlip, HVFlip,\n+\t\t\t\t\t  Transpose, Rot90, Rot270, Rot180Transpose };\n+\n+\t\treturn Transform(inverses[type_]);\n+\t}\n+\n+\tconstexpr Transform operator*(Transform xfm) const\n+\t{\n+\t\t/*\n+\t\t * Reorder the operations so that we imagine doing xfm's transpose\n+\t\t * (if any) after our flips. The effect is to swap our hflips for\n+\t\t * vflips and vice versa, after which we can just xor all the bits.\n+\t\t */\n+\t\tint reorderedType = type_;\n+\t\tif (xfm.type_ & Transpose)\n+\t\t\treorderedType = (type_ & 4) | ((type_ & 1) << 1) | ((type_ & 2) >> 1);\n+\n+\t\treturn Transform((Type)(reorderedType ^ xfm.type_));\n+\t}\n+\n+\tbool operator==(Transform xfm) const\n+\t{\n+\t\treturn type_ == xfm.type_;\n+\t}\n+\n+\tbool operator!=(Transform xfm) const\n+\t{\n+\t\treturn !(*this == xfm);\n+\t}\n+\n+\tstd::string toString() const\n+\t{\n+\t\tchar const *strings[] = {\n+\t\t\t\"identity\",\n+\t\t\t\"hflip\",\n+\t\t\t\"vflip\",\n+\t\t\t\"hvflip\",\n+\t\t\t\"transpose\",\n+\t\t\t\"rot270\",\n+\t\t\t\"rot90\",\n+\t\t\t\"rot180transpose\"\n+\t\t};\n+\t\treturn strings[type_];\n+\t}\n+\n+private:\n+\tenum Type : int {\n+\t\tIdentity = 0,\n+\t\tHFlip = 1,\n+\t\tVFlip = 2,\n+\t\tHVFlip = HFlip | VFlip,\n+\t\tTranspose = 4,\n+\t\tRot270 = HFlip | Transpose,\n+\t\tRot90 = VFlip | Transpose,\n+\t\tRot180Transpose = HFlip | VFlip | Transpose\n+\t};\n+\n+\tconstexpr Transform(Type type)\n+\t\t: type_(type)\n+\t{\n+\t}\n+\n+\tType type_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_TRANSFORM_H__ */\n+\n",
    "prefixes": [
        "libcamera-devel",
        "1/5"
    ]
}