- Main Page
- Modules
- Namespaces
- Classes
- Files

- Search for |

- File List
- File Members

# include/nvbuf_utils.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
    00003  *
    00004  * NVIDIA Corporation and its licensors retain all intellectual property
    00005  * and proprietary rights in and to this software, related documentation
    00006  * and any modifications thereto.  Any use, reproduction, disclosure or
    00007  * distribution of this software and related documentation without an express
    00008  * license agreement from NVIDIA Corporation is strictly prohibited.
    00009  */
    00010
    00011 /**
    00012 * @file nvbuf_utils.h
    00013 * @brief NVBUF Utils library to be used by applications
    00014 */
    00015
    00016 #ifndef _NVBUF_UTILS_H_
    00017 #define _NVBUF_UTILS_H_
    00018
    00019 #ifdef __cplusplus
    00020 extern "C"
    00021 {
    00022 #endif
    00023
    00024 #include <EGL/egl.h>
    00025 #include <EGL/eglext.h>
    00026 #include <errno.h>
    00027
    00028 #define MAX_NUM_PLANES 3
    00029
    00030 typedef enum
    00031 {
    00032   NvBufferLayout_Pitch,
    00033   NvBufferLayout_BlockLinear,
    00034 } NvBufferLayout;
    00035
    00036 typedef enum
    00037 {
    00038   NvBufferColorFormat_YUV420,
    00039   NvBufferColorFormat_YVU420,
    00040   NvBufferColorFormat_NV12,
    00041   NvBufferColorFormat_NV21,
    00042   NvBufferColorFormat_UYVY,
    00043   NvBufferColorFormat_ABGR32,
    00044   NvBufferColorFormat_XRGB32,
    00045   NvBufferColorFormat_Invalid,
    00046 } NvBufferColorFormat;
    00047
    00048 typedef struct _NvBufferParams
    00049 {
    00050   uint32_t dmabuf_fd;
    00051   void *nv_buffer;
    00052   uint32_t nv_buffer_size;
    00053   uint32_t pixel_format;
    00054   uint32_t num_planes;
    00055   uint32_t width[MAX_NUM_PLANES];
    00056   uint32_t height[MAX_NUM_PLANES];
    00057   uint32_t pitch[MAX_NUM_PLANES];
    00058   uint32_t offset[MAX_NUM_PLANES];
    00059 }NvBufferParams;
    00060
    00061 /**
    00062 * This method should be used for getting EGLImage from dmabuf-fd
    00063 * @param[in] display EGLDisplay object used during creation of EGLImage
    00064 * @param[in] dmabuf_fd DMABUF FD of buffer from which EGLImage to be created
    00065 *
    00066 * @returns EGLImageKHR for success, NULL for failure
    00067 */
    00068 EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);
    00069
    00070 /**
    00071 * This method should be used for destroying EGLImage object
    00072 * @param[in] display EGLDisplay object used for destroying EGLImage
    00073 * @param[in] eglImage EGLImageKHR object to be destroyed
    00074 *
    00075 * @returns 0 for success, -1 for failure
    00076 */
    00077 int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);
    00078
    00079 /**
    00080  * This method can be used to allocate hw buffer.
    00081  * @param[out] dmabuf_fd returns dmabuf_fd of hardware buffer
    00082  * @param[in] width hardware buffer width in bytes
    00083  * @param[in] height hardware buffer height in bytes
    00084  * @param[in] layout layout of buffer
    00085  * @param[in] colorFormat colorFormat of buffer
    00086  *
    00087  * @returns 0 for success, -1 for failure
    00088  */
    00089 int NvBufferCreate (int *dmabuf_fd, int width, int height,
    00090     NvBufferLayout layout, NvBufferColorFormat colorFormat);
    00091
    00092 /**
    00093  * This method can be used to get buffer parameters.
    00094  * @param[in] dmabuf_fd DMABUF FD of buffer
    00095  * @param[out] params structure which will be filled with parameters.
    00096  *
    00097  * @returns 0 for success, -1 for failure.
    00098  */
    00099 int NvBufferGetParams (int dmabuf_fd, NvBufferParams *params);
    00100
    00101 /**
    00102 * This method should be used for destroying hw_buffer
    00103 * @param[in] dmabuf_fd dmabuf_fd hw_buffer to be destroyed
    00104 *
    00105 * @returns 0 for success, -1 for failure
    00106 */
    00107 int NvBufferDestroy (int dmabuf_fd);
    00108
    00109 #ifdef __cplusplus
    00110 }
    00111 #endif
    00112
    00113 #endif