|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved.
|
|
|
* Description: IAPI header file for Huanglong video decoders and encoders
|
|
|
* Author: Hisilicon
|
|
|
* Create: 2019-09-19
|
|
|
*/
|
|
|
|
|
|
#ifndef __UAPI_VCODEC_H__
|
|
|
#define __UAPI_VCODEC_H__
|
|
|
|
|
|
#include "uapi_video.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#define SOC_ERR_VCODEC_NOENOUGHRES (td_s32)(0x80510001) /* Insufficient resources */ /* CNcomment: 资源不足 */
|
|
|
#define SOC_ERR_VCODEC_INVALIDPARAM (td_s32)(0x80510002) /* Parameter invalid */ /* CNcomment: 参数无效 */
|
|
|
#define SOC_ERR_VCODEC_INPUTCORRUPT (td_s32)(0x80510003) /* Incorrect input */ /* CNcomment: 输入数据有误 */
|
|
|
#define SOC_ERR_VCODEC_NOENOUGHDATA (td_s32)(0x80510004) /* Insufficient input */ /* CNcomment: 输入数据不足 */
|
|
|
#define SOC_ERR_VCODEC_INVALIDMODE (td_s32)(0x80510005) /* Mode not support */ /* CNcomment: 不支持的(编)解码类型 */
|
|
|
#define SOC_ERR_VCODEC_OPERATEFAIL (td_s32)(0x80510006) /* Operate fail */ /* CNcomment: 操作失败 */
|
|
|
#define SOC_ERR_VCODEC_VERSIONUNMATCH (td_s32)(0x80510007) /* Version unmatch */ /* CNcomment: 版本不匹配 */
|
|
|
#define SOC_ERR_VCODEC_UNSUPPORT (td_s32)(0x80510008) /* Unsupport operation */ /* CNcomment: 不支持的操作 */
|
|
|
#define SOC_ERR_VCODEC_BUSY (td_s32)(0x80510009) /* Decorder busy */ /* CNcomment: 解码器忙 */
|
|
|
#define SOC_ERR_VCODEC_UNKNOWN (td_s32)(0x80510010) /* Unknown error */ /* CNcomment: 未知错误 */
|
|
|
|
|
|
/*
|
|
|
* Defines driven tyoe.
|
|
|
* CNcomment: 驱动类型定义
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VCODEC_CAP_DRIVEN_OUTSIDE = 0x1, /* Driven by outside thread */ /* CNcomment:外部驱动 */
|
|
|
UAPI_VCODEC_CAP_DRIVEN_INSIDE = 0x2, /* Driven by inside thread */ /* CNcomment:内部自驱动 */
|
|
|
UAPI_VCODEC_CAP_DRIVEN_MAX
|
|
|
} uapi_vcodec_cap_driven;
|
|
|
|
|
|
/*
|
|
|
* Defines output address tyoe.
|
|
|
* CNcomment: 输出地址类型定义
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VCODEC_CAP_OUTPUT_OUTSIDE = 0x1, /* Output to outside address */ /* CNcomment:输出到外部地址 */
|
|
|
UAPI_VCODEC_CAP_OUTPUT_INSIDE = 0x2, /* Output to inside address */ /* CNcomment:输出到内部地址 */
|
|
|
UAPI_VCODEC_CAP_OUTPUT_MAX
|
|
|
} uapi_vcodec_cap_output;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec tyoe.
|
|
|
* CNcomment: vcodec类型定义
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VCODEC_ROLE_DEC = 0x01, /* Decoder */ /* CNcomment:解码器 */
|
|
|
UAPI_VCODEC_ROLE_ENC = 0x02, /* Encoder */ /* CNcomment:编码器 */
|
|
|
UAPI_VCODEC_ROLE_MAX
|
|
|
} uapi_vcodec_role;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec support type.
|
|
|
* CNcomment: vcodec capacity链表节点定义
|
|
|
*/
|
|
|
typedef struct uapi_vcodec_support {
|
|
|
uapi_vcodec_role role; /* Codec role */ /* CNcomment:Codec解码还是编码 */
|
|
|
uapi_vcodec_type type; /* Codec ID */ /* CNcomment:Codec支持的协议类型 */
|
|
|
struct uapi_vcodec_support *next; /* Pointer to next node */ /* CNcomment:指向下一个能力结点的指针 */
|
|
|
} uapi_vcodec_support;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec capacity.
|
|
|
* CNcomment: vcodec 编解码能力定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_cap_driven cap_driven; /* Driven type */ /* CNcomment: 驱动类型 */
|
|
|
uapi_vcodec_cap_output cap_output; /* Output address type */ /* CNcomment: 输出地址类型 */
|
|
|
uapi_vcodec_support *support; /* Support type list */ /* CNcomment: Codec能力链表 */
|
|
|
} uapi_vcodec_cap;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec version.
|
|
|
* CNcomment: vcodec 版本定义
|
|
|
*/
|
|
|
typedef union {
|
|
|
struct {
|
|
|
td_u8 major;
|
|
|
td_u8 minor;
|
|
|
td_u8 revision;
|
|
|
td_u8 step;
|
|
|
} version_struct;
|
|
|
td_u32 version_int;
|
|
|
} uapi_vcodec_version;
|
|
|
|
|
|
/*
|
|
|
* Defines decoder open parameter.
|
|
|
* CNcomment: 解码器打开命令参数定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_void *paltform_priv; /* Pointer to platform private info */ /* CNcomment: 平台私有信息指针 */
|
|
|
} uapi_vcodec_vdec_open_param;
|
|
|
|
|
|
/*
|
|
|
* Defines encoder open parameter.
|
|
|
* CNcomment: 编码器打开命令参数定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_u32 reserve;
|
|
|
} uapi_vcodec_venc_open_param;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec open parameter.
|
|
|
* CNcomment: Codec打开命令参数定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_role role; /* Role */ /* CNcomment: 角色 */
|
|
|
uapi_vcodec_type type; /* Format type */ /* CNcomment: 协议类型 */
|
|
|
union {
|
|
|
uapi_vcodec_vdec_open_param vdec; /* deoder open parameter */ /* CNcomment: 解码器打开参数 */
|
|
|
uapi_vcodec_venc_open_param venc; /* encoder open parameter */ /* CNcomment: 编码器打开参数 */
|
|
|
} param;
|
|
|
} uapi_vcodec_open_param;
|
|
|
|
|
|
/*
|
|
|
* Defines decoder attribute.
|
|
|
* CNcomment: 解码器属性定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_void *codec_ctx; /* Codec context */ /* CNcomment:解码器上下文,可以传递解码器特定参数 */
|
|
|
td_void *platform_priv; /* Only used by platform */ /* CNcomment:解码器私有参数 */
|
|
|
} uapi_vcodec_vdec_attr;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec attribute.
|
|
|
* CNcomment: vcodec属性定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_type type; /* Codec ID */ /* CNcomment:编码或解码的协议类型 */
|
|
|
union {
|
|
|
uapi_vcodec_vdec_attr vdec; /* Instance attribute */ /* CNcomment:视频解码器属性参数 */
|
|
|
} attr;
|
|
|
} uapi_vcodec_attr;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec address.
|
|
|
* CNcomment: 地址信息定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_u8 *vir; /* Virtual address of (frame or stream) buffer */ /* CNcomment: 帧或流数据的虚拟地址 */
|
|
|
td_mem_handle mem_handle; /* Memory handle */ /* CNcomment: 内存句柄 */
|
|
|
td_u32 size; /* Memory size */ /* CNcomment: 内存大小 */
|
|
|
} uapi_vcodec_address;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec stream.
|
|
|
* CNcomment: 码流信息定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_address addr; /* Stream address */ /* CNcomment: 码流地址信息 */
|
|
|
td_s64 pts; /* PTS(us) */ /* CNcomment: 流数据对应PTS,微秒为单位 */
|
|
|
} uapi_vcodec_stream;
|
|
|
|
|
|
/*
|
|
|
* Defines vcodec frame.
|
|
|
* CNcomment: 帧信息定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_address addr; /* Frame adddress */ /* CNcomment: vcodec帧输出地址 */
|
|
|
struct {
|
|
|
uapi_video_frame_info frame_info; /* Video frame information */ /* CNcomment: 视频帧信息 */
|
|
|
} info;
|
|
|
} uapi_vcodec_frame;
|
|
|
|
|
|
/*
|
|
|
* Defines codec
|
|
|
* CNcomment: CODEC结构体定义
|
|
|
*/
|
|
|
typedef struct {
|
|
|
/* Description information about a codec */ /* CNcomment: 编解码器描述名字 */
|
|
|
const td_char *name;
|
|
|
|
|
|
/* Codec version */ /* CNcomment: 编解码器版本描述 */
|
|
|
const uapi_vcodec_version version;
|
|
|
|
|
|
/* Detailed information about a codec */ /* CNcomment: 编解码器详细描述信息 */
|
|
|
const td_char *description;
|
|
|
|
|
|
/*
|
|
|
* brief Get codec capability. CNcomment:获取编解码器能力 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[out] cap, Pointer of the codec capability. CNcomment: 指针类型,输出编码器能力 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*get_cap)(uapi_vcodec_cap *cap);
|
|
|
|
|
|
/*
|
|
|
* brief Create a codec instance. CNcomment:创建编解码器实例 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] param, Pointer of the open params. CNcomment:指针类型,指向实例打开参数 CNend
|
|
|
* param [out] inst, Pointer to instance handle. CNcomment:指针类型,指向实例句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*create)(td_handle *inst, const uapi_vcodec_open_param *param);
|
|
|
|
|
|
/*
|
|
|
* brief Destroy a codec instance. CNcomment:销毁编解码器实例 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*destroy)(td_handle inst);
|
|
|
|
|
|
/*
|
|
|
* brief Start a codec instance. CNcomment:启动编解码器实例 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*start)(td_handle inst);
|
|
|
|
|
|
/*
|
|
|
* brief Stop a codec instance. CNcomment:停止编解码器实例 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*stop)(td_handle inst);
|
|
|
|
|
|
/*
|
|
|
* brief Reset a codec instance. CNcomment:复位编解码器实例 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*reset)(td_handle inst);
|
|
|
|
|
|
/*
|
|
|
* brief Set attribute to a codec instance. CNcomment:设置编解码器属性 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* param [in] attr, Pointer to the instance attribute. CNcomment:指针类型,指向实例属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*set_attr)(td_handle inst, const uapi_vcodec_attr *attr);
|
|
|
|
|
|
/*
|
|
|
* brief Get attribute to a codec instance. CNcomment:获取编解码器属性 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* param [out] attr, Pointer to the instance attribute. CNcomment:指针类型,指向实例属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*get_attr)(td_handle inst, uapi_vcodec_attr *attr);
|
|
|
|
|
|
/*
|
|
|
* brief Decode a frame. CNcomment:解码一帧 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* param [in] stream, Pointer to stream data descriptor. CNcomment:指针类型,指向码流数据信息结构体 CNend
|
|
|
* param [out] frame, Pointer to frame data descriptor. CNcomment:指针类型,指向帧数据信息结构体 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*decode_frame)(td_handle inst, const uapi_vcodec_stream *stream, uapi_vcodec_frame *frame);
|
|
|
|
|
|
/*
|
|
|
* brief Encode a frame. CNcomment:编码一帧 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* param [in] frame, Pointer to stream data descriptor. CNcomment:指针类型,指向码流数据信息结构体 CNend
|
|
|
* param [out] stream, Pointer to frame data descriptor. CNcomment:指针类型,指向帧数据信息结构体 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*encode_frame)(td_handle inst, const uapi_vcodec_frame *frame, uapi_vcodec_stream *stream);
|
|
|
|
|
|
/*
|
|
|
* brief Get stream information. CNcomment:获取码流信息 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param [in] inst, Instance handle. CNcomment:实例句柄 CNend
|
|
|
* param [out] stream_info, Pointer to stream information. CNcomment:指针类型,指向码流信息结构体 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 (*get_stream_info)(td_handle inst, uapi_video_stream_info *stream_info);
|
|
|
} uapi_vcodec;
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#endif
|