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 <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>
This commit is contained in:
Laurent Pinchart
2022-08-06 17:27:37 +03:00
parent 26c82ce136
commit 4b6e624e6a
3 changed files with 4 additions and 4 deletions

View File

@@ -68,7 +68,7 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
break;
#endif
case libcamera::formats::YUYV:
texture_ = std::make_unique<SDLTextureYUYV>(rect_);
texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);
break;
default:
std::cerr << "Unsupported pixel format "

View File

@@ -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)
{
}

View File

@@ -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<const uint8_t> data) override;
};