Index: source/Lib/TLibCommon/TypeDef.h =================================================================== --- source/Lib/TLibCommon/TypeDef.h (revision 2966) +++ source/Lib/TLibCommon/TypeDef.h (working copy) @@ -87,6 +87,7 @@ #define SAO_ENCODING_RATE_CHROMA 0.5 #endif #endif +#define SAO_TEST_DISABLED 1 ///< Test for whether SAO completely disabled produces the lowest cost. #define MAX_NUM_VPS 16 #define MAX_NUM_SPS 16 Index: source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp =================================================================== --- source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp (revision 2966) +++ source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp (working copy) @@ -1865,6 +1865,9 @@ Int addr = 0; Int addrUp = -1; Int addrLeft = -1; +#if SAO_TEST_DISABLED + double totalCost = 0; +#endif Int compIdx = 0; SaoLcuParam mergeSaoParam[3][2]; Double compDistortion[3]; @@ -1899,6 +1902,11 @@ #endif #endif +#if SAO_TEST_DISABLED + m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_CURR_BEST]); + m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_NEXT_BEST]); // next best if SAO is to be disabled. +#endif + for (idxY = 0; idxY< frameHeightInCU; idxY++) { for (idxX = 0; idxX< frameWidthInCU; idxX++) @@ -2039,6 +2047,10 @@ } } } +#if SAO_TEST_DISABLED + totalCost += bestCost; +#endif + #if SAO_ENCODING_CHOICE #if SAO_ENCODING_CHOICE_CHROMA if( saoParam->saoLcuParam[0][addr].typeIdx == -1) @@ -2064,6 +2076,17 @@ } } } + +#if SAO_TEST_DISABLED + if (totalCost >= 0.0) + { + saoParam->bSaoFlag[0]=false; + saoParam->bSaoFlag[1]=false; + m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[0][CI_NEXT_BEST]); + m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[0][CI_CURR_BEST]); + } +#endif + #if SAO_ENCODING_CHOICE #if SAO_ENCODING_CHOICE_CHROMA if( !saoParam->bSaoFlag[0])