Commit da293ee3 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

SSE2 optimization for Bayer->RGB; added Bayer->Gray with SSE2 optimization;…

SSE2 optimization for Bayer->RGB; added Bayer->Gray with SSE2 optimization; corrected some bugs noted in the yahoogroups forum
parent e834a46c
......@@ -5541,7 +5541,7 @@ Random number generator class.
class CV_EXPORTS RNG
{
public:
enum { A=4164903690U, UNIFORM=0, NORMAL=1 };
enum { UNIFORM=0, NORMAL=1 };
// constructors
RNG();
......
......@@ -1816,7 +1816,7 @@ public:
class CV_EXPORTS RNG
{
public:
enum { A=4164903690U, UNIFORM=0, NORMAL=1 };
enum { UNIFORM=0, NORMAL=1 };
RNG();
RNG(uint64 _state);
......
......@@ -572,6 +572,7 @@ Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
......@@ -579,6 +580,7 @@ Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
......@@ -586,6 +588,7 @@ Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha)
{
for( int i = 0; i < m*n; i++ )
a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
return a;
}
template<typename _Tp, int m, int n> static inline
......@@ -2239,7 +2242,7 @@ inline RNG::RNG() { state = 0xffffffff; }
inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; }
inline unsigned RNG::next()
{
state = (uint64)(unsigned)state*A + (unsigned)(state >> 32);
state = (uint64)(unsigned)state*CV_RNG_COEFF + (unsigned)(state >> 32);
return (unsigned)state;
}
......
......@@ -375,6 +375,8 @@ CV_INLINE int cvIsInf( double value )
typedef uint64 CvRNG;
#define CV_RNG_COEFF 4164903690U
CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1))
{
CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
......@@ -385,7 +387,7 @@ CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1))
CV_INLINE unsigned cvRandInt( CvRNG* rng )
{
uint64 temp = *rng;
temp = (uint64)(unsigned)temp*4164903690U + (temp >> 32);
temp = (uint64)(unsigned)temp*CV_RNG_COEFF + (temp >> 32);
*rng = temp;
return (unsigned)temp;
}
......
......@@ -60,7 +60,7 @@ namespace cv
carry = temp / (2^32)
*/
#define RNG_NEXT(x) ((uint64)(unsigned)(x)*RNG::A + ((x) >> 32))
#define RNG_NEXT(x) ((uint64)(unsigned)(x)*CV_RNG_COEFF + ((x) >> 32))
/***************************************************************************************\
* Pseudo-Random Number Generators (PRNGs) *
......
......@@ -221,6 +221,11 @@ enum
CV_YUV2BGR = 84,
CV_YUV2RGB = 85,
CV_BayerBG2Gray = 86,
CV_BayerGB2Gray = 87,
CV_BayerRG2Gray = 88,
CV_BayerGR2Gray = 89,
CV_COLORCVT_MAX =100
};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment