Inital refactor to use resource independent from the video windows
This commit is contained in:
23 files changed
+1378
-587
No files matched your search
+20
-37
@@ -36,9 +36,10 @@ constexpr auto kMaxPixelValue{ 255 };
|
||||
|
||||
static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB )
|
||||
{
|
||||
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue,
|
||||
kMaxPixelValue ); // NOLINT
|
||||
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
|
||||
}
|
||||
|
||||
static inline void rgbToYuv( const int& iR, const int& iG, const int& iB, int& iY, int& iU, int& iV )
|
||||
@@ -75,10 +76,7 @@ CalypPixel& CalypPixel::operator+=( const CalypPixel& in )
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::transform( other_comp.begin(),
|
||||
other_comp.end(),
|
||||
m_pelComp.begin(),
|
||||
m_pelComp.begin(),
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), m_pelComp.begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
|
||||
return *this;
|
||||
}
|
||||
@@ -87,20 +85,14 @@ CalypPixel& CalypPixel::operator-=( const CalypPixel& in )
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::transform( other_comp.begin(),
|
||||
other_comp.end(),
|
||||
m_pelComp.begin(),
|
||||
m_pelComp.begin(),
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), m_pelComp.begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypPixel& CalypPixel::operator*=( const double op )
|
||||
{
|
||||
std::transform( m_pelComp.begin(),
|
||||
m_pelComp.end(),
|
||||
m_pelComp.begin(),
|
||||
[&op]( auto& p1 ) { return p1 * op; } );
|
||||
std::transform( m_pelComp.begin(), m_pelComp.end(), m_pelComp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -109,10 +101,7 @@ CalypPixel CalypPixel::operator+( const CalypPixel& in ) const
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::transform( other_comp.begin(),
|
||||
other_comp.end(),
|
||||
m_pelComp.begin(),
|
||||
result.components().begin(),
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), result.components().begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
|
||||
return result;
|
||||
}
|
||||
@@ -122,10 +111,7 @@ CalypPixel CalypPixel::operator-( const CalypPixel& in ) const
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::transform( other_comp.begin(),
|
||||
other_comp.end(),
|
||||
m_pelComp.begin(),
|
||||
result.components().begin(),
|
||||
std::transform( other_comp.begin(), other_comp.end(), m_pelComp.begin(), result.components().begin(),
|
||||
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
|
||||
return result;
|
||||
}
|
||||
@@ -134,10 +120,7 @@ CalypPixel CalypPixel::operator*( const double op ) const
|
||||
{
|
||||
CalypPixel result{ m_colorSpace };
|
||||
auto& comp = result.components();
|
||||
std::transform( comp.begin(),
|
||||
comp.end(),
|
||||
comp.begin(),
|
||||
[&op]( auto& p1 ) { return p1 * op; } );
|
||||
std::transform( comp.begin(), comp.end(), comp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -149,16 +132,16 @@ auto CalypPixel::operator==( const CalypPixel& other ) const -> bool
|
||||
|
||||
std::ostream& operator<<( std::ostream& os, const CalypPixel& p )
|
||||
{
|
||||
#ifdef CLP_DEBUG
|
||||
if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
|
||||
{
|
||||
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
|
||||
}
|
||||
#endif
|
||||
// #ifdef CLP_DEBUG
|
||||
// if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
|
||||
// {
|
||||
// os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
|
||||
// }
|
||||
// #endif
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user