summaryrefslogtreecommitdiff
path: root/src/cam/sdl_sink.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-08-06 17:35:56 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-08-08 17:25:02 +0300
commitd4a42894b158f5f248ca94a8331bb8a40e051e3c (patch)
tree06e89995760e05e5030c3623f7709f7b6a5ae99b /src/cam/sdl_sink.cpp
parent3e0b3a10779debd7f55f594e4b2c18f1acdb2d55 (diff)
cam: sdl_sink: Support multi-planar formats
In order to prepare for NV12 support, implement support for multi-planar formats in the SDL sink. This mainly consists in passing a vector of plane data to the SDLTexture::update() function instead of a single value. 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>
Diffstat (limited to 'src/cam/sdl_sink.cpp')
-rw-r--r--src/cam/sdl_sink.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp
index 04350bd5..4ca97576 100644
--- a/src/cam/sdl_sink.cpp
+++ b/src/cam/sdl_sink.cpp
@@ -185,16 +185,23 @@ void SDLSink::renderBuffer(FrameBuffer *buffer)
{
Image *image = mappedBuffers_[buffer].get();
- /* \todo Implement support for multi-planar formats. */
- const FrameMetadata::Plane &meta = buffer->metadata().planes()[0];
+ std::vector<Span<const uint8_t>> planes;
+ unsigned int i = 0;
- Span<uint8_t> data = image->data(0);
- if (meta.bytesused > data.size())
- std::cerr << "payload size " << meta.bytesused
- << " larger than plane size " << data.size()
- << std::endl;
+ planes.reserve(buffer->metadata()->planes().size());
+
+ for (const FrameMetadata::Plane &meta : buffer->metadata().planes()) {
+ Span<uint8_t> data = image->data(i);
+ if (meta.bytesused > data.size())
+ std::cerr << "payload size " << meta.bytesused
+ << " larger than plane size " << data.size()
+ << std::endl;
+
+ planes.push_back(data);
+ i++;
+ }
- texture_->update(data);
+ texture_->update(planes);
SDL_RenderClear(renderer_);
SDL_RenderCopy(renderer_, texture_->get(), nullptr, nullptr);