summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorUmang Jain <umang.jain@ideasonboard.com>2024-09-26 15:06:21 +0530
committerUmang Jain <umang.jain@ideasonboard.com>2024-10-24 14:04:31 +0530
commit1b0b90a332e21fdc6b302740eeb414731c79fd3b (patch)
tree90ecdfd4508a28cbd5d24cabdd829b5e9b0ec19f /include
parent7fad22efae4e89374d1767642cdd0bb4d683df1f (diff)
libcamera: converter: Add interface to support cropping capability
If the converter has cropping capability on its input, the interface should support it by providing appropriate virtual functions. Provide Feature::InputCrop in Feature enumeration for the same. Provide virtual setInputCrop() and inputCropBounds() interfaces so that the converter can implement its own cropping functionality. The V4L2M2MConverter implements these interfaces of the Converter interface. Not all V4L2M2M converters will have cropping ability on its input, hence it needs to be discovered at construction time. If the capability to crop is identified successfully, the cropping bounds are determined during configure() time. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/converter.h5
-rw-r--r--include/libcamera/internal/converter/converter_v4l2_m2m.h11
2 files changed, 16 insertions, 0 deletions
diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h
index 6623de4d..ffbb6f34 100644
--- a/include/libcamera/internal/converter.h
+++ b/include/libcamera/internal/converter.h
@@ -14,6 +14,7 @@
#include <memory>
#include <string>
#include <tuple>
+#include <utility>
#include <vector>
#include <libcamera/base/class.h>
@@ -35,6 +36,7 @@ class Converter
public:
enum class Feature {
None = 0,
+ InputCrop = (1 << 0),
};
using Features = Flags<Feature>;
@@ -63,6 +65,9 @@ public:
virtual int queueBuffers(FrameBuffer *input,
const std::map<const Stream *, FrameBuffer *> &outputs) = 0;
+ virtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0;
+ virtual std::pair<Rectangle, Rectangle> inputCropBounds(const Stream *stream) = 0;
+
Signal<FrameBuffer *> inputBufferReady;
Signal<FrameBuffer *> outputBufferReady;
diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h
index b9e59899..0bc0d053 100644
--- a/include/libcamera/internal/converter/converter_v4l2_m2m.h
+++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h
@@ -30,6 +30,7 @@ class Size;
class SizeRange;
class Stream;
struct StreamConfiguration;
+class Rectangle;
class V4L2M2MDevice;
class V4L2M2MConverter : public Converter
@@ -57,6 +58,9 @@ public:
int queueBuffers(FrameBuffer *input,
const std::map<const Stream *, FrameBuffer *> &outputs);
+ int setInputCrop(const Stream *stream, Rectangle *rect);
+ std::pair<Rectangle, Rectangle> inputCropBounds(const Stream *stream);
+
private:
class V4L2M2MStream : protected Loggable
{
@@ -75,6 +79,11 @@ private:
int queueBuffers(FrameBuffer *input, FrameBuffer *output);
+ int setInputSelection(unsigned int target, Rectangle *rect);
+ int getInputSelection(unsigned int target, Rectangle *rect);
+
+ std::pair<Rectangle, Rectangle> inputCropBounds();
+
protected:
std::string logPrefix() const override;
@@ -88,6 +97,8 @@ private:
unsigned int inputBufferCount_;
unsigned int outputBufferCount_;
+
+ std::pair<Rectangle, Rectangle> inputCropBounds_;
};
std::unique_ptr<V4L2M2MDevice> m2m_;