Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1392)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1397)
@@ -386,4 +386,6 @@
   // distortion
   m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
+  m_cDistParam.m_maximumDistortionForEarlyExit = rcStruct.uiBestSad;
+
   if(m_pcEncCfg->getFastSearch() == SELECTIVE)
   {
@@ -439,4 +441,5 @@
           rcStruct.uiBestRound    = 0;
           rcStruct.ucPointNr      = ucPointNr;
+          m_cDistParam.m_maximumDistortionForEarlyExit = uiSad;
         }
       }
@@ -458,4 +461,5 @@
       rcStruct.uiBestRound    = 0;
       rcStruct.ucPointNr      = ucPointNr;
+      m_cDistParam.m_maximumDistortionForEarlyExit = uiSad;
     }
   }
@@ -882,4 +886,5 @@
       uiDistBest  = uiDist;
       uiDirecBest = i;
+      m_cDistParam.m_maximumDistortionForEarlyExit = uiDist;
     }
   }
@@ -3404,9 +3409,9 @@
             }
           }
-#if (ENCODER_FAST_MODE)
+#if ENCODER_FAST_MODE
           }
 #endif
         }
-#if (ENCODER_FAST_MODE)
+#if ENCODER_FAST_MODE
         } // for loop-iRefIdxTemp
 #endif
@@ -4064,4 +4069,5 @@
         iBestX    = x;
         iBestY    = y;
+        m_cDistParam.m_maximumDistortionForEarlyExit = uiSad;
       }
     }
