{"id":3161,"url":"https://patchwork.libcamera.org/api/1.1/patches/3161/?format=json","web_url":"https://patchwork.libcamera.org/patch/3161/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200318033200.3042855-9-niklas.soderlund@ragnatech.se>","date":"2020-03-18T03:32:00","name":"[libcamera-devel,v3,8/8] libcamera: PixelFormat: Mark all function arguments of type PixelFormat as const reference","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a806ce2e0844e70b3458e0b6f429797252336e10","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3161/mbox/","series":[{"id":730,"url":"https://patchwork.libcamera.org/api/1.1/series/730/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=730","date":"2020-03-18T03:31:52","name":"libcamera: PixelFormat: Turn into a class","version":3,"mbox":"https://patchwork.libcamera.org/series/730/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3161/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3161/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A624C62928\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Mar 2020 04:32:41 +0100 (CET)","from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 1ed75d41-68c9-11ea-9f85-005056917a89;\n\tWed, 18 Mar 2020 04:32:40 +0100 (CET)"],"X-Halon-ID":"1ed75d41-68c9-11ea-9f85-005056917a89","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 18 Mar 2020 04:32:00 +0100","Message-Id":"<20200318033200.3042855-9-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200318033200.3042855-1-niklas.soderlund@ragnatech.se>","References":"<20200318033200.3042855-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 8/8] libcamera: PixelFormat: Mark all\n\tfunction 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":"Wed, 18 Mar 2020 03:32:41 -0000"},"content":"PixelFormat was previously an alias for unsigned int but is now a\nclass. Make all functions taking PixelFormat do so as a const reference.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\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(-)","diff":"diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\nindex 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_;\ndiff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 2507daf23efac66f..bc1c6a4d10c76e29 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;\ndiff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\nindex 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())\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 3d2747274dc4c020..70e84daa1e94730e 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1627,7 +1627,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@@ -1645,7 +1645,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. */\ndiff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex 66d07025ac9578ca..1e5edc8cc4cfdb46 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -25,8 +25,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:\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex 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);\ndiff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex 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 \ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex 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 \ndiff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 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);\ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 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);\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 547ae2dd6606dec9..0a7542bc39fde4ce 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -598,7 +598,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) {\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex 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_;\n","prefixes":["libcamera-devel","v3","8/8"]}