NVIDIA DeepStream SDK API Reference

4.0.2 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 {
54 
58 typedef enum
59 {
134 
137 
141 typedef enum
142 {
148 
152 typedef enum
153 {
169 
174 {
176  uint32_t num_planes;
189 
192 
196 typedef struct NvBufSurfaceCreateParams {
198  uint32_t gpuId;
200  uint32_t width;
202  uint32_t height;
205  uint32_t size;
216 
220 typedef struct NvBufSurfaceMappedAddr {
224  void *eglImage;
225 
228 
232 typedef struct NvBufSurfaceParams {
234  uint32_t width;
236  uint32_t height;
238  uint32_t pitch;
246  uint64_t bufferDesc;
248  uint32_t dataSize;
252  void * dataPtr;
257 
260 
264 typedef struct NvBufSurface {
266  uint32_t gpuId;
268  uint32_t batchSize;
270  uint32_t numFilled;
277 
279 } NvBufSurface;
280 
297 int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
298  NvBufSurfaceCreateParams *params);
299 
308 
338 int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
339 
349 int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
350 
366 int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
367 
379 int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
380 
392 int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
393 
402 int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
403 
416 int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
417 
434 int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
435 
444 int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
445 
448 #ifdef __cplusplus
449 }
450 #endif
451 #endif /* NVBUFSURFACE_H_ */
ABGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:105
BT.709 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:123
BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:119
uint32_t size
optional but if set memory of that size will be allocated and all other parameters (width...
Definition: nvbufsurface.h:205
NVBUF_MEM_CUDA_DEVICE type for dGpu and NVBUF_MEM_SURFACE_ARRAY type for Jetson.
Definition: nvbufsurface.h:155
NvBufSurfaceLayout layout
BL or PL for Jetson, ONLY PL in case of dGPU.
Definition: nvbufsurface.h:242
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:91
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:278
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:258
Pitch Layout.
Definition: nvbufsurface.h:144
uint32_t pitch[NVBUF_MAX_PLANES]
pitch of planes in bytes
Definition: nvbufsurface.h:182
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:93
CUDA Unified memory type.
Definition: nvbufsurface.h:161
void * dataPtr
pointer to allocated memory, Not valid for NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE ...
Definition: nvbufsurface.h:252
Invalid color format.
Definition: nvbufsurface.h:61
BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:65
BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:131
NvBufSurfaceColorFormat colorFormat
color format
Definition: nvbufsurface.h:240
int NvBufSurfaceUnMapEglImage(NvBufSurface *surf, int index)
Destroy the previously created EGLImage(s).
int NvBufSurfaceMemSet(NvBufSurface *surf, int index, int plane, uint8_t value)
Fill each byte of buffer(s) in NvBufSurface with provided value.
uint32_t num_planes
Number of planes.
Definition: nvbufsurface.h:176
BT.601 colorspace - YUV444 multi-planar.
Definition: nvbufsurface.h:97
uint32_t bytesPerPix[NVBUF_MAX_PLANES]
bytes taken for each pixel
Definition: nvbufsurface.h:188
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:85
CUDA Host memory type.
Definition: nvbufsurface.h:157
Hold the information of single buffer in the batch.
Definition: nvbufsurface.h:232
#define NVBUF_MAX_PLANES
Maximum number of planes.
Definition: nvbufsurface.h:43
BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:129
bool isContiguous
optional but if set contiguous memory is allocated for batch.
Definition: nvbufsurface.h:208
NvBufSurfaceLayout
Defines Layout formats for NvBufSurface video planes.
Definition: nvbufsurface.h:141
int NvBufSurfaceMapEglImage(NvBufSurface *surf, int index)
Creates an EGLImage from memory of NvBufSurface buffer(s).
int NvBufSurfaceMap(NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
Map HW batched buffers to HOST / CPU address space.
BT.601 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:69
void * addr[NVBUF_MAX_PLANES]
plane wise pointers to CPU mapped buffer
Definition: nvbufsurface.h:222
NvBufSurfaceMappedAddr mappedAddr
pointers of mapped buffers.
Definition: nvbufsurface.h:256
RGBx-8-8-8-8 single plane.
Definition: nvbufsurface.h:107
malloced memory
Definition: nvbufsurface.h:167
BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:67
int NvBufSurfaceFromFd(int dmabuf_fd, void **buffer)
Get the NvBufSurface from the dmabuf fd.
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:79
uint32_t numFilled
valid / filled buffers, Zero initialized
Definition: nvbufsurface.h:270
NVRM Handle type - valid only for Jetson.
Definition: nvbufsurface.h:165
BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
Definition: nvbufsurface.h:121
RGBA-8-8-8-8 single plane.
Definition: nvbufsurface.h:99
uint32_t pitch
pitch of buffer
Definition: nvbufsurface.h:238
uint32_t psize[NVBUF_MAX_PLANES]
size of planes in bytes
Definition: nvbufsurface.h:186
NvBufSurfaceParams * surfaceList
Pointer to array of batched buffers.
Definition: nvbufsurface.h:276
uint32_t batchSize
batch size
Definition: nvbufsurface.h:268
ARGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:103
int NvBufSurfaceDestroy(NvBufSurface *surf)
Free the batched buffers previously allocated through NvBufSurfaceCreate.
Hold parameters required to allocate NvBufSurface.
Definition: nvbufsurface.h:196
struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams
Holds plane wise parameters of a buffer.
int NvBufSurfaceCopy(NvBufSurface *srcSurf, NvBufSurface *dstSurf)
Copy the memory content of source batched buffer(s) to memory of destination batched buffer(s)...
NvBufSurfaceMemType memType
type of memory of buffers in batch
Definition: nvbufsurface.h:274
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:83
BT.709 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:125
NvBufSurfaceMemType
Defines memory types of NvBufSurface.
Definition: nvbufsurface.h:152
NvBufSurfacePlaneParams planeParams
plane wise info (w, h, p, offset etc.)
Definition: nvbufsurface.h:254
int NvBufSurfaceUnMap(NvBufSurface *surf, int index, int plane)
Unmap the previously mapped buffer(s).
Holds plane wise parameters of a buffer.
Definition: nvbufsurface.h:173
uint32_t width
width of buffer
Definition: nvbufsurface.h:234
CUDA Device memory type.
Definition: nvbufsurface.h:159
uint32_t height
height of buffer
Definition: nvbufsurface.h:236
BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:133
uint64_t bufferDesc
dmabuf fd in case of NVBUF_MEM_SURFACE_ARRAY and NVBUF_MEM_HANDLE type memory.
Definition: nvbufsurface.h:246
uint32_t height
height of buffer
Definition: nvbufsurface.h:202
Hold the information of batched buffers.
Definition: nvbufsurface.h:264
NVRM Surface Array type - valid only for Jetson.
Definition: nvbufsurface.h:163
uint32_t offset[NVBUF_MAX_PLANES]
offsets of planes in bytes
Definition: nvbufsurface.h:184
#define STRUCTURE_PADDING
Default padding for reserved fields of structures.
Definition: nvbufsurface.h:40
uint32_t width[NVBUF_MAX_PLANES]
width of planes
Definition: nvbufsurface.h:178
uint32_t gpuId
GPU id - valid for multi GPU system.
Definition: nvbufsurface.h:198
uint32_t gpuId
GPU id - valid for multiple GPU system.
Definition: nvbufsurface.h:266
RGB-8-8-8 single plane.
Definition: nvbufsurface.h:115
xBGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:113
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:87
struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr
Hold the pointers of mapped buffer.
NvBufSurfaceMemType memType
type of memory to be allocated
Definition: nvbufsurface.h:214
uint32_t height[NVBUF_MAX_PLANES]
height of planes
Definition: nvbufsurface.h:180
int NvBufSurfaceSyncForCpu(NvBufSurface *surf, int index, int plane)
Syncs the HW memory cache for the CPU.
struct NvBufSurfaceParams NvBufSurfaceParams
Hold the information of single buffer in the batch.
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:81
BGRx-8-8-8-8 single plane.
Definition: nvbufsurface.h:109
BGRA-8-8-8-8 single plane.
Definition: nvbufsurface.h:101
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:226
uint32_t width
width of buffer
Definition: nvbufsurface.h:200
NvBufSurfaceLayout layout
BL or PL for Jetson, ONLY PL in case of dGPU.
Definition: nvbufsurface.h:212
bool isContiguous
check if memory allocated for batch is contiguous.
Definition: nvbufsurface.h:272
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:73
void * eglImage
pointer to mapped EGLImage
Definition: nvbufsurface.h:224
BGR-8-8-8 single plane.
Definition: nvbufsurface.h:117
struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams
Hold parameters required to allocate NvBufSurface.
NvBufSurfaceColorFormat colorFormat
color format of buffer
Definition: nvbufsurface.h:210
8 bit GRAY scale - single plane
Definition: nvbufsurface.h:63
BT.601 colorspace - YVU420 ER multi-planar.
Definition: nvbufsurface.h:71
NvBufSurfaceMemMapFlags
Defines mapping types of NvBufSurface.
Definition: nvbufsurface.h:48
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:89
Block Linear Layout.
Definition: nvbufsurface.h:146
NvBufSurfaceColorFormat
Defines color formats for NvBufSurface.
Definition: nvbufsurface.h:58
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:77
Hold the pointers of mapped buffer.
Definition: nvbufsurface.h:220
uint32_t dataSize
size of allocated memory
Definition: nvbufsurface.h:248
struct NvBufSurface NvBufSurface
Hold the information of batched buffers.
int NvBufSurfaceCreate(NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceCreateParams *params)
Allocate batch of buffers.
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:75
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:95
BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:127
void * _reserved[STRUCTURE_PADDING *NVBUF_MAX_PLANES]
Definition: nvbufsurface.h:190
xRGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:111
int NvBufSurfaceSyncForDevice(NvBufSurface *surf, int index, int plane)
Syncs the HW memory cache for the device.