hi_comm_photo.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /******************************************************************************
  2. Copyright (C), 2017-2018, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hi_comm_photo.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software group
  7. Created :
  8. Last Modified :
  9. Description : common definitions for photo algorithms
  10. Function List :
  11. History :
  12. 1.Date : 20171216
  13. Author :
  14. Modification: Create
  15. ******************************************************************************/
  16. #ifndef __HI_COMM_PHOTO_H__
  17. #define __HI_COMM_PHOTO_H__
  18. #ifdef __cplusplus
  19. #if __cplusplus
  20. extern "C"{
  21. #endif
  22. #endif /* __cplusplus */
  23. #include "hi_type.h"
  24. #include "hi_common.h"
  25. #include "hi_errno.h"
  26. #include "hi_math.h"
  27. #include "hi_comm_video.h"
  28. #define PHOTO_HDR_FRAME_NUM 3
  29. #define PHOTO_MFNR_FRAME_NUM 4
  30. #define PHOTO_MIN_WIDTH 1280
  31. #define PHOTO_MIN_HEIGHT 720
  32. #define PHOTO_MAX_WIDTH 7680
  33. #define PHOTO_MAX_HEIGHT 4320
  34. #define PHOTO_HDR_ISO_LEVEL_CNT 10
  35. #define PHOTO_SFNR_ISO_LEVEL_CNT 8
  36. #define PHOTO_MFNR_ISO_LEVEL_CNT 8
  37. #define PHOTO_DE_ISO_LEVEL_CNT 8
  38. #define PHOTO_MAX_FACE_NUM 10
  39. typedef enum hiPHOTO_ALG_TYPE_E
  40. {
  41. PHOTO_ALG_TYPE_HDR = 0x0,
  42. PHOTO_ALG_TYPE_SFNR = 0x1,
  43. PHOTO_ALG_TYPE_MFNR = 0x2,
  44. PHOTO_ALG_TYPE_DE = 0x3,
  45. PHOTO_ALG_TYPE_BUTT
  46. } PHOTO_ALG_TYPE_E;
  47. typedef struct hiPHOTO_FACE_INFO_S
  48. {
  49. HI_U32 u32Id; //reserved
  50. RECT_S stFaceRect;
  51. RECT_S stLeftEyeRect; //reserved
  52. RECT_S stRightEyeRect; //reserved
  53. HI_U32 u32BlinkScore; //reserved
  54. HI_U32 u32SmileScore; //reserved
  55. }PHOTO_FACE_INFO_S;
  56. typedef struct hiPHOTO_DARK_MOTION_DETECTION_PARAM_S
  57. {
  58. HI_S32 s32IsoSpeed;
  59. HI_S32 s32MotionLowGray;
  60. HI_S32 s32MotionHighGray;
  61. HI_FLOAT f32MotionRatio;
  62. HI_S32 s32NightAverageLuma;
  63. }PHOTO_DARK_MOTION_DETECTION_PARAM_S;
  64. typedef struct hiPHOTO_IMAGE_FUSION_PARAM_S
  65. {
  66. HI_S32 s32IsoSpeed;
  67. HI_S32 s32PyramidTopSize;
  68. HI_S32 s32WeightCurveMethod;
  69. HI_S32 s32WeightCalcMethod;
  70. HI_S32 s32BlendUVGain;
  71. HI_S32 s32DetailEnhanceRatioL0;
  72. HI_S32 s32DetailEnhanceRatioL1;
  73. HI_FLOAT f32BlendSigma;
  74. }PHOTO_IMAGE_FUSION_PARAM_S;
  75. typedef struct hiPHOTO_HDR_COEF_S
  76. {
  77. HI_S32 s32AjustRatio;
  78. HI_S32 s32ImageScaleMethod;
  79. PHOTO_DARK_MOTION_DETECTION_PARAM_S astMotionDetectionParam[PHOTO_HDR_ISO_LEVEL_CNT];
  80. PHOTO_IMAGE_FUSION_PARAM_S astImageFusionParam[PHOTO_HDR_ISO_LEVEL_CNT];
  81. }PHOTO_HDR_COEF_S;
  82. typedef struct hiPHOTO_SFNR_ISO_STRATEGY_S
  83. {
  84. HI_S32 s32IsoValue;
  85. HI_S32 s32Luma;
  86. HI_S32 s32Chroma;
  87. HI_S32 s32LumaHF;
  88. HI_S32 s32ChromaHF;
  89. }PHOTO_SFNR_ISO_STRATEGY_S;
  90. typedef struct hiPHOTO_SFNR_COEF_S
  91. {
  92. PHOTO_SFNR_ISO_STRATEGY_S astIsoStrat[PHOTO_SFNR_ISO_LEVEL_CNT];
  93. }PHOTO_SFNR_COEF_S;
  94. typedef struct hiPHOTO_MFNR_3DNR_ISO_STRATEGY_S
  95. {
  96. HI_S32 s32IsoValue;
  97. HI_S32 s32Stnr;
  98. HI_S32 s32TnrFrmNum;
  99. HI_S32 s32StnrDarkLess;
  100. HI_S32 s32StnrGhostLess;
  101. HI_S32 s32LumaAlpha;
  102. HI_S32 s32LumaDelta;
  103. HI_S32 s32ChromaAlpha;
  104. HI_S32 s32ChromaDelta;
  105. }PHOTO_MFNR_3DNR_ISO_STRATEGY_S;
  106. typedef struct hiPHOTO_MFNR_3DNR_PARAM_S
  107. {
  108. PHOTO_MFNR_3DNR_ISO_STRATEGY_S ast3DNRIsoStrat[PHOTO_MFNR_ISO_LEVEL_CNT];
  109. }PHOTO_MFNR_3DNR_PARAM_S;
  110. typedef struct hiPHOTO_MFNR_2DNR_ISO_STRATEGY_S
  111. {
  112. HI_S32 s32IsoValue;
  113. HI_S32 s32Luma;
  114. HI_S32 s32Chroma;
  115. HI_S32 s32LumaHF2;
  116. HI_S32 s32DetailMin;
  117. }PHOTO_MFNR_2DNR_ISO_STRATEGY_S;
  118. typedef struct hiPHOTO_MFNR_2DNR_PARAM_S
  119. {
  120. PHOTO_MFNR_2DNR_ISO_STRATEGY_S ast2DNRIsoStrat[PHOTO_MFNR_ISO_LEVEL_CNT];
  121. }PHOTO_MFNR_2DNR_PARAM_S;
  122. typedef struct hiPHOTO_DE_ISO_STRATEGY_S
  123. {
  124. HI_S32 s32IsoValue;
  125. HI_S32 s32GlobalGain;
  126. HI_S32 s32GainLF;
  127. HI_S32 s32GainHFPos;
  128. HI_S32 s32GainHFNeg;
  129. HI_S32 s32LumaScaleX0;
  130. HI_S32 s32LumaScaleX1;
  131. HI_S32 s32LumaScaleY1;
  132. HI_S32 s32SatuGainX0;
  133. HI_S32 s32SatuGainX1;
  134. HI_S32 s32SatuGainY1;
  135. }PHOTO_DE_ISO_STRATEGY_S;
  136. typedef struct hiPHOTO_DE_COEF_S
  137. {
  138. PHOTO_DE_ISO_STRATEGY_S astDEIsoStrat[PHOTO_DE_ISO_LEVEL_CNT];
  139. }PHOTO_DE_COEF_S;
  140. typedef struct hiPHOTO_MFNR_COEF_S
  141. {
  142. HI_BOOL bImageScale;
  143. PHOTO_MFNR_3DNR_PARAM_S st3DNRParam;
  144. PHOTO_MFNR_2DNR_PARAM_S st2DNRParam;
  145. HI_BOOL bDEEnable;
  146. PHOTO_DE_COEF_S stPhotoDECoef;
  147. }PHOTO_MFNR_COEF_S;
  148. typedef struct hiPHOTO_ALG_COEF_S
  149. {
  150. union
  151. {
  152. PHOTO_HDR_COEF_S stPhotoHdrCoef;
  153. PHOTO_SFNR_COEF_S stPhotoSfnrCoef;
  154. PHOTO_MFNR_COEF_S stPhotoMfnrCoef;
  155. PHOTO_DE_COEF_S stPhotoDECoef;
  156. };
  157. }PHOTO_ALG_COEF_S;
  158. #if 0
  159. typedef HI_U32 (*PFN_PHOTO_AlgMemMalloc)(HI_U32 u32MemSize, HI_U64* pu64PhyAddr, HI_VOID** ppVirAddr);
  160. typedef HI_U32 (*PFN_PHOTO_AlgMemFree)(HI_U64 u64PhyAddr, HI_VOID* pVirAddr);
  161. typedef struct hiPHOTO_ALG_INIT_S
  162. {
  163. PFN_PHOTO_AlgMalloc pfnMallocCB;
  164. PFN_PHOTO_AlgMemFree pfnFreeCB;
  165. HI_BOOL bPrintDebugInfo;
  166. }PHOTO_ALG_INIT_S;
  167. #else
  168. typedef struct hiPHOTO_ALG_INIT_S
  169. {
  170. HI_U64 u64PublicMemPhyAddr;
  171. HI_U64 u64PublicMemVirAddr;
  172. HI_U32 u32PublicMemSize;
  173. HI_BOOL bPrintDebugInfo;
  174. }PHOTO_ALG_INIT_S;
  175. #endif
  176. typedef struct hiPHOTO_HDR_ATTR_S
  177. {
  178. VIDEO_FRAME_INFO_S stSrcFrm;
  179. VIDEO_FRAME_INFO_S stDesFrm;
  180. HI_U32 u32FrmIndex;
  181. HI_U32 u32ISO;
  182. HI_U32 u32FaceNum;
  183. PHOTO_FACE_INFO_S astFaceInfo[PHOTO_MAX_FACE_NUM];
  184. }PHOTO_HDR_ATTR_S;
  185. typedef struct hiPHOTO_SFNR_ATTR_S
  186. {
  187. VIDEO_FRAME_INFO_S stFrm; // src & des
  188. HI_U32 u32ISO;
  189. }PHOTO_SFNR_ATTR_S;
  190. typedef struct hiPHOTO_MFNR_ATTR_S
  191. {
  192. VIDEO_FRAME_INFO_S stSrcFrm;
  193. VIDEO_FRAME_INFO_S stDesFrm;
  194. VIDEO_FRAME_INFO_S stRawFrm;
  195. HI_U32 u32FrmIndex;
  196. HI_U32 u32ISO;
  197. }PHOTO_MFNR_ATTR_S;
  198. typedef struct hiPHOTO_DE_ATTR_S
  199. {
  200. VIDEO_FRAME_INFO_S stFrm; // src & des
  201. VIDEO_FRAME_INFO_S stRawFrm;
  202. HI_U32 u32ISO;
  203. }PHOTO_DE_ATTR_S;
  204. typedef struct hiPHOTO_ALG_ATTR_S
  205. {
  206. union
  207. {
  208. PHOTO_HDR_ATTR_S stHDRAttr;
  209. PHOTO_SFNR_ATTR_S stSFNRAttr;
  210. PHOTO_MFNR_ATTR_S stMFNRAttr;
  211. PHOTO_DE_ATTR_S stDEAttr;
  212. };
  213. }PHOTO_ALG_ATTR_S;
  214. __inline static HI_U32 HDR_GetPublicMemSize(HI_U32 u32Width, HI_U32 u32Height)
  215. {
  216. HI_U32 u32Stride = ALIGN_UP(u32Width, 128);
  217. HI_U32 u32PubMemSize = u32Stride * u32Height * 13.4 + 7000000;
  218. return u32PubMemSize;
  219. }
  220. __inline static HI_U32 MFNR_GetPublicMemSize(HI_U32 u32Width, HI_U32 u32Height)
  221. {
  222. HI_U32 u32Stride = ALIGN_UP(u32Width, 128);
  223. HI_U32 u32PubMemSize = u32Stride * u32Height * 12.6 + 6000000;
  224. return u32PubMemSize;
  225. }
  226. __inline static HI_U32 SFNR_GetPublicMemSize(HI_U32 u32Width, HI_U32 u32Height)
  227. {
  228. HI_U32 u32Stride = ALIGN_UP(u32Width, 128);
  229. HI_U32 u32PubMemSize = u32Stride * u32Height * 3.6 + 550000;
  230. return u32PubMemSize;
  231. }
  232. __inline static HI_U32 DE_GetPublicMemSize(HI_U32 u32Width, HI_U32 u32Height)
  233. {
  234. HI_U32 u32Stride = ALIGN_UP(u32Width>>1, 128);
  235. HI_U32 u32PubMemSize = u32Stride * u32Height + 1024;
  236. return u32PubMemSize;
  237. }
  238. #define HI_ERR_PHOTO_NULL_PTR HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
  239. #define HI_ERR_PHOTO_NOTREADY HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
  240. #define HI_ERR_PHOTO_INVALID_DEVID HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID)
  241. #define HI_ERR_PHOTO_INVALID_CHNID HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
  242. #define HI_ERR_PHOTO_EXIST HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST)
  243. #define HI_ERR_PHOTO_UNEXIST HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
  244. #define HI_ERR_PHOTO_NOT_CONFIG HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
  245. #define HI_ERR_PHOTO_NOT_SUPPORT HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
  246. #define HI_ERR_PHOTO_NOT_PERM HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
  247. #define HI_ERR_PHOTO_NOMEM HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
  248. #define HI_ERR_PHOTO_NOBUF HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
  249. #define HI_ERR_PHOTO_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
  250. #define HI_ERR_PHOTO_BUSY HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
  251. #define HI_ERR_PHOTO_BUF_EMPTY HI_DEF_ERR(HI_ID_PHOTO, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
  252. #ifdef __cplusplus
  253. #if __cplusplus
  254. }
  255. #endif
  256. #endif /* __cplusplus */
  257. #endif /* __HI_COMM_PHOTO_H__ */