@@ -61,6 +61,7 @@ public:
std::tuple<unsigned int, unsigned int>
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
+ uint32_t getPreferredInputStride(const PixelFormat &inputFormat, const Size &size);
int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
@@ -1542,6 +1542,11 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
captureFormat.fourcc = videoFormat;
captureFormat.size = pipeConfig->captureSize;
+ uint32_t requested_bpl = 0;
+ if (data->swIsp_)
+ requested_bpl = data->swIsp_->getPreferredInputStride(videoFormat.toPixelFormat(), pipeConfig->captureSize);
+ captureFormat.planes[0].bpl = requested_bpl;
+
ret = video->setFormat(&captureFormat);
if (ret)
return ret;
@@ -1561,6 +1566,13 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
return -EINVAL;
}
+ if (requested_bpl && captureFormat.planes[0].bpl != requested_bpl) {
+ LOG(SimplePipeline, Info)
+ << "Input buffer stride ignored by the driver. "
+ << "Requested " << requested_bpl
+ << ", got " << captureFormat.planes[0].bpl;
+ }
+
/* Configure the converter if needed. */
std::vector<std::reference_wrapper<const StreamConfiguration>> outputCfgs;
data->useConversion_ = config->needConversion();
@@ -103,6 +103,14 @@ Debayer::~Debayer()
* there is no valid output config
*/
+/**
+ * \fn uint32_t Debayer::getPreferredInputStride(const PixelFormat &inputFormat, const Size &size)
+ * Get the preferred input stride in bytes for the given input format and size
+ * \param[in] inputFormat The input format
+ * \param[in] size The input size (width and height in pixels)
+ * \return The preferred input stride in bytes or 0 if there is no preference
+ */
+
/**
* \fn void Debayer::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)
* \brief Process the bayer data into the requested format
@@ -46,6 +46,7 @@ public:
virtual std::tuple<unsigned int, unsigned int>
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;
+ virtual uint32_t getPreferredInputStride([[maybe_unused]] const PixelFormat &inputFormat, [[maybe_unused]] const Size &size) { return 0; }
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) = 0;
virtual int start() { return 0; }
@@ -21,6 +21,7 @@
#include <libcamera/formats.h>
+#include "libcamera/internal/formats.h"
#include "libcamera/internal/framebuffer.h"
#include "../glsl_shaders.h"
@@ -378,6 +379,12 @@ DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size
return std::make_tuple(stride, stride * size.height);
}
+uint32_t DebayerEGL::getPreferredInputStride(const PixelFormat &inputFormat, const Size &size)
+{
+ const PixelFormatInfo &info = PixelFormatInfo::info(inputFormat);
+ return info.stride(size.width, 0, 256);
+}
+
void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms)
{
/*
@@ -50,6 +50,7 @@ public:
std::vector<PixelFormat> formats(PixelFormat input) override;
std::tuple<unsigned int, unsigned int> strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) override;
+ uint32_t getPreferredInputStride(const PixelFormat &inputFormat, const Size &size) override;
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) override;
int start() override;
@@ -255,6 +255,19 @@ SoftwareIsp::strideAndFrameSize(const PixelFormat &outputFormat, const Size &siz
return debayer_->strideAndFrameSize(outputFormat, size);
}
+/**
+ * Get the preferred input stride in bytes for the given input format and size
+ * \param[in] inputFormat The input format
+ * \param[in] size The input size (width and height in pixels)
+ * \return The preferred input stride in bytes or 0 if there is no preference
+ */
+uint32_t SoftwareIsp::getPreferredInputStride(const PixelFormat &inputFormat, const Size &size)
+{
+ ASSERT(debayer_);
+
+ return debayer_->getPreferredInputStride(inputFormat, size);
+}
+
/**
* \brief Configure the SoftwareIsp object according to the passed in parameters
* \param[in] inputCfg The input configuration