NVIDIA DeepStream SDK API Reference

4.0.1 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
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 
36 #ifndef NVBUFSURFACE_H_
37 #define NVBUFSURFACE_H_
38 
39 #include <stdint.h>
40 #include <stdbool.h>
41 
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #endif
46 
55 #define STRUCTURE_PADDING 4
56 
58 #define NVBUF_MAX_PLANES 4
59 
63 typedef enum
64 {
71 
75 typedef enum
76 {
151 
154 
158 typedef enum
159 {
165 
169 typedef enum
170 {
188 
193 {
195  uint32_t num_planes;
208 
211 
215 typedef struct NvBufSurfaceCreateParams {
217  uint32_t gpuId;
219  uint32_t width;
221  uint32_t height;
224  uint32_t size;
236 
240 typedef struct NvBufSurfaceMappedAddr {
244  void *eglImage;
245 
248 
252 typedef struct NvBufSurfaceParams {
254  uint32_t width;
256  uint32_t height;
258  uint32_t pitch;
265  uint64_t bufferDesc;
267  uint32_t dataSize;
270  void * dataPtr;
276 
279 
283 typedef struct NvBufSurface {
285  uint32_t gpuId;
287  uint32_t batchSize;
290  uint32_t numFilled;
298 
300 } NvBufSurface;
301 
321 int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
322  NvBufSurfaceCreateParams *params);
323 
332 
372 int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
373 
385 int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
386 
403 int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
404 
419 int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
420 
435 int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
436 
445 int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
446 
462 int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
463 
490 int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
491 
501 int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
502 
503 #ifdef __cplusplus
504 }
505 #endif
506 #endif /* NVBUFSURFACE_H_ */
507 
Specifies NvBufSurface mapping type "read/write.".
Definition: nvbufsurface.h:68
int NvBufSurfaceFromFd(int dmabuf_fd, void **buffer)
Gets the NvBufSurface from the DMABUF FD.
NvBufSurfaceLayout
Specifies layout formats for NvBufSurface video planes.
Definition: nvbufsurface.h:158
struct NvBufSurface NvBufSurface
Holds information about batched buffers.
struct NvBufSurfacePlaneParams NvBufSurfacePlaneParams
Holds the planewise parameters of a buffer.
Specifies RGB-8-8-8 single plane.
Definition: nvbufsurface.h:132
uint32_t size
Holds the amount of memory to be allocated.
Definition: nvbufsurface.h:224
NvBufSurfaceLayout layout
Holds BL or PL.
Definition: nvbufsurface.h:262
int NvBufSurfaceUnMapEglImage(NvBufSurface *surf, int index)
Destroys the previously created EGLImage object(s).
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:299
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:104
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:277
uint32_t pitch[NVBUF_MAX_PLANES]
Holds the pitches of planes in bytes.
Definition: nvbufsurface.h:201
int NvBufSurfaceCopy(NvBufSurface *srcSurf, NvBufSurface *dstSurf)
Copies the content of source batched buffer(s) to destination batched buffer(s).
Specifies ARGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:120
Specifies BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:150
void * dataPtr
Holds a pointer to allocated memory.
Definition: nvbufsurface.h:270
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:110
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.
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:260
Specifies BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:148
uint32_t num_planes
Holds the number of planes.
Definition: nvbufsurface.h:195
Specifies BGR-8-8-8 single plane.
Definition: nvbufsurface.h:134
Specifies CUDA Device memory type.
Definition: nvbufsurface.h:178
Specifies BT.601 colorspace - YVU420 ER multi-planar.
Definition: nvbufsurface.h:88
uint32_t bytesPerPix[NVBUF_MAX_PLANES]
Holds the number of bytes occupied by a pixel in each plane.
Definition: nvbufsurface.h:207
Specifies NVRM Surface Array type.
Definition: nvbufsurface.h:182
Holds information about a single buffer in a batch.
Definition: nvbufsurface.h:252
Specifies the default memory type, i.e.
Definition: nvbufsurface.h:174
Specifies BT.709 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:140
Specifies xRGB-8-8-8-8 single plane.
Definition: nvbufsurface.h:128
bool isContiguous
Holds a "contiguous memory" flag.
Definition: nvbufsurface.h:227
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:106
Specifies an invalid color format.
Definition: nvbufsurface.h:78
Specifies BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:144
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:100
struct NvBufSurfaceParams NvBufSurfaceParams
Holds information about a single buffer in a batch.
void * addr[NVBUF_MAX_PLANES]
Holds planewise pointers to a CPU mapped buffer.
Definition: nvbufsurface.h:242
NvBufSurfaceMappedAddr mappedAddr
Holds pointers to mapped buffers.
Definition: nvbufsurface.h:275
Specifies CUDA Unified memory type.
Definition: nvbufsurface.h:180
int NvBufSurfaceMap(NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
Maps hardware batched buffers to the HOST or CPU address space.
Specifies xBGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:130
Specifies RGBx-8-8-8-8 single plane.
Definition: nvbufsurface.h:124
uint32_t numFilled
Holds the number valid and filled buffers.
Definition: nvbufsurface.h:290
NvBufSurfaceMemMapFlags
Specifies mapping types for NvBufSurface.
Definition: nvbufsurface.h:63
uint32_t pitch
Holds the pitch of the buffer.
Definition: nvbufsurface.h:258
uint32_t psize[NVBUF_MAX_PLANES]
Holds the sizes of planes in bytes.
Definition: nvbufsurface.h:205
Specifies BT.601 colorspace - YUV444 multi-planar.
Definition: nvbufsurface.h:114
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:94
NvBufSurfaceParams * surfaceList
Holds a pointer to an array of batched buffers.
Definition: nvbufsurface.h:297
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:108
uint32_t batchSize
Holds the batch size.
Definition: nvbufsurface.h:287
NvBufSurfaceColorFormat
Specifies color formats for NvBufSurface.
Definition: nvbufsurface.h:75
Holds parameters required to allocate an NvBufSurface.
Definition: nvbufsurface.h:215
Specifies pitch layout.
Definition: nvbufsurface.h:161
Specifies BGRA-8-8-8-8 single plane.
Definition: nvbufsurface.h:118
NvBufSurfaceMemType memType
Holds type of memory for buffers in the batch.
Definition: nvbufsurface.h:295
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:92
Specifies memory allocated by malloc().
Definition: nvbufsurface.h:186
int NvBufSurfaceDestroy(NvBufSurface *surf)
Frees batched buffers previously allocated by NvBufSurfaceCreate().
Specifies NvBufSurface mapping type "read.".
Definition: nvbufsurface.h:65
int NvBufSurfaceSyncForDevice(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the device.
NvBufSurfacePlaneParams planeParams
Holds planewise information (width, height, pitch, offset, etc.).
Definition: nvbufsurface.h:272
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:98
Holds the planewise parameters of a buffer.
Definition: nvbufsurface.h:192
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:254
Specifies BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbufsurface.h:136
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:256
int NvBufSurfaceMapEglImage(NvBufSurface *surf, int index)
Creates an EGLImage from the memory of one or more NvBufSurface buffers.
Specifies BT.709 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:142
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbufsurface.h:90
uint64_t bufferDesc
Holds a DMABUF FD.
Definition: nvbufsurface.h:265
uint32_t height
Holds the height of the buffer.
Definition: nvbufsurface.h:221
#define NVBUF_MAX_PLANES
Defines the maximum number of planes.
Definition: nvbufsurface.h:58
#define STRUCTURE_PADDING
Defines the default padding length for reserved fields of structures.
Definition: nvbufsurface.h:55
Specifies CUDA Host memory type.
Definition: nvbufsurface.h:176
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:84
Holds information about batched buffers.
Definition: nvbufsurface.h:283
uint32_t offset[NVBUF_MAX_PLANES]
Holds the offsets of planes in bytes.
Definition: nvbufsurface.h:203
int NvBufSurfaceUnMap(NvBufSurface *surf, int index, int plane)
Unmaps previously mapped buffer(s).
uint32_t width[NVBUF_MAX_PLANES]
Holds the widths of planes.
Definition: nvbufsurface.h:197
Specifies BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbufsurface.h:102
uint32_t gpuId
Holds the GPU ID.
Definition: nvbufsurface.h:217
uint32_t gpuId
Holds a GPU ID.
Definition: nvbufsurface.h:285
Specifies RGBA-8-8-8-8 single plane.
Definition: nvbufsurface.h:116
Specifies BT.601 colorspace - YUV420 multi-planar.
Definition: nvbufsurface.h:82
Specifies ABGR-8-8-8-8 single plane.
Definition: nvbufsurface.h:122
NvBufSurfaceMemType memType
Holds the type of memory to be allocated.
Definition: nvbufsurface.h:234
Specifies 8 bit GRAY scale - single plane.
Definition: nvbufsurface.h:80
uint32_t height[NVBUF_MAX_PLANES]
Holds the heights of planes.
Definition: nvbufsurface.h:199
Specifies BT.601 colorspace - YUV420 ER multi-planar.
Definition: nvbufsurface.h:86
void * _reserved[STRUCTURE_PADDING]
Definition: nvbufsurface.h:246
Specifies BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:146
struct NvBufSurfaceCreateParams NvBufSurfaceCreateParams
Holds parameters required to allocate an NvBufSurface.
Specifies BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
Definition: nvbufsurface.h:138
Specifies NvBufSurface mapping type "write.".
Definition: nvbufsurface.h:66
uint32_t width
Holds the width of the buffer.
Definition: nvbufsurface.h:219
NvBufSurfaceLayout layout
Holds the surface layout.
Definition: nvbufsurface.h:232
bool isContiguous
Holds an "is contiguous" flag.
Definition: nvbufsurface.h:293
Specifies BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbufsurface.h:96
void * eglImage
Holds a pointer to a mapped EGLImage.
Definition: nvbufsurface.h:244
Specifies BGRx-8-8-8-8 single plane.
Definition: nvbufsurface.h:126
NvBufSurfaceMemType
Specifies memory types for NvBufSurface.
Definition: nvbufsurface.h:169
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
Definition: nvbufsurface.h:229
struct NvBufSurfaceMappedAddr NvBufSurfaceMappedAddr
Holds pointers for a mapped buffer.
Holds pointers for a mapped buffer.
Definition: nvbufsurface.h:240
uint32_t dataSize
Holds the amount of allocated memory.
Definition: nvbufsurface.h:267
Specifies block linear layout.
Definition: nvbufsurface.h:163
int NvBufSurfaceCreate(NvBufSurface **surf, uint32_t batchSize, NvBufSurfaceCreateParams *params)
Allocates a batch of buffers.
void * _reserved[STRUCTURE_PADDING *NVBUF_MAX_PLANES]
Definition: nvbufsurface.h:209
Specifies NVRM Handle type.
Definition: nvbufsurface.h:184
Specifies BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbufsurface.h:112
int NvBufSurfaceSyncForCpu(NvBufSurface *surf, int index, int plane)
Syncs the hardware memory cache for the CPU.