cam: sdl_sink: Fix compilation with SDL2 <2.0.16
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: 7b8df9fe6b
("cam: sdl_sink: Add NV12 texture support")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
This commit is contained in:
parent
7b8df9fe6b
commit
fe8941d7d6
3 changed files with 6 additions and 0 deletions
|
@ -67,9 +67,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
|
||||||
texture_ = std::make_unique<SDLTextureMJPG>(rect_);
|
texture_ = std::make_unique<SDLTextureMJPG>(rect_);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||||
case libcamera::formats::NV12:
|
case libcamera::formats::NV12:
|
||||||
texture_ = std::make_unique<SDLTextureNV12>(rect_, cfg.stride);
|
texture_ = std::make_unique<SDLTextureNV12>(rect_, cfg.stride);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case libcamera::formats::YUYV:
|
case libcamera::formats::YUYV:
|
||||||
texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);
|
texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||||
SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)
|
SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)
|
||||||
: SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride)
|
: SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +20,7 @@ void SDLTextureNV12::update(const std::vector<libcamera::Span<const uint8_t>> &d
|
||||||
SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,
|
SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,
|
||||||
data[1].data(), pitch_);
|
data[1].data(), pitch_);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
|
SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
|
||||||
: SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride)
|
: SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride)
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
|
|
||||||
#include "sdl_texture.h"
|
#include "sdl_texture.h"
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 16)
|
||||||
class SDLTextureNV12 : public SDLTexture
|
class SDLTextureNV12 : public SDLTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDLTextureNV12(const SDL_Rect &rect, unsigned int stride);
|
SDLTextureNV12(const SDL_Rect &rect, unsigned int stride);
|
||||||
void update(const std::vector<libcamera::Span<const uint8_t>> &data) override;
|
void update(const std::vector<libcamera::Span<const uint8_t>> &data) override;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
class SDLTextureYUYV : public SDLTexture
|
class SDLTextureYUYV : public SDLTexture
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue