|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __VPU_API_H__ |
|
#define __VPU_API_H__ |
|
|
|
#include "rk_type.h" |
|
#include "mpp_err.h" |
|
|
|
|
|
|
|
|
|
|
|
#define VPU_API_NOPTS_VALUE (0x8000000000000000LL) |
|
|
|
|
|
|
|
|
|
#define VPU_OUTPUT_FORMAT_TYPE_MASK (0x0000ffff) |
|
#define VPU_OUTPUT_FORMAT_ARGB8888 (0x00000000) |
|
#define VPU_OUTPUT_FORMAT_ABGR8888 (0x00000001) |
|
#define VPU_OUTPUT_FORMAT_RGB888 (0x00000002) |
|
#define VPU_OUTPUT_FORMAT_RGB565 (0x00000003) |
|
#define VPU_OUTPUT_FORMAT_RGB555 (0x00000004) |
|
#define VPU_OUTPUT_FORMAT_YUV420_SEMIPLANAR (0x00000005) |
|
#define VPU_OUTPUT_FORMAT_YUV420_PLANAR (0x00000006) |
|
#define VPU_OUTPUT_FORMAT_YUV422 (0x00000007) |
|
#define VPU_OUTPUT_FORMAT_YUV444 (0x00000008) |
|
#define VPU_OUTPUT_FORMAT_YCH420 (0x00000009) |
|
#define VPU_OUTPUT_FORMAT_BIT_MASK (0x000f0000) |
|
#define VPU_OUTPUT_FORMAT_BIT_8 (0x00000000) |
|
#define VPU_OUTPUT_FORMAT_BIT_10 (0x00010000) |
|
#define VPU_OUTPUT_FORMAT_BIT_12 (0x00020000) |
|
#define VPU_OUTPUT_FORMAT_BIT_14 (0x00030000) |
|
#define VPU_OUTPUT_FORMAT_BIT_16 (0x00040000) |
|
#define VPU_OUTPUT_FORMAT_FBC_MASK (0x00f00000) |
|
#define VPU_OUTPUT_FORMAT_FBC_AFBC_V1 (0x00100000) |
|
#define VPU_OUTPUT_FORMAT_FBC_AFBC_V2 (0x00200000) |
|
#define VPU_OUTPUT_FORMAT_DYNCRANGE_MASK (0x0f000000) |
|
#define VPU_OUTPUT_FORMAT_DYNCRANGE_SDR (0x00000000) |
|
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR10 (0x01000000) |
|
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_HLG (0x02000000) |
|
#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_DOLBY (0x03000000) |
|
|
|
|
|
|
|
|
|
typedef enum { |
|
ENC_INPUT_YUV420_PLANAR = 0, |
|
ENC_INPUT_YUV420_SEMIPLANAR = 1, |
|
ENC_INPUT_YUV422_INTERLEAVED_YUYV = 2, |
|
ENC_INPUT_YUV422_INTERLEAVED_UYVY = 3, |
|
ENC_INPUT_RGB565 = 4, |
|
ENC_INPUT_BGR565 = 5, |
|
ENC_INPUT_RGB555 = 6, |
|
ENC_INPUT_BGR555 = 7, |
|
ENC_INPUT_RGB444 = 8, |
|
ENC_INPUT_BGR444 = 9, |
|
ENC_INPUT_RGB888 = 10, |
|
ENC_INPUT_BGR888 = 11, |
|
ENC_INPUT_RGB101010 = 12, |
|
ENC_INPUT_BGR101010 = 13 |
|
} EncInputPictureType; |
|
|
|
typedef enum VPU_API_CMD { |
|
VPU_API_ENC_SETCFG, |
|
VPU_API_ENC_GETCFG, |
|
VPU_API_ENC_SETFORMAT, |
|
VPU_API_ENC_SETIDRFRAME, |
|
|
|
VPU_API_ENABLE_DEINTERLACE, |
|
VPU_API_SET_VPUMEM_CONTEXT, |
|
VPU_API_USE_PRESENT_TIME_ORDER, |
|
VPU_API_SET_DEFAULT_WIDTH_HEIGH, |
|
VPU_API_SET_INFO_CHANGE, |
|
VPU_API_USE_FAST_MODE, |
|
VPU_API_DEC_GET_STREAM_COUNT, |
|
VPU_API_GET_VPUMEM_USED_COUNT, |
|
VPU_API_GET_FRAME_INFO, |
|
VPU_API_SET_OUTPUT_BLOCK, |
|
VPU_API_GET_EOS_STATUS, |
|
VPU_API_SET_OUTPUT_MODE, |
|
|
|
|
|
VPU_API_GET_EXTRA_INFO = 0x200, |
|
|
|
VPU_API_SET_IMMEDIATE_OUT = 0x1000, |
|
VPU_API_SET_PARSER_SPLIT_MODE, |
|
VPU_API_DEC_OUT_FRM_STRUCT_TYPE, |
|
VPU_API_DEC_EN_THUMBNAIL, |
|
VPU_API_DEC_EN_HDR_META, |
|
VPU_API_DEC_EN_MVC, |
|
VPU_API_DEC_EN_FBC_HDR_256_ODD, |
|
|
|
VPU_API_ENC_VEPU22_START = 0x2000, |
|
VPU_API_ENC_SET_VEPU22_CFG, |
|
VPU_API_ENC_GET_VEPU22_CFG, |
|
VPU_API_ENC_SET_VEPU22_CTU_QP, |
|
VPU_API_ENC_SET_VEPU22_ROI, |
|
|
|
VPU_API_ENC_MPP = 0x3000, |
|
VPU_API_ENC_MPP_SETCFG, |
|
VPU_API_ENC_MPP_GETCFG, |
|
|
|
|
|
VPU_API_ENC_MLVEC_CFG = 0x4000, |
|
VPU_API_ENC_SET_MAX_TID, |
|
VPU_API_ENC_SET_MARK_LTR, |
|
VPU_API_ENC_SET_USE_LTR, |
|
VPU_API_ENC_SET_FRAME_QP, |
|
VPU_API_ENC_SET_BASE_LAYER_PID, |
|
} VPU_API_CMD; |
|
|
|
typedef struct { |
|
RK_U32 TimeLow; |
|
RK_U32 TimeHigh; |
|
} TIME_STAMP; |
|
|
|
typedef struct { |
|
RK_U32 CodecType; |
|
RK_U32 ImgWidth; |
|
RK_U32 ImgHeight; |
|
RK_U32 ImgHorStride; |
|
RK_U32 ImgVerStride; |
|
RK_U32 BufSize; |
|
} VPU_GENERIC; |
|
|
|
typedef struct VPUMem { |
|
RK_U32 phy_addr; |
|
RK_U32 *vir_addr; |
|
RK_U32 size; |
|
RK_U32 *offset; |
|
} VPUMemLinear_t; |
|
|
|
typedef struct tVPU_FRAME { |
|
RK_U32 FrameBusAddr[2]; |
|
RK_U32 FrameWidth; |
|
RK_U32 FrameHeight; |
|
RK_U32 OutputWidth; |
|
RK_U32 OutputHeight; |
|
RK_U32 DisplayWidth; |
|
RK_U32 DisplayHeight; |
|
RK_U32 CodingType; |
|
RK_U32 FrameType; |
|
RK_U32 ColorType; |
|
RK_U32 DecodeFrmNum; |
|
TIME_STAMP ShowTime; |
|
RK_U32 ErrorInfo; |
|
RK_U32 employ_cnt; |
|
VPUMemLinear_t vpumem; |
|
struct tVPU_FRAME *next_frame; |
|
union { |
|
struct { |
|
RK_U32 Res0[2]; |
|
struct { |
|
RK_U32 ColorPrimaries : 8; |
|
RK_U32 ColorTransfer : 8; |
|
RK_U32 ColorCoeffs : 8; |
|
RK_U32 ColorRange : 1; |
|
RK_U32 Res1 : 7; |
|
}; |
|
|
|
RK_U32 Res2; |
|
}; |
|
|
|
RK_U32 Res[4]; |
|
}; |
|
} VPU_FRAME; |
|
|
|
typedef struct FrameThumbInfo { |
|
RK_U32 enable; |
|
RK_U32 yOffset; |
|
RK_U32 uvOffset; |
|
} FrameThumbInfo_t; |
|
|
|
typedef struct FrameHdrInfo { |
|
RK_U32 isHdr; |
|
RK_U32 offset; |
|
RK_U32 size; |
|
} FrameHdrInfo_t; |
|
|
|
typedef struct VideoFrame { |
|
VPU_FRAME vpuFrame; |
|
FrameThumbInfo_t thumbInfo; |
|
FrameHdrInfo_t hdrInfo; |
|
RK_U32 viewId; |
|
RK_U32 reserved[16]; |
|
} VideoFrame_t; |
|
|
|
typedef struct VideoPacket { |
|
RK_S64 pts; |
|
RK_S64 dts; |
|
RK_U8 *data; |
|
RK_S32 size; |
|
RK_U32 capability; |
|
RK_U32 nFlags; |
|
} VideoPacket_t; |
|
|
|
typedef struct DecoderOut { |
|
RK_U8 *data; |
|
RK_U32 size; |
|
RK_S64 timeUs; |
|
RK_S32 nFlags; |
|
} DecoderOut_t; |
|
|
|
typedef struct ParserOut { |
|
RK_U8 *data; |
|
RK_U32 size; |
|
RK_S64 timeUs; |
|
RK_U32 nFlags; |
|
RK_U32 width; |
|
RK_U32 height; |
|
} ParserOut_t; |
|
|
|
typedef struct EncInputStream { |
|
RK_U8 *buf; |
|
RK_S32 size; |
|
RK_U32 bufPhyAddr; |
|
RK_S64 timeUs; |
|
RK_U32 nFlags; |
|
} EncInputStream_t; |
|
|
|
typedef struct EncoderOut { |
|
RK_U8 *data; |
|
RK_S32 size; |
|
RK_S64 timeUs; |
|
RK_S32 keyFrame; |
|
|
|
} EncoderOut_t; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum OMX_RK_VIDEO_CODINGTYPE { |
|
OMX_RK_VIDEO_CodingUnused, |
|
OMX_RK_VIDEO_CodingAutoDetect, |
|
OMX_RK_VIDEO_CodingMPEG2, |
|
OMX_RK_VIDEO_CodingH263, |
|
OMX_RK_VIDEO_CodingMPEG4, |
|
OMX_RK_VIDEO_CodingWMV, |
|
OMX_RK_VIDEO_CodingRV, |
|
OMX_RK_VIDEO_CodingAVC, |
|
OMX_RK_VIDEO_CodingMJPEG, |
|
OMX_RK_VIDEO_CodingVP8, |
|
OMX_RK_VIDEO_CodingVP9, |
|
OMX_RK_VIDEO_CodingVC1 = 0x01000000, |
|
OMX_RK_VIDEO_CodingFLV1, |
|
OMX_RK_VIDEO_CodingDIVX3, |
|
OMX_RK_VIDEO_CodingVP6, |
|
OMX_RK_VIDEO_CodingHEVC, |
|
OMX_RK_VIDEO_CodingAVSPLUS, |
|
OMX_RK_VIDEO_CodingAVS, |
|
OMX_RK_VIDEO_CodingAVS2, |
|
OMX_RK_VIDEO_CodingAV1, |
|
OMX_RK_VIDEO_CodingKhronosExtensions = 0x6F000000, |
|
OMX_RK_VIDEO_CodingVendorStartUnused = 0x7F000000, |
|
OMX_RK_VIDEO_CodingMax = 0x7FFFFFFF |
|
} OMX_RK_VIDEO_CODINGTYPE; |
|
|
|
typedef enum CODEC_TYPE { |
|
CODEC_NONE, |
|
CODEC_DECODER, |
|
CODEC_ENCODER, |
|
CODEC_BUTT, |
|
} CODEC_TYPE; |
|
|
|
typedef enum VPU_API_ERR { |
|
VPU_API_OK = 0, |
|
VPU_API_ERR_UNKNOW = -1, |
|
VPU_API_ERR_BASE = -1000, |
|
VPU_API_ERR_LIST_STREAM = VPU_API_ERR_BASE - 1, |
|
VPU_API_ERR_INIT = VPU_API_ERR_BASE - 2, |
|
VPU_API_ERR_VPU_CODEC_INIT = VPU_API_ERR_BASE - 3, |
|
VPU_API_ERR_STREAM = VPU_API_ERR_BASE - 4, |
|
VPU_API_ERR_FATAL_THREAD = VPU_API_ERR_BASE - 5, |
|
VPU_API_EOS_STREAM_REACHED = VPU_API_ERR_BASE - 11, |
|
|
|
VPU_API_ERR_BUTT, |
|
} VPU_API_ERR; |
|
|
|
typedef enum VPU_FRAME_ERR { |
|
VPU_FRAME_ERR_UNKNOW = 0x0001, |
|
VPU_FRAME_ERR_UNSUPPORT = 0x0002, |
|
|
|
} VPU_FRAME_ERR; |
|
|
|
typedef struct EncParameter { |
|
RK_S32 width; |
|
RK_S32 height; |
|
RK_S32 rc_mode; |
|
RK_S32 bitRate; |
|
RK_S32 framerate; |
|
RK_S32 qp; |
|
RK_S32 enableCabac; |
|
RK_S32 cabacInitIdc; |
|
RK_S32 format; |
|
RK_S32 intraPicRate; |
|
RK_S32 framerateout; |
|
RK_S32 profileIdc; |
|
RK_S32 levelIdc; |
|
RK_S32 reserved[3]; |
|
} EncParameter_t; |
|
|
|
typedef struct EXtraCfg { |
|
RK_S32 vc1extra_size; |
|
RK_S32 vp6codeid; |
|
RK_S32 tsformat; |
|
RK_U32 ori_vpu; |
|
|
|
RK_U32 mpp_mode; |
|
RK_U32 bit_depth; |
|
RK_U32 yuv_format; |
|
RK_U32 reserved[16]; |
|
} EXtraCfg_t; |
|
|
|
|
|
|
|
|
|
typedef struct VpuCodecContext { |
|
void* vpuApiObj; |
|
|
|
CODEC_TYPE codecType; |
|
OMX_RK_VIDEO_CODINGTYPE videoCoding; |
|
|
|
RK_U32 width; |
|
RK_U32 height; |
|
void *extradata; |
|
RK_S32 extradata_size; |
|
|
|
RK_U8 enableparsing; |
|
|
|
RK_S32 no_thread; |
|
EXtraCfg_t extra_cfg; |
|
|
|
void* private_data; |
|
|
|
|
|
|
|
|
|
RK_S32 decoder_err; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*init)(struct VpuCodecContext *ctx, RK_U8 *extraData, RK_U32 extra_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*decode)(struct VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aDecOut); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*encode)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut); |
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*flush)(struct VpuCodecContext *ctx); |
|
RK_S32 (*control)(struct VpuCodecContext *ctx, VPU_API_CMD cmdType, void* param); |
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*decode_sendstream)(struct VpuCodecContext *ctx, VideoPacket_t *pkt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*decode_getframe)(struct VpuCodecContext *ctx, DecoderOut_t *aDecOut); |
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*encoder_sendframe)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm); |
|
|
|
|
|
|
|
|
|
|
|
|
|
RK_S32 (*encoder_getstream)(struct VpuCodecContext *ctx, EncoderOut_t *aEncOut); |
|
} VpuCodecContext_t; |
|
|
|
|
|
#ifdef __cplusplus |
|
extern "C" |
|
{ |
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
RK_S32 vpu_open_context(struct VpuCodecContext **ctx); |
|
|
|
|
|
|
|
|
|
RK_S32 vpu_close_context(struct VpuCodecContext **ctx); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
|
|
|
|
|
|
#define vpu_display_mem_pool_FIELDS \ |
|
RK_S32 (*commit_hdl)(vpu_display_mem_pool *p, RK_S32 hdl, RK_S32 size); \ |
|
void* (*get_free)(vpu_display_mem_pool *p); \ |
|
RK_S32 (*inc_used)(vpu_display_mem_pool *p, void *hdl); \ |
|
RK_S32 (*put_used)(vpu_display_mem_pool *p, void *hdl); \ |
|
RK_S32 (*reset)(vpu_display_mem_pool *p); \ |
|
RK_S32 (*get_unused_num)(vpu_display_mem_pool *p); \ |
|
RK_S32 buff_size;\ |
|
float version; \ |
|
RK_S32 res[18]; |
|
|
|
typedef struct vpu_display_mem_pool vpu_display_mem_pool; |
|
|
|
struct vpu_display_mem_pool { |
|
vpu_display_mem_pool_FIELDS |
|
}; |
|
|
|
#ifdef __cplusplus |
|
extern "C" |
|
{ |
|
#endif |
|
|
|
|
|
|
|
|
|
RK_S32 VPUMemJudgeIommu(void); |
|
RK_S32 VPUMallocLinear(VPUMemLinear_t *p, RK_U32 size); |
|
RK_S32 VPUFreeLinear(VPUMemLinear_t *p); |
|
RK_S32 VPUMemDuplicate(VPUMemLinear_t *dst, VPUMemLinear_t *src); |
|
RK_S32 VPUMemLink(VPUMemLinear_t *p); |
|
RK_S32 VPUMemFlush(VPUMemLinear_t *p); |
|
RK_S32 VPUMemClean(VPUMemLinear_t *p); |
|
RK_S32 VPUMemInvalidate(VPUMemLinear_t *p); |
|
RK_S32 VPUMemGetFD(VPUMemLinear_t *p); |
|
RK_S32 VPUMallocLinearFromRender(VPUMemLinear_t *p, RK_U32 size, void *ctx); |
|
|
|
|
|
|
|
|
|
vpu_display_mem_pool* open_vpu_memory_pool(void); |
|
void close_vpu_memory_pool(vpu_display_mem_pool *p); |
|
int create_vpu_memory_pool_allocator(vpu_display_mem_pool **ipool, int num, int size); |
|
void release_vpu_memory_pool_allocator(vpu_display_mem_pool *ipool); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
|
|
#endif |
|
|