Show a patch.

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

{
    "id": 18036,
    "url": "https://patchwork.libcamera.org/api/patches/18036/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18036/",
    "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": "<20221216143344.8177-3-david.plowman@raspberrypi.com>",
    "date": "2022-12-16T14:33:43",
    "name": "[libcamera-devel,2/3] libcamera: camera: Fix validateColorSpaces not to loose YCbCr encodings",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8b9ad350181d37b9f4a222df78ba25b26f4851f8",
    "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/18036/mbox/",
    "series": [
        {
            "id": 3677,
            "url": "https://patchwork.libcamera.org/api/series/3677/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3677",
            "date": "2022-12-16T14:33:41",
            "name": "Fix colour spaces on Raspberry Pi",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3677/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18036/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18036/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 E0F8FC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 16 Dec 2022 14:33:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8FE06633A5;\n\tFri, 16 Dec 2022 15:33:52 +0100 (CET)",
            "from mail-ej1-x632.google.com (mail-ej1-x632.google.com\n\t[IPv6:2a00:1450:4864:20::632])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 529146339A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 16 Dec 2022 15:33:49 +0100 (CET)",
            "by mail-ej1-x632.google.com with SMTP id t17so6643456eju.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 16 Dec 2022 06:33:49 -0800 (PST)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tmb4-20020a170906eb0400b0073dd8e5a39fsm907903ejb.156.2022.12.16.06.33.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 16 Dec 2022 06:33:48 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1671201232;\n\tbh=QhaPnfHsQyN18DFbE/ITvSBem1Qe71uKP2mAuiFWaBU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HXe+g2EhEBhnHg4ohsDbp9UiHF8V0ReMB9y2xuOcMy5xqVgLtvnR4a7scyCHAUud4\n\t6jI7y0fBwcl/yG503VFUTswfdUlf/jsn13e5n+qV0LoEJHas4THz3IDVAikgZD8m/Q\n\tGTw5Wc1jj2oehVHVpnVaZVsvkTB8eb+vHJ6IOrTko7RkMkzOV1dcq3etiEs/AoQh6j\n\tKgF48Cs3egST16HLkSjGUJMsoXIKEgIehvbTSTmrd97esPGmxXI0OfofunaF1uQG5V\n\t3OSBix5pDy30o73xqaT5ktF1MYCB6+EilN3CAW9sdbZvj04iA1SLLMLZaAFJ3eHgqq\n\tnAFCnM66kG0wg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Wm7vFBxaO4oAVnSNjseltZOQRGnDDL5NMbu478QBPD8=;\n\tb=QBhq41twK/6MFRYMUOnquBBy+QRC24XZKMqj0iYGikD/1La7zjoeAOVfhE7Hfm7K+8\n\tTFX8Zl0IKOOSrsghDYI2/jUDbKmDQjd85Vssiim+OgACu/oCaVjD/9JMyu4ZzhgV2+iu\n\t1Lx3wW6depF6cP3gwdgpKh7hVhvt6k2HA+ryjuoDwisTM5YWHi6XsdZbVTdwzs67I1CM\n\tR2EpQwPa+9Xu58hoyeN3FwXcbiUKrxT2VIC088LmK/hPH0Cjo83qdOVhI1sj1zTELnAH\n\t2/JkgRk37Xf+pEadIAuhok1RPxG/VoNcZDBnMtuCVKCj0pi5ez1abIUDhkybZCYTW/8o\n\tQ4vA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"QBhq41tw\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=Wm7vFBxaO4oAVnSNjseltZOQRGnDDL5NMbu478QBPD8=;\n\tb=iBYakKgbw2erEQTDZqjXPueN4RLgCKP1DOEZRncSzKb+gzcN0z+ZkBic4uwbm79IJY\n\t2U4zJYzFrU98/wlw01+zDwXh/67lbo6VOE3QSTn9zaGII3FiGbBsCeiPWe9UUmbR1s9r\n\t5GY+JOc/XNSGcFEPBhhGyfSenzZylPNk3ZzJMQxQBWajHhd56x27E3y5KNk+Fcvru5Yz\n\tZeQ5sZepmgVQrjDsfVikemDIDwf3SMB303MZQ27/w6/sDNH0Uv7RRmsbWBQdizRBeTyY\n\t+B33cDdb1qaeVX9wmVGxNef0x1nAk3VR1D3Npe4KVOiQByeYebCWP9wkfSizmFD5GI7V\n\tR+pw==",
        "X-Gm-Message-State": "ANoB5pkrKlQniNch2Lwf50/Sj/x8F3T4Y/uAJIKjJGrn0RlB1e65C7Fg\n\tQIhSNfp2g9XZB6T/rOZnQSIFKoZbSk5s1eRB",
        "X-Google-Smtp-Source": "AA0mqf5W6TXdB9uezE/rb1smyDsDP8DBUsuMX6v+PwKHvzI9q7CAuft4KknnHEOR88HTEFJJUwXueg==",
        "X-Received": "by 2002:a17:906:a852:b0:7c0:e0d8:9500 with SMTP id\n\tdx18-20020a170906a85200b007c0e0d89500mr26884793ejb.75.1671201228669; \n\tFri, 16 Dec 2022 06:33:48 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 16 Dec 2022 14:33:43 +0000",
        "Message-Id": "<20221216143344.8177-3-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20221216143344.8177-1-david.plowman@raspberrypi.com>",
        "References": "<20221216143344.8177-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/3] libcamera: camera: Fix\n\tvalidateColorSpaces not to loose YCbCr encodings",
        "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>",
        "From": "David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "David Plowman <david.plowman@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "When sharing the same colour spaces across streams, the \"main\" stream\nmight be an RGB stream so we must stop its YCbCr information (encoding\nand range) from overwriting other YUV streams.\n\nInstead we also make a note of the largest stream with YCbCr\ninformation. We take the primaries and transfer function from the\noriginal \"main\" stream, but the YCbCr encoding and range from this\nsecond stream.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/libcamera/camera.cpp | 47 +++++++++++++++++++++++++++++++++++-----\n 1 file changed, 42 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 0da167a7..e0a5d03d 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -358,10 +358,13 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF\n \n \t/*\n \t * Set all raw streams to the Raw color space, and make a note of the\n-\t * largest non-raw stream with a defined color space (if there is one).\n+\t * largest non-raw stream with a defined color space (if there is one), and\n+\t * also the largest stream with YCbCr encoding information.\n \t */\n \tstd::optional<ColorSpace> colorSpace;\n+\tstd::optional<ColorSpace> ycbcrColorSpace;\n \tSize size;\n+\tSize ycbcrSize;\n \n \tfor (auto [i, cfg] : utils::enumerate(config_)) {\n \t\tif (!cfg.colorSpace)\n@@ -370,22 +373,56 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF\n \t\tif (cfg.colorSpace->adjust(cfg.pixelFormat))\n \t\t\tstatus = Adjusted;\n \n-\t\tif (cfg.colorSpace != ColorSpace::Raw && cfg.size > size) {\n+\t\tif (cfg.colorSpace == ColorSpace::Raw)\n+\t\t\tcontinue;\n+\n+\t\tif (cfg.size > size) {\n \t\t\tcolorSpace = cfg.colorSpace;\n \t\t\tsize = cfg.size;\n \t\t}\n+\n+\t\tif (cfg.colorSpace->ycbcrEncoding != ColorSpace::YcbcrEncoding::None &&\n+\t\t    cfg.size > ycbcrSize) {\n+\t\t\tycbcrColorSpace = cfg.colorSpace;\n+\t\t\tycbcrSize = cfg.size;\n+\t\t}\n \t}\n \n \tif (!colorSpace || !(flags & ColorSpaceFlag::StreamsShareColorSpace))\n \t\treturn status;\n \n-\t/* Make all output color spaces the same, if requested. */\n+\t/*\n+\t * Make all output color spaces the same, if requested. Note that when sharing like\n+\t * this, we copy the primaries and transfer function from the principal stream\n+\t * (the variable \"colorSpace\") but we mustn't use its ycbcrEncoding or range because\n+\t * it may be an RGB stream. So we take these fields instead from the \"ycbcrColorSpace\".\n+\t */\n \tfor (auto &cfg : config_) {\n-\t\tif (cfg.colorSpace != ColorSpace::Raw &&\n-\t\t    cfg.colorSpace != colorSpace) {\n+\t\tif (!cfg.colorSpace) {\n \t\t\tcfg.colorSpace = colorSpace;\n \t\t\tstatus = Adjusted;\n \t\t}\n+\n+\t\tif (cfg.colorSpace == ColorSpace::Raw)\n+\t\t\tcontinue;\n+\n+\t\t/* Ensure the primaries and transferFunction match the \"main\" stream. */\n+\t\tif (cfg.colorSpace->primaries != colorSpace->primaries ||\n+\t\t    cfg.colorSpace->transferFunction != colorSpace->transferFunction) {\n+\t\t\tcfg.colorSpace->primaries = colorSpace->primaries;\n+\t\t\tcfg.colorSpace->transferFunction = colorSpace->transferFunction;\n+\t\t\tstatus = Adjusted;\n+\t\t}\n+\n+\t\tif (cfg.colorSpace->ycbcrEncoding != ColorSpace::YcbcrEncoding::None) {\n+\t\t\t/* Set these from the ycbcrColorSpace (which we note must exist). */\n+\t\t\tif (ycbcrColorSpace->ycbcrEncoding != cfg.colorSpace->ycbcrEncoding ||\n+\t\t\t    ycbcrColorSpace->range != cfg.colorSpace->range) {\n+\t\t\t\tcfg.colorSpace->ycbcrEncoding = ycbcrColorSpace->ycbcrEncoding;\n+\t\t\t\tcfg.colorSpace->range = ycbcrColorSpace->range;\n+\t\t\t\tstatus = Adjusted;\n+\t\t\t}\n+\t\t}\n \t}\n \n \treturn status;\n",
    "prefixes": [
        "libcamera-devel",
        "2/3"
    ]
}