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 
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 {
152 
155 
159 typedef enum
160 {
166 
170 typedef enum
171 {
189 
194 {
196  uint32_t num_planes;
209 
212 
216 typedef struct NvBufSurfaceCreateParams {
218  uint32_t gpuId;
220  uint32_t width;
222  uint32_t height;
225  uint32_t size;
237 
241 typedef struct NvBufSurfaceMappedAddr {
245  void *eglImage;
246 
249 
253 typedef struct NvBufSurfaceParams {
255  uint32_t width;
257  uint32_t height;
259  uint32_t pitch;
266  uint64_t bufferDesc;
268  uint32_t dataSize;
271  void * dataPtr;
277 
280 
284 typedef struct NvBufSurface {
286  uint32_t gpuId;
288  uint32_t batchSize;
291  uint32_t numFilled;
299 
301 } NvBufSurface;
302 
322 int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
323  NvBufSurfaceCreateParams *params);
324 
333 
373 int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
374 
386 int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
387 
404 int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
405 
420 int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
421 
436 int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
437 
446 int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
447 
463 int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
464 
491 int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
492 
502 int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
503 
506 #ifdef __cplusplus
507 }
508 #endif
509 #endif /* NVBUFSURFACE_H_ */
Specifies BT.601 colorspace - YUV444 multi-planar.
Definition: nvbufsurface.h:105
Specifies CUDA Device memory type.
Definition: nvbufsurface.h:179
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:225
NvBufSurfaceLayout layout
Holds BL or PL.
Definition: nvbufsurface.h:263
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:91
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:300
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:278
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:202
int NvBufSurfaceUnMapEglImage(NvBufSurface *surf, int index)
Destroys the previously created EGLImage object(s).
int NvBufSurfaceDestroy(NvBufSurface *surf)
Frees batched buffers previously allocated by NvBufSurfaceCreate().
void * dataPtr
Holds a pointer to allocated memory.
Definition: nvbufsurface.h:271
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:261
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:164
int NvBufSurfaceSyncForDevice(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the device.
Specifies NVRM Surface Array type.
Definition: nvbufsurface.h:183
uint32_t num_planes
Holds the number of planes.
Definition: nvbufsurface.h:196
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:208
Specifies RGB-8-8-8 single plane.
Definition: nvbufsurface.h:123
Specifies RGBA-8-8-8-8 single plane.
Definition: nvbufsurface.h:107
Holds information about a single buffer in a batch.
Definition: nvbufsurface.h:253
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:228
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:243
NvBufSurfaceMappedAddr mappedAddr
Holds pointers to mapped buffers.
Definition: nvbufsurface.h:276
Specifies BGRA-8-8-8-8 single plane.
Definition: nvbufsurface.h:109
Specifies CUDA Host memory type.
Definition: nvbufsurface.h:177
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:291
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:81
Specifies memory allocated by malloc().
Definition: nvbufsurface.h:187
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:259
uint32_t psize[NVBUF_MAX_PLANES]
Holds the sizes of planes in bytes.
Definition: nvbufsurface.h:206
NvBufSurfaceParams * surfaceList
Holds a pointer to an array of batched buffers.
Definition: nvbufsurface.h:298
uint32_t batchSize
Holds the batch size.
Definition: nvbufsurface.h:288
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:216
Specifies CUDA Unified memory type.
Definition: nvbufsurface.h:181
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:296
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:273
Holds the planewise parameters of a buffer.
Definition: nvbufsurface.h:193
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:255
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:257
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:266
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:222
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:284
uint32_t offset[NVBUF_MAX_PLANES]
Holds the offsets of planes in bytes.
Definition: nvbufsurface.h:204
NvBufSurfaceMemType
Specifies memory types for NvBufSurface.
Definition: nvbufsurface.h:170
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:198
Specifies the default memory type, i.e.
Definition: nvbufsurface.h:175
uint32_t gpuId
Holds the GPU ID.
Definition: nvbufsurface.h:218
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:286
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:235
Specifies NVRM Handle type.
Definition: nvbufsurface.h:185
uint32_t height[NVBUF_MAX_PLANES]
Holds the heights of planes.
Definition: nvbufsurface.h:200
Specifies pitch layout.
Definition: nvbufsurface.h:162
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:247
NvBufSurfaceLayout
Specifies layout formats for NvBufSurface video planes.
Definition: nvbufsurface.h:159
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:220
NvBufSurfaceLayout layout
Holds the surface layout.
Definition: nvbufsurface.h:233
bool isContiguous
Holds an "is contiguous" flag.
Definition: nvbufsurface.h:294
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 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:245
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:230
int NvBufSurfaceMap(NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
Maps hardware batched buffers to the HOST or CPU address space.
Specifies xRGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:119
Holds pointers for a mapped buffer.
Definition: nvbufsurface.h:241
uint32_t dataSize
Holds the amount of allocated memory.
Definition: nvbufsurface.h:268
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:210
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.