From 6d2f5eacdb31bf1eb19f13290b8b3f4c53c461c1 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 24 Nov 2016 18:24:32 +0000 Subject: [PATCH] Fix PSNR formula --- lib/PlaYUVerFrame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 6737c30..7a2325d 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -1327,10 +1327,12 @@ Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) { + UInt uiMaxValue = ( 1 << Org->getBitsPel() ); + Double uiMaxValueSquare = uiMaxValue * uiMaxValue; Double dPSNR = 100; Double dMSE = getMSE( Org, component ); if( dMSE != 0 ) - dPSNR = 10 * log10( 65025 / dMSE ); + dPSNR = 10 * log10( uiMaxValueSquare / dMSE ); return dPSNR; }