IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SaturatedCastPack.h
1 // SaturatedCastPack.h:
3 // ------------
4 //
15 
16 #ifndef __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX_SATURATEDCASTPACK_H__
17 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX_SATURATEDCASTPACK_H__
18 
24 
25 namespace ipsdk {
26 namespace simd {
27 namespace detail {
28 
31 
33 template <typename TIn, typename TOut>
34 struct SaturatedCastPack<eInstructionSet::eIS_Avx, TIn, TOut,
35  typename boost::enable_if_c<
36  sizeof(TIn) <= sizeof(TOut)
37  >::type
38 >
39 {
40  static IPSDK_FORCEINLINE BasePack<ePackType::ePT_Avx, TOut>
41  act(const BasePack<ePackType::ePT_Avx, TIn>& in)
42  {
43  return CastPack<eInstructionSet::eIS_Avx, TIn, TOut>::act(in);
44  }
45 
46  static IPSDK_FORCEINLINE
47  void
48  act(const BasePack<ePackType::ePT_Avx, TIn>& in,
49  BasePack<ePackType::ePT_Avx, TOut> & out)
50  {
51  CastPack<eInstructionSet::eIS_Avx, TIn, TOut>::act(in, out);
52  }
53 };
54 
55 template <>
56 struct SaturatedCastPack<eInstructionSet::eIS_Avx, ipReal64, ipReal32>
57 {
58  static IPSDK_FORCEINLINE BasePack<ePackType::ePT_Avx, ipReal32>
59  act(const BasePack<ePackType::ePT_Avx, ipReal64>& in)
60  {
61  BasePack<ePackType::ePT_Avx, ipReal64> clampedIn, packMin, packMax;
62  simd::assign<eInstructionSet::eIS_Avx>(packMin, NumericLimits<ipReal32>::min());
63  simd::assign<eInstructionSet::eIS_Avx>(packMax, NumericLimits<ipReal32>::max());
64  simd::min<eInstructionSet::eIS_Avx>(packMax, in, clampedIn);
65  simd::max<eInstructionSet::eIS_Avx>(packMin, clampedIn, clampedIn);
66 
67  return CastPack<eInstructionSet::eIS_Avx, ipReal64, ipReal32>::act(clampedIn);
68  }
69 
70  static IPSDK_FORCEINLINE
71  void
72  act(const BasePack<ePackType::ePT_Avx, ipReal64>& in,
73  BasePack<ePackType::ePT_Avx, ipReal32> & out)
74  {
75  BasePack<ePackType::ePT_Avx, ipReal64> clampedIn, packMin, packMax;
76  simd::assign<eInstructionSet::eIS_Avx>(packMin, NumericLimits<ipReal32>::min());
77  simd::assign<eInstructionSet::eIS_Avx>(packMax, NumericLimits<ipReal32>::max());
78  simd::min<eInstructionSet::eIS_Avx>(packMax, in, clampedIn);
79  simd::max<eInstructionSet::eIS_Avx>(packMin, clampedIn, clampedIn);
80 
81  CastPack<eInstructionSet::eIS_Avx, ipReal64, ipReal32>::act(clampedIn, out);
82  }
83 };
84 
87 
88 } // end of namespace detail
89 } // end of namespace simd
90 } // end of namespace ipsdk
91 
92 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_AVX_SATURATEDCASTPACK_H__
93 
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
BasePack class; defines a set of scalars (for instruction set "standard") or registers (for all other...
eInstructionSet
Enumerate for processor instruction set description.
Definition: InstructionSetTypes.h:31
Advanced Vector Extensions.
Definition: InstructionSetTypes.h:44
Definition of import/export macro for library.
float ipReal32
Base types definition.
Definition: BaseTypes.h:56