libcamera: converter: Add functions to adjust config
Add to the Converter interface two functions used by pipeline handlers to validate and adjust the converter input and output configurations by specifying the desired alignment for the adjustment. Add the adjustInputSize() and adjustOutputSize() functions that allows to adjust the converter input/output sizes with the desired alignment. Add a validateOutput() function meant to be used by the pipeline handler implementations of validate(). The function adjusts a StreamConfiguration to a valid configuration produced by the Converter. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
This commit is contained in:
parent
a631af61af
commit
0ce20a8cd5
4 changed files with 235 additions and 0 deletions
|
@ -41,6 +41,11 @@ public:
|
|||
|
||||
using Features = Flags<Feature>;
|
||||
|
||||
enum class Alignment {
|
||||
Down = 0,
|
||||
Up,
|
||||
};
|
||||
|
||||
Converter(MediaDevice *media, Features features = Feature::None);
|
||||
virtual ~Converter();
|
||||
|
||||
|
@ -51,9 +56,19 @@ public:
|
|||
virtual std::vector<PixelFormat> formats(PixelFormat input) = 0;
|
||||
virtual SizeRange sizes(const Size &input) = 0;
|
||||
|
||||
virtual Size adjustInputSize(const PixelFormat &pixFmt,
|
||||
const Size &size,
|
||||
Alignment align = Alignment::Down) = 0;
|
||||
virtual Size adjustOutputSize(const PixelFormat &pixFmt,
|
||||
const Size &size,
|
||||
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,
|
||||
Alignment align = Alignment::Down) = 0;
|
||||
|
||||
virtual int configure(const StreamConfiguration &inputCfg,
|
||||
const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;
|
||||
virtual bool isConfigured(const Stream *stream) const = 0;
|
||||
|
|
|
@ -47,6 +47,11 @@ public:
|
|||
std::tuple<unsigned int, unsigned int>
|
||||
strideAndFrameSize(const PixelFormat &pixelFormat, const Size &size) override;
|
||||
|
||||
Size adjustInputSize(const PixelFormat &pixFmt,
|
||||
const Size &size, Alignment align = Alignment::Down) override;
|
||||
Size adjustOutputSize(const PixelFormat &pixFmt,
|
||||
const Size &size, Alignment align = Alignment::Down) override;
|
||||
|
||||
int configure(const StreamConfiguration &inputCfg,
|
||||
const std::vector<std::reference_wrapper<StreamConfiguration>>
|
||||
&outputCfg) override;
|
||||
|
@ -57,6 +62,9 @@ public:
|
|||
int start() override;
|
||||
void stop() override;
|
||||
|
||||
int validateOutput(StreamConfiguration *cfg, bool *adjusted,
|
||||
Alignment align = Alignment::Down) override;
|
||||
|
||||
int queueBuffers(FrameBuffer *input,
|
||||
const std::map<const Stream *, FrameBuffer *> &outputs) override;
|
||||
|
||||
|
@ -104,6 +112,9 @@ private:
|
|||
std::pair<Rectangle, Rectangle> inputCropBounds_;
|
||||
};
|
||||
|
||||
Size adjustSizes(const Size &size, const std::vector<SizeRange> &ranges,
|
||||
Alignment align);
|
||||
|
||||
std::unique_ptr<V4L2M2MDevice> m2m_;
|
||||
|
||||
std::map<const Stream *, std::unique_ptr<V4L2M2MStream>> streams_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue