[libcamera-devel,v2,2/3] libcamera: formats: Remove ImageFormats

Message ID 20200721135541.2931205-3-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • libcamera: formats: Remove ImageFormat
Related show

Commit Message

Niklas Söderlund July 21, 2020, 1:55 p.m. UTC
The ImageFormats helper class is not used anymore and can be removed.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/internal/formats.h | 14 -----
 src/libcamera/formats.cpp            | 88 ----------------------------
 2 files changed, 102 deletions(-)

Comments

Jacopo Mondi July 21, 2020, 3:21 p.m. UTC | #1
Hi Niklas

On Tue, Jul 21, 2020 at 03:55:40PM +0200, Niklas Söderlund wrote:
> The ImageFormats helper class is not used anymore and can be removed.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  include/libcamera/internal/formats.h | 14 -----
>  src/libcamera/formats.cpp            | 88 ----------------------------

\o/

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>  2 files changed, 102 deletions(-)
>
> diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
> index cad41ad864a41b62..0bb15104429489aa 100644
> --- a/include/libcamera/internal/formats.h
> +++ b/include/libcamera/internal/formats.h
> @@ -19,20 +19,6 @@
>
>  namespace libcamera {
>
> -class ImageFormats
> -{
> -public:
> -	int addFormat(unsigned int format, const std::vector<SizeRange> &sizes);
> -
> -	bool isEmpty() const;
> -	std::vector<unsigned int> formats() const;
> -	const std::vector<SizeRange> &sizes(unsigned int format) const;
> -	const std::map<unsigned int, std::vector<SizeRange>> &data() const;
> -
> -private:
> -	std::map<unsigned int, std::vector<SizeRange>> data_;
> -};
> -
>  struct PixelFormatPlaneInfo
>  {
>  	unsigned int bytesPerGroup;
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index af3996c954ae1457..60b42ce23c2145fd 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -23,94 +23,6 @@ namespace libcamera {
>
>  LOG_DEFINE_CATEGORY(Formats)
>
> -/**
> - * \class ImageFormats
> - * \brief Describe V4L2Device and V4L2SubDevice image formats
> - *
> - * This class stores a list of image formats, each associated with a
> - * corresponding set of image sizes. It is used to describe the formats and
> - * sizes supported by a V4L2Device or V4L2Subdevice.
> - *
> - * Formats are stored as an integer. When used for a V4L2Device, the image
> - * formats are fourcc pixel formats. When used for a V4L2Subdevice they are
> - * media bus codes. Both are defined by the V4L2 specification.
> - *
> - * Sizes are stored as a list of SizeRange.
> - */
> -
> -/**
> - * \brief Add a format and corresponding sizes to the description
> - * \param[in] format Pixel format or media bus code to describe
> - * \param[in] sizes List of supported size ranges for the format
> - *
> - * \return 0 on success or a negative error code otherwise
> - * \retval -EEXIST The format is already described
> - */
> -int ImageFormats::addFormat(unsigned int format, const std::vector<SizeRange> &sizes)
> -{
> -	if (data_.find(format) != data_.end())
> -		return -EEXIST;
> -
> -	data_[format] = sizes;
> -
> -	return 0;
> -}
> -
> -/**
> - * \brief Check if the list of devices supported formats is empty
> - * \return True if the list of supported formats is empty
> - */
> -bool ImageFormats::isEmpty() const
> -{
> -	return data_.empty();
> -}
> -
> -/**
> - * \brief Retrieve a list of all supported image formats
> - * \return List of pixel formats or media bus codes
> - */
> -std::vector<unsigned int> ImageFormats::formats() const
> -{
> -	std::vector<unsigned int> formats;
> -	formats.reserve(data_.size());
> -
> -	/* \todo: Should this be cached instead of computed each time? */
> -	for (auto const &it : data_)
> -		formats.push_back(it.first);
> -
> -	return formats;
> -}
> -
> -/**
> - * \brief Retrieve all sizes for a specific format
> - * \param[in] format The pixel format or mbus code
> - *
> - * Retrieve all size ranges for a specific format. For V4L2Device \a format is a
> - * pixel format while for a V4L2Subdevice \a format is a media bus code.
> - *
> - * \return The list of image sizes supported for \a format, or an empty list if
> - * the format is not supported
> - */
> -const std::vector<SizeRange> &ImageFormats::sizes(unsigned int format) const
> -{
> -	static const std::vector<SizeRange> empty;
> -
> -	auto const &it = data_.find(format);
> -	if (it == data_.end())
> -		return empty;
> -
> -	return it->second;
> -}
> -
> -/**
> - * \brief Retrieve the map that associates formats to image sizes
> - * \return The map that associates formats to image sizes
> - */
> -const std::map<unsigned int, std::vector<SizeRange>> &ImageFormats::data() const
> -{
> -	return data_;
> -}
> -
>  /**
>   * \class PixelFormatPlaneInfo
>   * \brief Information about a single plane of a pixel format
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
index cad41ad864a41b62..0bb15104429489aa 100644
--- a/include/libcamera/internal/formats.h
+++ b/include/libcamera/internal/formats.h
@@ -19,20 +19,6 @@ 
 
 namespace libcamera {
 
-class ImageFormats
-{
-public:
-	int addFormat(unsigned int format, const std::vector<SizeRange> &sizes);
-
-	bool isEmpty() const;
-	std::vector<unsigned int> formats() const;
-	const std::vector<SizeRange> &sizes(unsigned int format) const;
-	const std::map<unsigned int, std::vector<SizeRange>> &data() const;
-
-private:
-	std::map<unsigned int, std::vector<SizeRange>> data_;
-};
-
 struct PixelFormatPlaneInfo
 {
 	unsigned int bytesPerGroup;
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index af3996c954ae1457..60b42ce23c2145fd 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -23,94 +23,6 @@  namespace libcamera {
 
 LOG_DEFINE_CATEGORY(Formats)
 
-/**
- * \class ImageFormats
- * \brief Describe V4L2Device and V4L2SubDevice image formats
- *
- * This class stores a list of image formats, each associated with a
- * corresponding set of image sizes. It is used to describe the formats and
- * sizes supported by a V4L2Device or V4L2Subdevice.
- *
- * Formats are stored as an integer. When used for a V4L2Device, the image
- * formats are fourcc pixel formats. When used for a V4L2Subdevice they are
- * media bus codes. Both are defined by the V4L2 specification.
- *
- * Sizes are stored as a list of SizeRange.
- */
-
-/**
- * \brief Add a format and corresponding sizes to the description
- * \param[in] format Pixel format or media bus code to describe
- * \param[in] sizes List of supported size ranges for the format
- *
- * \return 0 on success or a negative error code otherwise
- * \retval -EEXIST The format is already described
- */
-int ImageFormats::addFormat(unsigned int format, const std::vector<SizeRange> &sizes)
-{
-	if (data_.find(format) != data_.end())
-		return -EEXIST;
-
-	data_[format] = sizes;
-
-	return 0;
-}
-
-/**
- * \brief Check if the list of devices supported formats is empty
- * \return True if the list of supported formats is empty
- */
-bool ImageFormats::isEmpty() const
-{
-	return data_.empty();
-}
-
-/**
- * \brief Retrieve a list of all supported image formats
- * \return List of pixel formats or media bus codes
- */
-std::vector<unsigned int> ImageFormats::formats() const
-{
-	std::vector<unsigned int> formats;
-	formats.reserve(data_.size());
-
-	/* \todo: Should this be cached instead of computed each time? */
-	for (auto const &it : data_)
-		formats.push_back(it.first);
-
-	return formats;
-}
-
-/**
- * \brief Retrieve all sizes for a specific format
- * \param[in] format The pixel format or mbus code
- *
- * Retrieve all size ranges for a specific format. For V4L2Device \a format is a
- * pixel format while for a V4L2Subdevice \a format is a media bus code.
- *
- * \return The list of image sizes supported for \a format, or an empty list if
- * the format is not supported
- */
-const std::vector<SizeRange> &ImageFormats::sizes(unsigned int format) const
-{
-	static const std::vector<SizeRange> empty;
-
-	auto const &it = data_.find(format);
-	if (it == data_.end())
-		return empty;
-
-	return it->second;
-}
-
-/**
- * \brief Retrieve the map that associates formats to image sizes
- * \return The map that associates formats to image sizes
- */
-const std::map<unsigned int, std::vector<SizeRange>> &ImageFormats::data() const
-{
-	return data_;
-}
-
 /**
  * \class PixelFormatPlaneInfo
  * \brief Information about a single plane of a pixel format