summaryrefslogtreecommitdiff
path: root/src/cam/sdl_sink.cpp
AgeCommit message (Collapse)Author
2022-08-08cam: sdl_sink: Fix compilation with SDL2 <2.0.16Laurent Pinchart
The SDL_UpdateNVTexture() function, used for NV12 texture support, has been introduced in SDL2 2.0.16. Compiling against older SDL versions fails with ../src/cam/sdl_texture_yuv.cpp: In member function ‘virtual void SDLTextureNV12::update(const std::vector<libcamera::Span<const unsigned char> >&)’: ../src/cam/sdl_texture_yuv.cpp:19:2: error: ‘SDL_UpdateNVTexture’ was not declared in this scope; did you mean ‘SDL_UpdateYUVTexture’? 19 | SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_, | ^~~~~~~~~~~~~~~~~~~ | SDL_UpdateYUVTexture Fix it with conditional compilation based on the SDL version. Fixes: 7b8df9fe6b3e ("cam: sdl_sink: Add NV12 texture support") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Eric Curtin <ecurtin@redhat.com>
2022-08-08cam: sdl_sink: Add NV12 texture supportLaurent Pinchart
Extend the SDL sink with support for NV12 textures, useful on platforms that don't support packed YUYV formats. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-08-08cam: sdl_sink: Support multi-planar formatsLaurent Pinchart
In order to prepare for NV12 support, implement support for multi-planar formats in the SDL sink. This mainly consists in passing a vector of plane data to the SDLTexture::update() function instead of a single value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-08-08cam: Rename sdl_texture_yuyv.{cpp,h} to sdl_texture_yuv.{cpp,h}Laurent Pinchart
In preparation for the addition of NV12 support in the SDL sink, rename the sdl_texture_yuyv.{cpp,h} files to just "yuv". Separate sdl_texture_nv12.{cpp,h} files could be added instead, but given how short the implementation will be, grouping all YUV formats in a single file is better. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-08-08cam: sdl_texture_yuyv: Make line stride configurableLaurent Pinchart
The line stride of the texture is currently hardcoded based on the image width, which may not match the real stride. Use the stride value from the stream configuration instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Eric Curtin <ecurtin@redhat.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-07-28cam: sdl_sink: Use libjpeg over SDL2_imageEric Curtin
We were using the libjpeg functionality of SDL2_image only, instead just use libjpeg directly to reduce our dependancy count, it is a more commonly available library. Signed-off-by: Eric Curtin <ecurtin@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-23cam: sdl_sink: Add MJPG support to SDL sinkEric Curtin
So we have at least two supported capturing pixel formats (although many possible output pixel formats thanks to SDL conversion). MJPG support only built in if SDL2_image is available, provides decompression. Signed-off-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-23cam: sdl_sink: Add SDL sink with initial YUYV supportEric Curtin
This adds more portability to existing cam sinks. You can pass a YUYV camera buffer and SDL will handle the pixel buffer conversion to the display. This allows cam reference implementation to display images on VMs, Mac M1, Raspberry Pi, etc. This also enables cam reference implementation, to run as a desktop application in Wayland or X11. SDL also has support for Android and ChromeOS which has not been tested. Also tested on simpledrm Raspberry Pi 4 framebuffer successfully where existing kms sink did not work. Can also be used as kmsdrm sink. Only supports one camera stream at present. Signed-off-by: Eric Curtin <ecurtin@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>