Show a patch.

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

{
    "id": 14430,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14430/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14430/",
    "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": "<20211029132343.1629-7-david.plowman@raspberrypi.com>",
    "date": "2021-10-29T13:23:42",
    "name": "[libcamera-devel,v4,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/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14430/mbox/",
    "series": [
        {
            "id": 2682,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2682/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2682",
            "date": "2021-10-29T13:23:36",
            "name": "Colour spaces",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2682/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14430/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14430/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 8D886C324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Oct 2021 13:23:58 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C0BF600C6;\n\tFri, 29 Oct 2021 15:23:58 +0200 (CEST)",
            "from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com\n\t[IPv6:2a00:1450:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DEC1600BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Oct 2021 15:23:50 +0200 (CEST)",
            "by mail-wr1-x42c.google.com with SMTP id u18so16178127wrg.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Oct 2021 06:23:50 -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\tl7sm111934wrf.31.2021.10.29.06.23.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 29 Oct 2021 06:23:49 -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=\"SBBYklli\"; 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=SBBYklli9XYf9omlnWTiEP08T698bsGvYvVGfCEVaPXWgnJ/8VTyUYNzb8ONv2xLv6\n\tAEto3UPBLW84YFuL6LTY0btFbwD3jjyVfCAMnwMYfOD8+f5TUrV3fBkBLFDG4piew5mK\n\taBoXLxu9OB5YDHopWB9hqSPRLRi6C6YGfm0UIw36DhgzqNVs2fxLVPO40tA/85w00Xqv\n\tLbuEkdeqToLk1sNiXy7p1tsYCszEnotnMSpO2Vei5cTVRk2yT9ZqSs6fIb6RfEkY/GJx\n\tsiFrY5YYzuiawwYrVwglu3kKd+zSiPjZLSnjTGkvOx8xR3pKO70G0D6KLF3AXD2hQT2r\n\t1hpg==",
        "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=j1bxCHEOwU/Gd6jwoS7L/YM+mPp9iHJbbxcT9qTepQJGtMiOaG5XsY8qSSPIxLk/TA\n\tMqwZrgPDA5ylSSe6DVCaiGMBTjleI9M3AUwEQOVaEyWeX3a9Qk5RMWlQ4mZnws6QGaPH\n\tlY9xAMR/Db6uazng9c06j7H+EXG1IbVaeERmxaX2JvO0bzbA1wBOtVu5a8LzYvAeYRAY\n\t7NNV0XgRiab1la/+3krV3ERQumg2/vbNmSCVbzouJgL7YtmVF9igLOc97Bo45XbDHPQ/\n\tEbZ03cUSoBIaw5w1bMR99inWkTiDUWcx3BExODiewFxRfSCv+WLiLBICxAF0DortM2Nf\n\tt7JA==",
        "X-Gm-Message-State": "AOAM533JTFAFVyTsr61yuY042r1+lZ1vf5KsQX7PjOko0f4di/tB+JZh\n\t4gllWlFDTyejcuOXhCbzBI2jWjdMX2IQWA==",
        "X-Google-Smtp-Source": "ABdhPJyoiacREGvgbQ4IlQpuKP1SnEw1HM6H/5ns4reyAF6sGzQxkizKhR7eJDC+Sq0yoL0kAd+Uhw==",
        "X-Received": "by 2002:a05:6000:18ce:: with SMTP id\n\tw14mr14391772wrq.230.1635513830165; \n\tFri, 29 Oct 2021 06:23:50 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 29 Oct 2021 14:23:42 +0100",
        "Message-Id": "<20211029132343.1629-7-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211029132343.1629-1-david.plowman@raspberrypi.com>",
        "References": "<20211029132343.1629-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 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",
        "v4",
        "6/7"
    ]
}