@@ -34,6 +34,7 @@ if libsdl2.found()
cam_sources += files([
'sdl_sink.cpp',
'sdl_texture.cpp',
+ 'sdl_texture_1plane.cpp',
'sdl_texture_yuv.cpp',
])
@@ -22,6 +22,7 @@
#include "../common/event_loop.h"
#include "../common/image.h"
+#include "sdl_texture_1plane.h"
#ifdef HAVE_LIBJPEG
#include "sdl_texture_mjpg.h"
#endif
@@ -74,7 +75,7 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
break;
#endif
case libcamera::formats::YUYV:
- texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);
+ texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);
break;
default:
std::cerr << "Unsupported pixel format "
new file mode 100644
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2025, Ideas on Board Oy
+ *
+ * SDL single plane textures
+ */
+
+#include "sdl_texture_1plane.h"
+
+#include <assert.h>
+
+void SDLTexture1Plane::update(libcamera::Span<const libcamera::Span<const uint8_t>> data)
+{
+ assert(data.size() == 1);
+ assert(data[0].size_bytes() == std::size_t(rect_.h) * std::size_t(stride_));
+ SDL_UpdateTexture(ptr_, nullptr, data[0].data(), stride_);
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2025, Ideas on Board Oy
+ *
+ * SDL single plane textures
+ */
+
+#pragma once
+
+#include "sdl_texture.h"
+
+class SDLTexture1Plane final : public SDLTexture
+{
+public:
+ using SDLTexture::SDLTexture;
+
+ void update(libcamera::Span<const libcamera::Span<const uint8_t>> data) override;
+};
@@ -21,13 +21,3 @@ void SDLTextureNV12::update(libcamera::Span<const libcamera::Span<const uint8_t>
data[1].data(), stride_);
}
#endif
-
-SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
- : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride)
-{
-}
-
-void SDLTextureYUYV::update(libcamera::Span<const libcamera::Span<const uint8_t>> data)
-{
- SDL_UpdateTexture(ptr_, nullptr, data[0].data(), stride_);
-}
@@ -17,10 +17,3 @@ public:
void update(libcamera::Span<const libcamera::Span<const uint8_t>> data) override;
};
#endif
-
-class SDLTextureYUYV : public SDLTexture
-{
-public:
- SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride);
- void update(libcamera::Span<const libcamera::Span<const uint8_t>> data) override;
-};