# include/nvbuf_utils.h File Reference

NVBUF Utils library to be used by applications. More...

`#include <EGL/egl.h>`
`#include <EGL/eglext.h>`
`#include <errno.h>`

Go to the source code of this file.

## Classes

struct | _NvBufferParams

## Defines

#define | MAX_NUM_PLANES 3

## Typedefs

typedef struct _NvBufferParams | NvBufferParams

## Enumerations

enum | NvBufferLayout { NvBufferLayout_Pitch, NvBufferLayout_BlockLinear }
enum | NvBufferColorFormat { NvBufferColorFormat_YUV420, NvBufferColorFormat_YVU420, NvBufferColorFormat_NV12, NvBufferColorFormat_NV21, NvBufferColorFormat_UYVY, NvBufferColorFormat_ABGR32, NvBufferColorFormat_XRGB32, NvBufferColorFormat_Invalid }

## Functions

EGLImageKHR | NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd)
| This method should be used for getting EGLImage from dmabuf-fd.
int | NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage)
| This method should be used for destroying EGLImage object.
int | NvBufferCreate (int *dmabuf_fd, int width, int height, NvBufferLayout layout, NvBufferColorFormat colorFormat)
| This method can be used to allocate hw buffer.
int | NvBufferGetParams (int dmabuf_fd, NvBufferParams *params)
| This method can be used to get buffer parameters.
int | NvBufferDestroy (int dmabuf_fd)
| This method should be used for destroying hw_buffer.

## Detailed Description

NVBUF Utils library to be used by applications.

Definition in file nvbuf_utils.h.

## Define Documentation

#define MAX_NUM_PLANES 3

Definition at line 28 of file nvbuf_utils.h.

## Typedef Documentation

typedef struct _NvBufferParams NvBufferParams

## Enumeration Type Documentation

enum NvBufferColorFormat

Enumerator:

  NvBufferColorFormat_YUV420 |
  NvBufferColorFormat_YVU420 |
  NvBufferColorFormat_NV12 |
  NvBufferColorFormat_NV21 |
  NvBufferColorFormat_UYVY |
  NvBufferColorFormat_ABGR32 |
  NvBufferColorFormat_XRGB32 |
  NvBufferColorFormat_Invalid |

Definition at line 36 of file nvbuf_utils.h.

enum NvBufferLayout

Enumerator:

  NvBufferLayout_Pitch |
  NvBufferLayout_BlockLinear |

Definition at line 30 of file nvbuf_utils.h.

## Function Documentation

int NvBufferCreate | ( | int * | dmabuf_fd,
|  | int | width,
|  | int | height,
|  | NvBufferLayout | layout,
|  | NvBufferColorFormat | colorFormat |
| ) |  |  |

This method can be used to allocate hw buffer.

Parameters:

  `[out]` | dmabuf_fd | returns dmabuf_fd of hardware buffer
  `[in]` | width | hardware buffer width in bytes
  `[in]` | height | hardware buffer height in bytes
  `[in]` | layout | layout of buffer
  `[in]` | colorFormat | colorFormat of buffer

Returns:
  0 for success, -1 for failure

int NvBufferDestroy | ( | int | dmabuf_fd | ) |

This method should be used for destroying hw_buffer.

Parameters:

  `[in]` | dmabuf_fd | dmabuf_fd hw_buffer to be destroyed

Returns:
  0 for success, -1 for failure

int NvBufferGetParams | ( | int | dmabuf_fd,
|  | NvBufferParams * | params |
| ) |  |  |

This method can be used to get buffer parameters.

Parameters:

  `[in]` | dmabuf_fd | DMABUF FD of buffer
  `[out]` | params | structure which will be filled with parameters.

Returns:
  0 for success, -1 for failure.

int NvDestroyEGLImage | ( | EGLDisplay | display,
|  | EGLImageKHR | eglImage |
| ) |  |  |

This method should be used for destroying EGLImage object.

Parameters:

  `[in]` | display | EGLDisplay object used for destroying EGLImage
  `[in]` | eglImage | EGLImageKHR object to be destroyed

Returns:
  0 for success, -1 for failure

EGLImageKHR NvEGLImageFromFd | ( | EGLDisplay | display,
|  | int | dmabuf_fd |
| ) |  |  |

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

Parameters:

  `[in]` | display | EGLDisplay object used during creation of EGLImage
  `[in]` | dmabuf_fd | DMABUF FD of buffer from which EGLImage to be created

Returns:
  EGLImageKHR for success, NULL for failure