{"id":16535,"url":"https://patchwork.libcamera.org/api/1.1/patches/16535/?format=json","web_url":"https://patchwork.libcamera.org/patch/16535/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220704180719.GA30565@amd>","date":"2022-07-04T18:07:20","name":"[libcamera-devel] JPEG support for libcamera","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"6ca56b67f11ff9ac144b1a6705165f3951287468","submitter":{"id":49,"url":"https://patchwork.libcamera.org/api/1.1/people/49/?format=json","name":"Pavel Machek","email":"pavel@ucw.cz"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16535/mbox/","series":[{"id":3248,"url":"https://patchwork.libcamera.org/api/1.1/series/3248/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3248","date":"2022-07-04T18:07:20","name":"[libcamera-devel] JPEG support for libcamera","version":1,"mbox":"https://patchwork.libcamera.org/series/3248/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16535/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16535/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 E6B21BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  4 Jul 2022 18:07:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 470A06564A;\n\tMon,  4 Jul 2022 20:07:23 +0200 (CEST)","from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B01961FB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  4 Jul 2022 20:07:21 +0200 (CEST)","by jabberwock.ucw.cz (Postfix, from userid 1017)\n\tid C046D1C0D7F; Mon,  4 Jul 2022 20:07:20 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656958043;\n\tbh=jRJzs6mlEQxfLdqdeAP6Msdx90cfLMjuKjIIN7QIqko=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=WblOXq7LJJX1bQBm5i77QHR2ZNQcBB1tIlpGjTdSre6nuiM4sVPiexvDGRiw8BO70\n\tAV7FjBcaOarxhL9N/WDMceuHFszdCHSGZrLgyG6lvmF/5t8y/iQ+l8D2r35H3eibi5\n\taMnGmHCh9l6THlDaD4G3KLedHDOWqJTuLORUxHbHc8RlChv3LBqtCxw781Vch1+05g\n\tyMfQ4ZTGHlXiZXCmUGivotsFSezIKsEBXDV8qHD5g2e023ffONPYb895EAdh7akMXT\n\tAIVPRUyEOGlaeHZdf2kAetNhonQPCRSz2xOqSL+7iE0qOskNp8eMQz+yDfUxY/Z8iT\n\tolzWrpZkxc5cw==","Date":"Mon, 4 Jul 2022 20:07:20 +0200","To":"Rafael Diniz <rafael@riseup.net>","Message-ID":"<20220704180719.GA30565@amd>","References":"<YrBXWTE+o3sKykj9@pendragon.ideasonboard.com>\n\t<20220620120711.GA12286@duo.ucw.cz>\n\t<YrG2JHFwydqmvhQ+@pendragon.ideasonboard.com>\n\t<20220701211120.GB18840@duo.ucw.cz>\n\t<279b87a6-2209-e4d1-6342-12253258b59f@riseup.net>\n\t<YsGe984b7/ShqZXw@pendragon.ideasonboard.com>\n\t<9a63e90b-5da6-2915-462e-70b2f61d1867@riseup.net>\n\t<20220703155800.GA11658@amd>\n\t<70821a87-8ea5-1583-daa3-ce1531977ce7@riseup.net>\n\t<d37fdb5f-79a6-56be-274f-12a5852836fc@riseup.net>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"9amGYk9869ThD9tj\"","Content-Disposition":"inline","In-Reply-To":"<d37fdb5f-79a6-56be-274f-12a5852836fc@riseup.net>","User-Agent":"Mutt/1.5.23 (2014-03-12)","Subject":"[libcamera-devel] JPEG support for libcamera","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":"Pavel Machek via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Pavel Machek <pavel@ucw.cz>","Cc":"martijn@brixit.nl, libcamera-devel@lists.libcamera.org, jozef@mlich.cz","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"JPEG is very similar to MJPEG format (AFAICT, it may contain extra\nEXIF headers). Add support for it. Tested with PinePhone and command\nline cam utility.\n\nSigned-off-by: Pavel Machek <pavel@ucw.cz>","diff":"diff --git a/include/linux/drm_fourcc.h b/include/linux/drm_fourcc.h\nindex ea11dcb4..b30a705d 100644\n--- a/include/linux/drm_fourcc.h\n+++ b/include/linux/drm_fourcc.h\n@@ -352,6 +352,7 @@ extern \"C\" {\n \n /* Compressed formats */\n #define DRM_FORMAT_MJPEG\tfourcc_code('M', 'J', 'P', 'G') /* Motion-JPEG */\n+#define DRM_FORMAT_JPEG\tfourcc_code('J', 'P', 'E', 'G') /* JFIF JPEG */\n \n /*\n  * Bayer formats\ndiff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\nindex f8e3e95d..673bd642 100644\n--- a/src/cam/sdl_sink.cpp\n+++ b/src/cam/sdl_sink.cpp\n@@ -63,6 +63,7 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n \n \tswitch (cfg.pixelFormat) {\n #ifdef HAVE_SDL_IMAGE\n+\tcase libcamera::formats::JPEG:\n \tcase libcamera::formats::MJPEG:\n \t\ttexture_ = std::make_unique<SDLTextureMJPG>(rect_);\n \t\tbreak;\ndiff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex 3f242286..fd5689d9 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -80,6 +80,7 @@ bare_structure_from_format(const PixelFormat &format)\n \t\t\t\t\t gst_video_format_to_string(gst_format), nullptr);\n \n \tswitch (format) {\n+\tcase formats::JPEG:\n \tcase formats::MJPEG:\n \t\treturn gst_structure_new_empty(\"image/jpeg\");\n \tdefault:\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 283ecb3d..c5e97198 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -944,6 +944,19 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t} },\n \n \t/* Compressed formats. */\n+\t{ formats::JPEG, {\n+\t\t.name = \"JPEG\",\n+\t\t.format = formats::JPEG,\n+\t\t.v4l2Formats = {\n+\t\t\t.single = V4L2PixelFormat(V4L2_PIX_FMT_JPEG),\n+\t\t\t.multi = V4L2PixelFormat(),\n+\t\t},\n+\t\t.bitsPerPixel = 0,\n+\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n+\t\t.packed = false,\n+\t\t.pixelsPerGroup = 1,\n+\t\t.planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n+\t} },\n \t{ formats::MJPEG, {\n \t\t.name = \"MJPEG\",\n \t\t.format = formats::MJPEG,\ndiff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml\nindex 7dda0132..6b931c34 100644\n--- a/src/libcamera/formats.yaml\n+++ b/src/libcamera/formats.yaml\n@@ -76,6 +76,8 @@ formats:\n   - YVU444:\n       fourcc: DRM_FORMAT_YVU444\n \n+  - JPEG:\n+      fourcc: DRM_FORMAT_JPEG\n   - MJPEG:\n       fourcc: DRM_FORMAT_MJPEG\n \ndiff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\nindex 58fc4e9d..82dfbd1e 100644\n--- a/src/libcamera/v4l2_pixelformat.cpp\n+++ b/src/libcamera/v4l2_pixelformat.cpp\n@@ -183,6 +183,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{\n \t/* Compressed formats. */\n \t{ V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),\n \t\t{ formats::MJPEG, \"Motion-JPEG\" } },\n+\t{ V4L2PixelFormat(V4L2_PIX_FMT_JPEG),\n+\t\t{ formats::JPEG, \"JPEG\" } },\n };\n \n } /* namespace */\n","prefixes":["libcamera-devel"]}