Improve frame difference to support multiple channels

This commit is contained in:
2019-02-28 18:04:47 +00:00
parent b3340bb13b
commit 805cee6fbc
2 changed files with 28 additions and 25 deletions
+8 -5
View File
@@ -49,13 +49,11 @@ bool AbsoluteFrameDifference::create( std::vector<CalypFrame*> apcFrameList )
_BASIC_MODULE_API_2_CHECK_
for( unsigned int i = 1; i < apcFrameList.size(); i++ )
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE |
CalypFrame::MATCH_RESOLUTION |
CalypFrame::MATCH_BITS ) )
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_COLOR_SPACE_IGNORE_GRAY
| CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_RESOLUTION | CalypFrame::MATCH_BITS ) )
return false;
m_pcFrameDifference =
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
m_pcFrameDifference = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, apcFrameList[0]->getBitsPel() );
return true;
}
@@ -68,13 +66,18 @@ CalypFrame* AbsoluteFrameDifference::process( std::vector<CalypFrame*> apcFrameL
ClpPel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0];
int aux_pel_1, aux_pel_2;
for( unsigned int ch = 0; ch < m_pcFrameDifference->getNumberChannels(); ch++ )
{
for( unsigned int y = 0; y < m_pcFrameDifference->getHeight(); y++ )
{
for( unsigned int x = 0; x < m_pcFrameDifference->getWidth(); x++ )
{
aux_pel_1 = *pInput1PelYUV++;
aux_pel_2 = *pInput2PelYUV++;
*pOutputPelYUV++ = abs( aux_pel_1 - aux_pel_2 );
}
}
}
return m_pcFrameDifference;
}
+3 -3
View File
@@ -52,8 +52,7 @@ bool FrameDifference::create( std::vector<CalypFrame*> apcFrameList )
unsigned int uiMaxBitsPixel = 0;
for( unsigned int i = 0; i < apcFrameList.size(); i++ )
{
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0],
CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_RESOLUTION ) )
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_PEL_FMT | CalypFrame::MATCH_COLOR_SPACE | CalypFrame::MATCH_RESOLUTION ) )
return false;
if( apcFrameList[i]->getBitsPel() > uiMaxBitsPixel )
{
@@ -70,7 +69,7 @@ bool FrameDifference::create( std::vector<CalypFrame*> apcFrameList )
m_iMaxDiffValue = ( 1 << ( m_uiBitsPixel - 1 ) );
m_pcFrameDifference = new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(),
CLP_GRAY, m_uiBitsPixel );
apcFrameList[0]->getPelFormat(), m_uiBitsPixel );
return true;
}
@@ -82,6 +81,7 @@ CalypFrame* FrameDifference::process( std::vector<CalypFrame*> apcFrameList )
int aux_pel_1, aux_pel_2;
int diff = 0;
for( unsigned int ch = 0; ch < m_pcFrameDifference->getNumberChannels(); ch++ )
for( unsigned int y = 0; y < m_pcFrameDifference->getHeight(); y++ )
for( unsigned int x = 0; x < m_pcFrameDifference->getWidth(); x++ )
{