From patchwork Wed Mar 18 03:31:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3154 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 868DE6041A for ; Wed, 18 Mar 2020 04:32:36 +0100 (CET) X-Halon-ID: 1bbc1db1-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1bbc1db1-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:35 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:53 +0100 Message-Id: <20200318033200.3042855-2-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 Subject: [libcamera-devel] [PATCH v3 1/8] libcamera: Use PixelFormat instead of unsigned int where appropriate X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:36 -0000 Use the PixelFormat instead of unsigned int where a pixel format is to be used. PixelFormat is defined as an unsigned int but is about to be turned into a class to add functionality. There is no functional change in this patch. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/cam/main.cpp | 2 +- src/gstreamer/gstlibcamera-utils.cpp | 10 +++++----- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc.cpp | 4 ++-- src/qcam/format_converter.cpp | 2 +- src/qcam/format_converter.h | 6 ++++-- src/qcam/viewfinder.cpp | 2 +- src/qcam/viewfinder.h | 6 ++++-- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index ea6f7914839c703e..af516f1cbf23974a 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -303,7 +303,7 @@ int CamApp::infoConfiguration() std::cout << index << ": " << cfg.toString() << std::endl; const StreamFormats &formats = cfg.formats(); - for (unsigned int pixelformat : formats.pixelformats()) { + for (PixelFormat pixelformat : formats.pixelformats()) { std::cout << " * Pixelformat: 0x" << std::hex << std::setw(8) << pixelformat << " " << formats.range(pixelformat).toString() diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 44a993fa6b6f4da1..3b3973bcea3dc759 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -79,16 +79,16 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) { GstCaps *caps = gst_caps_new_empty(); - for (unsigned int fourcc : formats.pixelformats()) { - g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(fourcc); + for (PixelFormat pixelformat : formats.pixelformats()) { + g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat); if (!bare_s) { GST_WARNING("Unsupported DRM format %" GST_FOURCC_FORMAT, - GST_FOURCC_ARGS(fourcc)); + GST_FOURCC_ARGS(pixelformat)); continue; } - for (const Size &size : formats.sizes(fourcc)) { + for (const Size &size : formats.sizes(pixelformat)) { GstStructure *s = gst_structure_copy(bare_s); gst_structure_set(s, "width", G_TYPE_INT, size.width, @@ -97,7 +97,7 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) gst_caps_append_structure(caps, s); } - const SizeRange &range = formats.range(fourcc); + const SizeRange &range = formats.range(pixelformat); if (range.hStep && range.vStep) { GstStructure *s = gst_structure_copy(bare_s); GValue val = G_VALUE_INIT; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 6b93c50978a76630..0c2a217c9ea8f6ba 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -348,7 +348,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() for (unsigned int i = 0; i < config_.size(); ++i) { StreamConfiguration &cfg = config_[i]; - const unsigned int pixelFormat = cfg.pixelFormat; + const PixelFormat pixelFormat = cfg.pixelFormat; const Size size = cfg.size; const IPU3Stream *stream; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 01977ad697a91a44..dec0ad6118241ff1 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -431,7 +431,7 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera, CameraConfiguration::Status RkISP1CameraConfiguration::validate() { - static const std::array formats{ + static const std::array formats{ DRM_FORMAT_YUYV, DRM_FORMAT_YVYU, DRM_FORMAT_VYUY, diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 40cc3ee7d0987ba9..320da2685795c041 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -105,10 +105,10 @@ CameraConfiguration::Status UVCCameraConfiguration::validate() StreamConfiguration &cfg = config_[0]; const StreamFormats &formats = cfg.formats(); - const unsigned int pixelFormat = cfg.pixelFormat; + const PixelFormat pixelFormat = cfg.pixelFormat; const Size size = cfg.size; - const std::vector pixelFormats = formats.pixelformats(); + const std::vector pixelFormats = formats.pixelformats(); auto iter = std::find(pixelFormats.begin(), pixelFormats.end(), pixelFormat); if (iter == pixelFormats.end()) { cfg.pixelFormat = pixelFormats.front(); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index eceb16d5586acf09..a30e416e6000bcda 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -104,7 +104,7 @@ private: namespace { -constexpr std::array pixelformats{ +constexpr std::array pixelformats{ DRM_FORMAT_RGB888, DRM_FORMAT_BGR888, DRM_FORMAT_BGRA8888, @@ -175,7 +175,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, ImageFormats formats; - for (unsigned int pixelformat : pixelformats) { + for (PixelFormat pixelformat : pixelformats) { /* The scaler hardcodes a x3 scale-up ratio. */ std::vector sizes{ SizeRange{ 48, 48, 4096, 2160 } diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp index 4604143419dde1bd..d4a66f381f5a1b78 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -27,7 +27,7 @@ #define CLIP(x) CLAMP(x,0,255) #endif -int FormatConverter::configure(unsigned int format, unsigned int width, +int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width, unsigned int height) { switch (format) { diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h index 391e6a44d4ba7d4b..ff488b994ade3c3e 100644 --- a/src/qcam/format_converter.h +++ b/src/qcam/format_converter.h @@ -9,12 +9,14 @@ #include +#include + class QImage; class FormatConverter { public: - int configure(unsigned int format, unsigned int width, + int configure(libcamera::PixelFormat format, unsigned int width, unsigned int height); void convert(const unsigned char *src, size_t size, QImage *dst); @@ -31,7 +33,7 @@ private: void convertRGB(const unsigned char *src, unsigned char *dst); void convertYUV(const unsigned char *src, unsigned char *dst); - unsigned int format_; + libcamera::PixelFormat format_; unsigned int width_; unsigned int height_; diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp index d51eebb10aef8663..0ebb8edd49efd1b1 100644 --- a/src/qcam/viewfinder.cpp +++ b/src/qcam/viewfinder.cpp @@ -44,7 +44,7 @@ QImage ViewFinder::getCurrentImage() return image_->copy(); } -int ViewFinder::setFormat(unsigned int format, unsigned int width, +int ViewFinder::setFormat(libcamera::PixelFormat format, unsigned int width, unsigned int height) { int ret; diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h index 2ba28b60345b0cb3..2668aa4457657ef9 100644 --- a/src/qcam/viewfinder.h +++ b/src/qcam/viewfinder.h @@ -10,6 +10,8 @@ #include #include +#include + #include "format_converter.h" class QImage; @@ -20,7 +22,7 @@ public: ViewFinder(QWidget *parent); ~ViewFinder(); - int setFormat(unsigned int format, unsigned int width, + int setFormat(libcamera::PixelFormat format, unsigned int width, unsigned int height); void display(const unsigned char *rgb, size_t size); @@ -31,7 +33,7 @@ protected: QSize sizeHint() const override; private: - unsigned int format_; + libcamera::PixelFormat format_; unsigned int width_; unsigned int height_; From patchwork Wed Mar 18 03:31:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3155 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E6C3E6041A for ; Wed, 18 Mar 2020 04:32:36 +0100 (CET) X-Halon-ID: 1c3f677a-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1c3f677a-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:36 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:54 +0100 Message-Id: <20200318033200.3042855-3-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 Subject: [libcamera-devel] [PATCH v3 2/8] libcamera: pixelformats: include linux/drm_fourcc.h X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:37 -0000 Instead of having to include linux/drm_fourcc.h everywhere a DRM FourCC are used in conjunction with PixelFormat include the header directly in pixelformats.h. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- include/libcamera/pixelformats.h | 2 ++ src/libcamera/pipeline/ipu3/ipu3.cpp | 1 - src/libcamera/pipeline/rkisp1/rkisp1.cpp | 1 - src/libcamera/pipeline/vimc.cpp | 1 - src/libcamera/v4l2_videodevice.cpp | 1 - src/qcam/format_converter.cpp | 2 -- src/v4l2/v4l2_camera_proxy.cpp | 1 - 7 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index 6e25b8d8b76e5961..544363af7a8c6f05 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -9,6 +9,8 @@ #include +#include + namespace libcamera { using PixelFormat = uint32_t; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0c2a217c9ea8f6ba..1e3d8a107c6475be 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index dec0ad6118241ff1..a95ae48ac8cfbc98 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index a30e416e6000bcda..de2458afff3a4784 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 858310c3b810350a..3869766046236f34 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp index d4a66f381f5a1b78..7b8ad77c42fe85d4 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -7,8 +7,6 @@ #include -#include - #include #include "format_converter.h" diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index b620f236499cf77d..e349fbddc2a4d5a2 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include From patchwork Wed Mar 18 03:31:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3156 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74D7D6297B for ; Wed, 18 Mar 2020 04:32:37 +0100 (CET) X-Halon-ID: 1c93e98d-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1c93e98d-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:36 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:55 +0100 Message-Id: <20200318033200.3042855-4-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 Subject: [libcamera-devel] [PATCH v3 3/8] test: v4l2_videodevice: buffer_cache: Use DRM pixel format X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:37 -0000 The pixel format used in the stream configuration is from V4L2 but should be from DRM, fix it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- test/v4l2_videodevice/buffer_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp index 0a8cb0d28ca9b204..e6edd2fad7aa3d33 100644 --- a/test/v4l2_videodevice/buffer_cache.cpp +++ b/test/v4l2_videodevice/buffer_cache.cpp @@ -142,7 +142,7 @@ public: const unsigned int numBuffers = 8; StreamConfiguration cfg; - cfg.pixelFormat = V4L2_PIX_FMT_YUYV; + cfg.pixelFormat = DRM_FORMAT_YUYV; cfg.size = Size(600, 800); cfg.bufferCount = numBuffers; From patchwork Wed Mar 18 03:31:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3157 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 211E2629AA for ; Wed, 18 Mar 2020 04:32:38 +0100 (CET) X-Halon-ID: 1ce32bb3-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1ce32bb3-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:37 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:56 +0100 Message-Id: <20200318033200.3042855-5-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 Subject: [libcamera-devel] [PATCH v3 4/8] libcamera: pipeline: vimc: Remove internal usage of ImageFormats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:39 -0000 There is no need to use the ImageFormats helper to generate a map of PixelFormat to sizes, use std::map directly. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/vimc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index de2458afff3a4784..04cad94e739e9ae9 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -172,17 +172,17 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats formats; + std::map> formats; for (PixelFormat pixelformat : pixelformats) { /* The scaler hardcodes a x3 scale-up ratio. */ std::vector sizes{ SizeRange{ 48, 48, 4096, 2160 } }; - formats.addFormat(pixelformat, sizes); + formats[pixelformat] = sizes; } - StreamConfiguration cfg(formats.data()); + StreamConfiguration cfg(formats); cfg.pixelFormat = DRM_FORMAT_BGR888; cfg.size = { 1920, 1080 }; From patchwork Wed Mar 18 03:31:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3158 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90DEC629AE for ; Wed, 18 Mar 2020 04:32:38 +0100 (CET) X-Halon-ID: 1d31c314-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1d31c314-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:37 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:57 +0100 Message-Id: <20200318033200.3042855-6-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 Subject: [libcamera-devel] [PATCH v3 5/8] libcamera: pipeline: uvcvideo: Translate from V4L2 to DRM pixel formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:39 -0000 When generating a camera configuration pixel formats directly from the video device are used that contains V4L2 pixel formats. Translate the pixel formats to DRM before using them in the camera configuration. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 320da2685795c041..1de091e0c0e57f7c 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -153,8 +153,19 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats v4l2formats = data->video_->formats(); - StreamFormats formats(v4l2formats.data()); + std::map> v4l2Formats = + data->video_->formats().data(); + std::map> deviceFormats; + std::transform(v4l2Formats.begin(), v4l2Formats.end(), + std::inserter(deviceFormats, deviceFormats.begin()), + [&](const decltype(v4l2Formats)::value_type &format) { + return decltype(deviceFormats)::value_type{ + data->video_->toPixelFormat(format.first), + format.second + }; + }); + + StreamFormats formats(deviceFormats); StreamConfiguration cfg(formats); cfg.pixelFormat = formats.pixelformats().front(); From patchwork Wed Mar 18 03:31:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3159 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8769A6298E for ; Wed, 18 Mar 2020 04:32:39 +0100 (CET) X-Halon-ID: 1d81b2dd-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1d81b2dd-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:38 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:58 +0100 Message-Id: <20200318033200.3042855-7-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 Subject: [libcamera-devel] [PATCH v3 6/8] libcamera: PixelFormat: Turn into a class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:40 -0000 Create a class to represent a pixel format. This is done to add support for modifiers for the formats. So far no modifiers are added by any pipeline handler, all plumbing to deal with them is however in place. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- * Changes since v2 - Add isValid() - Add operator uint32_t() - Handle modifiers in operator<() - Remove include for log.h * Changes since v1 - Remove copy constructor and operator= - Removed LOG_DEFINE_CATEGORY - Updated documentation - Improved toString() * Changes since RFC - Drop table of translation from V4L2 to DRM fourcc and turn PixelFormat into a more basic data container class. --- include/libcamera/pixelformats.h | 25 ++++++- src/cam/main.cpp | 6 +- src/gstreamer/gstlibcamera-utils.cpp | 8 +-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/uvcvideo.cpp | 5 +- src/libcamera/pipeline/vimc.cpp | 2 +- src/libcamera/pixelformats.cpp | 87 ++++++++++++++++++++++-- src/libcamera/stream.cpp | 4 +- src/libcamera/v4l2_videodevice.cpp | 5 +- src/qcam/format_converter.cpp | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 4 +- 11 files changed, 124 insertions(+), 26 deletions(-) diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index 544363af7a8c6f05..eb40e55ac159505a 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -7,13 +7,36 @@ #ifndef __LIBCAMERA_PIXEL_FORMATS_H__ #define __LIBCAMERA_PIXEL_FORMATS_H__ +#include #include +#include #include namespace libcamera { -using PixelFormat = uint32_t; +class PixelFormat +{ +public: + PixelFormat(); + PixelFormat(uint32_t fourcc, const std::set &modifiers = {}); + + bool operator==(const PixelFormat &other) const; + bool operator!=(const PixelFormat &other) const { return !(*this == other); } + bool operator<(const PixelFormat &other) const; + + bool isValid() const { return fourcc_ != 0; } + + operator uint32_t() const { return fourcc_; } + uint32_t fourcc() const { return fourcc_; } + const std::set &modifiers() const { return modifiers_; } + + std::string toString() const; + +private: + uint32_t fourcc_; + std::set modifiers_; +}; } /* namespace libcamera */ diff --git a/src/cam/main.cpp b/src/cam/main.cpp index af516f1cbf23974a..f73e77f381779853 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -253,7 +253,7 @@ int CamApp::prepareConfig() /* TODO: Translate 4CC string to ID. */ if (opt.isSet("pixelformat")) - cfg.pixelFormat = opt["pixelformat"]; + cfg.pixelFormat = PixelFormat(opt["pixelformat"]); } } @@ -304,8 +304,8 @@ int CamApp::infoConfiguration() const StreamFormats &formats = cfg.formats(); for (PixelFormat pixelformat : formats.pixelformats()) { - std::cout << " * Pixelformat: 0x" << std::hex - << std::setw(8) << pixelformat << " " + std::cout << " * Pixelformat: " + << pixelformat.toString() << " " << formats.range(pixelformat).toString() << std::endl; diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 3b3973bcea3dc759..f21e94c3eef92737 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -80,11 +80,11 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) GstCaps *caps = gst_caps_new_empty(); for (PixelFormat pixelformat : formats.pixelformats()) { - g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat); + g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(pixelformat.fourcc()); if (!bare_s) { GST_WARNING("Unsupported DRM format %" GST_FOURCC_FORMAT, - GST_FOURCC_ARGS(pixelformat)); + GST_FOURCC_ARGS(pixelformat.fourcc())); continue; } @@ -120,7 +120,7 @@ GstCaps * gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg) { GstCaps *caps = gst_caps_new_empty(); - GstStructure *s = bare_structure_from_fourcc(stream_cfg.pixelFormat); + GstStructure *s = bare_structure_from_fourcc(stream_cfg.pixelFormat.fourcc()); gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, @@ -135,7 +135,7 @@ void gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg, GstCaps *caps) { - GstVideoFormat gst_format = drm_to_gst_format(stream_cfg.pixelFormat); + GstVideoFormat gst_format = drm_to_gst_format(stream_cfg.pixelFormat.fourcc()); /* First fixate the caps using default configuration value. */ g_assert(gst_caps_is_writable(caps)); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index a95ae48ac8cfbc98..8a11deb814bc0bfb 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -789,7 +789,7 @@ int PipelineHandlerRkISP1::start(Camera *camera) /* Inform IPA of stream configuration and sensor controls. */ std::map streamConfig; streamConfig[0] = { - .pixelFormat = data->stream_.configuration().pixelFormat, + .pixelFormat = data->stream_.configuration().pixelFormat.fourcc(), .size = data->stream_.configuration().size, }; diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 1de091e0c0e57f7c..731149755728f209 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -113,8 +113,9 @@ CameraConfiguration::Status UVCCameraConfiguration::validate() if (iter == pixelFormats.end()) { cfg.pixelFormat = pixelFormats.front(); LOG(UVC, Debug) - << "Adjusting pixel format from " << pixelFormat - << " to " << cfg.pixelFormat; + << "Adjusting pixel format from " + << pixelFormat.toString() << " to " + << cfg.pixelFormat.toString(); status = Adjusted; } diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 04cad94e739e9ae9..2e2162b2bf4477c5 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -103,7 +103,7 @@ private: namespace { -constexpr std::array pixelformats{ +static const std::array pixelformats{ DRM_FORMAT_RGB888, DRM_FORMAT_BGR888, DRM_FORMAT_BGRA8888, diff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp index c03335400b709d9b..929578fed3e22c92 100644 --- a/src/libcamera/pixelformats.cpp +++ b/src/libcamera/pixelformats.cpp @@ -15,14 +15,91 @@ namespace libcamera { /** - * \typedef PixelFormat + * \class PixelFormat * \brief libcamera image pixel format * * The PixelFormat type describes the format of images in the public libcamera - * API. It stores a FourCC value as a 32-bit unsigned integer. The values are - * defined in the Linux kernel DRM/KMS API (see linux/drm_fourcc.h). - * - * \todo Add support for format modifiers + * API. It stores a FourCC value as a 32-bit unsigned integer and a set of + * modifiers. The FourCC and modifiers values are defined in the Linux kernel + * DRM/KMS API (see linux/drm_fourcc.h). */ +PixelFormat::PixelFormat() + : fourcc_(0) +{ +} + +/** + * \brief Construct a PixelFormat from a DRM FourCC and a set of modifiers + * \param[in] fourcc A DRM FourCC + * \param[in] modifiers A set of DRM FourCC modifiers + */ +PixelFormat::PixelFormat(uint32_t fourcc, const std::set &modifiers) + : fourcc_(fourcc), modifiers_(modifiers) +{ +} + +/** + * \brief Compare pixel formats for equality + * \return True if the two pixel formats are equal, false otherwise + */ +bool PixelFormat::operator==(const PixelFormat &other) const +{ + return fourcc_ == other.fourcc() && modifiers_ == other.modifiers_; +} + +/** + * \fn bool PixelFormat::operator!=(const PixelFormat &other) const + * \brief Compare pixel formats for inequality + * \return True if the two pixel formats are not equal, false otherwise + */ + +/** + * \brief Compare pixel formats for smaller than order + * \return True if \a this is smaller than \a other, false otherwise + */ +bool PixelFormat::operator<(const PixelFormat &other) const +{ + if (fourcc_ < other.fourcc_) + return true; + if (fourcc_ > other.fourcc_) + return false; + return modifiers_ < modifiers_; +} + +/** + * \fn bool PixelFormat::isValid() const + * \brief Check if the pixel format is valid + * \return True if the pixel format has a non-zero value, false otherwise + */ + +/** + * \fn PixelFormat::operator uint32_t() const + * \brief Convert the the pixel format numerical value + * \return The pixel format numerical value + */ + +/** + * \fn PixelFormat::fourcc() const + * \brief Retrieve the pixel format FourCC + * \return DRM FourCC + */ + +/** + * \fn PixelFormat::modifiers() const + * \brief Retrieve the pixel format modifiers + * \return Set of DRM modifiers + */ + +/** + * \brief Assemble and return a string describing the pixel format + * \return A string describing the pixel format + */ +std::string PixelFormat::toString() const +{ + char str[11]; + snprintf(str, 11, "0x%08x", fourcc_); + return str; +} + } /* namespace libcamera */ diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 13789e9eb344f95c..0716de388bd81d80 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -347,9 +347,7 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) */ std::string StreamConfiguration::toString() const { - std::stringstream ss; - ss << size.toString() << "-" << utils::hex(pixelFormat); - return ss.str(); + return size.toString() + "-" + pixelFormat.toString(); } /** diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 3869766046236f34..c8ba0f8cebedb91a 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1647,7 +1647,7 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat) */ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar) { - switch (pixelFormat) { + switch (pixelFormat.fourcc()) { /* RGB formats. */ case DRM_FORMAT_BGR888: return V4L2_PIX_FMT_RGB24; @@ -1691,8 +1691,7 @@ uint32_t V4L2VideoDevice::toV4L2Fourcc(PixelFormat pixelFormat, bool multiplanar * class. Until we fix the logger, work around it. */ libcamera::_log(__FILE__, __LINE__, _LOG_CATEGORY(V4L2)(), LogError).stream() - << "Unsupported V4L2 pixel format " - << utils::hex(pixelFormat); + << "Unsupported V4L2 pixel format " << pixelFormat.toString(); return 0; } diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp index 7b8ad77c42fe85d4..66d07025ac9578ca 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -28,7 +28,7 @@ int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width, unsigned int height) { - switch (format) { + switch (format.fourcc()) { case DRM_FORMAT_NV12: formatFamily_ = NV; horzSubSample_ = 2; diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index e349fbddc2a4d5a2..c6d1e5030b58b630 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -533,7 +533,7 @@ struct PixelFormatInfo { namespace { -constexpr std::array pixelFormatInfo = {{ +static const std::array pixelFormatInfo = {{ /* RGB formats. */ { DRM_FORMAT_RGB888, V4L2_PIX_FMT_BGR24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, { DRM_FORMAT_BGR888, V4L2_PIX_FMT_RGB24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, @@ -605,7 +605,7 @@ uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format) return info.format == format; }); if (info == pixelFormatInfo.end()) - return format; + return format.fourcc(); return info->v4l2Format; } From patchwork Wed Mar 18 03:31:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3160 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1F1C6298E for ; Wed, 18 Mar 2020 04:32:40 +0100 (CET) X-Halon-ID: 1e2351f7-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1e2351f7-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:39 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Mar 2020 04:31:59 +0100 Message-Id: <20200318033200.3042855-8-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 Subject: [libcamera-devel] [PATCH v3 7/8] libcamera: PixelFormat: Make constructor explicit X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:41 -0000 From: Laurent Pinchart To achieve the goal of preventing unwanted conversion between a DRM and a V4L2 FourCC, make the PixelFormat constructor that takes an integer value explicit. All users of pixel formats flagged by the compiler are fixed. Signed-off-by: Laurent Pinchart Signed-off-by: Niklas Söderlund --- * Changes since v2 - Moved compare operations to where PixelFormat class is added. --- include/libcamera/pixelformats.h | 2 +- src/gstreamer/gstlibcamera-utils.cpp | 4 ++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 6 ++--- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 18 +++++++-------- src/libcamera/pipeline/vimc.cpp | 10 ++++----- src/libcamera/v4l2_videodevice.cpp | 26 +++++++++++----------- src/v4l2/v4l2_camera_proxy.cpp | 28 ++++++++++++------------ test/stream/stream_formats.cpp | 24 ++++++++++---------- test/v4l2_videodevice/buffer_cache.cpp | 2 +- 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index eb40e55ac159505a..9ce6f7f082d259f8 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -19,7 +19,7 @@ class PixelFormat { public: PixelFormat(); - PixelFormat(uint32_t fourcc, const std::set &modifiers = {}); + explicit PixelFormat(uint32_t fourcc, const std::set &modifiers = {}); bool operator==(const PixelFormat &other) const; bool operator!=(const PixelFormat &other) const { return !(*this == other); } diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index f21e94c3eef92737..c13b0ca245386168 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -154,9 +154,9 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg, if (gst_structure_has_name(s, "video/x-raw")) { const gchar *format = gst_structure_get_string(s, "format"); gst_format = gst_video_format_from_string(format); - stream_cfg.pixelFormat = gst_format_to_drm(gst_format); + stream_cfg.pixelFormat = PixelFormat(gst_format_to_drm(gst_format)); } else if (gst_structure_has_name(s, "image/jpeg")) { - stream_cfg.pixelFormat = DRM_FORMAT_MJPEG; + stream_cfg.pixelFormat = PixelFormat(DRM_FORMAT_MJPEG); } else { g_critical("Unsupported media type: %s", gst_structure_get_name(s)); } diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 1e3d8a107c6475be..55ce8fa16af160d6 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -245,7 +245,7 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera, void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale) { /* The only pixel format the driver supports is NV12. */ - cfg.pixelFormat = DRM_FORMAT_NV12; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12); if (scale) { /* @@ -400,7 +400,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, StreamConfiguration cfg = {}; IPU3Stream *stream = nullptr; - cfg.pixelFormat = DRM_FORMAT_NV12; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12); switch (role) { case StreamRole::StillCapture: @@ -1078,7 +1078,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output, return 0; V4L2DeviceFormat outputFormat = {}; - outputFormat.fourcc = dev->toV4L2Fourcc(DRM_FORMAT_NV12); + outputFormat.fourcc = dev->toV4L2Fourcc(PixelFormat(DRM_FORMAT_NV12)); outputFormat.size = cfg.size; outputFormat.planesCount = 2; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a11deb814bc0bfb..80bd2185bfd7e827 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -431,13 +431,13 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera, CameraConfiguration::Status RkISP1CameraConfiguration::validate() { static const std::array formats{ - DRM_FORMAT_YUYV, - DRM_FORMAT_YVYU, - DRM_FORMAT_VYUY, - DRM_FORMAT_NV16, - DRM_FORMAT_NV61, - DRM_FORMAT_NV21, - DRM_FORMAT_NV12, + PixelFormat(DRM_FORMAT_YUYV), + PixelFormat(DRM_FORMAT_YVYU), + PixelFormat(DRM_FORMAT_VYUY), + PixelFormat(DRM_FORMAT_NV16), + PixelFormat(DRM_FORMAT_NV61), + PixelFormat(DRM_FORMAT_NV21), + PixelFormat(DRM_FORMAT_NV12), /* \todo Add support for 8-bit greyscale to DRM formats */ }; @@ -459,7 +459,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) { LOG(RkISP1, Debug) << "Adjusting format to NV12"; - cfg.pixelFormat = DRM_FORMAT_NV12, + cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12), status = Adjusted; } @@ -538,7 +538,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera return config; StreamConfiguration cfg{}; - cfg.pixelFormat = DRM_FORMAT_NV12; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12); cfg.size = data->sensor_->resolution(); config->addConfiguration(cfg); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 2e2162b2bf4477c5..fa84f0c1b20d3182 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -104,9 +104,9 @@ private: namespace { static const std::array pixelformats{ - DRM_FORMAT_RGB888, - DRM_FORMAT_BGR888, - DRM_FORMAT_BGRA8888, + PixelFormat(DRM_FORMAT_RGB888), + PixelFormat(DRM_FORMAT_BGR888), + PixelFormat(DRM_FORMAT_BGRA8888), }; } /* namespace */ @@ -135,7 +135,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate() if (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) == pixelformats.end()) { LOG(VIMC, Debug) << "Adjusting format to RGB24"; - cfg.pixelFormat = DRM_FORMAT_BGR888; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888); status = Adjusted; } @@ -184,7 +184,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, StreamConfiguration cfg(formats); - cfg.pixelFormat = DRM_FORMAT_BGR888; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888); cfg.size = { 1920, 1080 }; cfg.bufferCount = 4; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index c8ba0f8cebedb91a..3d2747274dc4c020 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1567,39 +1567,39 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) switch (v4l2Fourcc) { /* RGB formats. */ case V4L2_PIX_FMT_RGB24: - return DRM_FORMAT_BGR888; + return PixelFormat(DRM_FORMAT_BGR888); case V4L2_PIX_FMT_BGR24: - return DRM_FORMAT_RGB888; + return PixelFormat(DRM_FORMAT_RGB888); case V4L2_PIX_FMT_ARGB32: - return DRM_FORMAT_BGRA8888; + return PixelFormat(DRM_FORMAT_BGRA8888); /* YUV packed formats. */ case V4L2_PIX_FMT_YUYV: - return DRM_FORMAT_YUYV; + return PixelFormat(DRM_FORMAT_YUYV); case V4L2_PIX_FMT_YVYU: - return DRM_FORMAT_YVYU; + return PixelFormat(DRM_FORMAT_YVYU); case V4L2_PIX_FMT_UYVY: - return DRM_FORMAT_UYVY; + return PixelFormat(DRM_FORMAT_UYVY); case V4L2_PIX_FMT_VYUY: - return DRM_FORMAT_VYUY; + return PixelFormat(DRM_FORMAT_VYUY); /* YUY planar formats. */ case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV16M: - return DRM_FORMAT_NV16; + return PixelFormat(DRM_FORMAT_NV16); case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV61M: - return DRM_FORMAT_NV61; + return PixelFormat(DRM_FORMAT_NV61); case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12M: - return DRM_FORMAT_NV12; + return PixelFormat(DRM_FORMAT_NV12); case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21M: - return DRM_FORMAT_NV21; + return PixelFormat(DRM_FORMAT_NV21); /* Compressed formats. */ case V4L2_PIX_FMT_MJPEG: - return DRM_FORMAT_MJPEG; + return PixelFormat(DRM_FORMAT_MJPEG); /* V4L2 formats not yet supported by DRM. */ case V4L2_PIX_FMT_GREY: @@ -1612,7 +1612,7 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc) LogError).stream() << "Unsupported V4L2 pixel format " << utils::hex(v4l2Fourcc); - return 0; + return PixelFormat(); } } diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index c6d1e5030b58b630..547ae2dd6606dec9 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -535,21 +535,21 @@ namespace { static const std::array pixelFormatInfo = {{ /* RGB formats. */ - { DRM_FORMAT_RGB888, V4L2_PIX_FMT_BGR24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_BGR888, V4L2_PIX_FMT_RGB24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_BGRA8888, V4L2_PIX_FMT_ARGB32, 1, {{ { 32, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_RGB888), V4L2_PIX_FMT_BGR24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_BGR888), V4L2_PIX_FMT_RGB24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_BGRA8888), V4L2_PIX_FMT_ARGB32, 1, {{ { 32, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, /* YUV packed formats. */ - { DRM_FORMAT_UYVY, V4L2_PIX_FMT_UYVY, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_VYUY, V4L2_PIX_FMT_VYUY, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_YUYV, V4L2_PIX_FMT_YUYV, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_YVYU, V4L2_PIX_FMT_YVYU, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_UYVY), V4L2_PIX_FMT_UYVY, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_VYUY), V4L2_PIX_FMT_VYUY, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_YUYV), V4L2_PIX_FMT_YUYV, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_YVYU), V4L2_PIX_FMT_YVYU, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, /* YUY planar formats. */ - { DRM_FORMAT_NV12, V4L2_PIX_FMT_NV12, 2, {{ { 8, 1, 1 }, { 16, 2, 2 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_NV21, V4L2_PIX_FMT_NV21, 2, {{ { 8, 1, 1 }, { 16, 2, 2 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_NV16, V4L2_PIX_FMT_NV16, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_NV61, V4L2_PIX_FMT_NV61, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_NV24, V4L2_PIX_FMT_NV24, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, - { DRM_FORMAT_NV42, V4L2_PIX_FMT_NV42, 2, {{ { 8, 1, 1 }, { 16, 1, 1 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV12), V4L2_PIX_FMT_NV12, 2, {{ { 8, 1, 1 }, { 16, 2, 2 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV21), V4L2_PIX_FMT_NV21, 2, {{ { 8, 1, 1 }, { 16, 2, 2 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV16), V4L2_PIX_FMT_NV16, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV61), V4L2_PIX_FMT_NV61, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV24), V4L2_PIX_FMT_NV24, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, + { PixelFormat(DRM_FORMAT_NV42), V4L2_PIX_FMT_NV42, 2, {{ { 8, 1, 1 }, { 16, 1, 1 }, { 0, 0, 0 } }} }, }}; } /* namespace */ @@ -593,7 +593,7 @@ PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format) return info.v4l2Format == format; }); if (info == pixelFormatInfo.end()) - return format; + return PixelFormat(); return info->format; } diff --git a/test/stream/stream_formats.cpp b/test/stream/stream_formats.cpp index a391f5cd087d3872..92f1574b8a0b315c 100644 --- a/test/stream/stream_formats.cpp +++ b/test/stream/stream_formats.cpp @@ -55,40 +55,40 @@ protected: { /* Test discrete sizes */ StreamFormats discrete({ - { 1, { SizeRange(100, 100), SizeRange(200, 200) } }, - { 2, { SizeRange(300, 300), SizeRange(400, 400) } }, + { PixelFormat(1), { SizeRange(100, 100), SizeRange(200, 200) } }, + { PixelFormat(2), { SizeRange(300, 300), SizeRange(400, 400) } }, }); - if (testSizes("discrete 1", discrete.sizes(1), + if (testSizes("discrete 1", discrete.sizes(PixelFormat(1)), { Size(100, 100), Size(200, 200) })) return TestFail; - if (testSizes("discrete 2", discrete.sizes(2), + if (testSizes("discrete 2", discrete.sizes(PixelFormat(2)), { Size(300, 300), Size(400, 400) })) return TestFail; /* Test range sizes */ StreamFormats range({ - { 1, { SizeRange(640, 480, 640, 480) } }, - { 2, { SizeRange(640, 480, 800, 600, 8, 8) } }, - { 3, { SizeRange(640, 480, 800, 600, 16, 16) } }, - { 4, { SizeRange(128, 128, 4096, 4096, 128, 128) } }, + { PixelFormat(1), { SizeRange(640, 480, 640, 480) } }, + { PixelFormat(2), { SizeRange(640, 480, 800, 600, 8, 8) } }, + { PixelFormat(3), { SizeRange(640, 480, 800, 600, 16, 16) } }, + { PixelFormat(4), { SizeRange(128, 128, 4096, 4096, 128, 128) } }, }); - if (testSizes("range 1", range.sizes(1), { Size(640, 480) })) + if (testSizes("range 1", range.sizes(PixelFormat(1)), { Size(640, 480) })) return TestFail; - if (testSizes("range 2", range.sizes(2), { + if (testSizes("range 2", range.sizes(PixelFormat(2)), { Size(640, 480), Size(720, 480), Size(720, 576), Size(768, 480), Size(800, 600) })) return TestFail; - if (testSizes("range 3", range.sizes(3), { + if (testSizes("range 3", range.sizes(PixelFormat(3)), { Size(640, 480), Size(720, 480), Size(720, 576), Size(768, 480) })) return TestFail; - if (testSizes("range 4", range.sizes(4), { + if (testSizes("range 4", range.sizes(PixelFormat(4)), { Size(1024, 768), Size(1280, 1024), Size(2048, 1152), Size(2048, 1536), Size(2560, 2048), Size(3200, 2048), })) diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp index e6edd2fad7aa3d33..d730e7550377430e 100644 --- a/test/v4l2_videodevice/buffer_cache.cpp +++ b/test/v4l2_videodevice/buffer_cache.cpp @@ -142,7 +142,7 @@ public: const unsigned int numBuffers = 8; StreamConfiguration cfg; - cfg.pixelFormat = DRM_FORMAT_YUYV; + cfg.pixelFormat = PixelFormat(DRM_FORMAT_YUYV); cfg.size = Size(600, 800); cfg.bufferCount = numBuffers; From patchwork Wed Mar 18 03:32:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3161 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A624C62928 for ; Wed, 18 Mar 2020 04:32:41 +0100 (CET) X-Halon-ID: 1ed75d41-68c9-11ea-9f85-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1ed75d41-68c9-11ea-9f85-005056917a89; Wed, 18 Mar 2020 04:32:40 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= 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 Subject: [libcamera-devel] [PATCH v3 8/8] libcamera: PixelFormat: Mark all 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 03:32:41 -0000 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 Reviewed-by: Laurent Pinchart --- 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> &formats); std::vector pixelformats() const; - std::vector sizes(PixelFormat pixelformat) const; + std::vector sizes(const PixelFormat &pixelformat) const; - SizeRange range(PixelFormat pixelformat) const; + SizeRange range(const PixelFormat &pixelformat) const; private: std::map> 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 StreamFormats::pixelformats() const * * \return A list of frame sizes or an empty list on error */ -std::vector StreamFormats::sizes(PixelFormat pixelformat) const +std::vector StreamFormats::sizes(const PixelFormat &pixelformat) const { /* * Sizes to try and extract from ranges. @@ -240,7 +240,7 @@ std::vector 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 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_;