From 08a75925d86605d63f115e76ad7644ba194812a4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 22 May 2020 03:08:15 +0300 Subject: libcamera: Rename pixelformats.{cpp,h} to pixel_format.{cpp,h} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The libcamera source files are named after class names, using snake_case. pixelformats.h and pixelformats.cpp don't comply with that rule. Fix them. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/internal/formats.h | 2 +- include/libcamera/internal/v4l2_pixelformat.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- include/libcamera/meson.build | 2 +- include/libcamera/pixel_format.h | 43 ++++++++++ include/libcamera/pixelformats.h | 43 ---------- include/libcamera/stream.h | 2 +- src/libcamera/meson.build | 2 +- src/libcamera/pipeline/simple/converter.h | 2 +- src/libcamera/pixel_format.cpp | 116 ++++++++++++++++++++++++++ src/libcamera/pixelformats.cpp | 116 -------------------------- src/libcamera/v4l2_pixelformat.cpp | 2 +- src/qcam/format_converter.h | 2 +- src/qcam/viewfinder.h | 2 +- 14 files changed, 169 insertions(+), 169 deletions(-) create mode 100644 include/libcamera/pixel_format.h delete mode 100644 include/libcamera/pixelformats.h create mode 100644 src/libcamera/pixel_format.cpp delete mode 100644 src/libcamera/pixelformats.cpp diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 4092a93e..4455b0f9 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "libcamera/internal/v4l2_pixelformat.h" diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index 0fe8a017..4d0e034b 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -13,7 +13,7 @@ #include -#include +#include namespace libcamera { diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index cbaee614..45c3404c 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include "libcamera/internal/formats.h" diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 27760c19..73c5b999 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -13,7 +13,7 @@ libcamera_public_headers = files([ 'geometry.h', 'logging.h', 'object.h', - 'pixelformats.h', + 'pixel_format.h', 'request.h', 'signal.h', 'span.h', diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h new file mode 100644 index 00000000..e3b371ef --- /dev/null +++ b/include/libcamera/pixel_format.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * pixel_format.h - libcamera Pixel Format + */ +#ifndef __LIBCAMERA_PIXEL_FORMAT_H__ +#define __LIBCAMERA_PIXEL_FORMAT_H__ + +#include +#include +#include + +#include + +namespace libcamera { + +class PixelFormat +{ +public: + PixelFormat(); + explicit PixelFormat(uint32_t fourcc, uint64_t modifier = 0); + + 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_; } + uint64_t modifier() const { return modifier_; } + + std::string toString() const; + +private: + uint32_t fourcc_; + uint64_t modifier_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_PIXEL_FORMAT_H__ */ diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h deleted file mode 100644 index 89966e5e..00000000 --- a/include/libcamera/pixelformats.h +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * pixelformats.h - libcamera pixel formats - */ -#ifndef __LIBCAMERA_PIXEL_FORMATS_H__ -#define __LIBCAMERA_PIXEL_FORMATS_H__ - -#include -#include -#include - -#include - -namespace libcamera { - -class PixelFormat -{ -public: - PixelFormat(); - explicit PixelFormat(uint32_t fourcc, uint64_t modifier = 0); - - 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_; } - uint64_t modifier() const { return modifier_; } - - std::string toString() const; - -private: - uint32_t fourcc_; - uint64_t modifier_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_PIXEL_FORMATS_H__ */ diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index b3cbea3d..1a68bd23 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -14,7 +14,7 @@ #include #include -#include +#include namespace libcamera { diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index b88f295d..611fc061 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -34,7 +34,7 @@ libcamera_sources = files([ 'message.cpp', 'object.cpp', 'pipeline_handler.cpp', - 'pixelformats.cpp', + 'pixel_format.cpp', 'process.cpp', 'pub_key.cpp', 'request.cpp', diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h index 1f770eb8..ef18cf73 100644 --- a/src/libcamera/pipeline/simple/converter.h +++ b/src/libcamera/pipeline/simple/converter.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include namespace libcamera { diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp new file mode 100644 index 00000000..d8718739 --- /dev/null +++ b/src/libcamera/pixel_format.cpp @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * pixel_format.cpp - libcamera Pixel Format + */ + +#include + +/** + * \file pixel_format.h + * \brief libcamera pixel format + */ + +namespace libcamera { + +/** + * \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 and a modifier. + * The FourCC and modifier values are defined in the Linux kernel DRM/KMS API + * (see linux/drm_fourcc.h). + */ + +/** + * \brief Construct a PixelFormat with an invalid format + * + * PixelFormat instances constructed with the default constructor are + * invalid, calling the isValid() function returns false. + */ +PixelFormat::PixelFormat() + : fourcc_(0) +{ +} + +/** + * \brief Construct a PixelFormat from a DRM FourCC and a modifier + * \param[in] fourcc A DRM FourCC + * \param[in] modifier A DRM FourCC modifier + */ +PixelFormat::PixelFormat(uint32_t fourcc, uint64_t modifier) + : fourcc_(fourcc), modifier_(modifier) +{ +} + +/** + * \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() && modifier_ == other.modifier_; +} + +/** + * \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 modifier_ < other.modifier_; +} + +/** + * \fn bool PixelFormat::isValid() const + * \brief Check if the pixel format is valid + * + * PixelFormat instances constructed with the default constructor are + * invalid. Instances constructed with a FourCC defined in the DRM API + * are valid. The behaviour is undefined otherwise. + * + * \return True if the pixel format is valid, 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::modifier() const + * \brief Retrieve the pixel format modifier + * \return DRM modifier + */ + +/** + * \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/pixelformats.cpp b/src/libcamera/pixelformats.cpp deleted file mode 100644 index 1330dc5a..00000000 --- a/src/libcamera/pixelformats.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * pixelformats.cpp - libcamera pixel formats - */ - -#include - -/** - * \file pixelformats.h - * \brief libcamera pixel formats - */ - -namespace libcamera { - -/** - * \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 and a modifier. - * The FourCC and modifier values are defined in the Linux kernel DRM/KMS API - * (see linux/drm_fourcc.h). - */ - -/** - * \brief Construct a PixelFormat with an invalid format - * - * PixelFormat instances constructed with the default constructor are - * invalid, calling the isValid() function returns false. - */ -PixelFormat::PixelFormat() - : fourcc_(0) -{ -} - -/** - * \brief Construct a PixelFormat from a DRM FourCC and a modifier - * \param[in] fourcc A DRM FourCC - * \param[in] modifier A DRM FourCC modifier - */ -PixelFormat::PixelFormat(uint32_t fourcc, uint64_t modifier) - : fourcc_(fourcc), modifier_(modifier) -{ -} - -/** - * \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() && modifier_ == other.modifier_; -} - -/** - * \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 modifier_ < other.modifier_; -} - -/** - * \fn bool PixelFormat::isValid() const - * \brief Check if the pixel format is valid - * - * PixelFormat instances constructed with the default constructor are - * invalid. Instances constructed with a FourCC defined in the DRM API - * are valid. The behaviour is undefined otherwise. - * - * \return True if the pixel format is valid, 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::modifier() const - * \brief Retrieve the pixel format modifier - * \return DRM modifier - */ - -/** - * \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/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 36776be9..94fae470 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -14,7 +14,7 @@ #include -#include +#include #include "libcamera/internal/formats.h" #include "libcamera/internal/log.h" diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h index 5e28adf0..e389b24a 100644 --- a/src/qcam/format_converter.h +++ b/src/qcam/format_converter.h @@ -11,7 +11,7 @@ #include -#include +#include class QImage; diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h index b3f1d25d..26a13205 100644 --- a/src/qcam/viewfinder.h +++ b/src/qcam/viewfinder.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include "format_converter.h" -- cgit v1.2.1