libcamera v0.5.1 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
libcamera::Converter Class Referenceabstract

Abstract Base Class for converter. More...

Inheritance diagram for libcamera::Converter:
[legend]
Collaboration diagram for libcamera::Converter:
[legend]

## Public Types
enum class | Feature { None = 0 , InputCrop = (1 << 0) }
| Specify the features supported by the converter. More...
enum class | Alignment { Down = 0 , Up }
| The alignment mode specified when adjusting the converter input or output sizes. More...
using | Features = Flags<Feature>
| A bitwise combination of features supported by the converter.

## Public Member Functions
| Converter (MediaDevice *media, Features features=Feature::None)
| Construct a Converter instance.
virtual int | loadConfiguration (const std::string &filename)=0
| Load converter configuration from file.
virtual bool | isValid () const =0
| Check if the converter configuration is valid.
virtual std::vector< PixelFormat > | formats (PixelFormat input)=0
| Retrieve the list of supported pixel formats for an input pixel format.
virtual SizeRange | sizes (const Size &input)=0
| Retrieve the range of minimum and maximum output sizes for an input size.
virtual Size | adjustInputSize (const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down)=0
| Adjust the converter input size to a valid value.
virtual Size | adjustOutputSize (const PixelFormat &pixFmt, const Size &size, Alignment align=Alignment::Down)=0
| Adjust the converter output size to a valid value.
virtual std::tuple< unsigned int, unsigned int > | strideAndFrameSize (const PixelFormat &pixelFormat, const Size &size)=0
| Retrieve the output stride and frame size for an input configutation.
virtual int | validateOutput (StreamConfiguration *cfg, bool *adjusted, Alignment align=Alignment::Down)=0
| Validate and possibily adjust cfg to a valid converter output.
virtual int | configure (const StreamConfiguration &inputCfg, const std::vector< std::reference_wrapper< StreamConfiguration > > &outputCfgs)=0
| Configure a set of output stream conversion from an input stream.
virtual bool | isConfigured (const Stream *stream) const =0
| Check if a given stream is configured.
virtual int | exportBuffers (const Stream *stream, unsigned int count, std::vector< std::unique_ptr< FrameBuffer > > *buffers)=0
| Export buffers from the converter device.
virtual int | start ()=0
| Start the converter streaming operation.
virtual void | stop ()=0
| Stop the converter streaming operation.
virtual int | queueBuffers (FrameBuffer *input, const std::map< const Stream *, FrameBuffer * > &outputs)=0
| Queue buffers to converter device.
virtual int | setInputCrop (const Stream *stream, Rectangle *rect)=0
| Set the crop rectangle rect for stream.
virtual std::pair< Rectangle, Rectangle > | inputCropBounds ()=0
| Retrieve the crop bounds of the converter.
virtual std::pair< Rectangle, Rectangle > | inputCropBounds (const Stream *stream)=0
| Retrieve the crop bounds for stream.
const std::string & | deviceNode () const
| The converter device node attribute accessor.
Features | features () const
| Retrieve the features supported by the converter.

## Public Attributes
Signal< FrameBuffer * > | inputBufferReady
| A signal emitted when the input frame buffer completes.
Signal< FrameBuffer * > | outputBufferReady
| A signal emitted on each frame buffer completion of the output queue.

## Protected Attributes
Features | features_
| Stores the features supported by the converter.

## Detailed Description

Abstract Base Class for converter.

The Converter class is an Abstract Base Class defining the interfaces of converter implementations.

Converters offer scaling and pixel format conversion services on an input stream. The converter can output multiple streams with individual conversion parameters from the same input stream.

## Member Enumeration Documentation

## ◆ Alignment

enum class libcamera::Converter::Alignment
| strong

The alignment mode specified when adjusting the converter input or output sizes.

Enumerator
Down | Adjust the Converter sizes to a smaller valid size.
Up | Adjust the Converter sizes to a larger valid size.

## ◆ Feature

enum class libcamera::Converter::Feature
| strong

Specify the features supported by the converter.

Enumerator
None | No extra features supported by the converter.
InputCrop | Cropping capability at input is supported by the converter.

## Constructor & Destructor Documentation

## ◆ Converter()

libcamera::Converter::Converter | ( | MediaDevice * | media,
|  | Features | features = Feature::None )

Construct a Converter instance.

Parameters

  [in] | media | The media device implementing the converter
  [in] | features | Features flags representing supported features

This searches for the entity implementing the data streaming function in the media graph entities and use its device node as the converter device node.

## Member Function Documentation

## ◆ adjustInputSize()

virtual Size libcamera::Converter::adjustInputSize | ( | const PixelFormat & | pixFmt,
|  | const Size & | size,
|  | Alignment | align = Alignment::Down )
| pure virtual

Adjust the converter input size to a valid value.

Parameters

  [in] | pixFmt | The pixel format of the converter input stream
  [in] | size | The converter input size to adjust to a valid value
  [in] | align | The desired alignment

Returns
  The adjusted converter input size or a null Size if size cannot be adjusted

Implemented in libcamera::V4L2M2MConverter.

## ◆ adjustOutputSize()

virtual Size libcamera::Converter::adjustOutputSize | ( | const PixelFormat & | pixFmt,
|  | const Size & | size,
|  | Alignment | align = Alignment::Down )
| pure virtual

Adjust the converter output size to a valid value.

Parameters

  [in] | pixFmt | The pixel format of the converter output stream
  [in] | size | The converter output size to adjust to a valid value
  [in] | align | The desired alignment

Returns
  The adjusted converter output size or a null Size if size cannot be adjusted

Implemented in libcamera::V4L2M2MConverter.

## ◆ configure()

virtual int libcamera::Converter::configure | ( | const StreamConfiguration & | inputCfg,
|  | const std::vector< std::reference_wrapper< StreamConfiguration > > & | outputCfgs )
| pure virtual

Configure a set of output stream conversion from an input stream.

Parameters

  [in] | inputCfg | Input stream configuration
  [out] | outputCfgs | A list of output stream configurations

Returns
  0 on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ deviceNode()

const std::string & libcamera::Converter::deviceNode | ( |  | ) | const
| inline

The converter device node attribute accessor.

Returns
  The converter device node string

## ◆ exportBuffers()

virtual int libcamera::Converter::exportBuffers | ( | const Stream * | stream,
|  | unsigned int | count,
|  | std::vector< std::unique_ptr< FrameBuffer > > * | buffers )
| pure virtual

Export buffers from the converter device.

Parameters

  [in] | stream | Output stream pointer exporting the buffers
  [in] | count | Number of buffers to allocate
  [out] | buffers | Vector to store allocated buffers

This function operates similarly to V4L2VideoDevice::exportBuffers() on the output stream indicated by the output.

Returns
  The number of allocated buffers on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ features()

Features libcamera::Converter::features | ( |  | ) | const
| inline

Retrieve the features supported by the converter.

Returns
  The converter Features flags

## ◆ formats()

virtual std::vector< PixelFormat > libcamera::Converter::formats | ( | PixelFormat | input | ) |
| pure virtual

Retrieve the list of supported pixel formats for an input pixel format.

Parameters

  [in] | input | Input pixel format to retrieve output pixel format list for

Returns
  The list of supported output pixel formats

Implemented in libcamera::V4L2M2MConverter.

## ◆ inputCropBounds() [1/2]

virtual std::pair< Rectangle, Rectangle > libcamera::Converter::inputCropBounds | ( |  | ) |
| pure virtual

Retrieve the crop bounds of the converter.

Retrieve the minimum and maximum crop bounds of the converter. This can be used to query the crop bounds before configuring a stream.

Returns
  A pair containing the minimum and maximum crop bound in that order

Implemented in libcamera::V4L2M2MConverter.

## ◆ inputCropBounds() [2/2]

virtual std::pair< Rectangle, Rectangle > libcamera::Converter::inputCropBounds | ( | const Stream * | stream | ) |
| pure virtual

Retrieve the crop bounds for stream.

Parameters

  [in] | stream | The output stream

Retrieve the minimum and maximum crop bounds for stream. The converter should support cropping (Feature::InputCrop).

The crop bounds depend on the configuration of the output stream and hence this function should be called after the stream has been configured using configure().

When called with an unconfigured stream, this function returns a pair of null rectangles.

Returns
  A pair containing the minimum and maximum crop bound in that order

Implemented in libcamera::V4L2M2MConverter.

## ◆ isConfigured()

virtual bool libcamera::Converter::isConfigured | ( | const Stream * | stream | ) | const
| pure virtual

Check if a given stream is configured.

Parameters

  [in] | stream | The output stream

Returns
  True if the stream is configured or false otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ isValid()

virtual bool libcamera::Converter::isValid | ( |  | ) | const
| pure virtual

Check if the converter configuration is valid.

Returns
  True is the converter is valid, false otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ loadConfiguration()

virtual int libcamera::Converter::loadConfiguration | ( | const std::string & | filename | ) |
| pure virtual

Load converter configuration from file.

Parameters

  [in] | filename | The file name path

Load converter dependent configuration parameters to apply on the hardware.

Returns
  0 on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ queueBuffers()

virtual int libcamera::Converter::queueBuffers | ( | FrameBuffer * | input,
|  | const std::map< const Stream *, FrameBuffer * > & | outputs )
| pure virtual

Queue buffers to converter device.

Parameters

  [in] | input | The frame buffer to apply the conversion
  [out] | outputs | The container holding the output stream pointers and their respective frame buffer outputs.

This function queues the input frame buffer on the output streams of the outputs map key and retrieve the output frame buffer indicated by the buffer map value.

Returns
  0 on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ setInputCrop()

virtual int libcamera::Converter::setInputCrop | ( | const Stream * | stream,
|  | Rectangle * | rect )
| pure virtual

Set the crop rectangle rect for stream.

Parameters

  [in] | stream | The output stream
  [in,out] | rect | The crop rectangle to apply and return the rectangle that is actually applied

Set the crop rectangle rect for stream provided the converter supports cropping. The converter has the Feature::InputCrop flag in this case.

The underlying hardware can adjust the rectangle supplied by the user due to hardware constraints. The caller can inspect rect to determine the actual rectangle that has been applied by the converter, after this function returns.

Returns
  0 on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ sizes()

virtual SizeRange libcamera::Converter::sizes | ( | const Size & | input | ) |
| pure virtual

Retrieve the range of minimum and maximum output sizes for an input size.

Parameters

  [in] | input | Input stream size to retrieve range for

Returns
  A range of output image sizes

Implemented in libcamera::V4L2M2MConverter.

## ◆ start()

virtual int libcamera::Converter::start | ( |  | ) |
| pure virtual

Start the converter streaming operation.

Returns
  0 on success or a negative error code otherwise

Implemented in libcamera::V4L2M2MConverter.

## ◆ stop()

virtual void libcamera::Converter::stop | ( |  | ) |
| pure virtual

Stop the converter streaming operation.

Implemented in libcamera::V4L2M2MConverter.

## ◆ strideAndFrameSize()

virtual std::tuple< unsigned int, unsigned int > libcamera::Converter::strideAndFrameSize | ( | const PixelFormat & | pixelFormat,
|  | const Size & | size )
| pure virtual

Retrieve the output stride and frame size for an input configutation.

Parameters

  [in] | pixelFormat | Input stream pixel format
  [in] | size | Input stream size

Returns
  A tuple indicating the stride and frame size or an empty tuple on error

Implemented in libcamera::V4L2M2MConverter.

## ◆ validateOutput()

virtual int libcamera::Converter::validateOutput | ( | StreamConfiguration * | cfg,
|  | bool * | adjusted,
|  | Alignment | align = Alignment::Down )
| pure virtual

Validate and possibily adjust cfg to a valid converter output.

Parameters

  [in,out] | cfg | The StreamConfiguration to validate and adjust
  [out] | adjusted | Set to true if cfg has been adjusted
  [in] | align | The desired alignment

Returns
  0 if cfg is valid or has been adjusted, a negative error code otherwise if cfg cannot be adjusted

Implemented in libcamera::V4L2M2MConverter.

The documentation for this class was generated from the following files:

- include/libcamera/internal/converter.h
- src/libcamera/converter.cpp