You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
16 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: api vplugin function define
* Author: Hisilicon
* Create: 2021-10-18
*/
#ifndef __UAPI_VPLUGIN_H__
#define __UAPI_VPLUGIN_H__
#include "uapi_video.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
/*
* Define the VPLUGIN INVALID HANDLE MACRO.
* CNcomment: 定义VPLUGIN INVALID HANDLE宏.
*/
#define INVALID_HANDLE (-1)
/*
* Define the VPLUGIN DATA STREAME.
* CNcomment: 定义 VPLUGIN 数据流.
*/
typedef enum {
UAPI_VPLUGIN_STREAM_MAIN = 0,
UAPI_VPLUGIN_STREAM_EXT_0 = 1,
UAPI_VPLUGIN_STREAM_MAX,
} uapi_vplugin_stream_index;
/*
* Define the VPLUGIN frame type
* CNcomment: 定义 VPLUGIN 处理完的帧类型,当前识别到只放大亮度、只放大色度、正常帧
*/
typedef enum {
UAPI_VPLUGIN_FRAME_TYPE_NORMAL, /* Y和C都放大的帧 */
UAPI_VPLUGIN_FRAME_TYPE_Y, /* 只有Y放大的帧 */
UAPI_VPLUGIN_FRAME_TYPE_C, /* 只有C放大的帧 */
UAPI_VPLUGIN_FRAME_TYPE_MAX,
} uapi_vplugin_frame_type;
typedef struct {
td_u32 y_sr_ratio;
td_u32 y_width;
td_u32 y_height;
td_u32 c_sr_ratio;
td_u32 c_width;
td_u32 c_height;
} uapi_vplugin_aisr_result;
typedef struct {
td_u32 hdr_coef0;
td_u32 hdr_coef1;
td_u32 hdr_coef2;
} uapi_vplugin_aihdr_result;
typedef struct {
td_u32 coef0;
td_u32 coef1;
td_u32 coef2;
} uapi_vplugin_aift_coef_result;
/*
* Define the VPLUGIN result strutc type.
* CNcomment: 定义 VPLUGIN server 处理完的检测结果类型.
*/
typedef enum {
UAPI_VPLUGIN_RESULT_TYPE_AISR = 0,
UAPI_VPLUGIN_RESULT_TYPE_AIHDR,
UAPI_VPLUGIN_RESULT_TYPE_FT_COEF,
UAPI_VPLUGIN_RESULT_TYPE_MAX = 10,
} uapi_vplugin_result_type;
/*
* Define the VPLUGIN STATE
* CNcomment: 定义 VPLUGIN 状态类型,只有当状态为开始时,才可以进行取帧
*/
typedef enum {
UAPI_VPLUGIN_STATUS_NONE,
UAPI_VPLUGIN_STATUS_CREATE,
UAPI_VPLUGIN_STATUS_START,
UAPI_VPLUGIN_STATUS_STOP,
UAPI_VPLUGIN_STATUS_DESTROY,
UAPI_VPLUGIN_STATUS_MAX,
} uapi_vplugin_inst_status;
/*
* Define the VPLUGIN backin stream param.
* CNcomment: 定义 VPLUGIN backin数据流参数
*/
typedef struct {
td_bool secure_frame;
uapi_vplugin_frame_type frame_type;
td_u32 frame_stride_y;
td_u32 frame_stride_c;
td_u32 frame_width;
td_u32 frame_height;
uapi_video_pixel_format frame_format;
uapi_pixel_bit_depth frame_bit_depth;
td_u32 result_cnt;
td_u32 result_size[UAPI_VPLUGIN_RESULT_TYPE_MAX];
} uapi_vplugin_backin_param;
/*
* Define the VPLUGIN frontout stream param.
* CNcomment: 定义 VPLUGIN 输出数据流参数 (w h)为0frontout param不生效
*/
typedef struct {
td_u32 frame_width;
td_u32 frame_height;
uapi_video_pixel_format frame_format;
uapi_pixel_bit_depth frame_bit_depth;
uapi_video_crop_rect crop_rect;
} uapi_vplugin_frontout_param;
/*
* Define the VPLUGIN frontout info.
* CNcomment: 定义 VPLUGIN 输出数据流信息
*/
typedef struct {
td_bool stream_valid;
uapi_video_frame_info frontout_frame;
} uapi_vplugin_frontout_stream;
typedef struct {
td_u32 frontout_stream_cnt;
uapi_vplugin_frontout_stream frontout_stream[UAPI_VPLUGIN_STREAM_MAX];
} uapi_vplugin_frontout_stream_package;
/*
* Define the VPLUGIN result.
* CNcomment: 定义 VPLUGIN处理完的检测结果结构体.
*/
typedef struct {
td_s32 is_valid;
td_u32 result_offset;
uapi_vplugin_result_type result_type;
td_u32 result_frame_index;
} uapi_vplugin_result;
/*
* Define the VPLUGIN backin info.
* CNcomment: 定义VPLUGIN 输入数据流信息,对应于上层处理完的输出信息,
* 包含检测结果、检测结果个数、输出帧信息以及输出帧类型.
*/
typedef struct {
td_bool stream_valid;
td_bool frame_vaild;
uapi_vplugin_frame_type frame_type;
uapi_video_frame_info backin_frame;
td_u32 result_cnt;
td_mem_handle_t result_buf_fd; /* result buffer fd. */
uapi_vplugin_result result[UAPI_VPLUGIN_RESULT_TYPE_MAX];
} uapi_vplugin_backin_stream;
typedef struct {
td_u32 backin_stream_cnt;
uapi_vplugin_backin_stream backin_stream[UAPI_VPLUGIN_STREAM_MAX];
} uapi_vplugin_backin_stream_package;
/*
* Define the VPLUGIN rect info.
* CNcomment: 定义 VPLUGIN vect信息
*/
typedef struct {
uapi_video_rect crop_rect;
uapi_video_rect video_rect;
} uapi_vplugin_rect_info;
/*
* brief init vplugin module.CNcomment: 初始化VPLUGIN模块 CNend
* attention \n
* call this func before any other vplugin funcs .
* CNcomment: 调用VPLUGIN模块要求首先调用本接口 CNend
* retval ::TD_SUCCESS successs. * CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_DEV_OPEN_ERR open vplugin failed. CNcomment: VPLUGIN打开失败 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_init(td_void);
/*
* brief deinit vplugin module. * CNcomment: 去初始化VPLUGIN模块 CNend
* attention \n
* before calling this func ,you should call uapi_vplugin_destroy to destroy all the vplugins first.
* CNcomment: 在调用::uapi_vplugin_destroy接口销毁所有创建的VPLUGIN后调用本接口 CNend
* param * CNcomment: 无 CNend
* retval ::TD_SUCCESS success. * CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_DEV_CLOSE_ERR vplugin deinited failed. CNcomment: VPLUGIN关闭失败 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_deinit(td_void);
/*
* brief create the vplugin. * CNcomment: 创建VPLUGIN CNend
* attention \n
* CNcomment: 无 CNend
* param[in] win_handle the window handler to be create vplugin. CNcomment: WINDOW句柄 CNend
* param[out] vplugin_handle the vplugin handler to be created. CNcomment: 创建的VPLUGIN句柄 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: VPLUGIN未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_CREATE_ERR ceate vplugin failed CNcomment: 创建VPLUGIN失败 CNend
* see \n
CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_create(td_handle win_handle, td_handle *vplugin_handle);
/*
* brief destroy the given vplugin. CNcomment: 销毁VPLUGIN CNend
* attention \n
* user should disable vplugin before call this func
* CNcomment: 请先调用接口disable vplugin 再调用此接口 CNend
* param[in] vplugin_handle the input vplugin handler. CNcomment: VPLUGIN句柄 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_destroy(td_handle vplugin_handle);
/*
* brief set the param of the given vplugin. CNcomment: 设置vplugin参数 CNend
* attention \n
* CNcomment: 无 CNend
* param[in] vplugin_handle the input vplugin handler. CNcomment: vplugin句柄 CNend
* param[in] stream_index the data source select. CNcomment: VPLUGIN 数据流ID CNend
* param[in] frontout_param the struct of data source param. CNcomment: vplugin输出流参数结构体 CNend
* param[in] backin_param the struct of data source param. CNcomment: vplugin输入流参数结构体 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_set_param(td_handle vplugin_handle, uapi_vplugin_stream_index stream_index,
uapi_vplugin_frontout_param *frontout_param, uapi_vplugin_backin_param *backin_param);
/*
* brief get the param of the given vplugin. CNcomment: 获取vplugin参数 CNend
* attention \n
* CNcomment: 无 CNend
* param[in] vplugin_handle the input vplugin handler. CNcomment: vplugin句柄 CNend
* param[in] stream_index the data source select. CNcomment: VPLUGIN 数据流ID CNend
* param[out] frontout_param the pointer of data source param. CNcomment: vplugin输出流参数结构指针 CNend
* param[out] backin_param the pointer of data source param. CNcomment: vplugin输入流参数结构指针 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_get_param(td_handle vplugin_handle, uapi_vplugin_stream_index stream_index,
uapi_vplugin_frontout_param *frontout_param, uapi_vplugin_backin_param *backin_param);
/*
* brief to enable or disable the given vplugin. CNcomment: 使能/禁止VPLUGIN CNend
* attention \n
* param[in] vplugin_handle the input vplugin handler. CNcomment: VPLUGIN句柄 CNend
* param[in] stream_index the data source select. CNcomment: VPLUGIN 数据流ID CNend
* param[in] enable the flag of enable or disable vplugin instance. CNcomment: 使能/禁止标志 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_set_enable(td_handle vplugin_handle, uapi_vplugin_stream_index stream_index, td_bool enable);
/*
* brief get the enable status of the given vplugin: enable or not. CNcomment: 获取VPLUGIN的使能状态 CNend
* attention \n
CNcomment: 无 CNend
* param[in] vplugin_handle the input vplugin handler. CNcomment: VPLUGIN句柄 CNend
* param[in] stream_index the data source select. CNcomment: VPLUGIN 数据流ID CNend
* param[out] enable the flag of enable or disable vplugin instance. CNcomment: 使能/禁止标志 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_get_enable(td_handle vplugin_handle, uapi_vplugin_stream_index stream_index, td_bool *enable);
/*
* brief get the running status of the given vplugin: start or not. CNcomment: 获取VPLUGIN的运行状态 CNend
* attention \n
CNcomment: 无 CNend
* param[in] vplugin_handle the input vplugin handler. CNcomment: VPLUGIN句柄 CNend
* param[out] status the vplugin running status. CNcomment: VPLUGIN 运行状态 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_get_inst_status(td_handle vplugin_handle, uapi_vplugin_inst_status *status);
/*
* user acquire frame . CNcomment: 用户catch帧接口 CNend
* attention \n
* param[in] vplugin_handle vplugin handle. CNcomment: vplugin 句柄 CNend
* param[out] output_info frame info. CNcomment: frontout帧信息 CNend
* param[out] input_info frame info. CNcomment: backin帧信息(提供内存空间,供上层填数据) CNend
* param[in] timeout_ms . CNcomment: 阻塞调用等待时间 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* none. CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_catch_stream(td_handle vplugin_handle,
uapi_vplugin_frontout_stream_package *frontout_stream_package,
uapi_vplugin_backin_stream_package *backin_stream_package, td_u32 timeout_ms);
/*
* user acquire frame extend . CNcomment: 用户catch帧扩展接口 CNend
* attention \n
* param[in] vplugin_handle vplugin handle. CNcomment: vplugin 句柄 CNend
* param[out] output_info frame info. CNcomment: frontout帧信息 CNend
* param[out] input_info frame info. CNcomment: backin帧信息(提供内存空间,供上层填数据) CNend
* param[out] rect info. CNcomment: crop rect和video rect信息 CNend
* param[in] timeout_ms . CNcomment: 阻塞调用等待时间 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* none. CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_catch_stream_ext(td_handle vplugin_handle,
uapi_vplugin_frontout_stream_package *frontout_stream_package,
uapi_vplugin_backin_stream_package *backin_stream_package,
uapi_vplugin_rect_info *rect_info, td_u32 timeout_ms);
/*
* user release frame . CNcomment: 用户sendback帧接口 CNend
* attention \n
* param[in] vplugin_handle vplugin handle. CNcomment: vplugin 句柄 CNend
* param[in] input_info frame info. CNcomment: backin帧信息(上层填完数据送给vplugin) CNend
* param[in] input_info frame info. CNcomment: frontout帧信息 CNend
* retval ::TD_SUCCESS CNcomment: 成功 CNend
* retval ::SOC_ERR_VPLUGIN_NO_INIT VPLUGIN not inited. CNcomment: 未初始化 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_PARA illegal params. CNcomment: 输入参数非法 CNend
* retval ::SOC_ERR_VPLUGIN_INVALID_OPT illegal operation. CNcomment: 操作非法 CNend
* retval ::SOC_ERR_VPLUGIN_NOT_EXIST vplugin not exist. CNcomment: vplugin不存在 CNend
* see \n
* none. CNcomment: 无 CNend
*/
td_s32 uapi_vplugin_sendback_stream(td_handle vplugin_handle,
uapi_vplugin_backin_stream_package *backin_stream_package,
uapi_vplugin_frontout_stream_package *frontout_stream_package);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif