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:
@@ -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 "
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user