OpenCV  4.1.0
Open Source Computer Vision
Namespaces | Macros
intrin_vsx.hpp File Reference
#include <algorithm>
#include "opencv2/core/utility.hpp"

Namespaces

namespace  cv
 "black box" representation of the file storage associated with a file on disk.
 

Macros

#define CV_SIMD128   1
 
#define CV_SIMD128_64F   1
 
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC(func, intrin)
 
#define OPENCV_HAL_IMPL_VSX_BIN_OP(bin_op, _Tpvec, intrin)
 
#define OPENCV_HAL_IMPL_VSX_EXPAND(_Tpvec, _Tpwvec, _Tp, fl, fh)
 
#define OPENCV_HAL_IMPL_VSX_INITVEC(_Tpvec, _Tp, suffix, cast)
 
#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)
 
#define OPENCV_HAL_IMPL_VSX_INTERLEAVE(_Tp, _Tpvec)
 
#define OPENCV_HAL_IMPL_VSX_LOADSTORE(_Tpvec, _Tp)   OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vec_ld, vsx_st, vec_st)
 
#define OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, ld, ld_a, st, st_a)
 
#define OPENCV_HAL_IMPL_VSX_LOGIC_OP(_Tpvec)
 
#define OPENCV_HAL_IMPL_VSX_MUL_SAT(_Tpvec, _Tpwvec)
 
#define OPENCV_HAL_IMPL_VSX_MULADD(_Tpvec)
 
#define OPENCV_HAL_IMPL_VSX_PACK(_Tpvec, _Tp, _Tpwvec, _Tpvn, _Tpdel, sfnc, pkfnc, addfnc, pack)
 
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(_Tpvec, _Tpvec2, scalartype, suffix, func)
 
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(_Tpvec, _Tpvec2, scalartype, suffix, func)
 
#define OPENCV_HAL_IMPL_VSX_SELECT(_Tpvec, cast)
 
#define OPENCV_HAL_IMPL_VSX_SHIFT_OP(_Tpvec, shr, splfunc)
 
#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(_Tpvec, _Tpvec2)
 
#define OPENCV_IMPL_VSX_ROTATE(_Tpvec, suffix, shf, cast)
 
#define OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, suffix, rg1, rg2)
 
#define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(_Tpvec)
 
#define OPENCV_IMPL_VSX_ROTATE_LR(_Tpvec, cast)
 

Macro Definition Documentation

#define CV_SIMD128   1
#define CV_SIMD128_64F   1
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC (   func,
  intrin 
)
Value:
template<typename _Tpvec> \
inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(intrin(a.val, b.val)); }
#define OPENCV_HAL_IMPL_VSX_BIN_OP (   bin_op,
  _Tpvec,
  intrin 
)
Value:
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(intrin(a.val, b.val)); } \
inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \
{ a.val = intrin(a.val, b.val); return a; }
#define OPENCV_HAL_IMPL_VSX_EXPAND (   _Tpvec,
  _Tpwvec,
  _Tp,
  fl,
  fh 
)
Value:
inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \
{ \
b0.val = fh(a.val); \
b1.val = fl(a.val); \
} \
inline _Tpwvec v_expand_low(const _Tpvec& a) \
{ return _Tpwvec(fh(a.val)); } \
inline _Tpwvec v_expand_high(const _Tpvec& a) \
{ return _Tpwvec(fl(a.val)); } \
inline _Tpwvec v_load_expand(const _Tp* ptr) \
{ return _Tpwvec(fh(vec_ld_l8(ptr))); }
#define OPENCV_HAL_IMPL_VSX_INITVEC (   _Tpvec,
  _Tp,
  suffix,
  cast 
)
Value:
inline _Tpvec v_setzero_##suffix() { return _Tpvec(); } \
inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));} \
template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a) \
{ return _Tpvec((cast)a.val); }
#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP (   _Tpvec)
Value:
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmpeq(a.val, b.val)); } \
inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmpne(a.val, b.val)); } \
inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmplt(a.val, b.val)); } \
inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmpgt(a.val, b.val)); } \
inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmple(a.val, b.val)); } \
inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_cmpge(a.val, b.val)); }
#define OPENCV_HAL_IMPL_VSX_INTERLEAVE (   _Tp,
  _Tpvec 
)
Value:
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b) \
{ vec_ld_deinterleave(ptr, a.val, b.val);} \
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, \
_Tpvec& b, _Tpvec& c) \
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val); } \
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b, \
_Tpvec& c, _Tpvec& d) \
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val, d.val); } \
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \
{ vec_st_interleave(a.val, b.val, ptr); } \
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, \
const _Tpvec& b, const _Tpvec& c, \
{ vec_st_interleave(a.val, b.val, c.val, ptr); } \
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \
const _Tpvec& c, const _Tpvec& d, \
{ vec_st_interleave(a.val, b.val, c.val, d.val, ptr); }
#define OPENCV_HAL_IMPL_VSX_LOADSTORE (   _Tpvec,
  _Tp 
)    OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vec_ld, vsx_st, vec_st)
#define OPENCV_HAL_IMPL_VSX_LOADSTORE_C (   _Tpvec,
  _Tp,
  ld,
  ld_a,
  st,
  st_a 
)
Value:
inline _Tpvec v_load(const _Tp* ptr) \
{ return _Tpvec(ld(0, ptr)); } \
inline _Tpvec v_load_aligned(VSX_UNUSED(const _Tp* ptr)) \
{ return _Tpvec(ld_a(0, ptr)); } \
inline _Tpvec v_load_low(const _Tp* ptr) \
{ return _Tpvec(vec_ld_l8(ptr)); } \
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
{ return _Tpvec(vec_mergesqh(vec_ld_l8(ptr0), vec_ld_l8(ptr1))); } \
inline void v_store(_Tp* ptr, const _Tpvec& a) \
{ st(a.val, 0, ptr); } \
inline void v_store_aligned(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \
{ st_a(a.val, 0, ptr); } \
inline void v_store_aligned_nocache(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \
{ st_a(a.val, 0, ptr); } \
inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \
{ if(mode == hal::STORE_UNALIGNED) st(a.val, 0, ptr); else st_a(a.val, 0, ptr); } \
inline void v_store_low(_Tp* ptr, const _Tpvec& a) \
{ vec_st_l8(a.val, ptr); } \
inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
{ vec_st_h8(a.val, ptr); }
#define OPENCV_HAL_IMPL_VSX_LOGIC_OP (   _Tpvec)
Value:
OPENCV_HAL_IMPL_VSX_BIN_OP(&, _Tpvec, vec_and) \
OPENCV_HAL_IMPL_VSX_BIN_OP(|, _Tpvec, vec_or) \
OPENCV_HAL_IMPL_VSX_BIN_OP(^, _Tpvec, vec_xor) \
inline _Tpvec operator ~ (const _Tpvec& a) \
{ return _Tpvec(vec_not(a.val)); }
#define OPENCV_HAL_IMPL_VSX_MUL_SAT (   _Tpvec,
  _Tpwvec 
)
Value:
inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \
{ \
_Tpwvec c, d; \
v_mul_expand(a, b, c, d); \
return v_pack(c, d); \
} \
inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \
{ a = a * b; return a; }
#define OPENCV_HAL_IMPL_VSX_MULADD (   _Tpvec)
Value:
inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_sqrt(vec_madd(a.val, a.val, vec_mul(b.val, b.val)))); } \
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_madd(a.val, a.val, vec_mul(b.val, b.val))); } \
inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
{ return _Tpvec(vec_madd(a.val, b.val, c.val)); } \
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
{ return _Tpvec(vec_madd(a.val, b.val, c.val)); }
#define OPENCV_HAL_IMPL_VSX_PACK (   _Tpvec,
  _Tp,
  _Tpwvec,
  _Tpvn,
  _Tpdel,
  sfnc,
  pkfnc,
  addfnc,
  pack 
)
Value:
inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \
{ \
return _Tpvec(pkfnc(a.val, b.val)); \
} \
inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
{ \
vec_st_l8(pkfnc(a.val, a.val), ptr); \
} \
template<int n> \
inline _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \
{ \
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
return _Tpvec(pkfnc(sfnc(addfnc(a.val, delta), vn), sfnc(addfnc(b.val, delta), vn))); \
} \
template<int n> \
inline void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
{ \
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
vec_st_l8(pkfnc(sfnc(addfnc(a.val, delta), vn), delta), ptr); \
}
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4 (   _Tpvec,
  _Tpvec2,
  scalartype,
  suffix,
  func 
)
Value:
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
{ \
const _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
return vec_extract(func(rs, vec_sld(rs, rs, 4)), 0); \
}
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8 (   _Tpvec,
  _Tpvec2,
  scalartype,
  suffix,
  func 
)
Value:
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
{ \
_Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
rs = func(rs, vec_sld(rs, rs, 4)); \
return vec_extract(func(rs, vec_sld(rs, rs, 2)), 0); \
}
#define OPENCV_HAL_IMPL_VSX_SELECT (   _Tpvec,
  cast 
)
Value:
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vec_sel(b.val, a.val, cast(mask.val))); }
#define OPENCV_HAL_IMPL_VSX_SHIFT_OP (   _Tpvec,
  shr,
  splfunc 
)
Value:
inline _Tpvec operator << (const _Tpvec& a, int imm) \
{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \
inline _Tpvec operator >> (const _Tpvec& a, int imm) \
{ return _Tpvec(shr(a.val, splfunc(imm))); } \
template<int imm> inline _Tpvec v_shl(const _Tpvec& a) \
{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \
template<int imm> inline _Tpvec v_shr(const _Tpvec& a) \
{ return _Tpvec(shr(a.val, splfunc(imm))); }
#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4 (   _Tpvec,
  _Tpvec2 
)
Value:
inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \
const _Tpvec& a2, const _Tpvec& a3, \
_Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \
{ \
_Tpvec2 a02 = vec_mergeh(a0.val, a2.val); \
_Tpvec2 a13 = vec_mergeh(a1.val, a3.val); \
b0.val = vec_mergeh(a02, a13); \
b1.val = vec_mergel(a02, a13); \
a02 = vec_mergel(a0.val, a2.val); \
a13 = vec_mergel(a1.val, a3.val); \
b2.val = vec_mergeh(a02, a13); \
b3.val = vec_mergel(a02, a13); \
}
#define OPENCV_IMPL_VSX_ROTATE (   _Tpvec,
  suffix,
  shf,
  cast 
)
Value:
template<int imm> \
inline _Tpvec v_rotate_##suffix(const _Tpvec& a) \
{ \
const int wd = imm * sizeof(typename _Tpvec::lane_type); \
if (wd > 15) \
return _Tpvec(); \
return _Tpvec((cast)shf(vec_uchar16_c(a.val), vec_uchar16_sp(wd << 3))); \
}
#define OPENCV_IMPL_VSX_ROTATE_64_2RG (   _Tpvec,
  suffix,
  rg1,
  rg2 
)
Value:
template<int imm> \
inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
{ \
if (imm == 1) \
return _Tpvec(vec_permi(rg1.val, rg2.val, 2)); \
return imm ? b : a; \
}
#define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR (   _Tpvec)
Value:
OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, left, b, a) \
OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, right, a, b)
#define OPENCV_IMPL_VSX_ROTATE_LR (   _Tpvec,
  cast 
)
Value:
OPENCV_IMPL_VSX_ROTATE(_Tpvec, left, vec_slo, cast) \
OPENCV_IMPL_VSX_ROTATE(_Tpvec, right, vec_sro, cast)