Show a patch.

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

{
    "id": 14199,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14199/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14199/",
    "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": "<20211020110825.12902-7-david.plowman@raspberrypi.com>",
    "date": "2021-10-20T11:08:24",
    "name": "[libcamera-devel,v3,6/7] libcamera: Add validateColorSpaces to CameraConfiguration class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e65c6fff28d49f176b0050c10277d26d0d33cd55",
    "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/14199/mbox/",
    "series": [
        {
            "id": 2641,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2641/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2641",
            "date": "2021-10-20T11:08:18",
            "name": "Colour spaces",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2641/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14199/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14199/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 3DD83C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Oct 2021 11:08:37 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED60868F71;\n\tWed, 20 Oct 2021 13:08:36 +0200 (CEST)",
            "from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A5DE668F64\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 13:08:31 +0200 (CEST)",
            "by mail-wm1-x331.google.com with SMTP id\n\t67-20020a1c1946000000b0030d4c90fa87so9268930wmz.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 04:08:31 -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\tf20sm1929654wmq.38.2021.10.20.04.08.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 20 Oct 2021 04:08:30 -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=\"EryKXKyt\"; 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=/DkWsC49pTR4LtQbKMXqaDsUcUfiAkrci28YuUbz4pg=;\n\tb=EryKXKytDszuoNQQe4JsV9U3GFRqmxL0OPKwdOyPqzXrq45p6U3dPWCLdhOO5UTwfG\n\tq1taqsHbf/FyJGVN5ZFCJrOc9iQvmSUcQrsoIGpa9yRPYKbDL/k3HEAB0/GikVWeJwR9\n\t9sl/cB2oUiMqL9MvnQt2XGTFhlZjKGQLhjWefhkmLIy3XKoqI/A3Dz+2ImqW2vKZv+YF\n\tbl72cwe80o6is3KNBVnMVOpuq8FQDVt5EOi0ZhkzdTpxQO4tPSXG9JlPw3Biau26LUMN\n\tQgcqf4BSvYZWJ1ifzHsEt5AiIv0UcTZD23zFsgOjBBbkl7qc+pwGvTz5mbnaPGF5gW4d\n\tTHGA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=/DkWsC49pTR4LtQbKMXqaDsUcUfiAkrci28YuUbz4pg=;\n\tb=tzwSGmlwexbVrBtnNadi+R0WqnRvAQNqO6SOvz4afTgqk/Ds6dmA/nZ1J76orU9Zsz\n\tIoQTuRCl6CDCfRwGkDLWM+efSqn+VDzIeB4/T1u2/cQh6phejg55Tn6/P/LWih+wSNRs\n\tksJZWvGjlHxrY7KpwvCy07ACjIfgKKVb1nxxThhZ2uQ+r8Iw0gON7J2EKfUY18JEakol\n\t8iPwbFS3cE/g+ny9t+PwrJ2m77TBH6Fi/MBnx97iH0212tzdiLMksvypkI3ZBAKhhLiY\n\tM5hbOeaptcDBI+aWsMcohQ3NAJ/sAdX++u13MRXo1Y5Ho3InaXbmW0QAPwl1iORE/8/y\n\t6Niw==",
        "X-Gm-Message-State": "AOAM532o0P+QQY3d3VBXx5JRmEG+0Mqmb25+WRIxwysuhmhsn8xHF0Vm\n\t94RN9rMlE2NRXAjI4kgUKj1jkLa8JiIExA==",
        "X-Google-Smtp-Source": "ABdhPJzDsF7AyeXeP+Id459Q+EGISvZ0qi3DR44d4F0DhcnEDscCfUUVIhKpZVvho2f2OZRO1xxKLQ==",
        "X-Received": "by 2002:a1c:f008:: with SMTP id\n\ta8mr12857449wmb.140.1634728111145; \n\tWed, 20 Oct 2021 04:08:31 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 20 Oct 2021 12:08:24 +0100",
        "Message-Id": "<20211020110825.12902-7-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211020110825.12902-1-david.plowman@raspberrypi.com>",
        "References": "<20211020110825.12902-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 6/7] libcamera: Add validateColorSpaces\n\tto CameraConfiguration 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 method checks that the requested color spaces are sensible and do\nnot contain any undefined enum values. It also initialises the\n\"actual\" color space field to the same value as the one requested, in\nthe expectation that the rest of the validate() method will be able to\ncheck this.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/camera.h |  2 ++\n src/libcamera/camera.cpp   | 53 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 55 insertions(+)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 601ee46e..fdab4410 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -69,6 +69,8 @@ public:\n protected:\n \tCameraConfiguration();\n \n+\tStatus validateColorSpaces(bool sharedColorSpace);\n+\n \tstd::vector<StreamConfiguration> config_;\n };\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 71809bcd..79451ef4 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -19,6 +19,7 @@\n #include <libcamera/stream.h>\n \n #include \"libcamera/internal/camera.h\"\n+#include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n \n /**\n@@ -313,6 +314,58 @@ std::size_t CameraConfiguration::size() const\n \treturn config_.size();\n }\n \n+static bool isRaw(const PixelFormat &pixFmt)\n+{\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n+\treturn info.isValid() &&\n+\t       info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n+}\n+\n+CameraConfiguration::Status CameraConfiguration::validateColorSpaces(bool sharedColorSpace)\n+{\n+\tStatus status = Valid;\n+\n+\t/* Find the largest non-raw stream (if any). */\n+\tint index = -1;\n+\tfor (unsigned int i = 0; i < config_.size(); i++) {\n+\t\tconst StreamConfiguration &cfg = config_[i];\n+\t\tif (!isRaw(cfg.pixelFormat) &&\n+\t\t    (index < 0 ||\n+\t\t     cfg.size.width * cfg.size.height > config_[i].size.width * config_[i].size.height))\n+\t\t\tindex = i;\n+\t}\n+\n+\t/*\n+\t * Here we force raw streams to the correct color space and signal\n+\t * an error if we encounter anything undefined. We handle the case\n+\t * where all output streams are to share a color space, which we\n+\t * choose to be the color space of the largest stream.\n+\t */\n+\tfor (auto &cfg : config_) {\n+\t\tColorSpace initialColorSpace = cfg.requestedColorSpace;\n+\n+\t\tif (isRaw(cfg.pixelFormat))\n+\t\t\tcfg.requestedColorSpace = ColorSpace::Raw;\n+\t\telse if (!cfg.requestedColorSpace.isFullyDefined()) {\n+\t\t\tLOG(Camera, Error) << \"Stream has undefined color space\";\n+\t\t\tcfg.requestedColorSpace = ColorSpace::Jpeg;\n+\t\t} else if (sharedColorSpace)\n+\t\t\tcfg.requestedColorSpace = config_[index].requestedColorSpace;\n+\n+\t\tif (cfg.requestedColorSpace != initialColorSpace)\n+\t\t\tstatus = Adjusted;\n+\n+\t\t/*\n+\t\t * We also initialise the actual color space as if the\n+\t\t * hardware can do what we want. But note that the rest\n+\t\t * of the validate() method may change this.\n+\t\t */\n+\t\tcfg.actualColorSpace = cfg.requestedColorSpace;\n+\t}\n+\n+\treturn status;\n+}\n+\n /**\n  * \\var CameraConfiguration::transform\n  * \\brief User-specified transform to be applied to the image\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "6/7"
    ]
}