Converts the image contents to the desired format, with optional pixel value scaling and offset. More...
Data Structures | |
struct | VPIConvertImageFormatParams |
Parameters for customizing image format conversion. More... | |
Enumerations | |
enum | VPIConversionPolicy |
Policy used when converting between image types. More... | |
Functions | |
VPIStatus | vpiInitConvertImageFormatParams (VPIConvertImageFormatParams *params) |
Initialize VPIConvertImageFormatParams with default values. More... | |
VPIStatus | vpiSubmitConvertImageFormat (VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, const VPIConvertImageFormatParams *params) |
Converts the image contents to the desired format, with optional scaling and offset. More... | |
VPIStatus | vpiSubmitConvertImageFormatPyramid (VPIStream stream, uint64_t backend, VPIPyramid input, VPIPyramid output, const VPIConvertImageFormatParams *params) |
Converts the pyramid contents to the desired format, with optional scaling and offset. More... | |
Converts the image contents to the desired format, with optional pixel value scaling and offset.
Refer to Convert Image Format for more details and usage examples.
struct VPIConvertImageFormatParams |
Parameters for customizing image format conversion.
These parameters are used to customize how the conversion will be made. Make sure to call vpiInitConvertImageFormatParams to initialize this structure before updating its attributes. This guarantees that new attributes added in future versions will have a suitable default value assigned.
Definition at line 85 of file ConvertImageFormat.h.
Data Fields | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
VPIConversionPolicy | policy |
Conversion policy to be used.
| ||||||||||||||||
float | scale |
Scaling factor. Pass 1 for no scaling.
| ||||||||||||||||
float | offset |
Offset factor. Pass 0 for no offset.
| ||||||||||||||||
uint64_t | flags |
Control flags.
| ||||||||||||||||
VPIInterpolationType | chromaUpFilter |
Interpolation to use for chroma upsampling.
| ||||||||||||||||
VPIInterpolationType | chromaDownFilter |
Interpolation to use for chroma downsampling.
|
enum VPIConversionPolicy |
#include </opt/nvidia/vpi2/include/vpi/Types.h>
Policy used when converting between image types.
VPIStatus vpiInitConvertImageFormatParams | ( | VPIConvertImageFormatParams * | params | ) |
#include </opt/nvidia/vpi2/include/vpi/algo/ConvertImageFormat.h>
Initialize VPIConvertImageFormatParams with default values.
The following parameters are set:
[out] | params | Pointer to structure to be filled. Must not be NULL. |
VPI_ERROR_INVALID_ARGUMENT | params is NULL. |
VPI_SUCCESS | Operation executed successfully. |
VPIStatus vpiSubmitConvertImageFormat | ( | VPIStream | stream, |
uint64_t | backend, | ||
VPIImage | input, | ||
VPIImage | output, | ||
const VPIConvertImageFormatParams * | params | ||
) |
#include </opt/nvidia/vpi2/include/vpi/algo/ConvertImageFormat.h>
Converts the image contents to the desired format, with optional scaling and offset.
The input and output formats are inferred from the corresponding images passed as parameters. When scaling and offset are fractional, input is converted to 32-bit floating point prior conversion takes place. The formula that relates input and output pixels is:
\[ out(x,y) = clamp_{[\mathsf{min_{out}},\mathsf{max_{out}}]}(in(x,y)*\alpha + \beta) \]
where:
Floating point to integer conversion does returns the nearest integer number, rounding halfway cases away from zero.
Supported format conversions.
CPU and CUDA | VIC |
---|---|
VPI_IMAGE_FORMAT_2F32 | VPI_IMAGE_FORMAT_Y16 |
VPI_IMAGE_FORMAT_Y16_BL |
VIC |
---|
VPI_IMAGE_FORMAT_Y16_ER |
VPI_IMAGE_FORMAT_Y16_ER_BL |
VIC |
---|
VPI_IMAGE_FORMAT_2S16 |
VPI_IMAGE_FORMAT_2S16_BL |
CPU and CUDA | |
---|---|
VPI_IMAGE_FORMAT_Y8 | VPI_IMAGE_FORMAT_S8 |
VPI_IMAGE_FORMAT_Y16 | VPI_IMAGE_FORMAT_S16 |
VPI_IMAGE_FORMAT_U8 | |
VPI_IMAGE_FORMAT_U16 | |
VPI_IMAGE_FORMAT_F32 |
Conversion among format with extended or studio ranges and non-color formats (i.e. U8, F32, S16, ...) will keep range unchanged, except for clamping or casting specified in VPIConvertImageFormatParams::policy.
[in] | stream | A stream handle where the operation will be queued into.
|
[in] | backend | Backend that will execute the algorithm.
|
[in] | input | Input image to be converted.
|
[out] | output | Output image where result will be written to, with the desired format.
|
[in] | params | Parameters to fine tune the conversion. Pass NULL to use default values given by vpiInitConvertImageFormatParams. |
VPI_ERROR_INVALID_ARGUMENT | stream is NULL. |
VPI_ERROR_INVALID_ARGUMENT | input or output are NULL. |
VPI_ERROR_INVALID_ARGUMENT | Invalid flags in params . |
VPI_ERROR_INVALID_ARGUMENT | Invalid conversion type in params . |
VPI_ERROR_INVALID_ARGUMENT | input and output image dimensions do not match. |
VPI_ERROR_INVALID_ARGUMENT | output format can't be used with given image dimensions. |
VPI_ERROR_INVALID_IMAGE_FORMAT | Format conversion not supported. |
VPI_ERROR_NOT_IMPLEMENTED | Convert Image Format algorithm is not supported by given backend. |
VPI_ERROR_INVALID_OPERATION | Hardware backend not available. |
VPI_ERROR_INVALID_OPERATION | The needed backends aren't enabled in stream , input or output . |
VPI_SUCCESS | Operation executed successfully. |
VPIStatus vpiSubmitConvertImageFormatPyramid | ( | VPIStream | stream, |
uint64_t | backend, | ||
VPIPyramid | input, | ||
VPIPyramid | output, | ||
const VPIConvertImageFormatParams * | params | ||
) |
#include </opt/nvidia/vpi2/include/vpi/algo/ConvertImageFormat.h>
Converts the pyramid contents to the desired format, with optional scaling and offset.
The input and output formats are inferred from the corresponding pyramids passed as parameters. When scaling and offset are fractional, input is converted to 32-bit floating point prior conversion takes place. The formula that relates input and output pixels is:
\[ out(x,y) = clamp_{[\mathsf{min_{out}},\mathsf{max_{out}}]}(in(x,y)*\alpha + \beta) \]
where:
Floating point to integer conversion does returns the nearest integer number, rounding halfway cases away from zero.
Supported format conversions.
CPU and CUDA | VIC |
---|---|
VPI_IMAGE_FORMAT_2F32 | VPI_IMAGE_FORMAT_Y16 |
VPI_IMAGE_FORMAT_Y16_BL |
VIC |
---|
VPI_IMAGE_FORMAT_Y16_ER |
VPI_IMAGE_FORMAT_Y16_ER_BL |
VIC |
---|
VPI_IMAGE_FORMAT_S16 |
VPI_IMAGE_FORMAT_S16_BL |
CPU and CUDA | |
---|---|
VPI_IMAGE_FORMAT_Y8 | VPI_IMAGE_FORMAT_S8 |
VPI_IMAGE_FORMAT_Y16 | VPI_IMAGE_FORMAT_S16 |
VPI_IMAGE_FORMAT_U8 | |
VPI_IMAGE_FORMAT_U16 | |
VPI_IMAGE_FORMAT_F32 |
Conversion among format with extended or studio ranges and non-color formats (i.e. U8, F32, S16, ...) will keep range unchanged, except for clamping or casting specified in VPIConvertImageFormatParams::policy.
[in] | stream | A stream handle where the operation will be queued into.
|
[in] | backend | Backend that will execute the algorithm.
|
[in] | input | Input pyramid to be converted.
|
[out] | output | Output pyramid where result will be written to, with the desired format.
|
[in] | params | Parameters to fine tune the conversion. Pass NULL to use default values given by vpiInitConvertImageFormatParams. |
VPI_ERROR_INVALID_ARGUMENT | stream is NULL. |
VPI_ERROR_INVALID_ARGUMENT | input or output are NULL. |
VPI_ERROR_INVALID_ARGUMENT | Invalid flags in params . |
VPI_ERROR_INVALID_ARGUMENT | Invalid conversion type in params . |
VPI_ERROR_INVALID_ARGUMENT | input and output pyramid dimensions or number of levels do not match. |
VPI_ERROR_INVALID_ARGUMENT | output format can't be used with given pyramid dimensions. |
VPI_ERROR_INVALID_IMAGE_FORMAT | Format conversion not supported. |
VPI_ERROR_NOT_IMPLEMENTED | Convert Image Format algorithm is not supported by given backend. |
VPI_ERROR_INVALID_OPERATION | Hardware backend not available. |
VPI_ERROR_INVALID_OPERATION | The needed backends aren't enabled in stream , input or output . |
VPI_SUCCESS | Operation executed successfully. |