Index: branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1309)
@@ -133,4 +133,5 @@
   }
 
+  D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost)); 
   return dRdCost;
 }
@@ -3684,4 +3685,6 @@
   }
 
+  D_PRINT_INDENT( g_traceRDCost, "VSO Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost)); 
+
   return dRdCost;
 }
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.cpp	(revision 1309)
@@ -546,13 +546,19 @@
 Bool g_disableNumbering = false; 
 Bool g_disableHLSTrace = false; 
-UInt64 g_stopAtCounter       = 4660; 
-Bool g_traceCopyBack         = false; 
-Bool g_decTraceDispDer       = false; 
-Bool g_decTraceMvFromMerge   = false; 
-Bool g_decTracePicOutput     = false; 
-Bool g_stopAtPos             = false; 
-Bool g_outputPos             = false;   
-Bool g_traceCameraParameters = false; 
-Bool g_encNumberOfWrittenBits     = false; 
+UInt64 g_stopAtCounter         = 4660; 
+Bool g_traceCopyBack           = false; 
+Bool g_decTraceDispDer         = false; 
+Bool g_decTraceMvFromMerge     = false; 
+Bool g_decTracePicOutput       = false; 
+Bool g_startStopTrace          = true; 
+Bool g_outputPos               = false;   
+Bool g_traceCameraParameters   = false; 
+Bool g_encNumberOfWrittenBits  = false; 
+Bool g_traceEncFracBits        = false; 
+Bool g_traceIntraSearchCost    = false; 
+Bool g_traceRDCost             = false; 
+Bool g_traceSAOCost            = false; 
+Bool g_traceModeCheck          = false; 
+UInt g_indent                  = false; 
 #endif
 #endif
@@ -685,24 +691,35 @@
               << std::endl; 
   }
-  Bool stopFlag = false; 
-  if ( g_stopAtPos && poc == 0 && layerId == 2 )
-  {
-    Bool stopAtCU = true; 
-    if ( stopAtCU )        // Stop at CU with specific size
-    {    
-      stopFlag = ( cuPelX  == 416 ) && ( cuPelY  == 632 ) && ( cuWidth == 8 ) && ( cuHeight == 8 ); 
-    }
-    else
-    {                     // Stop at specific position 
-      Int xPos = 888; 
-      Int yPos = 248; 
-      Int cuPelXEnd = cuPelX + cuWidth  - 1; 
-      Int cuPelYEnd = cuPelY + cuHeight - 1; 
-      stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos ); 
-    }
-  }
-  if ( stopFlag )
-  { // Set breakpoint here. 
-    std::cout << "Stop position. Break point here." << std::endl; 
+
+  Bool startTrace = false; 
+  if ( g_startStopTrace && poc == 0 && layerId == 0 )
+  {    
+    startTrace = ( cuPelX  == 0 ) && ( cuPelY  == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 ); 
+  }
+  if ( startTrace )
+  { 
+    g_outputPos              = true; 
+    g_traceEncFracBits       = false;   
+    g_traceIntraSearchCost   = false;     
+    g_encNumberOfWrittenBits = false;     
+    g_traceRDCost            = true; 
+    g_traceModeCheck         = true; 
+    g_traceCopyBack          = false; 
+  }  
+
+  Bool stopTrace = false; 
+  if ( g_startStopTrace && poc == 0 && layerId == 0 )
+  {
+    stopTrace = ( cuPelX  == 128 ) && ( cuPelY  == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 ); 
+  }
+  if ( stopTrace )
+  { 
+    g_outputPos              = false; 
+    g_traceModeCheck         = false; 
+    g_traceEncFracBits       = false; 
+    g_traceIntraSearchCost   = false;        
+    g_encNumberOfWrittenBits = false; 
+    g_traceRDCost            = false; 
+    g_traceCopyBack          = false;     
   }  
 }
@@ -738,4 +755,37 @@
   }
 }
+Void printStr( std::string str )
+{
+  std::cout << str << std::endl; 
+}
+Void printStrIndent( Bool b, std::string strStr )
+{
+  if ( b )
+  {  
+    std::cout << std::string(g_indent, ' ');
+    printStr( strStr );
+  }
+}
+
+Void prinStrIncIndent( Bool b,  std::string strStr )
+{
+  if ( b )
+  {
+    printStrIndent( true,  strStr );
+    if (g_indent < 50)
+    {
+      g_indent++;
+    }
+  }  
+}
+
+Void decIndent( Bool b )
+{
+  if (b && g_indent > 0)
+  {
+    g_indent--;  
+  }  
+}
+
 #endif
 #endif
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.h	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComRom.h	(revision 1309)
@@ -183,8 +183,14 @@
  extern Bool   g_decTraceMvFromMerge;   // Trace motion vectors obtained from merge (decoder only) 
  extern Bool   g_decTracePicOutput;     // Trace output of pictures
- extern Bool   g_stopAtPos;             // Stop at position
+ extern Bool   g_startStopTrace;             // Stop at position
  extern Bool   g_outputPos;             // Output position
  extern Bool   g_traceCameraParameters; // Trace camera parameters
  extern Bool   g_encNumberOfWrittenBits;// Trace number of written bits
+ extern Bool   g_traceEncFracBits;      // Trace fractional bits
+ extern Bool   g_traceIntraSearchCost;  // Trace intra mode cost
+ extern Bool   g_traceRDCost;          
+ extern Bool   g_traceModeCheck; 
+ extern Bool   g_traceSAOCost; 
+ extern UInt   g_indent; 
 #define DTRACE_CU(x,y)             writeToTraceFile( x,y, g_traceCU );
 #define DTRACE_PU(x,y)             writeToTraceFile( x,y, g_tracePU );
@@ -193,4 +199,9 @@
 #define DTRACE_PU_S(x)             writeToTraceFile( x,   g_tracePU );
 #define DTRACE_TU_S(x)             writeToTraceFile( x,   g_traceTU );
+
+#define D_DEC_INDENT( b )            decIndent        ( b );
+#define D_PRINT_INC_INDENT( b, str ) prinStrIncIndent( b, str );
+#define D_PRINT_INDENT( b, str )     printStrIndent   ( b, str);
+
  Void           tracePSHeader   ( const Char* psName, Int layerId ); 
  Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
@@ -198,4 +209,18 @@
  UInt64         incSymbolCounter();          
  Void           stopAtPos       ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight );           
+
+ Void           printStr         ( std::string str );
+ Void           printStrIndent   ( Bool b, std::string str );
+ Void           prinStrIncIndent ( Bool b, std::string str );
+ Void           decIndent        ( Bool b );
+
+ template <typename T>
+ std::string n2s ( T Number )
+ {
+   std::ostringstream ss;
+   ss << Number;
+   return ss.str();
+ };
+
 #endif
 #else
@@ -214,4 +239,9 @@
 #define DTRACE_PU_S(x) ;            
 #define DTRACE_TU_S(x) ;            
+
+#define D_DEC_INDENT( b ) ;
+#define D_PRINT_INC_INDENT( b, str );
+#define D_PRINT_INDENT( b, str );
+
 #endif
 #endif
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComYuv.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComYuv.cpp	(revision 1309)
@@ -125,11 +125,12 @@
     ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth);
 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
-    if ( g_traceCopyBack && g_nSymbolCounter >= g_stopAtCounter )
+    if ( g_traceCopyBack && compID == COMPONENT_Y)
     { 
+      std::stringstream strStr; 
       for ( Int x = 0; x < iWidth; x++)
       {      
-        std::cout << pSrc[ x ] << " " ; 
-      }
-      std::cout << std::endl;
+        strStr << pSrc[ x ] << " " ; 
+      }
+      printStrIndent( true, strStr.str() );
     }
 #endif
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1309)
@@ -66,5 +66,7 @@
 /////////////////////////////////////////////////////////////////////////////////////////
 #if NH_MV
-#define NH_3D_INTRA_SDC_RD_FIX            1 // Fix in RD- decsion of intra sdc.
+#define NH_3D_DIS_FIX                     1
+#define NH_3D_ENC_DEPTH_FIX               1 // Fix Intra TU coding. 
+#define NH_3D_INTRA_SDC_RD_FIX            1 // Fix in RD- decision of intra SDC.
 #define NH_3D_DLT_FIX                     1 // Fixes numbers of parsed DLTs 
 #define NH_3D_VER141_DEC_COMP_FLAG        0 // Makes decoding of this version compatible to HTM-14.1 by re-introducing HTM-14.1 bugs.
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	(revision 1309)
@@ -156,4 +156,5 @@
 #if FAST_BIT_EST
   m_fracBits = pcTEncBinCABAC->m_fracBits;
+  D_PRINT_INDENT(g_traceEncFracBits,  "CopyState " + n2s(m_fracBits) );    
 #endif
 }
@@ -170,5 +171,7 @@
   }
 #if FAST_BIT_EST
+  D_PRINT_INDENT( g_traceEncFracBits, "Reset Bits Before" + n2s(m_fracBits) );
   m_fracBits &= 32767;
+  D_PRINT_INDENT( g_traceEncFracBits, "Reset Bits " + n2s(m_fracBits) );  
 #endif
 }
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp	(revision 1309)
@@ -59,4 +59,5 @@
   m_pcTComBitIf->write(0, UInt(m_fracBits >> 15) );
   m_fracBits &= 32767;
+  D_PRINT_INDENT( g_traceEncFracBits, "Finish " + n2s(m_fracBits) );    
 }
 
@@ -80,4 +81,6 @@
   m_uiBinsCoded += m_binCountIncrement;
   m_fracBits += rcCtxModel.getEntropyBits( binValue );
+  D_PRINT_INDENT( g_traceEncFracBits, "EncodeBin " + n2s(m_fracBits) );    
+
   rcCtxModel.update( binValue );
 
@@ -110,4 +113,5 @@
   m_uiBinsCoded += m_binCountIncrement;
   m_fracBits += 32768;
+    D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinEP " + n2s(m_fracBits) );    
 }
 
@@ -122,4 +126,5 @@
   m_uiBinsCoded += numBins & -m_binCountIncrement;
   m_fracBits += 32768 * numBins;
+  D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinsEP " + n2s(m_fracBits) );    
 }
 
@@ -133,4 +138,5 @@
   m_uiBinsCoded += m_binCountIncrement;
   m_fracBits += ContextModel::getEntropyBitsTrm( binValue );
+  D_PRINT_INDENT( g_traceEncFracBits , "EncodeBinTrm " + n2s(m_fracBits) );    
 }
 
@@ -138,4 +144,5 @@
 {
   m_fracBits = (m_fracBits + 32767) & (~32767);
+  D_PRINT_INDENT( g_traceEncFracBits, "Align " + n2s(m_fracBits) );    
 }
 
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1309)
@@ -1784,4 +1784,7 @@
     return;   // never check merge in fast deltaqp mode
   }
+
+  D_PRINT_INC_INDENT( g_traceModeCheck, "xCheckRDCostMerge2Nx2N" );
+
 #if NH_3D_MLC
   TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
@@ -1967,4 +1970,6 @@
   for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
   {
+    D_PRINT_INC_INDENT ( g_traceModeCheck, "uiNoResidual: " + n2s( uiNoResidual) );
+
     for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
     {
@@ -1978,4 +1983,5 @@
       }
 #endif
+      D_PRINT_INC_INDENT ( g_traceModeCheck, "uiMergeCand: "+  n2s(uiMergeCand) );
 
       if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
@@ -2191,4 +2197,5 @@
         }
       }
+      D_DEC_INDENT( g_traceModeCheck ); 
     }
 
@@ -2222,4 +2229,5 @@
       }
     }
+    D_DEC_INDENT( g_traceModeCheck ); 
   }
   DEBUG_STRING_APPEND(sDebug, bestStr)
@@ -2231,4 +2239,5 @@
  delete[] puhInterDirSP;
 #endif
+ D_DEC_INDENT( g_traceModeCheck );
 }
 
@@ -2255,4 +2264,7 @@
     }
   }
+
+  D_PRINT_INC_INDENT(g_traceModeCheck,   "xCheckRDCostInter; ePartSize:" + n2s( ePartSize) );
+
 
   // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
@@ -2342,11 +2354,14 @@
   {
 #if NH_3D_ARP
-        if( nARPWMax )
-        {
-          continue;
-        }
-        else
-#endif
-    return;
+    if( nARPWMax )
+    {
+      continue;
+    }
+    else
+#endif
+    {
+      D_DEC_INDENT( g_traceModeCheck ); 
+      return;
+    }
   }
 #endif
@@ -2464,4 +2479,5 @@
   }
 #endif
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 
@@ -2675,4 +2691,6 @@
   }
 
+  D_PRINT_INC_INDENT(g_traceModeCheck, "xCheckRDCostDIS" );
+
 #if NH_3D_VSO // M5
   if( m_pcRdCost->getUseRenModel() )
@@ -2735,4 +2753,5 @@
   xCheckDQP( rpcTempCU );
   xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth  DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest) );
+  D_DEC_INDENT( g_traceModeCheck );  
 }
 #endif
@@ -2758,5 +2777,6 @@
     }
   }
-
+  D_PRINT_INC_INDENT (g_traceModeCheck, "xCheckRDCostIntra; eSize: " + n2s(eSize) );
+  
   UInt uiDepth = rpcTempCU->getDepth( 0 );
 #if NH_3D_VSO // M5
@@ -2810,5 +2830,5 @@
     m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
   }
-#if NH_3D_DIS
+#if NH_3D_DIS && !NH_3D_DIS_FIX
   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
   if(!rpcTempCU->getDISFlag(0))
@@ -2816,4 +2836,9 @@
 #endif
   m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
+#if NH_3D_DIS_FIX
+  m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
+  if(!rpcTempCU->getDISFlag(0))
+  {
+#endif
   m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
   m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
@@ -2851,5 +2876,7 @@
 
   xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth DEBUG_STRING_PASS_INTO(sDebug) DEBUG_STRING_PASS_INTO(sTest));
-}
+
+  D_DEC_INDENT( g_traceModeCheck ); 
+  }
 
 
@@ -3029,5 +3056,13 @@
   m_ppcRecoYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvRec (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx);
 
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  Bool oldtraceCopyBack = g_traceCopyBack;
+  g_traceCopyBack = false; 
+#endif
   m_ppcPredYuvBest[uiSrcDepth]->copyToPicYuv( rpcPic->getPicYuvPred (), uiCUAddr, uiAbsPartIdx, uiDepth - uiSrcDepth, uiPartIdx);
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  g_traceCopyBack = oldtraceCopyBack; 
+#endif
 }
 
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1309)
@@ -795,4 +795,9 @@
 Void TEncEntropy::encodeCoeffNxN( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID)
 {
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  Bool oldTraceFracBits = g_traceEncFracBits; 
+  g_traceEncFracBits = false; 
+#endif
+
   TComDataCU *pcCU = rTu.getCU();
 
@@ -822,4 +827,7 @@
     }
   }
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  g_traceEncFracBits = oldTraceFracBits; 
+#endif
 }
 
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1309)
@@ -139,12 +139,6 @@
   Void    setBitstream              ( TComBitIf* p )          { m_pcEntropyCoderIf->setBitstream(p);  }
   Void    resetBits                 ()                        { m_pcEntropyCoderIf->resetBits();      }
-  UInt    getNumberOfWrittenBits    ()
-                        {
-#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
-    Bool oldJustDoIt = g_bJustDoIt;
-    g_bJustDoIt = true; 
-    writeToTraceFile( "NumberOfWrittenBits", m_pcEntropyCoderIf->getNumberOfWrittenBits(), g_encNumberOfWrittenBits );
-    g_bJustDoIt = oldJustDoIt; 
-#endif
+  UInt    getNumberOfWrittenBits    ()                        {
+      D_PRINT_INDENT(g_encNumberOfWrittenBits,  "NumBits: " +  n2s( m_pcEntropyCoderIf->getNumberOfWrittenBits() ))
  return m_pcEntropyCoderIf->getNumberOfWrittenBits(); }
   Void    resetEntropy              (const TComSlice *pSlice) { m_pcEntropyCoderIf->resetEntropy(pSlice);  }
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	(revision 1309)
@@ -826,4 +826,6 @@
       }
 
+      D_PRINT_INDENT( g_traceSAOCost, "SAO mode " + n2s( mode ) + " Cost:  " + n2s( modeCost) );
+
       if(modeCost < minCost)
       {
Index: branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1308)
+++ branches/HTM-14.1-update-dev1/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1309)
@@ -1530,4 +1530,6 @@
                                   )
 {
+  D_PRINT_INC_INDENT( g_traceModeCheck, "xRecurIntraCodingLumaQT; zeroResiFlag " + n2s(zeroResiFlag) )
+
   TComDataCU   *pcCU          = rTu.getCU();
   const UInt    uiAbsPartIdx  = rTu.GetAbsPartIdxTU();
@@ -1711,5 +1713,9 @@
       dSingleCost   = 0.0;
 #if NH_3D_ENC_DEPTH
+#if NH_3D_ENC_DEPTH_FIX
+      xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), 0, zeroResiFlag );
+#else
       xIntraCodingTUBlock( pcOrgYuv, pcPredYuv, pcResiYuv, resiLumaSingle, false, uiSingleDistLuma, COMPONENT_Y, rTu DEBUG_STRING_PASS_INTO(sDebug), zeroResiFlag );
+#endif
 #else
       pcCU ->setTransformSkipSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, totalAdjustedDepthChan );
@@ -1835,5 +1841,5 @@
         }
       }
-
+      D_DEC_INDENT( g_traceModeCheck ); 
       return;
     }
@@ -1882,4 +1888,5 @@
   ruiDistY += uiSingleDistLuma;
   dRDCost  += dSingleCost;
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 
@@ -2747,4 +2754,6 @@
                                   Bool        bLumaOnly )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck, "estIntraPredDis");
+
   UInt    uiDepth        = pcCU->getDepth(0);
   UInt    uiWidth        = pcCU->getWidth (0);
@@ -2763,4 +2772,6 @@
   for( UInt uiPredMode = 0; uiPredMode < 4 ; uiPredMode++ )
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck, "uiPredMode" +  n2s(uiPredMode ) );
+
     // set context models
     m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
@@ -2785,4 +2796,5 @@
       pcPredYuv->copyPartToPartYuv(pcRecoYuv, 0, uiWidth, uiHeight);
     }
+      D_DEC_INDENT( g_traceModeCheck );  
   } 
 
@@ -2795,4 +2807,5 @@
   //===== set distortion (rate and r-d costs are determined later) =====
   pcCU->getTotalDistortion() = uiBestDist;
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 #endif
@@ -2813,4 +2826,6 @@
                               )
 {
+  D_PRINT_INC_INDENT( g_traceModeCheck,  "estIntraPredLumaQT");
+
   const UInt         uiDepth               = pcCU->getDepth(0);
   const UInt         uiInitTrDepth         = pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
@@ -2867,4 +2882,6 @@
   {
     const UInt uiPartOffset=tuRecurseWithPU.GetAbsPartIdxTU();
+    D_PRINT_INC_INDENT(g_traceModeCheck, "uiPartOffset: " + n2s(uiPartOffset ) );
+
 //  for( UInt uiPU = 0, uiPartOffset=0; uiPU < uiNumPU; uiPU++, uiPartOffset += uiQNumParts )
   //{
@@ -2923,4 +2940,5 @@
         Distortion uiSad  = 0;
 #endif
+        D_PRINT_INC_INDENT(g_traceModeCheck, "preTest; uiMode " + n2s(uiMode) );
 
         const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag());
@@ -2975,4 +2993,5 @@
 
         CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
+        D_DEC_INDENT( g_traceModeCheck ); 
       }
 
@@ -3173,4 +3192,6 @@
       }
 #endif
+
+      D_PRINT_INC_INDENT(g_traceModeCheck, "Test; uiOrgMode: " + n2s(uiOrgMode) );
 
       pcCU->setIntraDirSubParts ( CHANNEL_TYPE_LUMA, uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
@@ -3374,5 +3395,5 @@
       } // SDC loop
 #endif
-
+      D_DEC_INDENT( g_traceModeCheck ); 
     } // Mode loop
 
@@ -3533,5 +3554,5 @@
     pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, uiDepth + uiInitTrDepth );
 #endif
-
+    D_DEC_INDENT( g_traceModeCheck ); 
   } while (tuRecurseWithPU.nextSection(tuRecurseCU));
 
@@ -3562,4 +3583,5 @@
   //===== set distortion (rate and r-d costs are determined later) =====
   pcCU->getTotalDistortion() = uiOverallDistY;
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 
@@ -3870,4 +3892,6 @@
 )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck,  "xMergeEstimation" ); 
+
   UInt uiAbsPartIdx = 0;
   Int iWidth = 0;
@@ -3990,4 +4014,5 @@
   for( UInt uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand )
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck,  "uiMergeCand: " + n2s(uiMergeCand) ); 
     Distortion uiCostCand = std::numeric_limits<Distortion>::max();
     UInt       uiBitsCand = 0;
@@ -4066,4 +4091,7 @@
     }
     uiCostCand = uiCostCand + m_pcRdCost->getCost( uiBitsCand );
+
+    D_PRINT_INDENT( g_traceRDCost, "IP RD Cost: "  + n2s(uiCostCand)); 
+
     if ( uiCostCand < ruiCost )
     {
@@ -4074,5 +4102,7 @@
       uiMergeIndex = uiMergeCand;
     }
-  }
+    D_DEC_INDENT( g_traceModeCheck ); 
+  }
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 
@@ -4111,4 +4141,7 @@
 #endif
 {
+
+  D_PRINT_INC_INDENT(g_traceModeCheck,  "predInterSearch");
+
   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
   {
@@ -4177,4 +4210,6 @@
   for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck, "iPartIdx: " + n2s(iPartIdx) );
+
     Distortion   uiCost[2] = { std::numeric_limits<Distortion>::max(), std::numeric_limits<Distortion>::max() };
     Distortion   uiCostBi  =   std::numeric_limits<Distortion>::max();
@@ -4223,8 +4258,12 @@
     for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
     {
+      D_PRINT_INC_INDENT(g_traceModeCheck,  "iRefList: " + n2s(iRefList) );
+
       RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
 
       for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
       {
+        D_PRINT_INC_INDENT(g_traceModeCheck,  "iRefIdxTemp: " + n2s(iRefIdxTemp) );
+
         uiBitsTemp = uiMbBits[iRefList];
         if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
@@ -4299,5 +4338,7 @@
           refIdxValidList1 = iRefIdxTemp;
         }
-      }
+        D_DEC_INDENT( g_traceModeCheck ); 
+      }
+      D_DEC_INDENT( g_traceModeCheck ); 
     }
 
@@ -4568,4 +4609,5 @@
         xGetInterPredictionError( pcCU, pcOrgYuv, iPartIdx, uiMEError, m_pcEncCfg->getUseHADME() );
         uiMECost = uiMEError + m_pcRdCost->getCost( uiMEBits );
+        D_PRINT_INDENT( g_traceRDCost, "IP RD Cost: "  + n2s(uiMECost)); 
       }
 #else
@@ -4714,9 +4756,10 @@
     //  MC
     motionCompensation ( pcCU, pcPredYuv, REF_PIC_LIST_X, iPartIdx );
-
+    D_DEC_INDENT( g_traceModeCheck ); 
   } //  end of for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ )
 
   setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
 
+  D_DEC_INDENT( g_traceModeCheck ); 
   return;
 }
@@ -4726,4 +4769,6 @@
 Void TEncSearch::xEstimateMvPredAMVP( TComDataCU* pcCU, TComYuv* pcOrgYuv, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred, Bool bFilled, Distortion* puiDistBiP )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck, "xEstimateMvPredAMVP");
+
   AMVPInfo*  pcAMVPInfo = pcCU->getCUMvField(eRefPicList)->getAMVPInfo();
 
@@ -4802,5 +4847,9 @@
     if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefPicList==REF_PIC_LIST_1)
     {
+      D_PRINT_INC_INDENT(g_traceModeCheck, "Init");
+
       (*puiDistBiP) = xGetTemplateCost( pcCU, uiPartAddr, pcOrgYuv, &m_cYuvPredTemp, rcMvPred, 0, AMVP_MAX_NUM_CANDS, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight);
+
+      D_DEC_INDENT( g_traceModeCheck ); 
     }
     return;
@@ -4818,4 +4867,6 @@
   for ( i = 0 ; i < pcAMVPInfo->iN; i++)
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck, "Cand i=" +  n2s(i) + " X: " + n2s( pcAMVPInfo->m_acMvCand[i].getHor() ) + " Y: " + n2s( pcAMVPInfo->m_acMvCand[i].getVer() ));
+
     Distortion uiTmpCost;
     uiTmpCost = xGetTemplateCost( pcCU, uiPartAddr, pcOrgYuv, &m_cYuvPredTemp, pcAMVPInfo->m_acMvCand[i], i, AMVP_MAX_NUM_CANDS, eRefPicList, iRefIdx, iRoiWidth, iRoiHeight);
@@ -4827,4 +4878,6 @@
       (*puiDistBiP) = uiTmpCost;
     }
+
+    D_DEC_INDENT( g_traceModeCheck ); 
   }
 
@@ -4835,4 +4888,7 @@
   pcCU->setMVPIdxSubParts( iBestIdx, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
   pcCU->setMVPNumSubParts( pcAMVPInfo->iN, eRefPicList, uiPartAddr, uiPartIdx, pcCU->getDepth(uiPartAddr));
+
+  D_DEC_INDENT( g_traceModeCheck ); 
+
   return;
 }
@@ -5038,4 +5094,6 @@
 Void TEncSearch::xMotionEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPartIdx, RefPicList eRefPicList, TComMv* pcMvPred, Int iRefIdxPred, TComMv& rcMv, UInt& ruiBits, Distortion& ruiCost, Bool bBi  )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck,  "xMotionEstimation");
+
   UInt          uiPartAddr;
   Int           iRoiWidth;
@@ -5168,4 +5226,7 @@
   ruiBits      += uiMvBits;
   ruiCost       = (Distortion)( floor( fWeight * ( (Double)ruiCost - (Double)m_pcRdCost->getCost( uiMvBits ) ) ) + (Double)m_pcRdCost->getCost( ruiBits ) );
+  
+  D_PRINT_INDENT(g_traceRDCost, "ME Cost:" + n2s(ruiCost)  );
+  D_DEC_INDENT  ( g_traceModeCheck ); 
 }
 
@@ -5727,4 +5788,6 @@
                                             Bool bSkipResidual DEBUG_STRING_FN_DECLARE(sDebug) )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck, "encodeResAndCalcRdInterCU; Skip residual: " + n2s(bSkipResidual));
+
   assert ( !pcCU->isIntra(0) );
 
@@ -5820,4 +5883,6 @@
     }
 #endif
+    D_DEC_INDENT( g_traceModeCheck ); 
+
     return;
   }
@@ -5846,5 +5911,22 @@
   }
 
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  Bool oldTraceRDCost = g_traceRDCost;     
+  g_traceRDCost = false; 
+
+  Bool oldTraceModeCheck = g_traceModeCheck; 
+  g_traceModeCheck = false; 
+
+  Bool oldTraceFracBits = g_traceEncFracBits; 
+  g_traceEncFracBits = false; 
+  
+#endif
   xEstimateInterResidualQT( pcYuvResi,  pcYuvOrg, pcYuvPred, nonZeroCost, nonZeroBits, nonZeroDistortion, &zeroDistortion, tuLevel0 DEBUG_STRING_PASS_INTO(sDebug) );    
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  g_traceRDCost = oldTraceRDCost;
+  g_traceEncFracBits = oldTraceFracBits; 
+  g_traceModeCheck = oldTraceModeCheck; 
+#endif
 
   if ( m_pcRdCost->getUseVSO() )
@@ -5967,5 +6049,5 @@
   }
 #endif
-
+  D_DEC_INDENT( g_traceModeCheck ); 
 }
 
@@ -6125,4 +6207,6 @@
                                            DEBUG_STRING_FN_DECLARE(sDebug) )
 {
+  D_PRINT_INC_INDENT(g_traceModeCheck, "xEstimateInterResidualQT");
+
   TComDataCU *pcCU        = rTu.getCU();
   const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU();
@@ -6176,4 +6260,6 @@
   if( bCheckFull )
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck,  "bCheckFull" );
+
     Double minCost[MAX_NUM_COMPONENT][2/*0 = top (or whole TU for non-4:2:2) sub-TU, 1 = bottom sub-TU*/];
     Bool checkTransformSkip[MAX_NUM_COMPONENT];
@@ -6263,4 +6349,6 @@
           for (Int transformSkipModeId = 0; transformSkipModeId < transformSkipModesToTest; transformSkipModeId++)
           {
+            D_PRINT_INC_INDENT( g_traceModeCheck && ( transformSkipModeId > 0) , "TransformSkipModeId: " + n2s(transformSkipModeId) );
+
             pcCU->setTransformSkipPartRange(transformSkipModeId, compID, subTUAbsPartIdx, partIdxesPerSubTU);
 
@@ -6269,4 +6357,6 @@
               const Bool isFirstMode          = (transformSkipModeId == 0) && (crossCPredictionModeId == 0);
               const Bool bUseCrossCPrediction = crossCPredictionModeId != 0;
+
+              D_PRINT_INC_INDENT( g_traceModeCheck, "Zero" );              
 
               m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
@@ -6423,6 +6513,10 @@
               DEBUG_STRING_NEW(sSingleStringTest)
 
+              D_DEC_INDENT( g_traceModeCheck ); 
+
               if( currAbsSum > 0 ) //if non-zero coefficients are present, a residual needs to be derived for further prediction
               {
+                D_PRINT_INC_INDENT(g_traceModeCheck, "NonZero");
+
                 if (isFirstMode)
                 {
@@ -6517,4 +6611,5 @@
                 currCompCost = nonCoeffCost;
               }
+              D_DEC_INDENT( g_traceModeCheck ); 
 
               // evaluate
@@ -6594,4 +6689,5 @@
               }
             }
+            D_DEC_INDENT( g_traceModeCheck ); 
           }
 
@@ -6604,4 +6700,6 @@
     } // component loop
 
+    D_PRINT_INC_INDENT(g_traceModeCheck,  "Final");
+
     for(UInt ch = 0; ch < numValidComp; ch++)
     {
@@ -6659,4 +6757,7 @@
 #endif
       dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDist );
+
+      D_DEC_INDENT( g_traceModeCheck ); 
+      D_DEC_INDENT( g_traceModeCheck ); 
   } // check full
 
@@ -6664,4 +6765,5 @@
   if( bCheckSplit )
   {
+    D_PRINT_INC_INDENT(g_traceModeCheck,  "bCheckSplit" );
     if( bCheckFull )
     {
@@ -6833,4 +6935,5 @@
       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_TEST ] );
     }
+    D_DEC_INDENT( g_traceModeCheck ); 
   }
   else
@@ -6852,4 +6955,5 @@
 #endif
   }
+  D_DEC_INDENT( g_traceModeCheck ); 
   DEBUG_STRING_APPEND(sDebug, debug_reorder_data_inter_token[MAX_NUM_COMPONENT])
 }
