summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-24 17:54:07 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-03 00:59:25 +0200
commite07cca2fbf1ae20c2eed1367eab1f691da440cee (patch)
treed11f7c820ecadc2a71b19104d5c6ef5fb9418bbe /src
parent23c60fcdff048863b372d9974bac85c3b73b8c71 (diff)
libcamera: pipeline: simple: Add output formats to Configuration
Store the list of converter output formats in the Configuration structure, to be used to implement multi-stream support. As the Configuration structure grows bigger, avoid duplicating it in the formats_ map for each supported pixel format by storing it in a configs_ vector instead, and storing pointers only in the map. 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>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/simple/simple.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 9c32ad02..d923db0c 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -159,6 +159,7 @@ public:
uint32_t code;
PixelFormat captureFormat;
Size captureSize;
+ std::vector<PixelFormat> outputFormats;
SizeRange outputSizes;
};
@@ -167,7 +168,8 @@ public:
std::list<Entity> entities_;
V4L2VideoDevice *video_;
- std::map<PixelFormat, Configuration> formats_;
+ std::vector<Configuration> configs_;
+ std::map<PixelFormat, const Configuration *> formats_;
};
class SimpleCameraConfiguration : public CameraConfiguration
@@ -371,13 +373,6 @@ int SimpleCameraData::init()
})
<< " ]";
- /*
- * Store the configuration in the formats_ map, mapping the
- * PixelFormat to the corresponding configuration. Any
- * previously stored value is overwritten, as the pipeline
- * handler currently doesn't care about how a particular
- * PixelFormat is achieved.
- */
for (const auto &videoFormat : videoFormats) {
PixelFormat pixelFormat = videoFormat.first.toPixelFormat();
if (!pixelFormat)
@@ -389,23 +384,34 @@ int SimpleCameraData::init()
config.captureSize = format.size;
if (!converter) {
+ config.outputFormats = { pixelFormat };
config.outputSizes = config.captureSize;
- formats_[pixelFormat] = config;
- continue;
+ } else {
+ config.outputFormats = converter->formats(pixelFormat);
+ config.outputSizes = converter->sizes(format.size);
}
- config.outputSizes = converter->sizes(format.size);
-
- for (PixelFormat fmt : converter->formats(pixelFormat))
- formats_[fmt] = config;
+ configs_.push_back(config);
}
}
- if (formats_.empty()) {
+ if (configs_.empty()) {
LOG(SimplePipeline, Error) << "No valid configuration found";
return -EINVAL;
}
+ /*
+ * Map the pixel formats to configurations. Any previously stored value
+ * is overwritten, as the pipeline handler currently doesn't care about
+ * how a particular PixelFormat is achieved.
+ */
+ for (const Configuration &config : configs_) {
+ formats_[config.captureFormat] = &config;
+
+ for (PixelFormat fmt : config.outputFormats)
+ formats_[fmt] = &config;
+ }
+
properties_ = sensor_->properties();
return 0;
@@ -548,7 +554,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()
status = Adjusted;
}
- pipeConfig_ = &it->second;
+ pipeConfig_ = it->second;
if (!pipeConfig_->outputSizes.contains(cfg.size)) {
LOG(SimplePipeline, Debug)
<< "Adjusting size from " << cfg.size.toString()
@@ -615,7 +621,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.captureSize;
+ const Size &size = format.second->captureSize;
return { pixelFormat, { size } };
});