From 89fb1efac240451a2e463a405f4676910fc062b1 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Sat, 4 Jul 2020 17:56:25 +0900 Subject: libcamera: simple: Fill stride and frameSize at config validation Fill the stride and frameSize fields of the StreamConfiguration at configuration validation time instead of at camera configuration time. This allows applications to get the stride when trying a configuration without modifying the active configuration of the camera. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/simple/converter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/libcamera/pipeline/simple/converter.cpp') diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index e5e2f0fd..dc7c0463 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -261,4 +261,19 @@ void SimpleConverter::outputBufferReady(FrameBuffer *buffer) } } +std::tuple +SimpleConverter::strideAndFrameSize(const Size &size, + const PixelFormat &pixelFormat) +{ + V4L2DeviceFormat format = {}; + format.fourcc = m2m_->capture()->toV4L2PixelFormat(pixelFormat); + format.size = size; + + int ret = m2m_->capture()->tryFormat(&format); + if (ret < 0) + return { 0, 0 }; + + return { format.planes[0].bpl, format.planes[0].size }; +} + } /* namespace libcamera */ -- cgit v1.2.1