From patchwork Tue Mar 17 03:52:32 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: 3132 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CFBB560416 for ; Tue, 17 Mar 2020 04:53:36 +0100 (CET) X-Halon-ID: d9e71ce9-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id d9e71ce9-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:24 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:32 +0100 Message-Id: <20200317035239.2697679-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Tue, 17 Mar 2020 03:53:37 -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/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc.cpp | 2 +- src/qcam/format_converter.cpp | 2 +- src/qcam/format_converter.h | 6 ++++-- src/qcam/viewfinder.cpp | 2 +- src/qcam/viewfinder.h | 6 ++++-- 9 files changed, 20 insertions(+), 16 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/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..8792dfe48ed8db31 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -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 383d482231400a44..368cb43fbf17ae4d 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 Tue Mar 17 03:52:33 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: 3133 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4350262992 for ; Tue, 17 Mar 2020 04:53:37 +0100 (CET) X-Halon-ID: da6e2ac4-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id da6e2ac4-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:25 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:33 +0100 Message-Id: <20200317035239.2697679-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/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: Tue, 17 Mar 2020 03:53: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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp index 0a8cb0d28ca9b204..c951bc9650dc4e0e 100644 --- a/test/v4l2_videodevice/buffer_cache.cpp +++ b/test/v4l2_videodevice/buffer_cache.cpp @@ -11,6 +11,8 @@ #include +#include + #include "buffer_source.h" #include "test.h" @@ -142,7 +144,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 Tue Mar 17 03:52:34 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: 3134 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 CECEE6297B for ; Tue, 17 Mar 2020 04:53:37 +0100 (CET) X-Halon-ID: dab5ef3f-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id dab5ef3f-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:25 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:34 +0100 Message-Id: <20200317035239.2697679-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/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: Tue, 17 Mar 2020 03:53:38 -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 8792dfe48ed8db31..72924bf2f55d0021 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -173,17 +173,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 Tue Mar 17 03:52:35 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: 3135 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 5D9D662928 for ; Tue, 17 Mar 2020 04:53:38 +0100 (CET) X-Halon-ID: db0c5851-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id db0c5851-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:26 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:35 +0100 Message-Id: <20200317035239.2697679-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/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: Tue, 17 Mar 2020 03:53: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 i the camera configuration. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 320da2685795c041..14f7ddb18a765834 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -154,7 +154,14 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, return config; ImageFormats v4l2formats = data->video_->formats(); - StreamFormats formats(v4l2formats.data()); + std::map> deviceformats; + for (const auto &it : v4l2formats.data()) { + PixelFormat pixelformat = V4L2VideoDevice::toPixelFormat(it.first); + const std::vector &ranges = it.second; + deviceformats[pixelformat] = ranges; + } + + StreamFormats formats(deviceformats); StreamConfiguration cfg(formats); cfg.pixelFormat = formats.pixelformats().front(); From patchwork Tue Mar 17 03:52:36 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: 3136 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 DF85962950 for ; Tue, 17 Mar 2020 04:53:38 +0100 (CET) X-Halon-ID: db59b448-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id db59b448-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:26 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:36 +0100 Message-Id: <20200317035239.2697679-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/8] libcamera: v4l2_videodevice: Remove 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: Tue, 17 Mar 2020 03:53:39 -0000 The ImageFormats class is not very nice as it forces the pixel format to be an unsigned integer. Replace it with a map of unsigned int to vector of sizes. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/include/v4l2_videodevice.h | 2 +- src/libcamera/pipeline/uvcvideo.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 11 +++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 2507daf23efac66f..62e6a657fc7eedb0 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -184,7 +184,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - ImageFormats formats(); + std::map> formats(); int setCrop(Rectangle *rect); int setCompose(Rectangle *rect); diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 14f7ddb18a765834..5ebd83f3c2099ffe 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -153,9 +153,8 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats v4l2formats = data->video_->formats(); std::map> deviceformats; - for (const auto &it : v4l2formats.data()) { + for (const auto &it : data->video_->formats()) { PixelFormat pixelformat = V4L2VideoDevice::toPixelFormat(it.first); const std::vector &ranges = it.second; deviceformats[pixelformat] = ranges; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 858310c3b810350a..280cf1877c8936d7 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -901,21 +901,16 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -ImageFormats V4L2VideoDevice::formats() +std::map> V4L2VideoDevice::formats() { - ImageFormats formats; + std::map> formats; for (unsigned int pixelformat : enumPixelformats()) { std::vector sizes = enumSizes(pixelformat); if (sizes.empty()) return {}; - if (formats.addFormat(pixelformat, sizes)) { - LOG(V4L2, Error) - << "Could not add sizes for pixel format " - << pixelformat; - return {}; - } + formats[pixelformat] = sizes; } return formats; From patchwork Tue Mar 17 03:52:37 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: 3137 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 E63AA6298A for ; Tue, 17 Mar 2020 04:53:39 +0100 (CET) X-Halon-ID: dbb2ab2f-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id dbb2ab2f-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:27 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:37 +0100 Message-Id: <20200317035239.2697679-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Tue, 17 Mar 2020 03:53:40 -0000 Create a class to represent a pixel formats. This is done to add support for modifiers for the formats. So far no formats are added by any pipeline handler, all plumbing to deal with them is however in place. Pipelines that adds modifiers will come when support for RAW capture is added. Signed-off-by: Niklas Söderlund --- * 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 | 21 ++++++- 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/pixelformats.cpp | 78 ++++++++++++++++++++++-- src/libcamera/stream.cpp | 4 +- src/libcamera/v4l2_videodevice.cpp | 5 +- src/qcam/format_converter.cpp | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 4 +- 10 files changed, 110 insertions(+), 25 deletions(-) diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index 6e25b8d8b76e5961..5ba1ba1b324272b9 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -7,11 +7,30 @@ #ifndef __LIBCAMERA_PIXEL_FORMATS_H__ #define __LIBCAMERA_PIXEL_FORMATS_H__ +#include #include +#include namespace libcamera { -using PixelFormat = uint32_t; +class PixelFormat +{ +public: + PixelFormat(); + PixelFormat(uint32_t fourcc, const std::set &modifiers = {}); + + uint32_t fourcc() const { return fourcc_; } + const std::set &modifiers() const { return modifiers_; } + std::string toString() const; + +private: + uint32_t fourcc_; + std::set modifiers_; +}; + +bool operator==(const PixelFormat &lhs, const PixelFormat &rhs); +bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs); +bool operator<(const PixelFormat &lhs, const PixelFormat &rhs); } /* 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 01977ad697a91a44..8223b82c4a9c773c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -790,7 +790,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 5ebd83f3c2099ffe..12af164590020142 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/pixelformats.cpp b/src/libcamera/pixelformats.cpp index c03335400b709d9b..fe9a6a2576978647 100644 --- a/src/libcamera/pixelformats.cpp +++ b/src/libcamera/pixelformats.cpp @@ -7,6 +7,8 @@ #include +#include "log.h" + /** * \file pixelformats.h * \brief libcamera pixel formats @@ -15,14 +17,80 @@ 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) +{ +} + +/** + * \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; +} + +/** + * \brief Compare pixel formats for equality + * \return True if the two pixel formats are equal, false otherwise + */ +bool operator==(const PixelFormat &lhs, const PixelFormat &rhs) +{ + return lhs.fourcc() == rhs.fourcc() && + lhs.modifiers() == rhs.modifiers(); +} + +/** + * \brief Compare pixel formats for inequality + * \return True if the two pixel formats are not equal, false otherwise + */ +bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs) +{ + return !(lhs == rhs); +} + +/** + * \brief Compare pixel formats for smaller than order + * \todo Take modifiers into account if \a lhs == \a rhs. + * \return True if \a lhs is smaller than \a rhs, false otherwise + */ +bool operator<(const PixelFormat &lhs, const PixelFormat &rhs) +{ + return lhs.fourcc() < rhs.fourcc(); +} + } /* 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 280cf1877c8936d7..b5762a7eabcf4e25 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1643,7 +1643,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; @@ -1687,8 +1687,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 368cb43fbf17ae4d..c071ea9b4022750c 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -30,7 +30,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 b620f236499cf77d..3bbbbf79cdb475db 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -534,7 +534,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 } }} }, @@ -606,7 +606,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 Tue Mar 17 03:52:38 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: 3138 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 32984629A4 for ; Tue, 17 Mar 2020 04:53:41 +0100 (CET) X-Halon-ID: dc4e679c-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id dc4e679c-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:28 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:38 +0100 Message-Id: <20200317035239.2697679-8-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Tue, 17 Mar 2020 03:53: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 V4L2 pixel formats flagged by the compiler are fixed. While at it make the compare operations part of PixelFormat class. Signed-off-by: Laurent Pinchart [Niklas: Make the compare operations part of PixelFormat] Signed-off-by: Niklas Söderlund --- include/libcamera/pixelformats.h | 10 ++--- src/gstreamer/gstlibcamera-utils.cpp | 4 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 6 +-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++----- src/libcamera/pipeline/vimc.cpp | 12 ++--- src/libcamera/pixelformats.cpp | 57 ++++++++++++------------ 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 +- 10 files changed, 94 insertions(+), 95 deletions(-) diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index 5ba1ba1b324272b9..3285941382ccdd96 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -17,7 +17,11 @@ 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; + bool operator<(const PixelFormat &other) const; uint32_t fourcc() const { return fourcc_; } const std::set &modifiers() const { return modifiers_; } @@ -28,10 +32,6 @@ private: std::set modifiers_; }; -bool operator==(const PixelFormat &lhs, const PixelFormat &rhs); -bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs); -bool operator<(const PixelFormat &lhs, const PixelFormat &rhs); - } /* namespace libcamera */ #endif /* __LIBCAMERA_PIXEL_FORMATS_H__ */ 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 0c2a217c9ea8f6ba..52b6d48aca4394c6 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -246,7 +246,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) { /* @@ -401,7 +401,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: @@ -1079,7 +1079,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 8223b82c4a9c773c..3bbe73c3abd9d75e 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -431,14 +431,14 @@ 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, + static const std::array formats{ + 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 */ }; @@ -460,7 +460,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; } @@ -539,7 +539,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 72924bf2f55d0021..8dad2b40ed4fbb2c 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -104,10 +104,10 @@ private: namespace { -constexpr std::array pixelformats{ - DRM_FORMAT_RGB888, - DRM_FORMAT_BGR888, - DRM_FORMAT_BGRA8888, +const std::array pixelformats{ + PixelFormat(DRM_FORMAT_RGB888), + PixelFormat(DRM_FORMAT_BGR888), + PixelFormat(DRM_FORMAT_BGRA8888), }; } /* namespace */ @@ -136,7 +136,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; } @@ -185,7 +185,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/pixelformats.cpp b/src/libcamera/pixelformats.cpp index fe9a6a2576978647..1c559fe46d406826 100644 --- a/src/libcamera/pixelformats.cpp +++ b/src/libcamera/pixelformats.cpp @@ -41,6 +41,34 @@ PixelFormat::PixelFormat(uint32_t fourcc, const std::set &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_; +} + +/** + * \brief Compare pixel formats for inequality + * \return True if the two pixel formats are not equal, false otherwise + */ +bool PixelFormat::operator!=(const PixelFormat &other) const +{ + return !(*this == other); +} + +/** + * \brief Compare pixel formats for smaller than order + * \todo Take modifiers into account if FourCC are equal + * \return True if \a this is smaller than \a other, false otherwise + */ +bool PixelFormat::operator<(const PixelFormat &other) const +{ + return fourcc_ < other.fourcc_; +} + /** * \fn PixelFormat::fourcc() const * \brief Retrieve the pixel format FourCC @@ -64,33 +92,4 @@ std::string PixelFormat::toString() const return str; } -/** - * \brief Compare pixel formats for equality - * \return True if the two pixel formats are equal, false otherwise - */ -bool operator==(const PixelFormat &lhs, const PixelFormat &rhs) -{ - return lhs.fourcc() == rhs.fourcc() && - lhs.modifiers() == rhs.modifiers(); -} - -/** - * \brief Compare pixel formats for inequality - * \return True if the two pixel formats are not equal, false otherwise - */ -bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs) -{ - return !(lhs == rhs); -} - -/** - * \brief Compare pixel formats for smaller than order - * \todo Take modifiers into account if \a lhs == \a rhs. - * \return True if \a lhs is smaller than \a rhs, false otherwise - */ -bool operator<(const PixelFormat &lhs, const PixelFormat &rhs) -{ - return lhs.fourcc() < rhs.fourcc(); -} - } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index b5762a7eabcf4e25..d8d711a951d666e9 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1563,39 +1563,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: @@ -1608,7 +1608,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 3bbbbf79cdb475db..55dd69d37bd65897 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -536,21 +536,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 */ @@ -594,7 +594,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 c951bc9650dc4e0e..8921605030cfdefb 100644 --- a/test/v4l2_videodevice/buffer_cache.cpp +++ b/test/v4l2_videodevice/buffer_cache.cpp @@ -144,7 +144,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 Tue Mar 17 03:52:39 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: 3139 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 13210629CC for ; Tue, 17 Mar 2020 04:53:42 +0100 (CET) X-Halon-ID: dd1a5ddf-6802-11ea-aa6d-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id dd1a5ddf-6802-11ea-aa6d-005056917f90; Tue, 17 Mar 2020 04:53:29 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 17 Mar 2020 04:52:39 +0100 Message-Id: <20200317035239.2697679-9-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> References: <20200317035239.2697679-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Tue, 17 Mar 2020 03:53:42 -0000 PixelFormat was previously an alias for unsigned int but are 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 62e6a657fc7eedb0..252820cba3fdc7a3 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 d8d711a951d666e9..40f431abb0dba721 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1623,7 +1623,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()); } @@ -1641,7 +1641,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 c071ea9b4022750c..b72e8342135d3c39 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -27,8 +27,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 55dd69d37bd65897..d519af85a9e0b300 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -599,7 +599,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_;