diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-05-19 04:14:33 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-05-22 04:54:03 +0300 |
commit | 2ed5259098c0aa52bc34f6d47076729d3e8da758 (patch) | |
tree | 6224a927f996d44b6f46432b8b2ab54bba7bcf8d /src | |
parent | fd76304e005903d6fe7ad28fa537f356b1048454 (diff) |
libcamera: pipeline: simple: Add scaling support
Use the converter to implement scaling.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/simple/simple.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 686639c3..1ec8d0f7 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -75,7 +75,8 @@ public: struct Configuration { uint32_t code; PixelFormat pixelFormat; - Size size; + Size captureSize; + SizeRange outputSizes; }; Stream stream_; @@ -301,13 +302,16 @@ int SimpleCameraData::init() Configuration config; config.code = code; config.pixelFormat = pixelFormat; - config.size = format.size; + config.captureSize = format.size; if (!converter) { + config.outputSizes = config.captureSize; formats_[pixelFormat] = config; continue; } + config.outputSizes = converter->sizes(format.size); + for (PixelFormat format : converter->formats(pixelFormat)) formats_[format] = config; } @@ -440,15 +444,16 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } const SimpleCameraData::Configuration &pipeConfig = it->second; - if (cfg.size != pipeConfig.size) { + if (!pipeConfig.outputSizes.contains(cfg.size)) { LOG(SimplePipeline, Debug) << "Adjusting size from " << cfg.size.toString() - << " to " << pipeConfig.size.toString(); - cfg.size = pipeConfig.size; + << " to " << pipeConfig.captureSize.toString(); + cfg.size = pipeConfig.captureSize; status = Adjusted; } - needConversion_ = cfg.pixelFormat != pipeConfig.pixelFormat; + needConversion_ = cfg.pixelFormat != pipeConfig.pixelFormat + || cfg.size != pipeConfig.captureSize; cfg.bufferCount = 3; @@ -485,7 +490,7 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera std::inserter(formats, formats.end()), [](const auto &format) -> decltype(formats)::value_type { const PixelFormat &pixelFormat = format.first; - const Size &size = format.second.size; + const Size &size = format.second.captureSize; return { pixelFormat, { size } }; }); @@ -537,15 +542,18 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) V4L2DeviceFormat captureFormat = {}; captureFormat.fourcc = videoFormat; - captureFormat.size = cfg.size; + captureFormat.size = pipeConfig.captureSize; ret = video->setFormat(&captureFormat); if (ret) return ret; - if (captureFormat.fourcc != videoFormat || captureFormat.size != cfg.size) { + if (captureFormat.fourcc != videoFormat || + captureFormat.size != pipeConfig.captureSize) { LOG(SimplePipeline, Error) - << "Unable to configure capture in " << cfg.toString(); + << "Unable to configure capture in " + << pipeConfig.captureSize.toString() << "-" + << videoFormat.toString(); return -EINVAL; } @@ -556,7 +564,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (useConverter_) { int ret = converter_->configure(pipeConfig.pixelFormat, - cfg.size, &cfg); + pipeConfig.captureSize, &cfg); if (ret < 0) { LOG(SimplePipeline, Error) << "Unable to configure converter"; |