![]() |
NVIDIA DeepStream SDK API Reference4.0.2 Release |
NvBufSurface Interface
This file specifies the NvBufSurface management APIs.
NvBufSurface APIs provides methods to allocate / deallocate, map / unmap and copy batched buffers.
Definition in file nvbufsurface.h.
Go to the source code of this file.
Data Structures | |
struct | NvBufSurfacePlaneParams |
Holds plane wise parameters of a buffer. More... | |
struct | NvBufSurfaceCreateParams |
Hold parameters required to allocate NvBufSurface. More... | |
struct | NvBufSurfaceMappedAddr |
Hold the pointers of mapped buffer. More... | |
struct | NvBufSurfaceParams |
Hold the information of single buffer in the batch. More... | |
struct | NvBufSurface |
Hold the information of batched buffers. More... | |
#define NVBUF_MAX_PLANES 4 |
Maximum number of planes.
Definition at line 43 of file nvbufsurface.h.
#define STRUCTURE_PADDING 4 |
Default padding for reserved fields of structures.
Definition at line 40 of file nvbufsurface.h.
typedef struct NvBufSurface NvBufSurface |
Hold the information of batched buffers.
typedef struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams |
Hold parameters required to allocate NvBufSurface.
typedef struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr |
Hold the pointers of mapped buffer.
typedef struct NvBufSurfaceParams NvBufSurfaceParams |
Hold the information of single buffer in the batch.
typedef struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams |
Holds plane wise parameters of a buffer.
Defines color formats for NvBufSurface.
Definition at line 58 of file nvbufsurface.h.
enum NvBufSurfaceLayout |
Defines Layout formats for NvBufSurface video planes.
Enumerator | |
---|---|
NVBUF_LAYOUT_PITCH |
Pitch Layout. |
NVBUF_LAYOUT_BLOCK_LINEAR |
Block Linear Layout. |
Definition at line 141 of file nvbufsurface.h.
Defines mapping types of NvBufSurface.
Enumerator | |
---|---|
NVBUF_MAP_READ | |
NVBUF_MAP_WRITE | |
NVBUF_MAP_READ_WRITE |
Definition at line 48 of file nvbufsurface.h.
enum NvBufSurfaceMemType |
Defines memory types of NvBufSurface.
Definition at line 152 of file nvbufsurface.h.
int NvBufSurfaceCopy | ( | NvBufSurface * | srcSurf, |
NvBufSurface * | dstSurf | ||
) |
Copy the memory content of source batched buffer(s) to memory of destination batched buffer(s).
This function can be used to copy source buffer(s) of one memory type to destination buffer(s) of different memory type. e.g. CUDA Host to CUDA Device or malloced memory to CUDA device etc.
Both source and destination NvBufSurface must have same buffer and batch size.
[in] | srcSurf | pointer to source NvBufSurface structure. |
[in] | dstSurf | pointer to destination NvBufSurface structure. |
int NvBufSurfaceCreate | ( | NvBufSurface ** | surf, |
uint32_t | batchSize, | ||
NvBufSurfaceCreateParams * | params | ||
) |
Allocate batch of buffers.
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] | params | pointer to NvBufSurfaceCreateParams structure. |
int NvBufSurfaceDestroy | ( | NvBufSurface * | surf | ) |
Free the batched buffers previously allocated through NvBufSurfaceCreate.
[in] | surf | pointer to NvBufSurface to free. |
int NvBufSurfaceFromFd | ( | int | dmabuf_fd, |
void ** | buffer | ||
) |
Get the NvBufSurface from the dmabuf fd.
[in] | dmabuf_fd | dmabuf fd of the buffer. |
[out] | buffer | pointer to NvBufSurface. |
int NvBufSurfaceMap | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane, | ||
NvBufSurfaceMemMapFlags | type | ||
) |
Map HW batched buffers to HOST / CPU address space.
Valid for NVBUF_MEM_CUDA_UNIFIED type of memory for dGPU and NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE type of memory for Jetson.
This function will fill addr array of NvBufSurfaceMappedAddr field of NvBufSurfaceParams with the CPU mapped memory pointers.
The client must call NvBufSurfaceSyncForCpu() with the virtual address populated by this function before accessing the mapped memory in CPU.
After memory mapping is complete, mapped memory modification must be coordinated between the CPU and hardware device as follows:
Use NvBufSurfaceUnMap() to unmap buffer(s) and release any resource.
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
[in] | plane | index of plane in buffer. -1 for all planes in buffer. |
[in] | type | flag for mapping type. |
int NvBufSurfaceMapEglImage | ( | NvBufSurface * | surf, |
int | index | ||
) |
Creates an EGLImage from memory of NvBufSurface buffer(s).
Only memory type NVBUF_MEM_SURFACE_ARRAY is supported. This function will set eglImage pointer of NvBufSurfaceMappedAddr field of NvBufSurfaceParams with EGLImageKHR.
This function can be used in scenarios where CUDA operation on Jetson HW memory (NVBUF_MEM_SURFACE_ARRAY) is required. EGLImageKHR provided by this function can then be register with CUDA for further CUDA operations.
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
int NvBufSurfaceMemSet | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane, | ||
uint8_t | value | ||
) |
Fill each byte of buffer(s) in NvBufSurface with provided value.
This function can also be used to reset the buffer(s) in the batch.
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
[in] | plane | index of plane in buffer. -1 for all planes in buffer. |
[in] | value | value to be set. |
int NvBufSurfaceSyncForCpu | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Syncs the HW memory cache for the CPU.
Valid only for NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE memory types.
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
[in] | plane | index of plane in buffer. -1 for all planes in buffer. |
int NvBufSurfaceSyncForDevice | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Syncs the HW memory cache for the device.
Valid only for NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE memory types.
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
[in] | plane | index of plane in buffer. -1 for all planes in buffer. |
int NvBufSurfaceUnMap | ( | NvBufSurface * | surf, |
int | index, | ||
int | plane | ||
) |
Unmap the previously mapped buffer(s).
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |
[in] | plane | index of plane in buffer. -1 for all planes in buffer. |
int NvBufSurfaceUnMapEglImage | ( | NvBufSurface * | surf, |
int | index | ||
) |
Destroy the previously created EGLImage(s).
[in] | surf | pointer to NvBufSurface structure. |
[in] | index | index of buffer in the batch. -1 for all buffers in batch. |