[PATCH v2 4/4] apps: cam: sdl_sink: Support more single-plane formats
Barnabás Pőcze
barnabas.pocze at ideasonboard.com
Fri Apr 25 12:47:03 CEST 2025
With the newly introduced `SDLTexture1Plane` it is easy to handle
any single-plane format that has an SDL equivalent. So use it for
more YUV and RGB formats.
The mapping of RGB formats is not entirely straightforward because
`SDL_PIXELFORMAT_ZZZ...888...` defines a format where the order of
the components is endian dependent, while libcamera's `ZZZ...888...`
formats are derived from the matching DRM formats, and the RGB formats
in question are defined to be little-endian there. So the
endian-independent `SDL_PIXELFORMAT_{ZZZ24,ZZZZ32}` are used.
Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>
---
src/apps/cam/sdl_sink.cpp | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp
index b295675dc..2edbb523d 100644
--- a/src/apps/cam/sdl_sink.cpp
+++ b/src/apps/cam/sdl_sink.cpp
@@ -77,6 +77,42 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
case libcamera::formats::YUYV:
texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);
break;
+ case libcamera::formats::UYVY:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_UYVY, cfg.stride);
+ break;
+ case libcamera::formats::YVYU:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YVYU, cfg.stride);
+ break;
+ case libcamera::formats::ARGB8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGRA32, cfg.stride);
+ break;
+ case libcamera::formats::XRGB8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGRX32, cfg.stride);
+ break;
+ case libcamera::formats::RGBA8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_ABGR32, cfg.stride);
+ break;
+ case libcamera::formats::RGBX8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_XBGR32, cfg.stride);
+ break;
+ case libcamera::formats::ABGR8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGBA32, cfg.stride);
+ break;
+ case libcamera::formats::XBGR8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGBX32, cfg.stride);
+ break;
+ case libcamera::formats::BGRA8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_ARGB32, cfg.stride);
+ break;
+ case libcamera::formats::BGRX8888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_XRGB32, cfg.stride);
+ break;
+ case libcamera::formats::RGB888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGR24, cfg.stride);
+ break;
+ case libcamera::formats::BGR888:
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGB24, cfg.stride);
+ break;
default:
std::cerr << "Unsupported pixel format "
<< cfg.pixelFormat.toString() << std::endl;
--
2.49.0
More information about the libcamera-devel
mailing list