[{"id":1544,"web_url":"https://patchwork.libcamera.org/comment/1544/","msgid":"<20190430185454.GQ16573@bigcity.dyn.berto.se>","date":"2019-04-30T18:54:54","subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: Use the Size class\n\tthrough libcamera","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2019-04-30 21:37:43 +0300, Laurent Pinchart wrote:\n> Several of our structures include width and height fields that model a\n> size while be have a Size class for that purpose. Use the Size class\n\ns/be/we/\n\n> through libcamera, and give it a toString() method like other geometry\n> and format classes.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\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(-)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index 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);\n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 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_;\n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index 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\"))\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 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}\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index 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>  }\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 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\n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 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;\n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 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>  };\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 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);\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 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();\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 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>  \n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index 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>  \n> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> index 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>  \n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 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) {\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 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;\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 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;\n> diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\n> index 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;\n> diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp\n> index 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;\n> diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x136.google.com (mail-lf1-x136.google.com\n\t[IPv6:2a00:1450:4864:20::136])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CE5C160E5B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Apr 2019 20:54:56 +0200 (CEST)","by mail-lf1-x136.google.com with SMTP id w23so11535487lfc.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Apr 2019 11:54:56 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tc17sm6023304lff.84.2019.04.30.11.54.55\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 30 Apr 2019 11:54:55 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=VJkzjkz7qJ1vY5/ukH38S8hQOlFdJP7OCmF5V3pAfzo=;\n\tb=AuZ3k7lrgEx7pvYzEOjznJcz+aShYW2itZNwO4J4P3BVEEzzp+PCVn7ViJxG5XusuC\n\tPgb47IAAp9XwJ0BjhjxUcZ35daobwe8kAUfUjRu9/thPdW2/ILZyS0A3Q5l8Dre3BzEt\n\tymRBLmMUi8ZrgVQAGg1wo9u3h/9v6FFY3Dh8yyM4atRck6YjSswaThQ+VBr8j/vpqqsv\n\tmQ4Usk0nQvM5brNibhe7uYjtZOdEv6Ysj/3O8Bw4dEoEw6g90hsGoKOBvI7HytlBZlRY\n\tsOmkumSMdubTJyZyLA6mIXtlmJwmFT4U4dnEh8gvbObYIFcjoDcETVMqamPBYEayWiHr\n\tRQzA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=VJkzjkz7qJ1vY5/ukH38S8hQOlFdJP7OCmF5V3pAfzo=;\n\tb=VHL+P7b1Tw6TjaxGjki/Ba0Id1EeWosWT6+iXuKCDF+7m1o3k5QFsi9mug+Tdxen0D\n\t5x65jCafEnaMI7n/p3yMZ/XIbINXptul1u5/nfJqdSAW3Knh99akXLH0YyokT5uPacyW\n\tz0VJFCLUrMJO7SJnir69bjXSvGrSCrnxlvXaOukSWFVY8mptd2BK/23Ilo6+DavJcjP2\n\tVJ4uMxWE4lzltfO/mzvwhXga+IM8hxdFmgbTnw5E8GuMRgzmscCVK8Nemnc17wKSu/u6\n\tn/3AF7GAkwKiqbV2ituqqihIBFbNAicy5jo7xovmBMMZnVNgCmhQoEFUNTjjKVY2f1wE\n\t0/bg==","X-Gm-Message-State":"APjAAAVYMK/yC4HnPHHmX3hJhe3yoWL2rD5SqAjW+3BRmrsOiKfQlQK3\n\trWmR8PwrTKEiMIqURX/sUkduTp9Zmdc=","X-Google-Smtp-Source":"APXvYqwRjVAnwFTLHNYDY0F1xGU4r/vVBBFy4sKn+kepJUu70pMmXVxGMeJTsjaGZXn161VWdTqAIQ==","X-Received":"by 2002:ac2:52b1:: with SMTP id\n\tr17mr28104403lfm.39.1556650495991; \n\tTue, 30 Apr 2019 11:54:55 -0700 (PDT)","Date":"Tue, 30 Apr 2019 20:54:54 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190430185454.GQ16573@bigcity.dyn.berto.se>","References":"<20190430183746.28518-1-laurent.pinchart@ideasonboard.com>\n\t<20190430183746.28518-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190430183746.28518-3-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: Use the Size class\n\tthrough libcamera","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:54:57 -0000"}}]