Download 3rdparty/ndsrvp/src/cvutils.hpp from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 3.4 kB
-
https://huggingface.co/tgollogly/test/resolve/main/3rdparty/ndsrvp/src/cvutils.hpp
- Command line
-
hf download hf://tgollogly/test/3rdparty/ndsrvp/src/cvutils.hpp
-
curl -L -o cvutils.hpp https://huggingface.co/tgollogly/test/resolve/main/3rdparty/ndsrvp/src/cvutils.hpp
3.4 kB
| // This file is part of OpenCV project. | |
| // It is subject to the license terms in the LICENSE file found in the top-level directory | |
| // of this distribution and at http://opencv.org/license.html. | |
| // misc functions that not exposed to public interface | |
| namespace cv { | |
| namespace ndsrvp { | |
| void* fastMalloc(size_t size); | |
| void fastFree(void* ptr); | |
| int borderInterpolate(int p, int len, int borderType); | |
| // error codes | |
| enum Error{ | |
| StsNoMem = -4, | |
| StsBadArg = -5, | |
| StsAssert = -215 | |
| }; | |
| // output error | |
| inline void ndsrvp_error(int code, std::string msg = "") | |
| { | |
| std::cerr << "NDSRVP Error: code " << code << std::endl; | |
| if(!msg.empty()) | |
| std::cerr << msg << std::endl; | |
| if(code < 0) | |
| throw code; | |
| } | |
| // clip & vclip | |
| inline int clip(int x, int a, int b) | |
| { | |
| return x >= a ? (x < b ? x : b - 1) : a; | |
| } | |
| inline int32x2_t vclip(int32x2_t x, int32x2_t a, int32x2_t b) | |
| { | |
| return (int32x2_t)__nds__bpick((long)a, __nds__bpick((long)(b - 1), (long)x, (long)(x < b)), (long)(x >= a)); | |
| } | |
| // saturate | |
| template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); } | |
| template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); } | |
| template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); } | |
| template<> inline uchar saturate_cast<uchar>(int v) { return __nds__uclip32(v, 8); } | |
| template<> inline uchar saturate_cast<uchar>(float v) { return saturate_cast<uchar>((int)lrintf(v)); } | |
| template<> inline uchar saturate_cast<uchar>(double v) { return saturate_cast<uchar>((int)lrint(v)); } | |
| template<> inline char saturate_cast<char>(int v) { return __nds__sclip32(v, 7); } | |
| template<> inline char saturate_cast<char>(float v) { return saturate_cast<char>((int)lrintf(v)); } | |
| template<> inline char saturate_cast<char>(double v) { return saturate_cast<char>((int)lrint(v)); } | |
| template<> inline ushort saturate_cast<ushort>(int v) { return __nds__uclip32(v, 16); } | |
| template<> inline ushort saturate_cast<ushort>(float v) { return saturate_cast<ushort>((int)lrintf(v)); } | |
| template<> inline ushort saturate_cast<ushort>(double v) { return saturate_cast<ushort>((int)lrint(v)); } | |
| template<> inline short saturate_cast<short>(int v) { return __nds__sclip32(v, 15); } | |
| template<> inline short saturate_cast<short>(float v) { return saturate_cast<short>((int)lrintf(v)); } | |
| template<> inline short saturate_cast<short>(double v) { return saturate_cast<short>((int)lrint(v)); } | |
| template<> inline int saturate_cast<int>(float v) { return (int)lrintf(v); } | |
| template<> inline int saturate_cast<int>(double v) { return (int)lrint(v); } | |
| // align | |
| inline long align(size_t v, int n) | |
| { | |
| return (v + n - 1) & -n; | |
| } | |
| } // namespace ndsrvp | |
| } // namespace cv | |