[{"id":23023,"web_url":"https://patchwork.libcamera.org/comment/23023/","msgid":"<165283092350.2416244.6620331161436406545@Monstersaurus>","date":"2022-05-17T23:42:03","subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL sink","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Eric Curtin via libcamera-devel (2022-05-05 16:18:51)\n> So we have at least two supported capturing pixel formats (although\n> many possible output pixel formats thanks to SDL conversion). MJPG\n> support only built in if SDL2_image is available, provides\n> decompression.\n> \n> Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> ---\n>  src/cam/meson.build          |  9 +++++++++\n>  src/cam/sdl_sink.cpp         |  9 +++++++++\n>  src/cam/sdl_texture_mjpg.cpp | 18 ++++++++++++++++++\n>  src/cam/sdl_texture_mjpg.h   | 10 ++++++++++\n>  4 files changed, 46 insertions(+)\n>  create mode 100644 src/cam/sdl_texture_mjpg.cpp\n>  create mode 100644 src/cam/sdl_texture_mjpg.h\n> \n> diff --git a/src/cam/meson.build b/src/cam/meson.build\n> index 3032730b..afc0ea9f 100644\n> --- a/src/cam/meson.build\n> +++ b/src/cam/meson.build\n> @@ -41,6 +41,14 @@ if libsdl2.found()\n>          'sdl_texture.cpp',\n>          'sdl_texture_yuyv.cpp'\n>      ])\n> +\n> +    libsdl2_image = dependency('SDL2_image', required : false)\n> +    if libsdl2.found()\n> +        cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n> +        cam_sources += files([\n> +            'sdl_texture_mjpg.cpp'\n> +        ])\n> +    endif\n>  endif\n\nAll this extending complexity that is sdl specific makes me wish more\nthat this was under src/cam/sdl/ with a dedicated meson.build there, but\nthat could also be done on top.\n\nThis looks quite straightforward so far so:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  \n>  cam  = executable('cam', cam_sources,\n> @@ -49,6 +57,7 @@ cam  = executable('cam', cam_sources,\n>                        libcamera_public,\n>                        libdrm,\n>                        libsdl2,\n> +                      libsdl2_image,\n>                        libevent,\n>                    ],\n>                    cpp_args : cam_cpp_args,\n> diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> index 6fbeaf56..f15c01cb 100644\n> --- a/src/cam/sdl_sink.cpp\n> +++ b/src/cam/sdl_sink.cpp\n> @@ -19,6 +19,10 @@\n>  \n>  #include \"sdl_texture_yuyv.h\"\n>  \n> +#ifdef HAVE_SDL_IMAGE\n> +#include \"sdl_texture_mjpg.h\"\n> +#endif\n> +\n>  #include \"event_loop.h\"\n>  #include \"image.h\"\n>  \n> @@ -59,6 +63,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n>         case libcamera::formats::YUYV:\n>                 sdlTexture_ = std::make_unique<SDLTextureYUYV>(sdlRect_);\n>                 break;\n> +#ifdef HAVE_SDL_IMAGE\n> +       case libcamera::formats::MJPEG:\n> +               sdlTexture_ = std::make_unique<SDLTextureMJPG>(sdlRect_);\n> +               break;\n> +#endif\n>         default:\n>                 std::cerr << \"Unsupported pixel format \"\n>                           << cfg.pixelFormat.toString() << std::endl;\n> diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\n> new file mode 100644\n> index 00000000..636fdbea\n> --- /dev/null\n> +++ b/src/cam/sdl_texture_mjpg.cpp\n> @@ -0,0 +1,18 @@\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> +       : SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n> +{\n> +}\n> +\n> +void SDLTextureMJPG::update(const Span<uint8_t> &data)\n> +{\n> +       SDL_RWops *buffer_stream = SDL_RWFromMem(data.data(), data.size());\n> +       SDL_Surface *frame = IMG_Load_RW(buffer_stream, 0);\n> +       SDL_UpdateTexture(ptr_, NULL, frame->pixels, frame->pitch);\n> +       SDL_FreeSurface(frame);\n> +}\n> diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\n> new file mode 100644\n> index 00000000..fefaaeeb\n> --- /dev/null\n> +++ b/src/cam/sdl_texture_mjpg.h\n> @@ -0,0 +1,10 @@\n> +#pragma once\n> +\n> +#include \"sdl_texture.h\"\n> +\n> +class SDLTextureMJPG : public SDLTexture\n> +{\n> +public:\n> +       SDLTextureMJPG(const SDL_Rect &sdlRect);\n> +       void update(const libcamera::Span<uint8_t> &data) override;\n> +};\n> -- \n> 2.35.1\n>","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 00134C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 May 2022 23:42:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FBA065659;\n\tWed, 18 May 2022 01:42:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2A59E6041D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 01:42:06 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CA41D4A8;\n\tWed, 18 May 2022 01:42:05 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652830927;\n\tbh=Hkb4FJLyrpgwlxlg7z7+yCwPdpcjHOxq32W+m4+nhf4=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=IvxRV42RtRsvOpDwLWamdlCYFXvrnXeLrUIW/WI0lTCFbsfVIzVRskEa/goj5G+Mt\n\tsqqwsvR55VpOEpRlcdT79Fr6i4YB45r0zyEFqxyp6yvwygvaN1StJL54I347nu6jVn\n\t9W94OTn+b+hpS2LjTJs4ay1wRTM0ZXynWvFM0O0l4ln+bdeu9bl9gkDYGPXwiuvRD3\n\t8yVo53rigeihWbguHkaooBDyCz5HIeZxSKbwsvSmcCZrFNsJLU26aHUL5r709c+lIe\n\tXeAZdHcFfKOXRF7keDFgL1G3yS48UBSUFRxv71M0EIdtHFTtW46Ehr72WS7WRXKgZe\n\tpLae9z56saTAg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652830925;\n\tbh=Hkb4FJLyrpgwlxlg7z7+yCwPdpcjHOxq32W+m4+nhf4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=pGKfV1rzR/pnPFj+xvdLeB1EppkStRfV1Yp9qm6CsId2o7tx+Pn6YTk5j5S7SSicl\n\tYYXqO4+/trmjx3B+FXKufdAqsHagJ82NhvD2JDSY6RRCRAI1WTOEI/4nlm7TKNUTcr\n\tEwe76QC37b7FRDjSILgTwpK3H4lAC2F+osRtMyMI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"pGKfV1rz\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220505151851.2421-4-ecurtin@redhat.com>","References":"<20220505151851.2421-1-ecurtin@redhat.com>\n\t<20220505151851.2421-4-ecurtin@redhat.com>","To":"Eric Curtin <ecurtin@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Wed, 18 May 2022 00:42:03 +0100","Message-ID":"<165283092350.2416244.6620331161436406545@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL 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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23074,"web_url":"https://patchwork.libcamera.org/comment/23074/","msgid":"<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","date":"2022-05-18T19:33:22","subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL sink","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Eric,\n\nThank you for the patch.\n\nOn Wed, May 18, 2022 at 12:42:03AM +0100, Kieran Bingham via libcamera-devel wrote:\n> Quoting Eric Curtin via libcamera-devel (2022-05-05 16:18:51)\n> > So we have at least two supported capturing pixel formats (although\n> > many possible output pixel formats thanks to SDL conversion). MJPG\n> > support only built in if SDL2_image is available, provides\n> > decompression.\n> > \n> > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > ---\n> >  src/cam/meson.build          |  9 +++++++++\n> >  src/cam/sdl_sink.cpp         |  9 +++++++++\n> >  src/cam/sdl_texture_mjpg.cpp | 18 ++++++++++++++++++\n> >  src/cam/sdl_texture_mjpg.h   | 10 ++++++++++\n> >  4 files changed, 46 insertions(+)\n> >  create mode 100644 src/cam/sdl_texture_mjpg.cpp\n> >  create mode 100644 src/cam/sdl_texture_mjpg.h\n> > \n> > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > index 3032730b..afc0ea9f 100644\n> > --- a/src/cam/meson.build\n> > +++ b/src/cam/meson.build\n> > @@ -41,6 +41,14 @@ if libsdl2.found()\n> >          'sdl_texture.cpp',\n> >          'sdl_texture_yuyv.cpp'\n> >      ])\n> > +\n> > +    libsdl2_image = dependency('SDL2_image', required : false)\n> > +    if libsdl2.found()\n> > +        cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n> > +        cam_sources += files([\n> > +            'sdl_texture_mjpg.cpp'\n> > +        ])\n> > +    endif\n> >  endif\n> \n> All this extending complexity that is sdl specific makes me wish more\n> that this was under src/cam/sdl/ with a dedicated meson.build there, but\n> that could also be done on top.\n> \n> This looks quite straightforward so far so:\n> \n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> >  cam  = executable('cam', cam_sources,\n> > @@ -49,6 +57,7 @@ cam  = executable('cam', cam_sources,\n> >                        libcamera_public,\n> >                        libdrm,\n> >                        libsdl2,\n> > +                      libsdl2_image,\n> >                        libevent,\n> >                    ],\n> >                    cpp_args : cam_cpp_args,\n> > diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> > index 6fbeaf56..f15c01cb 100644\n> > --- a/src/cam/sdl_sink.cpp\n> > +++ b/src/cam/sdl_sink.cpp\n> > @@ -19,6 +19,10 @@\n> >  \n> >  #include \"sdl_texture_yuyv.h\"\n> >  \n> > +#ifdef HAVE_SDL_IMAGE\n> > +#include \"sdl_texture_mjpg.h\"\n> > +#endif\n\nI'd move this above the previous header to order them alphabetically.\n\n> > +\n> >  #include \"event_loop.h\"\n> >  #include \"image.h\"\n> >  \n> > @@ -59,6 +63,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n> >         case libcamera::formats::YUYV:\n> >                 sdlTexture_ = std::make_unique<SDLTextureYUYV>(sdlRect_);\n> >                 break;\n> > +#ifdef HAVE_SDL_IMAGE\n> > +       case libcamera::formats::MJPEG:\n> > +               sdlTexture_ = std::make_unique<SDLTextureMJPG>(sdlRect_);\n> > +               break;\n> > +#endif\n> >         default:\n> >                 std::cerr << \"Unsupported pixel format \"\n> >                           << cfg.pixelFormat.toString() << std::endl;\n> > diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\n> > new file mode 100644\n> > index 00000000..636fdbea\n> > --- /dev/null\n> > +++ b/src/cam/sdl_texture_mjpg.cpp\n> > @@ -0,0 +1,18 @@\n\nMissing SPDX tag and copyright header. Same for sdl_texture_mjpg.cpp.\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> > +       : SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n> > +{\n> > +}\n> > +\n> > +void SDLTextureMJPG::update(const Span<uint8_t> &data)\n> > +{\n> > +       SDL_RWops *buffer_stream = SDL_RWFromMem(data.data(), data.size());\n\ns/buffer_stream/bufferStream/\n\n> > +       SDL_Surface *frame = IMG_Load_RW(buffer_stream, 0);\n> > +       SDL_UpdateTexture(ptr_, NULL, frame->pixels, frame->pitch);\n\ns/NULL/nullptr/\n\n> > +       SDL_FreeSurface(frame);\n> > +}\n> > diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\n> > new file mode 100644\n> > index 00000000..fefaaeeb\n> > --- /dev/null\n> > +++ b/src/cam/sdl_texture_mjpg.h\n> > @@ -0,0 +1,10 @@\n> > +#pragma once\n> > +\n> > +#include \"sdl_texture.h\"\n> > +\n> > +class SDLTextureMJPG : public SDLTexture\n> > +{\n> > +public:\n> > +       SDLTextureMJPG(const SDL_Rect &sdlRect);\n> > +       void update(const libcamera::Span<uint8_t> &data) override;\n> > +};","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 C59CFC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 May 2022 19:33:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2CB8F65659;\n\tWed, 18 May 2022 21:33:31 +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 1405A65656\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 May 2022 21:33:30 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [45.131.31.124])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 54A1F1BBB;\n\tWed, 18 May 2022 21:33:29 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652902411;\n\tbh=qd+9EwgL7EwjMLHhgM+DdLOKYw/B4tXjGafP/QKq+QU=;\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=YfsxlykRisp6ywPHehNhi9+xkdTiqoEDRw1r/i+ZyJUQ1XMCl0IOYm2941GKgJxkR\n\tAtES0B5WsCmLrLSORp7tz/DXA+JANmvGgVIIExYOfgHHZcEjpXuqBw+gxiBOsNZ46w\n\tjfGQa4Te6/rTHcpntWwqjRwDyrvFPAN25Xm5xP7BkD56QQb3M8qDoeFSwZYN1IW/tR\n\tOckw1wPz8EjuaCKH2yArwd6j05/eZMil8vRLOX7NCOkWVq3AYoWEI73OQOEIjQPJiL\n\t6NPszWhBu/NAnC3L/72lxunzS0zIeoTOyx9eBuu/l2n5PVi1LFh2+z8zGh3xcdf+kB\n\t1BJ+eOtxy0LPw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652902409;\n\tbh=qd+9EwgL7EwjMLHhgM+DdLOKYw/B4tXjGafP/QKq+QU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=m8TDwu9FgePb7HfwlBFgsXNYYv7fAyAqxDZGaLTyPwQSnKC7bnnMzoD50gdiD6jrN\n\tShuHhJMM6k/gHiuJQIbsELl0ZTEWrb+foFNtfyD1Dq5fuoVggzHpleWlmuU5oTyvWT\n\tJlHnBksToNjasCG5KR5vQHfUO0No2k/IkdG/yPrQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"m8TDwu9F\"; dkim-atps=neutral","Date":"Wed, 18 May 2022 22:33:22 +0300","To":"Eric Curtin <ecurtin@redhat.com>","Message-ID":"<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","References":"<20220505151851.2421-1-ecurtin@redhat.com>\n\t<20220505151851.2421-4-ecurtin@redhat.com>\n\t<165283092350.2416244.6620331161436406545@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<165283092350.2416244.6620331161436406545@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23096,"web_url":"https://patchwork.libcamera.org/comment/23096/","msgid":"<165297742128.368702.2549809124593008871@Monstersaurus>","date":"2022-05-19T16:23:41","subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL sink","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2022-05-18 20:33:22)\n> Hi Eric,\n> \n> Thank you for the patch.\n> \n> On Wed, May 18, 2022 at 12:42:03AM +0100, Kieran Bingham via libcamera-devel wrote:\n> > Quoting Eric Curtin via libcamera-devel (2022-05-05 16:18:51)\n> > > So we have at least two supported capturing pixel formats (although\n> > > many possible output pixel formats thanks to SDL conversion). MJPG\n> > > support only built in if SDL2_image is available, provides\n> > > decompression.\n> > > \n> > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > ---\n> > >  src/cam/meson.build          |  9 +++++++++\n> > >  src/cam/sdl_sink.cpp         |  9 +++++++++\n> > >  src/cam/sdl_texture_mjpg.cpp | 18 ++++++++++++++++++\n> > >  src/cam/sdl_texture_mjpg.h   | 10 ++++++++++\n> > >  4 files changed, 46 insertions(+)\n> > >  create mode 100644 src/cam/sdl_texture_mjpg.cpp\n> > >  create mode 100644 src/cam/sdl_texture_mjpg.h\n> > > \n> > > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > > index 3032730b..afc0ea9f 100644\n> > > --- a/src/cam/meson.build\n> > > +++ b/src/cam/meson.build\n> > > @@ -41,6 +41,14 @@ if libsdl2.found()\n> > >          'sdl_texture.cpp',\n> > >          'sdl_texture_yuyv.cpp'\n> > >      ])\n> > > +\n> > > +    libsdl2_image = dependency('SDL2_image', required : false)\n> > > +    if libsdl2.found()\n> > > +        cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n\nOh - here it is - but somehow this didn't work or something didn't do\nthe right thing perhaps ?\n\n--\nKieran\n\n\n> > > +        cam_sources += files([\n> > > +            'sdl_texture_mjpg.cpp'\n> > > +        ])\n> > > +    endif\n> > >  endif\n> > \n> > All this extending complexity that is sdl specific makes me wish more\n> > that this was under src/cam/sdl/ with a dedicated meson.build there, but\n> > that could also be done on top.\n> > \n> > This looks quite straightforward so far so:\n> > \n> > \n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> > >  cam  = executable('cam', cam_sources,\n> > > @@ -49,6 +57,7 @@ cam  = executable('cam', cam_sources,\n> > >                        libcamera_public,\n> > >                        libdrm,\n> > >                        libsdl2,\n> > > +                      libsdl2_image,\n> > >                        libevent,\n> > >                    ],\n> > >                    cpp_args : cam_cpp_args,\n> > > diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> > > index 6fbeaf56..f15c01cb 100644\n> > > --- a/src/cam/sdl_sink.cpp\n> > > +++ b/src/cam/sdl_sink.cpp\n> > > @@ -19,6 +19,10 @@\n> > >  \n> > >  #include \"sdl_texture_yuyv.h\"\n> > >  \n> > > +#ifdef HAVE_SDL_IMAGE\n> > > +#include \"sdl_texture_mjpg.h\"\n> > > +#endif\n> \n> I'd move this above the previous header to order them alphabetically.\n> \n> > > +\n> > >  #include \"event_loop.h\"\n> > >  #include \"image.h\"\n> > >  \n> > > @@ -59,6 +63,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n> > >         case libcamera::formats::YUYV:\n> > >                 sdlTexture_ = std::make_unique<SDLTextureYUYV>(sdlRect_);\n> > >                 break;\n> > > +#ifdef HAVE_SDL_IMAGE\n> > > +       case libcamera::formats::MJPEG:\n> > > +               sdlTexture_ = std::make_unique<SDLTextureMJPG>(sdlRect_);\n> > > +               break;\n> > > +#endif\n> > >         default:\n> > >                 std::cerr << \"Unsupported pixel format \"\n> > >                           << cfg.pixelFormat.toString() << std::endl;\n> > > diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\n> > > new file mode 100644\n> > > index 00000000..636fdbea\n> > > --- /dev/null\n> > > +++ b/src/cam/sdl_texture_mjpg.cpp\n> > > @@ -0,0 +1,18 @@\n> \n> Missing SPDX tag and copyright header. Same for sdl_texture_mjpg.cpp.\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> > > +       : SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n> > > +{\n> > > +}\n> > > +\n> > > +void SDLTextureMJPG::update(const Span<uint8_t> &data)\n> > > +{\n> > > +       SDL_RWops *buffer_stream = SDL_RWFromMem(data.data(), data.size());\n> \n> s/buffer_stream/bufferStream/\n> \n> > > +       SDL_Surface *frame = IMG_Load_RW(buffer_stream, 0);\n> > > +       SDL_UpdateTexture(ptr_, NULL, frame->pixels, frame->pitch);\n> \n> s/NULL/nullptr/\n> \n> > > +       SDL_FreeSurface(frame);\n> > > +}\n> > > diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\n> > > new file mode 100644\n> > > index 00000000..fefaaeeb\n> > > --- /dev/null\n> > > +++ b/src/cam/sdl_texture_mjpg.h\n> > > @@ -0,0 +1,10 @@\n> > > +#pragma once\n> > > +\n> > > +#include \"sdl_texture.h\"\n> > > +\n> > > +class SDLTextureMJPG : public SDLTexture\n> > > +{\n> > > +public:\n> > > +       SDLTextureMJPG(const SDL_Rect &sdlRect);\n> > > +       void update(const libcamera::Span<uint8_t> &data) override;\n> > > +};\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 087C4C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 May 2022 16:23:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFFF465663;\n\tThu, 19 May 2022 18:23: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 C997760420\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 May 2022 18:23:43 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 81E336D4;\n\tThu, 19 May 2022 18:23:43 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652977424;\n\tbh=N9548w9/IIfovriD0B2k7oGaEIT+Vo0JyYhKgP4xXSc=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=e8y3Jgc1nZrQ8STgnGWZ/txtqPd3PfGejzMBie4AcQYV2SXS1uh3P1GOR7GRYwvv8\n\tLgPU+sGgky1FnmYLepS9WYWsinxOBYvxtup1vG54w2XroTTwdjdLF3KwU6LRzkKIMk\n\tSbOWQPvOj/1XNf9rhpP264RSY/sQy7vNka6RiYj0rGybTzQnhdqykZ0cUyBs3apvRE\n\th41f8jIGu5asusckKmDW5qmRr/lCWSOPcmpoyySLtkSuL0/VqCvvaCGMvSIAdv9TPJ\n\tsQQP4Q678eqQvo57FQj5bREeNW+vvufGepj1E76T+1Ba5jK9nAscmxzidjbr/mVHGg\n\tFqB5lrxbJO9eg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652977423;\n\tbh=N9548w9/IIfovriD0B2k7oGaEIT+Vo0JyYhKgP4xXSc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=SHONViNrdWiDrYYI6ZwYLOgocG8vl8lCK3/ZAVTl+w8TQmvQeNClkLL5+osMjUYAG\n\toVuzaCt7FmMW5jVau2GYsCyJcHm6ihOVHWoBvNSZZwy0MVlWHq0iLVJ/V0N1zhucKx\n\tsOqFFjbP5rQWYsB+nAQoMN/aQEvLGpXOqe1TfYXA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"SHONViNr\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","References":"<20220505151851.2421-1-ecurtin@redhat.com>\n\t<20220505151851.2421-4-ecurtin@redhat.com>\n\t<165283092350.2416244.6620331161436406545@Monstersaurus>\n\t<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","To":"Eric Curtin <ecurtin@redhat.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Thu, 19 May 2022 17:23:41 +0100","Message-ID":"<165297742128.368702.2549809124593008871@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL 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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23097,"web_url":"https://patchwork.libcamera.org/comment/23097/","msgid":"<YoZw0JOo3hYFX2bb@pendragon.ideasonboard.com>","date":"2022-05-19T16:31:12","subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL sink","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Two more comments.\n\nOn Wed, May 18, 2022 at 10:33:22PM +0300, Laurent Pinchart via libcamera-devel wrote:\n> Hi Eric,\n> \n> Thank you for the patch.\n> \n> On Wed, May 18, 2022 at 12:42:03AM +0100, Kieran Bingham via libcamera-devel wrote:\n> > Quoting Eric Curtin via libcamera-devel (2022-05-05 16:18:51)\n> > > So we have at least two supported capturing pixel formats (although\n> > > many possible output pixel formats thanks to SDL conversion). MJPG\n> > > support only built in if SDL2_image is available, provides\n> > > decompression.\n> > > \n> > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > ---\n> > >  src/cam/meson.build          |  9 +++++++++\n> > >  src/cam/sdl_sink.cpp         |  9 +++++++++\n> > >  src/cam/sdl_texture_mjpg.cpp | 18 ++++++++++++++++++\n> > >  src/cam/sdl_texture_mjpg.h   | 10 ++++++++++\n> > >  4 files changed, 46 insertions(+)\n> > >  create mode 100644 src/cam/sdl_texture_mjpg.cpp\n> > >  create mode 100644 src/cam/sdl_texture_mjpg.h\n> > > \n> > > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > > index 3032730b..afc0ea9f 100644\n> > > --- a/src/cam/meson.build\n> > > +++ b/src/cam/meson.build\n> > > @@ -41,6 +41,14 @@ if libsdl2.found()\n> > >          'sdl_texture.cpp',\n> > >          'sdl_texture_yuyv.cpp'\n> > >      ])\n> > > +\n> > > +    libsdl2_image = dependency('SDL2_image', required : false)\n> > > +    if libsdl2.found()\n\nThis should be libsdl2_image.\n\n> > > +        cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n> > > +        cam_sources += files([\n> > > +            'sdl_texture_mjpg.cpp'\n> > > +        ])\n> > > +    endif\n> > >  endif\n> > \n> > All this extending complexity that is sdl specific makes me wish more\n> > that this was under src/cam/sdl/ with a dedicated meson.build there, but\n> > that could also be done on top.\n> > \n> > This looks quite straightforward so far so:\n> > \n> > \n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> > >  cam  = executable('cam', cam_sources,\n> > > @@ -49,6 +57,7 @@ cam  = executable('cam', cam_sources,\n> > >                        libcamera_public,\n> > >                        libdrm,\n> > >                        libsdl2,\n> > > +                      libsdl2_image,\n\nIf libsdl2 isn't found, then libsdl2_image won't be assigned, and meson\nwill throw an error here:\n\nsrc/cam/meson.build:55:0: ERROR: Unknown variable \"libsdl2_image\".\n\n> > >                        libevent,\n> > >                    ],\n> > >                    cpp_args : cam_cpp_args,\n> > > diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> > > index 6fbeaf56..f15c01cb 100644\n> > > --- a/src/cam/sdl_sink.cpp\n> > > +++ b/src/cam/sdl_sink.cpp\n> > > @@ -19,6 +19,10 @@\n> > >  \n> > >  #include \"sdl_texture_yuyv.h\"\n> > >  \n> > > +#ifdef HAVE_SDL_IMAGE\n> > > +#include \"sdl_texture_mjpg.h\"\n> > > +#endif\n> \n> I'd move this above the previous header to order them alphabetically.\n> \n> > > +\n> > >  #include \"event_loop.h\"\n> > >  #include \"image.h\"\n> > >  \n> > > @@ -59,6 +63,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n> > >         case libcamera::formats::YUYV:\n> > >                 sdlTexture_ = std::make_unique<SDLTextureYUYV>(sdlRect_);\n> > >                 break;\n> > > +#ifdef HAVE_SDL_IMAGE\n> > > +       case libcamera::formats::MJPEG:\n> > > +               sdlTexture_ = std::make_unique<SDLTextureMJPG>(sdlRect_);\n> > > +               break;\n> > > +#endif\n> > >         default:\n> > >                 std::cerr << \"Unsupported pixel format \"\n> > >                           << cfg.pixelFormat.toString() << std::endl;\n> > > diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\n> > > new file mode 100644\n> > > index 00000000..636fdbea\n> > > --- /dev/null\n> > > +++ b/src/cam/sdl_texture_mjpg.cpp\n> > > @@ -0,0 +1,18 @@\n> \n> Missing SPDX tag and copyright header. Same for sdl_texture_mjpg.cpp.\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> > > +       : SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n> > > +{\n> > > +}\n> > > +\n> > > +void SDLTextureMJPG::update(const Span<uint8_t> &data)\n> > > +{\n> > > +       SDL_RWops *buffer_stream = SDL_RWFromMem(data.data(), data.size());\n> \n> s/buffer_stream/bufferStream/\n> \n> > > +       SDL_Surface *frame = IMG_Load_RW(buffer_stream, 0);\n> > > +       SDL_UpdateTexture(ptr_, NULL, frame->pixels, frame->pitch);\n> \n> s/NULL/nullptr/\n> \n> > > +       SDL_FreeSurface(frame);\n> > > +}\n> > > diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\n> > > new file mode 100644\n> > > index 00000000..fefaaeeb\n> > > --- /dev/null\n> > > +++ b/src/cam/sdl_texture_mjpg.h\n> > > @@ -0,0 +1,10 @@\n> > > +#pragma once\n> > > +\n> > > +#include \"sdl_texture.h\"\n> > > +\n> > > +class SDLTextureMJPG : public SDLTexture\n> > > +{\n> > > +public:\n> > > +       SDLTextureMJPG(const SDL_Rect &sdlRect);\n> > > +       void update(const libcamera::Span<uint8_t> &data) override;\n> > > +};","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 16C97C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 May 2022 16:31:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1412265663;\n\tThu, 19 May 2022 18:31:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F1F3660420\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 May 2022 18:31:19 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [45.131.31.124])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EC916D4;\n\tThu, 19 May 2022 18:31:19 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652977882;\n\tbh=UfMaKAC9lRxrbzEFFn4sI5UQENTMa7YgfQ+pOS4s1eI=;\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:\n\tFrom;\n\tb=dNYQ74ZnLrjtG5PlZxB1o1sxLHfhqkWFaocxdpHts4sqgvBTIo9eoq7v3cqiDZv28\n\tMwSeRMw2owWHEdmbEK+APlx+CKGRaEmGlp/LcmqO0WwNoDq3jX6ibIllG64n4SUkrK\n\tH/dd3UYcROXupsXccNkGyRv1JDd7NQziR925YiYhgQ3U2DDQmjtk0TNK58UlCKmAxG\n\ttNfg5MkP+cGbpQoY+0SMvZigM9Yfg7thNLjbTx+8KbzlzWF+AN6bH4qlvMZgz6k9wz\n\txkW14Z4n6bkTgN2NwYTvK61soQxUgOqE8v+oEsOSmTLvy9Jow5YI8xAXMtzuDUoXYh\n\tL957TiZVmvUOA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652977879;\n\tbh=UfMaKAC9lRxrbzEFFn4sI5UQENTMa7YgfQ+pOS4s1eI=;\n\th=Date:From:To:Subject:References:In-Reply-To:From;\n\tb=hUyYjKAdeIfmWk96UhEQ9O5SuaZvi6huIj6e/4eJbLOJEKf68NuaN0MQslNLlcqal\n\t/KfszwLIbqeTXvbT35OVXLzJlEwv0d+26vbfpG8s9Z1a9BJltCZ3c4QLZhoXZYXewo\n\t9WqFu1c5as/Iyn9UvfZh12Ww/ML/lljfDS+DMPQE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hUyYjKAd\"; dkim-atps=neutral","Date":"Thu, 19 May 2022 19:31:12 +0300","To":"Eric Curtin <ecurtin@redhat.com>, libcamera-devel@lists.libcamera.org","Message-ID":"<YoZw0JOo3hYFX2bb@pendragon.ideasonboard.com>","References":"<20220505151851.2421-1-ecurtin@redhat.com>\n\t<20220505151851.2421-4-ecurtin@redhat.com>\n\t<165283092350.2416244.6620331161436406545@Monstersaurus>\n\t<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23098,"web_url":"https://patchwork.libcamera.org/comment/23098/","msgid":"<YoZyv3AYBEjVjsQ0@pendragon.ideasonboard.com>","date":"2022-05-19T16:39:27","subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL sink","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Thu, May 19, 2022 at 05:23:41PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2022-05-18 20:33:22)\n> > Hi Eric,\n> > \n> > Thank you for the patch.\n> > \n> > On Wed, May 18, 2022 at 12:42:03AM +0100, Kieran Bingham via libcamera-devel wrote:\n> > > Quoting Eric Curtin via libcamera-devel (2022-05-05 16:18:51)\n> > > > So we have at least two supported capturing pixel formats (although\n> > > > many possible output pixel formats thanks to SDL conversion). MJPG\n> > > > support only built in if SDL2_image is available, provides\n> > > > decompression.\n> > > > \n> > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > > ---\n> > > >  src/cam/meson.build          |  9 +++++++++\n> > > >  src/cam/sdl_sink.cpp         |  9 +++++++++\n> > > >  src/cam/sdl_texture_mjpg.cpp | 18 ++++++++++++++++++\n> > > >  src/cam/sdl_texture_mjpg.h   | 10 ++++++++++\n> > > >  4 files changed, 46 insertions(+)\n> > > >  create mode 100644 src/cam/sdl_texture_mjpg.cpp\n> > > >  create mode 100644 src/cam/sdl_texture_mjpg.h\n> > > > \n> > > > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > > > index 3032730b..afc0ea9f 100644\n> > > > --- a/src/cam/meson.build\n> > > > +++ b/src/cam/meson.build\n> > > > @@ -41,6 +41,14 @@ if libsdl2.found()\n> > > >          'sdl_texture.cpp',\n> > > >          'sdl_texture_yuyv.cpp'\n> > > >      ])\n> > > > +\n> > > > +    libsdl2_image = dependency('SDL2_image', required : false)\n> > > > +    if libsdl2.found()\n> > > > +        cam_cpp_args += ['-DHAVE_SDL_IMAGE']\n> \n> Oh - here it is - but somehow this didn't work or something didn't do\n> the right thing perhaps ?\n\nI haven't noticed your issue report before sending mine :-)\n\nThis could be fixed with\n\nlibsdl2 = dependency('SDL2', required : false)\nlibsdl2_image = dependency('SDL2_image', required : false)\n\nif libsdl2.found()\n    cam_cpp_args += ['-DHAVE_SDL']\n    cam_sources += files([\n        'sdl_sink.cpp',\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\nendif\n\n> > > > +        cam_sources += files([\n> > > > +            'sdl_texture_mjpg.cpp'\n> > > > +        ])\n> > > > +    endif\n> > > >  endif\n> > > \n> > > All this extending complexity that is sdl specific makes me wish more\n> > > that this was under src/cam/sdl/ with a dedicated meson.build there, but\n> > > that could also be done on top.\n> > > \n> > > This looks quite straightforward so far so:\n> > > \n> > > \n> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > \n> > > >  cam  = executable('cam', cam_sources,\n> > > > @@ -49,6 +57,7 @@ cam  = executable('cam', cam_sources,\n> > > >                        libcamera_public,\n> > > >                        libdrm,\n> > > >                        libsdl2,\n> > > > +                      libsdl2_image,\n> > > >                        libevent,\n> > > >                    ],\n> > > >                    cpp_args : cam_cpp_args,\n> > > > diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> > > > index 6fbeaf56..f15c01cb 100644\n> > > > --- a/src/cam/sdl_sink.cpp\n> > > > +++ b/src/cam/sdl_sink.cpp\n> > > > @@ -19,6 +19,10 @@\n> > > >  \n> > > >  #include \"sdl_texture_yuyv.h\"\n> > > >  \n> > > > +#ifdef HAVE_SDL_IMAGE\n> > > > +#include \"sdl_texture_mjpg.h\"\n> > > > +#endif\n> > \n> > I'd move this above the previous header to order them alphabetically.\n> > \n> > > > +\n> > > >  #include \"event_loop.h\"\n> > > >  #include \"image.h\"\n> > > >  \n> > > > @@ -59,6 +63,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n> > > >         case libcamera::formats::YUYV:\n> > > >                 sdlTexture_ = std::make_unique<SDLTextureYUYV>(sdlRect_);\n> > > >                 break;\n> > > > +#ifdef HAVE_SDL_IMAGE\n> > > > +       case libcamera::formats::MJPEG:\n> > > > +               sdlTexture_ = std::make_unique<SDLTextureMJPG>(sdlRect_);\n> > > > +               break;\n> > > > +#endif\n> > > >         default:\n> > > >                 std::cerr << \"Unsupported pixel format \"\n> > > >                           << cfg.pixelFormat.toString() << std::endl;\n> > > > diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp\n> > > > new file mode 100644\n> > > > index 00000000..636fdbea\n> > > > --- /dev/null\n> > > > +++ b/src/cam/sdl_texture_mjpg.cpp\n> > > > @@ -0,0 +1,18 @@\n> > \n> > Missing SPDX tag and copyright header. Same for sdl_texture_mjpg.cpp.\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> > > > +       : SDLTexture(sdlRect, SDL_PIXELFORMAT_RGB24, 0)\n> > > > +{\n> > > > +}\n> > > > +\n> > > > +void SDLTextureMJPG::update(const Span<uint8_t> &data)\n> > > > +{\n> > > > +       SDL_RWops *buffer_stream = SDL_RWFromMem(data.data(), data.size());\n> > \n> > s/buffer_stream/bufferStream/\n> > \n> > > > +       SDL_Surface *frame = IMG_Load_RW(buffer_stream, 0);\n> > > > +       SDL_UpdateTexture(ptr_, NULL, frame->pixels, frame->pitch);\n> > \n> > s/NULL/nullptr/\n> > \n> > > > +       SDL_FreeSurface(frame);\n> > > > +}\n> > > > diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h\n> > > > new file mode 100644\n> > > > index 00000000..fefaaeeb\n> > > > --- /dev/null\n> > > > +++ b/src/cam/sdl_texture_mjpg.h\n> > > > @@ -0,0 +1,10 @@\n> > > > +#pragma once\n> > > > +\n> > > > +#include \"sdl_texture.h\"\n> > > > +\n> > > > +class SDLTextureMJPG : public SDLTexture\n> > > > +{\n> > > > +public:\n> > > > +       SDLTextureMJPG(const SDL_Rect &sdlRect);\n> > > > +       void update(const libcamera::Span<uint8_t> &data) override;\n> > > > +};","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 7E549C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 May 2022 16:39:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B80F265663;\n\tThu, 19 May 2022 18:39:35 +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 15B8360420\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 May 2022 18:39:34 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [45.131.31.124])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 62CD46E0;\n\tThu, 19 May 2022 18:39:33 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652978375;\n\tbh=3ZHIojJ+Vbu3xRmRMentO4Jlm0AFcuWVavnUE/BjJSs=;\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=aRkHH4HL9EPLauxO5o3R/+JRchLZ61IgsoqwrlacYQNc0QWm/vbrh548lfwkovJho\n\tjNJ1Tkt8lI8PlHeztT2bhtkpUUQtqwbHzTCppbeFHzPe8+qY7jXA9k4QhRanwkQ5aJ\n\t4hDCfRpohQNVT1ktGs4Qh0r4Q6I5tn/f3FviPI6nXMHYEdHQR9eb9/BgKhxeIZVP+/\n\tZqg1YXAEPmwr7osx50iSXkiXkYBccZf/oV+OSotPWEx/o5ZetoDli9yF5dkxG8INwP\n\tXx99y6MAYDxcMu1StI6S7PROiQt5eupR+6NTOzt+HTw36r9yq1obZMOonSAN7N8f2O\n\twL4gaDETZnMGA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652978373;\n\tbh=3ZHIojJ+Vbu3xRmRMentO4Jlm0AFcuWVavnUE/BjJSs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XDfYDHxSYatWaOSEjsVtkbAgOqUrYe8Gq+wrq2Nj3NGG2eD+WfEtFFu254hNQiybG\n\tN5UxPtHkk2B4AajwD0Hdxq+d8pOX5p/eCdi9aSW25yLwtu59ISnhY88ubthrmmlBYL\n\tfeF2mK8J2kTvugGYg7xCj8KBrxZxZeEfV265f+Ks="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XDfYDHxS\"; dkim-atps=neutral","Date":"Thu, 19 May 2022 19:39:27 +0300","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YoZyv3AYBEjVjsQ0@pendragon.ideasonboard.com>","References":"<20220505151851.2421-1-ecurtin@redhat.com>\n\t<20220505151851.2421-4-ecurtin@redhat.com>\n\t<165283092350.2416244.6620331161436406545@Monstersaurus>\n\t<YoVKAoXX2kU3mhnp@pendragon.ideasonboard.com>\n\t<165297742128.368702.2549809124593008871@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<165297742128.368702.2549809124593008871@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v8 4/4] cam: sdl_sink: Add MJPG\n\tsupport to SDL 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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]