L4T Multimedia API Reference

32.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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 3
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 {
171 
175 typedef enum
176 {
194 
198 typedef enum
199 {
213 
217 typedef enum {
227 
231 typedef enum {
235  NVBUFFER_BLEND = 1 << 1,
237 
241 typedef struct
242 {
244  float r;
246  float g;
248  float b;
250 
254 typedef struct
255 {
257  uint32_t top;
259  uint32_t left;
261  uint32_t width;
263  uint32_t height;
264 }NvBufferRect;
265 
272 typedef struct _NvBufferSession * NvBufferSession;
273 
277 typedef struct _NvBufferCreateParams
278 {
280  int32_t width;
282  int32_t height;
286  int32_t memsize;
294 
298 typedef struct _NvBufferParams
299 {
301  uint32_t dmabuf_fd;
303  void *nv_buffer;
307  int32_t memsize;
309  uint32_t nv_buffer_size;
313  uint32_t num_planes;
327 
332 {
334  uint32_t composite_flag;
336  uint32_t input_buf_count;
347  NvBufferSession session;
349 
354 {
356  uint32_t transform_flag;
367  NvBufferSession session;
369 
370 
376 int NvBufferGetSize (void);
377 
387 EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);
388 
398 int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);
399 
411 int NvBufferCreate (int *dmabuf_fd, int width, int height,
412  NvBufferLayout layout, NvBufferColorFormat colorFormat);
413 
421 int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params);
422 
430 int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params);
431 
438 int NvBufferDestroy (int dmabuf_fd);
439 
447 int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd);
448 
456 int NvReleaseFd (int dmabuf_fd);
457 
470 int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
471 
483 int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
484 
506 int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
507 
522 int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
523 
534 int NvBuffer2Raw (int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr);
535 
546 int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd);
547 
554 NvBufferSession NvBufferSessionCreate(void);
555 
560 void NvBufferSessionDestroy(NvBufferSession session);
561 
571 int NvBufferTransform (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params);
572 
582 int NvBufferComposite (int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params);
583 
584 #ifdef __cplusplus
585 }
586 #endif
587 
590 #endif
uint32_t layout[MAX_NUM_PLANES]
layout type of each planes of hardware buffer.
Definition: nvbuf_utils.h:325
uint32_t num_planes
number of planes of hardware buffer.
Definition: nvbuf_utils.h:313
NvBufferSession session
NvBufferSession to be used for transform.
Definition: nvbuf_utils.h:367
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:311
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:119
uint32_t left
rectangle left.
Definition: nvbuf_utils.h:259
NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME]
source rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:340
uint32_t transform_flag
flag to indicate which of the transform parameters are valid.
Definition: nvbuf_utils.h:356
BT.601 colorspace - YUV 4:2:2 planar.
Definition: nvbuf_utils.h:131
BT.601 colorspace - YUV444 multi-planar.
Definition: nvbuf_utils.h:167
tag for H264/H265/VP9 Video Decoder.
Definition: nvbuf_utils.h:96
transform flag to set flip method.
Definition: nvbuf_utils.h:225
float g
background color value for g.
Definition: nvbuf_utils.h:246
uint32_t psize[MAX_NUM_PLANES]
size of each vodeo planes of hardware buffer.
Definition: nvbuf_utils.h:323
transform flag to set filter type.
Definition: nvbuf_utils.h:223
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:233
Memory write.
Definition: nvbuf_utils.h:77
transform flag to crop source rectangle.
Definition: nvbuf_utils.h:219
Video flip rotate 270 degree clockwise.
Definition: nvbuf_utils.h:184
Video flip with respect to Y-axis.
Definition: nvbuf_utils.h:188
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:336
tag for Video Transform/Composite.
Definition: nvbuf_utils.h:98
NvBufferTransform_Filter transform_filter
transform filter.
Definition: nvbuf_utils.h:360
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:286
Video flip inverse transpode.
Definition: nvbuf_utils.h:192
NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME]
destination rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:342
int32_t width
width of the buffer.
Definition: nvbuf_utils.h:280
Video flip rotate 180 degree clockwise.
Definition: nvbuf_utils.h:182
Holds composition background r,g,b colors.
Definition: nvbuf_utils.h:241
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:203
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:207
Holds parameters for a hardware buffer.
Definition: nvbuf_utils.h:298
uint32_t nv_buffer_size
size of hardware buffer.
Definition: nvbuf_utils.h:309
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:201
uint32_t composite_flag
flag to indicate which of the composition/blending parameters are valid.
Definition: nvbuf_utils.h:334
uint32_t height
rectangle height.
Definition: nvbuf_utils.h:263
transform filter smart.
Definition: nvbuf_utils.h:209
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:217
transform filter 5 tap.
Definition: nvbuf_utils.h:205
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:231
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:261
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:248
#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:290
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:344
float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME]
alpha values of input buffers for the blending.
Definition: nvbuf_utils.h:338
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:284
NvBufferTransform_Flip transform_flip
flip method.
Definition: nvbuf_utils.h:358
uint32_t height[MAX_NUM_PLANES]
height of each planes of hardware buffer.
Definition: nvbuf_utils.h:317
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:315
uint32_t pitch[MAX_NUM_PLANES]
pitch of each planes of hardware buffer.
Definition: nvbuf_utils.h:319
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:301
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:321
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:257
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:307
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:186
Invalid color format.
Definition: nvbuf_utils.h:169
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:303
void NvBufferSessionDestroy(NvBufferSession session)
Destroys an exisiting NvBufferSession.
Holds the input parameters for hardware buffer creation.
Definition: nvbuf_utils.h:277
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:282
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:198
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:353
BT.709 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:153
NvBufferLayout layout
layout of the buffer.
Definition: nvbuf_utils.h:288
NvBufferTag nvbuf_tag
tag to associate with the buffer.
Definition: nvbuf_utils.h:292
float r
background color value for r.
Definition: nvbuf_utils.h:244
tag None.
Definition: nvbuf_utils.h:88
Video flip none.
Definition: nvbuf_utils.h:178
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:221
Video flip transpose.
Definition: nvbuf_utils.h:190
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:305
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:175
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:364
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:254
NvBufferColorFormat
Defines color formats for NvBuffer.
Definition: nvbuf_utils.h:104
Holds parameters related to compositing/blending.
Definition: nvbuf_utils.h:331
Video flip rotate 90 degree clockwise.
Definition: nvbuf_utils.h:180
struct _NvBufferSession * NvBufferSession
Holds an opaque NvBuffer session type required for parallel buffer tranformations and compositions...
Definition: nvbuf_utils.h:272
transform filter nicest.
Definition: nvbuf_utils.h:211
BT.2020 colorspace - YUV420 multi-planar.
Definition: nvbuf_utils.h:161
NvBufferRect src_rect
source rectangle coordinates for crop opeartion.
Definition: nvbuf_utils.h:362
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:347
flag to set for blending.
Definition: nvbuf_utils.h:235
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