From a2dddf7c26df3307b9d4554c25387a00687a6234 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 30 Apr 2019 21:16:28 +0300 Subject: libcamera: Use the Size class through libcamera MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund --- src/libcamera/v4l2_device.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/libcamera/v4l2_device.cpp') 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) { -- cgit v1.2.1