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>
This commit is contained in:
@@ -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 } };
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user