NVIDIA DeepStream SDK API Reference

4.0.2 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvbuf_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-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 
25 #ifndef _NVBUF_UTILS_H_
26 #define _NVBUF_UTILS_H_
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
33 #include <EGL/egl.h>
34 #include <EGL/eglext.h>
35 #include <errno.h>
36 
40 #define MAX_NUM_PLANES 4
41 
45 #define MAX_COMPOSITE_FRAME 16
46 
50 typedef enum
51 {
57 
61 typedef enum
62 {
68 
72 typedef enum
73 {
81 
85 typedef enum
86 {
92  NvBufferTag_JPEG = 0x1500,
99 } NvBufferTag;
100 
104 typedef enum
105 {
175 
179 typedef enum
180 {
198 
202 typedef enum
203 {
217 
221 typedef enum {
231 
235 typedef enum {
239  NVBUFFER_BLEND = 1 << 1,
241 
245 typedef struct
246 {
248  float r;
250  float g;
252  float b;
254 
258 typedef struct
259 {
261  uint32_t top;
263  uint32_t left;
265  uint32_t width;
267  uint32_t height;
268 }NvBufferRect;
269 
276 typedef struct _NvBufferSession * NvBufferSession;
277 
281 typedef struct _NvBufferCreateParams
282 {
284  int32_t width;
286  int32_t height;
290  int32_t memsize;
298 
302 typedef struct _NvBufferParams
303 {
305  uint32_t dmabuf_fd;
307  void *nv_buffer;
311  int32_t memsize;
313  uint32_t nv_buffer_size;
317  uint32_t num_planes;
331 
336 {
338  uint32_t composite_flag;
340  uint32_t input_buf_count;
351  NvBufferSession session;
353 
358 {
360  uint32_t transform_flag;
371  NvBufferSession session;
373 
374 
380 int NvBufferGetSize (void);
381 
391 EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);
392 
402 int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);
403 
415 int NvBufferCreate (int *dmabuf_fd, int width, int height,
416  NvBufferLayout layout, NvBufferColorFormat colorFormat);
417 
425 int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params);
426 
434 int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params);
435 
442 int NvBufferDestroy (int dmabuf_fd);
443 
451 int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd);
452 
460 int NvReleaseFd (int dmabuf_fd);
461 
474 int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
475 
487 int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
488 
510 int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
511 
526 int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
527 
538 int NvBuffer2Raw (int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr);
539 
550 int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd);
551 
558 NvBufferSession NvBufferSessionCreate(void);
559 
564 void NvBufferSessionDestroy(NvBufferSession session);
565 
575 int NvBufferTransform (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params);
576 
586 int NvBufferComposite (int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params);
587 
588 #ifdef __cplusplus
589 }
590 #endif
591 
594 #endif
uint32_t layout[MAX_NUM_PLANES]
layout type of each planes of hardware buffer.
Definition: nvbuf_utils.h:329
uint32_t num_planes
number of planes of hardware buffer.
Definition: nvbuf_utils.h:317
NvBufferSession session
NvBufferSession to be used for transform.
Definition: nvbuf_utils.h:371
int ExtractFdFromNvBuffer(void *nvbuf, int *dmabuf_fd)
Extracts the dmabuf_fd from the hardware buffer.
NvBufferColorFormat pixel_format
video format type of hardware buffer.
Definition: nvbuf_utils.h:315
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:119
8-bit grayscale.
Definition: nvbuf_utils.h:171
uint32_t left
rectangle left.
Definition: nvbuf_utils.h:263
NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME]
source rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:344
uint32_t transform_flag
flag to indicate which of the transform parameters are valid.
Definition: nvbuf_utils.h:360
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbuf_utils.h:131
BT.601 colorspace - YUV444 multi-planar.
Definition: nvbuf_utils.h:169
tag for H264/H265/VP9 Video Decoder.
Definition: nvbuf_utils.h:96
transform flag to set flip method.
Definition: nvbuf_utils.h:229
float g
background color value for g.
Definition: nvbuf_utils.h:250
uint32_t psize[MAX_NUM_PLANES]
size of each vodeo planes of hardware buffer.
Definition: nvbuf_utils.h:327
transform flag to set filter type.
Definition: nvbuf_utils.h:227
int NvReleaseFd(int dmabuf_fd)
Releases the dmabuf_fd buffer.
Memory read.
Definition: nvbuf_utils.h:75
flag to set for composition.
Definition: nvbuf_utils.h:237
Memory write.
Definition: nvbuf_utils.h:77
transform flag to crop source rectangle.
Definition: nvbuf_utils.h:223
Video flip rotate 270 degree clockwise.
Definition: nvbuf_utils.h:188
Video flip with respect to Y-axis.
Definition: nvbuf_utils.h:192
LegacyRGBA colorspace - BGRA-8-8-8-8 planar.
Definition: nvbuf_utils.h:139
uint32_t input_buf_count
number of the input buffers to be composited.
Definition: nvbuf_utils.h:340
tag for Video Transform/Composite.
Definition: nvbuf_utils.h:98
NvBufferTransform_Filter transform_filter
transform filter.
Definition: nvbuf_utils.h:364
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:290
Video flip inverse transpode.
Definition: nvbuf_utils.h:196
NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME]
destination rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:346
int32_t width
width of the buffer.
Definition: nvbuf_utils.h:284
Video flip rotate 180 degree clockwise.
Definition: nvbuf_utils.h:186
Holds composition background r,g,b colors.
Definition: nvbuf_utils.h:245
int NvBufferMemUnMap(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Unmaps the mapped virtual address of the plane.
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbuf_utils.h:133
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:115
Pitch Layout.
Definition: nvbuf_utils.h:64
struct _NvBufferCreateParams NvBufferCreateParams
Holds the input parameters for hardware buffer creation.
BT.601 colorspace - Y/CrCb 4:2:0 10-bit multi-planar.
Definition: nvbuf_utils.h:147
transform filter bilinear.
Definition: nvbuf_utils.h:207
LegacyRGBA colorspace - XRGB-8-8-8-8 planar.
Definition: nvbuf_utils.h:141
LegacyRGBA colorspace - ARGB-8-8-8-8 planar.
Definition: nvbuf_utils.h:143
buffer payload with HW memory handle for specific memory size.
Definition: nvbuf_utils.h:55
transform filter 10 tap.
Definition: nvbuf_utils.h:211
Holds parameters for a hardware buffer.
Definition: nvbuf_utils.h:302
uint32_t nv_buffer_size
size of hardware buffer.
Definition: nvbuf_utils.h:313
int NvBuffer2Raw(int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr)
Copies the NvBuffer plane contents to a raw buffer plane.
Memory read & write.
Definition: nvbuf_utils.h:79
transform filter nearest.
Definition: nvbuf_utils.h:205
uint32_t composite_flag
flag to indicate which of the composition/blending parameters are valid.
Definition: nvbuf_utils.h:338
uint32_t height
rectangle height.
Definition: nvbuf_utils.h:267
transform filter smart.
Definition: nvbuf_utils.h:213
int Raw2NvBuffer(unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd)
Copies raw buffer plane contents to an NvBuffer plane.
NvBufferTransform_Flag
Defines flags to indicate for valid transform.
Definition: nvbuf_utils.h:221
transform filter 5 tap.
Definition: nvbuf_utils.h:209
int NvBufferMemSyncForCpu(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the HW memory cache for the CPU.
NvBufferComposite_Flag
Defines flags that specify valid composition/blending operations.
Definition: nvbuf_utils.h:235
int NvBufferMemMap(int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr)
Gets the memory-mapped virtual address of the plane.
BT.709 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:157
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbuf_utils.h:135
uint32_t width
rectangle width.
Definition: nvbuf_utils.h:265
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbuf_utils.h:129
NvBufferTag
Defines tags to associate, while allocation of NvBuffer.
Definition: nvbuf_utils.h:85
NvBufferSession NvBufferSessionCreate(void)
Creates a new NvBufferSession for parallel scheduling of buffer transformations and compositions...
float b
background color value for b.
Definition: nvbuf_utils.h:252
#define MAX_NUM_PLANES
Defines the maximum number of planes for video frame.
Definition: nvbuf_utils.h:40
BT.601 colorspace - YVU420 ER multi-planar.
Definition: nvbuf_utils.h:113
tag for Camera.
Definition: nvbuf_utils.h:90
NvBufferColorFormat colorFormat
colorformat of the buffer.
Definition: nvbuf_utils.h:294
BT.601 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:107
struct _NvBufferCompositeParams NvBufferCompositeParams
Holds parameters related to compositing/blending.
NvBufferCompositeBackground composite_bgcolor
background color values for composition.
Definition: nvbuf_utils.h:348
float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME]
alpha values of input buffers for the blending.
Definition: nvbuf_utils.h:342
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:288
NvBufferTransform_Flip transform_flip
flip method.
Definition: nvbuf_utils.h:362
uint32_t height[MAX_NUM_PLANES]
height of each planes of hardware buffer.
Definition: nvbuf_utils.h:321
tag for Jpeg Encoder/Decoder.
Definition: nvbuf_utils.h:92
struct _NvBufferParams NvBufferParams
Holds parameters for a hardware buffer.
int NvBufferMemSyncForDevice(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the HW memory cache sync for the device.
uint32_t width[MAX_NUM_PLANES]
width of each planes of hardware buffer.
Definition: nvbuf_utils.h:319
uint32_t pitch[MAX_NUM_PLANES]
pitch of each planes of hardware buffer.
Definition: nvbuf_utils.h:323
int NvBufferCreate(int *dmabuf_fd, int width, int height, NvBufferLayout layout, NvBufferColorFormat colorFormat)
Allocates a HW buffer (deprecated).
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
Creates an EGLImage instance from dmabuf-fd.
BT.601 colorspace - YUV420 ER multi-planar.
Definition: nvbuf_utils.h:111
uint32_t dmabuf_fd
dmabuf_fd of hardware buffer.
Definition: nvbuf_utils.h:305
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbuf_utils.h:125
BT.709 colorspace - YUV420 ER multi-planar.
Definition: nvbuf_utils.h:155
uint32_t offset[MAX_NUM_PLANES]
memory offset values of each video planes of hardware buffer.
Definition: nvbuf_utils.h:325
buffer payload with HW memory handle for set of planes.
Definition: nvbuf_utils.h:53
BlockLinear Layout.
Definition: nvbuf_utils.h:66
BT.601 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:109
uint32_t top
rectangle top.
Definition: nvbuf_utils.h:261
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:311
int NvBufferTransform(int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params)
Transforms one DMA buffer to another DMA buffer.
int NvBufferGetSize(void)
This method can be used to get HW Buffer struct size.
Video flip with respect to X-axis.
Definition: nvbuf_utils.h:190
Invalid color format.
Definition: nvbuf_utils.h:173
BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbuf_utils.h:159
void * nv_buffer
pointer to hardware buffer memory.
Definition: nvbuf_utils.h:307
void NvBufferSessionDestroy(NvBufferSession session)
Destroys an exisiting NvBufferSession.
Holds the input parameters for hardware buffer creation.
Definition: nvbuf_utils.h:281
int NvBufferGetParams(int dmabuf_fd, NvBufferParams *params)
Gets buffer parameters.
NvBufferPayloadType
Defines Payload types for NvBuffer.
Definition: nvbuf_utils.h:50
int NvBufferComposite(int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params)
Composites multiple input DMA buffers to one output DMA buffer.
int32_t height
height of the buffer.
Definition: nvbuf_utils.h:286
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbuf_utils.h:121
NvBufferTransform_Filter
Defines transform video filter types.
Definition: nvbuf_utils.h:202
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
Definition: nvbuf_utils.h:117
BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Definition: nvbuf_utils.h:145
BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
Definition: nvbuf_utils.h:149
BT.601 colorspace - Y/CrCb 4:2:0 12-bit multi-planar.
Definition: nvbuf_utils.h:151
Holds parameters for buffer transform functions.
Definition: nvbuf_utils.h:357
BT.709 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:153
NvBufferLayout layout
layout of the buffer.
Definition: nvbuf_utils.h:292
NvBufferTag nvbuf_tag
tag to associate with the buffer.
Definition: nvbuf_utils.h:296
float r
background color value for r.
Definition: nvbuf_utils.h:248
tag None.
Definition: nvbuf_utils.h:88
Video flip none.
Definition: nvbuf_utils.h:182
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbuf_utils.h:127
struct _NvBufferTransformParams NvBufferTransformParams
Holds parameters for buffer transform functions.
transform flag to crop destination rectangle.
Definition: nvbuf_utils.h:225
Optical flow SAD calculation Buffer format.
Definition: nvbuf_utils.h:167
Video flip transpose.
Definition: nvbuf_utils.h:194
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:309
BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:163
NvBufferTransform_Flip
Defines video flip methods.
Definition: nvbuf_utils.h:179
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbuf_utils.h:123
NvBufferRect dst_rect
destination rectangle coordinates for crop opeartion.
Definition: nvbuf_utils.h:368
NvBufferLayout
Defines Layout formats for NvBuffer video planes.
Definition: nvbuf_utils.h:61
tag for H264/H265 Video Encoder.
Definition: nvbuf_utils.h:94
int NvBufferDestroy(int dmabuf_fd)
Destroys a HW buffer.
int NvBufferCreateEx(int *dmabuf_fd, NvBufferCreateParams *input_params)
Allocates a HW buffer.
Holds coordinates for a rectangle.
Definition: nvbuf_utils.h:258
NvBufferColorFormat
Defines color formats for NvBuffer.
Definition: nvbuf_utils.h:104
Holds parameters related to compositing/blending.
Definition: nvbuf_utils.h:335
Video flip rotate 90 degree clockwise.
Definition: nvbuf_utils.h:184
struct _NvBufferSession * NvBufferSession
Holds an opaque NvBuffer session type required for parallel buffer tranformations and compositions...
Definition: nvbuf_utils.h:276
transform filter nicest.
Definition: nvbuf_utils.h:215
BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:161
NvBufferRect src_rect
source rectangle coordinates for crop opeartion.
Definition: nvbuf_utils.h:366
BT.601 colorspace - YUV ER 4:2:2 planar.
Definition: nvbuf_utils.h:137
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
Destroys an EGLImage object.
NvBufferSession session
NvBufferSession to be used for composition.
Definition: nvbuf_utils.h:351
flag to set for blending.
Definition: nvbuf_utils.h:239
NvBufferMemFlags
Defines memory access flags for NvBuffer.
Definition: nvbuf_utils.h:72
#define MAX_COMPOSITE_FRAME
Defines the maximum number of input video frames that can be used for composition.
Definition: nvbuf_utils.h:45