@@ -137,12 +137,59 @@ void RkISP1Path::populateFormats()
}
}
+/**
+ * \brief Filter the sensor resolutions that can be supported
+ * \param[in] sensor The camera sensor
+ *
+ * This function retrieves all the sizes supported by the sensor and
+ * filters all the resolutions that can be supported on the pipeline.
+ * It is possible that the sensor's maximum output resolution is higher
+ * than the ISP maximum input. In that case, this function filters out all
+ * the resolution incapable of being supported and returns the maximum
+ * sensor resolution that can be supported by the pipeline.
+ *
+ * \return Maximum sensor size supported on the pipeline
+ */
+Size RkISP1Path::filterSensorResolution(const CameraSensor *sensor)
+{
+ auto iter = sensorSizesMap_.find(sensor);
+ if (iter != sensorSizesMap_.end() && !iter->second.empty())
+ return iter->second.back();
+
+ sensorSizesMap_.emplace(sensor, std::vector<Size>());
+
+ std::vector<Size> sensorSizes;
+ const std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();
+ for (const auto it : mbusCodes) {
+ std::vector<Size> sizes = sensor->sizes(it);
+ for (Size sz : sizes)
+ sensorSizes.push_back(sz);
+ }
+
+ std::sort(sensorSizes.begin(), sensorSizes.end());
+
+ /* Remove duplicates. */
+ auto last = std::unique(sensorSizes.begin(), sensorSizes.end());
+ sensorSizes.erase(last, sensorSizes.end());
+
+ /* Discard any sizes that the pipeline is unable to support. */
+ for (auto sz : sensorSizes) {
+ if (sz.width > maxResolution_.width ||
+ sz.height > maxResolution_.height)
+ continue;
+
+ sensorSizesMap_[sensor].push_back(sz);
+ }
+
+ return sensorSizesMap_[sensor].back();
+}
+
StreamConfiguration
RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,
StreamRole role)
{
const std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();
- const Size &resolution = sensor->resolution();
+ Size resolution = filterSensorResolution(sensor);
/* Min and max resolutions to populate the available stream formats. */
Size maxResolution = maxResolution_.boundedToAspectRatio(resolution)
@@ -231,7 +278,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,
StreamConfiguration *cfg)
{
const std::vector<unsigned int> &mbusCodes = sensor->mbusCodes();
- const Size &resolution = sensor->resolution();
+ Size resolution = filterSensorResolution(sensor);
const StreamConfiguration reqCfg = *cfg;
CameraConfiguration::Status status = CameraConfiguration::Valid;
@@ -7,6 +7,7 @@
#pragma once
+#include <map>
#include <memory>
#include <set>
#include <vector>
@@ -63,6 +64,7 @@ public:
private:
void populateFormats();
+ Size filterSensorResolution(const CameraSensor *sensor);
static constexpr unsigned int RKISP1_BUFFER_COUNT = 4;
@@ -77,6 +79,12 @@ private:
std::unique_ptr<V4L2Subdevice> resizer_;
std::unique_ptr<V4L2VideoDevice> video_;
MediaLink *link_;
+
+ /*
+ * Map from camera sensors to the sizes (in increasing order),
+ * which are guaranteed to be supported by the pipeline.
+ */
+ std::map<const CameraSensor *, std::vector<Size>> sensorSizesMap_;
};
class RkISP1MainPath : public RkISP1Path