The 2D Processing API encompasses all NvMedia 2D image processing related functionality.
6
Data Structures | |
struct | NvMedia2DAttributes |
Attributes structure for NvMedia2DCreate(). More... | |
struct | NvMedia2DComposeResult |
Stores information returned from NvMedia2DCompose(). More... | |
struct | NvMedia2DFilterCoefficients5Tap |
Coefficients values structure for 5-tap custom filter. More... | |
struct | NvMedia2DFilterCoefficients10Tap |
Coefficients values structure for 10-tap custom filter. More... | |
Macros | |
#define | NVMEDIA_2D_VERSION_MAJOR 8 |
Major version number of NvMedia 2D header. More... | |
#define | NVMEDIA_2D_VERSION_MINOR 0 |
Minor version number of NvMedia 2D header. More... | |
#define | NVMEDIA_2D_VERSION_PATCH 0 |
Patch version number of NvMedia 2D header. More... | |
Typedefs | |
typedef uint32_t | NvMedia2DComposeParameters |
Stores configuration for the NvMedia2DCompose() operation. More... | |
typedef uint32_t | NvMedia2DFilterBuffer |
Stores a filter buffer which coefficients can be configured. More... | |
typedef struct NvMedia2D | NvMedia2D |
NvMedia2D Context. More... | |
Enumerations | |
enum | NvMedia2DFilter { NVMEDIA_2D_FILTER_OFF = 0x1, NVMEDIA_2D_FILTER_LOW, NVMEDIA_2D_FILTER_MEDIUM, NVMEDIA_2D_FILTER_HIGH } |
2D filter mode. More... | |
enum | NvMedia2DTransform { NVMEDIA_2D_TRANSFORM_NONE = 0x0, NVMEDIA_2D_TRANSFORM_ROTATE_90, NVMEDIA_2D_TRANSFORM_ROTATE_180, NVMEDIA_2D_TRANSFORM_ROTATE_270, NVMEDIA_2D_TRANSFORM_FLIP_HORIZONTAL, NVMEDIA_2D_TRANSFORM_INV_TRANSPOSE, NVMEDIA_2D_TRANSFORM_FLIP_VERTICAL, NVMEDIA_2D_TRANSFORM_TRANSPOSE } |
2D rotation/transform. More... | |
enum | NvMedia2DBlendMode { NVMEDIA_2D_BLEND_MODE_DISABLED, NVMEDIA_2D_BLEND_MODE_CONSTANT_ALPHA, NVMEDIA_2D_BLEND_MODE_STRAIGHT_ALPHA, NVMEDIA_2D_BLEND_MODE_PREMULTIPLIED_ALPHA } |
Blending to use when compositing surfaces. More... | |
#define NVMEDIA_2D_VERSION_MAJOR 8 |
Major version number of NvMedia 2D header.
This defines the major version of the API defined in this header. This is intended to be used when validating the version number returned by the NvMedia2DGetVersion() function.
Definition at line 47 of file nvmedia_2d.h.
#define NVMEDIA_2D_VERSION_MINOR 0 |
Minor version number of NvMedia 2D header.
This defines the minor version of the API defined in this header. This is intended to be used when validating the version number returned by the NvMedia2DGetVersion() function.
Definition at line 57 of file nvmedia_2d.h.
#define NVMEDIA_2D_VERSION_PATCH 0 |
Patch version number of NvMedia 2D header.
This defines the patch version of the API defined in this header.
Definition at line 65 of file nvmedia_2d.h.
NvMedia2D Context.
This type represents a context for the NvMedia2D library. This context is an opaque data type that encapsulates the state needed to service the NvMedia2D API calls.
Definition at line 464 of file nvmedia_2d.h.
typedef uint32_t NvMedia2DComposeParameters |
Stores configuration for the NvMedia2DCompose() operation.
This object stores the information needed to configure the 2D operation that is executed inside the NvMedia2DCompose() function.
The underlying object cannot be instantiated directly by the client. Instead use the NvMedia2DGetComposeParameters() function to retrieve a handle to an available instance.
Value 0 is never a valid handle value, and can be used to initialize an NvMedia2DComposeParameters handle to a known value.
Definition at line 322 of file nvmedia_2d.h.
typedef uint32_t NvMedia2DFilterBuffer |
Stores a filter buffer which coefficients can be configured.
The underlying object cannot be instantiated directly by the client. Instead use the NvMedia2DCreateFilterBuffer() function to create and retrieve a handle to an available instance with resources allocated. Use NvMedia2DDestroyFilterBuffer() function to deallocate resources allocated by NvMedia2DCreateFilterBuffer() and release an instance.
Value 0 is never a valid handle value, and can be used to initialize an NvMedia2DFilterBuffer handle to a known value.
Definition at line 338 of file nvmedia_2d.h.
enum NvMedia2DBlendMode |
Blending to use when compositing surfaces.
Definition at line 205 of file nvmedia_2d.h.
enum NvMedia2DFilter |
2D filter mode.
This enum describes the filter modes that are supported by NvMedia 2D.
Definition at line 73 of file nvmedia_2d.h.
enum NvMedia2DTransform |
2D rotation/transform.
This enum describes the 2D transform to apply during a blit operation.
Transformations are used to rotate and mirror the source surface of a blit operation. The destination rectangle is not affected by any transformation settings.
NvMediaTransform identifies the transformations that can be applied as a combination of rotation and mirroring.
Specifically, given a hypothetical 2x2 image, applying these operations would yield the following results:
Definition at line 173 of file nvmedia_2d.h.
NvMediaStatus NvMedia2DCompose | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters const | params, | ||
NvMedia2DComposeResult *const | result | ||
) |
Performs a 2D compose operation.
A compose operation transfers pixels from a set of source surfaces to a destination surface, applying a variety of transformations to the pixel values on the way. The surfaces can have different pixel formats. NvMedia 2D does the necessary conversions between the formats.
If the dimensions of the source rectangle do not match the dimensions of the destination rectangle, the operation scales the pixels to fit the destination rectangle. The filtering mode for scale defaults to NVMEDIA_2D_FILTER_OFF. Additional filtering modes can be used by setting the corresponding parameter using NvMedia2DSetSrcFilter().
This example performs a straight pixel copy between surfaces of the same dimensions (but not necessarily the same bit depth or color format):
Restrictions on dimensions for input and output surfaces:
Additional restrictions for chroma sub-sampled YUV formats:
Restrictions on the source rectangle:
Restrictions on the destination rectangle:
If any of the restrictions are violated, this function will fail with an error code.
Performance considerations:
[in] | handle | Pointer to the NvMedia2D context. |
[in] | params | An NvMedia2DComposeParameters handle. |
[out] | result | Pointer to NvMedia2DComposeResult struct that will be populated with result info. May be NULL. |
NVMEDIA_STATUS_OK | Operation submitted successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value. This could be:
|
NVMEDIA_STATUS_NOT_SUPPORTED | Requested operation is not supported by current platform (see restrictions on parameters). |
NVMEDIA_STATUS_TIMED_OUT | No space available in the command buffer for this operation, because previous operations are still pending (see restrictions on concurrency). The caller should wait for the least recently submitted operation to complete and then try again. |
NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to perform the compose operation. This error indicates the system is potentially in an unrecoverable state. |
Usage considerations
NvMediaStatus NvMedia2DComputeFilterCoefficients10Tap | ( | NvMedia2D *const | handle, |
NvMedia2DFilterBuffer const | filterBuffer, | ||
uint32_t const | index, | ||
NvMedia2DFilterCoefficients10Tap const *const | lumaX, | ||
NvMedia2DFilterCoefficients10Tap const *const | lumaY, | ||
NvMedia2DFilterCoefficients10Tap const *const | chromaX, | ||
NvMedia2DFilterCoefficients10Tap const *const | chromaY | ||
) |
Computes the 10-tap filter coefficients for an NvMedia2DFilterBuffer.
This function computes the filter coefficients values for a specific source layer based on the contents of four NvMedia2DFilterCoefficients10Tap structures.
There is no restriction on multiple parameters pointing to the same NvMedia2DFilterCoefficients10Tap structure
[in] | handle | Pointer to the NvMedia2D context. |
[in] | filterBuffer | An NvMedia2DFilterBuffer handle. |
[in] | index | Index of source layer to configure. Must be in range [0, 4]. |
[in] | lumaX,lumaY | Pointers to NvMedia2DFilterCoefficients10Tap. These configure to the luma component for YUV formats, or all the components for RGB formats. There is one pointer for the horizontal direction, and one pointer for the vertical direction. |
[in] | chromaX,chromaY | Pointers to NvMedia2DFilterCoefficients10Tap. These configure the chroma component for YUV formats. There is one pointer for the horizontal direction, and one pointer for the vertical direction. |
NVMEDIA_STATUS_OK | Filter buffer was updated successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
Usage considerations
NvMediaStatus NvMedia2DComputeFilterCoefficients5Tap | ( | NvMedia2D *const | handle, |
NvMedia2DFilterBuffer const | filterBuffer, | ||
uint32_t const | index, | ||
NvMedia2DFilterCoefficients5Tap const *const | lumaX, | ||
NvMedia2DFilterCoefficients5Tap const *const | lumaY, | ||
NvMedia2DFilterCoefficients5Tap const *const | chromaX, | ||
NvMedia2DFilterCoefficients5Tap const *const | chromaY | ||
) |
Computes the 5-tap filter coefficients for an NvMedia2DFilterBuffer.
This function computes the filter coefficients values for a specific source layer based on the contents of four NvMedia2DFilterCoefficients5Tap structures.
There is no restriction on multiple parameters pointing to the same NvMedia2DFilterCoefficients5Tap structure
[in] | handle | Pointer to the NvMedia2D context. |
[in] | filterBuffer | An NvMedia2DFilterBuffer handle. |
[in] | index | Index of source layer to configure. Must be in range [0, 4]. |
[in] | lumaX,lumaY | Pointers to NvMedia2DFilterCoefficients5Tap. These configure to the luma component for YUV formats, or all the components for RGB formats. There is one pointer for the horizontal direction, and one pointer for the vertical direction. |
[in] | chromaX,chromaY | Pointers to NvMedia2DFilterCoefficients5Tap. These configure the chroma component for YUV formats. There is one pointer for the horizontal direction, and one pointer for the vertical direction. |
NVMEDIA_STATUS_OK | Filter buffer was updated successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
Usage considerations
NvMediaStatus NvMedia2DCreate | ( | NvMedia2D ** | handle, |
NvMedia2DAttributes const *const | attr | ||
) |
Creates a new NvMedia2D context.
This function creates a new instance of an NvMedia2D context, and returns a pointer to that context. Ownership of this context is passed to the caller. When no longer in use, the caller must destroy the context using the NvMedia2DDestroy() function.
Default attributes (when not specified by caller):
[out] | handle | Pointer to receive the handle to the new NvMedia2D context. |
[in] | attr | Pointer to NvMedia2DAttributes struct, or NULL for default attributes. |
NVMEDIA_STATUS_OK | Context created successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | handle is NULL, or attr has bad attribute values. |
NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
NVMEDIA_STATUS_NOT_SUPPORTED | NvMedia 2D is not supported on this hardware platform. |
NVMEDIA_STATUS_OUT_OF_MEMORY | Memory allocation failed for internal data structures or device memory buffers. |
NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to create the context. |
Usage considerations
NvMediaStatus NvMedia2DCreateFilterBuffer | ( | NvMedia2D *const | handle, |
NvMedia2DFilterBuffer *const | filterBuffer | ||
) |
Creates and returns an NvMedia2DFilterBuffer instance.
This functions returns a handle to an NvMedia2DFilterBuffer object. The filter buffer can be used to provide custom 5-tap and 10-tap filter coefficients for a compose operation.
The buffer instance must be destroyed with NvMedia2DDestroyFilterBuffer() during the De-Init stage.
[in] | handle | Pointer to the NvMedia2D context. |
[out] | filterBuffer | Pointer to an NvMedia2DFilterBuffer, which will be populated with the handle. |
NVMEDIA_STATUS_OK | Buffer created successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | Maximum number of buffers has been created. |
NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
NVMEDIA_STATUS_OUT_OF_MEMORY | Failed to allocate memory for the buffer. |
NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to create the buffer. |
Usage considerations
NvMediaStatus NvMedia2DDestroy | ( | NvMedia2D * | handle | ) |
Destroys the NvMedia2D context.
This function destroys the specified NvMedia2D context.
Before calling this function, the caller must ensure:
[in] | handle | Pointer to the NvMedia2D context. |
NVMEDIA_STATUS_OK | Context destroyed successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | handle is NULL. |
NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
NVMEDIA_STATUS_PENDING | There are still some NvSciSync or NvSciBuf objects registered against the NvMedia2D context. |
NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to destroy the context. The context is in state where the only valid operation is to attempt to destroy it again. |
Usage considerations
NvMediaStatus NvMedia2DDestroyFilterBuffer | ( | NvMedia2D *const | handle, |
NvMedia2DFilterBuffer const | filterBuffer | ||
) |
Destroys an NvMedia2DFilterBuffer instance.
This functions destroys an NvMedia2DFilterBuffer object.
[in] | handle | Pointer to the NvMedia2D context. |
[in] | filterBuffer | An NvMedia2DFilterBuffer handle. |
NVMEDIA_STATUS_OK | Buffer are destroyed successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
NVMEDIA_STATUS_INVALID_STATE | The function was called in incorrect system state. |
NVMEDIA_STATUS_PENDING | The buffer is still being used by a pending operation. |
NVMEDIA_STATUS_ERROR | An internal failure occurred when trying to destroy the buffer. The buffer is in state where the only valid operation is to attempt to destroy it again. |
Usage considerations
NvMediaStatus NvMedia2DGetComposeParameters | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters * | params | ||
) |
Returns an NvMedia2DComposeParameters instance.
This functions returns a handle to an NvMedia2DComposeParameters object. The object will be initialised and ready to use. The caller takes ownership of this handle. Ownership will be passed back to the NvMedia2D context when it is subsequently used in the NvMedia2DCompose() operation.
The object will be initialised with these default values:
[in] | handle | Pointer to the NvMedia2D context. |
[out] | params | Pointer to an NvMedia2DComposeParameters, which will be populated with the handle. |
NVMEDIA_STATUS_OK | Parameters instance is initialized successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
NVMEDIA_STATUS_INSUFFICIENT_BUFFERING | There is no free instance available. |
Usage considerations
NvMediaStatus NvMedia2DGetVersion | ( | NvMediaVersion * | version | ) |
Returns the version number of the NvMedia 2D library.
This function returns the major and minor version number of the NvMedia 2D library. The client must pass an NvMediaVersion struct to this function, and the version information will be returned in this struct.
This allows the client to verify that the version of the library matches and is compatible with the the version number of the header file they are using.
[out] | version | Pointer to an NvMediaVersion struct that will be populated with the version information. |
NVMEDIA_STATUS_OK | Version information returned successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | version is NULL. |
Usage considerations
NvMediaStatus NvMedia2DSetFilterBuffer | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters const | params, | ||
NvMedia2DFilterBuffer const | filterBuffer | ||
) |
Sets the filter buffer for an NvMedia2DComposeParameters instance.
This function updates the NvMedia2DComposeParameters instance to indicate that the specified filter buffer object shall be used to provide the custom filter coefficients for the compose operation.
After this function returns successfully, there are a few additional limitations on the compose operation:
Due to the filter buffer object being read-only from the compose operation perspective, there is no limitation for the same filter buffer object to be set for multiple NvMedia2DComposeParameters instances.
[in] | handle | Pointer to the NvMedia2D context. |
[in] | params | An NvMedia2DComposeParameters handle. |
[in] | filterBuffer | An NvMedia2DFilterBuffer handle. |
NVMEDIA_STATUS_OK | Filter buffer was set successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value, either:
|
Usage considerations
NvMediaStatus NvMedia2DSetSrcBlendMode | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters const | params, | ||
uint32_t const | index, | ||
NvMedia2DBlendMode const | blendMode, | ||
float const | constantAlpha | ||
) |
Sets the blend mode for a source layer.
[in] | handle | Pointer to the NvMedia2D context. |
[in] | params | An NvMedia2DComposeParameters handle. |
[in] | index | Index of source layer to configure. Must be in range [0, 15]. |
[in] | blendMode | Blend mode to set. |
[in] | constantAlpha | Constant alpha factor to use in blending. Must be in range [0, 1]. |
NVMEDIA_STATUS_OK | Parameters set successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value. This could be:
|
Usage considerations
NvMediaStatus NvMedia2DSetSrcFilter | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters const | params, | ||
uint32_t const | index, | ||
NvMedia2DFilter const | filter | ||
) |
Sets the filter mode for a source layer.
[in] | handle | Pointer to the NvMedia2D context. |
[in] | params | An NvMedia2DComposeParameters handle. |
[in] | index | Index of source layer to configure. Must be in range [0, 15]. |
[in] | filter | An NvMedia2DFilter to use when reading the the layer's source surface. |
NVMEDIA_STATUS_OK | Parameters set successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value. This could be:
|
Usage considerations
NvMediaStatus NvMedia2DSetSrcGeometry | ( | NvMedia2D *const | handle, |
NvMedia2DComposeParameters const | params, | ||
uint32_t const | index, | ||
NvMediaRect const *const | srcRect, | ||
NvMediaRect const *const | dstRect, | ||
NvMedia2DTransform const | transform | ||
) |
Sets the geometry for a source layer.
[in] | handle | Pointer to the NvMedia2D context. |
[in] | params | An NvMedia2DComposeParameters handle. |
[in] | index | Index of source layer to configure. Must be in range [0, 15]. |
[in] | dstRect | Pointer to an NvMediaRect that contains the destination rectangle, or NULL for default rectangle. |
[in] | srcRect | Pointer to an NvMediaRect that contains the source rectangle, or NULL for default rectangle. |
[in] | transform | An NvMedia2DTransform to apply the content region. |
NVMEDIA_STATUS_OK | Parameters set successfully. |
NVMEDIA_STATUS_BAD_PARAMETER | One of the parameters has an invalid value. This could be:
|
NVMEDIA_STATUS_NOT_SUPPORTED | Requested operation is not supported by current platform. |
Usage considerations