NVIDIA DeepStream SDK API Reference

5.0 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvbufsurface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, 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 
21 #ifndef NVBUFSURFACE_H_
22 #define NVBUFSURFACE_H_
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
40 #define STRUCTURE_PADDING 4
41 
43 #define NVBUF_MAX_PLANES 4
44 
48 typedef enum
49 {
56 
60 typedef enum
61 {
146 
149 
153 typedef enum
154 {
160 
164 typedef enum
165 {
183 
188 {
190  uint32_t num_planes;
203 
206 
210 typedef struct NvBufSurfaceCreateParams {
212  uint32_t gpuId;
214  uint32_t width;
216  uint32_t height;
219  uint32_t size;
231 
235 typedef struct NvBufSurfaceMappedAddr {
239  void *eglImage;
240 
243 
247 typedef struct NvBufSurfaceParams {
249  uint32_t width;
251  uint32_t height;
253  uint32_t pitch;
260  uint64_t bufferDesc;
262  uint32_t dataSize;
265  void * dataPtr;
271 
274 
278 typedef struct NvBufSurface {
280  uint32_t gpuId;
282  uint32_t batchSize;
285  uint32_t numFilled;
293 
295 } NvBufSurface;
296 
316 int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
317  NvBufSurfaceCreateParams *params);
318 
327 
367 int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
368 
380 int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
381 
398 int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
399 
414 int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
415 
430 int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
431 
440 int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
441 
457 int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
458 
485 int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
486 
496 int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
497 
500 #ifdef __cplusplus
501 }
502 #endif
503 #endif /* NVBUFSURFACE_H_ */
Specifies ABGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:107
Specifies BT.709 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:125
Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:141
Specifies BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:121
uint32_t size
Holds the amount of memory to be allocated.
Definition: nvbufsurface.h:219
Specifies the default memory type, i.e.
Definition: nvbufsurface.h:169
NvBufSurfaceLayout layout
Holds BL or PL.
Definition: nvbufsurface.h:257
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:93
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:294
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:272
Specifies pitch layout.
Definition: nvbufsurface.h:156
uint32_t pitch[NVBUF_MAX_PLANES]
Holds the pitches of planes in bytes.
Definition: nvbufsurface.h:196
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:95
Specifies NvBufSurface mapping type "read/write.".
Definition: nvbufsurface.h:53
Specifies CUDA Unified memory type.
Definition: nvbufsurface.h:175
void * dataPtr
Holds a pointer to allocated memory.
Definition: nvbufsurface.h:265
Specifies an invalid color format.
Definition: nvbufsurface.h:63
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:67
Specifies BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:133
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:255
int NvBufSurfaceUnMapEglImage(NvBufSurface *surf, int index)
Destroys the previously created EGLImage object(s).
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.
uint32_t num_planes
Holds the number of planes.
Definition: nvbufsurface.h:190
Specifies color format for packed 2 signed shorts.
Definition: nvbufsurface.h:145
Specifies BT.601 colorspace - YUV444 multi-planar.
Definition: nvbufsurface.h:99
uint32_t bytesPerPix[NVBUF_MAX_PLANES]
Holds the number of bytes occupied by a pixel in each plane.
Definition: nvbufsurface.h:202
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:87
Specifies CUDA Host memory type.
Definition: nvbufsurface.h:171
Holds information about a single buffer in a batch.
Definition: nvbufsurface.h:247
#define NVBUF_MAX_PLANES
Defines the maximum number of planes.
Definition: nvbufsurface.h:43
Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:131
bool isContiguous
Holds a "contiguous memory" flag.
Definition: nvbufsurface.h:222
NvBufSurfaceLayout
Specifies layout formats for NvBufSurface video planes.
Definition: nvbufsurface.h:153
int NvBufSurfaceMapEglImage(NvBufSurface *surf, int index)
Creates an EGLImage from the memory of one or more NvBufSurface buffers.
int NvBufSurfaceMap(NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
Maps hardware batched buffers to the HOST or CPU address space.
Specifies BT.601 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:71
void * addr[NVBUF_MAX_PLANES]
Holds planewise pointers to a CPU mapped buffer.
Definition: nvbufsurface.h:237
NvBufSurfaceMappedAddr mappedAddr
Holds pointers to mapped buffers.
Definition: nvbufsurface.h:270
Specifies BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:143
Specifies BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:139
Specifies RGBx-8-8-8-8 single plane.
Definition: nvbufsurface.h:109
Specifies memory allocated by malloc().
Definition: nvbufsurface.h:181
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:69
int NvBufSurfaceFromFd(int dmabuf_fd, void **buffer)
Gets the NvBufSurface from the DMABUF FD.
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:81
uint32_t numFilled
Holds the number valid and filled buffers.
Definition: nvbufsurface.h:285
Specifies NVRM Handle type.
Definition: nvbufsurface.h:179
Specifies BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
Definition: nvbufsurface.h:123
Specifies RGBA-8-8-8-8 single plane.
Definition: nvbufsurface.h:101
uint32_t pitch
Holds the pitch of the buffer.
Definition: nvbufsurface.h:253
uint32_t psize[NVBUF_MAX_PLANES]
Holds the sizes of planes in bytes.
Definition: nvbufsurface.h:200
NvBufSurfaceParams * surfaceList
Holds a pointer to an array of batched buffers.
Definition: nvbufsurface.h:292
uint32_t batchSize
Holds the batch size.
Definition: nvbufsurface.h:282
Specifies ARGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:105
int NvBufSurfaceDestroy(NvBufSurface *surf)
Frees batched buffers previously allocated by NvBufSurfaceCreate().
Holds parameters required to allocate an NvBufSurface.
Definition: nvbufsurface.h:210
struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams
Holds the planewise parameters of a buffer.
int NvBufSurfaceCopy(NvBufSurface *srcSurf, NvBufSurface *dstSurf)
Copies the content of source batched buffer(s) to destination batched buffer(s).
NvBufSurfaceMemType memType
Holds type of memory for buffers in the batch.
Definition: nvbufsurface.h:290
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:85
Specifies BT.709 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:127
NvBufSurfaceMemType
Specifies memory types for NvBufSurface.
Definition: nvbufsurface.h:164
NvBufSurfacePlaneParams planeParams
Holds planewise information (width, height, pitch, offset, etc.).
Definition: nvbufsurface.h:267
int NvBufSurfaceUnMap(NvBufSurface *surf, int index, int plane)
Unmaps previously mapped buffer(s).
Holds the planewise parameters of a buffer.
Definition: nvbufsurface.h:187
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:249
Specifies CUDA Device memory type.
Definition: nvbufsurface.h:173
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:251
Specifies BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:135
uint64_t bufferDesc
Holds a DMABUF FD.
Definition: nvbufsurface.h:260
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:216
Holds information about batched buffers.
Definition: nvbufsurface.h:278
Specifies NVRM Surface Array type.
Definition: nvbufsurface.h:177
uint32_t offset[NVBUF_MAX_PLANES]
Holds the offsets of planes in bytes.
Definition: nvbufsurface.h:198
#define STRUCTURE_PADDING
Defines the default padding length for reserved fields of structures.
Definition: nvbufsurface.h:40
uint32_t width[NVBUF_MAX_PLANES]
Holds the widths of planes.
Definition: nvbufsurface.h:192
uint32_t gpuId
Holds the GPU ID.
Definition: nvbufsurface.h:212
uint32_t gpuId
Holds a GPU ID.
Definition: nvbufsurface.h:280
Specifies RGB-8-8-8 single plane.
Definition: nvbufsurface.h:117
Specifies xBGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:115
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:89
struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr
Holds pointers for a mapped buffer.
NvBufSurfaceMemType memType
Holds the type of memory to be allocated.
Definition: nvbufsurface.h:229
uint32_t height[NVBUF_MAX_PLANES]
Holds the heights of planes.
Definition: nvbufsurface.h:194
int NvBufSurfaceSyncForCpu(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the CPU.
struct NvBufSurfaceParams NvBufSurfaceParams
Holds information about a single buffer in a batch.
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:83
Specifies BGRx-8-8-8-8 single plane.
Definition: nvbufsurface.h:111
Specifies BGRA-8-8-8-8 single plane.
Definition: nvbufsurface.h:103
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:241
Specifies NvBufSurface mapping type "read.".
Definition: nvbufsurface.h:50
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:214
NvBufSurfaceLayout layout
Holds the surface layout.
Definition: nvbufsurface.h:227
bool isContiguous
Holds an "is contiguous" flag.
Definition: nvbufsurface.h:288
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:75
Specifies NvBufSurface mapping type "write.".
Definition: nvbufsurface.h:51
void * eglImage
Holds a pointer to a mapped EGLImage.
Definition: nvbufsurface.h:239
Specifies BGR-8-8-8 single plane.
Definition: nvbufsurface.h:119
struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams
Holds parameters required to allocate an NvBufSurface.
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:224
Specifies 8 bit GRAY scale - single plane.
Definition: nvbufsurface.h:65
Specifies BT.601 colorspace - YVU420 ER multi-planar.
Definition: nvbufsurface.h:73
NvBufSurfaceMemMapFlags
Specifies mapping types for NvBufSurface.
Definition: nvbufsurface.h:48
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:91
Specifies block linear layout.
Definition: nvbufsurface.h:158
NvBufSurfaceColorFormat
Specifies color formats for NvBufSurface.
Definition: nvbufsurface.h:60
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:79
Holds pointers for a mapped buffer.
Definition: nvbufsurface.h:235
uint32_t dataSize
Holds the amount of allocated memory.
Definition: nvbufsurface.h:262
struct NvBufSurface NvBufSurface
Holds information about batched buffers.
int NvBufSurfaceCreate(NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceCreateParams *params)
Allocates a batch of buffers.
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:77
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:97
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:137
Specifies BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:129
void * _reserved[STRUCTURE_PADDING *NVBUF_MAX_PLANES]
Definition: nvbufsurface.h:204
Specifies xRGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:113
int NvBufSurfaceSyncForDevice(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the device.