Show a patch.

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

{
    "id": 23305,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/23305/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23305/",
    "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": "<20250430075849.2790398-5-barnabas.pocze@ideasonboard.com>",
    "date": "2025-04-30T07:58:49",
    "name": "[v4,4/4] apps: cam: sdl_sink: Support more single-plane formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "097b3918854496c370c685e05418440392e27600",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23305/mbox/",
    "series": [
        {
            "id": 5154,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5154/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5154",
            "date": "2025-04-30T07:58:45",
            "name": "apps: cam: sdl_sink: Support more RGB and YUV formats",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5154/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23305/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23305/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 763FFBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Apr 2025 07:59:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1BFD468B24;\n\tWed, 30 Apr 2025 09:59:02 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D05568AD6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Apr 2025 09:58:54 +0200 (CEST)",
            "from pb-laptop.local (185.221.141.190.nat.pool.zt.hu\n\t[185.221.141.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C8D211AA;\n\tWed, 30 Apr 2025 09:58:48 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sEi347Mx\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745999928;\n\tbh=PdhpGN0EbYbRTlfTsxOEjIHGd4oq148CYcVEwNlvA+4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sEi347MxiKJYrK18XchZX3ZoSs2EtzHJ4oSmd9pTcWer9nVDhbgTbNV44n1D7fViT\n\tchdRv7heDulWVd2kMnjFQaCQvft9woEhRORs8GmeNWwo2vL4zkpmne5hyHLjZfJH3U\n\tNHetDfU4OmLkHhu69dZW5Kl3g1HoLQUPfO9XFd1I=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v4 4/4] apps: cam: sdl_sink: Support more single-plane\n\tformats",
        "Date": "Wed, 30 Apr 2025 09:58:49 +0200",
        "Message-ID": "<20250430075849.2790398-5-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250430075849.2790398-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20250430075849.2790398-1-barnabas.pocze@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "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": "With the newly introduced `SDLTexture1Plane` it is easy to handle\nany single-plane format that has an SDL equivalent. So use it for\nmore YUV and RGB formats.\n\nThe mapping of RGB formats is not entirely straightforward because\n`SDL_PIXELFORMAT_ZZZ...888...` defines a format where the order of\nthe components is endian dependent, while libcamera's `ZZZ...888...`\nformats are derived from the matching DRM formats, and the RGB formats\nin question are defined to be little-endian there. So the\nendian-independent `SDL_PIXELFORMAT_{ZZZ24,ZZZZ32}` are used.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/apps/cam/sdl_sink.cpp | 58 +++++++++++++++++++++++++++++++--------\n 1 file changed, 46 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp\nindex b295675dc..15087ec7a 100644\n--- a/src/apps/cam/sdl_sink.cpp\n+++ b/src/apps/cam/sdl_sink.cpp\n@@ -11,6 +11,7 @@\n #include <fcntl.h>\n #include <iomanip>\n #include <iostream>\n+#include <optional>\n #include <signal.h>\n #include <sstream>\n #include <string.h>\n@@ -32,6 +33,44 @@ using namespace libcamera;\n \n using namespace std::chrono_literals;\n \n+namespace {\n+\n+std::optional<SDL_PixelFormatEnum> singlePlaneFormatToSDL(const libcamera::PixelFormat &f)\n+{\n+\tswitch (f) {\n+\tcase libcamera::formats::RGB888:\n+\t\treturn SDL_PIXELFORMAT_BGR24;\n+\tcase libcamera::formats::BGR888:\n+\t\treturn SDL_PIXELFORMAT_RGB24;\n+\tcase libcamera::formats::ARGB8888:\n+\t\treturn SDL_PIXELFORMAT_BGRA32;\n+\tcase libcamera::formats::XRGB8888:\n+\t\treturn SDL_PIXELFORMAT_BGRX32;\n+\tcase libcamera::formats::RGBA8888:\n+\t\treturn SDL_PIXELFORMAT_ABGR32;\n+\tcase libcamera::formats::RGBX8888:\n+\t\treturn SDL_PIXELFORMAT_XBGR32;\n+\tcase libcamera::formats::ABGR8888:\n+\t\treturn SDL_PIXELFORMAT_RGBA32;\n+\tcase libcamera::formats::XBGR8888:\n+\t\treturn SDL_PIXELFORMAT_RGBX32;\n+\tcase libcamera::formats::BGRA8888:\n+\t\treturn SDL_PIXELFORMAT_ARGB32;\n+\tcase libcamera::formats::BGRX8888:\n+\t\treturn SDL_PIXELFORMAT_XRGB32;\n+\tcase libcamera::formats::YUYV:\n+\t\treturn SDL_PIXELFORMAT_YUY2;\n+\tcase libcamera::formats::UYVY:\n+\t\treturn SDL_PIXELFORMAT_UYVY;\n+\tcase libcamera::formats::YVYU:\n+\t\treturn SDL_PIXELFORMAT_YVYU;\n+\t}\n+\n+\treturn {};\n+}\n+\n+} /* namespace */\n+\n SDLSink::SDLSink()\n \t: window_(nullptr), renderer_(nullptr), rect_({}),\n \t  init_(false)\n@@ -63,25 +102,20 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n \trect_.w = cfg.size.width;\n \trect_.h = cfg.size.height;\n \n-\tswitch (cfg.pixelFormat) {\n+\tif (auto sdlFormat = singlePlaneFormatToSDL(cfg.pixelFormat))\n+\t\ttexture_ = std::make_unique<SDLTexture1Plane>(rect_, *sdlFormat, cfg.stride);\n #ifdef HAVE_LIBJPEG\n-\tcase libcamera::formats::MJPEG:\n+\telse if (cfg.pixelFormat == libcamera::formats::MJPEG)\n \t\ttexture_ = std::make_unique<SDLTextureMJPG>(rect_);\n-\t\tbreak;\n #endif\n #if SDL_VERSION_ATLEAST(2, 0, 16)\n-\tcase libcamera::formats::NV12:\n+\telse if (cfg.pixelFormat == libcamera::formats::NV12)\n \t\ttexture_ = std::make_unique<SDLTextureNV12>(rect_, cfg.stride);\n-\t\tbreak;\n #endif\n-\tcase libcamera::formats::YUYV:\n-\t\ttexture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);\n-\t\tbreak;\n-\tdefault:\n-\t\tstd::cerr << \"Unsupported pixel format \"\n-\t\t\t  << cfg.pixelFormat.toString() << std::endl;\n+\telse {\n+\t\tstd::cerr << \"Unsupported pixel format \" << cfg.pixelFormat << std::endl;\n \t\treturn -EINVAL;\n-\t};\n+\t}\n \n \treturn 0;\n }\n",
    "prefixes": [
        "v4",
        "4/4"
    ]
}