25 #ifndef _NVBUF_UTILS_H_
26 #define _NVBUF_UTILS_H_
34 #include <EGL/eglext.h>
41 #define MAX_NUM_PLANES 4
46 #define MAX_COMPOSITE_FRAME 16
52 #define NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0
53 #define NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT 1
58 #define NVBUF_MAX_SYNCOBJ_PARAMS 5
66 #define NVBUFFER_SYNCPOINT_WAIT_INFINITE 0xFFFFFFFF
394 #define NVBUF_CHROMA_SUBSAMPLING_PARAMS_DEFAULT \
396 NVBUF_CHROMA_SUBSAMPLING_HORIZ_DEFAULT, \
397 NVBUF_CHROMA_SUBSAMPLING_VERT_DEFAULT \
813 int NvBuffer2Raw (
int dmabuf_fd,
unsigned int plane,
unsigned int out_width,
unsigned int out_height,
unsigned char *ptr);
825 int Raw2NvBuffer (
unsigned char *ptr,
unsigned int plane,
unsigned int in_width,
unsigned int in_height,
int dmabuf_fd);
uint32_t layout[MAX_NUM_PLANES]
layout type of each planes of hardware buffer.
uint32_t num_planes
number of planes of hardware buffer.
NvBufferParams params
nvbuffer basic parameters.
int ExtractFdFromNvBuffer(void *nvbuf, int *dmabuf_fd)
Extracts the dmabuf_fd from the hardware buffer.
NvBufferColorFormat pixel_format
video format type of hardware buffer.
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
uint32_t left
rectangle left.
NvBufferRect src_comp_rect[MAX_COMPOSITE_FRAME]
source rectangle coordinates of input buffers for composition.
void * reserved
reserved field.
bool is_protected
get buffer vpr information.
NvBufferSyncObj syncobj
buffer sync point object parameters
BT.601 colorspace - YUV 4:2:2 planar.
BT.601 colorspace - YUV444 multi-planar.
struct _NvBufferParamsEx NvBufferParamsEx
Holds extended parameters for a hardware buffer.
tag for H264/H265/VP9 Video Decoder.
transform flag to set flip method.
float g
background color value for g.
uint32_t psize[MAX_NUM_PLANES]
size of each vodeo planes of hardware buffer.
transform flag to set filter type.
struct _NvBufferChromaSubSamplingParams NvBufferChromaSubsamplingParams
Holds Chroma Subsampling parameters.
int NvReleaseFd(int dmabuf_fd)
Releases the dmabuf_fd buffer.
flag to set for composition.
struct _NvBufferSyncObjParams NvBufferSyncObjParams
Holds parameters for buffer sync point object.
transform flag to crop source rectangle.
Video flip rotate 270 degree counter-clockwise.
Video flip with respect to Y-axis.
LegacyRGBA colorspace - BGRA-8-8-8-8 planar.
int32_t sizeofvaliddatainbytes
size of the valid data from the first to the last valid byte.
Non-linear RGB BT.2020 colorspace - BGRA-10-10-10-2 planar.
uint32_t input_buf_count
number of the input buffers to be composited.
tag for Video Transform/Composite.
int32_t memsize
size of the memory.
Video flip inverse transpode.
BT.601 colorspace - Y/CbCr 4:4:4 multi-planar.
Non-linear RGB BT.709 colorspace - RGBA-10-10-10-2 planar.
NvBufferRect dst_comp_rect[MAX_COMPOSITE_FRAME]
destination rectangle coordinates of input buffers for composition.
BT.709 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.
int32_t width
width of the buffer.
Video flip rotate 180 degree.
Holds composition background r,g,b colors.
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.
uint32_t physicaladdress[MAX_NUM_PLANES]
physical address of allocated planes.
BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
struct _NvBufferCreateParams NvBufferCreateParams
Holds the input parameters for hardware buffer creation.
BT.601 colorspace - Y/CrCb 4:2:0 10-bit multi-planar.
BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
transform filter bilinear.
LegacyRGBA colorspace - XRGB-8-8-8-8 planar.
LegacyRGBA colorspace - ARGB-8-8-8-8 planar.
int NvBufferGetParamsEx(int dmabuf_fd, NvBufferParamsEx *exparams)
Gets buffer extended parameters.
buffer payload with hardware memory handle for specific memory size.
uint32_t secondfieldoffset[MAX_NUM_PLANES]
offset of the second field for interlaced buffer.
Holds parameters for a hardware buffer.
uint32_t nv_buffer_size
size of hardware buffer.
Holds Chroma Subsampling parameters.
BT.709_ER colorspace - Y/CbCr 4:4:4 multi-planar.
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.
transform filter nearest.
uint32_t composite_flag
flag to indicate which of the composition/blending parameters are valid.
uint32_t height
rectangle height.
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.
int NvBufferMemUnMapEx(int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr)
Unmaps the mapped virtual address of the plane, API to be used for another process.
NvBufferTransform_Filter composite_filter[MAX_COMPOSITE_FRAME]
filters to use for composition.
NvBufferTransform_Flag
Defines flags to indicate for valid transform.
int NvBufferMemSyncForCpu(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the hardware memory cache for the CPU.
NvBufferComposite_Flag
Defines flags that specify valid composition/blending operations.
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.
BT.601 colorspace - YUV 4:2:2 planar.
composition flag to set filter type.
NvBufferChromaSubsamplingParams chromaSubsampling
chroma subsampling parameters
uint32_t width
rectangle width.
int NvBufferMemSyncForCpuEx(int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr)
Syncs the hardware memory cache for the CPU, API to be used for another process.
BT.601 colorspace - YUV ER 4:2:2 planar.
NvBufferTag
Defines tags that identify the components requesting a memory allocation.
BT.2020 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
NvBufferSession NvBufferSessionCreate(void)
Creates a new NvBufferSession for parallel scheduling of buffer transformations and compositions...
float b
background color value for b.
#define MAX_NUM_PLANES
Defines the maximum number of planes for a video frame.
BT.601 colorspace - YVU420 ER multi-planar.
NvBufferColorFormat colorFormat
colorformat of the buffer.
BT.601 colorspace - YUV420 multi-planar.
struct _NvBufferCompositeParams NvBufferCompositeParams
Holds parameters related to compositing/blending.
Non-linear RGB BT.709 colorspace - BGRA-10-10-10-2 planar.
NvBufferCompositeBackground composite_bgcolor
background color values for composition.
NvBufferSyncObjParams insyncobj[NVBUF_MAX_SYNCOBJ_PARAMS]
BT.2020 colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.
BT.709_ER colorspace - Y/CbCr 4:2:2 multi-planar.
int32_t startofvaliddata
offset in bytes from the start of the buffer to the first valid byte.
float dst_comp_rect_alpha[MAX_COMPOSITE_FRAME]
alpha values of input buffers for the blending.
NvBufferDisplayScanFormat scanformat[MAX_NUM_PLANES]
display scan format - progressive/interlaced.
int NvBufferCreateInterlace(int *dmabuf_fd, NvBufferCreateParams *input_params)
Allocates a hardware buffer for interlace scan format.
int NvBufferMemSyncForDeviceEx(int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, void **pVirtAddr)
Syncs the hardware memory cache for the device, API to be used for another process.
NvBufferPayloadType payloadType
payload type of the buffer.
Holds extended parameters for a hardware buffer.
uint32_t height[MAX_NUM_PLANES]
height of each planes of hardware buffer.
#define NVBUF_MAX_SYNCOBJ_PARAMS
Defines the maximum number of sync object parameters.
tag for Jpeg Encoder/Decoder.
struct _NvBufferParams NvBufferParams
Holds parameters for a hardware buffer.
int NvBufferMemSyncForDevice(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the hardware memory cache for the device.
uint32_t blockheightlog2[MAX_NUM_PLANES]
block height of the planes for blockLinear layout hardware buffer.
uint32_t width[MAX_NUM_PLANES]
width of each planes of hardware buffer.
Holds parameters for buffer sync point object.
uint32_t pitch[MAX_NUM_PLANES]
pitch of each planes of hardware buffer.
NvBufferDisplayScanFormat
Defines display scan formats for NvBuffer video planes.
BT.709 ER colorspace - Y/CbCr 10 bit 4:4:4 multi-planar.
int NvBufferCreate(int *dmabuf_fd, int width, int height, NvBufferLayout layout, NvBufferColorFormat colorFormat)
Allocates a hardware buffer (deprecated).
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
Creates an instance of EGLImage from a DMABUF FD.
BT.601 colorspace - YUV420 ER multi-planar.
uint32_t dmabuf_fd
Holds the DMABUF FD of the hardware buffer.
BT.601 colorspace - YUV ER 4:2:2 planar.
int NvBufferCreateWithChromaLoc(int *dmabuf_fd, NvBufferCreateParams *input_params, NvBufferChromaSubsamplingParams *chromaSubsampling)
Allocates a hardware buffer with a given chroma subsampling location.
BT.709 colorspace - YUV420 ER multi-planar.
uint32_t offset[MAX_NUM_PLANES]
memory offset values of each video planes of hardware buffer.
buffer payload with hardware memory handle for set of planes.
BT.601 colorspace - Y/CrCb 4:4:4 10-bit multi-planar.
BT.601 colorspace - YUV420 multi-planar.
uint32_t top
rectangle top.
int32_t memsize
size of the memory.
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 hardware Buffer struct size.
Video flip with respect to X-axis.
BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar.
uint64_t flags[MAX_NUM_PLANES]
flags associated with planes
void * nv_buffer
pointer to hardware buffer memory.
void NvBufferSessionDestroy(NvBufferSession session)
Destroys an existing NvBufferSession.
Holds the input parameters for hardware buffer creation.
int NvBufferTransformEx(int src_dmabuf_fd, NvBufferParamsEx *input_params, int dst_dmabuf_fd, NvBufferParamsEx *output_params, NvBufferTransformParams *transform_params)
Transforms one DMA buffer to another DMA buffer, API to be used for another process.
Non-linear RGB BT.2020 colorspace - RGBA-10-10-10-2 planar.
int NvBufferGetParams(int dmabuf_fd, NvBufferParams *params)
Gets buffer parameters.
NvBufferPayloadType
Defines Payload types for NvBuffer.
uint8_t chromaLocHoriz
location settings
int NvBufferTransformAsync(int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params, NvBufferSyncObj *syncobj)
Transforms one DMA buffer to another DMA buffer asyncroniously (non-blocking).
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.
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
NvBufferTransform_Filter
Defines transform video filter types.
BT.601 colorspace - Y/CbCr ER 4:2:0 multi-planar.
BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
BT.601 colorspace - Y/CbCr 4:2:0 12-bit multi-planar.
buffer sync point object.
BT.601 colorspace - Y/CrCb 4:2:0 12-bit multi-planar.
BT.601_ER colorspace - Y/CbCr 4:4:4 multi-planar.
BT.709 colorspace - YUV420 multi-planar.
NvBufferLayout layout
layout of the buffer.
NvBufferTag nvbuf_tag
tag to associate with the buffer.
BT.601 colorspace - Y/CbCr 4:2:2 multi-planar.
float r
background color value for r.
struct _NvBufferSyncObjRec NvBufferSyncObj
buffer sync point object.
BT.601_ER colorspace - Y/CbCr 4:2:2 multi-planar.
BT.601 colorspace - YUV 4:2:2 planar.
struct _NvBufferTransformParams NvBufferTransformParams
Holds parameters for buffer transform functions.
transform flag to crop destination rectangle.
BT.2020 colorspace - Y/CbCr 12 bit 4:4:4 multi-planar.
BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
Optical flow SAD calculation Buffer format.
NvBufferPayloadType payloadType
payload type of the buffer.
BT.709 colorspace - Y/CbCr 4:2:2 multi-planar.
NvBufferSyncObjParams outsyncobj
BT.2020 colorspace - Y/CbCr 4:2:0 multi-planar.
NvBufferTransform_Flip
Defines video flip methods.
BT.601 colorspace - YUV 4:2:2 planar.
BT.601 colorspace - Y/CbCr 4:2:2 10-bit semi-planar.
void * payloadmetaInfo
metadata associated with the hardware buffer.
NvBufferLayout
Defines Layout formats for NvBuffer video planes.
tag for H264/H265 Video Encoder.
int NvBufferDestroy(int dmabuf_fd)
Destroys a hardware buffer.
int NvBufferMemMapEx(int dmabuf_fd, NvBufferParamsEx *exparams, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr)
Gets the memory-mapped virtual address of the plane, API to be used for another process.
int NvBufferCreateEx(int *dmabuf_fd, NvBufferCreateParams *input_params)
Allocates a hardware buffer.
Holds coordinates for a rectangle.
NvBufferColorFormat
Defines color formats for NvBuffer.
Holds parameters related to compositing/blending.
Video flip rotate 90 degree counter-clockwise.
BT.709_ER colorspace - Y/CbCr 4:2:0 10-bit multi-planar.
struct _NvBufferSession * NvBufferSession
Holds an opaque NvBuffer session type required for parallel buffer tranformations and compositions...
BT.2020 colorspace - YUV420 multi-planar.
int NvBufferSyncObjWait(NvBufferSyncObjParams *syncobj_params, unsigned int timeout)
This method can be used to wait on sync point ID.
BT.709 colorspace - Y/CbCr 4:4:4 multi-planar.
BT.601 colorspace - YUV422 multi-planar.
BT.601 colorspace - YUV ER 4:2:2 planar.
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
Destroys an EGLImage object.
NvBufferSession session
NvBufferSession to be used for composition.
flag to set for blending.
NvBufferMemFlags
Defines memory access flags for NvBuffer.
#define MAX_COMPOSITE_FRAME
Defines the maximum number of input video frames that can be used for composition.