Patch Detail
Show a patch.
GET /api/1.1/patches/15999/?format=api
{ "id": 15999, "url": "https://patchwork.libcamera.org/api/1.1/patches/15999/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15999/", "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": "<20220520190106.425386-5-ecurtin@redhat.com>", "date": "2022-05-20T19:01:06", "name": "[libcamera-devel,v9,4/4] cam: sdl_sink: Add MJPG support to SDL sink", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3df54e1d64e1c835d92fc57a5c907d3d6acc7301", "submitter": { "id": 101, "url": "https://patchwork.libcamera.org/api/1.1/people/101/?format=api", "name": "Eric Curtin", "email": "ecurtin@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15999/mbox/", "series": [ { "id": 3132, "url": "https://patchwork.libcamera.org/api/1.1/series/3132/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3132", "date": "2022-05-20T19:01:02", "name": "Add SDL Sink", "version": 9, "mbox": "https://patchwork.libcamera.org/series/3132/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15999/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15999/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 AA5D6C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 May 2022 19:02:13 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 72BF165673;\n\tFri, 20 May 2022 21:02:13 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C27A65670\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 May 2022 21:02:12 +0200 (CEST)", "from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n\t[209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-52-8lnyKZfANMOuqtp0sVrcxg-1; Fri, 20 May 2022 15:02:09 -0400", "by mail-wm1-f70.google.com with SMTP id\n\to11-20020a05600c510b00b003973d4d37d3so727592wms.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 May 2022 12:02:08 -0700 (PDT)", "from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\tu30-20020adfa19e000000b0020d10a249eesm3337016wru.13.2022.05.20.12.02.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 20 May 2022 12:02:05 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653073333;\n\tbh=JEZ17N5MMZQ2R9emqpby71KoEsu1ox4SILeP4cBF8VA=;\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=mFvs7ezk7mcNYyq4KzZwE5qqBbCSkNDlNjZ1mNCNn7hohUhXXCEZtTq+SxRyKhRp+\n\trW0xPdNM5O/Jq19dcv/BGFSu6DCsVAt0TLZi825TY9XNvDI2aIwm9Ez+Qy04r8jxKj\n\tzxqhh+U5rHNW3G+cqcGyP6PKXwVbe5Nvl3CaEVdQwLktHtnoBYxEs65MV3s+BLhDhQ\n\tG6h6HNuFr3Dd4KmBQDbM3TtdOxZ+E9aENh6tDpghEPYJAlybnWAqpDe0MyuitletMR\n\t0rGRhZ4ioyqoWkgFS5xXUBdNmtRIq4wI91JbR0W2Mhylo+CfiSYK9VrYCgCLS7szoU\n\tLqk+WOPzcwRQQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1653073331;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=+SXzNYyNmAeGgcWQqAMwnTK/agL9lKQH3a0+73LkUpc=;\n\tb=AGiHH8U8doqrGnpNvhysrNolBG5Qb9Z064ZsxLPYpHUav/ZMVFnXwV3Cl0tCapJHSFRcfW\n\thtH6WjQwq9c3KZAhG8GicmE/yQIOp9Cow0OIx8h62hmSzjBUKrl//vej1vyeNjeE/WspBv\n\ty/juQG6MUU/tx2Dl8l7cAXw14bT2A60=" ], "Authentication-Results": [ "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"AGiHH8U8\"; \n\tdkim-atps=neutral", "relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com" ], "X-MC-Unique": "8lnyKZfANMOuqtp0sVrcxg-1", "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=+SXzNYyNmAeGgcWQqAMwnTK/agL9lKQH3a0+73LkUpc=;\n\tb=6d5U7mz6WvL+qGXQI5/FPplLF0etD8Us/L2A363tI0RCBJPi9GtzBt5XrZN4ct7inX\n\tVKychJXTvCMT1Vk/2RAv+LW7ZC+RitcQGIXICdZAXegQcQudIxYXs7DgK/SXz97vuLEO\n\tdiFkyhL4kTU0TuSb6d7YoBOlBy8ONEnwUkWdj5oBCpTT7oRMmeiBjRGvgF8EHgl4jScR\n\tUBHXZ+zUqBBU51R0odfIf71oeeUCFzgGel0WznEkJAqocEO/6KarsPJjIQEcCg7jixBc\n\tfYfzu+KXiQtor0K3xL/NVzQTIdoCZnoMVTTXIMjZ0wTj96QYFNDmVj6O3i2KQLc8vb1e\n\tvN8g==", "X-Gm-Message-State": "AOAM530IQN0UBnEcNhki07JMsnlvmyh7Yz2SRd3WoBIJFgUwhv5pPCDn\n\t4W+B/wWloAf9h9rQpxueqOIDSa1cDArRu1dfi8gr0+h0iD+EuOxf+Z9fHymSrcQJ2uzuOihj13v\n\tJ4pMgpjcuZ9Jymq4A2wQH8iR6bs8hB30QV501uy6QkE/b03xjNgoLoeTlpCT6n8WN83DRSwD9kg\n\tqu/lUxqDaL", "X-Received": [ "by 2002:a5d:48ce:0:b0:20a:bb9b:62a3 with SMTP id\n\tp14-20020a5d48ce000000b0020abb9b62a3mr9490013wrs.307.1653073327182; \n\tFri, 20 May 2022 12:02:07 -0700 (PDT)", "by 2002:a5d:48ce:0:b0:20a:bb9b:62a3 with SMTP id\n\tp14-20020a5d48ce000000b0020abb9b62a3mr9489987wrs.307.1653073326711; \n\tFri, 20 May 2022 12:02:06 -0700 (PDT)" ], "X-Google-Smtp-Source": "ABdhPJwQBfeUH4ZYGBxWmWmcfJEszUSJlxO2rm+5ylqlEb19UMUoWG9rO1FWvf8BjSAY7v3e6Ml92w==", "To": "libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com, \n\tkieran.bingham@ideasonboard.com, jacopo@jmondi.org, javierm@redhat.com", "Date": "Fri, 20 May 2022 20:01:06 +0100", "Message-Id": "<20220520190106.425386-5-ecurtin@redhat.com>", "X-Mailer": "git-send-email 2.35.3", "In-Reply-To": "<20220520190106.425386-1-ecurtin@redhat.com>", "References": "<20220520190106.425386-1-ecurtin@redhat.com>", "MIME-Version": "1.0", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "Subject": "[libcamera-devel] [PATCH v9 4/4] cam: sdl_sink: Add MJPG support to\n\tSDL sink", "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": "Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Eric Curtin <ecurtin@redhat.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "So we have at least two supported capturing pixel formats (although\nmany possible output pixel formats thanks to SDL conversion). MJPG\nsupport only built in if SDL2_image is available, provides\ndecompression.\n\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nTested-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/cam/meson.build | 9 +++++++++\n src/cam/sdl_sink.cpp | 8 ++++++++\n src/cam/sdl_texture_mjpg.cpp | 25 +++++++++++++++++++++++++\n src/cam/sdl_texture_mjpg.h | 17 +++++++++++++++++\n 4 files changed, 59 insertions(+)\n create mode 100644 src/cam/sdl_texture_mjpg.cpp\n create mode 100644 src/cam/sdl_texture_mjpg.h", "diff": "diff --git a/src/cam/meson.build b/src/cam/meson.build\nindex 7d714152..a3c776d3 100644\n--- a/src/cam/meson.build\n+++ b/src/cam/meson.build\n@@ -33,6 +33,7 @@ if libdrm.found()\n endif\n \n libsdl2 = dependency('SDL2', required : false)\n+libsdl2_image = dependency('SDL2_image', required : false)\n \n if libsdl2.found()\n cam_cpp_args += ['-DHAVE_SDL']\n@@ -41,6 +42,13 @@ if libsdl2.found()\n 'sdl_texture.cpp',\n 'sdl_texture_yuyv.cpp'\n ])\n+\n+ if libsdl2_image.found()\n+ cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n+ cam_sources += files([\n+ 'sdl_texture_mjpg.cpp'\n+ ])\n+ endif\n endif\n \n cam = executable('cam', cam_sources,\n@@ -50,6 +58,7 @@ cam = executable('cam', cam_sources,\n libdrm,\n libevent,\n libsdl2,\n+ libsdl2_image,\n ],\n cpp_args : cam_cpp_args,\n install : true)\ndiff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\nindex 65430efb..e0dd235a 100644\n--- a/src/cam/sdl_sink.cpp\n+++ b/src/cam/sdl_sink.cpp\n@@ -21,6 +21,9 @@\n \n #include \"event_loop.h\"\n #include \"image.h\"\n+#ifdef HAVE_SDL_IMAGE\n+#include \"sdl_texture_mjpg.h\"\n+#endif\n #include \"sdl_texture_yuyv.h\"\n \n using namespace libcamera;\n@@ -59,6 +62,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n \trect_.h = cfg.size.height;\n \n \tswitch (cfg.pixelFormat) {\n+#ifdef HAVE_SDL_IMAGE\n+\tcase libcamera::formats::MJPEG:\n+\t\ttexture_ = std::make_unique<SDLTextureMJPG>(rect_);\n+\t\tbreak;\n+#endif\n \tcase libcamera::formats::YUYV:\n \t\ttexture_ = std::make_unique<SDLTextureYUYV>(rect_);\n \t\tbreak;\ndiff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\nnew file mode 100644\nindex 00000000..12f26c0b\n--- /dev/null\n+++ b/src/cam/sdl_texture_mjpg.cpp\n@@ -0,0 +1,25 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas on Board Oy\n+ *\n+ * sdl_texture_mjpg.cpp - SDL Texture MJPG\n+ */\n+\n+#include \"sdl_texture_mjpg.h\"\n+\n+#include <SDL2/SDL_image.h>\n+\n+using namespace libcamera;\n+\n+SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &sdlRect)\n+\t: SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n+{\n+}\n+\n+void SDLTextureMJPG::update(const Span<uint8_t> &data)\n+{\n+\tSDL_RWops *bufferStream = SDL_RWFromMem(data.data(), data.size());\n+\tSDL_Surface *frame = IMG_Load_RW(bufferStream, 0);\n+\tSDL_UpdateTexture(ptr_, nullptr, frame->pixels, frame->pitch);\n+\tSDL_FreeSurface(frame);\n+}\ndiff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\nnew file mode 100644\nindex 00000000..113ffb55\n--- /dev/null\n+++ b/src/cam/sdl_texture_mjpg.h\n@@ -0,0 +1,17 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas on Board Oy\n+ *\n+ * sdl_texture_mjpg.h - SDL Texture MJPG\n+ */\n+\n+#pragma once\n+\n+#include \"sdl_texture.h\"\n+\n+class SDLTextureMJPG : public SDLTexture\n+{\n+public:\n+\tSDLTextureMJPG(const SDL_Rect &sdlRect);\n+\tvoid update(const libcamera::Span<uint8_t> &data) override;\n+};\n", "prefixes": [ "libcamera-devel", "v9", "4/4" ] }