summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-30 21:16:28 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-30 22:18:42 +0300
commita2dddf7c26df3307b9d4554c25387a00687a6234 (patch)
treebe4004bb072d39d471ee790069e3f74d1cd5bbe0 /src/libcamera/v4l2_device.cpp
parentbaad55d00975f8931d51c333def20472457dc943 (diff)
libcamera: Use the Size class through libcamera
Several of our structures include width and height fields that model a size while we have a Size class for that purpose. Use the Size class through libcamera, and give it a toString() method like other geometry and format classes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/v4l2_device.cpp')
-rw-r--r--src/libcamera/v4l2_device.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index a2194416..1bbf7967 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -195,13 +195,8 @@ LOG_DEFINE_CATEGORY(V4L2)
*/
/**
- * \var V4L2DeviceFormat::width
- * \brief The image width in pixels
- */
-
-/**
- * \var V4L2DeviceFormat::height
- * \brief The image height in pixels
+ * \var V4L2DeviceFormat::size
+ * \brief The image size in pixels
*/
/**
@@ -236,8 +231,7 @@ const std::string V4L2DeviceFormat::toString() const
std::stringstream ss;
ss.fill(0);
- ss << width << "x" << height << "-0x" << std::hex
- << std::setw(8) << fourcc;
+ ss << size.toString() << "-0x" << std::hex << std::setw(8) << fourcc;
return ss.str();
}
@@ -458,8 +452,8 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
return ret;
}
- format->width = pix->width;
- format->height = pix->height;
+ format->size.width = pix->width;
+ format->size.height = pix->height;
format->fourcc = pix->pixelformat;
format->planesCount = 1;
format->planes[0].bpl = pix->bytesperline;
@@ -475,8 +469,8 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
int ret;
v4l2Format.type = bufferType_;
- pix->width = format->width;
- pix->height = format->height;
+ pix->width = format->size.width;
+ pix->height = format->size.height;
pix->pixelformat = format->fourcc;
pix->bytesperline = format->planes[0].bpl;
pix->field = V4L2_FIELD_NONE;
@@ -492,8 +486,8 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
* Return to caller the format actually applied on the device,
* which might differ from the requested one.
*/
- format->width = pix->width;
- format->height = pix->height;
+ format->size.width = pix->width;
+ format->size.height = pix->height;
format->fourcc = pix->pixelformat;
format->planesCount = 1;
format->planes[0].bpl = pix->bytesperline;
@@ -516,8 +510,8 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
return ret;
}
- format->width = pix->width;
- format->height = pix->height;
+ format->size.width = pix->width;
+ format->size.height = pix->height;
format->fourcc = pix->pixelformat;
format->planesCount = pix->num_planes;
@@ -536,8 +530,8 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
int ret;
v4l2Format.type = bufferType_;
- pix->width = format->width;
- pix->height = format->height;
+ pix->width = format->size.width;
+ pix->height = format->size.height;
pix->pixelformat = format->fourcc;
pix->num_planes = format->planesCount;
pix->field = V4L2_FIELD_NONE;
@@ -558,8 +552,8 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
* Return to caller the format actually applied on the device,
* which might differ from the requested one.
*/
- format->width = pix->width;
- format->height = pix->height;
+ format->size.width = pix->width;
+ format->size.height = pix->height;
format->fourcc = pix->pixelformat;
format->planesCount = pix->num_planes;
for (unsigned int i = 0; i < format->planesCount; ++i) {