NVIDIA DeepStream SDK API Reference

6.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvbufsurface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA Corporation and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA Corporation is strictly prohibited.
9  */
10 
28 #ifndef NVBUFSURFACE_H_
29 #define NVBUFSURFACE_H_
30 
31 #include <stdint.h>
32 #include <stdbool.h>
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
46 #define STRUCTURE_PADDING 4
47 
49 #define NVBUF_MAX_PLANES 4
50 
54 typedef enum
55 {
62 
66 typedef enum
67 {
162 
165 
169 typedef enum
170 {
176 
180 typedef enum
181 {
199 
204 {
206  uint32_t num_planes;
219 
222 
226 typedef struct NvBufSurfaceCreateParams {
228  uint32_t gpuId;
230  uint32_t width;
232  uint32_t height;
235  uint32_t size;
247 
251 typedef struct NvBufSurfaceMappedAddr {
255  void *eglImage;
256 
259 
263 typedef struct NvBufSurfaceParams {
265  uint32_t width;
267  uint32_t height;
269  uint32_t pitch;
276  uint64_t bufferDesc;
278  uint32_t dataSize;
281  void * dataPtr;
287 
290 
294 typedef struct NvBufSurface {
296  uint32_t gpuId;
298  uint32_t batchSize;
301  uint32_t numFilled;
309 
311 } NvBufSurface;
312 
332 int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
333  NvBufSurfaceCreateParams *params);
334 
343 
383 int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
384 
396 int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
397 
414 int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
415 
430 int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
431 
446 int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
447 
456 int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
457 
473 int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
474 
501 int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
502 
512 int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
513 
516 #ifdef __cplusplus
517 }
518 #endif
519 #endif /* NVBUFSURFACE_H_ */
Specifies BT.601 colorspace - YUV444 multi-planar.
Definition: nvbufsurface.h:105
Specifies CUDA Device memory type.
Definition: nvbufsurface.h:189
NvBufSurfaceColorFormat
Specifies color formats for NvBufSurface.
Definition: nvbufsurface.h:66
struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams
Holds parameters required to allocate an NvBufSurface.
Specifies color format for packed 2 signed shorts.
Definition: nvbufsurface.h:151
uint32_t size
Holds the amount of memory to be allocated.
Definition: nvbufsurface.h:235
NvBufSurfaceLayout layout
Holds BL or PL.
Definition: nvbufsurface.h:273
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:91
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:310
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:288
Specifies BT.601 colorspace - YVU420 ER multi-planar.
Definition: nvbufsurface.h:79
#define NVBUF_MAX_PLANES
Defines the maximum number of planes.
Definition: nvbufsurface.h:49
uint32_t pitch[NVBUF_MAX_PLANES]
Holds the pitches of planes in bytes.
Definition: nvbufsurface.h:212
int NvBufSurfaceUnMapEglImage(NvBufSurface *surf, int index)
Destroys the previously created EGLImage object(s).
int NvBufSurfaceDestroy(NvBufSurface *surf)
Frees batched buffers previously allocated by NvBufSurfaceCreate().
Specifies BT.601 colorspace - YUV422 multi-planar.
Definition: nvbufsurface.h:161
void * dataPtr
Holds a pointer to allocated memory.
Definition: nvbufsurface.h:281
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:271
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:83
struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr
Holds pointers for a mapped buffer.
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:103
Specifies block linear layout.
Definition: nvbufsurface.h:174
int NvBufSurfaceSyncForDevice(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the device.
Specifies NVRM Surface Array type.
Definition: nvbufsurface.h:193
uint32_t num_planes
Holds the number of planes.
Definition: nvbufsurface.h:206
Specifies an invalid color format.
Definition: nvbufsurface.h:69
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:87
uint32_t bytesPerPix[NVBUF_MAX_PLANES]
Holds the number of bytes occupied by a pixel in each plane.
Definition: nvbufsurface.h:218
Specifies RGB-8-8-8 single plane.
Definition: nvbufsurface.h:123
Specifies RGBA-8-8-8-8 single plane.
Definition: nvbufsurface.h:107
Specifies RGB- unsigned 8 bit multiplanar plane.
Definition: nvbufsurface.h:153
Holds information about a single buffer in a batch.
Definition: nvbufsurface.h:263
Specifies NvBufSurface mapping type "write.".
Definition: nvbufsurface.h:57
Specifies ABGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:113
struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams
Holds the planewise parameters of a buffer.
Specifies NvBufSurface mapping type "read.".
Definition: nvbufsurface.h:56
bool isContiguous
Holds a "contiguous memory" flag.
Definition: nvbufsurface.h:238
Specifies BGR-8-8-8 single plane.
Definition: nvbufsurface.h:125
Specifies BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:149
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:89
Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:137
Specifies BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:127
void * addr[NVBUF_MAX_PLANES]
Holds planewise pointers to a CPU mapped buffer.
Definition: nvbufsurface.h:253
NvBufSurfaceMappedAddr mappedAddr
Holds pointers to mapped buffers.
Definition: nvbufsurface.h:286
Specifies BGRA-8-8-8-8 single plane.
Definition: nvbufsurface.h:109
Specifies CUDA Host memory type.
Definition: nvbufsurface.h:187
Specifies RGBx-8-8-8-8 single plane.
Definition: nvbufsurface.h:115
uint32_t numFilled
Holds the number valid and filled buffers.
Definition: nvbufsurface.h:301
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:81
Specifies memory allocated by malloc().
Definition: nvbufsurface.h:197
int NvBufSurfaceFromFd(int dmabuf_fd, void **buffer)
Gets the NvBufSurface from the DMABUF FD.
int NvBufSurfaceCopy(NvBufSurface *srcSurf, NvBufSurface *dstSurf)
Copies the content of source batched buffer(s) to destination batched buffer(s).
Specifies BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:139
uint32_t pitch
Holds the pitch of the buffer.
Definition: nvbufsurface.h:269
uint32_t psize[NVBUF_MAX_PLANES]
Holds the sizes of planes in bytes.
Definition: nvbufsurface.h:216
NvBufSurfaceParams * surfaceList
Holds a pointer to an array of batched buffers.
Definition: nvbufsurface.h:308
uint32_t batchSize
Holds the batch size.
Definition: nvbufsurface.h:298
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:73
int NvBufSurfaceSyncForCpu(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the CPU.
Holds parameters required to allocate an NvBufSurface.
Definition: nvbufsurface.h:226
Specifies BGR- unsigned 8 bit multiplanar plane.
Definition: nvbufsurface.h:155
Specifies CUDA Unified memory type.
Definition: nvbufsurface.h:191
Specifies BT.601 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:77
Specifies 8 bit GRAY scale - single plane.
Definition: nvbufsurface.h:71
NvBufSurfaceMemType memType
Holds type of memory for buffers in the batch.
Definition: nvbufsurface.h:306
struct NvBufSurface NvBufSurface
Holds information about batched buffers.
#define STRUCTURE_PADDING
Defines the default padding length for reserved fields of structures.
Definition: nvbufsurface.h:46
NvBufSurfacePlaneParams planeParams
Holds planewise information (width, height, pitch, offset, etc.).
Definition: nvbufsurface.h:283
Holds the planewise parameters of a buffer.
Definition: nvbufsurface.h:203
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:265
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:93
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:267
Specifies BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
Definition: nvbufsurface.h:129
uint64_t bufferDesc
Holds a DMABUF FD.
Definition: nvbufsurface.h:276
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:232
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:95
Specifies ARGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:111
Holds information about batched buffers.
Definition: nvbufsurface.h:294
uint32_t offset[NVBUF_MAX_PLANES]
Holds the offsets of planes in bytes.
Definition: nvbufsurface.h:214
NvBufSurfaceMemType
Specifies memory types for NvBufSurface.
Definition: nvbufsurface.h:180
Specifies BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:135
uint32_t width[NVBUF_MAX_PLANES]
Holds the widths of planes.
Definition: nvbufsurface.h:208
Specifies the default memory type, i.e.
Definition: nvbufsurface.h:185
uint32_t gpuId
Holds the GPU ID.
Definition: nvbufsurface.h:228
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:99
int NvBufSurfaceUnMap(NvBufSurface *surf, int index, int plane)
Unmaps previously mapped buffer(s).
uint32_t gpuId
Holds a GPU ID.
Definition: nvbufsurface.h:296
struct NvBufSurfaceParams NvBufSurfaceParams
Holds information about a single buffer in a batch.
Specifies BGRx-8-8-8-8 single plane.
Definition: nvbufsurface.h:117
Specifies BT.709 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:131
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:75
NvBufSurfaceMemType memType
Holds the type of memory to be allocated.
Definition: nvbufsurface.h:245
Specifies NVRM Handle type.
Definition: nvbufsurface.h:195
uint32_t height[NVBUF_MAX_PLANES]
Holds the heights of planes.
Definition: nvbufsurface.h:210
Specifies pitch layout.
Definition: nvbufsurface.h:172
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:97
int NvBufSurfaceCreate(NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceCreateParams *params)
Allocates a batch of buffers.
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:101
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:257
NvBufSurfaceLayout
Specifies layout formats for NvBufSurface video planes.
Definition: nvbufsurface.h:169
Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:147
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:230
NvBufSurfaceLayout layout
Holds the surface layout.
Definition: nvbufsurface.h:243
bool isContiguous
Holds an "is contiguous" flag.
Definition: nvbufsurface.h:304
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:85
Specifies xBGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:121
Specifies RGB-32bit Floating point multiplanar plane.
Definition: nvbufsurface.h:157
Specifies NvBufSurface mapping type "read/write.".
Definition: nvbufsurface.h:59
NvBufSurfaceMemMapFlags
Specifies mapping types for NvBufSurface.
Definition: nvbufsurface.h:54
void * eglImage
Holds a pointer to a mapped EGLImage.
Definition: nvbufsurface.h:255
Specifies BT.709 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:133
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:143
Specifies BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:141
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:240
int NvBufSurfaceMap(NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
Maps hardware batched buffers to the HOST or CPU address space.
Specifies BGR-32bit Floating point multiplanar plane.
Definition: nvbufsurface.h:159
Specifies xRGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:119
Holds pointers for a mapped buffer.
Definition: nvbufsurface.h:251
uint32_t dataSize
Holds the amount of allocated memory.
Definition: nvbufsurface.h:278
Specifies BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:145
int NvBufSurfaceMapEglImage(NvBufSurface *surf, int index)
Creates an EGLImage from the memory of one or more NvBufSurface buffers.
void * _reserved[STRUCTURE_PADDING *NVBUF_MAX_PLANES]
Definition: nvbufsurface.h:220
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.