123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
-
- #ifndef NVBUFSURFACE_H_
- #define NVBUFSURFACE_H_
- #include <stdint.h>
- #include <stdbool.h>
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #define STRUCTURE_PADDING 4
- #define NVBUF_MAX_PLANES 4
- #define NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT 0
- #define NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT 1
- #define NVBUFSURFACE_CHROMA_SUBSAMPLING_PARAMS_DEFAULT \
- { \
- NVBUFSURFACE_CHROMA_SUBSAMPLING_HORIZ_DEFAULT, \
- NVBUFSURFACE_CHROMA_SUBSAMPLING_VERT_DEFAULT \
- }
- typedef enum
- {
- NVBUF_MAP_READ,
- NVBUF_MAP_WRITE,
- NVBUF_MAP_READ_WRITE,
- } NvBufSurfaceMemMapFlags;
- typedef enum
- {
-
- NvBufSurfaceTag_NONE = 0x0,
-
- NvBufSurfaceTag_CAMERA = 0x200,
-
- NvBufSurfaceTag_JPEG = 0x1500,
-
- NvBufSurfaceTag_PROTECTED = 0x1504,
-
- NvBufSurfaceTag_VIDEO_ENC = 0x1200,
-
- NvBufSurfaceTag_VIDEO_DEC = 0x1400,
-
- NvBufSurfaceTag_VIDEO_CONVERT = 0xf01,
- } NvBufSurfaceTag;
- typedef enum
- {
-
- NVBUF_COLOR_FORMAT_INVALID,
-
- NVBUF_COLOR_FORMAT_GRAY8,
-
- NVBUF_COLOR_FORMAT_YUV420,
-
- NVBUF_COLOR_FORMAT_YVU420,
-
- NVBUF_COLOR_FORMAT_YUV420_ER,
-
- NVBUF_COLOR_FORMAT_YVU420_ER,
-
- NVBUF_COLOR_FORMAT_NV12,
-
- NVBUF_COLOR_FORMAT_NV12_ER,
-
- NVBUF_COLOR_FORMAT_NV21,
-
- NVBUF_COLOR_FORMAT_NV21_ER,
-
- NVBUF_COLOR_FORMAT_UYVY,
-
- NVBUF_COLOR_FORMAT_UYVY_ER,
-
- NVBUF_COLOR_FORMAT_VYUY,
-
- NVBUF_COLOR_FORMAT_VYUY_ER,
-
- NVBUF_COLOR_FORMAT_YUYV,
-
- NVBUF_COLOR_FORMAT_YUYV_ER,
-
- NVBUF_COLOR_FORMAT_YVYU,
-
- NVBUF_COLOR_FORMAT_YVYU_ER,
-
- NVBUF_COLOR_FORMAT_YUV444,
-
- NVBUF_COLOR_FORMAT_RGBA,
-
- NVBUF_COLOR_FORMAT_BGRA,
-
- NVBUF_COLOR_FORMAT_ARGB,
-
- NVBUF_COLOR_FORMAT_ABGR,
-
- NVBUF_COLOR_FORMAT_RGBx,
-
- NVBUF_COLOR_FORMAT_BGRx,
-
- NVBUF_COLOR_FORMAT_xRGB,
-
- NVBUF_COLOR_FORMAT_xBGR,
-
- NVBUF_COLOR_FORMAT_RGB,
-
- NVBUF_COLOR_FORMAT_BGR,
-
- NVBUF_COLOR_FORMAT_NV12_10LE,
-
- NVBUF_COLOR_FORMAT_NV12_12LE,
-
- NVBUF_COLOR_FORMAT_YUV420_709,
-
- NVBUF_COLOR_FORMAT_YUV420_709_ER,
-
- NVBUF_COLOR_FORMAT_NV12_709,
-
- NVBUF_COLOR_FORMAT_NV12_709_ER,
-
- NVBUF_COLOR_FORMAT_YUV420_2020,
-
- NVBUF_COLOR_FORMAT_NV12_2020,
-
- NVBUF_COLOR_FORMAT_NV12_10LE_ER,
-
- NVBUF_COLOR_FORMAT_NV12_10LE_709,
-
- NVBUF_COLOR_FORMAT_NV12_10LE_709_ER,
-
- NVBUF_COLOR_FORMAT_NV12_10LE_2020,
-
- NVBUF_COLOR_FORMAT_SIGNED_R16G16,
-
- NVBUF_COLOR_FORMAT_R8_G8_B8,
-
- NVBUF_COLOR_FORMAT_B8_G8_R8,
-
- NVBUF_COLOR_FORMAT_R32F_G32F_B32F,
-
- NVBUF_COLOR_FORMAT_B32F_G32F_R32F,
-
- NVBUF_COLOR_FORMAT_YUV422,
-
- NVBUF_COLOR_FORMAT_NV21_10LE,
-
- NVBUF_COLOR_FORMAT_NV21_12LE,
-
- NVBUF_COLOR_FORMAT_NV12_12LE_2020,
-
- NVBUF_COLOR_FORMAT_NV16,
-
- NVBUF_COLOR_FORMAT_NV16_10LE,
-
- NVBUF_COLOR_FORMAT_NV24,
-
- NVBUF_COLOR_FORMAT_NV24_10LE,
-
- NVBUF_COLOR_FORMAT_NV16_ER,
-
- NVBUF_COLOR_FORMAT_NV24_ER,
-
- NVBUF_COLOR_FORMAT_NV16_709,
-
- NVBUF_COLOR_FORMAT_NV24_709,
-
- NVBUF_COLOR_FORMAT_NV16_709_ER,
-
- NVBUF_COLOR_FORMAT_NV24_709_ER,
-
- NVBUF_COLOR_FORMAT_NV24_10LE_709,
-
- NVBUF_COLOR_FORMAT_NV24_10LE_709_ER,
-
- NVBUF_COLOR_FORMAT_NV24_10LE_2020,
-
- NVBUF_COLOR_FORMAT_NV24_12LE_2020,
-
- NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_709,
-
- NVBUF_COLOR_FORMAT_RGBA_10_10_10_2_2020,
-
- NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_709,
-
- NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_2020,
-
- NVBUF_COLOR_FORMAT_A32,
-
- NVBUF_COLOR_FORMAT_UYVP,
-
- NVBUF_COLOR_FORMAT_UYVP_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_709,
-
- NVBUF_COLOR_FORMAT_YUV444_709_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_2020,
-
- NVBUF_COLOR_FORMAT_YUV444_10LE,
-
- NVBUF_COLOR_FORMAT_YUV444_10LE_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_10LE_709,
-
- NVBUF_COLOR_FORMAT_YUV444_10LE_709_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_10LE_2020,
-
- NVBUF_COLOR_FORMAT_YUV444_12LE,
-
- NVBUF_COLOR_FORMAT_YUV444_12LE_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_12LE_709,
-
- NVBUF_COLOR_FORMAT_YUV444_12LE_709_ER,
-
- NVBUF_COLOR_FORMAT_YUV444_12LE_2020,
-
- NVBUF_COLOR_FORMAT_NV12_12LE_ER,
-
- NVBUF_COLOR_FORMAT_NV12_12LE_709,
-
- NVBUF_COLOR_FORMAT_NV12_12LE_709_ER,
- NVBUF_COLOR_FORMAT_LAST
- } NvBufSurfaceColorFormat;
- typedef enum
- {
-
- NVBUF_LAYOUT_PITCH,
-
- NVBUF_LAYOUT_BLOCK_LINEAR,
- } NvBufSurfaceLayout;
- typedef enum
- {
-
- NVBUF_MEM_DEFAULT,
-
- NVBUF_MEM_CUDA_PINNED,
-
- NVBUF_MEM_CUDA_DEVICE,
-
- NVBUF_MEM_CUDA_UNIFIED,
-
- NVBUF_MEM_SURFACE_ARRAY,
-
- NVBUF_MEM_HANDLE,
-
- NVBUF_MEM_SYSTEM,
- } NvBufSurfaceMemType;
- typedef enum
- {
-
- NVBUF_DISPLAYSCANFORMAT_PROGRESSIVE,
-
- NVBUF_DISPLAYSCANFORMAT_INTERLACED,
- } NvBufSurfaceDisplayScanFormat;
- typedef struct NvBufSurfacePlaneParamsEx
- {
-
- NvBufSurfaceDisplayScanFormat scanformat[NVBUF_MAX_PLANES];
-
- uint32_t secondfieldoffset[NVBUF_MAX_PLANES];
-
- uint32_t blockheightlog2[NVBUF_MAX_PLANES];
-
- uint32_t physicaladdress[NVBUF_MAX_PLANES];
-
- uint64_t flags[NVBUF_MAX_PLANES];
- void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
- } NvBufSurfacePlaneParamsEx;
- typedef struct NvBufSurfacePlaneParams
- {
-
- uint32_t num_planes;
-
- uint32_t width[NVBUF_MAX_PLANES];
-
- uint32_t height[NVBUF_MAX_PLANES];
-
- uint32_t pitch[NVBUF_MAX_PLANES];
-
- uint32_t offset[NVBUF_MAX_PLANES];
-
- uint32_t psize[NVBUF_MAX_PLANES];
-
- uint32_t bytesPerPix[NVBUF_MAX_PLANES];
- void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
- } NvBufSurfacePlaneParams;
- typedef struct NvBufSurfaceChromaSubsamplingParams
- {
-
- uint8_t chromaLocHoriz;
- uint8_t chromaLocVert;
- } NvBufSurfaceChromaSubsamplingParams;
- typedef struct NvBufSurfaceCreateParams {
-
- uint32_t gpuId;
-
- uint32_t width;
-
- uint32_t height;
-
- uint32_t size;
-
- bool isContiguous;
-
- NvBufSurfaceColorFormat colorFormat;
-
- NvBufSurfaceLayout layout;
-
- NvBufSurfaceMemType memType;
- } NvBufSurfaceCreateParams;
- typedef struct NvBufSurfaceAllocateParams {
-
- NvBufSurfaceCreateParams params;
-
- NvBufSurfaceDisplayScanFormat displayscanformat;
-
- NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
-
- NvBufSurfaceTag memtag;
-
- bool disablePitchPadding;
-
- uint32_t _reservedParam;
- void * _reserved[STRUCTURE_PADDING-1];
- } NvBufSurfaceAllocateParams;
- typedef struct NvBufSurfaceMappedAddr {
-
- void * addr[NVBUF_MAX_PLANES];
-
- void *eglImage;
- void * _reserved[STRUCTURE_PADDING];
- } NvBufSurfaceMappedAddr;
- typedef struct NvBufSurfaceParamsEx {
-
- int32_t startofvaliddata;
-
- int32_t sizeofvaliddatainbytes;
-
- NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
-
- bool is_protected;
-
- NvBufSurfacePlaneParamsEx planeParamsex;
- void * _reserved[STRUCTURE_PADDING];
- } NvBufSurfaceParamsEx;
- typedef struct NvBufSurfaceParams {
-
- uint32_t width;
-
- uint32_t height;
-
- uint32_t pitch;
-
- NvBufSurfaceColorFormat colorFormat;
-
- NvBufSurfaceLayout layout;
-
- uint64_t bufferDesc;
-
- uint32_t dataSize;
-
- void * dataPtr;
-
- NvBufSurfacePlaneParams planeParams;
-
- NvBufSurfaceMappedAddr mappedAddr;
-
- NvBufSurfaceParamsEx *paramex;
- void * _reserved[STRUCTURE_PADDING - 1];
- } NvBufSurfaceParams;
- typedef struct NvBufSurface {
-
- uint32_t gpuId;
-
- uint32_t batchSize;
-
- uint32_t numFilled;
-
- bool isContiguous;
-
- NvBufSurfaceMemType memType;
-
- NvBufSurfaceParams *surfaceList;
- void * _reserved[STRUCTURE_PADDING];
- } NvBufSurface;
- typedef struct NvBufSurfaceMapPlaneParams
- {
-
- uint32_t width;
-
- uint32_t height;
-
- uint32_t pitch;
-
- uint32_t offset;
-
- uint32_t psize;
-
- uint32_t secondfieldoffset;
-
- uint32_t blockheightlog2;
-
- uint64_t flags;
-
- uint8_t reserved[64];
- } NvBufSurfaceMapPlaneParams;
- typedef struct NvBufSurfaceMapParams {
-
- uint32_t num_planes;
-
- uint32_t gpuId;
-
- uint64_t fd;
-
- uint32_t totalSize;
-
- NvBufSurfaceMemType memType;
-
- NvBufSurfaceLayout layout;
-
- NvBufSurfaceDisplayScanFormat scanformat;
-
- NvBufSurfaceColorFormat colorFormat;
-
- NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
-
- NvBufSurfaceMapPlaneParams planes[NVBUF_MAX_PLANES];
-
- uint8_t reserved[64];
- } NvBufSurfaceMapParams;
- int NvBufSurfaceCreate (NvBufSurface **surf, uint32_t batchSize,
- NvBufSurfaceCreateParams *params);
- int NvBufSurfaceAllocate (NvBufSurface **surf, uint32_t batchSize,
- NvBufSurfaceAllocateParams *paramsext);
- int NvBufSurfaceDestroy (NvBufSurface *surf);
- int NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type);
- int NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane);
- int NvBufSurfaceCopy (NvBufSurface *srcSurf, NvBufSurface *dstSurf);
- int NvBufSurface2Raw (NvBufSurface *Surf, unsigned int index, unsigned int plane, unsigned int outwidth, unsigned int outheight, unsigned char *ptr);
- int Raw2NvBufSurface (unsigned char *ptr, unsigned int index, unsigned int plane, unsigned int inwidth, unsigned int inheight, NvBufSurface *Surf);
- int NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane);
- int NvBufSurfaceSyncForDevice (NvBufSurface *surf, int index, int plane);
- int NvBufSurfaceFromFd (int dmabuf_fd, void **buffer);
- int NvBufSurfaceMemSet (NvBufSurface *surf, int index, int plane, uint8_t value);
- int NvBufSurfaceMapEglImage (NvBufSurface *surf, int index);
- int NvBufSurfaceUnMapEglImage (NvBufSurface *surf, int index);
- int NvBufSurfaceImport (NvBufSurface **out_nvbuf_surf, const NvBufSurfaceMapParams *in_params);
- int NvBufSurfaceGetMapParams (const NvBufSurface *surf, int index, NvBufSurfaceMapParams *params);
- #ifdef __cplusplus
- }
- #endif
- #endif
|