[libcamera-devel] [PATCH v2 1/3] libcamera: pipeline: simple: Add stride support
Niklas Söderlund
niklas.soderlund at ragnatech.se
Fri May 22 02:55:44 CEST 2020
Hi Laurent,
Thanks for your work.
On 2020-05-19 19:55:41 +0300, Laurent Pinchart wrote:
> Report the stride when configuring the camera. The stride is retrieved
> from the capture device first, and overridden by the converter if used.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> src/libcamera/pipeline/simple/converter.cpp | 13 ++++++++-----
> src/libcamera/pipeline/simple/converter.h | 4 ++--
> src/libcamera/pipeline/simple/simple.cpp | 5 +++--
> 3 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
> index 02443e7f78ed..7a9d67b37624 100644
> --- a/src/libcamera/pipeline/simple/converter.cpp
> +++ b/src/libcamera/pipeline/simple/converter.cpp
> @@ -12,6 +12,7 @@
> #include <libcamera/buffer.h>
> #include <libcamera/geometry.h>
> #include <libcamera/signal.h>
> +#include <libcamera/stream.h>
>
> #include "libcamera/internal/log.h"
> #include "libcamera/internal/media_device.h"
> @@ -93,14 +94,14 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
> }
>
> int SimpleConverter::configure(PixelFormat inputFormat,
> - PixelFormat outputFormat, const Size &size)
> + StreamConfiguration *cfg)
> {
> V4L2DeviceFormat format;
> int ret;
>
> V4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);
> format.fourcc = videoFormat;
> - format.size = size;
> + format.size = cfg->size;
>
> ret = m2m_->output()->setFormat(&format);
> if (ret < 0) {
> @@ -109,7 +110,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,
> return ret;
> }
>
> - if (format.fourcc != videoFormat || format.size != size) {
> + if (format.fourcc != videoFormat || format.size != cfg->size) {
> LOG(SimplePipeline, Error)
> << "Input format not supported";
> return -EINVAL;
> @@ -119,7 +120,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,
> * Set the pixel format on the output, the size is identical to the
> * input as we don't support scaling.
> */
> - videoFormat = m2m_->capture()->toV4L2PixelFormat(outputFormat);
> + videoFormat = m2m_->capture()->toV4L2PixelFormat(cfg->pixelFormat);
> format.fourcc = videoFormat;
>
> ret = m2m_->capture()->setFormat(&format);
> @@ -129,12 +130,14 @@ int SimpleConverter::configure(PixelFormat inputFormat,
> return ret;
> }
>
> - if (format.fourcc != videoFormat || format.size != size) {
> + if (format.fourcc != videoFormat || format.size != cfg->size) {
> LOG(SimplePipeline, Error)
> << "Output format not supported";
> return -EINVAL;
> }
>
> + cfg->stride = format.planes[0].bpl;
> +
> return 0;
> }
>
> diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h
> index a33071fa8578..0beb96a55d5b 100644
> --- a/src/libcamera/pipeline/simple/converter.h
> +++ b/src/libcamera/pipeline/simple/converter.h
> @@ -20,6 +20,7 @@ namespace libcamera {
> class FrameBuffer;
> class MediaDevice;
> struct Size;
> +struct StreamConfiguration;
> class V4L2M2MDevice;
>
> class SimpleConverter
> @@ -33,8 +34,7 @@ public:
>
> std::vector<PixelFormat> formats(PixelFormat input);
>
> - int configure(PixelFormat inputFormat, PixelFormat outputFormat,
> - const Size &size);
> + int configure(PixelFormat inputFormat, StreamConfiguration *cfg);
> int exportBuffers(unsigned int count,
> std::vector<std::unique_ptr<FrameBuffer>> *buffers);
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index 2565190082c8..68595bc29726 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -549,12 +549,13 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
> return -EINVAL;
> }
>
> + cfg.stride = captureFormat.planes[0].bpl;
> +
> /* Configure the converter if required. */
> useConverter_ = config->needConversion();
>
> if (useConverter_) {
> - int ret = converter_->configure(pipeConfig.pixelFormat,
> - cfg.pixelFormat, cfg.size);
> + int ret = converter_->configure(pipeConfig.pixelFormat, &cfg);
> if (ret < 0) {
> LOG(SimplePipeline, Error)
> << "Unable to configure converter";
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list