Defines types and functions of NvBufSurface application programming interface.
Data Structures | |
struct | NvBufSurfacePlaneParamsEx |
Holds plane wise parameters(extended) of a buffer. More... | |
struct | NvBufSurfacePlaneParams |
Holds plane wise parameters of a buffer. More... | |
struct | NvBufSurfaceChromaSubsamplingParams |
Holds Chroma Subsampling parameters for NvBufSurface allocation. More... | |
struct | NvBufSurfaceCreateParams |
Holds parameters required to allocate an NvBufSurface. More... | |
struct | NvBufSurfaceAllocateParams |
Hold extended parameters required to allocate NvBufSurface. More... | |
struct | NvBufSurfaceMappedAddr |
Hold the pointers of mapped buffer. More... | |
struct | NvBufSurfaceParamsEx |
Hold the information(extended) of single buffer in the batch. More... | |
struct | NvBufSurfaceParams |
Hold the information of single buffer in the batch. More... | |
struct | NvBufSurface |
Holds information about batched buffers. More... | |
struct | NvBufSurfaceMapPlaneParams |
Holds plane parameters to map the buffer received from another process. More... | |
struct | NvBufSurfaceMapParams |
Holds buffer parameters to map the buffer received from another process. More... | |
Macros | |
#define | STRUCTURE_PADDING 4 |
Defines the default padding length for reserved fields of structures. More... | |
#define | NVBUF_MAX_PLANES 4 |
Defines the maximum number of planes. More... | |
#define | NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0 |
Defines the default values for chroma subsampling. More... | |
#define | NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT 1 |
#define | NVBUFSURFACE_CHROMA_SUBSAMPLING_PARAMS_DEFAULT |
Typedefs | |
typedef struct NvBufSurfacePlaneParamsEx | NvBufSurfacePlaneParamsEx |
Holds plane wise parameters(extended) of a buffer. More... | |
typedef struct NvBufSurfacePlaneParams | NvBufSurfacePlaneParams |
Holds plane wise parameters of a buffer. More... | |
typedef struct NvBufSurfaceChromaSubsamplingParams | NvBufSurfaceChromaSubsamplingParams |
Holds Chroma Subsampling parameters for NvBufSurface allocation. More... | |
typedef struct NvBufSurfaceCreateParams | NvBufSurfaceCreateParams |
Holds parameters required to allocate an NvBufSurface. More... | |
typedef struct NvBufSurfaceAllocateParams | NvBufSurfaceAllocateParams |
Hold extended parameters required to allocate NvBufSurface. More... | |
typedef struct NvBufSurfaceMappedAddr | NvBufSurfaceMappedAddr |
Hold the pointers of mapped buffer. More... | |
typedef struct NvBufSurfaceParamsEx | NvBufSurfaceParamsEx |
Hold the information(extended) of single buffer in the batch. More... | |
typedef struct NvBufSurfaceParams | NvBufSurfaceParams |
Hold the information of single buffer in the batch. More... | |
typedef struct NvBufSurface | NvBufSurface |
Holds information about batched buffers. More... | |
typedef struct NvBufSurfaceMapPlaneParams | NvBufSurfaceMapPlaneParams |
Holds plane parameters to map the buffer received from another process. More... | |
typedef struct NvBufSurfaceMapParams | NvBufSurfaceMapParams |
Holds buffer parameters to map the buffer received from another process. More... | |
Functions | |
int | NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceCreateParams *params) |
Allocates a batch of buffers. More... | |
int | NvBufSurfaceAllocate (NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceAllocateParams *paramsext) |
Allocate batch of buffers. More... | |
int | NvBufSurfaceDestroy (NvBufSurface *surf) |
Free the batched buffers previously allocated through NvBufSurfaceCreate. More... | |
int | NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type) |
Maps hardware batched buffers to the HOST or CPU address space. More... | |
int | NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane) |
Unmaps previously mapped buffer(s). More... | |
int | NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf) |
Copies the content of source batched buffer(s) to destination batched buffer(s). More... | |
int | NvBufSurface2Raw (NvBufSurface *Surf, unsigned int index, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr) |
Copies the NvBufSurface plane memory content to a raw buffer plane for a specific batched buffer. More... | |
int | Raw2NvBufSurface (unsigned char *ptr, unsigned int index, unsigned int plane, unsigned int in_width, unsigned int in_height, NvBufSurface *Surf) |
Copies the raw buffer plane memory content to the NvBufSurface plane memory of a specific batched buffer. More... | |
int | NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane) |
Syncs the HW memory cache for the CPU. More... | |
int | NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane) |
Syncs the hardware memory cache for the device. More... | |
int | NvBufSurfaceFromFd (int dmabuf_fd, void **buffer) |
Gets the NvBufSurface from the DMABUF FD. More... | |
int | NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value) |
Fills each byte of the buffer(s) in an NvBufSurface with a provided value. More... | |
int | NvBufSurfaceMapEglImage (NvBufSurface *surf, int index) |
Creates an EGLImage from the memory of one or more NvBufSurface buffers. More... | |
int | NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index) |
Destroys the previously created EGLImage object(s). More... | |
int | NvBufSurfaceImport (NvBufSurface **out_nvbuf_surf, const NvBufSurfaceMapParams *in_params) |
Import parameters received from another process and create hardware buffer. More... | |
int | NvBufSurfaceGetMapParams (const NvBufSurface *surf, int index, NvBufSurfaceMapParams *params) |
Get buffer information to map the buffer in another process. More... | |
#define NVBUF_MAX_PLANES 4 |
Defines the maximum number of planes.
Definition at line 49 of file nvbufsurface.h.
#define NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0 |
Defines the default values for chroma subsampling.
The default value matches JPEG/MPEG use cases.
Definition at line 55 of file nvbufsurface.h.
#define NVBUFSURFACE_CHROMA_SUBSAMPLING_PARAMS_DEFAULT |
Definition at line 58 of file nvbufsurface.h.
#define NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT 1 |
Definition at line 56 of file nvbufsurface.h.
#define STRUCTURE_PADDING 4 |
Defines the default padding length for reserved fields of structures.
Definition at line 46 of file nvbufsurface.h.
typedef struct NvBufSurface NvBufSurface |
Holds information about batched buffers.
typedef struct NvBufSurfaceAllocateParams NvBufSurfaceAllocateParams |
Hold extended parameters required to allocate NvBufSurface.
(Applicable for NvBufSurfaceAllocate API)
Holds Chroma Subsampling parameters for NvBufSurface allocation.
typedef struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams |
Holds parameters required to allocate an NvBufSurface.
typedef struct NvBufSurfaceMapParams NvBufSurfaceMapParams |
Holds buffer parameters to map the buffer received from another process.
typedef struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr |
Hold the pointers of mapped buffer.
typedef struct NvBufSurfaceMapPlaneParams NvBufSurfaceMapPlaneParams |
Holds plane parameters to map the buffer received from another process.
typedef struct NvBufSurfaceParams NvBufSurfaceParams |
Hold the information of single buffer in the batch.
typedef struct NvBufSurfaceParamsEx NvBufSurfaceParamsEx |
Hold the information(extended) of single buffer in the batch.
typedef struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams |
Holds plane wise parameters of a buffer.
typedef struct NvBufSurfacePlaneParamsEx NvBufSurfacePlaneParamsEx |
Holds plane wise parameters(extended) of a buffer.
Defines color formats for NvBufSurface.
Definition at line 103 of file nvbufsurface.h.
Defines display scan formats for NvBufSurface video planes.
Enumerator | |
---|---|
NVBUF_DISPLAYSCANFORMAT_PROGRESSIVE | Progessive scan formats. |
NVBUF_DISPLAYSCANFORMAT_INTERLACED | Interlaced scan formats. |
Definition at line 288 of file nvbufsurface.h.
enum NvBufSurfaceLayout |
Specifies layout formats for NvBufSurface video planes.
Enumerator | |
---|---|
NVBUF_LAYOUT_PITCH | Specifies pitch layout. |
NVBUF_LAYOUT_BLOCK_LINEAR | Specifies block linear layout. |
Definition at line 254 of file nvbufsurface.h.
Defines mapping types of NvBufSurface.
Enumerator | |
---|---|
NVBUF_MAP_READ | Specifies NvBufSurface mapping type "read.". |
NVBUF_MAP_WRITE | Specifies NvBufSurface mapping type "write.". |
NVBUF_MAP_READ_WRITE | Specifies NvBufSurface mapping type "read/write.". |
Definition at line 67 of file nvbufsurface.h.
enum NvBufSurfaceMemType |
Specifies memory types for NvBufSurface.
Enumerator | |
---|---|
NVBUF_MEM_DEFAULT | Specifies the default memory type, i.e. NVBUF_MEM_CUDA_DEVICE for dGPU, NVBUF_MEM_SURFACE_ARRAY for Jetson. Use NVBUF_MEM_DEFAULT to allocate whichever type of memory is appropriate for the platform. |
NVBUF_MEM_CUDA_PINNED | Specifies CUDA Host memory type. |
NVBUF_MEM_CUDA_DEVICE | Specifies CUDA Device memory type. |
NVBUF_MEM_CUDA_UNIFIED | Specifies CUDA Unified memory type. |
NVBUF_MEM_SURFACE_ARRAY | Specifies NVRM Surface Array type. Valid only for Jetson. |
NVBUF_MEM_HANDLE | Specifies NVRM Handle type. Valid only for Jetson. |
NVBUF_MEM_SYSTEM | Specifies memory allocated by malloc(). |
Definition at line 265 of file nvbufsurface.h.
enum NvBufSurfaceTag |
Defines tags that identify the components requesting a memory allocation.
The tags can be used later to identify the total memory allocated to particular types of components. TODO: Check if DeepStream require more tags to be defined.
Definition at line 82 of file nvbufsurface.h.
int NvBufSurface2Raw | ( | NvBufSurface * | Surf, |
unsigned int | index, | ||
unsigned int | plane, | ||
unsigned int | out_width, | ||
unsigned int | out_height, | ||
unsigned char * | ptr | ||
) |
Copies the NvBufSurface plane memory content to a raw buffer plane for a specific batched buffer.
This function can be used to copy plane memory content from source raw buffer pointer to specific destination batch buffer of supported memory type.
[in] | Surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. |
[in] | plane | index of plane in buffer. |
[in] | out_width | aligned width of the raw data plane. |
[in] | out_height | aligned height of the raw data plane. |
[in] | ptr | pointer to the output raw plane data. |
int NvBufSurfaceAllocate | ( | NvBufSurface ** | surf, |
uint32_t | batchSize, | ||
NvBufSurfaceAllocateParams * | paramsext | ||
) |
Allocate batch of buffers.
(Using extended buffer allocation parameters)
Allocates memory for batchSize buffers and returns in *surf a pointer to allocated NvBufSurface. params structure should have allocation parameters of single buffer. If size field in params is set, buffer of that size will be allocated and all other parameters (w, h, color format etc.) will be ignored.
Use NvBufSurfaceDestroy to free all the resources.
[out] | surf | pointer to allocated batched buffers. |
[in] | batchSize | batch size of buffers. |
[in] | paramsext | pointer to NvBufSurfaceAllocateParams structure. |
int NvBufSurfaceCopy | ( | NvBufSurface * | srcSurf, |
NvBufSurface * | dstSurf | ||
) |
Copies the content of source batched buffer(s) to destination batched buffer(s).
You can use this function to copy source buffer(s) of one memory type to destination buffer(s) of another memory type, e.g. CUDA host to CUDA device, malloc'ed memory to CUDA device, etc.
The source and destination NvBufSurface objects must have same buffer and batch size.
[in] | srcSurf | A pointer to the source NvBufSurface structure. |
[in] | dstSurf | A pointer to the destination NvBufSurface structure. |
int NvBufSurfaceCreate | ( | NvBufSurface ** | surf, |
uint32_t | batchSize, | ||
NvBufSurfaceCreateParams * | params | ||
) |
Allocates a batch of buffers.
Allocates memory for batchSize buffers and returns a pointer to an allocated NvBufSurface. The params structure must have the allocation parameters of a single buffer. If params.size is set, a buffer of that size is allocated, and all other parameters (width, height, color format, etc.) are ignored.
Call NvBufSurfaceDestroy() to free resources allocated by this function.
[out] | surf | An indirect pointer to the allocated batched buffers. |
[in] | batchSize | Batch size of buffers. |
[in] | params | A pointer to an NvBufSurfaceCreateParams structure. |
int NvBufSurfaceDestroy | ( | NvBufSurface * | surf | ) |
Free the batched buffers previously allocated through NvBufSurfaceCreate.
[in] | surf | A pointer to an NvBufSurface to be freed. |
int NvBufSurfaceFromFd | ( | int | dmabuf_fd, |
void ** | buffer | ||
) |
Gets the NvBufSurface from the DMABUF FD.
[in] | dmabuf_fd | DMABUF FD of the buffer. |
[out] | buffer | A pointer to the NvBufSurface. |
int NvBufSurfaceGetMapParams | ( | const NvBufSurface * | surf, |
int | index, | ||
NvBufSurfaceMapParams * | params | ||
) |
Get buffer information to map the buffer in another process.
[in] | surf | Pointer to NvBufSurface structure. |
[in] | index | Index of a buffer in the batch. |
[out] | params | Pointer to NvBufSurfaceMapParams information of the buffer. |
int NvBufSurfaceImport | ( | NvBufSurface ** | out_nvbuf_surf, |
const NvBufSurfaceMapParams * | in_params | ||
) |
Import parameters received from another process and create hardware buffer.
Calling process must need to call NvBufferDestroy() to remove reference count for hardware buffer handle of the imported DMA buffer.
[out] | out_nvbuf_surf | Pointer to hardware buffer. |
[in] | in_params | Parameters to create hardware buffer. |
int NvBufSurfaceMap | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane, | ||
NvBufSurfaceMemMapFlags | type | ||
) |
Maps hardware batched buffers to the HOST or CPU address space.
Valid for NVBUF_MEM_CUDA_UNIFIED type memory for dGPU and NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE type memory for Jetson.
This function fills an array of pointers at surf->surfaceList->mappedAddr->addr. surf is a pointer to an NvBufSurface. surfaceList is a pointer to an NvBufSurfaceParams. mappedAddr is a pointer to an NvBufSurfaceMappedAddr. addr is declared as an array of pointers to void, and holds pointers to the buffers.
The client must call NvBufSurfaceSyncForCpu() with the virtual address populated by this function before accessing mapped memory in the CPU.
After memory mapping is complete, mapped memory modification must be coordinated between the CPU and the hardware device as follows:
Use NvBufSurfaceUnMap() to unmap buffer(s) and release any resource.
[in,out] | surf | A pointer to an NvBufSurface structure. The function stores pointers to the buffers in a descendant of this structure; see the notes above. |
[in] | index | Index of a buffer in the batch. -1 refers to all buffers in the batch. |
[in] | plane | Index of a plane in buffer. -1 refers to all planes in the buffer. |
[in] | type | A flag for mapping type. |
int NvBufSurfaceMapEglImage | ( | NvBufSurface * | surf, |
int | index | ||
) |
Creates an EGLImage from the memory of one or more NvBufSurface buffers.
Only memory type NVBUF_MEM_SURFACE_ARRAY is supported.
This function returns the created EGLImage by storing its address at surf->surfaceList->mappedAddr->eglImage. (surf is a pointer to an NvBufSurface. surfaceList is a pointer to an NvBufSurfaceParams. mappedAddr is a pointer to an NvBufSurfaceMappedAddr. eglImage is declared as a pointer to void, and holds an EGLImageKHR.)
You can use this function in scenarios where a CUDA operation on Jetson hardware memory (identified by NVBUF_MEM_SURFACE_ARRAY) is required. The EGLImageKHR struct provided by this function can then be registered with CUDA for further CUDA operations.
[in,out] | surf | A pointer to an NvBufSurface structure. The function stores a pointer to the created EGLImage in a descendant of this structure; see the notes above. |
[in] | index | Index of a buffer in the batch. -1 specifies all buffers in the batch. |
int NvBufSurfaceMemSet | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane, | ||
uint8_t | value | ||
) |
Fills each byte of the buffer(s) in an NvBufSurface with a provided value.
You can also use this function to reset the buffer(s) in the batch.
[in] | surf | A pointer to the NvBufSurface structure. |
[in] | index | Index of a buffer in the batch. -1 refers to all buffers in the batch. |
[in] | plane | Index of a plane in the buffer. -1 refers to all planes in the buffer. |
[in] | value | The value to be used as fill. |
int NvBufSurfaceSyncForCpu | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Syncs the HW memory cache for the CPU.
Valid only for memory types NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE.
[in] | surf | A pointer to an NvBufSurface structure. |
[in] | index | Index of the buffer in the batch. -1 refers to all buffers in the batch. |
[in] | plane | Index of a plane in the buffer. -1 refers to all planes in the buffer. |
int NvBufSurfaceSyncForDevice | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Syncs the hardware memory cache for the device.
Valid only for memory types NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE.
[in] | surf | A pointer to an NvBufSurface structure. |
[in] | index | Index of a buffer in the batch. -1 refers to all buffers in the batch. |
[in] | plane | Index of a plane in the buffer. -1 refers to all planes in the buffer. |
int NvBufSurfaceUnMap | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Unmaps previously mapped buffer(s).
[in] | surf | A pointer to an NvBufSurface structure. |
[in] | index | Index of a buffer in the batch. -1 indicates all buffers in the batch. |
[in] | plane | Index of a plane in the buffer. -1 indicates all planes in the buffer. |
int NvBufSurfaceUnMapEglImage | ( | NvBufSurface * | surf, |
int | index | ||
) |
Destroys the previously created EGLImage object(s).
[in] | surf | A pointer to an NvBufSurface structure. |
[in] | index | The index of a buffer in the batch. -1 specifies all buffers in the batch. |
int Raw2NvBufSurface | ( | unsigned char * | ptr, |
unsigned int | index, | ||
unsigned int | plane, | ||
unsigned int | in_width, | ||
unsigned int | in_height, | ||
NvBufSurface * | Surf | ||
) |
Copies the raw buffer plane memory content to the NvBufSurface plane memory of a specific batched buffer.
This function can be used to copy plane memory content from batch buffer to specific destination raw buffer pointer.
[in] | ptr | pointer to the input raw plane data. |
[in] | index | index of buffer in the batch. |
[in] | plane | index of plane in buffer. |
[in] | in_width | aligned width of the raw data plane. |
[in] | in_height | aligned height of the raw data plane. |
[in] | Surf | pointer to NvBufSurface structure. |