L4T Multimedia API Reference

28.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Buffer Manager

Detailed Description

NVIDIA buffering utility library for use by applications.

The utility also transform, composits, and blends.

Data Structures

struct  NvBufferCompositeBackground
 Defines composition background r,g,b colors. More...
 
struct  NvBufferRect
 Defines coordinates for rectangle. More...
 
struct  _NvBufferCreateParams
 Defines input parameters for hardware buffer creation. More...
 
struct  _NvBufferParams
 Defines parameters related to hardware buffer. More...
 
struct  _NvBufferCompositeParams
 Defines parameters related to composition/blending. More...
 
struct  _NvBufferTransformParams
 Defines parameters related to transform. More...
 

Macros

#define MAX_NUM_PLANES   3
 Defines maximum number of planes for video frame. More...
 
#define MAX_COMPOSITE_FRAME   16
 Defines maximum number of input video frames can be used for composition. More...
 

Typedefs

typedef struct
_NvBufferCreateParams 
NvBufferCreateParams
 Defines input parameters for hardware buffer creation. More...
 
typedef struct _NvBufferParams NvBufferParams
 Defines parameters related to hardware buffer. More...
 
typedef struct
_NvBufferCompositeParams 
NvBufferCompositeParams
 Defines parameters related to composition/blending. More...
 
typedef struct
_NvBufferTransformParams 
NvBufferTransformParams
 Defines parameters related to transform. More...
 

Enumerations

enum  NvBufferPayloadType {
  NvBufferPayload_SurfArray,
  NvBufferPayload_MemHandle
}
 Defines Payload type for NvBuffer. More...
 
enum  NvBufferLayout {
  NvBufferLayout_Pitch,
  NvBufferLayout_BlockLinear
}
 Defines Layout formats for NvBuffer video planes. More...
 
enum  NvBufferMemFlags {
  NvBufferMem_Read,
  NvBufferMem_Write,
  NvBufferMem_Read_Write
}
 Defines memory access flags for NvBuffer. More...
 
enum  NvBufferTag {
  NvBufferTag_NONE = 0x0,
  NvBufferTag_CAMERA = 0x200,
  NvBufferTag_JPEG = 0x1500,
  NvBufferTag_VIDEO_ENC = 0x1200,
  NvBufferTag_VIDEO_DEC = 0x1400,
  NvBufferTag_VIDEO_CONVERT = 0xf01
}
 Defines tags to associate, while allocation of NvBuffer. More...
 
enum  NvBufferColorFormat {
  NvBufferColorFormat_YUV420,
  NvBufferColorFormat_YVU420,
  NvBufferColorFormat_NV12,
  NvBufferColorFormat_NV21,
  NvBufferColorFormat_UYVY,
  NvBufferColorFormat_VYUY,
  NvBufferColorFormat_YUYV,
  NvBufferColorFormat_YVYU,
  NvBufferColorFormat_ABGR32,
  NvBufferColorFormat_XRGB32,
  NvBufferColorFormat_ARGB32,
  NvBufferColorFormat_Invalid
}
 Defines color formats for NvBuffer. More...
 
enum  NvBufferTransform_Flip {
  NvBufferTransform_None,
  NvBufferTransform_Rotate90,
  NvBufferTransform_Rotate180,
  NvBufferTransform_Rotate270,
  NvBufferTransform_FlipX,
  NvBufferTransform_FlipY,
  NvBufferTransform_Transpose,
  NvBufferTransform_InvTranspose
}
 Defines video flip methods. More...
 
enum  NvBufferTransform_Filter {
  NvBufferTransform_Filter_Nearest,
  NvBufferTransform_Filter_Bilinear,
  NvBufferTransform_Filter_5_Tap,
  NvBufferTransform_Filter_10_Tap,
  NvBufferTransform_Filter_Smart,
  NvBufferTransform_Filter_Nicest
}
 Defines transform video filter types. More...
 
enum  NvBufferTransform_Flag {
  NVBUFFER_TRANSFORM_CROP_SRC = 1,
  NVBUFFER_TRANSFORM_CROP_DST = 1 << 1,
  NVBUFFER_TRANSFORM_FILTER = 1 << 2,
  NVBUFFER_TRANSFORM_FLIP = 1 << 3
}
 Defines flags to indicate for valid transform. More...
 
enum  NvBufferComposite_Flag {
  NVBUFFER_COMPOSITE = 1,
  NVBUFFER_BLEND = 1 << 1
}
 Defines flags to indicate for valid composition/blending operation. More...
 

Functions

EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd)
 This method must be used for getting EGLImage from dmabuf-fd. More...
 
int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage)
 This method must be used for destroying EGLImage object. More...
 
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). More...
 
int NvBufferCreateEx (int *dmabuf_fd, NvBufferCreateParams *input_params)
 Use this method to allocate HW buffer. More...
 
int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params)
 Use this method to get buffer parameters. More...
 
int NvBufferDestroy (int dmabuf_fd)
 This method must be used for destroying hw_buffer. More...
 
int ExtractFdFromNvBuffer (void *nvbuf, int *dmabuf_fd)
 This method must be used to extract dmabuf_fd of the hardware buffer. More...
 
int NvReleaseFd (int dmabuf_fd)
 This method must be used for releasing dmabuf_fd. More...
 
int NvBufferMemSyncForCpu (int dmabuf_fd, unsigned int plane, void **pVirtAddr)
 This method must be used for hw memory cache sync for the CPU. More...
 
int NvBufferMemSyncForDevice (int dmabuf_fd, unsigned int plane, void **pVirtAddr)
 This method must be used for hw memory cache sync for device. More...
 
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. More...
 
int NvBufferMemUnMap (int dmabuf_fd, unsigned int plane, void **pVirtAddr)
 This method must be used to Unmap the mapped virtual Address of the plane. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Macro Definition Documentation

#define MAX_COMPOSITE_FRAME   16

Defines maximum number of input video frames can be used for composition.

Definition at line 45 of file nvbuf_utils.h.

#define MAX_NUM_PLANES   3

Defines maximum number of planes for video frame.

Definition at line 40 of file nvbuf_utils.h.

Typedef Documentation

Defines parameters related to composition/blending.

Defines input parameters for hardware buffer creation.

Defines parameters related to hardware buffer.

Defines parameters related to transform.

Enumeration Type Documentation

Defines color formats for NvBuffer.

Enumerator
NvBufferColorFormat_YUV420 

YUV420 multi-planar.

NvBufferColorFormat_YVU420 

YUV420 multi-planar.

NvBufferColorFormat_NV12 

Y/CbCr 4:2:0 multi-planar.

NvBufferColorFormat_NV21 

Y/CbCr 4:2:0 multi-planar.

NvBufferColorFormat_UYVY 

YUV 4:2:2 planar.

NvBufferColorFormat_VYUY 

YUV 4:2:2 planar.

NvBufferColorFormat_YUYV 

YUV 4:2:2 planar.

NvBufferColorFormat_YVYU 

YUV 4:2:2 planar.

NvBufferColorFormat_ABGR32 

BGRA-8-8-8-8 planar.

NvBufferColorFormat_XRGB32 

XRGB-8-8-8-8 planar.

NvBufferColorFormat_ARGB32 

ARGB-8-8-8-8 planar.

NvBufferColorFormat_Invalid 

Invalid color format.

Definition at line 104 of file nvbuf_utils.h.

Defines flags to indicate for valid composition/blending operation.

Enumerator
NVBUFFER_COMPOSITE 

flag to set for composition.

NVBUFFER_BLEND 

flag to set for blending.

Definition at line 191 of file nvbuf_utils.h.

Defines Layout formats for NvBuffer video planes.

Enumerator
NvBufferLayout_Pitch 

Pitch Layout.

NvBufferLayout_BlockLinear 

BlockLinear Layout.

Definition at line 61 of file nvbuf_utils.h.

Defines memory access flags for NvBuffer.

Enumerator
NvBufferMem_Read 

Memory read.

NvBufferMem_Write 

Memory write.

NvBufferMem_Read_Write 

Memory read & write.

Definition at line 72 of file nvbuf_utils.h.

Defines Payload type for NvBuffer.

Enumerator
NvBufferPayload_SurfArray 

buffer payload with HW memory handle for set of planes.

NvBufferPayload_MemHandle 

buffer payload with HW memory handle for specific memory size.

Definition at line 50 of file nvbuf_utils.h.

Defines tags to associate, while allocation of NvBuffer.

Enumerator
NvBufferTag_NONE 

tag None.

NvBufferTag_CAMERA 

tag for Camera.

NvBufferTag_JPEG 

tag for Jpeg Encoder/Decoder.

NvBufferTag_VIDEO_ENC 

tag for H264/H265 Video Encoder.

NvBufferTag_VIDEO_DEC 

tag for H264/H265/VP9 Video Decoder.

NvBufferTag_VIDEO_CONVERT 

tag for Video Transform/Composite.

Definition at line 85 of file nvbuf_utils.h.

Defines transform video filter types.

Enumerator
NvBufferTransform_Filter_Nearest 

transform filter nearest.

NvBufferTransform_Filter_Bilinear 

transform filter bilinear.

NvBufferTransform_Filter_5_Tap 

transform filter 5 tap.

NvBufferTransform_Filter_10_Tap 

transform filter 10 tap.

NvBufferTransform_Filter_Smart 

transform filter smart.

NvBufferTransform_Filter_Nicest 

transform filter nicest.

Definition at line 158 of file nvbuf_utils.h.

Defines flags to indicate for valid transform.

Enumerator
NVBUFFER_TRANSFORM_CROP_SRC 

transform flag to crop source rectangle.

NVBUFFER_TRANSFORM_CROP_DST 

transform flag to crop destination rectangle.

NVBUFFER_TRANSFORM_FILTER 

transform flag to set filter type.

NVBUFFER_TRANSFORM_FLIP 

transform flag to set flip method.

Definition at line 177 of file nvbuf_utils.h.

Defines video flip methods.

Enumerator
NvBufferTransform_None 

Video flip none.

NvBufferTransform_Rotate90 

Video flip rotate 90 degree clockwise.

NvBufferTransform_Rotate180 

Video flip rotate 180 degree clockwise.

NvBufferTransform_Rotate270 

Video flip rotate 270 degree clockwise.

NvBufferTransform_FlipX 

Video flip with respect to X-axis.

NvBufferTransform_FlipY 

Video flip with respect to Y-axis.

NvBufferTransform_Transpose 

Video flip transpose.

NvBufferTransform_InvTranspose 

Video flip inverse transpode.

Definition at line 135 of file nvbuf_utils.h.

Function Documentation

int ExtractFdFromNvBuffer ( void *  nvbuf,
int *  dmabuf_fd 
)

This method must be used to extract dmabuf_fd of the hardware buffer.

Parameters
[in]nvbufSpecifies the hw_buffer.
[out]dmabuf_fdReturns DMABUF FD of hw_buffer.
Returns
0 for success, -1 for failure.
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.

Parameters
[in]dmabuf_fdDMABUF FD of NvBuffer.
[in]planevideo frame plane.
[in]out_widthaligned width of the raw data plane.
[in]out_heightaligned height of the raw data plane.
[in]ptrpointer to the output raw plane data.
Returns
0 for success, -1 for failure.
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.

It can support composition of multiple input frames to one composited output.

Parameters
[in]src_dmabuf_fdsarray of DMABUF FDs of source buffers to composite from
[in]dst_dmabuf_fdDMABUF FD of destination buffer for composition
[in]composite_paramscomposition parameters
Returns
0 for sucess, -1 for failure.
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).

Parameters
[out]dmabuf_fdReturns dmabuf_fd of hardware buffer.
[in]widthHardware buffer width, in bytes.
[in]heightHardware buffer height, in bytes.
[in]layoutLayout of buffer.
[in]colorFormatThe colorFormat of buffer.
Returns
0 for success, -1 for failure
int NvBufferCreateEx ( int *  dmabuf_fd,
NvBufferCreateParams input_params 
)

Use this method to allocate HW buffer.

Parameters
[out]dmabuf_fdReturns dmabuf_fd of hardware buffer.
[in]input_paramsInput parameters for hardware buffer creation.
Returns
0 for success, -1 for failure
int NvBufferDestroy ( int  dmabuf_fd)

This method must be used for destroying hw_buffer.

Parameters
[in]dmabuf_fdSpecifies the dmabuf_fd hw_buffer to destroy.
Returns
0 for success, -1 for failure.
int NvBufferGetParams ( int  dmabuf_fd,
NvBufferParams params 
)

Use this method to get buffer parameters.

Parameters
[in]dmabuf_fdDMABUF FD of buffer.
[out]paramsA pointer to the structure to fill with parameters.
Returns
0 for success, -1 for failure.
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.

Parameters
[in]dmabuf_fdDMABUF FD of buffer.
[in]planevideo frame plane.(Applicale for NvBufferPayload_SurfArray)
[in]memflagNvBuffer memory flag.
[in]pVirtAddrVirtual Addres pointer of the mem mapped plane.
Returns
0 for success, -1 for failure.
int NvBufferMemSyncForCpu ( int  dmabuf_fd,
unsigned int  plane,
void **  pVirtAddr 
)

This method must be used for hw memory cache sync for the CPU.

Parameters
[in]dmabuf_fdDMABUF FD of buffer.
[in]planevideo frame plane.
[in]pVirtAddrVirtual Addres pointer of the mem mapped plane.
Returns
0 for success, -1 for failure.
int NvBufferMemSyncForDevice ( int  dmabuf_fd,
unsigned int  plane,
void **  pVirtAddr 
)

This method must be used for hw memory cache sync for device.

Parameters
[in]dmabuf_fdDMABUF FD of buffer.
[in]planevideo frame plane.
[in]pVirtAddrVirtual Addres pointer of the mem mapped plane.
Returns
0 for success, -1 for failure.
int NvBufferMemUnMap ( int  dmabuf_fd,
unsigned int  plane,
void **  pVirtAddr 
)

This method must be used to Unmap the mapped virtual Address of the plane.

Parameters
[in]dmabuf_fdDMABUF FD of buffer.
[in]planevideo frame plane.(Applicale for NvBufferPayload_SurfArray)
[in]pVirtAddrmem mapped Virtual Addres pointer of the plane.
Returns
0 for success, -1 for failure.
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.

It can support transforms for copying, scaling, fliping, rotation and cropping.

Parameters
[in]src_dmabuf_fdDMABUF FD of source buffer
[in]dst_dmabuf_fdDMABUF FD of destination buffer
[in]transform_paramstransform parameters
Returns
0 for sucess, -1 for failure.
int NvDestroyEGLImage ( EGLDisplay  display,
EGLImageKHR  eglImage 
)

This method must be used for destroying EGLImage object.

Parameters
[in]displayEGLDisplay object used for destroying EGLImage.
[in]eglImageEGLImageKHR object to be destroyed.
Returns
0 for success, -1 for failure
EGLImageKHR NvEGLImageFromFd ( EGLDisplay  display,
int  dmabuf_fd 
)

This method must be used for getting EGLImage from dmabuf-fd.

Parameters
[in]displayEGLDisplay object used during the creation of EGLImage.
[in]dmabuf_fdDMABUF FD of buffer from which EGLImage to be created.
Returns
EGLImageKHR for success, NULL for failure
int NvReleaseFd ( int  dmabuf_fd)

This method must be used for releasing dmabuf_fd.

Obtained using ExtractfdFromNvBuffer API.

Parameters
[in]dmabuf_fdSpecifies the dmabuf_fd to release.
Returns
0 for success, -1 for failure.
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.

Parameters
[in]ptrpointer to the input raw plane data.
[in]planevideo frame plane.
[in]in_widthaligned width of the raw data plane.
[in]in_heightaligned height of the raw data plane.
[in]dmabuf_fdDMABUF FD of NvBuffer.
Returns
0 for success, -1 for failure.