123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #ifndef __SAMPLE_COMM_SVP_H__
- #define __SAMPLE_COMM_SVP_H__
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <signal.h>
- #include "hi_common.h"
- #include "hi_debug.h"
- #include "hi_dsp.h"
- #ifdef __cplusplus
- #if __cplusplus
- extern "C"{
- #endif
- #endif /* __cplusplus */
- //#########################add##########################
- //增加代码,补充SAMPLE_SVP_NNIE_Yolov3_SoftwareInit中缺少的定义
- #define SAMPLE_SVP_NNIE_YOLOV3_REPORT_BLOB_NUM 3 /*yolov3 report blob num*/
- //增加代码,补充SVP_NNIE_Yolov3_GetResult中缺少的定义
- typedef struct hiSAMPLE_SVP_NNIE_YOLOV2_BBOX
- {
- HI_FLOAT f32Xmin;
- HI_FLOAT f32Xmax;
- HI_FLOAT f32Ymin;
- HI_FLOAT f32Ymax;
- HI_S32 s32ClsScore;
- HI_U32 u32ClassIdx;
- HI_U32 u32Mask;
- }SAMPLE_SVP_NNIE_YOLOV2_BBOX_S;
- typedef SAMPLE_SVP_NNIE_YOLOV2_BBOX_S SAMPLE_SVP_NNIE_YOLOV3_BBOX_S;
- #define SAMPLE_SVP_NNIE_YOLOV3_EACH_GRID_BIAS_NUM 6 /*yolov3 bias num of each grid*/
- #define SAMPLE_SVP_NNIE_YOLOV3_EACH_BBOX_INFER_RESULT_NUM 7 /*yolov3 inference result num of each bbox*/ //4+1+2
- #define SAMPLE_SVP_NNIE_SIGMOID(x) (HI_FLOAT)(1.0f/(1+exp(-x)))
- //##########################add#########################
- typedef enum hiSAMPLE_SVP_ERR_LEVEL_E
- {
- SAMPLE_SVP_ERR_LEVEL_DEBUG = 0x0, /* debug-level */
- SAMPLE_SVP_ERR_LEVEL_INFO = 0x1, /* informational */
- SAMPLE_SVP_ERR_LEVEL_NOTICE = 0x2, /* normal but significant condition */
- SAMPLE_SVP_ERR_LEVEL_WARNING = 0x3, /* warning conditions */
- SAMPLE_SVP_ERR_LEVEL_ERROR = 0x4, /* error conditions */
- SAMPLE_SVP_ERR_LEVEL_CRIT = 0x5, /* critical conditions */
- SAMPLE_SVP_ERR_LEVEL_ALERT = 0x6, /* action must be taken immediately */
- SAMPLE_SVP_ERR_LEVEL_FATAL = 0x7, /* just for compatibility with previous version */
- SAMPLE_SVP_ERR_LEVEL_BUTT
- }SAMPLE_SVP_ERR_LEVEL_E;
- #define SAMPLE_SVP_PRINTF(LevelStr,Msg, ...) do { fprintf(stderr,"[Level]:%s,[Func]:%s [Line]:%d [Info]:"Msg,LevelStr, __FUNCTION__, __LINE__,## __VA_ARGS__); } while (0)
- #define SAMPLE_SVP_PRINTF_RED(LevelStr,Msg, ...) do { fprintf(stderr,"\033[0;31m [Level]:%s,[Func]:%s [Line]:%d [Info]:"Msg"\033[0;39m\n",LevelStr, __FUNCTION__, __LINE__,## __VA_ARGS__); } while (0)
- /* system is unusable */
- #define SAMPLE_SVP_TRACE_FATAL(Msg,...) SAMPLE_SVP_PRINTF_RED("Fatal",Msg,##__VA_ARGS__)
- /* action must be taken immediately */
- #define SAMPLE_SVP_TRACE_ALERT(Msg,...) SAMPLE_SVP_PRINTF_RED("Alert",Msg,##__VA_ARGS__)
- /* critical conditions */
- #define SAMPLE_SVP_TRACE_CRIT(Msg,...) SAMPLE_SVP_PRINTF_RED("Critical",Msg,##__VA_ARGS__)
- /* error conditions */
- #define SAMPLE_SVP_TRACE_ERR(Msg,...) SAMPLE_SVP_PRINTF_RED("Error",Msg,##__VA_ARGS__)
- /* warning conditions */
- #define SAMPLE_SVP_TRACE_WARN(Msg,...) SAMPLE_SVP_PRINTF("Warning",Msg,##__VA_ARGS__)
- /* normal but significant condition */
- #define SAMPLE_SVP_TRACE_NOTICE(Msg,...) SAMPLE_SVP_PRINTF("Notice",Msg,##__VA_ARGS__)
- /* informational */
- #define SAMPLE_SVP_TRACE_INFO(Msg,...) SAMPLE_SVP_PRINTF("Info",Msg,##__VA_ARGS__)
- /* debug-level messages */
- #define SAMPLE_SVP_TRACE_DEBUG(Msg, ...) SAMPLE_SVP_PRINTF("Debug",Msg,##__VA_ARGS__)
- #define SAMPLE_SVP_TRACE(Level,Msg, ...)\
- do\
- {\
- switch(Level){\
- case SAMPLE_SVP_ERR_LEVEL_DEBUG:\
- SAMPLE_SVP_TRACE_DEBUG(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_INFO:\
- SAMPLE_SVP_TRACE_INFO(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_NOTICE:\
- SAMPLE_SVP_TRACE_NOTICE(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_WARNING:\
- SAMPLE_SVP_TRACE_WARN(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_ERROR:\
- SAMPLE_SVP_TRACE_ERR(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_CRIT:\
- SAMPLE_SVP_TRACE_CRIT(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_ALERT:\
- SAMPLE_SVP_TRACE_ALERT(Msg,##__VA_ARGS__);\
- break;\
- case SAMPLE_SVP_ERR_LEVEL_FATAL:\
- SAMPLE_SVP_TRACE_FATAL(Msg,##__VA_ARGS__);\
- break;\
- default:\
- break;\
- }\
- }while(0)
- /****
- *Expr is true,goto
- */
- #define SAMPLE_SVP_CHECK_EXPR_GOTO(Expr, Label,Level,Msg, ...) \
- do{ \
- if(Expr) \
- { \
- SAMPLE_SVP_TRACE(Level,Msg,## __VA_ARGS__); \
- goto Label; \
- } \
- }while(0)
- /****
- *Expr is true,return void
- */
- #define SAMPLE_SVP_CHECK_EXPR_RET_VOID(Expr,Level,Msg, ...) \
- do{ \
- if(Expr) \
- { \
- SAMPLE_SVP_TRACE(Level,Msg, ##__VA_ARGS__); \
- return; \
- } \
- }while(0)
- /****
- *Expr is true,return Ret
- */
- #define SAMPLE_SVP_CHECK_EXPR_RET(Expr,Ret,Level,Msg, ...) \
- do{ \
- if(Expr) \
- { \
- SAMPLE_SVP_TRACE(Level,Msg, ##__VA_ARGS__); \
- return Ret; \
- } \
- }while(0)
- /****
- *Expr is true,trace
- */
- #define SAMPLE_SVP_CHECK_EXPR_TRACE(Expr,Level,Msg, ...) \
- do{ \
- if(Expr) \
- { \
- SAMPLE_SVP_TRACE(Level,Msg, ##__VA_ARGS__); \
- } \
- }while(0)
- #define SAMPLE_SVP_ALIGN_16 16
- #define SAMPLE_SVP_ALIGN_32 32
- #define SAMPLE_SVP_D1_PAL_HEIGHT 576
- #define SAMPLE_SVP_D1_PAL_WIDTH 704
- //free mmz
- #define SAMPLE_SVP_MMZ_FREE(phy,vir)\
- do{\
- if ((0 != (phy)) && (0 != (vir)))\
- {\
- HI_MPI_SYS_MmzFree((phy),(void*)(vir));\
- (phy) = 0;\
- (vir) = 0;\
- }\
- }while(0)
- #define SAMPLE_SVP_CLOSE_FILE(fp)\
- do{\
- if (NULL != (fp))\
- {\
- fclose((fp));\
- (fp) = NULL;\
- }\
- }while(0)
- /*
- *System init
- */
- void SAMPLE_COMM_SVP_CheckSysInit(void);
- /*
- *System exit
- */
- void SAMPLE_COMM_SVP_CheckSysExit(void);
- /*
- *Load bin
- */
- HI_S32 SAMPLE_COMM_SVP_LoadCoreBinary(SVP_DSP_ID_E enCoreId);
- /*
- *UnLoad bin
- */
- void SAMPLE_COMM_SVP_UnLoadCoreBinary(SVP_DSP_ID_E enCoreId);
- /*
- *Align
- */
- HI_U32 SAMPLE_COMM_SVP_Align(HI_U32 u32Size, HI_U16 u16Align);
- /*
- *Create Image memory
- */
- HI_S32 SAMPLE_COMM_SVP_CreateImage(SVP_IMAGE_S *pstImg,SVP_IMAGE_TYPE_E enType,HI_U32 u32Width,
- HI_U32 u32Height,HI_U32 u32AddrOffset);
- /*
- *Destory image memory
- */
- HI_VOID SAMPLE_COMM_SVP_DestroyImage(SVP_IMAGE_S *pstImg,HI_U32 u32AddrOffset);
- /*
- *Create mem info
- */
- HI_S32 SAMPLE_COMM_SVP_CreateMemInfo(SVP_MEM_INFO_S *pstMemInfo,HI_U32 u32Size,HI_U32 u32AddrOffset);
- /*
- Destory mem info
- */
- HI_VOID SAMPLE_COMM_SVP_DestroyMemInfo(SVP_MEM_INFO_S *pstMemInfo,HI_U32 u32AddrOffset);
- /*
- *Malloc memory
- */
- HI_S32 SAMPLE_COMM_SVP_MallocMem(HI_CHAR *pszMmb, HI_CHAR *pszZone, HI_U64 *pu64PhyAddr, HI_VOID **ppvVirAddr, HI_U32 u32Size);
- /*
- *Malloc memory with cached
- */
- HI_S32 SAMPLE_COMM_SVP_MallocCached(HI_CHAR *pszMmb, HI_CHAR *pszZone,HI_U64 *pu64PhyAddr, HI_VOID **ppvVirAddr, HI_U32 u32Size);
- /*
- *Fulsh cached
- */
- HI_S32 SAMPLE_COMM_SVP_FlushCache(HI_U64 u64PhyAddr, HI_VOID *pvVirAddr, HI_U32 u32Size);
- /*
- *Gen rand data
- */
- HI_S32 SAMPLE_COMM_SVP_GenRandS32(HI_S32 s32Max,HI_S32 s32Min);
- /*
- *Gen image
- */
- HI_VOID SAMPLE_COMM_SVP_GenImage(HI_U64 au64Buff[3],HI_U32 au32Stride[3],SVP_IMAGE_TYPE_E enType,HI_U32 u32Width,HI_U32 u32Height);
- #ifdef __cplusplus
- #if __cplusplus
- }
- #endif
- #endif /* __cplusplus */
- #endif /* __SAMPLE_COMM_SVP_H__ */
|