NVIDIA DeepStream SDK API Reference

6.4 Release
NvBufSurface Types and Functions

Detailed Description

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...
 

Enumerations

enum  NvBufSurfaceMemMapFlags {
  NVBUF_MAP_READ,
  NVBUF_MAP_WRITE,
  NVBUF_MAP_READ_WRITE
}
 Defines mapping types of NvBufSurface. More...
 
enum  NvBufSurfaceTag {
  NvBufSurfaceTag_NONE = 0x0,
  NvBufSurfaceTag_CAMERA = 0x200,
  NvBufSurfaceTag_JPEG = 0x1500,
  NvBufSurfaceTag_PROTECTED = 0x1504,
  NvBufSurfaceTag_VIDEO_ENC = 0x1200,
  NvBufSurfaceTag_VIDEO_DEC = 0x1400,
  NvBufSurfaceTag_VIDEO_CONVERT = 0xf01
}
 Defines tags that identify the components requesting a memory allocation. More...
 
enum  NvBufSurfaceColorFormat {
  NVBUF_COLOR_FORMAT_INVALID,
  NVBUF_COLOR_FORMAT_GRAY8,
  NVBUF_COLOR_FORMAT_YUV420,
  NVBUF_COLOR_FORMAT_YVU420,
  NVBUF_COLOR_FORMAT_YUV420_ER,
  NVBUF_COLOR_FORMAT_YVU420_ER,
  NVBUF_COLOR_FORMAT_NV12,
  NVBUF_COLOR_FORMAT_NV12_ER,
  NVBUF_COLOR_FORMAT_NV21,
  NVBUF_COLOR_FORMAT_NV21_ER,
  NVBUF_COLOR_FORMAT_UYVY,
  NVBUF_COLOR_FORMAT_UYVY_ER,
  NVBUF_COLOR_FORMAT_VYUY,
  NVBUF_COLOR_FORMAT_VYUY_ER,
  NVBUF_COLOR_FORMAT_YUYV,
  NVBUF_COLOR_FORMAT_YUYV_ER,
  NVBUF_COLOR_FORMAT_YVYU,
  NVBUF_COLOR_FORMAT_YVYU_ER,
  NVBUF_COLOR_FORMAT_YUV444,
  NVBUF_COLOR_FORMAT_RGBA,
  NVBUF_COLOR_FORMAT_BGRA,
  NVBUF_COLOR_FORMAT_ARGB,
  NVBUF_COLOR_FORMAT_ABGR,
  NVBUF_COLOR_FORMAT_RGBx,
  NVBUF_COLOR_FORMAT_BGRx,
  NVBUF_COLOR_FORMAT_xRGB,
  NVBUF_COLOR_FORMAT_xBGR,
  NVBUF_COLOR_FORMAT_RGB,
  NVBUF_COLOR_FORMAT_BGR,
  NVBUF_COLOR_FORMAT_NV12_10LE,
  NVBUF_COLOR_FORMAT_NV12_12LE,
  NVBUF_COLOR_FORMAT_YUV420_709,
  NVBUF_COLOR_FORMAT_YUV420_709_ER,
  NVBUF_COLOR_FORMAT_NV12_709,
  NVBUF_COLOR_FORMAT_NV12_709_ER,
  NVBUF_COLOR_FORMAT_YUV420_2020,
  NVBUF_COLOR_FORMAT_NV12_2020,
  NVBUF_COLOR_FORMAT_NV12_10LE_ER,
  NVBUF_COLOR_FORMAT_NV12_10LE_709,
  NVBUF_COLOR_FORMAT_NV12_10LE_709_ER,
  NVBUF_COLOR_FORMAT_NV12_10LE_2020,
  NVBUF_COLOR_FORMAT_SIGNED_R16G16,
  NVBUF_COLOR_FORMAT_R8_G8_B8,
  NVBUF_COLOR_FORMAT_B8_G8_R8,
  NVBUF_COLOR_FORMAT_R32F_G32F_B32F,
  NVBUF_COLOR_FORMAT_B32F_G32F_R32F,
  NVBUF_COLOR_FORMAT_YUV422,
  NVBUF_COLOR_FORMAT_NV21_10LE,
  NVBUF_COLOR_FORMAT_NV21_12LE,
  NVBUF_COLOR_FORMAT_NV12_12LE_2020,
  NVBUF_COLOR_FORMAT_NV16,
  NVBUF_COLOR_FORMAT_NV16_10LE,
  NVBUF_COLOR_FORMAT_NV24,
  NVBUF_COLOR_FORMAT_NV24_10LE,
  NVBUF_COLOR_FORMAT_NV16_ER,
  NVBUF_COLOR_FORMAT_NV24_ER,
  NVBUF_COLOR_FORMAT_NV16_709,
  NVBUF_COLOR_FORMAT_NV24_709,
  NVBUF_COLOR_FORMAT_NV16_709_ER,
  NVBUF_COLOR_FORMAT_NV24_709_ER,
  NVBUF_COLOR_FORMAT_NV24_10LE_709,
  NVBUF_COLOR_FORMAT_NV24_10LE_709_ER,
  NVBUF_COLOR_FORMAT_NV24_10LE_2020,
  NVBUF_COLOR_FORMAT_NV24_12LE_2020,
  NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_709,
  NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_2020,
  NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_709,
  NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_2020,
  NVBUF_COLOR_FORMAT_A32,
  NVBUF_COLOR_FORMAT_UYVP,
  NVBUF_COLOR_FORMAT_UYVP_ER,
  NVBUF_COLOR_FORMAT_YUV444_ER,
  NVBUF_COLOR_FORMAT_YUV444_709,
  NVBUF_COLOR_FORMAT_YUV444_709_ER,
  NVBUF_COLOR_FORMAT_YUV444_2020,
  NVBUF_COLOR_FORMAT_YUV444_10LE,
  NVBUF_COLOR_FORMAT_YUV444_10LE_ER,
  NVBUF_COLOR_FORMAT_YUV444_10LE_709,
  NVBUF_COLOR_FORMAT_YUV444_10LE_709_ER,
  NVBUF_COLOR_FORMAT_YUV444_10LE_2020,
  NVBUF_COLOR_FORMAT_YUV444_12LE,
  NVBUF_COLOR_FORMAT_YUV444_12LE_ER,
  NVBUF_COLOR_FORMAT_YUV444_12LE_709,
  NVBUF_COLOR_FORMAT_YUV444_12LE_709_ER,
  NVBUF_COLOR_FORMAT_YUV444_12LE_2020,
  NVBUF_COLOR_FORMAT_NV12_12LE_ER,
  NVBUF_COLOR_FORMAT_NV12_12LE_709,
  NVBUF_COLOR_FORMAT_NV12_12LE_709_ER,
  NVBUF_COLOR_FORMAT_GRAY8_ER,
  NVBUF_COLOR_FORMAT_LAST
}
 Defines color formats for NvBufSurface. More...
 
enum  NvBufSurfaceLayout {
  NVBUF_LAYOUT_PITCH,
  NVBUF_LAYOUT_BLOCK_LINEAR
}
 Specifies layout formats for NvBufSurface video planes. More...
 
enum  NvBufSurfaceMemType {
  NVBUF_MEM_DEFAULT,
  NVBUF_MEM_CUDA_PINNED,
  NVBUF_MEM_CUDA_DEVICE,
  NVBUF_MEM_CUDA_UNIFIED,
  NVBUF_MEM_SURFACE_ARRAY,
  NVBUF_MEM_HANDLE,
  NVBUF_MEM_SYSTEM
}
 Specifies memory types for NvBufSurface. More...
 
enum  NvBufSurfaceDisplayScanFormat {
  NVBUF_DISPLAYSCANFORMAT_PROGRESSIVE,
  NVBUF_DISPLAYSCANFORMAT_INTERLACED
}
 Defines display scan formats for NvBufSurface video planes. 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...
 

Macro Definition Documentation

◆ NVBUF_MAX_PLANES

#define NVBUF_MAX_PLANES   4

Defines the maximum number of planes.

Definition at line 49 of file nvbufsurface.h.

◆ NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT

#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.

◆ NVBUFSURFACE_CHROMA_SUBSAMPLING_PARAMS_DEFAULT

#define NVBUFSURFACE_CHROMA_SUBSAMPLING_PARAMS_DEFAULT
Value:
{ \
NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT, \
NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT \
}

Definition at line 58 of file nvbufsurface.h.

◆ NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT

#define NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT   1

Definition at line 56 of file nvbufsurface.h.

◆ STRUCTURE_PADDING

#define STRUCTURE_PADDING   4

Defines the default padding length for reserved fields of structures.

Definition at line 46 of file nvbufsurface.h.

Typedef Documentation

◆ NvBufSurface

typedef struct NvBufSurface NvBufSurface

Holds information about batched buffers.

◆ NvBufSurfaceAllocateParams

Hold extended parameters required to allocate NvBufSurface.

(Applicable for NvBufSurfaceAllocate API)

◆ NvBufSurfaceChromaSubsamplingParams

Holds Chroma Subsampling parameters for NvBufSurface allocation.

◆ NvBufSurfaceCreateParams

Holds parameters required to allocate an NvBufSurface.

◆ NvBufSurfaceMapParams

Holds buffer parameters to map the buffer received from another process.

◆ NvBufSurfaceMappedAddr

Hold the pointers of mapped buffer.

◆ NvBufSurfaceMapPlaneParams

Holds plane parameters to map the buffer received from another process.

◆ NvBufSurfaceParams

Hold the information of single buffer in the batch.

◆ NvBufSurfaceParamsEx

Hold the information(extended) of single buffer in the batch.

◆ NvBufSurfacePlaneParams

Holds plane wise parameters of a buffer.

◆ NvBufSurfacePlaneParamsEx

Holds plane wise parameters(extended) of a buffer.

Enumeration Type Documentation

◆ NvBufSurfaceColorFormat

Defines color formats for NvBufSurface.

Enumerator
NVBUF_COLOR_FORMAT_INVALID 

Specifies an invalid color format.

NVBUF_COLOR_FORMAT_GRAY8 

Specifies 8 bit GRAY scale - single plane.

NVBUF_COLOR_FORMAT_YUV420 

Specifies BT.601 colorspace - YUV420 multi-planar.

NVBUF_COLOR_FORMAT_YVU420 

Specifies BT.601 colorspace - YUV420 multi-planar.

NVBUF_COLOR_FORMAT_YUV420_ER 

Specifies BT.601 colorspace - YUV420 ER multi-planar.

NVBUF_COLOR_FORMAT_YVU420_ER 

Specifies BT.601 colorspace - YVU420 ER multi-planar.

NVBUF_COLOR_FORMAT_NV12 

Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_NV12_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_NV21 

Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_NV21_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_UYVY 

Specifies BT.601 colorspace - YUV 4:2:2 planar.

NVBUF_COLOR_FORMAT_UYVY_ER 

Specifies BT.601 colorspace - YUV ER 4:2:2 planar.

NVBUF_COLOR_FORMAT_VYUY 

Specifies BT.601 colorspace - YUV 4:2:2 planar.

NVBUF_COLOR_FORMAT_VYUY_ER 

Specifies BT.601 colorspace - YUV ER 4:2:2 planar.

NVBUF_COLOR_FORMAT_YUYV 

Specifies BT.601 colorspace - YUV 4:2:2 planar.

NVBUF_COLOR_FORMAT_YUYV_ER 

Specifies BT.601 colorspace - YUV ER 4:2:2 planar.

NVBUF_COLOR_FORMAT_YVYU 

Specifies BT.601 colorspace - YUV 4:2:2 planar.

NVBUF_COLOR_FORMAT_YVYU_ER 

Specifies BT.601 colorspace - YUV ER 4:2:2 planar.

NVBUF_COLOR_FORMAT_YUV444 

Specifies BT.601 colorspace - YUV444 multi-planar.

NVBUF_COLOR_FORMAT_RGBA 

Specifies RGBA-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_BGRA 

Specifies BGRA-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_ARGB 

Specifies ARGB-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_ABGR 

Specifies ABGR-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_RGBx 

Specifies RGBx-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_BGRx 

Specifies BGRx-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_xRGB 

Specifies xRGB-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_xBGR 

Specifies xBGR-8-8-8-8 single plane.

NVBUF_COLOR_FORMAT_RGB 

Specifies RGB-8-8-8 single plane.

NVBUF_COLOR_FORMAT_BGR 

Specifies BGR-8-8-8 single plane.

NVBUF_COLOR_FORMAT_NV12_10LE 

Specifies BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_12LE 

Specifies BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV420_709 

Specifies BT.709 colorspace - YUV420 multi-planar.

NVBUF_COLOR_FORMAT_YUV420_709_ER 

Specifies BT.709 colorspace - YUV420 ER multi-planar.

NVBUF_COLOR_FORMAT_NV12_709 

Specifies BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_NV12_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_YUV420_2020 

Specifies BT.2020 colorspace - YUV420 multi-planar.

NVBUF_COLOR_FORMAT_NV12_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.

NVBUF_COLOR_FORMAT_NV12_10LE_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_10LE_709 

Specifies BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_10LE_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_10LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_SIGNED_R16G16 

Specifies color format for packed 2 signed shorts

NVBUF_COLOR_FORMAT_R8_G8_B8 

Specifies RGB- unsigned 8 bit multiplanar plane.

NVBUF_COLOR_FORMAT_B8_G8_R8 

Specifies BGR- unsigned 8 bit multiplanar plane.

NVBUF_COLOR_FORMAT_R32F_G32F_B32F 

Specifies RGB-32bit Floating point multiplanar plane.

NVBUF_COLOR_FORMAT_B32F_G32F_R32F 

Specifies BGR-32bit Floating point multiplanar plane.

NVBUF_COLOR_FORMAT_YUV422 

Specifies BT.601 colorspace - YUV422 multi-planar.

NVBUF_COLOR_FORMAT_NV21_10LE 

Specifies BT.601 colorspace - Y/CrCb 4:2:0 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV21_12LE 

Specifies BT.601 colorspace - Y/CrCb 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_12LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_NV16 

Specifies BT.601 colorspace - Y/CbCr 4:2:2 multi-planar.

NVBUF_COLOR_FORMAT_NV16_10LE 

Specifies BT.601 colorspace - Y/CbCr 4:2:2 10-bit semi-planar.

NVBUF_COLOR_FORMAT_NV24 

Specifies BT.601 colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV24_10LE 

Specifies BT.601 colorspace - Y/CrCb 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_NV16_ER 

Specifies BT.601_ER colorspace - Y/CbCr 4:2:2 multi-planar.

NVBUF_COLOR_FORMAT_NV24_ER 

Specifies BT.601_ER colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV16_709 

Specifies BT.709 colorspace - Y/CbCr 4:2:2 multi-planar.

NVBUF_COLOR_FORMAT_NV24_709 

Specifies BT.709 colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV16_709_ER 

Specifies BT.709_ER colorspace - Y/CbCr 4:2:2 multi-planar.

NVBUF_COLOR_FORMAT_NV24_709_ER 

Specifies BT.709_ER colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV24_10LE_709 

Specifies BT.709 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV24_10LE_709_ER 

Specifies BT.709 ER colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV24_10LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_NV24_12LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 12 bit 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_709 

Specifies Non-linear RGB BT.709 colorspace - RGBA-10-10-10-2 planar.

NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_2020 

Specifies Non-linear RGB BT.2020 colorspace - RGBA-10-10-10-2 planar.

NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_709 

Specifies Non-linear RGB BT.709 colorspace - BGRA-10-10-10-2 planar.

NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_2020 

Specifies Non-linear RGB BT.2020 colorspace - BGRA-10-10-10-2 planar.

NVBUF_COLOR_FORMAT_A32 

Specifies Optical flow SAD calculation Buffer format.

NVBUF_COLOR_FORMAT_UYVP 

Specifies BT.601 colorspace - 10 bit YUV 4:2:2 interleaved.

NVBUF_COLOR_FORMAT_UYVP_ER 

Specifies BT.601 colorspace - 10 bit YUV ER 4:2:2 interleaved.

NVBUF_COLOR_FORMAT_YUV444_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_YUV444_709 

Specifies BT.709 colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_YUV444_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_YUV444_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:4:4 multi-planar.

NVBUF_COLOR_FORMAT_YUV444_10LE 

Specifies BT.601 colorspace - Y/CbCr 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_10LE_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_10LE_709 

Specifies BT.709 colorspace - Y/CbCr 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_10LE_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_10LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:4:4 10-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_12LE 

Specifies BT.601 colorspace - Y/CbCr 4:4:4 12-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_12LE_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:4:4 12-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_12LE_709 

Specifies BT.709 colorspace - Y/CbCr 4:4:4 12-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_12LE_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:4:4 12-bit multi-planar.

NVBUF_COLOR_FORMAT_YUV444_12LE_2020 

Specifies BT.2020 colorspace - Y/CbCr 4:4:4 12-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_12LE_ER 

Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_12LE_709 

Specifies BT.709 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_NV12_12LE_709_ER 

Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 12-bit multi-planar.

NVBUF_COLOR_FORMAT_GRAY8_ER 

Specifies 8 bit GRAY scale ER - single plane.

NVBUF_COLOR_FORMAT_LAST 

Definition at line 103 of file nvbufsurface.h.

◆ NvBufSurfaceDisplayScanFormat

Defines display scan formats for NvBufSurface video planes.

Enumerator
NVBUF_DISPLAYSCANFORMAT_PROGRESSIVE 

Progessive scan formats.

NVBUF_DISPLAYSCANFORMAT_INTERLACED 

Interlaced scan formats.

Definition at line 323 of file nvbufsurface.h.

◆ 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 289 of file nvbufsurface.h.

◆ NvBufSurfaceMemMapFlags

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.

◆ 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 300 of file nvbufsurface.h.

◆ 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.

Enumerator
NvBufSurfaceTag_NONE 

tag None.

NvBufSurfaceTag_CAMERA 

tag for Camera.

NvBufSurfaceTag_JPEG 

tag for Jpeg Encoder/Decoder.

NvBufSurfaceTag_PROTECTED 

tag for VPR Buffers.

NvBufSurfaceTag_VIDEO_ENC 

tag for H264/H265 Video Encoder.

NvBufSurfaceTag_VIDEO_DEC 

tag for H264/H265/VP9 Video Decoder.

NvBufSurfaceTag_VIDEO_CONVERT 

tag for Video Transform/Composite/Blend.

Definition at line 82 of file nvbufsurface.h.

Function Documentation

◆ NvBufSurface2Raw()

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.

Parameters
[in]Surfpointer to NvBufSurface structure.
[in]indexindex of buffer in the batch.
[in]planeindex of plane in buffer.
[in]out_widthaligned width of the raw data plane.
[in]out_heightaligned height of the raw data plane.
[in]ptrpointer to the output raw plane data.
Returns
0 for success, -1 for failure.

◆ NvBufSurfaceAllocate()

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.

Parameters
[out]surfpointer to allocated batched buffers.
[in]batchSizebatch size of buffers.
[in]paramsextpointer to NvBufSurfaceAllocateParams structure.
Returns
0 for success, -1 for failure.

◆ NvBufSurfaceCopy()

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.

Parameters
[in]srcSurfA pointer to the source NvBufSurface structure.
[in]dstSurfA pointer to the destination NvBufSurface structure.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceCreate()

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.

Parameters
[out]surfAn indirect pointer to the allocated batched buffers.
[in]batchSizeBatch size of buffers.
[in]paramsA pointer to an NvBufSurfaceCreateParams structure.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceDestroy()

int NvBufSurfaceDestroy ( NvBufSurface surf)

Free the batched buffers previously allocated through NvBufSurfaceCreate.

Parameters
[in]surfA pointer to an NvBufSurface to be freed.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceFromFd()

int NvBufSurfaceFromFd ( int  dmabuf_fd,
void **  buffer 
)

Gets the NvBufSurface from the DMABUF FD.

Parameters
[in]dmabuf_fdDMABUF FD of the buffer.
[out]bufferA pointer to the NvBufSurface.
Returns
0 for success, or -1 otherwise.

◆ NvBufSurfaceGetMapParams()

int NvBufSurfaceGetMapParams ( const NvBufSurface surf,
int  index,
NvBufSurfaceMapParams params 
)

Get buffer information to map the buffer in another process.

Parameters
[in]surfPointer to NvBufSurface structure.
[in]indexIndex of a buffer in the batch.
[out]paramsPointer to NvBufSurfaceMapParams information of the buffer.
Returns
0 for success, -1 for failure.

◆ NvBufSurfaceImport()

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.

Parameters
[out]out_nvbuf_surfPointer to hardware buffer.
[in]in_paramsParameters to create hardware buffer.
Returns
0 for success, -1 for failure.

◆ NvBufSurfaceMap()

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:

  • CPU: If the CPU modifies mapped memory, the client must call NvBufSurfaceSyncForDevice() before any hardware device accesses the memory.
  • Hardware device: If a hardware device modifies mapped memory, the client must call NvBufSurfaceSyncForCpu() before the CPU accesses the memory.

Use NvBufSurfaceUnMap() to unmap buffer(s) and release any resource.

Parameters
[in,out]surfA pointer to an NvBufSurface structure. The function stores pointers to the buffers in a descendant of this structure; see the notes above.
[in]indexIndex of a buffer in the batch. -1 refers to all buffers in the batch.
[in]planeIndex of a plane in buffer. -1 refers to all planes in the buffer.
[in]typeA flag for mapping type.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceMapEglImage()

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.

Parameters
[in,out]surfA 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]indexIndex of a buffer in the batch. -1 specifies all buffers in the batch.
Returns
0 for success, or -1 otherwise.

◆ NvBufSurfaceMemSet()

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.

Parameters
[in]surfA pointer to the NvBufSurface structure.
[in]indexIndex of a buffer in the batch. -1 refers to all buffers in the batch.
[in]planeIndex of a plane in the buffer. -1 refers to all planes in the buffer.
[in]valueThe value to be used as fill.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceSyncForCpu()

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.

Parameters
[in]surfA pointer to an NvBufSurface structure.
[in]indexIndex of the buffer in the batch. -1 refers to all buffers in the batch.
[in]planeIndex of a plane in the buffer. -1 refers to all planes in the buffer.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceSyncForDevice()

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.

Parameters
[in]surfA pointer to an NvBufSurface structure.
[in]indexIndex of a buffer in the batch. -1 refers to all buffers in the batch.
[in]planeIndex of a plane in the buffer. -1 refers to all planes in the buffer.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceUnMap()

int NvBufSurfaceUnMap ( NvBufSurface surf,
int  index,
int  plane 
)

Unmaps previously mapped buffer(s).

Parameters
[in]surfA pointer to an NvBufSurface structure.
[in]indexIndex of a buffer in the batch. -1 indicates all buffers in the batch.
[in]planeIndex of a plane in the buffer. -1 indicates all planes in the buffer.
Returns
0 if successful, or -1 otherwise.

◆ NvBufSurfaceUnMapEglImage()

int NvBufSurfaceUnMapEglImage ( NvBufSurface surf,
int  index 
)

Destroys the previously created EGLImage object(s).

Parameters
[in]surfA pointer to an NvBufSurface structure.
[in]indexThe index of a buffer in the batch. -1 specifies all buffers in the batch.
Returns
0 if successful, or -1 otherwise.

◆ Raw2NvBufSurface()

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.

Parameters
[in]ptrpointer to the input raw plane data.
[in]indexindex of buffer in the batch.
[in]planeindex of plane in buffer.
[in]in_widthaligned width of the raw data plane.
[in]in_heightaligned height of the raw data plane.
[in]Surfpointer to NvBufSurface structure.
Returns
0 for success, -1 for failure.