Show a patch.

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

{
    "id": 24763,
    "url": "https://patchwork.libcamera.org/api/patches/24763/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24763/",
    "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": "<20251023145139.1085153-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-10-23T14:51:39",
    "name": "[v1] apps: cam: sdl_texture: Support NV21",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6cbbedd12ecdcdb1c08e700dc479bb735ae0dac2",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24763/mbox/",
    "series": [
        {
            "id": 5521,
            "url": "https://patchwork.libcamera.org/api/series/5521/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5521",
            "date": "2025-10-23T14:51:39",
            "name": "[v1] apps: cam: sdl_texture: Support NV21",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5521/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24763/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24763/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 11248C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 14:51:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4CE860865;\n\tThu, 23 Oct 2025 16:51:44 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF2E36080F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 16:51:42 +0200 (CEST)",
            "from pb-laptop.local (185.221.141.231.nat.pool.zt.hu\n\t[185.221.141.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBAFC591\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 16:49:57 +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=\"u9OT4BQa\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761230998;\n\tbh=b9n1HKHgfMtNk3fwihAZ+MZFd4u7OzRyUZuq0+/h50s=;\n\th=From:To:Subject:Date:From;\n\tb=u9OT4BQa9bugQegn+9rp4affIORSUXPFOlx1akBuaf7EOXQQoBPmdcIwsgaxxcQ9d\n\tMjtLdRx6oDuzPj2IiUBRHIYMa50A/e9HU5LQYlfwRtbT1C06roS0dZLJIqs+rMDIID\n\tgH/sC1qXwZRUEPtVVqtE6CWKc6fJKDzK+WOzqNd4=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v1] apps: cam: sdl_texture: Support NV21",
        "Date": "Thu, 23 Oct 2025 16:51:39 +0200",
        "Message-ID": "<20251023145139.1085153-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.51.1.dirty",
        "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": "SDL also supports NV21 with the same `SDL_UpdateNVTexture()`,\nso add support for it.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/apps/cam/sdl_sink.cpp        |  4 +++-\n src/apps/cam/sdl_texture_yuv.cpp | 13 +++++++++----\n src/apps/cam/sdl_texture_yuv.h   |  4 ++--\n 3 files changed, 14 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp\nindex 30cfdf0af..17a9e04b5 100644\n--- a/src/apps/cam/sdl_sink.cpp\n+++ b/src/apps/cam/sdl_sink.cpp\n@@ -112,7 +112,9 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n #endif\n #if SDL_VERSION_ATLEAST(2, 0, 16)\n \telse if (cfg.pixelFormat == libcamera::formats::NV12)\n-\t\ttexture_ = std::make_unique<SDLTextureNV12>(rect_, cfg.stride);\n+\t\ttexture_ = std::make_unique<SDLTextureNV>(rect_, SDL_PIXELFORMAT_NV12, cfg.stride);\n+\telse if (cfg.pixelFormat == libcamera::formats::NV21)\n+\t\ttexture_ = std::make_unique<SDLTextureNV>(rect_, SDL_PIXELFORMAT_NV21, cfg.stride);\n #endif\n \telse {\n \t\tstd::cerr << \"Unsupported pixel format \" << cfg.pixelFormat << std::endl;\ndiff --git a/src/apps/cam/sdl_texture_yuv.cpp b/src/apps/cam/sdl_texture_yuv.cpp\nindex bed297d28..40d1a3ae9 100644\n--- a/src/apps/cam/sdl_texture_yuv.cpp\n+++ b/src/apps/cam/sdl_texture_yuv.cpp\n@@ -7,16 +7,21 @@\n \n #include \"sdl_texture_yuv.h\"\n \n-using namespace libcamera;\n+#include <assert.h>\n \n #if SDL_VERSION_ATLEAST(2, 0, 16)\n-SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)\n-\t: SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride)\n+SDLTextureNV::SDLTextureNV(const SDL_Rect &rect, uint32_t pixelFormat, unsigned int stride)\n+\t: SDLTexture(rect, pixelFormat, stride)\n {\n+\tassert(pixelFormat == SDL_PIXELFORMAT_NV12 || pixelFormat == SDL_PIXELFORMAT_NV21);\n }\n \n-void SDLTextureNV12::update(libcamera::Span<const libcamera::Span<const uint8_t>> data)\n+void SDLTextureNV::update(libcamera::Span<const libcamera::Span<const uint8_t>> data)\n {\n+\tassert(data.size() == 2);\n+\tassert(data[0].size_bytes() == std::size_t(rect_.h) * std::size_t(stride_));\n+\tassert(data[1].size_bytes() == std::size_t(rect_.h) * std::size_t(stride_) / 2);\n+\n \tSDL_UpdateNVTexture(ptr_, nullptr, data[0].data(), stride_,\n \t\t\t    data[1].data(), stride_);\n }\ndiff --git a/src/apps/cam/sdl_texture_yuv.h b/src/apps/cam/sdl_texture_yuv.h\nindex c271f901b..8e73506d1 100644\n--- a/src/apps/cam/sdl_texture_yuv.h\n+++ b/src/apps/cam/sdl_texture_yuv.h\n@@ -10,10 +10,10 @@\n #include \"sdl_texture.h\"\n \n #if SDL_VERSION_ATLEAST(2, 0, 16)\n-class SDLTextureNV12 : public SDLTexture\n+class SDLTextureNV final : public SDLTexture\n {\n public:\n-\tSDLTextureNV12(const SDL_Rect &rect, unsigned int stride);\n+\tSDLTextureNV(const SDL_Rect &rect, uint32_t pixelFormat, unsigned int stride);\n \tvoid update(libcamera::Span<const libcamera::Span<const uint8_t>> data) override;\n };\n #endif\n",
    "prefixes": [
        "v1"
    ]
}