MC3302_SDK_V1.1.9_202507281.../media/mpp/include/fhhcp/ive.h

201 lines
8.2 KiB
C
Raw Normal View History

2025-11-11 04:08:31 +00:00
#ifndef IVE_H_
#define IVE_H_
#include <stdint.h>
#include "base.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef uint64_t TY_IVE_TASK_HANDLE;
#define TY_IVE_MAP_NUM 256
typedef enum TY_ThreshMode {
E_TY_THRESH_MODE_TY_BINARY = 0x0, /*srcVal <= lowThr, dstVal = minVal; srcVal > lowThr, dstVal = maxVal.*/
E_TY_THRESH_MODE_TY_TRUNC = 0x1, /*srcVal <= lowThr, dstVal = srcVal; srcVal > lowThr, dstVal = maxVal.*/
E_TY_THRESH_MODE_TY_TO_MINVAL = 0x2, /*srcVal <= lowThr, dstVal = minVal; srcVal > lowThr, dstVal = srcVal.*/
E_TY_THRESH_MODE_TY_MIN_MID_MAX = 0x3, /*srcVal <= lowThr, dstVal = minVal; lowThr < srcVal <= highThr, dstVal = midVal; srcVal > highThr, dstVal = maxVal.*/
E_TY_THRESH_MODE_TY_ORI_MID_MAX = 0x4, /*srcVal <= lowThr, dstVal = srcVal; lowThr < srcVal <= highThr, dstVal = midVal; srcVal > highThr, dstVal = maxVal.*/
E_TY_THRESH_MODE_TY_MIN_MID_ORI = 0x5, /*srcVal <= lowThr, dstVal = minVal; lowThr < srcVal <= highThr, dstVal = midVal; srcVal > highThr, dstVal = srcVal.*/
E_TY_THRESH_MODE_TY_MIN_ORI_MAX = 0x6, /*srcVal <= lowThr, dstVal = minVal; lowThr < srcVal <= highThr, dstVal = srcVal; srcVal > highThr, dstVal = maxVal.*/
E_TY_THRESH_MODE_TY_ORI_MID_ORI = 0x7, /*srcVal <= lowThr, dstVal = srcVal; lowThr < srcVal <= highThr, dstVal = midVal; srcVal > highThr, dstVal = srcVal.*/
E_TY_THRESH_MODE_TY_BUTT
}E_TY_ThreshMode;
typedef struct TY_ThreshCtrlU8 {
E_TY_ThreshMode enMode;
uint8_t lowThr; /*user-defined threshold, 0<=lowThr<=255 */
uint8_t highThr; /*user-defined threshold, if enMode<E_THRESH_MODE_MIN_MID_MAX, highThr is not used, else 0<=lowThr<=highThr<=255;*/
uint8_t minVal; /*Minimum value when tri-level thresholding*/
uint8_t midVal; /*Middle value when tri-level thresholding, if enMode<2, u32MidVal is not used; */
uint8_t maxVal; /*Maxmum value when tri-level thresholding*/
uint8_t reserve;
}T_TY_ThreshCtrlU8;
typedef enum TY_ThreshModeU16 {
E_TY_THRESH_U16_MODE_U16_TO_U8_MIN_MID_MAX = 0x0,
E_TY_THRESH_U16_MODE_U16_TO_U8_MIN_ORI_MAX = 0x1,
E_TY_THRESH_U16_MODE_BUTT
}E_TY_ThreshModeU16;
typedef struct TY_ThreshCtrlU16 {
E_TY_ThreshModeU16 enMode;
uint16_t lowThr;
uint16_t highThr;
uint8_t minVal;
uint8_t midVal;
uint8_t maxVal;
uint8_t reserve;
}T_TY_ThreshCtrlU16;
typedef struct TY_MapLutU8 {
uint8_t map[TY_IVE_MAP_NUM];
}T_TY_MapLutU8;
typedef struct TY_MapLut16 {
uint16_t map[TY_IVE_MAP_NUM];
}T_TY_MapLutU16;
typedef enum TY_MapMode {
E_TY_MAP_MODE_U8 = 0x0, //U8C1->U8C1
E_TY_MAP_MODE_U16 = 0x2 //U8C1->U16C1
}E_TY_MapMode;
typedef struct TY_MapCtrl{
E_TY_MapMode mode;
}T_TY_MapCtrl;
/*!
* @brief IVE系统初始化
* @param [in] iveModelDir ive功能的算子模型目录
* @note IVE接口才能正常工作
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_SysInit(const char *iveModelDir);
/*!
* @brief IVE系统去初始化
* @note IVE_SysInit配对使用ive接口不能正常工作
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_SysExit(void);
/*!
* @brief IVE接口版本信息
* @param [out] majorVersion major版本
* @param [out] minorVersion minor版本
* @param [out] patchVersion patch版本
* @note x.y.z
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_GetVersion(int32_t *majorVersion,
int32_t *minorVersion,
int32_t *patchVersion);
/*!
* @brief IVE算子所需Memory大小
* @param [out] iveMemInfo IVE算子需要的内存信息T_MemSegmentInfo结构中allocInfo成员申请对应内存
* T_MemSegmentInfo结构中mem成员IVE_Create创建IVE算子库
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_GetIveMemSize(T_TY_MemSegmentInfo *iveMemInfo);
/*!
* @brief IVE算子库
* @param [in] iveMemInfo IVE算子需要的内存信息
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_Create(const T_TY_MemSegmentInfo *iveMemInfo);
/*!
* @brief
* @param [in] src E_PIXEL_FORMAT_U8C1
* @param [in] ctrl
* @param [out] dst E_PIXEL_FORMAT_U8C1
* @param [out] handle handle
* @param [in] isBlock 10IVE_Query获取任务完成状态
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_ThreshU8(const T_TY_Image *src, const T_TY_ThreshCtrlU8 *ctrl, T_TY_Image *dst,
TY_IVE_TASK_HANDLE *handle, int32_t isBlock);
/*!
* @brief
* @param [in] src E_PIXEL_FORMAT_U16C1
* @param [in] ctrl
* @param [out] dst E_PIXEL_FORMAT_U8C1
* @param [out] handle handle
* @param [in] isBlock 10IVE_Query获取任务完成状态
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_ThreshU16(const T_TY_Image *src, const T_TY_ThreshCtrlU16 *ctrl, T_TY_Image *dst,
TY_IVE_TASK_HANDLE *handle, int32_t isBlock);
/*!
* @brief
* @param [in] src E_PIXEL_FORMAT_U8C1
* @param [in] mapTable U8C1->U16C1时空间至少sizeof(T_MapLutU8);
* U8C1->U16C1时空间至少sizeof(T_MapLutU16)
* @param [out] dst E_PIXEL_FORMAT_U8C1/E_PIXEL_FORMAT_U16C1
* @param [in] ctrl
* @param [out] handle handle
* @param [in] isBlock 10IVE_Query获取任务完成状态
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_Map(const T_TY_Image *src, const T_TY_Mem *mapTable, T_TY_Image *dst,
T_TY_MapCtrl *ctrl, TY_IVE_TASK_HANDLE *handle, int32_t isBlock);
/*!
* @brief
* @param [in] src0 E_PIXEL_FORMAT_U8C1
* @param [in] src1 E_PIXEL_FORMAT_U8C1
* @param [out] dst E_PIXEL_FORMAT_U8C1
* @param [out] handle handle
* @param [in] isBlock 10IVE_Query获取任务完成状态
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_And(const T_TY_Image *src0, const T_TY_Image *src1, T_TY_Image *dst,
TY_IVE_TASK_HANDLE *handle, int32_t isBlock);
/*!
* @brief
* @param [in] src0 E_PIXEL_FORMAT_U8C1
* @param [in] src1 E_PIXEL_FORMAT_U8C1
* @param [out] dst E_PIXEL_FORMAT_U8C1
* @param [out] handle handle
* @param [in] isBlock 10IVE_Query获取任务完成状态
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_Or(const T_TY_Image *src0, const T_TY_Image *src1, T_TY_Image *dst,
TY_IVE_TASK_HANDLE *handle, int32_t isBlock);
/*!
* @brief
* @param [in] handle
* @param [out] status
* @param [in] isBlock 10
*
0
*/
TY_NPU_FUNC_VISIBILITY int32_t TY_IVE_Query(TY_IVE_TASK_HANDLE handle, E_TY_Bool *status, int32_t isBlock);
#ifdef __cplusplus
}
#endif
#endif