[v3.1,09/17] fixup! libcamera: converter: Add functions to adjust config
diff mbox series

Message ID 20241212175635.99625-1-jacopo.mondi@ideasonboard.com
State New
Headers show
Series
  • Untitled series #4878
Related show

Commit Message

Jacopo Mondi Dec. 12, 2024, 5:56 p.m. UTC
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 include/libcamera/internal/converter.h                | 10 ++++------
 .../libcamera/internal/converter/converter_v4l2_m2m.h |  8 ++++----
 src/libcamera/converter.cpp                           | 11 ++++-------
 src/libcamera/converter/converter_v4l2_m2m.cpp        | 10 +++++-----
 4 files changed, 17 insertions(+), 22 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h
index 9213ae5b9c33..12de6aef0e40 100644
--- a/include/libcamera/internal/converter.h
+++ b/include/libcamera/internal/converter.h
@@ -43,11 +43,9 @@  public:
 
 	enum class Alignment {
 		Down = 0,
-		Up = (1 << 0),
+		Up,
 	};
 
-	using Alignments = Flags<Alignment>;
-
 	Converter(MediaDevice *media, Features features = Feature::None);
 	virtual ~Converter();
 
@@ -60,16 +58,16 @@  public:
 
 	virtual Size adjustInputSize(const PixelFormat &pixFmt,
 				     const Size &size,
-				     Alignments align = Alignment::Down) = 0;
+				     Alignment align = Alignment::Down) = 0;
 	virtual Size adjustOutputSize(const PixelFormat &pixFmt,
 				      const Size &size,
-				      Alignments align = Alignment::Down) = 0;
+				      Alignment align = Alignment::Down) = 0;
 
 	virtual std::tuple<unsigned int, unsigned int>
 	strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) = 0;
 
 	virtual int validateOutput(StreamConfiguration *cfg, bool *adjusted,
-				   Alignments align = Alignment::Down) = 0;
+				   Alignment align = Alignment::Down) = 0;
 
 	virtual int configure(const StreamConfiguration &inputCfg,
 			      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;
diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h
index 89bd2878b190..89c398614006 100644
--- a/include/libcamera/internal/converter/converter_v4l2_m2m.h
+++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h
@@ -48,9 +48,9 @@  public:
 	strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size);
 
 	Size adjustInputSize(const PixelFormat &pixFmt,
-			     const Size &size, Alignments align = Alignment::Down) override;
+			     const Size &size, Alignment align = Alignment::Down) override;
 	Size adjustOutputSize(const PixelFormat &pixFmt,
-			      const Size &size, Alignments align = Alignment::Down) override;
+			      const Size &size, Alignment align = Alignment::Down) override;
 
 	int configure(const StreamConfiguration &inputCfg,
 		      const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfg);
@@ -61,7 +61,7 @@  public:
 	void stop();
 
 	int validateOutput(StreamConfiguration *cfg, bool *adjusted,
-			   Alignments align = Alignment::Down) override;
+			   Alignment align = Alignment::Down) override;
 
 	int queueBuffers(FrameBuffer *input,
 			 const std::map<const Stream *, FrameBuffer *> &outputs);
@@ -110,7 +110,7 @@  private:
 	};
 
 	Size adjustSizes(const Size &size, const std::vector<SizeRange> &ranges,
-			 Alignments align);
+			 Alignment align);
 
 	std::unique_ptr<V4L2M2MDevice> m2m_;
 
diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp
index c3da162b7de7..c373564d6007 100644
--- a/src/libcamera/converter.cpp
+++ b/src/libcamera/converter.cpp
@@ -60,11 +60,6 @@  LOG_DEFINE_CATEGORY(Converter)
  * \brief Adjust the Converter sizes to a larger valid size
  */
 
-/**
- * \typedef Converter::Alignments
- * \brief A bitwise combination of alignments supported by the converter
- */
-
 /**
  * \brief Construct a Converter instance
  * \param[in] media The media device implementing the converter
@@ -131,7 +126,8 @@  Converter::~Converter()
  * \param[in] pixFmt The pixel format of the converter input stream
  * \param[in] size The converter input size to adjust to a valid value
  * \param[in] align The desired alignment
- * \return The adjusted converter input size
+ * \return The adjusted converter input size or a null Size if \a size cannot
+ * be adjusted
  */
 
 /**
@@ -140,7 +136,8 @@  Converter::~Converter()
  * \param[in] pixFmt The pixel format of the converter output stream
  * \param[in] size The converter output size to adjust to a valid value
  * \param[in] align The desired alignment
- * \return The adjusted converter output size
+ * \return The adjusted converter output size or a null Size if \a size cannot
+ * be adjusted
  */
 
 /**
diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp
index 6857472b29f2..17098f69c934 100644
--- a/src/libcamera/converter/converter_v4l2_m2m.cpp
+++ b/src/libcamera/converter/converter_v4l2_m2m.cpp
@@ -405,7 +405,7 @@  V4L2M2MConverter::strideAndFrameSize(const PixelFormat &pixelFormat,
  * \copydoc libcamera::Converter::adjustInputSize
  */
 Size V4L2M2MConverter::adjustInputSize(const PixelFormat &pixFmt,
-				       const Size &size, Alignments align)
+				       const Size &size, Alignment align)
 {
 	auto formats = m2m_->output()->formats();
 	V4L2PixelFormat v4l2PixFmt = m2m_->output()->toV4L2PixelFormat(pixFmt);
@@ -424,7 +424,7 @@  Size V4L2M2MConverter::adjustInputSize(const PixelFormat &pixFmt,
  * \copydoc libcamera::Converter::adjustOutputSize
  */
 Size V4L2M2MConverter::adjustOutputSize(const PixelFormat &pixFmt,
-					const Size &size, Alignments align)
+					const Size &size, Alignment align)
 {
 	auto formats = m2m_->capture()->formats();
 	V4L2PixelFormat v4l2PixFmt = m2m_->capture()->toV4L2PixelFormat(pixFmt);
@@ -441,7 +441,7 @@  Size V4L2M2MConverter::adjustOutputSize(const PixelFormat &pixFmt,
 
 Size V4L2M2MConverter::adjustSizes(const Size &cfgSize,
 				   const std::vector<SizeRange> &ranges,
-				   Alignments align)
+				   Alignment align)
 {
 	Size size = cfgSize;
 
@@ -495,7 +495,7 @@  Size V4L2M2MConverter::adjustSizes(const Size &cfgSize,
 		 * alignment: smaller than s1 if we align down, larger than s1
 		 * if we align up.
 		 */
-		auto nextSizeValid = [](const Size &s1, const Size &s2, Alignments a) {
+		auto nextSizeValid = [](const Size &s1, const Size &s2, Alignment a) {
 			return a == Alignment::Down
 				? (s1.width > s2.width && s1.height > s2.height)
 				: (s1.width < s2.width && s1.height < s2.height);
@@ -633,7 +633,7 @@  void V4L2M2MConverter::stop()
  * \copydoc libcamera::Converter::validateOutput
  */
 int V4L2M2MConverter::validateOutput(StreamConfiguration *cfg, bool *adjusted,
-				     Alignments align)
+				     Alignment align)
 {
 	V4L2VideoDevice *capture = m2m_->capture();
 	V4L2VideoDevice::Formats fmts = capture->formats();