libcamera: v4l2_videodevice: Add using statement for format map
Define a using statement for the format maps returned by V4L2Device::formats() and use it in all call sites. There is no functional change in this patch. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
4a5b0df984
commit
a8a2048ab0
5 changed files with 18 additions and 13 deletions
|
@ -168,6 +168,8 @@ public:
|
||||||
class V4L2VideoDevice : public V4L2Device
|
class V4L2VideoDevice : public V4L2Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using Formats = std::map<V4L2PixelFormat, std::vector<SizeRange>>;
|
||||||
|
|
||||||
explicit V4L2VideoDevice(const std::string &deviceNode);
|
explicit V4L2VideoDevice(const std::string &deviceNode);
|
||||||
explicit V4L2VideoDevice(const MediaEntity *entity);
|
explicit V4L2VideoDevice(const MediaEntity *entity);
|
||||||
V4L2VideoDevice(const V4L2VideoDevice &) = delete;
|
V4L2VideoDevice(const V4L2VideoDevice &) = delete;
|
||||||
|
@ -188,7 +190,7 @@ public:
|
||||||
int getFormat(V4L2DeviceFormat *format);
|
int getFormat(V4L2DeviceFormat *format);
|
||||||
int tryFormat(V4L2DeviceFormat *format);
|
int tryFormat(V4L2DeviceFormat *format);
|
||||||
int setFormat(V4L2DeviceFormat *format);
|
int setFormat(V4L2DeviceFormat *format);
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> formats(uint32_t code = 0);
|
Formats formats(uint32_t code = 0);
|
||||||
|
|
||||||
int setSelection(unsigned int target, Rectangle *rect);
|
int setSelection(unsigned int target, Rectangle *rect);
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,6 @@ namespace libcamera {
|
||||||
|
|
||||||
LOG_DEFINE_CATEGORY(RPI)
|
LOG_DEFINE_CATEGORY(RPI)
|
||||||
|
|
||||||
using V4L2PixFmtMap = std::map<V4L2PixelFormat, std::vector<SizeRange>>;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool isRaw(PixelFormat &pixFmt)
|
bool isRaw(PixelFormat &pixFmt)
|
||||||
|
@ -69,7 +67,8 @@ double scoreFormat(double desired, double actual)
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)
|
V4L2DeviceFormat findBestMode(V4L2VideoDevice::Formats &formatsMap,
|
||||||
|
const Size &req)
|
||||||
{
|
{
|
||||||
double bestScore = std::numeric_limits<double>::max(), score;
|
double bestScore = std::numeric_limits<double>::max(), score;
|
||||||
V4L2DeviceFormat bestMode = {};
|
V4L2DeviceFormat bestMode = {};
|
||||||
|
@ -410,7 +409,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
|
||||||
* Calculate the best sensor mode we can use based on
|
* Calculate the best sensor mode we can use based on
|
||||||
* the user request.
|
* the user request.
|
||||||
*/
|
*/
|
||||||
V4L2PixFmtMap fmts = data_->unicam_[Unicam::Image].dev()->formats();
|
V4L2VideoDevice::Formats fmts = data_->unicam_[Unicam::Image].dev()->formats();
|
||||||
V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size);
|
V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size);
|
||||||
int ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&sensorFormat);
|
int ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&sensorFormat);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -480,7 +479,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
|
||||||
else
|
else
|
||||||
dev = data_->isp_[Isp::Output1].dev();
|
dev = data_->isp_[Isp::Output1].dev();
|
||||||
|
|
||||||
V4L2PixFmtMap fmts = dev->formats();
|
V4L2VideoDevice::Formats fmts = dev->formats();
|
||||||
|
|
||||||
if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {
|
if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {
|
||||||
/* If we cannot find a native format, use a default one. */
|
/* If we cannot find a native format, use a default one. */
|
||||||
|
@ -517,7 +516,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
|
||||||
V4L2DeviceFormat sensorFormat;
|
V4L2DeviceFormat sensorFormat;
|
||||||
unsigned int bufferCount;
|
unsigned int bufferCount;
|
||||||
PixelFormat pixelFormat;
|
PixelFormat pixelFormat;
|
||||||
V4L2PixFmtMap fmts;
|
V4L2VideoDevice::Formats fmts;
|
||||||
Size size;
|
Size size;
|
||||||
|
|
||||||
if (roles.empty())
|
if (roles.empty())
|
||||||
|
@ -633,7 +632,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First calculate the best sensor mode we can use based on the user request. */
|
/* First calculate the best sensor mode we can use based on the user request. */
|
||||||
V4L2PixFmtMap fmts = data->unicam_[Unicam::Image].dev()->formats();
|
V4L2VideoDevice::Formats fmts = data->unicam_[Unicam::Image].dev()->formats();
|
||||||
V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize);
|
V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -275,7 +275,7 @@ int SimpleCameraData::init()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> videoFormats =
|
V4L2VideoDevice::Formats videoFormats =
|
||||||
video_->formats(format.mbus_code);
|
video_->formats(format.mbus_code);
|
||||||
|
|
||||||
LOG(SimplePipeline, Debug)
|
LOG(SimplePipeline, Debug)
|
||||||
|
|
|
@ -172,8 +172,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera,
|
||||||
if (roles.empty())
|
if (roles.empty())
|
||||||
return config;
|
return config;
|
||||||
|
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =
|
V4L2VideoDevice::Formats v4l2Formats = data->video_->formats();
|
||||||
data->video_->formats();
|
|
||||||
std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
|
std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
|
||||||
for (const auto &format : v4l2Formats) {
|
for (const auto &format : v4l2Formats) {
|
||||||
PixelFormat pixelFormat = format.first.toPixelFormat();
|
PixelFormat pixelFormat = format.first.toPixelFormat();
|
||||||
|
|
|
@ -461,6 +461,11 @@ const std::string V4L2DeviceFormat::toString() const
|
||||||
* \context This class is \threadbound.
|
* \context This class is \threadbound.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \typedef V4L2VideoDevice::Formats
|
||||||
|
* \brief A map of supported V4L2 pixel formats to frame sizes
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Construct a V4L2VideoDevice
|
* \brief Construct a V4L2VideoDevice
|
||||||
* \param[in] deviceNode The file-system path to the video device node
|
* \param[in] deviceNode The file-system path to the video device node
|
||||||
|
@ -951,9 +956,9 @@ int V4L2VideoDevice::trySetFormatSingleplane(V4L2DeviceFormat *format, bool set)
|
||||||
*
|
*
|
||||||
* \return A list of the supported video device formats
|
* \return A list of the supported video device formats
|
||||||
*/
|
*/
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats(uint32_t code)
|
V4L2VideoDevice::Formats V4L2VideoDevice::formats(uint32_t code)
|
||||||
{
|
{
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> formats;
|
Formats formats;
|
||||||
|
|
||||||
for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) {
|
for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) {
|
||||||
std::vector<SizeRange> sizes = enumSizes(pixelFormat);
|
std::vector<SizeRange> sizes = enumSizes(pixelFormat);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue