Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/ContextTables.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/ContextTables.h	(revision 1258)
@@ -51,5 +51,5 @@
 #define NUM_SPLIT_FLAG_CTX            3       ///< number of context models for split flag
 #define NUM_SKIP_FLAG_CTX             3       ///< number of context models for skip flag
-#if H_3D
+#if NH_3D_DIS
 #define NUM_DIS_FLAG_CTX              1
 #define NUM_DIS_TYPE_CTX              1       
@@ -218,5 +218,5 @@
   { CNU,  CNU,  CNU, },
 };
-#if H_3D
+#if NH_3D_DIS
 static const UChar 
 INIT_DIS_FLAG[3][NUM_DIS_FLAG_CTX] =  
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/Debug.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/Debug.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/Debug.h	(revision 1258)
@@ -46,5 +46,4 @@
 #include <sstream>
 #include <TLibCommon/CommonDef.h>
-
 #if DEBUG_STRING
 extern const Char *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1];
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/SEI.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/SEI.h	(revision 1258)
@@ -42,5 +42,4 @@
 #include "CommonDef.h"
 #include "libmd5/MD5.h"
-
 //! \ingroup TLibCommon
 //! \{
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1258)
@@ -55,7 +55,7 @@
 
   m_skipFlag           = NULL;
-#if H_3D
+#if NH_3D_DIS
   m_bDISFlag           = NULL;
-  m_uiDISType          = NULL;
+  m_ucDISType          = NULL;
 #endif
   m_pePartSize         = NULL;
@@ -169,7 +169,7 @@
     m_ChromaQpAdj        = new UChar[ uiNumPartition ];
     m_skipFlag           = new Bool[ uiNumPartition ];
-#if H_3D
+#if NH_3D_DIS
     m_bDISFlag           = new Bool[ uiNumPartition ];
-    m_uiDISType          = (UInt*)xMalloc(UInt, uiNumPartition);
+    m_ucDISType          = (UChar*)xMalloc(UChar, uiNumPartition);
 #endif
     m_pePartSize         = new Char[ uiNumPartition ];
@@ -321,7 +321,7 @@
     }
 
-#if H_3D
+#if NH_3D_DIS
     if ( m_bDISFlag           ) { delete[] m_bDISFlag;   m_bDISFlag     = NULL; }
-    if ( m_uiDISType         ) { xFree(m_uiDISType);  m_uiDISType    = NULL; }
+    if ( m_ucDISType         ) { xFree(m_ucDISType);  m_ucDISType    = NULL; }
 #endif
 
@@ -570,7 +570,7 @@
   memset( m_skipFlag          , false,                      m_uiNumPartition * sizeof( *m_skipFlag ) );
 
-#if H_3D
-    m_bDISFlag[ui]   = pcFrom->getDISFlag(ui);
-    m_uiDISType[ui]  = pcFrom->getDISType(ui);
+#if NH_3D_DIS
+    memset( m_bDISFlag        , false,                      m_uiNumPartition * sizeof( *m_bDISFlag ) );
+    memset( m_ucDISType       , false,                      m_uiNumPartition * sizeof( *m_ucDISType ) );
 #endif
 
@@ -619,8 +619,4 @@
 #if H_3D_DBBP
     m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
-#endif
-#if H_3D
-    memset( m_bDISFlag          + firstElement, false,                    numElements * sizeof( *m_bDISFlag ) );
-    memset( m_uiDISType         + firstElement,     0,                    numElements * sizeof( *m_uiDISType) );
 #endif
 #if H_3D_VSP
@@ -762,7 +758,7 @@
     }
     m_skipFlag[ui]      = false;
-#if H_3D
-      m_bDISFlag[ui]   = false;
-      m_uiDISType[ui]  = 0;
+#if NH_3D_DIS
+    m_bDISFlag[ui]      = false;
+    m_ucDISType[ui]     = 0;
 #endif
     m_pePartSize[ui]    = NUMBER_OF_PART_SIZES;
@@ -921,7 +917,7 @@
   {
     m_skipFlag[ui]   = false;
-#if H_3D
+#if NH_3D_DIS
     m_bDISFlag[ui]   = false;
-    m_uiDISType[ui]  = 0;
+    m_ucDISType[ui]  = 0;
 #endif
 
@@ -937,7 +933,7 @@
       m_apiMVPNum[rpl][ui] = -1;
     }
-#if H_3D
+#if NH_3D_DIS
       m_bDISFlag[ui]    = pcCU->getDISFlag(uiPartOffset+ui);
-      m_uiDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
+      m_ucDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
 #endif
 #if H_3D_VSP
@@ -1028,7 +1024,7 @@
 
   m_skipFlag=pcCU->getSkipFlag()          + uiPart;
-#if H_3D
+#if NH_3D_DIS
   m_bDISFlag     = pcCU->getDISFlag()     + uiPart;
-  m_uiDISType    = pcCU->getDISType()     + uiPart;
+  m_ucDISType    = pcCU->getDISType()     + uiPart;
 #endif
 
@@ -1166,7 +1162,7 @@
 
   m_skipFlag           = pcCU->getSkipFlag ()             + uiAbsPartIdx;
-#if H_3D
+#if NH_3D_DIS
   m_bDISFlag           = pcCU->getDISFlag ()              + uiAbsPartIdx;
-  m_uiDISType          = pcCU->getDISType()               + uiAbsPartIdx;
+  m_ucDISType          = pcCU->getDISType()               + uiAbsPartIdx;
 #endif
 
@@ -1240,7 +1236,7 @@
   Int sizeInChar  = sizeof( Char ) * uiNumPartition;
   memcpy( m_skipFlag   + uiOffset, pcCU->getSkipFlag(),       sizeof( *m_skipFlag )   * uiNumPartition );
-#if H_3D
-  memcpy( m_bDISFlag   + uiOffset, pcCU->getDISFlag(),       sizeof( *m_bDISFlag )   * uiNumPartition );
-  memcpy( m_uiDISType  + uiOffset, pcCU->getDISType(),       sizeof( *m_uiDISType )  * uiNumPartition);
+#if NH_3D_DIS
+  memcpy( m_bDISFlag   + uiOffset, pcCU->getDISFlag(),        sizeof( *m_bDISFlag )   * uiNumPartition );
+  memcpy( m_ucDISType  + uiOffset, pcCU->getDISType(),        sizeof( *m_ucDISType )  * uiNumPartition);
 #endif
   memcpy( m_phQP       + uiOffset, pcCU->getQP(),             sizeInChar                        );
@@ -1357,7 +1353,7 @@
 
   memcpy( pCtu->getSkipFlag() + m_absZIdxInCtu, m_skipFlag, sizeof( *m_skipFlag ) * m_uiNumPartition );
-#if H_3D
-  memcpy( rpcCU->getDISFlag()  + m_uiAbsIdxInLCU, m_bDISFlag,    sizeof( *m_bDISFlag )  * m_uiNumPartition );
-  memcpy( rpcCU->getDISType()  + m_uiAbsIdxInLCU, m_uiDISType,   sizeof( *m_uiDISType ) * m_uiNumPartition );
+#if NH_3D_DIS
+  memcpy( pCtu->getDISFlag()  + m_absZIdxInCtu, m_bDISFlag, sizeof( *m_bDISFlag )  * m_uiNumPartition );
+  memcpy( pCtu->getDISType()  + m_absZIdxInCtu, m_ucDISType, sizeof( *m_ucDISType ) * m_uiNumPartition );
 #endif
 
@@ -1455,10 +1451,4 @@
   pCtu->getTotalBins() = m_uiTotalBins;
 }
-
-#if H_3D
-  memcpy( rpcCU->getDISFlag()  + uiPartOffset, m_bDISFlag,    sizeof( *m_bDISFlag )   * uiQNumPart );
-  memcpy( rpcCU->getDISType()  + uiPartOffset, m_uiDISType,   sizeof( *m_uiDISType )  * uiQNumPart );
-#endif
-
 #if H_3D_VSP
   memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
@@ -2205,14 +2195,15 @@
 }
 
-#if H_3D
-Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt absPartIdx, UInt depth )
+#if NH_3D_DIS
+Void TComDataCU::setDISFlagSubParts( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth )
 {
     assert( sizeof( *m_bDISFlag) == 1 );
-    memset( m_bDISFlag + absPartIdx, bDIS, m_pcPic->getNumPartInCU() >> ( 2 * depth ) );
-}
-
-Void TComDataCU::setDISTypeSubParts(UInt uiDISType, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
-{
-    setSubPartT( uiDISType, m_uiDISType, uiAbsPartIdx, uiDepth, uiPUIdx );
+    memset( m_bDISFlag + uiAbsPartIdx, bDIS, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );
+}
+
+Void TComDataCU::setDISTypeSubParts(UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( sizeof( *m_ucDISType) == 1 );
+  memset( m_ucDISType + uiAbsPartIdx, ucDISType, m_pcPic->getNumPartitionsInCtu() >> ( 2 * uiDepth ) );
 }
 #endif
@@ -5604,14 +5595,16 @@
 #endif
 
-#if H_3D
+#if NH_3D_DIS
 Bool TComDataCU::getNeighDepth ( UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index )
 {
-  UInt  uiPartIdxLT, uiPartIdxRT;
-  this->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, 0, 0 );
+  assert(uiPartIdx==0);
+  const UInt uiPartIdxLT      = getZorderIdxInCtu() + uiPartAddr;
+  const Int  iPartIdxStride   = getPic()->getNumPartInCtuWidth();
+  
   UInt uiMidPart, uiPartNeighbor;  
   TComDataCU* pcCUNeighbor;
   Bool bDepAvail = false;
-  Pel *pDepth  = this->getPic()->getPicYuvRec()->getLumaAddr();
-  Int iDepStride =  this->getPic()->getPicYuvRec()->getStride();
+  Pel *pDepth  = this->getPic()->getPicYuvRec()->getAddr(COMPONENT_Y);
+  Int iDepStride =  this->getPic()->getPicYuvRec()->getStride(COMPONENT_Y);
 
   Int xP, yP, nPSW, nPSH;
@@ -5621,5 +5614,5 @@
   {
   case 0: // Mid Left
-    uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * this->getPic()->getNumPartInWidth();
+    uiMidPart = g_auiZscanToRaster[uiPartIdxLT] + (nPSH>>1) / this->getPic()->getMinCUHeight() * iPartIdxStride;
     pcCUNeighbor = this->getPULeft( uiPartNeighbor, g_auiRasterToZscan[uiMidPart] );
     if ( pcCUNeighbor )
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComDataCU.h	(revision 1258)
@@ -116,7 +116,7 @@
 
   Bool*          m_skipFlag;           ///< array of skip flags
-#if H_3D
-  Bool*         m_bDISFlag;         
-  UInt*         m_uiDISType;
+#if NH_3D_DIS
+  Bool*          m_bDISFlag;         
+  UChar*         m_ucDISType;
 #endif
   Char*          m_pePartSize;         ///< array of partition sizes
@@ -334,14 +334,14 @@
   Void          setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
   Void          setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
-#if H_3D
+#if NH_3D_DIS
   Bool*        getDISFlag            ()                         { return m_bDISFlag;          }
   Bool         getDISFlag            ( UInt idx)                { return m_bDISFlag[idx];     }
   Void         setDISFlag            ( UInt idx, Bool bDIS)     { m_bDISFlag[idx] = bDIS;   }
-  Void         setDISFlagSubParts    ( Bool bDIS, UInt absPartIdx, UInt depth );
-
-  UInt*        getDISType            ()                         { return m_uiDISType; }
-  UInt         getDISType            ( UInt idx)                { return m_uiDISType[idx];     }
-  Void         getDISType            ( UInt idx, UInt uiDISType)     { m_uiDISType[idx] = uiDISType;   }
-  Void         setDISTypeSubParts    ( UInt uiDISType, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth );
+  Void         setDISFlagSubParts    ( Bool bDIS, UInt uiAbsPartIdx, UInt uiDepth );
+
+  UChar*       getDISType            ()                         { return m_ucDISType; }
+  UChar        getDISType            ( UInt idx)                { return m_ucDISType[idx];     }
+  Void         getDISType            ( UInt idx, UChar ucDISType)     { m_ucDISType[idx] = ucDISType;   }
+  Void         setDISTypeSubParts    ( UChar ucDISType, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
   Char*         getPredictionMode     ()                        { return m_pePredMode;        }
@@ -501,6 +501,4 @@
   Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
   Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
-
-   Bool          getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index);
 #endif
 #if H_3D_NBDV_REF
@@ -508,4 +506,7 @@
   Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
 #endif //H_3D_NBDV_REF
+#endif
+#if NH_3D_DIS
+   Bool          getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index);
 #endif
 #if  H_3D_FAST_TEXTURE_ENCODING
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TComSlice.cpp	(revision 1258)
@@ -150,5 +150,5 @@
 , m_depthToDisparityF             (NULL)
 #endif
-#if H_3D
+#if NH_3D_DIS
 , m_bApplyDIS                     (false)
 #endif
@@ -1168,5 +1168,5 @@
   }
 #endif
-#if H_3D
+#if NH_3D_DIS
   m_bApplyDIS = pSrc->m_bApplyDIS;
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibCommon/TypeDef.h	(revision 1258)
@@ -61,4 +61,5 @@
 #define NH_3D          ( HEVC_EXT == 2)
 
+
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   MAJOR DEFINES   ///////////////////////////////////  
@@ -78,4 +79,5 @@
                                               // HHI_DMM4_ENC_I0066
                                               // H_3D_FAST_DEPTH_INTRA
+#define NH_3D_DIS                         1
 #endif
 
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/NALread.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/NALread.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/NALread.h	(revision 1258)
@@ -41,9 +41,7 @@
 #ifndef __NALREAD__
 #define __NALREAD__
-
 #include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComBitStream.h"
 #include "TLibCommon/NAL.h"
-
 //! \ingroup TLibDecoder
 //! \{
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/SyntaxElementParser.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/SyntaxElementParser.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/SyntaxElementParser.h	(revision 1258)
@@ -42,7 +42,5 @@
 #pragma once
 #endif // _MSC_VER > 1000
-
 #include "TLibCommon/TComRom.h"
-
 #if ENC_DEC_TRACE
 
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1258)
@@ -3224,5 +3224,5 @@
 }
 
-#if H_3D
+#if NH_3D_DIS
 Void TDecCavlc::parseDIS( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
 {
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1258)
@@ -111,6 +111,6 @@
         
   Void  parseSkipFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
-#if H_3D
-  Void  parseDIS            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#if NH_3D_DIS
+  Void  parseDIS             ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
   Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1258)
@@ -512,5 +512,5 @@
     return;
   }
-#if H_3D
+#if NH_3D_DIS
   m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth );
   if(!pcCU->getDISFlag(uiAbsPartIdx))
@@ -547,5 +547,5 @@
   setIsChromaQpAdjCoded( isChromaQpAdjCoded );
   setdQPFlag( bCodeDQP );
-#if H_3D
+#if NH_3D_DIS
   }
 #endif
@@ -643,8 +643,15 @@
     case MODE_INTRA:
 #if NH_3D
-    if( false /*m_ppcCU[uiDepth]->getDISFlag(0)*/ )
-    {
-      //xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
-    }
+#if NH_3D_DIS
+    if( m_ppcCU[uiDepth]->getDISFlag(0) )
+    {
+      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
+    }
+#else
+    if(false )
+    {
+     // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
+    }
+#endif
 #if NH_3D_SDC_INTRA
     else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
@@ -723,5 +730,5 @@
 }
 
-#if H_3D
+#if NH_3D_DIS
 Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -731,6 +738,6 @@
   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
 
-  UInt    uiStride    = pcRecoYuv->getStride  ();
-  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
+  UInt    uiStride    = pcRecoYuv->getStride  (COMPONENT_Y);
+  Pel*    piReco      = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx );
 
 
@@ -740,23 +747,23 @@
   Bool  bAboveAvail = false;
   Bool  bLeftAvail  = false;
-  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
-  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, 
-    m_pcPrediction->getPredicBuf       (),
-    m_pcPrediction->getPredicBufWidth  (),
-    m_pcPrediction->getPredicBufHeight (),
-    bAboveAvail, bLeftAvail
-    );
+  
+  TComTURecurse rTu(pcCU, 0);
+  const ChromaFormat chFmt     = rTu.GetChromaFormat();
 
   if ( pcCU->getDISType(uiAbsPartIdx) == 0 )
   {
-    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), VER_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
+    m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
+    m_pcPrediction->predIntraAng( COMPONENT_Y,   VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
   }
   else if ( pcCU->getDISType(uiAbsPartIdx) == 1 )
   {
-    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), HOR_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
+    m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
+    m_pcPrediction->predIntraAng( COMPONENT_Y,   HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
   }
   else if ( pcCU->getDISType(uiAbsPartIdx) == 2 )
   {
-    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
+    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
@@ -771,5 +778,5 @@
   else if ( pcCU->getDISType(uiAbsPartIdx) == 3 )
   {
-    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
+    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
@@ -784,7 +791,7 @@
 
   // clear UV
-  UInt  uiStrideC     = pcRecoYuv->getCStride();
-  Pel   *pRecCb       = pcRecoYuv->getCbAddr();
-  Pel   *pRecCr       = pcRecoYuv->getCrAddr();
+  UInt  uiStrideC     = pcRecoYuv->getStride(COMPONENT_Cb);
+  Pel   *pRecCb       = pcRecoYuv->getAddr(COMPONENT_Cb);
+  Pel   *pRecCr       = pcRecoYuv->getAddr(COMPONENT_Cr);
 
   for (Int y=0; y<uiHeight/2; y++)
@@ -792,6 +799,6 @@
     for (Int x=0; x<uiWidth/2; x++)
     {
-      pRecCb[x] = 1<<(g_bitDepthC-1);
-      pRecCr[x] = 1<<(g_bitDepthC-1);
+      pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
+      pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
     }
 
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecCu.h	(revision 1258)
@@ -124,5 +124,5 @@
   Void xFillPCMBuffer           (TComDataCU* pCU, UInt depth);
 
-#if H_3D
+#if NH_3D_DIS
   Void xReconDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1258)
@@ -60,5 +60,5 @@
   m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
 }
-#if H_3D
+#if NH_3D_DIS
 Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -67,5 +67,4 @@
     return;
   }  
-
   m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth );
 }
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1258)
@@ -38,5 +38,4 @@
 #ifndef __TDECENTROPY__
 #define __TDECENTROPY__
-
 #include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComBitStream.h"
@@ -45,5 +44,4 @@
 #include "TLibCommon/TComSampleAdaptiveOffset.h"
 #include "TLibCommon/TComRectangle.h"
-
 class TDecSbac;
 class TDecCavlc;
@@ -78,5 +76,5 @@
 public:
   virtual Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
-#if H_3D
+#if NH_3D_DIS
   virtual Void parseDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
@@ -167,5 +165,5 @@
   Void decodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void decodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
-#if H_3D
+#if NH_3D_DIS
   Void decodeDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) ;
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1258)
@@ -67,7 +67,7 @@
 , m_cCUSplitFlagSCModel                      ( 1,             1,                      NUM_SPLIT_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUSkipFlagSCModel                       ( 1,             1,                      NUM_SKIP_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D
-, m_cCUDISFlagSCModel         ( 1,             1,               NUM_DIS_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cCUDISTypeSCModel         ( 1,             1,               NUM_DIS_TYPE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#if NH_3D_DIS
+, m_cCUDISFlagSCModel                        ( 1,             1,                      NUM_DIS_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cCUDISTypeSCModel                        ( 1,             1,                      NUM_DIS_TYPE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 , m_cCUMergeFlagExtSCModel                   ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
@@ -159,7 +159,7 @@
   m_cCUSplitFlagSCModel.initBuffer                ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG );
   m_cCUSkipFlagSCModel.initBuffer                 ( sliceType, qp, (UChar*)INIT_SKIP_FLAG );
-#if H_3D
-  m_cCUDISFlagSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_DIS_FLAG );
-  m_cCUDISTypeSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_DIS_TYPE );
+#if NH_3D_DIS
+  m_cCUDISFlagSCModel.initBuffer                  ( sliceType, qp, (UChar*)INIT_DIS_FLAG );
+  m_cCUDISTypeSCModel.initBuffer                  ( sliceType, qp, (UChar*)INIT_DIS_TYPE );
 #endif
   m_cCUMergeFlagExtSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
@@ -238,8 +238,4 @@
 }
 
-#if H_3D
-  m_cCUDISFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );
-  m_cCUDISTypeSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
-#endif
 #if H_3D_ARP
   m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
@@ -525,10 +521,10 @@
 
 }
-#if H_3D
+#if NH_3D_DIS
 Void TDecSbac::parseDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
   pcCU->setDISFlagSubParts( false,        uiAbsPartIdx, uiDepth );
   UInt uiSymbol = 0;
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) );
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUDISFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) );
   if( uiSymbol )
   {
@@ -538,9 +534,9 @@
     pcCU->setPredModeSubParts( MODE_INTRA,  uiAbsPartIdx, uiDepth );
     pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
-    pcCU->setLumaIntraDirSubParts (DC_IDX, uiAbsPartIdx, uiDepth );
-    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
+    pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, uiAbsPartIdx, uiDepth );
+    pcCU->setSizeSubParts( pcCU->getSlice()->getSPS()->getMaxCUWidth()>>uiDepth, pcCU->getSlice()->getSPS()->getMaxCUHeight()>>uiDepth, uiAbsPartIdx, uiDepth );
     pcCU->setMergeFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
     pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth);
-    pcCU->setCbfSubParts(0, 1, 1, uiAbsPartIdx, uiDepth);
+    pcCU->setCbfSubParts(0, COMPONENT_Y, uiAbsPartIdx, uiDepth);
 
     UInt uiUnaryIdx = 0;
@@ -554,9 +550,9 @@
         if ( uiUnaryIdx==0 )
         {
-          m_pcTDecBinIf->decodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) );
+          m_pcTDecBinIf->decodeBin( uiSymbol2, m_cCUDISTypeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) );
         }
         else
         {
-          m_pcTDecBinIf->decodeBinEP( uiSymbol2);
+          m_pcTDecBinIf->decodeBinEP( uiSymbol2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG));
         }
         if( uiSymbol2 == 0 )
@@ -566,5 +562,5 @@
       }
     }
-    pcCU->setDISTypeSubParts(uiUnaryIdx, uiAbsPartIdx, 0, uiDepth);
+    pcCU->setDISTypeSubParts((UChar)uiUnaryIdx, uiAbsPartIdx, uiDepth);
   }
 }
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibDecoder/TDecSbac.h	(revision 1258)
@@ -133,5 +133,5 @@
 
   Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
-#if H_3D
+#if NH_3D_DIS
   Void parseDIS          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -182,5 +182,5 @@
   ContextModel3DBuffer m_cCUSplitFlagSCModel;
   ContextModel3DBuffer m_cCUSkipFlagSCModel;
-#if H_3D
+#if NH_3D_DIS
   ContextModel3DBuffer m_cCUDISFlagSCModel;
   ContextModel3DBuffer m_cCUDISTypeSCModel;
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1258)
@@ -2550,5 +2550,5 @@
   assert(0);
 }
-#if H_3D
+#if NH_3D_DIS
 Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1258)
@@ -121,5 +121,5 @@
   Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D
+#if NH_3D_DIS
   Void codeDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1258)
@@ -739,5 +739,5 @@
     }
 #endif
-#if H_3D
+#if NH_3D_DIS
     rpcTempCU->initEstData( uiDepth, iMinQP, isAddLowestQP  );
     if( rpcBestCU->getSlice()->getDepthIntraSkipFlag() )
@@ -1583,5 +1583,5 @@
   }
 
-#if H_3D
+#if NH_3D_DIS
   m_pcEntropyCoder->encodeDIS( pcCU, uiAbsPartIdx );
   if(!pcCU->getDISFlag(uiAbsPartIdx))
@@ -1628,5 +1628,5 @@
   setCodeChromaQpAdjFlag( codeChromaQpAdj );
   setdQPFlag( bCodeDQP );
-#if H_3D
+#if NH_3D_DIS
   }
 #endif
@@ -2021,5 +2021,5 @@
             mergeCandBuffer[uiMergeCand] = 1;
           }
-#if H_3D
+#if NH_3D_DIS
           rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
 #endif
@@ -2063,5 +2063,5 @@
               }
               rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
-#if H_3D
+#if NH_3D_DIS
               rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
 #endif
@@ -2214,5 +2214,5 @@
       }
 #endif
-#if H_3D
+#if NH_3D_DIS
       rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
 #endif
@@ -2331,5 +2331,5 @@
           }
           rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
-#if H_3D
+#if NH_3D_DIS
           rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
 #endif
@@ -2440,78 +2440,4 @@
     pMask   += 2*uiMaskStride;
   }
-}
-
-Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
-{
-  UInt uiDepth = rpcTempCU->getDepth( 0 );
-  if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N))
-  {
-    return;
-  }
-
-#if NH_3D_VSO // M5
-  if( m_pcRdCost->getUseRenModel() )
-  {
-    UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ( COMPONENT_Y );
-    UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ( COMPONENT_Y );
-    Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getAddr    ( COMPONENT_Y );
-    UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ( COMPONENT_Y );
-    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-  }
-#endif
-
-  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
-  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
-  rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
-  rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth );
-
-  rpcTempCU->setTrIdxSubParts(0, 0, uiDepth);
-  rpcTempCU->setCbfSubParts(0, 1, 1, 0, uiDepth);
-  rpcTempCU->setDISFlagSubParts(true, 0, uiDepth);
-  rpcTempCU->setLumaIntraDirSubParts (DC_IDX, 0, uiDepth);
-#if NH_3D_SDC_INTRA
-  rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth);
-#endif
-
-  UInt uiPreCalcDistC;
-  m_pcPredSearch  ->estIntraPredDIS      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false );
-
-#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
-  Int oldTraceCopyBack = g_traceCopyBack; 
-  g_traceCopyBack = false;  
-#endif
-  m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() );
-  #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC  
-    g_traceCopyBack = oldTraceCopyBack; 
-  #endif
-
-
-  m_pcEntropyCoder->resetBits();
-  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
-  {
-    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
-  }
-  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
-  m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
-
-
-  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
-
-  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
-  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
-
-
-#if NH_3D_VSO // M6
-  if( m_pcRdCost->getUseLambdaScaleVSO())
-  {
-    rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );  
-  }
-  else
-#endif
-    rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-
-
-  xCheckDQP( rpcTempCU );
-  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
 }
 
@@ -2651,5 +2577,75 @@
 }
 #endif
-
+#if NH_3D_DIS
+Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
+{
+  UInt uiDepth = rpcTempCU->getDepth( 0 );
+  if( !rpcBestCU->getSlice()->getIsDepth() || (eSize != SIZE_2Nx2N))
+  {
+    return;
+  }
+
+#if NH_3D_VSO // M5
+  if( m_pcRdCost->getUseRenModel() )
+  {
+    UInt  uiWidth     = m_ppcOrigYuv[uiDepth]->getWidth   ( COMPONENT_Y );
+    UInt  uiHeight    = m_ppcOrigYuv[uiDepth]->getHeight  ( COMPONENT_Y );
+    Pel*  piSrc       = m_ppcOrigYuv[uiDepth]->getAddr    ( COMPONENT_Y );
+    UInt  uiSrcStride = m_ppcOrigYuv[uiDepth]->getStride  ( COMPONENT_Y );
+    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+  }
+#endif
+
+  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
+  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
+  rpcTempCU->setPredModeSubParts( MODE_INTRA, 0, uiDepth );
+  rpcTempCU->setCUTransquantBypassSubParts( rpcTempCU->getCUTransquantBypass(0), 0, uiDepth );
+
+  rpcTempCU->setTrIdxSubParts(0, 0, uiDepth);
+  rpcTempCU->setCbfSubParts(0, COMPONENT_Y, 0, uiDepth);
+  rpcTempCU->setDISFlagSubParts(true, 0, uiDepth);
+  rpcTempCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, DC_IDX, 0, uiDepth);
+#if NH_3D_SDC_INTRA
+  rpcTempCU->setSDCFlagSubParts( false, 0, uiDepth);
+#endif
+
+  UInt uiPreCalcDistC;
+  m_pcPredSearch  ->estIntraPredDIS      ( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC, false );
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  Int oldTraceCopyBack = g_traceCopyBack; 
+  g_traceCopyBack = false;  
+#endif
+  m_ppcRecoYuvTemp[uiDepth]->copyToPicComponent(COMPONENT_Y, rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getCtuRsAddr(), rpcTempCU->getZorderIdxInCtu() );
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC  
+  g_traceCopyBack = oldTraceCopyBack; 
+#endif
+
+  m_pcEntropyCoder->resetBits();
+  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
+  {
+    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
+  }
+  m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
+  m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
+
+  m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
+
+  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
+  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
+
+#if NH_3D_VSO // M6
+  if( m_pcRdCost->getUseLambdaScaleVSO())
+  {
+    rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );  
+  }
+  else
+#endif
+  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+
+  xCheckDQP( rpcTempCU );
+  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
+}
+#endif
 Void TEncCu::xCheckRDCostIntra( TComDataCU *&rpcBestCU,
                                 TComDataCU *&rpcTempCU,
@@ -2677,5 +2673,5 @@
 
   rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
-#if H_3D
+#if NH_3D_DIS
   rpcTempCU->setDISFlagSubParts( false, 0, uiDepth );
 #endif
@@ -2715,5 +2711,5 @@
     m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
   }
-#if H_3D
+#if NH_3D_DIS
   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
   if(!rpcTempCU->getDISFlag(0))
@@ -2735,5 +2731,5 @@
   setCodeChromaQpAdjFlag( codeChromaQpAdjFlag );
   setdQPFlag( bCodeDQP );
-#if H_3D
+#if NH_3D_DIS
   }
 #endif
@@ -2782,5 +2778,5 @@
 
   rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth );
-#if H_3D
+#if NH_3D_DIS
   rpcTempCU->setDISFlagSubParts( false, 0, uiDepth );
 #endif
@@ -2804,5 +2800,5 @@
 
   m_pcEntropyCoder->encodeSkipFlag ( rpcTempCU, 0,          true );
-#if H_3D
+#if NH_3D_DIS
   m_pcEntropyCoder->encodeDIS( rpcTempCU, 0,          true );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncCu.h	(revision 1258)
@@ -159,5 +159,5 @@
   Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG = false );
 #endif
-#if H_3D
+#if NH_3D_DIS
   Void  xCheckRDCostDIS   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1258)
@@ -116,5 +116,5 @@
   m_pcEntropyCoderIf->codeSkipFlag( pcCU, uiAbsPartIdx );
 }
-#if H_3D
+#if NH_3D_DIS
 Void TEncEntropy::encodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1258)
@@ -79,5 +79,5 @@
   virtual Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
-#if H_3D
+#if NH_3D_DIS
   virtual Void codeDIS          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
@@ -165,5 +165,5 @@
   Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
   Void encodeSkipFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#if H_3D
+#if NH_3D_DIS
   Void encodeDIS               ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD=false );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1258)
@@ -62,5 +62,5 @@
 , m_cCUSplitFlagSCModel                ( 1,             1,                      NUM_SPLIT_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUSkipFlagSCModel                 ( 1,             1,                      NUM_SKIP_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D
+#if NH_3D_DIS
 , m_cCUDISFlagSCModel                  ( 1,             1,                      NUM_DIS_FLAG_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUDISTypeSCModel                  ( 1,             1,                      NUM_DIS_TYPE_CTX                     , m_contextModels + m_numContextModels, m_numContextModels)
@@ -143,5 +143,5 @@
   m_cCUSplitFlagSCModel.initBuffer                ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );
   m_cCUSkipFlagSCModel.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
-#if H_3D
+#if NH_3D_DIS
   m_cCUDISFlagSCModel.initBuffer                  ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );
   m_cCUDISTypeSCModel.initBuffer                  ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
@@ -231,5 +231,5 @@
       curCost  = m_cCUSplitFlagSCModel.calcCost                ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
       curCost += m_cCUSkipFlagSCModel.calcCost                 ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
-#if H_3D
+#if NH_3D_DIS
       curCost += m_cCUDISFlagSCModel.calcCost                  ( curSliceType, qp, (UChar*)INIT_DIS_FLAG );
       curCost += m_cCUDISTypeSCModel.calcCost                  ( curSliceType, qp, (UChar*)INIT_DIS_TYPE );
@@ -297,9 +297,4 @@
   }
 }
-
-#if H_3D
-  m_cCUDISFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );
-  m_cCUDISTypeSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
-#endif
 #if H_3D_ARP
   m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
@@ -420,5 +415,5 @@
 }
 
-#if H_3D
+#if NH_3D_DIS
 Void TEncSbac::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSbac.h	(revision 1258)
@@ -138,5 +138,5 @@
   Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D
+#if NH_3D_DIS
   Void codeDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
@@ -204,5 +204,5 @@
   ContextModel3DBuffer m_cCUSplitFlagSCModel;
   ContextModel3DBuffer m_cCUSkipFlagSCModel;
-#if H_3D
+#if NH_3D_DIS
   ContextModel3DBuffer m_cCUDISFlagSCModel;
   ContextModel3DBuffer m_cCUDISTypeSCModel;
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1258)
@@ -1007,5 +1007,5 @@
         }
         m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
-#if H_3D
+#if NH_3D_DIS
         m_pcEntropyCoder->encodeDIS(pcCU, 0, true );
         if(!pcCU->getDISFlag(uiAbsPartIdx))
@@ -1013,5 +1013,5 @@
         m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
       }
-#if H_3D
+#if NH_3D_DIS
       else
       {
@@ -1019,5 +1019,5 @@
       }
 #endif
-#if H_3D
+#if NH_3D_DIS
       if(!pcCU->getDISFlag(uiAbsPartIdx))
       {
@@ -1037,9 +1037,9 @@
         }
       }
-#if H_3D
-    }
-#endif
-  }
-#if H_3D
+#if NH_3D_DIS
+    }
+#endif
+  }
+#if NH_3D_DIS
     if(!pcCU->getDISFlag(uiAbsPartIdx))
     {
@@ -1080,5 +1080,5 @@
 #endif
 #endif
-#if H_3D
+#if NH_3D_DIS
       }
 #endif
@@ -1875,34 +1875,39 @@
 }
 
-#if H_3D
+#if NH_3D_DIS
 Void TEncSearch::xIntraCodingDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode )
 {
   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
   UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
-  UInt    uiStride          = pcOrgYuv ->getStride  ();
-  Pel*    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
-  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  UInt    uiStride          = pcOrgYuv ->getStride  (COMPONENT_Y);
+  Pel*    piOrg             = pcOrgYuv ->getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Pel*    piPred            = pcPredYuv->getAddr(COMPONENT_Y, uiAbsPartIdx );
 
   AOF( uiWidth == uiHeight );
   AOF( uiAbsPartIdx == 0 );
-  pcCU->setDISTypeSubParts(uiPredMode, uiAbsPartIdx, 0, pcCU->getDepth(0));  
+  pcCU->setDISTypeSubParts((UChar)uiPredMode, uiAbsPartIdx, pcCU->getDepth(0));  
   //===== reconstruction =====
 
   Bool bAboveAvail = false;
   Bool bLeftAvail  = false;
-  pcCU->getPattern()->initPattern   ( pcCU, 0, 0 );
-  pcCU->getPattern()->initAdiPattern( pcCU, 0, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
+
+  TComTURecurse rTu(pcCU, 0);
+  const ChromaFormat chFmt     = rTu.GetChromaFormat();
 
   if ( uiPredMode == 0 )
   {
-    predIntraLumaAng( pcCU->getPattern(), VER_IDX, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
+    initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
+    predIntraAng( COMPONENT_Y, VER_IDX, 0, uiStride, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
   }
   else if ( uiPredMode == 1 )
   {
-    predIntraLumaAng( pcCU->getPattern(), HOR_IDX, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+    const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
+    initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, COMPONENT_Y, bUseFilteredPredictions  DEBUG_STRING_PASS_INTO(sTemp) );
+    predIntraAng( COMPONENT_Y, HOR_IDX, 0, uiStride, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
   }
   else if ( uiPredMode == 2 )
   {
-    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
+    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 );
     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
@@ -1917,5 +1922,5 @@
   else if ( uiPredMode == 3 )
   {
-    Pel pSingleDepth = 1 << ( g_bitDepthY - 1 );
+    Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 );
     pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 );
     for( UInt uiY = 0; uiY < uiHeight; uiY++ )
@@ -1930,7 +1935,7 @@
 
   // clear UV
-  UInt  uiStrideC     = pcPredYuv->getCStride();
-  Pel   *pRecCb       = pcPredYuv->getCbAddr();
-  Pel   *pRecCr       = pcPredYuv->getCrAddr();
+  UInt  uiStrideC     = pcPredYuv->getStride(COMPONENT_Cb);
+  Pel   *pRecCb       = pcPredYuv->getAddr(COMPONENT_Cb);
+  Pel   *pRecCr       = pcPredYuv->getAddr(COMPONENT_Cr);
 
   for (Int y=0; y<uiHeight/2; y++)
@@ -1938,6 +1943,6 @@
     for (Int x=0; x<uiWidth/2; x++)
     {
-      pRecCb[x] = 1<<(g_bitDepthC-1);
-      pRecCr[x] = 1<<(g_bitDepthC-1);
+      pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
+      pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1);
     }
 
@@ -1946,12 +1951,12 @@
   }
 
-  piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  piPred            = pcPredYuv->getAddr(COMPONENT_Y, uiAbsPartIdx );
   //===== determine distortion =====
-#if H_3D_VSO
+#if NH_3D_VSO
   if ( m_pcRdCost->getUseVSO() )
-    ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
+    ruiDist = m_pcRdCost->getDistPartVSO  ( pcCU, uiAbsPartIdx, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, false );
   else
 #endif
-    ruiDist = m_pcRdCost->getDistPart(g_bitDepthY, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight );
+    ruiDist = m_pcRdCost->getDistPart(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, COMPONENT_Y );
 
   //===== determine rate and r-d cost =====
@@ -1960,5 +1965,5 @@
   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
 
-#if H_3D_VSO
+#if NH_3D_VSO
   if ( m_pcRdCost->getUseLambdaScaleVSO())
     dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
@@ -2721,5 +2726,5 @@
 }
 
-#if H_3D
+#if NH_3D_DIS
 Void TEncSearch::estIntraPredDIS( TComDataCU* pcCU, 
                                   TComYuv*    pcOrgYuv, 
@@ -2734,8 +2739,8 @@
   UInt    uiHeight       = pcCU->getHeight(0);
 
-
-  Pel* piOrg         = pcOrgYuv ->getLumaAddr( 0, uiWidth );
-  UInt uiStride      = pcPredYuv->getStride();
-
+#if NH_3D_VSO // M36
+  Pel* piOrg         = pcOrgYuv ->getAddr(COMPONENT_Y, 0, uiWidth );
+  UInt uiStride      = pcPredYuv->getStride(COMPONENT_Y);
+#endif
   Dist   uiDist = 0;
   Double dCost   = 0.0;
@@ -2752,5 +2757,5 @@
     uiDist = 0;
     dCost   = 0.0;
-#if H_3D_VSO // M36
+#if NH_3D_VSO // M36
     if( m_pcRdCost->getUseRenModel() )
     {
@@ -2771,5 +2776,5 @@
 
 
-  pcCU->setDISTypeSubParts(uiBestDISType, 0, 0, uiDepth);  
+  pcCU->setDISTypeSubParts((UChar)uiBestDISType, 0, uiDepth);  
   assert(uiBestDISType >= 0);
 
@@ -7091,5 +7096,5 @@
 
     m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
-#if H_3D
+#if NH_3D_DIS
     m_pcEntropyCoder->encodeDIS ( pcCU, 0, true );
 #endif
Index: branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.h	(revision 1253)
+++ branches/HTM-14.1-update-dev1-MediaTek/source/Lib/TLibEncoder/TEncSearch.h	(revision 1258)
@@ -192,5 +192,5 @@
                                   Pel         resiLuma[NUMBER_OF_STORED_RESIDUAL_TYPES][MAX_CU_SIZE * MAX_CU_SIZE]
                                   DEBUG_STRING_FN_DECLARE(sDebug));
-#if H_3D
+#if NH_3D_DIS
   Void  estIntraPredDIS        ( TComDataCU* pcCU, 
                                  TComYuv*    pcOrgYuv, 
@@ -344,5 +344,5 @@
   Void  xStoreIntraResultQT       ( const ComponentID compID, TComTU &rTu);
   Void  xLoadIntraResultQT        ( const ComponentID compID, TComTU &rTu);
-#if H_3D
+#if NH_3D_DIS
   Void xIntraCodingDIS           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, UInt uiPredMode );
 #endif
