From 4b6e624e6a825aebf171dc1cbe6f2d8d6dde867e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 6 Aug 2022 17:27:37 +0300 Subject: cam: sdl_texture_yuyv: Make line stride configurable 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin Tested-by: Kieran Bingham --- src/cam/sdl_sink.cpp | 2 +- src/cam/sdl_texture_yuyv.cpp | 4 ++-- src/cam/sdl_texture_yuyv.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index 19fdfd6d..a59d0751 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -68,7 +68,7 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config) break; #endif case libcamera::formats::YUYV: - texture_ = std::make_unique(rect_); + texture_ = std::make_unique(rect_, cfg.stride); break; default: std::cerr << "Unsupported pixel format " diff --git a/src/cam/sdl_texture_yuyv.cpp b/src/cam/sdl_texture_yuyv.cpp index 637c0900..cb51fb0e 100644 --- a/src/cam/sdl_texture_yuyv.cpp +++ b/src/cam/sdl_texture_yuyv.cpp @@ -9,8 +9,8 @@ using namespace libcamera; -SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect) - : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, 4 * ((rect.w + 1) / 2)) +SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride) + : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride) { } diff --git a/src/cam/sdl_texture_yuyv.h b/src/cam/sdl_texture_yuyv.h index 529a72d6..81e51381 100644 --- a/src/cam/sdl_texture_yuyv.h +++ b/src/cam/sdl_texture_yuyv.h @@ -12,6 +12,6 @@ class SDLTextureYUYV : public SDLTexture { public: - SDLTextureYUYV(const SDL_Rect &rect); + SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride); void update(libcamera::Span data) override; }; -- cgit v1.2.1