[libcamera-devel] [PATCH v3 8/8] libcamera: PixelFormat: Mark all function arguments of type PixelFormat as const reference
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Mar 18 04:32:00 CET 2020
PixelFormat was previously an alias for unsigned int but is now a
class. Make all functions taking PixelFormat do so as a const reference.
Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
include/libcamera/stream.h | 4 ++--
src/libcamera/include/v4l2_videodevice.h | 5 +++--
src/libcamera/stream.cpp | 4 ++--
src/libcamera/v4l2_videodevice.cpp | 5 +++--
src/qcam/format_converter.cpp | 4 ++--
src/qcam/format_converter.h | 2 +-
src/qcam/viewfinder.cpp | 4 ++--
src/qcam/viewfinder.h | 2 +-
src/v4l2/v4l2_camera.cpp | 2 +-
src/v4l2/v4l2_camera.h | 2 +-
src/v4l2/v4l2_camera_proxy.cpp | 2 +-
src/v4l2/v4l2_camera_proxy.h | 2 +-
12 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 29a8030dff71d58f..b1441f8ec6749fda 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -28,9 +28,9 @@ public:
StreamFormats(const std::map<PixelFormat, std::vector<SizeRange>> &formats);
std::vector<PixelFormat> pixelformats() const;
- std::vector<Size> sizes(PixelFormat pixelformat) const;
+ std::vector<Size> sizes(const PixelFormat &pixelformat) const;
- SizeRange range(PixelFormat pixelformat) const;
+ SizeRange range(const PixelFormat &pixelformat) const;
private:
std::map<PixelFormat, std::vector<SizeRange>> formats_;
diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h
index 2507daf23efac66f..bc1c6a4d10c76e29 100644
--- a/src/libcamera/include/v4l2_videodevice.h
+++ b/src/libcamera/include/v4l2_videodevice.h
@@ -206,8 +206,9 @@ public:
const std::string &entity);
static PixelFormat toPixelFormat(uint32_t v4l2Fourcc);
- uint32_t toV4L2Fourcc(PixelFormat pixelFormat);
- static uint32_t toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar);
+ uint32_t toV4L2Fourcc(const PixelFormat &pixelFormat);
+ static uint32_t toV4L2Fourcc(const PixelFormat &pixelFormat,
+ bool multiplanar);
protected:
std::string logPrefix() const;
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 0716de388bd81d80..e61484caf7157da5 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -127,7 +127,7 @@ std::vector<PixelFormat> StreamFormats::pixelformats() const
*
* \return A list of frame sizes or an empty list on error
*/
-std::vector<Size> StreamFormats::sizes(PixelFormat pixelformat) const
+std::vector<Size> StreamFormats::sizes(const PixelFormat &pixelformat) const
{
/*
* Sizes to try and extract from ranges.
@@ -240,7 +240,7 @@ std::vector<Size> StreamFormats::sizes(PixelFormat pixelformat) const
*
* \return A range of valid image sizes or an empty range on error
*/
-SizeRange StreamFormats::range(PixelFormat pixelformat) const
+SizeRange StreamFormats::range(const PixelFormat &pixelformat) const
{
auto const it = formats_.find(pixelformat);
if (it == formats_.end())
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 3d2747274dc4c020..70e84daa1e94730e 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1627,7 +1627,7 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)
*
* \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat
*/
-uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat)
+uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat)
{
return V4L2VideoDevice::toV4L2Fourcc(pixelFormat, caps_.isMultiplanar());
}
@@ -1645,7 +1645,8 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat)
*
* \return The V4L2_PIX_FMT_* pixel format code corresponding to \a pixelFormat
*/
-uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar)
+uint32_t V4L2VideoDevice::toV4L2Fourcc(const PixelFormat &pixelFormat,
+ bool multiplanar)
{
switch (pixelFormat.fourcc()) {
/* RGB formats. */
diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp
index 66d07025ac9578ca..1e5edc8cc4cfdb46 100644
--- a/src/qcam/format_converter.cpp
+++ b/src/qcam/format_converter.cpp
@@ -25,8 +25,8 @@
#define CLIP(x) CLAMP(x,0,255)
#endif
-int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width,
- unsigned int height)
+int FormatConverter::configure(const libcamera::PixelFormat &format,
+ unsigned int width, unsigned int height)
{
switch (format.fourcc()) {
case DRM_FORMAT_NV12:
diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h
index ff488b994ade3c3e..96bde2384ddfecc9 100644
--- a/src/qcam/format_converter.h
+++ b/src/qcam/format_converter.h
@@ -16,7 +16,7 @@ class QImage;
class FormatConverter
{
public:
- int configure(libcamera::PixelFormat format, unsigned int width,
+ int configure(const libcamera::PixelFormat &format, unsigned int width,
unsigned int height);
void convert(const unsigned char *src, size_t size, QImage *dst);
diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp
index 0ebb8edd49efd1b1..e9d5cc1e014b048b 100644
--- a/src/qcam/viewfinder.cpp
+++ b/src/qcam/viewfinder.cpp
@@ -44,8 +44,8 @@ QImage ViewFinder::getCurrentImage()
return image_->copy();
}
-int ViewFinder::setFormat(libcamera::PixelFormat format, unsigned int width,
- unsigned int height)
+int ViewFinder::setFormat(const libcamera::PixelFormat &format,
+ unsigned int width, unsigned int height)
{
int ret;
diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h
index 2668aa4457657ef9..0549f038edd6c3b5 100644
--- a/src/qcam/viewfinder.h
+++ b/src/qcam/viewfinder.h
@@ -22,7 +22,7 @@ public:
ViewFinder(QWidget *parent);
~ViewFinder();
- int setFormat(libcamera::PixelFormat format, unsigned int width,
+ int setFormat(const libcamera::PixelFormat &format, unsigned int width,
unsigned int height);
void display(const unsigned char *rgb, size_t size);
diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index f0b9f1804c94378a..ecbb70acfb8eeb52 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -88,7 +88,7 @@ void V4L2Camera::requestComplete(Request *request)
}
int V4L2Camera::configure(StreamConfiguration *streamConfigOut,
- const Size &size, PixelFormat pixelformat,
+ const Size &size, const PixelFormat &pixelformat,
unsigned int bufferCount)
{
StreamConfiguration &streamConfig = config_->at(0);
diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h
index 37bd358462db190d..130995d95eb4bd4c 100644
--- a/src/v4l2/v4l2_camera.h
+++ b/src/v4l2/v4l2_camera.h
@@ -43,7 +43,7 @@ public:
std::vector<Buffer> completedBuffers();
int configure(StreamConfiguration *streamConfigOut,
- const Size &size, PixelFormat pixelformat,
+ const Size &size, const PixelFormat &pixelformat,
unsigned int bufferCount);
int allocBuffers(unsigned int count);
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 547ae2dd6606dec9..0a7542bc39fde4ce 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -598,7 +598,7 @@ PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format)
return info->format;
}
-uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format)
+uint32_t V4L2CameraProxy::drmToV4L2(const PixelFormat &format)
{
auto info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(),
[format](const PixelFormatInfo &info) {
diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
index c8e61adf80f1b93b..e15b230d5f23f119 100644
--- a/src/v4l2/v4l2_camera_proxy.h
+++ b/src/v4l2/v4l2_camera_proxy.h
@@ -60,7 +60,7 @@ private:
unsigned int height);
static PixelFormat v4l2ToDrm(uint32_t format);
- static uint32_t drmToV4L2(PixelFormat format);
+ static uint32_t drmToV4L2(const PixelFormat &format);
unsigned int refcount_;
unsigned int index_;
--
2.25.1
More information about the libcamera-devel
mailing list