Patch Detail
Show a patch.
GET /api/1.1/patches/1142/?format=api
{ "id": 1142, "url": "https://patchwork.libcamera.org/api/1.1/patches/1142/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1142/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190430183746.28518-3-laurent.pinchart@ideasonboard.com>", "date": "2019-04-30T18:37:43", "name": "[libcamera-devel,2/5] libcamera: Use the Size class through libcamera", "commit_ref": "a2dddf7c26df3307b9d4554c25387a00687a6234", "pull_url": null, "state": "accepted", "archived": false, "hash": "6fe3291174f7e2ab58d6ddc4cb57c7fe400002b4", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1142/mbox/", "series": [ { "id": 285, "url": "https://patchwork.libcamera.org/api/1.1/series/285/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=285", "date": "2019-04-30T18:37:41", "name": "Miscellaneous cleanups and refactoring", "version": 1, "mbox": "https://patchwork.libcamera.org/series/285/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1142/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1142/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 65663600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Apr 2019 20:38:02 +0200 (CEST)", "from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it\n\t[37.182.44.227])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E4ED69A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Apr 2019 20:38:01 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556649482;\n\tbh=SakNNJW7IpZytlB+c2vurzHn1mhq5GGEZNIfR9oNLnA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=dH2zE+J82p+xeAQ5wxC21buiFKi54zYqCdG9Rq287fyXq7NC9scaMpoH9ITaYBi7W\n\tbdQ0bSAxlqwZPRoWXhLl6jLy4qjrCMDHW6LTOndok6yzZLDlsdplb9Xgp8qlQ3UMi/\n\tANojgWLSoV/n4uhYOhn0DcVtih/PABv5VQ9WbwXM=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 30 Apr 2019 21:37:43 +0300", "Message-Id": "<20190430183746.28518-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190430183746.28518-1-laurent.pinchart@ideasonboard.com>", "References": "<20190430183746.28518-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/5] libcamera: Use the Size class through\n\tlibcamera", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Tue, 30 Apr 2019 18:38:02 -0000" }, "content": "Several of our structures include width and height fields that model a\nsize while be have a Size class for that purpose. Use the Size class\nthrough libcamera, and give it a toString() method like other geometry\nand format classes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/geometry.h | 2 ++\n include/libcamera/stream.h | 5 ++-\n src/cam/main.cpp | 4 +--\n src/libcamera/camera.cpp | 2 +-\n src/libcamera/camera_sensor.cpp | 3 +-\n src/libcamera/geometry.cpp | 9 ++++++\n src/libcamera/include/v4l2_device.h | 4 +--\n src/libcamera/include/v4l2_subdevice.h | 3 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 39 ++++++++++--------------\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 16 ++++------\n src/libcamera/pipeline/uvcvideo.cpp | 9 ++----\n src/libcamera/pipeline/vimc.cpp | 9 ++----\n src/libcamera/stream.cpp | 22 +++++--------\n src/libcamera/v4l2_device.cpp | 36 +++++++++-------------\n src/libcamera/v4l2_subdevice.cpp | 24 ++++++---------\n src/qcam/main_window.cpp | 3 +-\n test/camera/configuration_set.cpp | 7 ++---\n test/v4l2_device/formats.cpp | 6 ++--\n test/v4l2_subdevice/test_formats.cpp | 11 +++----\n 19 files changed, 93 insertions(+), 121 deletions(-)", "diff": "diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 3dbbced5c76f..a87d65d3ed79 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -40,6 +40,8 @@ struct Size {\n \n \tunsigned int width;\n \tunsigned int height;\n+\n+\tconst std::string toString() const;\n };\n \n bool operator==(const Size &lhs, const Size &rhs);\ndiff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex 3caaefc9f8e9..0c986310939b 100644\n--- a/include/libcamera/stream.h\n+++ b/include/libcamera/stream.h\n@@ -17,9 +17,8 @@ namespace libcamera {\n class Camera;\n \n struct StreamConfiguration {\n-\tunsigned int width;\n-\tunsigned int height;\n \tunsigned int pixelFormat;\n+\tSize size;\n \n \tunsigned int bufferCount;\n \n@@ -40,7 +39,7 @@ public:\n \n protected:\n \texplicit StreamUsage(Role role);\n-\tStreamUsage(Role role, int width, int height);\n+\tStreamUsage(Role role, const Size &size);\n \n private:\n \tRole role_;\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 46aba728393c..f03c32b385a9 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -137,10 +137,10 @@ static int prepareCameraConfig(CameraConfiguration *config)\n \t\tit++;\n \n \t\tif (conf.isSet(\"width\"))\n-\t\t\t(*config)[stream].width = conf[\"width\"];\n+\t\t\t(*config)[stream].size.width = conf[\"width\"];\n \n \t\tif (conf.isSet(\"height\"))\n-\t\t\t(*config)[stream].height = conf[\"height\"];\n+\t\t\t(*config)[stream].size.height = conf[\"height\"];\n \n \t\t/* TODO: Translate 4CC string to ID. */\n \t\tif (conf.isSet(\"pixelformat\"))\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex ef9e15be09ec..6b74eb8e3507 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -131,7 +131,7 @@ bool CameraConfiguration::isValid() const\n \tfor (auto const &it : config_) {\n \t\tconst StreamConfiguration &conf = it.second;\n \n-\t\tif (conf.width == 0 || conf.height == 0 ||\n+\t\tif (conf.size.width == 0 || conf.size.height == 0 ||\n \t\t conf.pixelFormat == 0 || conf.bufferCount == 0)\n \t\t\treturn false;\n \t}\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 8f2eab562b94..2b9d8fa593c1 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -234,8 +234,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n \t\treturn format;\n \t}\n \n-\tformat.width = bestSize->width;\n-\tformat.height = bestSize->height;\n+\tformat.size = *bestSize;\n \n \treturn format;\n }\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex c8aa05f54b73..97c367bcb454 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -107,6 +107,15 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs)\n * \\brief The Size height\n */\n \n+/**\n+ * \\brief Assemble and return a string describing the size\n+ * \\return A string describing the size\n+ */\n+const std::string Size::toString() const\n+{\n+\treturn std::to_string(width) + \"x\" + std::to_string(height);\n+}\n+\n /**\n * \\brief Compare sizes for equality\n * \\return True if the two sizes are equal, false otherwise\ndiff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex b4b3cd5cfda3..2e7bd1e7f4cc 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -13,6 +13,7 @@\n \n #include <linux/videodev2.h>\n \n+#include <libcamera/geometry.h>\n #include <libcamera/signal.h>\n \n #include \"log.h\"\n@@ -92,9 +93,8 @@ struct V4L2Capability final : v4l2_capability {\n class V4L2DeviceFormat\n {\n public:\n-\tuint32_t width;\n-\tuint32_t height;\n \tuint32_t fourcc;\n+\tSize size;\n \n \tstruct {\n \t\tuint32_t size;\ndiff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex c7b0b4cb76ea..3e4e5107aebe 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -23,8 +23,7 @@ class MediaDevice;\n \n struct V4L2SubdeviceFormat {\n \tuint32_t mbus_code;\n-\tuint32_t width;\n-\tuint32_t height;\n+\tSize size;\n \n \tconst std::string toString() const;\n };\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex fbb37498ca8a..3aa475481cf9 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -262,8 +262,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n \t\t\t *\n \t\t\t * \\todo Clarify ImgU alignment requirements.\n \t\t\t */\n-\t\t\tstreamConfig.width = 2560;\n-\t\t\tstreamConfig.height = 1920;\n+\t\t\tstreamConfig.size = { 2560, 1920 };\n \n \t\t\tbreak;\n \n@@ -295,8 +294,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n \t\t\t\t\t\t res.width);\n \t\t\tunsigned int height = std::min(usage.size().height,\n \t\t\t\t\t\t res.height);\n-\t\t\tstreamConfig.width = width & ~7;\n-\t\t\tstreamConfig.height = height & ~3;\n+\t\t\tstreamConfig.size = { width & ~7, height & ~3 };\n \n \t\t\tbreak;\n \t\t}\n@@ -347,15 +345,15 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t\t * \\todo: Consider the BDS scaling factor requirements: \"the\n \t\t * downscaling factor must be an integer value multiple of 1/32\"\n \t\t */\n-\t\tif (cfg.width % 8 || cfg.height % 4) {\n+\t\tif (cfg.size.width % 8 || cfg.size.height % 4) {\n \t\t\tLOG(IPU3, Error)\n \t\t\t\t<< \"Invalid stream size: bad alignment\";\n \t\t\treturn -EINVAL;\n \t\t}\n \n \t\tconst Size &resolution = cio2->sensor_->resolution();\n-\t\tif (cfg.width > resolution.width ||\n-\t\t cfg.height > resolution.height) {\n+\t\tif (cfg.size.width > resolution.width ||\n+\t\t cfg.size.height > resolution.height) {\n \t\t\tLOG(IPU3, Error)\n \t\t\t\t<< \"Invalid stream size: larger than sensor resolution\";\n \t\t\treturn -EINVAL;\n@@ -365,10 +363,10 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t\t * Collect the maximum width and height: IPU3 can downscale\n \t\t * only.\n \t\t */\n-\t\tif (cfg.width > sensorSize.width)\n-\t\t\tsensorSize.width = cfg.width;\n-\t\tif (cfg.height > sensorSize.height)\n-\t\t\tsensorSize.height = cfg.height;\n+\t\tif (cfg.size.width > sensorSize.width)\n+\t\t\tsensorSize.width = cfg.size.width;\n+\t\tif (cfg.size.height > sensorSize.height)\n+\t\t\tsensorSize.height = cfg.size.height;\n \n \t\tstream->active_ = true;\n \t}\n@@ -427,8 +425,7 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t * \\todo Revise this when we'll actually use the stat node.\n \t */\n \tStreamConfiguration statConfig = {};\n-\tstatConfig.width = cio2Format.width;\n-\tstatConfig.height = cio2Format.height;\n+\tstatConfig.size = cio2Format.size;\n \n \tret = imgu->configureOutput(&imgu->stat_, statConfig);\n \tif (ret)\n@@ -932,8 +929,8 @@ int ImgUDevice::configureInput(const Size &size,\n \tRectangle rect = {\n \t\t.x = 0,\n \t\t.y = 0,\n-\t\t.w = inputFormat->width,\n-\t\t.h = inputFormat->height,\n+\t\t.w = inputFormat->size.width,\n+\t\t.h = inputFormat->size.height,\n \t};\n \tret = imgu_->setCrop(PAD_INPUT, &rect);\n \tif (ret)\n@@ -947,9 +944,8 @@ int ImgUDevice::configureInput(const Size &size,\n \t\t\t << rect.toString();\n \n \tV4L2SubdeviceFormat imguFormat = {};\n-\timguFormat.width = size.width;\n-\timguFormat.height = size.height;\n \timguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;\n+\timguFormat.size = size;\n \n \tret = imgu_->setFormat(PAD_INPUT, &imguFormat);\n \tif (ret)\n@@ -973,9 +969,8 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \tunsigned int pad = output->pad;\n \n \tV4L2SubdeviceFormat imguFormat = {};\n-\timguFormat.width = config.width;\n-\timguFormat.height = config.height;\n \timguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;\n+\timguFormat.size = config.size;\n \n \tint ret = imgu_->setFormat(pad, &imguFormat);\n \tif (ret)\n@@ -986,9 +981,8 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \t\treturn 0;\n \n \tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.width = config.width;\n-\toutputFormat.height = config.height;\n \toutputFormat.fourcc = V4L2_PIX_FMT_NV12;\n+\toutputFormat.size = config.size;\n \toutputFormat.planesCount = 2;\n \n \tret = dev->setFormat(&outputFormat);\n@@ -1288,9 +1282,8 @@ int CIO2Device::configure(const Size &size,\n \tif (ret)\n \t\treturn ret;\n \n-\toutputFormat->width = sensorFormat.width;\n-\toutputFormat->height = sensorFormat.height;\n \toutputFormat->fourcc = mediaBusToFormat(sensorFormat.mbus_code);\n+\toutputFormat->size = sensorFormat.size;\n \toutputFormat->planesCount = 1;\n \n \tret = output_->setFormat(outputFormat);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 9a63a68b81dd..7acf85155e2d 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -116,10 +116,8 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera,\n \tCameraConfiguration configs;\n \tStreamConfiguration config{};\n \n-\tconst Size &resolution = data->sensor_->resolution();\n-\tconfig.width = resolution.width;\n-\tconfig.height = resolution.height;\n \tconfig.pixelFormat = V4L2_PIX_FMT_NV12;\n+\tconfig.size = data->sensor_->resolution();\n \tconfig.bufferCount = RKISP1_BUFFER_COUNT;\n \n \tconfigs[&data->stream_] = config;\n@@ -137,8 +135,8 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n \n \t/* Verify the configuration. */\n \tconst Size &resolution = sensor->resolution();\n-\tif (cfg.width > resolution.width ||\n-\t cfg.height > resolution.height) {\n+\tif (cfg.size.width > resolution.width ||\n+\t cfg.size.height > resolution.height) {\n \t\tLOG(RkISP1, Error)\n \t\t\t<< \"Invalid stream size: larger than sensor resolution\";\n \t\treturn -EINVAL;\n@@ -193,7 +191,7 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n \t\t\t\t MEDIA_BUS_FMT_SGBRG8_1X8,\n \t\t\t\t MEDIA_BUS_FMT_SGRBG8_1X8,\n \t\t\t\t MEDIA_BUS_FMT_SRGGB8_1X8 },\n-\t\t\t\t Size(cfg.width, cfg.height));\n+\t\t\t\t cfg.size);\n \n \tLOG(RkISP1, Debug) << \"Configuring sensor with \" << format.toString();\n \n@@ -216,17 +214,15 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n \t\treturn ret;\n \n \tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.width = cfg.width;\n-\toutputFormat.height = cfg.height;\n \toutputFormat.fourcc = cfg.pixelFormat;\n+\toutputFormat.size = cfg.size;\n \toutputFormat.planesCount = 2;\n \n \tret = video_->setFormat(&outputFormat);\n \tif (ret)\n \t\treturn ret;\n \n-\tif (outputFormat.width != cfg.width ||\n-\t outputFormat.height != cfg.height ||\n+\tif (outputFormat.size != cfg.size ||\n \t outputFormat.fourcc != cfg.pixelFormat) {\n \t\tLOG(RkISP1, Error)\n \t\t\t<< \"Unable to configure capture in \" << cfg.toString();\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex fd1d6df177d9..358e247baade 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -92,9 +92,8 @@ PipelineHandlerUVC::streamConfiguration(Camera *camera,\n \tCameraConfiguration configs;\n \tStreamConfiguration config{};\n \n-\tconfig.width = 640;\n-\tconfig.height = 480;\n \tconfig.pixelFormat = V4L2_PIX_FMT_YUYV;\n+\tconfig.size = { 640, 480 };\n \tconfig.bufferCount = 4;\n \n \tconfigs[&data->stream_] = config;\n@@ -110,16 +109,14 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n \tint ret;\n \n \tV4L2DeviceFormat format = {};\n-\tformat.width = cfg->width;\n-\tformat.height = cfg->height;\n \tformat.fourcc = cfg->pixelFormat;\n+\tformat.size = cfg->size;\n \n \tret = data->video_->setFormat(&format);\n \tif (ret)\n \t\treturn ret;\n \n-\tif (format.width != cfg->width ||\n-\t format.height != cfg->height ||\n+\tif (format.size != cfg->size ||\n \t format.fourcc != cfg->pixelFormat)\n \t\treturn -EINVAL;\n \ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex f95140661b2a..83fa9cf4033a 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -92,9 +92,8 @@ PipelineHandlerVimc::streamConfiguration(Camera *camera,\n \tCameraConfiguration configs;\n \tStreamConfiguration config{};\n \n-\tconfig.width = 640;\n-\tconfig.height = 480;\n \tconfig.pixelFormat = V4L2_PIX_FMT_RGB24;\n+\tconfig.size = { 640, 480 };\n \tconfig.bufferCount = 4;\n \n \tconfigs[&data->stream_] = config;\n@@ -110,16 +109,14 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n \tint ret;\n \n \tV4L2DeviceFormat format = {};\n-\tformat.width = cfg->width;\n-\tformat.height = cfg->height;\n \tformat.fourcc = cfg->pixelFormat;\n+\tformat.size = cfg->size;\n \n \tret = data->video_->setFormat(&format);\n \tif (ret)\n \t\treturn ret;\n \n-\tif (format.width != cfg->width ||\n-\t format.height != cfg->height ||\n+\tif (format.size != cfg->size ||\n \t format.fourcc != cfg->pixelFormat)\n \t\treturn -EINVAL;\n \ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex aeb479c57b37..4ff296e3a75b 100644\n--- a/src/libcamera/stream.cpp\n+++ b/src/libcamera/stream.cpp\n@@ -41,13 +41,8 @@ namespace libcamera {\n */\n \n /**\n- * \\var StreamConfiguration::width\n- * \\brief Stream width in pixels\n- */\n-\n-/**\n- * \\var StreamConfiguration::height\n- * \\brief Stream height in pixels\n+ * \\var StreamConfiguration::size\n+ * \\brief Stream size in pixels\n */\n \n /**\n@@ -73,8 +68,8 @@ std::string StreamConfiguration::toString() const\n \tstd::stringstream ss;\n \n \tss.fill(0);\n-\tss << width << \"x\" << height << \"-0x\" << std::hex\n-\t << std::setw(8) << pixelFormat;\n+\tss << size.toString() << \"-0x\" << std::hex << std::setw(8)\n+\t << pixelFormat;\n \n \treturn ss.str();\n }\n@@ -128,11 +123,10 @@ StreamUsage::StreamUsage(Role role)\n /**\n * \\brief Create a stream usage with a desired size\n * \\param[in] role Stream role\n- * \\param[in] width The desired width\n- * \\param[in] height The desired height\n+ * \\param[in] size The desired size\n */\n-StreamUsage::StreamUsage(Role role, int width, int height)\n-\t: role_(role), size_(Size(width, height))\n+StreamUsage::StreamUsage(Role role, const Size &size)\n+\t: role_(role), size_(size)\n {\n }\n \n@@ -183,7 +177,7 @@ Stream::VideoRecording::VideoRecording()\n * \\param[in] height The desired viewfinder height\n */\n Stream::Viewfinder::Viewfinder(int width, int height)\n-\t: StreamUsage(Role::Viewfinder, width, height)\n+\t: StreamUsage(Role::Viewfinder, Size(width, height))\n {\n }\n \ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex a21944160253..1bbf79673c16 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -195,13 +195,8 @@ LOG_DEFINE_CATEGORY(V4L2)\n */\n \n /**\n- * \\var V4L2DeviceFormat::width\n- * \\brief The image width in pixels\n- */\n-\n-/**\n- * \\var V4L2DeviceFormat::height\n- * \\brief The image height in pixels\n+ * \\var V4L2DeviceFormat::size\n+ * \\brief The image size in pixels\n */\n \n /**\n@@ -236,8 +231,7 @@ const std::string V4L2DeviceFormat::toString() const\n \tstd::stringstream ss;\n \n \tss.fill(0);\n-\tss << width << \"x\" << height << \"-0x\" << std::hex\n-\t << std::setw(8) << fourcc;\n+\tss << size.toString() << \"-0x\" << std::hex << std::setw(8) << fourcc;\n \n \treturn ss.str();\n }\n@@ -458,8 +452,8 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n \t\treturn ret;\n \t}\n \n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n \tformat->fourcc = pix->pixelformat;\n \tformat->planesCount = 1;\n \tformat->planes[0].bpl = pix->bytesperline;\n@@ -475,8 +469,8 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n \tint ret;\n \n \tv4l2Format.type = bufferType_;\n-\tpix->width = format->width;\n-\tpix->height = format->height;\n+\tpix->width = format->size.width;\n+\tpix->height = format->size.height;\n \tpix->pixelformat = format->fourcc;\n \tpix->bytesperline = format->planes[0].bpl;\n \tpix->field = V4L2_FIELD_NONE;\n@@ -492,8 +486,8 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n \t * Return to caller the format actually applied on the device,\n \t * which might differ from the requested one.\n \t */\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n \tformat->fourcc = pix->pixelformat;\n \tformat->planesCount = 1;\n \tformat->planes[0].bpl = pix->bytesperline;\n@@ -516,8 +510,8 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)\n \t\treturn ret;\n \t}\n \n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n \tformat->fourcc = pix->pixelformat;\n \tformat->planesCount = pix->num_planes;\n \n@@ -536,8 +530,8 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \tint ret;\n \n \tv4l2Format.type = bufferType_;\n-\tpix->width = format->width;\n-\tpix->height = format->height;\n+\tpix->width = format->size.width;\n+\tpix->height = format->size.height;\n \tpix->pixelformat = format->fourcc;\n \tpix->num_planes = format->planesCount;\n \tpix->field = V4L2_FIELD_NONE;\n@@ -558,8 +552,8 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \t * Return to caller the format actually applied on the device,\n \t * which might differ from the requested one.\n \t */\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n \tformat->fourcc = pix->pixelformat;\n \tformat->planesCount = pix->num_planes;\n \tfor (unsigned int i = 0; i < format->planesCount; ++i) {\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 6fc866a6450b..fceee33156e9 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -65,13 +65,8 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n */\n \n /**\n- * \\var V4L2SubdeviceFormat::width\n- * \\brief The image width in pixels\n- */\n-\n-/**\n- * \\var V4L2SubdeviceFormat::height\n- * \\brief The image height in pixels\n+ * \\var V4L2SubdeviceFormat::size\n+ * \\brief The image size in pixels\n */\n \n /**\n@@ -83,8 +78,7 @@ const std::string V4L2SubdeviceFormat::toString() const\n \tstd::stringstream ss;\n \n \tss.fill(0);\n-\tss << width << \"x\" << height << \"-0x\" << std::hex\n-\t << std::setw(4) << mbus_code;\n+\tss << size.toString() << \"-0x\" << std::hex << std::setw(4) << mbus_code;\n \n \treturn ss.str();\n }\n@@ -265,8 +259,8 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n \t\treturn ret;\n \t}\n \n-\tformat->width = subdevFmt.format.width;\n-\tformat->height = subdevFmt.format.height;\n+\tformat->size.width = subdevFmt.format.width;\n+\tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n \n \treturn 0;\n@@ -288,8 +282,8 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n \tstruct v4l2_subdev_format subdevFmt = {};\n \tsubdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n \tsubdevFmt.pad = pad;\n-\tsubdevFmt.format.width = format->width;\n-\tsubdevFmt.format.height = format->height;\n+\tsubdevFmt.format.width = format->size.width;\n+\tsubdevFmt.format.height = format->size.height;\n \tsubdevFmt.format.code = format->mbus_code;\n \n \tint ret = ioctl(fd_, VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n@@ -301,8 +295,8 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n \t\treturn ret;\n \t}\n \n-\tformat->width = subdevFmt.format.width;\n-\tformat->height = subdevFmt.format.height;\n+\tformat->size.width = subdevFmt.format.width;\n+\tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n \n \treturn 0;\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 4bc044037041..6e92f6a1124d 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -106,7 +106,8 @@ int MainWindow::startCapture()\n \t}\n \n \tconst StreamConfiguration &sconf = config_[stream];\n-\tret = viewfinder_->setFormat(sconf.pixelFormat, sconf.width, sconf.height);\n+\tret = viewfinder_->setFormat(sconf.pixelFormat, sconf.size.width,\n+\t\t\t\t sconf.size.height);\n \tif (ret < 0) {\n \t\tstd::cout << \"Failed to set viewfinder format\" << std::endl;\n \t\treturn ret;\ndiff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\nindex 5ac2a7a908c8..0c932bc1de18 100644\n--- a/test/camera/configuration_set.cpp\n+++ b/test/camera/configuration_set.cpp\n@@ -64,8 +64,8 @@ protected:\n \t\t * the default configuration of the VIMC camera is known to\n \t\t * work.\n \t\t */\n-\t\tsconf->width *= 2;\n-\t\tsconf->height *= 2;\n+\t\tsconf->size.width *= 2;\n+\t\tsconf->size.height *= 2;\n \t\tif (camera_->configureStreams(conf)) {\n \t\t\tcout << \"Failed to set modified configuration\" << endl;\n \t\t\treturn TestFail;\n@@ -74,8 +74,7 @@ protected:\n \t\t/*\n \t\t * Test that setting an invalid configuration fails.\n \t\t */\n-\t\tsconf->width = 0;\n-\t\tsconf->height = 0;\n+\t\tsconf->size = { 0, 0 };\n \t\tif (!camera_->configureStreams(conf)) {\n \t\t\tcout << \"Invalid configuration incorrectly accepted\" << endl;\n \t\t\treturn TestFail;\ndiff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp\nindex 30b8b5c3f3f5..007e7e9487b5 100644\n--- a/test/v4l2_device/formats.cpp\n+++ b/test/v4l2_device/formats.cpp\n@@ -31,8 +31,7 @@ int Format::run()\n \t\treturn TestFail;\n \t}\n \n-\tformat.width = UINT_MAX;\n-\tformat.height = UINT_MAX;\n+\tformat.size = { UINT_MAX, UINT_MAX };\n \tret = capture_->setFormat(&format);\n \tif (ret) {\n \t\tcerr << \"Failed to set format: image resolution is invalid: \"\n@@ -41,7 +40,8 @@ int Format::run()\n \t\treturn TestFail;\n \t}\n \n-\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n+\tif (format.size.width == UINT_MAX ||\n+\t format.size.height == UINT_MAX) {\n \t\tcerr << \"Failed to update image format = (UINT_MAX x UINT_MAX)\"\n \t\t << endl;\n \t\treturn TestFail;\ndiff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\nindex af954459a3d8..e90c2c2426da 100644\n--- a/test/v4l2_subdevice/test_formats.cpp\n+++ b/test/v4l2_subdevice/test_formats.cpp\n@@ -44,8 +44,7 @@ int FormatHandlingTest::run()\n \t/*\n \t * Set unrealistic image resolutions and make sure it gets updated.\n \t */\n-\tformat.width = UINT_MAX;\n-\tformat.height = UINT_MAX;\n+\tformat.size = { UINT_MAX, UINT_MAX };\n \tret = scaler_->setFormat(0, &format);\n \tif (ret) {\n \t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n@@ -53,13 +52,13 @@ int FormatHandlingTest::run()\n \t\treturn TestFail;\n \t}\n \n-\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n+\tif (format.size.width == UINT_MAX ||\n+\t format.size.height == UINT_MAX) {\n \t\tcerr << \"Failed to update image format\" << endl;\n \t\treturn TestFail;\n \t}\n \n-\tformat.width = 0;\n-\tformat.height = 0;\n+\tformat.size = { 0, 0 };\n \tret = scaler_->setFormat(0, &format);\n \tif (ret) {\n \t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n@@ -67,7 +66,7 @@ int FormatHandlingTest::run()\n \t\treturn TestFail;\n \t}\n \n-\tif (format.width == 0 || format.height == 0) {\n+\tif (format.size.width == 0 || format.size.height == 0) {\n \t\tcerr << \"Failed to update image format\" << endl;\n \t\treturn TestFail;\n \t}\n", "prefixes": [ "libcamera-devel", "2/5" ] }