Add absolute frame difference module

This commit is contained in:
2014-12-03 18:08:50 +00:00
parent 4135c36b08
commit 7a5df0410e
4 changed files with 139 additions and 2 deletions
+7 -2
View File
@@ -23,6 +23,7 @@
*/
#include "FrameDifference.h"
#include <algorithm>
namespace plaYUVer
{
@@ -32,7 +33,7 @@ static PlaYUVerModuleDefinition FrameDifferenceDef =
FRAME_PROCESSING_MODULE,
"Measurements",
"AbsoluteFrameDifference",
"Measure the difference between two images (Y plane), e. g., abs( Y1 - Y2 )",
"Measure the difference between two images (Y plane), Y1 - Y2, with max absolute diff of 128",
MODULE_REQUIRES_TWO_FRAMES,
MODULE_REQUIRES_NEW_WINDOW,
APPLY_WHILE_PLAYING,
@@ -55,13 +56,17 @@ PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* I
Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0];
Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0];
Int aux_pel_1, aux_pel_2;
Int diff = 0;
for( UInt y = 0; y < m_pcFrameDifference->getHeight(); y++ )
for( UInt x = 0; x < m_pcFrameDifference->getWidth(); x++ )
{
aux_pel_1 = *pInput1PelYUV++;
aux_pel_2 = *pInput2PelYUV++;
*pOutputPelYUV++ = abs( aux_pel_1 - aux_pel_2 );
diff = aux_pel_1 - aux_pel_2;
diff = std::min( diff, 127 );
diff = std::max( diff, -128 );
*pOutputPelYUV++ = diff;
}
return m_pcFrameDifference;
}