{"id":12519,"url":"https://patchwork.libcamera.org/api/1.1/patches/12519/?format=json","web_url":"https://patchwork.libcamera.org/patch/12519/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210608144413.1529-2-david.plowman@raspberrypi.com>","date":"2021-06-08T14:44:11","name":"[libcamera-devel,RFC,1/3] libcamera: Add ColorSpace class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ef0126df91a22c292017233c820f16211226ef5c","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12519/mbox/","series":[{"id":2111,"url":"https://patchwork.libcamera.org/api/1.1/series/2111/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2111","date":"2021-06-08T14:44:10","name":"Colour spaces","version":1,"mbox":"https://patchwork.libcamera.org/series/2111/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12519/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12519/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 13323BD22E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Jun 2021 14:44:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B4122602A7;\n\tTue,  8 Jun 2021 16:44:19 +0200 (CEST)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D27E5602A7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jun 2021 16:44:17 +0200 (CEST)","by mail-wr1-x42d.google.com with SMTP id a20so21936961wrc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Jun 2021 07:44:17 -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\ti21sm3053173wmq.12.2021.06.08.07.44.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Jun 2021 07:44:16 -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=\"oklJMHz9\"; 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=tU0Kgc4GIfvHcEcZhIZFYCoGFnSm56EXIbRc7F5nySU=;\n\tb=oklJMHz9WudEoA/SEDjRqhilKCdt2ARNfDY40tgi6+24jgMElRlxDtcfYrlQEeIgaO\n\tnXYh6nzkQJlLqONLI3+g2j03jYbfXXyotNa0f2+UV1FsbjoIS+dpOIDaq5XStF53Frlm\n\t4LafXOe6xujysS6xBMYIuGvKDTs8QgtI6iTPKRD25/8Ci1wWo3fu9Fa1yWK7GPpTXdRF\n\t9ZYJZoiyVK1b/bvWzA9oyUNjsjCTTAVnHQ0C6gqio/ivDwRRiIIzzHOfFYEUGg/tciN3\n\tLr0BsFGkyzPyNrK5Oi/R1UEvulPGjHAyrJXIJgzfl0NBmM/P+GT9/LmET48tBV6Rk4lK\n\t0ULQ==","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=tU0Kgc4GIfvHcEcZhIZFYCoGFnSm56EXIbRc7F5nySU=;\n\tb=rh8CSxAlZrvZrzgRQacQBpYzi6XaL2B22/SOh6YqAKf/xYgOvW+W1YUChoOMX4vdC6\n\tvhKYK6/3XR0hYFytlh3NpoLFtWuZVyOhmj6W0RxLX5xGrrbN66UzyjY/h/8JUuY9zy1H\n\tXgTg5FAan4xQP5tDWQKjrv4qtxl3dIhxKRE+ScdBsuT/KdPs5qOGmgEtPn+q6yz3Hvt9\n\tmZ/rZmQPpJwjpprideKdtF+eoYN2QjgUQRmofG19v0g+WhKb0C+VNVxFOXrnwVRy2Ck8\n\tfjT8Hn3EuHM20JTMcCOZFeMue63tOF0qz/lm5HsROaT9nTF2dszYX4gitUqQNswo0jsU\n\tsqow==","X-Gm-Message-State":"AOAM532MTIiz8GhbqQyrjJPiLzMLhkJfVKjBmKTLHKGIG5/a9qjbQURT\n\tK34epNjQ3uR93AamA6AbSoOlK0FA/vJ/xmK2","X-Google-Smtp-Source":"ABdhPJzW44Lcju/Xck5Bm/h69OihMCNS0vxZ5WDW/l8vyIILhTJsjFvnHYYuwpSnDsxFJz887iwsYA==","X-Received":"by 2002:a5d:638b:: with SMTP id\n\tp11mr4363402wru.380.1623163457180; \n\tTue, 08 Jun 2021 07:44:17 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  8 Jun 2021 15:44:11 +0100","Message-Id":"<20210608144413.1529-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210608144413.1529-1-david.plowman@raspberrypi.com>","References":"<20210608144413.1529-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 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---\n include/libcamera/color_space.h | 94 +++++++++++++++++++++++++++++++++\n include/libcamera/meson.build   |  1 +\n src/libcamera/color_space.cpp   | 43 +++++++++++++++\n src/libcamera/meson.build       |  1 +\n 4 files changed, 139 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 086c958b..7d61d285 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -6,6 +6,7 @@ libcamera_public_headers = files([\n     'camera.h',\n     'camera_manager.h',\n     'class.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..888762ae\n--- /dev/null\n+++ b/src/libcamera/color_space.cpp\n@@ -0,0 +1,43 @@\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+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+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 7e19a177..f7b48a32 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -11,6 +11,7 @@ libcamera_sources = files([\n     'camera_sensor.cpp',\n     'camera_sensor_properties.cpp',\n     'class.cpp',\n+    'color_space.cpp',\n     'controls.cpp',\n     'control_serializer.cpp',\n     'control_validator.cpp',\n","prefixes":["libcamera-devel","RFC","1/3"]}