summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-26 23:45:04 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-03 00:59:01 +0200
commitad12f09a6237818cea9f2ff765ccaf8eb993d147 (patch)
tree2b9643fd4eba450a9acdb2b105c7c875d2366b38
parentcc8da6b8c215d125d4a5c51a36697609f40b9362 (diff)
libcamera: pipeline: simple: converter: Use StreamConfiguration for input configuration
Group the configuration parameters for the converter input in a StreamConfiguration instance. This makes the configure() function signature cleaner, and will allow passing additional parameters (such as stride and buffer count). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/simple/converter.cpp12
-rw-r--r--src/libcamera/pipeline/simple/converter.h2
-rw-r--r--src/libcamera/pipeline/simple/simple.cpp7
3 files changed, 13 insertions, 8 deletions
diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
index 8f54caac..6f4e41db 100644
--- a/src/libcamera/pipeline/simple/converter.cpp
+++ b/src/libcamera/pipeline/simple/converter.cpp
@@ -148,15 +148,17 @@ SimpleConverter::strideAndFrameSize(const PixelFormat &pixelFormat,
return std::make_tuple(format.planes[0].bpl, format.planes[0].size);
}
-int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,
+int SimpleConverter::configure(const StreamConfiguration &inputCfg,
const StreamConfiguration &outputCfg)
{
- V4L2DeviceFormat format;
int ret;
- V4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);
+ V4L2PixelFormat videoFormat =
+ m2m_->output()->toV4L2PixelFormat(inputCfg.pixelFormat);
+
+ V4L2DeviceFormat format;
format.fourcc = videoFormat;
- format.size = inputSize;
+ format.size = inputCfg.size;
ret = m2m_->output()->setFormat(&format);
if (ret < 0) {
@@ -165,7 +167,7 @@ int SimpleConverter::configure(PixelFormat inputFormat, const Size &inputSize,
return ret;
}
- if (format.fourcc != videoFormat || format.size != inputSize) {
+ if (format.fourcc != videoFormat || format.size != inputCfg.size) {
LOG(SimplePipeline, Error)
<< "Input format not supported";
return -EINVAL;
diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h
index dce3143c..8d2afe36 100644
--- a/src/libcamera/pipeline/simple/converter.h
+++ b/src/libcamera/pipeline/simple/converter.h
@@ -39,7 +39,7 @@ public:
std::tuple<unsigned int, unsigned int>
strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size);
- int configure(PixelFormat inputFormat, const Size &inputSize,
+ int configure(const StreamConfiguration &inputCfg,
const StreamConfiguration &outputCfg);
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 4afc5aa7..cb8309ca 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -603,8 +603,11 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
useConverter_ = config->needConversion();
if (useConverter_) {
- ret = converter_->configure(pipeConfig.pixelFormat,
- pipeConfig.captureSize, cfg);
+ StreamConfiguration inputCfg;
+ inputCfg.pixelFormat = pipeConfig.pixelFormat;
+ inputCfg.size = pipeConfig.captureSize;
+
+ ret = converter_->configure(inputCfg, cfg);
if (ret < 0) {
LOG(SimplePipeline, Error)
<< "Unable to configure converter";