1 /* 2 * By downloading, copying, installing or using the software you agree to this license. 3 * If you do not agree to this license, do not download, install, 4 * copy or use the software. 5 * 6 * 7 * License Agreement 8 * For Open Source Computer Vision Library 9 * (3-clause BSD License) 10 * 11 * Copyright (C) 2014, NVIDIA Corporation, all rights reserved. 12 * Third party copyrights are property of their respective owners. 13 * 14 * Redistribution and use in source and binary forms, with or without modification, 15 * are permitted provided that the following conditions are met: 16 * 17 * * Redistributions of source code must retain the above copyright notice, 18 * this list of conditions and the following disclaimer. 19 * 20 * * Redistributions in binary form must reproduce the above copyright notice, 21 * this list of conditions and the following disclaimer in the documentation 22 * and/or other materials provided with the distribution. 23 * 24 * * Neither the names of the copyright holders nor the names of the contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * This software is provided by the copyright holders and contributors "as is" and 29 * any express or implied warranties, including, but not limited to, the implied 30 * warranties of merchantability and fitness for a particular purpose are disclaimed. 31 * In no event shall copyright holders or contributors be liable for any direct, 32 * indirect, incidental, special, exemplary, or consequential damages 33 * (including, but not limited to, procurement of substitute goods or services; 34 * loss of use, data, or profits; or business interruption) however caused 35 * and on any theory of liability, whether in contract, strict liability, 36 * or tort (including negligence or otherwise) arising in any way out of 37 * the use of this software, even if advised of the possibility of such damage. 38 */ 39 40 #include <algorithm> 41 42 #include "common.hpp" 43 #include "vtransform.hpp" 44 45 namespace CAROTENE_NS { 46 47 #ifdef CAROTENE_NEON 48 49 namespace { 50 51 template <typename T> 52 struct Min 53 { 54 typedef T type; 55 operator ()CAROTENE_NS::__anond799e5510111::Min56 void operator() (const typename internal::VecTraits<T>::vec128 & v_src0, 57 const typename internal::VecTraits<T>::vec128 & v_src1, 58 typename internal::VecTraits<T>::vec128 & v_dst) const 59 { 60 v_dst = internal::vminq(v_src0, v_src1); 61 } 62 operator ()CAROTENE_NS::__anond799e5510111::Min63 void operator() (const typename internal::VecTraits<T>::vec64 & v_src0, 64 const typename internal::VecTraits<T>::vec64 & v_src1, 65 typename internal::VecTraits<T>::vec64 & v_dst) const 66 { 67 v_dst = internal::vmin(v_src0, v_src1); 68 } 69 operator ()CAROTENE_NS::__anond799e5510111::Min70 void operator() (const T * src0, const T * src1, T * dst) const 71 { 72 dst[0] = std::min(src0[0], src1[0]); 73 } 74 }; 75 76 template <typename T> 77 struct Max 78 { 79 typedef T type; 80 operator ()CAROTENE_NS::__anond799e5510111::Max81 void operator() (const typename internal::VecTraits<T>::vec128 & v_src0, 82 const typename internal::VecTraits<T>::vec128 & v_src1, 83 typename internal::VecTraits<T>::vec128 & v_dst) const 84 { 85 v_dst = internal::vmaxq(v_src0, v_src1); 86 } 87 operator ()CAROTENE_NS::__anond799e5510111::Max88 void operator() (const typename internal::VecTraits<T>::vec64 & v_src0, 89 const typename internal::VecTraits<T>::vec64 & v_src1, 90 typename internal::VecTraits<T>::vec64 & v_dst) const 91 { 92 v_dst = internal::vmax(v_src0, v_src1); 93 } 94 operator ()CAROTENE_NS::__anond799e5510111::Max95 void operator() (const T * src0, const T * src1, T * dst) const 96 { 97 dst[0] = std::max(src0[0], src1[0]); 98 } 99 }; 100 101 } // namespace 102 103 #define IMPL_OP(fun, op, type) \ 104 void fun(const Size2D &size, \ 105 const type * src0Base, ptrdiff_t src0Stride, \ 106 const type * src1Base, ptrdiff_t src1Stride, \ 107 type * dstBase, ptrdiff_t dstStride) \ 108 { \ 109 internal::assertSupportedConfiguration(); \ 110 internal::vtransform(size, \ 111 src0Base, src0Stride, \ 112 src1Base, src1Stride, \ 113 dstBase, dstStride, op<type>()); \ 114 } 115 116 #else 117 118 #define IMPL_OP(fun, op, type) \ 119 void fun(const Size2D &, \ 120 const type *, ptrdiff_t, \ 121 const type *, ptrdiff_t, \ 122 type *, ptrdiff_t) \ 123 { \ 124 internal::assertSupportedConfiguration(); \ 125 } 126 127 #endif 128 129 #define IMPL_MINMAX(type) IMPL_OP(min, Min, type) IMPL_OP(max, Max, type) 130 131 IMPL_MINMAX(u8) 132 IMPL_MINMAX(s8) 133 IMPL_MINMAX(u16) 134 IMPL_MINMAX(s16) 135 IMPL_MINMAX(u32) 136 IMPL_MINMAX(s32) 137 IMPL_MINMAX(f32) 138 139 } // namespace CAROTENE_NS 140