Commit 6065566b authored by Karl Sharman's avatar Karl Sharman
Browse files

Added Y0038 - XPSNR encoder calculation.

parent 9ba4c306
......@@ -707,6 +707,30 @@ When 1, the Mean Square Error (MSE) values of the entire sequence will also be o
When 1, the multi-scale structural similarity (MS-SSIM) will also be output alongside the PSNR values.
\\
\Option{xPSNREnableFlag (-xPS} &
%\ShortOption{\None} &
\Default{false} &
When 1, the cross component PSNR is calculated, using the weights provided with xPSNRYWeight, xPSNRCbWeight and xPSNRCrWeight.
\\
\Option{xPSNRYWeight (-xPS0)} &
%\ShortOption{\None} &
\Default{1.0} &
Specifies the xPSNR weighting factor for Y.
\\
\Option{xPSNRCbWeight (-xPS1)} &
%\ShortOption{\None} &
\Default{1.0} &
Specifies the xPSNR weighting factor for Cb.
\\
\Option{xPSNRCrWeight (-xPS2)} &
%\ShortOption{\None} &
\Default{1.0} &
Specifies the xPSNR weighting factor for Cr.
\\
\Option{SummaryOutFilename} &
%\ShortOption{\None} &
\Default{false} &
......
......@@ -759,6 +759,12 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
("PrintSequenceMSE", m_printSequenceMSE, false, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values")
#if JVET_F0064_MSSSIM
("PrintMSSSIM", m_printMSSSIM, false, "0 (default) do not print MS-SSIM scores, 1 = print MS-SSIM scores for each frame and for the whole sequence")
#endif
#if JCTVC_Y0037_XPSNR
("xPSNREnableFlag,-xPS", m_bXPSNREnableFlag, false, "Cross-Component xPSNR computation")
("xPSNRYWeight,-xPS0", m_dXPSNRWeight[COMPONENT_Y], ( Double )1.0, "xPSNR weighting factor for Y (default: 1.0)")
("xPSNRCbWeight,-xPS1", m_dXPSNRWeight[COMPONENT_Cb], ( Double )1.0, "xPSNR weighting factor for Cb (default: 1.0)")
("xPSNRCrWeight,-xPS2", m_dXPSNRWeight[COMPONENT_Cr], ( Double )1.0, "xPSNR weighting factor for Cr (default: 1.0)")
#endif
("CabacZeroWordPaddingEnabled", m_cabacZeroWordPaddingEnabled, true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required")
("ChromaFormatIDC,-cf", tmpChromaFormat, 0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
......@@ -2841,6 +2847,13 @@ Void TAppEncCfg::xPrintParameter()
printf("Frame MSE output : %s\n", (m_printFrameMSE ? "Enabled" : "Disabled") );
#if JVET_F0064_MSSSIM
printf("MS-SSIM output : %s\n", (m_printMSSSIM ? "Enabled" : "Disabled") );
#endif
#if JCTVC_Y0037_XPSNR
printf("xPSNR calculation : %s\n", (m_bXPSNREnableFlag ? "Enabled" : "Disabled"));
if (m_bXPSNREnableFlag)
{
printf("xPSNR Weights : (%8.3f, %8.3f, %8.3f)\n", m_dXPSNRWeight[COMPONENT_Y], m_dXPSNRWeight[COMPONENT_Cb], m_dXPSNRWeight[COMPONENT_Cr]);
}
#endif
printf("Cabac-zero-word-padding : %s\n", (m_cabacZeroWordPaddingEnabled? "Enabled" : "Disabled") );
if (m_isField)
......
......@@ -113,6 +113,12 @@ protected:
#if JVET_F0064_MSSSIM
Bool m_printMSSSIM;
#endif
#if JCTVC_Y0037_XPSNR
Bool m_bXPSNREnableFlag; ///< xPSNR enable flag
Double m_dXPSNRWeight[MAX_NUM_COMPONENT]; ///< xPSNR per component weights
#endif
Bool m_cabacZeroWordPaddingEnabled;
Bool m_bClipInputVideoToRec709Range;
Bool m_bClipOutputVideoToRec709Range;
......
......@@ -105,6 +105,15 @@ Void TAppEncTop::xInitLibCfg()
#if JVET_F0064_MSSSIM
m_cTEncTop.setPrintMSSSIM ( m_printMSSSIM );
#endif
#if JCTVC_Y0037_XPSNR
m_cTEncTop.setXPSNREnableFlag ( m_bXPSNREnableFlag);
for (Int id = 0 ; id < MAX_NUM_COMPONENT; id++)
{
m_cTEncTop.setXPSNRWeight ( m_dXPSNRWeight[id], ComponentID(id));
}
#endif
m_cTEncTop.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled );
m_cTEncTop.setFrameRate ( m_iFrameRate );
......
......@@ -90,6 +90,7 @@
#define JVET_G0101_QP_SWITCHING 1 ///< After switching POC, increase base QP instead of frame level QP.
#define JVET_F0064_MSSSIM 1 ///< Calculate MS-SSIM scores
#define JCTVC_Y0037_XPSNR 1 ///< Enable xPSNR (Cross-Component PSNR) computation
#ifndef EXTENSION_360_VIDEO
#define EXTENSION_360_VIDEO 0 ///< extension for 360/spherical video coding support; this macro should be controlled by makefile, as it would be used to control whether the library is built and linked
......
......@@ -70,12 +70,18 @@ public:
Bool printFrameMSE;
#if JVET_F0064_MSSSIM
Bool printMSSSIM;
#endif
#if JCTVC_Y0037_XPSNR
Bool printXPSNR;
#endif
};
struct ResultData
{
ResultData () : bits(0)
#if JCTVC_Y0037_XPSNR
, xpsnr(0)
#endif
{
for(Int i=0; i<MAX_NUM_COMPONENT; i++)
{
......@@ -91,6 +97,9 @@ public:
Double MSEyuvframe[MAX_NUM_COMPONENT];
#if JVET_F0064_MSSSIM
Double MSSSIM[MAX_NUM_COMPONENT];
#endif
#if JCTVC_Y0037_XPSNR
Double xpsnr;
#endif
};
......@@ -119,12 +128,18 @@ public:
#endif
}
#if JCTVC_Y0037_XPSNR
m_runningTotal.xpsnr += result.xpsnr;
#endif
m_uiNumPic++;
}
Double getPsnr(ComponentID compID) const { return m_runningTotal.psnr[compID]; }
#if JVET_F0064_MSSSIM
Double getMsssim(ComponentID compID) const { return m_runningTotal.MSSSIM[compID]; }
#endif
#if JCTVC_Y0037_XPSNR
Double getxPSNR() const { return m_runningTotal.xpsnr;}
#endif
Double getBits() const { return m_runningTotal.bits; }
Void setBits(Double numBits) { m_runningTotal.bits=numBits; }
......@@ -223,6 +238,13 @@ public:
}
#endif
#if JCTVC_Y0037_XPSNR
if (logctrl.printXPSNR)
{
printf( " xPSNR ");
}
#endif
if (logctrl.printSequenceMSE)
{
printf( " Y-MSE \n" );
......@@ -249,6 +271,13 @@ public:
printf(" %8.6lf ", getMsssim(COMPONENT_Y) / (Double)getNumPic());
}
#endif
#if JCTVC_Y0037_XPSNR
if(logctrl.printXPSNR)
{
printf(" %8.4lf ",
getxPSNR() / (Double)getNumPic());
}
#endif
if (logctrl.printSequenceMSE)
{
......@@ -290,6 +319,12 @@ public:
printf(" Y-MS-SSIM " "U-MS-SSIM " "V-MS-SSIM ");
}
#endif
#if JCTVC_Y0037_XPSNR
if (logctrl.printXPSNR)
{
printf( " xPSNR ");
}
#endif
#if EXTENSION_360_VIDEO
m_ext360.printHeader();
......@@ -326,6 +361,14 @@ public:
}
#endif
#if JCTVC_Y0037_XPSNR
if(logctrl.printXPSNR)
{
printf(" %8.4lf ",
getxPSNR() / (Double)getNumPic());
}
#endif
#if EXTENSION_360_VIDEO
m_ext360.printPSNRs(getNumPic());
#endif
......
......@@ -148,6 +148,10 @@ protected:
Bool m_printSequenceMSE;
#if JVET_F0064_MSSSIM
Bool m_printMSSSIM;
#endif
#if JCTVC_Y0037_XPSNR
Bool m_bXPSNREnableFlag;
Double m_dXPSNRWeight[MAX_NUM_COMPONENT];
#endif
Bool m_cabacZeroWordPaddingEnabled;
......@@ -558,6 +562,14 @@ public:
Void setPrintMSSSIM (Bool value) { m_printMSSSIM = value; }
#endif
#if JCTVC_Y0037_XPSNR
Bool getXPSNREnableFlag () const { return m_bXPSNREnableFlag;}
Double getXPSNRWeight (const ComponentID id) const { return m_dXPSNRWeight[id];}
Void setXPSNREnableFlag ( Bool i ) { m_bXPSNREnableFlag = i; }
Void setXPSNRWeight ( Double dValue, ComponentID id) { m_dXPSNRWeight[id] = dValue;}
#endif
Bool getCabacZeroWordPaddingEnabled() const { return m_cabacZeroWordPaddingEnabled; }
Void setCabacZeroWordPaddingEnabled(Bool value) { m_cabacZeroWordPaddingEnabled = value; }
......
......@@ -2278,34 +2278,120 @@ Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const Acces
//===== calculate PSNR =====
for(Int chan=0; chan<pcPicD->getNumberValidComponents(); chan++)
#if JCTVC_Y0037_XPSNR
if (outputLogCtrl.printXPSNR && pcPicD->getChromaFormat() != CHROMA_400)
{
TComPicYuv *pOrgPicYuv =(conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg() : pcPic ->getPicYuvOrg();
Pel* pOrg[MAX_NUM_COMPONENT];
Double dWeightPel[MAX_NUM_COMPONENT];
Int iWeightSize[MAX_NUM_COMPONENT] = {1, 1, 1};
Pel* pRec[MAX_NUM_COMPONENT];
Int iOrgStride[MAX_NUM_COMPONENT], iRecStride[MAX_NUM_COMPONENT];
Int iWidth[MAX_NUM_COMPONENT], iHeight[MAX_NUM_COMPONENT], iSize[MAX_NUM_COMPONENT];
UInt64 uiSSDtemp[MAX_NUM_COMPONENT];
UInt uiShiftWidth[MAX_NUM_COMPONENT], uiShiftHeight[MAX_NUM_COMPONENT];
Intermediate_Int iDiff;
for(Int chan=0; chan<pcPicD->getNumberValidComponents(); chan++)
{
const ComponentID ch=ComponentID(chan);
iOrgStride[ch] = pOrgPicYuv->getStride(ch);
iRecStride[ch] = picd.getStride(ch);
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
iSize[ch] = iWidth[ch]*iHeight[ch];
uiSSDtemp[ch] = 0;
uiShiftWidth[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444) ? 0 : 1;
uiShiftHeight[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444 || pcPicD->getChromaFormat() == CHROMA_422) ? 0 : 1;
dWeightPel[ch] = m_pcCfg->getXPSNRWeight(ch);
pOrg[ch] = pOrgPicYuv->getAddr(ch);
pRec[ch] = picd.getAddr(ch);
}
Double dSSDtemp=0;
std::vector<Double> vecSSEChroma(iSize[COMPONENT_Cb], Double(0));
for(Int y = 0, t= 0; y < iHeight[COMPONENT_Cb]; y++ )
{
for(Int x = 0; x < iWidth[COMPONENT_Cb]; x++, t++)
{
UInt64 uiSE_cb, uiSE_cr;
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Cb][x] - (Intermediate_Int)pRec[COMPONENT_Cb][x] );
uiSE_cb = iDiff * iDiff;
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Cr][x] - (Intermediate_Int)pRec[COMPONENT_Cr][x] );
uiSE_cr = iDiff * iDiff;
uiSSDtemp[COMPONENT_Cb] += uiSE_cb;
uiSSDtemp[COMPONENT_Cr] += uiSE_cr;
vecSSEChroma[t] = dWeightPel[COMPONENT_Cb] * (Double) uiSE_cb + dWeightPel[COMPONENT_Cr] * (Double) uiSE_cr;
}
pOrg[COMPONENT_Cb] += iOrgStride[COMPONENT_Cb];
pRec[COMPONENT_Cb] += iRecStride[COMPONENT_Cb];
pOrg[COMPONENT_Cr] += iOrgStride[COMPONENT_Cr];
pRec[COMPONENT_Cr] += iRecStride[COMPONENT_Cr];
}
for(Int y = 0; y < iHeight[COMPONENT_Y]; y++ )
{
UInt y_step_chroma = (y >> uiShiftHeight[COMPONENT_Cb]) * iWidth[COMPONENT_Cb];
for(Int x = 0; x < iWidth[COMPONENT_Y]; x++)
{
UInt64 uiSE_y;
UInt x_step_chroma = (x >> uiShiftWidth[COMPONENT_Cb]);
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Y][x] - (Intermediate_Int)pRec[COMPONENT_Y][x] );
uiSE_y = iDiff * iDiff;
uiSSDtemp[COMPONENT_Y] += uiSE_y;
dSSDtemp += sqrt(dWeightPel[COMPONENT_Y] * (Double) uiSE_y + vecSSEChroma[y_step_chroma+x_step_chroma]);
}
pOrg[COMPONENT_Y] += iOrgStride[COMPONENT_Y];
pRec[COMPONENT_Y] += iRecStride[COMPONENT_Y];
}
Double fWValue = 0;
for( Int chan = 0; chan<pcPicD->getNumberValidComponents(); chan++)
{
const ComponentID ch=ComponentID(chan);
const UInt maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize[ch];
result.psnr[ch] = ( uiSSDtemp[ch] ? 10.0 * log10( fRefValue / (Double)uiSSDtemp[ch] ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp[ch]/(iSize[ch]);
fWValue += (Double) iWeightSize[ch] * (Double) iSize[ch];
}
const Double maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(COMPONENT_Y)) - 8);
fWValue = Double( maxval * fWValue);
result.xpsnr = dSSDtemp ? 20.0 * log10( fWValue / dSSDtemp) : 999.99;
}
else
#endif
{
const ComponentID ch=ComponentID(chan);
const TComPicYuv *pOrgPicYuv =(conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg() : pcPic ->getPicYuvOrg();
const Pel* pOrg = pOrgPicYuv->getAddr(ch);
const Int iOrgStride = pOrgPicYuv->getStride(ch);
Pel* pRec = picd.getAddr(ch);
const Int iRecStride = picd.getStride(ch);
const Int iWidth = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
const Int iHeight = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
for(Int chan=0; chan<pcPicD->getNumberValidComponents(); chan++)
{
const ComponentID ch=ComponentID(chan);
const TComPicYuv *pOrgPicYuv =(conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg() : pcPic ->getPicYuvOrg();
const Pel* pOrg = pOrgPicYuv->getAddr(ch);
const Int iOrgStride = pOrgPicYuv->getStride(ch);
Pel* pRec = picd.getAddr(ch);
const Int iRecStride = picd.getStride(ch);
const Int iWidth = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
const Int iHeight = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
Int iSize = iWidth*iHeight;
Int iSize = iWidth*iHeight;
UInt64 uiSSDtemp=0;
for(Int y = 0; y < iHeight; y++ )
{
for(Int x = 0; x < iWidth; x++ )
UInt64 uiSSDtemp=0;
for(Int y = 0; y < iHeight; y++ )
{
Intermediate_Int iDiff = (Intermediate_Int)( pOrg[x] - pRec[x] );
uiSSDtemp += iDiff * iDiff;
for(Int x = 0; x < iWidth; x++ )
{
Intermediate_Int iDiff = (Intermediate_Int)( pOrg[x] - pRec[x] );
uiSSDtemp += iDiff * iDiff;
}
pOrg += iOrgStride;
pRec += iRecStride;
}
pOrg += iOrgStride;
pRec += iRecStride;
const Int maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize;
result.psnr[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp/(iSize);
}
const Int maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize;
result.psnr[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp/(iSize);
}
#if EXTENSION_360_VIDEO
m_ext360.calculatePSNRs(pcPic);
......@@ -2425,6 +2511,12 @@ Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const Acces
{
printf(" [MS-SSIM Y %1.6lf U %1.6lf V %1.6lf]", result.MSSSIM[COMPONENT_Y], result.MSSSIM[COMPONENT_Cb], result.MSSSIM[COMPONENT_Cr] );
}
#endif
#if JCTVC_Y0037_XPSNR
if (outputLogCtrl.printXPSNR)
{
printf(" [xPSNR %6.4lf dB]", result.xpsnr);
}
#endif
if (outputLogCtrl.printFrameMSE)
{
......@@ -2649,45 +2741,135 @@ Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic*
assert(apcPicRecFields[0]->getChromaFormat()==apcPicRecFields[1]->getChromaFormat());
const UInt numValidComponents=apcPicRecFields[0]->getNumberValidComponents();
for(Int chan=0; chan<numValidComponents; chan++)
{
const ComponentID ch=ComponentID(chan);
assert(apcPicRecFields[0]->getWidth(ch)==apcPicRecFields[1]->getWidth(ch));
assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
UInt64 uiSSDtemp=0;
const Int iWidth = apcPicRecFields[0]->getWidth (ch) - (m_pcEncTop->getPad(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int iHeight = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
Int iSize = iWidth*iHeight;
#if JCTVC_Y0037_XPSNR
if (outputLogCtrl.printXPSNR && apcPicRecFields[0]->getChromaFormat() != CHROMA_400 && apcPicRecFields[1]->getChromaFormat() != CHROMA_400)
{
// For interlace images, we need to scan the two fields independently
Pel* pOrg[MAX_NUM_COMPONENT];
Double dWeightPel[MAX_NUM_COMPONENT];
Int iWeightSize[MAX_NUM_COMPONENT] = {1, 1, 1};
Pel* pRec[MAX_NUM_COMPONENT];
Int iOrgStride[MAX_NUM_COMPONENT], iRecStride[MAX_NUM_COMPONENT];
Int iWidth[MAX_NUM_COMPONENT], iHeight[MAX_NUM_COMPONENT], iSize[MAX_NUM_COMPONENT];
UInt64 uiSSDtemp[MAX_NUM_COMPONENT];
UInt uiShiftWidth[MAX_NUM_COMPONENT], uiShiftHeight[MAX_NUM_COMPONENT];
Intermediate_Int iDiff;
Double dSSDtemp = 0.0;
Double fWValue = 0.0;
for(UInt fieldNum=0; fieldNum<2; fieldNum++)
{
TComPic *pcPic=apcPicOrgFields[fieldNum];
TComPicYuv *pcPicD=apcPicRecFields[fieldNum];
TComPicYuv *pOrgPicYuv =(conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg() : pcPic ->getPicYuvOrg();
const Pel* pOrg = (conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg()->getAddr(ch) : pcPic ->getPicYuvOrg()->getAddr(ch);
Pel* pRec = pcPicD->getAddr(ch);
const Int iStride = pcPicD->getStride(ch);
for(Int chan=0; chan<pcPicD->getNumberValidComponents(); chan++)
{
const ComponentID ch=ComponentID(chan);
iOrgStride[ch] = pOrgPicYuv->getStride(ch);
iRecStride[ch] = pcPicD->getStride(ch);
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> pcPic->getComponentScaleY(ch));
iSize[ch] = iWidth[ch]*iHeight[ch];
uiSSDtemp[ch] = 0;
uiShiftWidth[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444) ? 0 : 1;
uiShiftHeight[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444 || pcPicD->getChromaFormat() == CHROMA_422) ? 0 : 1;
dWeightPel[ch] = m_pcCfg->getXPSNRWeight(ch);
pOrg[ch] = pOrgPicYuv->getAddr(ch);
pRec[ch] = pcPicD->getAddr(ch);
}
std::vector<Double> vecSSEChroma(iSize[COMPONENT_Cb], Double(0));
for(Int y = 0, t= 0; y < iHeight[COMPONENT_Cb]; y++ )
{
for(Int x = 0; x < iWidth[COMPONENT_Cb]; x++, t++)
{
UInt64 uiSE_cb, uiSE_cr;
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Cb][x] - (Intermediate_Int)pRec[COMPONENT_Cb][x] );
uiSE_cb = iDiff * iDiff;
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Cr][x] - (Intermediate_Int)pRec[COMPONENT_Cr][x] );
uiSE_cr = iDiff * iDiff;
uiSSDtemp[COMPONENT_Cb] += uiSE_cb;
uiSSDtemp[COMPONENT_Cr] += uiSE_cr;
vecSSEChroma[t] = dWeightPel[COMPONENT_Cb] * (Double) uiSE_cb + dWeightPel[COMPONENT_Cr] * (Double) uiSE_cr;
}
pOrg[COMPONENT_Cb] += iOrgStride[COMPONENT_Cb];
pRec[COMPONENT_Cb] += iRecStride[COMPONENT_Cb];
pOrg[COMPONENT_Cr] += iOrgStride[COMPONENT_Cr];
pRec[COMPONENT_Cr] += iRecStride[COMPONENT_Cr];
}
for(Int y = 0; y < iHeight; y++ )
for(Int y = 0; y < iHeight[COMPONENT_Y]; y++ )
{
for(Int x = 0; x < iWidth; x++ )
UInt y_step_chroma = (y >> uiShiftHeight[COMPONENT_Cb]) * iWidth[COMPONENT_Cb];
for(Int x = 0; x < iWidth[COMPONENT_Y]; x++)
{
Intermediate_Int iDiff = (Intermediate_Int)( pOrg[x] - pRec[x] );
uiSSDtemp += iDiff * iDiff;
UInt64 uiSE_y;
UInt x_step_chroma = (x >> uiShiftWidth[COMPONENT_Cb]);
iDiff = (Intermediate_Int)( (Intermediate_Int)pOrg[COMPONENT_Y][x] - (Intermediate_Int)pRec[COMPONENT_Y][x] );
uiSE_y = iDiff * iDiff;
uiSSDtemp[COMPONENT_Y] += uiSE_y;
dSSDtemp += sqrt(dWeightPel[COMPONENT_Y] * (Double) uiSE_y + vecSSEChroma[y_step_chroma+x_step_chroma]);
}
pOrg += iStride;
pRec += iStride;
pOrg[COMPONENT_Y] += iOrgStride[COMPONENT_Y];
pRec[COMPONENT_Y] += iRecStride[COMPONENT_Y];
}
for( Int chan = 0; chan<pcPicD->getNumberValidComponents(); chan++)
{
const ComponentID ch=ComponentID(chan);
const UInt maxval = 255 << (sps.getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize[ch];
result.psnr[ch] = ( uiSSDtemp[ch] ? 10.0 * log10( fRefValue / (Double)uiSSDtemp[ch] ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp[ch]/(iSize[ch]);
fWValue += (Double) iWeightSize[ch] * (Double) iSize[ch];
}
}
const Int maxval = 255 << (sps.getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize*2;
result.psnr[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp/(iSize*2);
const Double maxval = 255 << (sps.getBitDepth(toChannelType(COMPONENT_Y)) - 8);
fWValue = Double( maxval * fWValue);
result.xpsnr = dSSDtemp ? 20.0 * log10( fWValue / dSSDtemp) : 999.99;
}
else
#endif
{
for(Int chan=0; chan<numValidComponents; chan++)
{
const ComponentID ch=ComponentID(chan);
assert(apcPicRecFields[0]->getWidth(ch)==apcPicRecFields[1]->getWidth(ch));
assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
UInt64 uiSSDtemp=0;
const Int iWidth = apcPicRecFields[0]->getWidth (ch) - (m_pcEncTop->getPad(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int iHeight = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
Int iSize = iWidth*iHeight;
for(UInt fieldNum=0; fieldNum<2; fieldNum++)
{
TComPic *pcPic=apcPicOrgFields[fieldNum];
TComPicYuv *pcPicD=apcPicRecFields[fieldNum];
const Pel* pOrg = (conversion!=IPCOLOURSPACE_UNCHANGED) ? pcPic ->getPicYuvTrueOrg()->getAddr(ch) : pcPic ->getPicYuvOrg()->getAddr(ch);
Pel* pRec = pcPicD->getAddr(ch);
const Int iStride = pcPicD->getStride(ch);
for(Int y = 0; y < iHeight; y++ )
{
for(Int x = 0; x < iWidth; x++ )
{
Intermediate_Int iDiff = (Intermediate_Int)( pOrg[x] - pRec[x] );
uiSSDtemp += iDiff * iDiff;
}
pOrg += iStride;
pRec += iStride;
}
}
const Int maxval = 255 << (sps.getBitDepth(toChannelType(ch)) - 8);
const Double fRefValue = (Double) maxval * maxval * iSize*2;
result.psnr[ch] = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
result.MSEyuvframe[ch] = (Double)uiSSDtemp/(iSize*2);
}
}
#if JVET_F0064_MSSSIM
//===== calculate MS-SSIM =====
if (outputLogCtrl.printMSSSIM)
......
......@@ -188,6 +188,9 @@ public:
outputLogCtrl.printMSSSIM=m_printMSSSIM;
#endif
outputLogCtrl.printSequenceMSE=m_printSequenceMSE;
#if JCTVC_Y0037_XPSNR
outputLogCtrl.printXPSNR=m_bXPSNREnableFlag;
#endif
return outputLogCtrl;
}
......
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