[{"id":4047,"web_url":"https://patchwork.libcamera.org/comment/4047/","msgid":"<20200317111400.GG4864@pendragon.ideasonboard.com>","date":"2020-03-17T11:14:00","subject":"Re: [libcamera-devel] [PATCH v2 8/8] libcamera: PixelFormat: Mark\n\tall function arguments of type PixelFormat as const reference","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Tue, Mar 17, 2020 at 04:52:39AM +0100, Niklas Söderlund wrote:\n> PixelFormat was previously an alias for unsigned int but are now a\n\ns/are now/is now/\n\n> class. Make all functions taking PixelFormat do so as a const reference.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/stream.h               | 4 ++--\n>  src/libcamera/include/v4l2_videodevice.h | 5 +++--\n>  src/libcamera/stream.cpp                 | 4 ++--\n>  src/libcamera/v4l2_videodevice.cpp       | 5 +++--\n>  src/qcam/format_converter.cpp            | 4 ++--\n>  src/qcam/format_converter.h              | 2 +-\n>  src/qcam/viewfinder.cpp                  | 4 ++--\n>  src/qcam/viewfinder.h                    | 2 +-\n>  src/v4l2/v4l2_camera.cpp                 | 2 +-\n>  src/v4l2/v4l2_camera.h                   | 2 +-\n>  src/v4l2/v4l2_camera_proxy.cpp           | 2 +-\n>  src/v4l2/v4l2_camera_proxy.h             | 2 +-\n>  12 files changed, 20 insertions(+), 18 deletions(-)\n> \n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 29a8030dff71d58f..b1441f8ec6749fda 100644\n> --- a/include/libcamera/stream.h\n> +++ b/include/libcamera/stream.h\n> @@ -28,9 +28,9 @@ public:\n>  \tStreamFormats(const std::map<PixelFormat, std::vector<SizeRange>> &formats);\n>  \n>  \tstd::vector<PixelFormat> pixelformats() const;\n> -\tstd::vector<Size> sizes(PixelFormat pixelformat) const;\n> +\tstd::vector<Size> sizes(const PixelFormat &pixelformat) const;\n>  \n> -\tSizeRange range(PixelFormat pixelformat) const;\n> +\tSizeRange range(const PixelFormat &pixelformat) const;\n>  \n>  private:\n>  \tstd::map<PixelFormat, std::vector<SizeRange>> formats_;\n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index 62e6a657fc7eedb0..252820cba3fdc7a3 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -206,8 +206,9 @@ public:\n>  \t\t\t\t\t       const std::string &entity);\n>  \n>  \tstatic PixelFormat toPixelFormat(uint32_t v4l2Fourcc);\n> -\tuint32_t toV4L2Fourcc(PixelFormat pixelFormat);\n> -\tstatic uint32_t toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar);\n> +\tuint32_t toV4L2Fourcc(const PixelFormat &pixelFormat);\n> +\tstatic uint32_t toV4L2Fourcc(const PixelFormat &pixelFormat,\n> +\t\t\t\t     bool multiplanar);\n>  \n>  protected:\n>  \tstd::string logPrefix() const;\n> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> index 0716de388bd81d80..e61484caf7157da5 100644\n> --- a/src/libcamera/stream.cpp\n> +++ b/src/libcamera/stream.cpp\n> @@ -127,7 +127,7 @@ std::vector<PixelFormat> StreamFormats::pixelformats() const\n>   *\n>   * \\return A list of frame sizes or an empty list on error\n>   */\n> -std::vector<Size> StreamFormats::sizes(PixelFormat pixelformat) const\n> +std::vector<Size> StreamFormats::sizes(const PixelFormat &pixelformat) const\n>  {\n>  \t/*\n>  \t * Sizes to try and extract from ranges.\n> @@ -240,7 +240,7 @@ std::vector<Size> StreamFormats::sizes(PixelFormat pixelformat) const\n>   *\n>   * \\return A range of valid image sizes or an empty range on error\n>   */\n> -SizeRange StreamFormats::range(PixelFormat pixelformat) const\n> +SizeRange StreamFormats::range(const PixelFormat &pixelformat) const\n>  {\n>  \tauto const it = formats_.find(pixelformat);\n>  \tif (it == formats_.end())\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index d8d711a951d666e9..40f431abb0dba721 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1623,7 +1623,7 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)\n>   *\n>   * \\return The V4L2_PIX_FMT_* pixel format code corresponding to \\a pixelFormat\n>   */\n> -uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat)\n> +uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat)\n>  {\n>  \treturn V4L2VideoDevice::toV4L2Fourcc(pixelFormat, caps_.isMultiplanar());\n>  }\n> @@ -1641,7 +1641,8 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat)\n>   *\n>   * \\return The V4L2_PIX_FMT_* pixel format code corresponding to \\a pixelFormat\n>   */\n> -uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar)\n> +uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat,\n> +\t\t\t\t       bool multiplanar)\n>  {\n>  \tswitch (pixelFormat.fourcc()) {\n>  \t/* RGB formats. */\n> diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\n> index c071ea9b4022750c..b72e8342135d3c39 100644\n> --- a/src/qcam/format_converter.cpp\n> +++ b/src/qcam/format_converter.cpp\n> @@ -27,8 +27,8 @@\n>  #define CLIP(x)\t\t\tCLAMP(x,0,255)\n>  #endif\n>  \n> -int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width,\n> -\t\t\t       unsigned int height)\n> +int FormatConverter::configure(const libcamera::PixelFormat &format,\n> +\t\t\t       unsigned int width, unsigned int height)\n>  {\n>  \tswitch (format.fourcc()) {\n>  \tcase DRM_FORMAT_NV12:\n> diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\n> index ff488b994ade3c3e..96bde2384ddfecc9 100644\n> --- a/src/qcam/format_converter.h\n> +++ b/src/qcam/format_converter.h\n> @@ -16,7 +16,7 @@ class QImage;\n>  class FormatConverter\n>  {\n>  public:\n> -\tint configure(libcamera::PixelFormat format, unsigned int width,\n> +\tint configure(const libcamera::PixelFormat &format, unsigned int width,\n>  \t\t      unsigned int height);\n>  \n>  \tvoid convert(const unsigned char *src, size_t size, QImage *dst);\n> diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\n> index 0ebb8edd49efd1b1..e9d5cc1e014b048b 100644\n> --- a/src/qcam/viewfinder.cpp\n> +++ b/src/qcam/viewfinder.cpp\n> @@ -44,8 +44,8 @@ QImage ViewFinder::getCurrentImage()\n>  \treturn image_->copy();\n>  }\n>  \n> -int ViewFinder::setFormat(libcamera::PixelFormat format, unsigned int width,\n> -\t\t\t  unsigned int height)\n> +int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n> +\t\t\t  unsigned int width, unsigned int height)\n>  {\n>  \tint ret;\n>  \n> diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\n> index 2668aa4457657ef9..0549f038edd6c3b5 100644\n> --- a/src/qcam/viewfinder.h\n> +++ b/src/qcam/viewfinder.h\n> @@ -22,7 +22,7 @@ public:\n>  \tViewFinder(QWidget *parent);\n>  \t~ViewFinder();\n>  \n> -\tint setFormat(libcamera::PixelFormat format, unsigned int width,\n> +\tint setFormat(const libcamera::PixelFormat &format, unsigned int width,\n>  \t\t      unsigned int height);\n>  \tvoid display(const unsigned char *rgb, size_t size);\n>  \n> diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\n> index f0b9f1804c94378a..ecbb70acfb8eeb52 100644\n> --- a/src/v4l2/v4l2_camera.cpp\n> +++ b/src/v4l2/v4l2_camera.cpp\n> @@ -88,7 +88,7 @@ void V4L2Camera::requestComplete(Request *request)\n>  }\n>  \n>  int V4L2Camera::configure(StreamConfiguration *streamConfigOut,\n> -\t\t\t  const Size &size, PixelFormat pixelformat,\n> +\t\t\t  const Size &size, const PixelFormat &pixelformat,\n>  \t\t\t  unsigned int bufferCount)\n>  {\n>  \tStreamConfiguration &streamConfig = config_->at(0);\n> diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\n> index 37bd358462db190d..130995d95eb4bd4c 100644\n> --- a/src/v4l2/v4l2_camera.h\n> +++ b/src/v4l2/v4l2_camera.h\n> @@ -43,7 +43,7 @@ public:\n>  \tstd::vector<Buffer> completedBuffers();\n>  \n>  \tint configure(StreamConfiguration *streamConfigOut,\n> -\t\t      const Size &size, PixelFormat pixelformat,\n> +\t\t      const Size &size, const PixelFormat &pixelformat,\n>  \t\t      unsigned int bufferCount);\n>  \n>  \tint allocBuffers(unsigned int count);\n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 55dd69d37bd65897..d519af85a9e0b300 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -599,7 +599,7 @@ PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format)\n>  \treturn info->format;\n>  }\n>  \n> -uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format)\n> +uint32_t V4L2CameraProxy::drmToV4L2(const PixelFormat &format)\n>  {\n>  \tauto info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(),\n>  \t\t\t\t [format](const PixelFormatInfo &info) {\n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index c8e61adf80f1b93b..e15b230d5f23f119 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -60,7 +60,7 @@ private:\n>  \t\t\t\t      unsigned int height);\n>  \n>  \tstatic PixelFormat v4l2ToDrm(uint32_t format);\n> -\tstatic uint32_t drmToV4L2(PixelFormat format);\n> +\tstatic uint32_t drmToV4L2(const PixelFormat &format);\n>  \n>  \tunsigned int refcount_;\n>  \tunsigned int index_;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F236462923\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 12:14:05 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 62C9AF9;\n\tTue, 17 Mar 2020 12:14:05 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584443645;\n\tbh=tJvdkvvDBc56p6foxCtAoJxKim5QxJEiJ9wnB8x7zk8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=v/XYBhX38U67qxpzrfE+D2W7xlobRNCgJmF97c15zzfxycg/CFYZiB7QpSmRnFPQX\n\t4zRQWDLUFqa5q62m6zFeFG/ldfxSXRQSTPy9S7PvJAjzRedmooDJm11mfS5nf6x/YU\n\tYT+CCTpnb9ckguwCiDJeJ7bhciTpwvSshNjhUh3s=","Date":"Tue, 17 Mar 2020 13:14:00 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200317111400.GG4864@pendragon.ideasonboard.com>","References":"<20200317035239.2697679-1-niklas.soderlund@ragnatech.se>\n\t<20200317035239.2697679-9-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200317035239.2697679-9-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 8/8] libcamera: PixelFormat: Mark\n\tall function arguments of type PixelFormat as const reference","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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, 17 Mar 2020 11:14:06 -0000"}}]