core.hpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_RVV_HAL_CORE_HPP
  5. #define OPENCV_RVV_HAL_CORE_HPP
  6. namespace cv { namespace rvv_hal { namespace core {
  7. #if CV_HAL_RVV_1P0_ENABLED
  8. /* ############ merge ############ */
  9. int merge8u(const uchar** src, uchar* dst, int len, int cn);
  10. int merge16u(const ushort** src, ushort* dst, int len, int cn);
  11. int merge32s(const int** src, int* dst, int len, int cn);
  12. int merge64s(const int64** src, int64* dst, int len, int cn);
  13. #undef cv_hal_merge8u
  14. #define cv_hal_merge8u cv::rvv_hal::core::merge8u
  15. #undef cv_hal_merge16u
  16. #define cv_hal_merge16u cv::rvv_hal::core::merge16u
  17. #undef cv_hal_merge32s
  18. #define cv_hal_merge32s cv::rvv_hal::core::merge32s
  19. #undef cv_hal_merge64s
  20. #define cv_hal_merge64s cv::rvv_hal::core::merge64s
  21. /* ############ meanStdDev ############ */
  22. int meanStdDev(const uchar* src_data, size_t src_step, int width, int height, int src_type,
  23. double* mean_val, double* stddev_val, uchar* mask, size_t mask_step);
  24. #undef cv_hal_meanStdDev
  25. #define cv_hal_meanStdDev cv::rvv_hal::core::meanStdDev
  26. /* ############ dft ############ */
  27. int dft(const uchar* src, uchar* dst, int depth, int nf, int *factors, double scale,
  28. int* itab, void* wave, int tab_size, int n, bool isInverse, bool noPermute);
  29. #undef cv_hal_dft
  30. #define cv_hal_dft cv::rvv_hal::core::dft
  31. /* ############ norm ############ */
  32. int norm(const uchar* src, size_t src_step, const uchar* mask, size_t mask_step,
  33. int width, int height, int type, int norm_type, double* result);
  34. #undef cv_hal_norm
  35. #define cv_hal_norm cv::rvv_hal::core::norm
  36. /* ############ normDiff ############ */
  37. int normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2_step,
  38. const uchar* mask, size_t mask_step, int width, int height, int type,
  39. int norm_type, double* result);
  40. #undef cv_hal_normDiff
  41. #define cv_hal_normDiff cv::rvv_hal::core::normDiff
  42. /* ############ normHamming ############ */
  43. int normHamming8u(const uchar* a, int n, int cellSize, int* result);
  44. int normHammingDiff8u(const uchar* a, const uchar* b, int n, int cellSize, int* result);
  45. #undef cv_hal_normHamming8u
  46. #define cv_hal_normHamming8u cv::rvv_hal::core::normHamming8u
  47. #undef cv_hal_normHammingDiff8u
  48. #define cv_hal_normHammingDiff8u cv::rvv_hal::core::normHammingDiff8u
  49. /* ############ convertScale ############ */
  50. int convertScale(const uchar* src, size_t src_step, uchar* dst, size_t dst_step,
  51. int width, int height, int sdepth, int ddepth, double alpha, double beta);
  52. #undef cv_hal_convertScale
  53. #define cv_hal_convertScale cv::rvv_hal::core::convertScale
  54. /* ############ minMaxIdx ############ */
  55. int minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth,
  56. double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask, size_t mask_step = 0);
  57. #undef cv_hal_minMaxIdx
  58. #define cv_hal_minMaxIdx cv::rvv_hal::core::minMaxIdx
  59. #undef cv_hal_minMaxIdxMaskStep
  60. #define cv_hal_minMaxIdxMaskStep cv::rvv_hal::core::minMaxIdx
  61. /* ############ fastAtan ############ */
  62. int fast_atan_32(const float* y, const float* x, float* dst, size_t n, bool angle_in_deg);
  63. int fast_atan_64(const double* y, const double* x, double* dst, size_t n, bool angle_in_deg);
  64. #undef cv_hal_fastAtan32f
  65. #define cv_hal_fastAtan32f cv::rvv_hal::core::fast_atan_32
  66. #undef cv_hal_fastAtan64f
  67. #define cv_hal_fastAtan64f cv::rvv_hal::core::fast_atan_64
  68. /* ############ split ############ */
  69. int split8u(const uchar* src, uchar** dst, int len, int cn);
  70. #undef cv_hal_split8u
  71. #define cv_hal_split8u cv::rvv_hal::core::split8u
  72. /* ############ sqrt ############ */
  73. int sqrt32f(const float* src, float* dst, int _len);
  74. int sqrt64f(const double* src, double* dst, int _len);
  75. #undef cv_hal_sqrt32f
  76. #define cv_hal_sqrt32f cv::rvv_hal::core::sqrt32f
  77. #undef cv_hal_sqrt64f
  78. #define cv_hal_sqrt64f cv::rvv_hal::core::sqrt64f
  79. int invSqrt32f(const float* src, float* dst, int _len);
  80. int invSqrt64f(const double* src, double* dst, int _len);
  81. #undef cv_hal_invSqrt32f
  82. #define cv_hal_invSqrt32f cv::rvv_hal::core::invSqrt32f
  83. #undef cv_hal_invSqrt64f
  84. #define cv_hal_invSqrt64f cv::rvv_hal::core::invSqrt64f
  85. /* ############ magnitude ############ */
  86. int magnitude32f(const float *x, const float *y, float *dst, int len);
  87. int magnitude64f(const double *x, const double *y, double *dst, int len);
  88. #undef cv_hal_magnitude32f
  89. #define cv_hal_magnitude32f cv::rvv_hal::core::magnitude32f
  90. #undef cv_hal_magnitude64f
  91. #define cv_hal_magnitude64f cv::rvv_hal::core::magnitude64f
  92. /* ############ cartToPolar ############ */
  93. int cartToPolar32f(const float* x, const float* y, float* mag, float* angle, int len, bool angleInDegrees);
  94. int cartToPolar64f(const double* x, const double* y, double* mag, double* angle, int len, bool angleInDegrees);
  95. #undef cv_hal_cartToPolar32f
  96. #define cv_hal_cartToPolar32f cv::rvv_hal::core::cartToPolar32f
  97. #undef cv_hal_cartToPolar64f
  98. #define cv_hal_cartToPolar64f cv::rvv_hal::core::cartToPolar64f
  99. /* ############ polarToCart ############ */
  100. int polarToCart32f(const float* mag, const float* angle, float* x, float* y, int len, bool angleInDegrees);
  101. int polarToCart64f(const double* mag, const double* angle, double* x, double* y, int len, bool angleInDegrees);
  102. #undef cv_hal_polarToCart32f
  103. #define cv_hal_polarToCart32f cv::rvv_hal::core::polarToCart32f
  104. #undef cv_hal_polarToCart64f
  105. #define cv_hal_polarToCart64f cv::rvv_hal::core::polarToCart64f
  106. /* ############ polarToCart ############ */
  107. int flip(int src_type, const uchar* src_data, size_t src_step, int src_width, int src_height,
  108. uchar* dst_data, size_t dst_step, int flip_mode);
  109. #undef cv_hal_flip
  110. #define cv_hal_flip cv::rvv_hal::core::flip
  111. /* ############ lut ############ */
  112. int lut(const uchar* src_data, size_t src_step, size_t src_type,
  113. const uchar* lut_data, size_t lut_channel_size, size_t lut_channels,
  114. uchar* dst_data, size_t dst_step, int width, int height);
  115. #undef cv_hal_lut
  116. #define cv_hal_lut cv::rvv_hal::core::lut
  117. /* ############ exp ############ */
  118. int exp32f(const float* src, float* dst, int _len);
  119. int exp64f(const double* src, double* dst, int _len);
  120. #undef cv_hal_exp32f
  121. #define cv_hal_exp32f cv::rvv_hal::core::exp32f
  122. #undef cv_hal_exp64f
  123. #define cv_hal_exp64f cv::rvv_hal::core::exp64f
  124. /* ############ log ############ */
  125. int log32f(const float* src, float* dst, int _len);
  126. int log64f(const double* src, double* dst, int _len);
  127. #undef cv_hal_log32f
  128. #define cv_hal_log32f cv::rvv_hal::core::log32f
  129. #undef cv_hal_log64f
  130. #define cv_hal_log64f cv::rvv_hal::core::log64f
  131. /* ############ lu ############ */
  132. int LU32f(float* src1, size_t src1_step, int m, float* src2, size_t src2_step, int n, int* info);
  133. int LU64f(double* src1, size_t src1_step, int m, double* src2, size_t src2_step, int n, int* info);
  134. #undef cv_hal_LU32f
  135. #define cv_hal_LU32f cv::rvv_hal::core::LU32f
  136. #undef cv_hal_LU64f
  137. #define cv_hal_LU64f cv::rvv_hal::core::LU64f
  138. /* ############ cholesky ############ */
  139. int Cholesky32f(float* src1, size_t src1_step, int m, float* src2, size_t src2_step, int n, bool* info);
  140. int Cholesky64f(double* src1, size_t src1_step, int m, double* src2, size_t src2_step, int n, bool* info);
  141. #undef cv_hal_Cholesky32f
  142. #define cv_hal_Cholesky32f cv::rvv_hal::core::Cholesky32f
  143. #undef cv_hal_Cholesky64f
  144. #define cv_hal_Cholesky64f cv::rvv_hal::core::Cholesky64f
  145. /* ############ qr ############ */
  146. int QR32f(float* src1, size_t src1_step, int m, int n, int k, float* src2, size_t src2_step, float* dst, int* info);
  147. int QR64f(double* src1, size_t src1_step, int m, int n, int k, double* src2, size_t src2_step, double* dst, int* info);
  148. #undef cv_hal_QR32f
  149. #define cv_hal_QR32f cv::rvv_hal::core::QR32f
  150. #undef cv_hal_QR64f
  151. #define cv_hal_QR64f cv::rvv_hal::core::QR64f
  152. /* ############ SVD ############ */
  153. int SVD32f(float* src, size_t src_step, float* w, float* u, size_t u_step, float* vt, size_t vt_step, int m, int n, int flags);
  154. int SVD64f(double* src, size_t src_step, double* w, double* u, size_t u_step, double* vt, size_t vt_step, int m, int n, int flags);
  155. #undef cv_hal_SVD32f
  156. #define cv_hal_SVD32f cv::rvv_hal::core::SVD32f
  157. #undef cv_hal_SVD64f
  158. #define cv_hal_SVD64f cv::rvv_hal::core::SVD64f
  159. /* ############ copyToMasked ############ */
  160. int copyToMasked(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int width, int height,
  161. int type, const uchar *mask_data, size_t mask_step, int mask_type);
  162. #undef cv_hal_copyToMasked
  163. #define cv_hal_copyToMasked cv::rvv_hal::core::copyToMasked
  164. /* ############ div, recip ############ */
  165. int div8u(const uchar *src1_data, size_t src1_step, const uchar *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, double scale);
  166. int div8s(const schar *src1_data, size_t src1_step, const schar *src2_data, size_t src2_step, schar *dst_data, size_t dst_step, int width, int height, double scale);
  167. int div16u(const ushort *src1_data, size_t src1_step, const ushort *src2_data, size_t src2_step, ushort *dst_data, size_t dst_step, int width, int height, double scale);
  168. int div16s(const short *src1_data, size_t src1_step, const short *src2_data, size_t src2_step, short *dst_data, size_t dst_step, int width, int height, double scale);
  169. int div32s(const int *src1_data, size_t src1_step, const int *src2_data, size_t src2_step, int *dst_data, size_t dst_step, int width, int height, double scale);
  170. int div32f(const float *src1_data, size_t src1_step, const float *src2_data, size_t src2_step, float *dst_data, size_t dst_step, int width, int height, double scale);
  171. // int div64f(const double *src1_data, size_t src1_step, const double *src2_data, size_t src2_step, double *dst_data, size_t dst_step, int width, int height, double scale);
  172. #undef cv_hal_div8u
  173. #define cv_hal_div8u cv::rvv_hal::core::div8u
  174. #undef cv_hal_div8s
  175. #define cv_hal_div8s cv::rvv_hal::core::div8s
  176. #undef cv_hal_div16u
  177. #define cv_hal_div16u cv::rvv_hal::core::div16u
  178. #undef cv_hal_div16s
  179. #define cv_hal_div16s cv::rvv_hal::core::div16s
  180. #undef cv_hal_div32s
  181. #define cv_hal_div32s cv::rvv_hal::core::div32s
  182. #undef cv_hal_div32f
  183. #define cv_hal_div32f cv::rvv_hal::core::div32f
  184. // #undef cv_hal_div64f
  185. // #define cv_hal_div64f cv::rvv_hal::core::div64f
  186. int recip8u(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step, int width, int height, double scale);
  187. int recip8s(const schar *src_data, size_t src_step, schar *dst_data, size_t dst_step, int width, int height, double scale);
  188. int recip16u(const ushort *src_data, size_t src_step, ushort *dst_data, size_t dst_step, int width, int height, double scale);
  189. int recip16s(const short *src_data, size_t src_step, short *dst_data, size_t dst_step, int width, int height, double scale);
  190. int recip32s(const int *src_data, size_t src_step, int *dst_data, size_t dst_step, int width, int height, double scale);
  191. int recip32f(const float *src_data, size_t src_step, float *dst_data, size_t dst_step, int width, int height, double scale);
  192. // int recip64f(const double *src_data, size_t src_step, double *dst_data, size_t dst_step, int width, int height, double scale);
  193. #undef cv_hal_recip8u
  194. #define cv_hal_recip8u cv::rvv_hal::core::recip8u
  195. #undef cv_hal_recip8s
  196. #define cv_hal_recip8s cv::rvv_hal::core::recip8s
  197. #undef cv_hal_recip16u
  198. #define cv_hal_recip16u cv::rvv_hal::core::recip16u
  199. #undef cv_hal_recip16s
  200. #define cv_hal_recip16s cv::rvv_hal::core::recip16s
  201. #undef cv_hal_recip32s
  202. #define cv_hal_recip32s cv::rvv_hal::core::recip32s
  203. #undef cv_hal_recip32f
  204. #define cv_hal_recip32f cv::rvv_hal::core::recip32f
  205. // #undef cv_hal_recip64f
  206. // #define cv_hal_recip64f cv::rvv_hal::core::recip64f
  207. /* ############ dotProduct ############ */
  208. int dotprod(const uchar *a_data, size_t a_step, const uchar *b_data, size_t b_step,
  209. int width, int height, int type, double *dot_val);
  210. #undef cv_hal_dotProduct
  211. #define cv_hal_dotProduct cv::rvv_hal::core::dotprod
  212. /* ############ compare ############ */
  213. int cmp8u(const uchar *src1_data, size_t src1_step, const uchar *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  214. int cmp8s(const schar *src1_data, size_t src1_step, const schar *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  215. int cmp16u(const ushort *src1_data, size_t src1_step, const ushort *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  216. int cmp16s(const short *src1_data, size_t src1_step, const short *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  217. int cmp32s(const int *src1_data, size_t src1_step, const int *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  218. int cmp32f(const float *src1_data, size_t src1_step, const float *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  219. // int cmp64f(const double *src1_data, size_t src1_step, const double *src2_data, size_t src2_step, uchar *dst_data, size_t dst_step, int width, int height, int operation);
  220. #undef cv_hal_cmp8u
  221. #define cv_hal_cmp8u cv::rvv_hal::core::cmp8u
  222. #undef cv_hal_cmp8s
  223. #define cv_hal_cmp8s cv::rvv_hal::core::cmp8s
  224. #undef cv_hal_cmp16u
  225. #define cv_hal_cmp16u cv::rvv_hal::core::cmp16u
  226. #undef cv_hal_cmp16s
  227. #define cv_hal_cmp16s cv::rvv_hal::core::cmp16s
  228. #undef cv_hal_cmp32s
  229. #define cv_hal_cmp32s cv::rvv_hal::core::cmp32s
  230. #undef cv_hal_cmp32f
  231. #define cv_hal_cmp32f cv::rvv_hal::core::cmp32f
  232. // #undef cv_hal_cmp64f
  233. // #define cv_hal_cmp64f cv::rvv_hal::core::cmp64f
  234. /* ############ transpose2d ############ */
  235. int transpose2d(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
  236. int src_width, int src_height, int element_size);
  237. #undef cv_hal_transpose2d
  238. #define cv_hal_transpose2d cv::rvv_hal::core::transpose2d
  239. #endif // CV_HAL_RVV_1P0_ENABLED
  240. }}} // cv::rvv_hal::core
  241. #endif // OPENCV_RVV_HAL_CORE_HPP