VPI - Vision Programming Interface

3.2 Release

PixelType.h File Reference

Defines types and functions to handle pixel types. More...

#include "DataLayout.h"
#include "detail/FormatUtils.h"
+ Include dependency graph for PixelType.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define VPI_PIXEL_TYPE_DEFAULT   ((VPIPixelType)0)
 Used to signal that the pixel type must be inferred from image format.
 
#define VPI_PIXEL_TYPE_INVALID   VPI_PIXEL_TYPE_DEFAULT
 Signal format conversion errors.
 
#define VPI_PIXEL_TYPE_U8   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X8)
 One channel of unsigned 8-bit value.
 
#define VPI_PIXEL_TYPE_2U8   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X8_Y8)
 Two interleaved channels of unsigned 8-bit values.
 
#define VPI_PIXEL_TYPE_3U8   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X8_Y8_Z8)
 Three interleaved channels of unsigned 8-bit values.
 
#define VPI_PIXEL_TYPE_4U8   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X8_Y8_Z8_W8)
 Four interleaved channels of unsigned 8-bit values.
 
#define VPI_PIXEL_TYPE_S8   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X8)
 One channel of signed 8-bit value.
 
#define VPI_PIXEL_TYPE_2S8   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X8_Y8)
 Two interleaved channels of signed 8-bit values.
 
#define VPI_PIXEL_TYPE_3S8   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X8_Y8_Z8)
 Three interleaved channels of signed 8-bit values.
 
#define VPI_PIXEL_TYPE_4S8   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X8_Y8_Z8_W8)
 Four interleaved channels of signed 8-bit values.
 
#define VPI_PIXEL_TYPE_U16   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X16)
 One channel of unsigned 16-bit value.
 
#define VPI_PIXEL_TYPE_2U16   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X16_Y16)
 Two interleaved channels of unsigned 16-bit values.
 
#define VPI_PIXEL_TYPE_3U16   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X16_Y16_Z16)
 Three interleaved channels of unsigned 16-bit values.
 
#define VPI_PIXEL_TYPE_4U16   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X16_Y16_Z16_W16)
 Four interleaved channels of unsigned 16-bit values.
 
#define VPI_PIXEL_TYPE_S16   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X16)
 One channel of signed 16-bit value.
 
#define VPI_PIXEL_TYPE_2S16   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X16_Y16)
 Two interleaved channels of signed 16-bit values.
 
#define VPI_PIXEL_TYPE_3S16   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X16_Y16_Z16)
 Three interleaved channels of signed 16-bit values.
 
#define VPI_PIXEL_TYPE_4S16   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X16_Y16_Z16_W16)
 Four interleaved channels of signed 16-bit values.
 
#define VPI_PIXEL_TYPE_U32   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X32)
 One channel of unsigned 32-bit value.
 
#define VPI_PIXEL_TYPE_2U32   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X32_Y32)
 Two interleaved channels of unsigned 32-bit values.
 
#define VPI_PIXEL_TYPE_3U32   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X32_Y32_Z32)
 Three interleaved channels of unsigned 32-bit values.
 
#define VPI_PIXEL_TYPE_4U32   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X32_Y32_Z32_W32)
 Four interleaved channels of unsigned 32-bit values.
 
#define VPI_PIXEL_TYPE_S32   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X32)
 One channel of signed 32-bit value.
 
#define VPI_PIXEL_TYPE_2S32   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X32_Y32)
 Two interleaved channels of signed 32-bit values.
 
#define VPI_PIXEL_TYPE_3S32   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X32_Y32_Z32)
 Three interleaved channels of signed 32-bit values.
 
#define VPI_PIXEL_TYPE_4S32   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X32_Y32_Z32_W32)
 Four interleaved channels of signed 32-bit values.
 
#define VPI_PIXEL_TYPE_F32   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X32)
 One channel of 32-bit IEEE 754 floating-point value.
 
#define VPI_PIXEL_TYPE_2F32   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X32_Y32)
 Two interleaved channels of 32-bit IEEE 754 floating-point values.
 
#define VPI_PIXEL_TYPE_3F32   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X32_Y32_Z32)
 Three interleaved channels of 32-bit IEEE 754 floating-point values.
 
#define VPI_PIXEL_TYPE_4F32   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X32_Y32_Z32_W32)
 Four interleaved channels of 32-bit IEEE 754 floating-point values.
 
#define VPI_PIXEL_TYPE_U64   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X64)
 One channel of unsigned 64-bit value.
 
#define VPI_PIXEL_TYPE_2U64   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X64_Y64)
 Two interleaved channels of unsigned 64-bit values.
 
#define VPI_PIXEL_TYPE_3U64   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X64_Y64_Z64)
 Three interleaved channels of unsigned 64-bit values.
 
#define VPI_PIXEL_TYPE_4U64   VPI_DETAIL_MAKE_PIX_TYPE(PL, UNSIGNED, X64_Y64_Z64_W64)
 Four interleaved channels of unsigned 64-bit values.
 
#define VPI_PIXEL_TYPE_S64   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X64)
 One channel of signed 64-bit value.
 
#define VPI_PIXEL_TYPE_2S64   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X64_Y64)
 Two interleaved channels of signed 64-bit values.
 
#define VPI_PIXEL_TYPE_3S64   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X64_Y64_Z64)
 Three interleaved channels of signed 64-bit values.
 
#define VPI_PIXEL_TYPE_4S64   VPI_DETAIL_MAKE_PIX_TYPE(PL, SIGNED, X64_Y64_Z64_W64)
 Four interleaved channels of signed 64-bit values.
 
#define VPI_PIXEL_TYPE_F64   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X64)
 One channel of 64-bit IEEE 754 floating-point value.
 
#define VPI_PIXEL_TYPE_2F64   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X64_Y64)
 Two interleaved channels of 64-bit IEEE 754 floating-point values.
 
#define VPI_PIXEL_TYPE_3F64   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X64_Y64_Z64)
 Three interleaved channels of 64-bit IEEE 754 floating-point values.
 
#define VPI_PIXEL_TYPE_4F64   VPI_DETAIL_MAKE_PIX_TYPE(PL, FLOAT, X64_Y64_Z64_W64)
 Four interleaved channels of 64-bit IEEE 754 floating-point values.
 
#define VPI_MAKE_PIXEL_TYPE_ABBREV(memLayout, dataType, packing)
 Creates a user-defined pixel type constant using abbreviated parameters. More...
 
#define VPI_MAKE_PIXEL_TYPE(memLayout, dataType, packing)
 Creates a user-defined pixel type constant. More...
 
typedef uint64_t VPIPixelType
 Pre-defined pixel types. More...
 
VPIPixelType vpiMakePixelType (VPIMemLayout memLayout, VPIDataType dataType, VPIPacking packing)
 Creates a user-defined pixel type. More...
 
VPIPacking vpiPixelTypeGetPacking (VPIPixelType type)
 Get the packing of a pixel type. More...
 
int vpiPixelTypeGetBitsPerPixel (VPIPixelType type)
 Get the number of bits per pixel of a pixel type. More...
 
void vpiPixelTypeGetBitsPerChannel (VPIPixelType type, int32_t *bits)
 Get the number of bits per channel of a pixel type. More...
 
VPIDataType vpiPixelTypeGetDataType (VPIPixelType type)
 Get the data type of a pixel type. More...
 
VPIMemLayout vpiPixelTypeGetMemLayout (VPIPixelType type)
 Get the memory layout of a pixel type. More...
 
VPIPixelType vpiPixelTypeSetMemLayout (VPIPixelType type, VPIMemLayout layout)
 Set the memory layout of a pixel type. More...
 
int vpiPixelTypeGetChannelCount (VPIPixelType type)
 Get the number of channels of a pixel type. More...
 
const char * vpiPixelTypeGetName (VPIPixelType type)
 Returns a string representation of the pixel type. More...
 
VPIPixelType vpiPixelTypeGetChannelType (VPIPixelType type, int channel)
 Get the pixel type for a given channel index. More...
 

Detailed Description

Defines types and functions to handle pixel types.

Definition in file PixelType.h.

Macro Definition Documentation

◆ VPI_MAKE_PIXEL_TYPE_ABBREV

#define VPI_MAKE_PIXEL_TYPE_ABBREV (   memLayout,
  dataType,
  packing 
)

Creates a user-defined pixel type constant using abbreviated parameters.

This macro allows passing abbreviated format parameters (without the parameter type prefix). Example to create a block-linear format two interleaved 32-bit floating point channels:

VPIPixelType type = VPI_MAKE_PIXEL_TYPE_ABBREV(BL, FLOAT, X32_Y32);
#define VPI_MAKE_PIXEL_TYPE_ABBREV(memLayout, dataType, packing)
Creates a user-defined pixel type constant using abbreviated parameters.
Definition: PixelType.h:194
uint64_t VPIPixelType
Pre-defined pixel types.
Definition: PixelType.h:78
Parameters
[in]memLayoutVPIMemLayout to be used, without the VPI_MEM_LAYOUT_ prefix.
[in]dataTypeVPIDataType to be used, without the VPI_DATA_TYPE_ prefix.
[in]packingFormat packing used, which also defines the number of channels, without the VPI_PACKING_ prefix.
Returns
The user-defined pixel type.

Definition at line 194 of file PixelType.h.

◆ VPI_MAKE_PIXEL_TYPE

#define VPI_MAKE_PIXEL_TYPE (   memLayout,
  dataType,
  packing 
)

Creates a user-defined pixel type constant.

Example to create a block-linear format two interleaved 32-bit floating point channels:

#define VPI_MAKE_PIXEL_TYPE(memLayout, dataType, packing)
Creates a user-defined pixel type constant.
Definition: PixelType.h:213
@ VPI_PACKING_X32_Y32
Two 32-bit channels in two 32-bit words.
Definition: DataLayout.h:233
@ VPI_MEM_LAYOUT_BL
Definition: DataLayout.h:315
@ VPI_DATA_TYPE_FLOAT
Channel are floating point values.
Definition: DataLayout.h:272
Parameters
[in]memLayoutVPIMemLayout to be used.
[in]dataTypeVPIDataType to be used.
[in]packingFormat packing used, which also defines the number of channels.
Returns
The user-defined pixel type.

Definition at line 213 of file PixelType.h.

Function Documentation

◆ vpiMakePixelType()

VPIPixelType vpiMakePixelType ( VPIMemLayout  memLayout,
VPIDataType  dataType,
VPIPacking  packing 
)

Creates a user-defined pixel type.

When the pre-defined pixel types aren't enough, user-defined formats can be created.

Parameters
[in]memLayoutVPIMemLayout to be used.
[in]dataTypeVPIDataType to be used.
[in]packingFormat packing used, which also defines the number of channels.
Returns
The user-defined pixel type.
Return values
VPI_PIXEL_TYPE_INVALIDInvalid memLayout.
VPI_PIXEL_TYPE_INVALIDInvalid dataType.
VPI_PIXEL_TYPE_INVALIDInvalid packing.

◆ vpiPixelTypeGetPacking()

VPIPacking vpiPixelTypeGetPacking ( VPIPixelType  type)

Get the packing of a pixel type.

Parameters
[in]typePixel type to be queried.
Returns
The format's packing.
Return values
VPI_PACKING_0type is invalid.

◆ vpiPixelTypeGetBitsPerPixel()

int vpiPixelTypeGetBitsPerPixel ( VPIPixelType  type)

Get the number of bits per pixel of a pixel type.

Parameters
[in]typePixel type to be queried.
Returns
The number of bits per pixel.
Return values
0type is invalid.

◆ vpiPixelTypeGetBitsPerChannel()

void vpiPixelTypeGetBitsPerChannel ( VPIPixelType  type,
int32_t *  bits 
)

Get the number of bits per channel of a pixel type.

Parameters
[in]typePixel type to be queried.
[out]bitsPointer to an int32_t array with 4 elements where output will be stored. If it is NULL, the function is a no-op, i.e., buffer pointed by bits is unchanged.

◆ vpiPixelTypeGetDataType()

VPIDataType vpiPixelTypeGetDataType ( VPIPixelType  type)

Get the data type of a pixel type.

Parameters
[in]typePixel type to be queried.
Returns
The data type of the pixel type.
Return values
VPI_DATA_TYPE_INVALIDtype is invalid.

◆ vpiPixelTypeGetMemLayout()

VPIMemLayout vpiPixelTypeGetMemLayout ( VPIPixelType  type)

Get the memory layout of a pixel type.

Parameters
[in]typePixel type to be queried.
Returns
The memory layout of the pixel type.
Return values
VPI_MEM_LAYOUT_INVALIDtype is invalid.

◆ vpiPixelTypeSetMemLayout()

VPIPixelType vpiPixelTypeSetMemLayout ( VPIPixelType  type,
VPIMemLayout  layout 
)

Set the memory layout of a pixel type.

Parameters
[in]typePixel type to have its memory layout set.
[in]layoutThe memory layout to be set.
Returns
The pixel type with the requested memory layout.
Return values
VPI_PIXEL_TYPE_INVALIDtype or layout are invalid.

◆ vpiPixelTypeGetChannelCount()

int vpiPixelTypeGetChannelCount ( VPIPixelType  type)

Get the number of channels of a pixel type.

Parameters
[in]typePixel type to be queried.
Returns
The number of channels of the pixel type.
Return values
0type is invalid.

◆ vpiPixelTypeGetName()

const char* vpiPixelTypeGetName ( VPIPixelType  type)

Returns a string representation of the pixel type.

Parameters
[in]typePixel type to be returned.
Returns
The string representation of the pixel type. Returned string is valid until next call of this function from the same calling thread. Returned pointer must not be freed.

◆ vpiPixelTypeGetChannelType()

VPIPixelType vpiPixelTypeGetChannelType ( VPIPixelType  type,
int  channel 
)

Get the pixel type for a given channel index.

It returns a single-channel pixel type that corresponds to the given channel of the input pixel type.

For instance: The channel #2 of VPI_PIXEL_TYPE_3U8 is VPI_PIXEL_TYPE_U8.

Parameters
[in]typePixel type to be queried.
[in]channelChannel whose pixel type is to be returned.
  • Must be between 0 and the maximum number of channels in type.
Returns
The pixel type of the given channel. The memory layout and data type are the same as type.
Return values
VPI_PIXEL_TYPE_INVALIDtype is invalid.
VPI_PIXEL_TYPE_INVALIDchannel is outside valid range.