L4T Multimedia API Reference

28.2 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-2018, 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 {
131 
135 typedef enum
136 {
154 
158 typedef enum
159 {
173 
177 typedef enum {
187 
191 typedef enum {
195  NVBUFFER_BLEND = 1 << 1,
197 
201 typedef struct
202 {
204  float r;
206  float g;
208  float b;
210 
214 typedef struct
215 {
217  uint32_t top;
219  uint32_t left;
221  uint32_t width;
223  uint32_t height;
224 }NvBufferRect;
225 
229 typedef struct _NvBufferCreateParams
230 {
232  int32_t width;
234  int32_t height;
238  int32_t memsize;
246 
250 typedef struct _NvBufferParams
251 {
253  uint32_t dmabuf_fd;
255  void *nv_buffer;
259  int32_t memsize;
261  uint32_t nv_buffer_size;
263  uint32_t pixel_format;
265  uint32_t num_planes;
279 
284 {
286  uint32_t composite_flag;
288  uint32_t input_buf_count;
298 
303 {
305  uint32_t transform_flag;
315 
324 EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);
325 
334 int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);
335 
346 int NvBufferCreate (int *dmabuf_fd, int width, int height,
347  NvBufferLayout layout, NvBufferColorFormat colorFormat);
348 
356 int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params);
357 
365 int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params);
366 
373 int NvBufferDestroy (int dmabuf_fd);
374 
382 int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd);
383 
391 int NvReleaseFd (int dmabuf_fd);
392 
402 int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
403 
412 int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
413 
423 int NvBufferMemMap (int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr);
424 
433 int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr);
434 
445 int NvBuffer2Raw (int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr);
446 
457 int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd);
458 
468 int NvBufferTransform (int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params);
469 
479 int NvBufferComposite (int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params);
480 
481 #ifdef __cplusplus
482 }
483 #endif
484 
487 #endif
uint32_t layout[MAX_NUM_PLANES]
layout type of each planes of hardware buffer.
Definition: nvbuf_utils.h:277
uint32_t num_planes
number of planes of hardware buffer.
Definition: nvbuf_utils.h:265
int ExtractFdFromNvBuffer(void *nvbuf, int *dmabuf_fd)
This method must be used to extract dmabuf_fd of the hardware buffer.
Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:113
uint32_t left
rectangle left.
Definition: nvbuf_utils.h:219
NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME]
source rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:292
uint32_t transform_flag
flag to indicate which of the transform parameters are valid.
Definition: nvbuf_utils.h:305
YUV 4:2:2 planar.
Definition: nvbuf_utils.h:119
tag for H264/H265/VP9 Video Decoder.
Definition: nvbuf_utils.h:96
transform flag to set flip method.
Definition: nvbuf_utils.h:185
float g
background color value for g.
Definition: nvbuf_utils.h:206
uint32_t psize[MAX_NUM_PLANES]
size of each vodeo planes of hardware buffer.
Definition: nvbuf_utils.h:275
transform flag to set filter type.
Definition: nvbuf_utils.h:183
int NvReleaseFd(int dmabuf_fd)
This method must be used for releasing dmabuf_fd.
Memory read.
Definition: nvbuf_utils.h:75
flag to set for composition.
Definition: nvbuf_utils.h:193
Memory write.
Definition: nvbuf_utils.h:77
transform flag to crop source rectangle.
Definition: nvbuf_utils.h:179
Video flip rotate 270 degree clockwise.
Definition: nvbuf_utils.h:144
Video flip with respect to Y-axis.
Definition: nvbuf_utils.h:148
BGRA-8-8-8-8 planar.
Definition: nvbuf_utils.h:123
uint32_t input_buf_count
number of the input buffers to be composited.
Definition: nvbuf_utils.h:288
tag for Video Transform/Composite.
Definition: nvbuf_utils.h:98
NvBufferTransform_Filter transform_filter
transform filter.
Definition: nvbuf_utils.h:309
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:238
Video flip inverse transpode.
Definition: nvbuf_utils.h:152
NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME]
destination rectangle coordinates of input buffers for composition.
Definition: nvbuf_utils.h:294
int32_t width
width of the buffer.
Definition: nvbuf_utils.h:232
Video flip rotate 180 degree clockwise.
Definition: nvbuf_utils.h:142
Defines composition background r,g,b colors.
Definition: nvbuf_utils.h:201
int NvBufferMemUnMap(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
This method must be used to Unmap the mapped virtual Address of the plane.
Y/CbCr 4:2:0 multi-planar.
Definition: nvbuf_utils.h:111
Pitch Layout.
Definition: nvbuf_utils.h:64
struct _NvBufferCreateParams NvBufferCreateParams
Defines input parameters for hardware buffer creation.
transform filter bilinear.
Definition: nvbuf_utils.h:163
XRGB-8-8-8-8 planar.
Definition: nvbuf_utils.h:125
ARGB-8-8-8-8 planar.
Definition: nvbuf_utils.h:127
buffer payload with HW memory handle for specific memory size.
Definition: nvbuf_utils.h:55
transform filter 10 tap.
Definition: nvbuf_utils.h:167
Defines parameters related to hardware buffer.
Definition: nvbuf_utils.h:250
uint32_t nv_buffer_size
size of hardware buffer.
Definition: nvbuf_utils.h:261
int NvBuffer2Raw(int dmabuf_fd, unsigned int plane, unsigned int out_width, unsigned int out_height, unsigned char *ptr)
This method is used to copy NvBuffer plane contents to raw buffer plane.
Memory read & write.
Definition: nvbuf_utils.h:79
transform filter nearest.
Definition: nvbuf_utils.h:161
uint32_t composite_flag
flag to indicate which of the composition/blending parameters are valid.
Definition: nvbuf_utils.h:286
uint32_t height
rectangle height.
Definition: nvbuf_utils.h:223
transform filter smart.
Definition: nvbuf_utils.h:169
int Raw2NvBuffer(unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd)
This method is used to copy raw buffer plane contents to NvBuffer plane.
NvBufferTransform_Flag
Defines flags to indicate for valid transform.
Definition: nvbuf_utils.h:177
uint32_t pixel_format
video format type of hardware buffer.
Definition: nvbuf_utils.h:263
transform filter 5 tap.
Definition: nvbuf_utils.h:165
int NvBufferMemSyncForCpu(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
This method must be used for hw memory cache sync for the CPU.
NvBufferComposite_Flag
Defines flags to indicate for valid composition/blending operation.
Definition: nvbuf_utils.h:191
int NvBufferMemMap(int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr)
This method must be used for getting mem mapped virtual Address of the plane.
YUV 4:2:2 planar.
Definition: nvbuf_utils.h:121
uint32_t width
rectangle width.
Definition: nvbuf_utils.h:221
NvBufferTag
Defines tags to associate, while allocation of NvBuffer.
Definition: nvbuf_utils.h:85
float b
background color value for b.
Definition: nvbuf_utils.h:208
#define MAX_NUM_PLANES
Defines maximum number of planes for video frame.
Definition: nvbuf_utils.h:40
tag for Camera.
Definition: nvbuf_utils.h:90
NvBufferColorFormat colorFormat
colorformat of the buffer.
Definition: nvbuf_utils.h:242
YUV420 multi-planar.
Definition: nvbuf_utils.h:107
struct _NvBufferCompositeParams NvBufferCompositeParams
Defines parameters related to composition/blending.
NvBufferCompositeBackground composite_bgcolor
background color values for composition.
Definition: nvbuf_utils.h:296
float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME]
alpha values of input buffers for the blending.
Definition: nvbuf_utils.h:290
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:236
NvBufferTransform_Flip transform_flip
flip method.
Definition: nvbuf_utils.h:307
uint32_t height[MAX_NUM_PLANES]
height of each planes of hardware buffer.
Definition: nvbuf_utils.h:269
tag for Jpeg Encoder/Decoder.
Definition: nvbuf_utils.h:92
struct _NvBufferParams NvBufferParams
Defines parameters related to hardware buffer.
int NvBufferMemSyncForDevice(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
This method must be used for hw memory cache sync for device.
uint32_t width[MAX_NUM_PLANES]
width of each planes of hardware buffer.
Definition: nvbuf_utils.h:267
uint32_t pitch[MAX_NUM_PLANES]
pitch of each planes of hardware buffer.
Definition: nvbuf_utils.h:271
int NvBufferCreate(int *dmabuf_fd, int width, int height, NvBufferLayout layout, NvBufferColorFormat colorFormat)
Use this method to allocate HW buffer (Deprecated, instead use NvBufferCreateEx API).
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
uint32_t dmabuf_fd
dmabuf_fd of hardware buffer.
Definition: nvbuf_utils.h:253
uint32_t offset[MAX_NUM_PLANES]
memory offset values of each video planes of hardware buffer.
Definition: nvbuf_utils.h:273
buffer payload with HW memory handle for set of planes.
Definition: nvbuf_utils.h:53
BlockLinear Layout.
Definition: nvbuf_utils.h:66
YUV420 multi-planar.
Definition: nvbuf_utils.h:109
uint32_t top
rectangle top.
Definition: nvbuf_utils.h:217
int32_t memsize
size of the memory.
Definition: nvbuf_utils.h:259
int NvBufferTransform(int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params)
This method is used to transform one DMA buffer to another DMA buffer.
Video flip with respect to X-axis.
Definition: nvbuf_utils.h:146
Invalid color format.
Definition: nvbuf_utils.h:129
void * nv_buffer
pointer to hardware buffer memory.
Definition: nvbuf_utils.h:255
Defines input parameters for hardware buffer creation.
Definition: nvbuf_utils.h:229
int NvBufferGetParams(int dmabuf_fd, NvBufferParams *params)
Use this method to get buffer parameters.
NvBufferPayloadType
Defines Payload type for NvBuffer.
Definition: nvbuf_utils.h:50
int NvBufferComposite(int *src_dmabuf_fds, int dst_dmabuf_fd, NvBufferCompositeParams *composite_params)
This method is used to composite multiple input DMA buffers to one output DMA buffer.
int32_t height
height of the buffer.
Definition: nvbuf_utils.h:234
NvBufferTransform_Filter
Defines transform video filter types.
Definition: nvbuf_utils.h:158
Defines parameters related to transform.
Definition: nvbuf_utils.h:302
NvBufferLayout layout
layout of the buffer.
Definition: nvbuf_utils.h:240
NvBufferTag nvbuf_tag
tag to associate with the buffer.
Definition: nvbuf_utils.h:244
float r
background color value for r.
Definition: nvbuf_utils.h:204
tag None.
Definition: nvbuf_utils.h:88
Video flip none.
Definition: nvbuf_utils.h:138
YUV 4:2:2 planar.
Definition: nvbuf_utils.h:117
struct _NvBufferTransformParams NvBufferTransformParams
Defines parameters related to transform.
transform flag to crop destination rectangle.
Definition: nvbuf_utils.h:181
Video flip transpose.
Definition: nvbuf_utils.h:150
NvBufferPayloadType payloadType
payload type of the buffer.
Definition: nvbuf_utils.h:257
NvBufferTransform_Flip
Defines video flip methods.
Definition: nvbuf_utils.h:135
YUV 4:2:2 planar.
Definition: nvbuf_utils.h:115
NvBufferRect dst_rect
destination rectangle coordinates for crop opeartion.
Definition: nvbuf_utils.h:313
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)
This method must be used for destroying hw_buffer.
int NvBufferCreateEx(int *dmabuf_fd, NvBufferCreateParams *input_params)
Use this method to allocate HW buffer.
Defines coordinates for rectangle.
Definition: nvbuf_utils.h:214
NvBufferColorFormat
Defines color formats for NvBuffer.
Definition: nvbuf_utils.h:104
Defines parameters related to composition/blending.
Definition: nvbuf_utils.h:283
Video flip rotate 90 degree clockwise.
Definition: nvbuf_utils.h:140
transform filter nicest.
Definition: nvbuf_utils.h:171
NvBufferRect src_rect
source rectangle coordinates for crop opeartion.
Definition: nvbuf_utils.h:311
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.
flag to set for blending.
Definition: nvbuf_utils.h:195
NvBufferMemFlags
Defines memory access flags for NvBuffer.
Definition: nvbuf_utils.h:72
#define MAX_COMPOSITE_FRAME
Defines maximum number of input video frames can be used for composition.
Definition: nvbuf_utils.h:45