/*1* By downloading, copying, installing or using the software you agree to this license.2* If you do not agree to this license, do not download, install,3* copy or use the software.4*5*6* License Agreement7* For Open Source Computer Vision Library8* (3-clause BSD License)9*10* Copyright (C) 2014, NVIDIA Corporation, all rights reserved.11* Third party copyrights are property of their respective owners.12*13* Redistribution and use in source and binary forms, with or without modification,14* are permitted provided that the following conditions are met:15*16* * Redistributions of source code must retain the above copyright notice,17* this list of conditions and the following disclaimer.18*19* * Redistributions in binary form must reproduce the above copyright notice,20* this list of conditions and the following disclaimer in the documentation21* and/or other materials provided with the distribution.22*23* * Neither the names of the copyright holders nor the names of the contributors24* may be used to endorse or promote products derived from this software25* without specific prior written permission.26*27* This software is provided by the copyright holders and contributors "as is" and28* any express or implied warranties, including, but not limited to, the implied29* warranties of merchantability and fitness for a particular purpose are disclaimed.30* In no event shall copyright holders or contributors be liable for any direct,31* indirect, incidental, special, exemplary, or consequential damages32* (including, but not limited to, procurement of substitute goods or services;33* loss of use, data, or profits; or business interruption) however caused34* and on any theory of liability, whether in contract, strict liability,35* or tort (including negligence or otherwise) arising in any way out of36* the use of this software, even if advised of the possibility of such damage.37*/3839#include <algorithm>4041#include "common.hpp"42#include "vtransform.hpp"4344namespace CAROTENE_NS {4546#ifdef CAROTENE_NEON4748namespace {4950template <typename T>51struct Min52{53typedef T type;5455void operator() (const typename internal::VecTraits<T>::vec128 & v_src0,56const typename internal::VecTraits<T>::vec128 & v_src1,57typename internal::VecTraits<T>::vec128 & v_dst) const58{59v_dst = internal::vminq(v_src0, v_src1);60}6162void operator() (const typename internal::VecTraits<T>::vec64 & v_src0,63const typename internal::VecTraits<T>::vec64 & v_src1,64typename internal::VecTraits<T>::vec64 & v_dst) const65{66v_dst = internal::vmin(v_src0, v_src1);67}6869void operator() (const T * src0, const T * src1, T * dst) const70{71dst[0] = std::min(src0[0], src1[0]);72}73};7475template <typename T>76struct Max77{78typedef T type;7980void operator() (const typename internal::VecTraits<T>::vec128 & v_src0,81const typename internal::VecTraits<T>::vec128 & v_src1,82typename internal::VecTraits<T>::vec128 & v_dst) const83{84v_dst = internal::vmaxq(v_src0, v_src1);85}8687void operator() (const typename internal::VecTraits<T>::vec64 & v_src0,88const typename internal::VecTraits<T>::vec64 & v_src1,89typename internal::VecTraits<T>::vec64 & v_dst) const90{91v_dst = internal::vmax(v_src0, v_src1);92}9394void operator() (const T * src0, const T * src1, T * dst) const95{96dst[0] = std::max(src0[0], src1[0]);97}98};99100} // namespace101102#define IMPL_OP(fun, op, type) \103void fun(const Size2D &size, \104const type * src0Base, ptrdiff_t src0Stride, \105const type * src1Base, ptrdiff_t src1Stride, \106type * dstBase, ptrdiff_t dstStride) \107{ \108internal::assertSupportedConfiguration(); \109internal::vtransform(size, \110src0Base, src0Stride, \111src1Base, src1Stride, \112dstBase, dstStride, op<type>()); \113}114115#else116117#define IMPL_OP(fun, op, type) \118void fun(const Size2D &, \119const type *, ptrdiff_t, \120const type *, ptrdiff_t, \121type *, ptrdiff_t) \122{ \123internal::assertSupportedConfiguration(); \124}125126#endif127128#define IMPL_MINMAX(type) IMPL_OP(min, Min, type) IMPL_OP(max, Max, type)129130IMPL_MINMAX(u8)131IMPL_MINMAX(s8)132IMPL_MINMAX(u16)133IMPL_MINMAX(s16)134IMPL_MINMAX(u32)135IMPL_MINMAX(s32)136IMPL_MINMAX(f32)137138} // namespace CAROTENE_NS139140141