Show a patch.

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

{
    "id": 14612,
    "url": "https://patchwork.libcamera.org/api/patches/14612/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14612/",
    "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": "<20211115161205.24335-7-david.plowman@raspberrypi.com>",
    "date": "2021-11-15T16:12:04",
    "name": "[libcamera-devel,v5,6/7] libcamera: Add validateColorSpaces to CameraConfiguration class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d8cd63365b5ba1749c821b40abdd38d3e8e0a355",
    "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/14612/mbox/",
    "series": [
        {
            "id": 2719,
            "url": "https://patchwork.libcamera.org/api/series/2719/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2719",
            "date": "2021-11-15T16:11:58",
            "name": "Colour spaces",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/2719/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14612/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14612/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 9641EC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 15 Nov 2021 16:13:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F075603C4;\n\tMon, 15 Nov 2021 17:13:10 +0100 (CET)",
            "from mail-wm1-x332.google.com (mail-wm1-x332.google.com\n\t[IPv6:2a00:1450:4864:20::332])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 361356036C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Nov 2021 17:13:02 +0100 (CET)",
            "by mail-wm1-x332.google.com with SMTP id\n\ti8-20020a7bc948000000b0030db7b70b6bso16261036wml.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Nov 2021 08:13:02 -0800 (PST)",
            "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\tj40sm16315615wms.16.2021.11.15.08.13.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 15 Nov 2021 08:13:01 -0800 (PST)"
        ],
        "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=\"lA6ZNaof\"; 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=px+J59JTE8VA+7mmTv2pDwc8QWJMkP/Tl3k7zA7RZOc=;\n\tb=lA6ZNaofLCd2+JjkqogeuZmcmMVGLhUM0+6CRZ/fT5UjGckn0jQdjkOGAEWqRKXR/E\n\tIXPN/VF0pA9gBQ93pdcytpcDFrCNjlsiIIHZt/vf16z+aY/Ba32DsQptFaM/fOU6jMwo\n\tvOoaK2QAdwUgSHU9fqAR/PIa4Pm1pLTcEcapGVJTl9svYQK8chEM2QjU02VzkehD+BhD\n\tCj0DHn3EhadopDhW3zbj4QhsIYqBpNzRWOPDlKHulDxjbGBXBkivDTIImUmdsQE3rX0w\n\tUGl+iJ/9oeet8igx9xqgTe7+CBcPhdYbnxNcPhFbUhV2Xv7pndDCKU63FwPzH+xPV2Ey\n\tRwcA==",
        "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=px+J59JTE8VA+7mmTv2pDwc8QWJMkP/Tl3k7zA7RZOc=;\n\tb=yfSNita43E3M4trlgtKhPShpTToqLhWruydQr+2BuHqT6UvzUL5U5Dcd3O3srLZCvq\n\tNAkKMi39A8ZWRdgB94el2/HWsG7SAZH8NVlCs9IW/dk/EOcAHAr0nV7AOA7Gx1bRwXZ+\n\teHQ267KNljGmt5VgvlVdNd/tPmFLTp1HpEJwTMbrj5cH+0H6SuK3sgshrPqR13ZebB6j\n\ttkeL9YvV8/gRS7W9xgdWJZfdWa4KhWhM8NvGdwVOWA0zf/8CPgnqsC1yowQhOeQbYZXB\n\tx4IvAh33OV0Co/UGbZ7ba9D5YicXFkAU+bkSoCi+xW9uhl86/utGUGh9O6KoobX5jjyP\n\tIEPg==",
        "X-Gm-Message-State": "AOAM5327/dUILYCspqVS7kEA+VzJjGFVwEAlYGJrb8S6b/yiCxFkijZJ\n\toEhdv+cJW27BV2flIsOQxC31KA==",
        "X-Google-Smtp-Source": "ABdhPJyptZyIeKPnPgLThjbBMaTNmFu5bpz/Rvnt+zx3TsroBHz4L0QZtNMkI5iITapygenVuwP19g==",
        "X-Received": "by 2002:a1c:7ed3:: with SMTP id\n\tz202mr42913048wmc.110.1636992781945; \n\tMon, 15 Nov 2021 08:13:01 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com,\n\tkieran.bingham@ideasonboard.com, jacopo@jmondi.org, tfiga@google.com, \n\tnaush@raspberrypi.com, libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 15 Nov 2021 16:12:04 +0000",
        "Message-Id": "<20211115161205.24335-7-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211115161205.24335-1-david.plowman@raspberrypi.com>",
        "References": "<20211115161205.24335-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 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>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/camera.h |  2 ++\n src/libcamera/camera.cpp   | 51 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 53 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 400a7cf0..90e9460b 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -20,6 +20,7 @@\n \n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_controls.h\"\n+#include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n \n /**\n@@ -314,6 +315,56 @@ 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) && (index < 0 || cfg.size > config_[i].size))\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",
        "v5",
        "6/7"
    ]
}