Show a patch.

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

{
    "id": 13212,
    "url": "https://patchwork.libcamera.org/api/patches/13212/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13212/",
    "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": "<20210805142154.20324-2-david.plowman@raspberrypi.com>",
    "date": "2021-08-05T14:21:52",
    "name": "[libcamera-devel,1/3] libcamera: Add ColorSpace class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9c3c977edaaee10b8b007f5822c92b3ede51cc5c",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13212/mbox/",
    "series": [
        {
            "id": 2308,
            "url": "https://patchwork.libcamera.org/api/series/2308/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2308",
            "date": "2021-08-05T14:21:51",
            "name": "Colour spaces",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2308/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13212/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13212/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 1CB5FC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 14:22:02 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CFA0368822;\n\tThu,  5 Aug 2021 16:22:00 +0200 (CEST)",
            "from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 857E16026D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 16:21:59 +0200 (CEST)",
            "by mail-wr1-x435.google.com with SMTP id n12so6812773wrr.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 05 Aug 2021 07:21:59 -0700 (PDT)",
            "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\tk17sm6410004wrw.53.2021.08.05.07.21.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 05 Aug 2021 07:21:58 -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=\"ApWBEUIr\"; 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=ncd5E7VqwPo5qncdQR3S7YIkVS5r9s5B2EL/AyaJzTo=;\n\tb=ApWBEUIrKy4FSvlKiZylZy8rkGUXApWpL7pNDNn1US0ORGMeisO7Sm+eLw535fILxF\n\tjrQepwxFeQt8ll1QKe5z2U6e692CLP7ziIF9Y696pVSwnNjCDnUu3NiPxDy/JEF/x+xs\n\tLxr/bxKZujY9i6XnxqWj5GFWjgGq8D8xKmAH5bFMP4+lMWdVv7KG03Wi5obGRm3qPTMg\n\t19iodFNWeoi5Z2zSO2Vd3yfmFCNJ5QrhNjuA38PdJ/TFwWUdgcdN/uSwV77qi8BRJTvl\n\tp0SYmEsrRhrolzEUw9ykZXMmiIyOvHbZBtUJ4fK8JpKQIoa3Z9fKze3o61qgAXydU/es\n\tQBPw==",
        "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=ncd5E7VqwPo5qncdQR3S7YIkVS5r9s5B2EL/AyaJzTo=;\n\tb=buWgbsCAT+vnuvmyFTPSMoi3qK/0Bpt8iKEllKi1GdH0th9lQg67j1tmQX4chN9SqA\n\t1W+/r0vYrYDFnPLY4jn8WlrcZHi0+ayQIRY46R2zZsz1zRA6unv8H80WuK3DFVgKkt7O\n\tg2Pa8ZEuzfnouRzVP1ZU0KQp7+Li0ONuG7vdjYFxqzyBND0+MCPfg+hLiGOOVzqWfhyo\n\tngFH0Ny/1EHkv0GEumEBASwS9IoTO4Ej65JbH/o/yg5MocjxjR9TeCggMt1e8BlZGoXh\n\tk1u5IesdCTkIoT6RXCdTIB6e80AbBlXTIGxD3U2L0AaFvqWOmGyQvoEGpxGehofc4yOc\n\tmIRw==",
        "X-Gm-Message-State": "AOAM532e4Mnl7efgvyP3/kEn9fmiq1gX3FulK3weZmZy2fxex7iasSGc\n\tsMTMn2MBxe5dqAQXOe5k4gg4AcNrU5KFLg==",
        "X-Google-Smtp-Source": "ABdhPJxpDDhfO5jj5qqSr013rKwN23P1TDgSQlPvDFP1Xdp9jo6RTINb0U70OFJxpt2GA1c+ua78BQ==",
        "X-Received": "by 2002:adf:f64b:: with SMTP id\n\tx11mr5526222wrp.155.1628173318894; \n\tThu, 05 Aug 2021 07:21:58 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  5 Aug 2021 15:21:52 +0100",
        "Message-Id": "<20210805142154.20324-2-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20210805142154.20324-1-david.plowman@raspberrypi.com>",
        "References": "<20210805142154.20324-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/3] libcamera: Add ColorSpace 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": "This class represents a colour space by defining its YCbCr encoding,\nthe transfer (gamma) function is uses, and whether the output is full\nor limited range.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/color_space.h |  94 +++++++++++++++++\n include/libcamera/meson.build   |   1 +\n src/libcamera/color_space.cpp   | 180 ++++++++++++++++++++++++++++++++\n src/libcamera/meson.build       |   1 +\n 4 files changed, 276 insertions(+)\n create mode 100644 include/libcamera/color_space.h\n create mode 100644 src/libcamera/color_space.cpp",
    "diff": "diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h\nnew file mode 100644\nindex 00000000..3d990f99\n--- /dev/null\n+++ b/include/libcamera/color_space.h\n@@ -0,0 +1,94 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n+ *\n+ * color_space.h - color space definitions\n+ */\n+\n+#ifndef __LIBCAMERA_COLOR_SPACE_H__\n+#define __LIBCAMERA_COLOR_SPACE_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+class ColorSpace\n+{\n+public:\n+\tenum class Encoding : int {\n+\t\tUNDEFINED,\n+\t\tRAW,\n+\t\tREC601,\n+\t\tREC709,\n+\t\tREC2020,\n+\t\tVIDEO,\n+\t};\n+\n+\tenum class TransferFunction : int {\n+\t\tUNDEFINED,\n+\t\tIDENTITY,\n+\t\tSRGB,\n+\t\tREC709,\n+\t};\n+\n+\tenum class Range : int {\n+\t\tUNDEFINED,\n+\t\tFULL,\n+\t\tLIMITED,\n+\t};\n+\n+\tconstexpr ColorSpace(Encoding e, TransferFunction t, Range r)\n+\t\t: encoding(e), transferFunction(t), range(r)\n+\t{\n+\t}\n+\n+\tconstexpr ColorSpace()\n+\t\t: ColorSpace(Encoding::UNDEFINED, TransferFunction::UNDEFINED, Range::UNDEFINED)\n+\t{\n+\t}\n+\n+\tstatic const ColorSpace UNDEFINED;\n+\tstatic const ColorSpace RAW;\n+\tstatic const ColorSpace JFIF;\n+\tstatic const ColorSpace SMPTE170M;\n+\tstatic const ColorSpace REC709;\n+\tstatic const ColorSpace REC2020;\n+\tstatic const ColorSpace VIDEO;\n+\n+\tEncoding encoding;\n+\tTransferFunction transferFunction;\n+\tRange range;\n+\n+\tbool isFullyDefined() const\n+\t{\n+\t\treturn encoding != Encoding::UNDEFINED &&\n+\t\t       transferFunction != TransferFunction::UNDEFINED &&\n+\t\t       range != Range::UNDEFINED;\n+\t}\n+\n+\tconst std::string toString() const;\n+};\n+\n+constexpr ColorSpace ColorSpace::UNDEFINED = { Encoding::UNDEFINED, TransferFunction::UNDEFINED, Range::UNDEFINED };\n+constexpr ColorSpace ColorSpace::RAW = { Encoding::RAW, TransferFunction::IDENTITY, Range::FULL };\n+constexpr ColorSpace ColorSpace::JFIF = { Encoding::REC601, TransferFunction::SRGB, Range::FULL };\n+constexpr ColorSpace ColorSpace::SMPTE170M = { Encoding::REC601, TransferFunction::REC709, Range::LIMITED };\n+constexpr ColorSpace ColorSpace::REC709 = { Encoding::REC709, TransferFunction::REC709, Range::LIMITED };\n+constexpr ColorSpace ColorSpace::REC2020 = { Encoding::REC2020, TransferFunction::REC709, Range::LIMITED };\n+constexpr ColorSpace ColorSpace::VIDEO = { Encoding::VIDEO, TransferFunction::REC709, Range::LIMITED };\n+\n+static inline bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)\n+{\n+\treturn lhs.encoding == rhs.encoding &&\n+\t       lhs.transferFunction == rhs.transferFunction &&\n+\t       lhs.range == rhs.range;\n+}\n+\n+static inline bool operator!=(const ColorSpace &lhs, const ColorSpace &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_COLOR_SPACE_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 5b25ef84..7a8a04e5 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -3,6 +3,7 @@\n libcamera_public_headers = files([\n     'camera.h',\n     'camera_manager.h',\n+    'color_space.h',\n     'compiler.h',\n     'controls.h',\n     'file_descriptor.h',\ndiff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp\nnew file mode 100644\nindex 00000000..c40264db\n--- /dev/null\n+++ b/src/libcamera/color_space.cpp\n@@ -0,0 +1,180 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n+ *\n+ * color_space.cpp - color spaces.\n+ */\n+\n+#include <libcamera/color_space.h>\n+\n+/**\n+ * \\file color_space.h\n+ * \\brief Class and enums to represent colour spaces.\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class ColorSpace\n+ * \\brief Class to describe a color space.\n+ *\n+ * The color space class defines the encodings of the color primaries, the\n+ * transfer function associated with the color space, and the range (sometimes\n+ * also referred to as the quantisation) of the color space.\n+ *\n+ * Certain combinations of these fields form well-known standard color spaces,\n+ * such as \"JFIF\" or \"REC709\", though there is flexibility to leave some or all\n+ * of them undefined too.\n+ */\n+\n+/**\n+ * \\enum ColorSpace::Encoding\n+ * \\brief The encoding used for the color primaries.\n+ *\n+ * \\var ColorSpace::Encoding::UNDEFINED\n+ * \\brief The encoding for the colour primaries is not specified.\n+ * \\var ColorSpace::Encoding::RAW\n+ * \\brief These are raw colours from the sensor.\n+ * \\var ColorSpace::Encoding::REC601\n+ * \\brief REC601 colour primaries.\n+ * \\var ColorSpace::Encoding::REC709\n+ * \\brief Rec709 colour primaries.\n+ * \\var ColorSpace::Encoding::REC2020\n+ * \\brief REC2020 colour primaries.\n+ * \\var ColorSpace::Encoding::VIDEO\n+ * \\brief A place-holder for video streams which will be resolved to one\n+ * of REC601, REC709 or REC2020 once the video resolution is known.\n+ */\n+\n+/**\n+ * \\enum ColorSpace::TransferFunction\n+ * \\brief The transfer function used for this colour space.\n+ *\n+ * \\var ColorSpace::TransferFunction::UNDEFINED\n+ * \\brief The transfer function is not specified.\n+ * \\var ColorSpace::TransferFunction::IDENTITY\n+ * \\brief This color space uses an identity transfer function.\n+ * \\var ColorSpace::TransferFunction::SRGB\n+ * \\brief sRGB transfer function.\n+ * \\var ColorSpace::TransferFunction::REC709\n+ * \\brief Rec709 transfer function.\n+ */\n+\n+/**\n+ * \\enum ColorSpace::Range\n+ * \\brief The range (sometimes \"quantisation\") for this color space.\n+ *\n+ * \\var ColorSpace::Range::UNDEFINED\n+ * \\brief The range is not specified.\n+ * \\var ColorSpace::Range::FULL\n+ * \\brief This color space uses full range pixel values.\n+ * \\var ColorSpace::Range::LIMITED\n+ * \\brief This color space uses limited range pixel values.\n+ */\n+\n+/**\n+ * \\fn ColorSpace::ColorSpace(Encoding e, TransferFunction t, Range r)\n+ * \\brief Construct a ColorSpace from explicit values\n+ * \\param[in] e The encoding for the color primaries\n+ * \\param[in] t The transfer function for the color space\n+ * \\param[in] r The range of the pixel values in this color space\n+ */\n+\n+/**\n+ * \\fn ColorSpace::ColorSpace()\n+ * \\brief Construct a color space with undefined encoding, transfer function\n+ * and range\n+ */\n+\n+/**\n+ * \\fn ColorSpace::isFullyDefined() const\n+ * \\brief Return whether all the fields of the color space are defined.\n+ */\n+\n+/**\n+ * \\brief Assemble and return a readable string representation of the\n+ * ColorSpace\n+ * \\return A string describing the ColorSpace\n+ */\n+const std::string ColorSpace::toString() const\n+{\n+\tstatic const char *encodings[] = {\n+\t\t\"UNDEFINED\",\n+\t\t\"RAW\",\n+\t\t\"REC601\",\n+\t\t\"REC709\",\n+\t\t\"REC2020\",\n+\t};\n+\tstatic const char *transferFunctions[] = {\n+\t\t\"UNDEFINED\",\n+\t\t\"IDENTITY\",\n+\t\t\"SRGB\",\n+\t\t\"REC709\",\n+\t};\n+\tstatic const char *ranges[] = {\n+\t\t\"UNDEFINED\",\n+\t\t\"FULL\",\n+\t\t\"LIMITED\",\n+\t};\n+\n+\treturn std::string(encodings[static_cast<int>(encoding)]) + \"+\" +\n+\t       std::string(transferFunctions[static_cast<int>(transferFunction)]) + \"+\" +\n+\t       std::string(ranges[static_cast<int>(range)]);\n+}\n+\n+/**\n+ * \\var ColorSpace::encoding\n+ * \\brief The encoding of the color primaries\n+ */\n+\n+/**\n+ * \\var ColorSpace::transferFunction\n+ * \\brief The transfer function for this color space.\n+ */\n+\n+/**\n+ * \\var ColorSpace::range\n+ * \\brief The pixel range used by this color space.\n+ */\n+\n+/**\n+ * \\var ColorSpace::UNDEFINED\n+ * \\brief A constant representing a fully undefined color space.\n+ */\n+\n+/**\n+ * \\var ColorSpace::RAW\n+ * \\brief A constant representing a raw color space (from a sensor).\n+ */\n+\n+/**\n+ * \\var ColorSpace::JFIF\n+ * \\brief A constant representing the JFIF color space usually used for\n+ * encoding JPEG images.\n+ */\n+\n+/**\n+ * \\var ColorSpace::SMPTE170M\n+ * \\brief A constant representing the SMPTE170M color space (sometimes also\n+ * referred to as \"full range BT601\").\n+ */\n+\n+/**\n+ * \\var ColorSpace::REC709\n+ * \\brief A constant representing the REC709 color space.\n+ */\n+\n+/**\n+ * \\var ColorSpace::REC2020\n+ * \\brief A constant representing the REC2020 color space.\n+ */\n+\n+/**\n+ * \\var ColorSpace::VIDEO\n+ * \\brief A constant that video streams can use to indicate the \"default\"\n+ * color space for a video of this resolution, once that is is known. For\n+ * exmample, SD streams would interpret this as SMPTE170M, HD streams as\n+ * REC709 and ultra HD as REC2020.\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 4f085801..e0748840 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -8,6 +8,7 @@ libcamera_sources = files([\n     'camera_manager.cpp',\n     'camera_sensor.cpp',\n     'camera_sensor_properties.cpp',\n+    'color_space.cpp',\n     'controls.cpp',\n     'control_serializer.cpp',\n     'control_validator.cpp',\n",
    "prefixes": [
        "libcamera-devel",
        "1/3"
    ]
}