Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/CommonDef.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/CommonDef.h	(revision 1262)
@@ -363,5 +363,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if H_3D_IV_MERGE || NH_3D_ARP
 #define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/ContextTables.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/ContextTables.h	(revision 1262)
@@ -162,5 +162,5 @@
 #define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
 
-#if H_3D_ARP
+#if NH_3D_ARP
 #define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
 #endif
@@ -542,5 +542,5 @@
 //! \}
 
-#if H_3D_ARP
+#if NH_3D_ARP
 static const UChar 
 INIT_ARPW[3][NUM_ARPW_CTX] = 
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComCodingStatistics.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1262)
@@ -82,4 +82,7 @@
 #if NH_3D_DBBP
   STATS__CABAC_BITS__DBBP_FLAG,
+#endif
+#if NH_3D_ARP
+  STATS__CABAC_BITS__ARP_FLAG,
 #endif
   STATS__CABAC_BITS__SAO,
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1262)
@@ -134,5 +134,5 @@
   m_pbSPIVMPFlag         = NULL;
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW              = NULL;
 #endif
@@ -249,6 +249,6 @@
     }
 
-#if H_3D_ARP
-    m_puhARPW            = new UChar[ uiNumPartition];
+#if NH_3D_ARP
+    m_puhARPW            = (UChar*  )xMalloc(UChar,   uiNumPartition);
 #endif
 #if H_3D_IC
@@ -468,6 +468,6 @@
 
 
-#if H_3D_ARP
-    if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
+#if NH_3D_ARP
+    if ( m_puhARPW            ) { xFree(m_puhARPW);             m_puhARPW           = NULL; }
 #endif
 #if H_3D_IC
@@ -598,7 +598,4 @@
   memset( m_puhHeight         , maxCUHeight,                m_uiNumPartition * sizeof( *m_puhHeight ) );
 
-#if H_3D_ARP
-    m_puhARPW   [ui] = pcFrom->getARPW( ui );
-#endif
 #if H_3D_IC
     m_pbICFlag[ui]   =  pcFrom->m_pbICFlag[ui];
@@ -651,6 +648,6 @@
   }
 
-#if H_3D_ARP
-    memset( m_puhARPW           + firstElement, 0,                        numElements * sizeof( UChar )         );
+#if NH_3D_ARP
+  memset( m_puhARPW      ,      0,        m_uiNumPartition * sizeof( *m_puhARPW )         );
 #endif
 #if H_3D_IC
@@ -809,6 +806,6 @@
       m_puhCbf[comp][ui] = 0;
     }
-#if H_3D_ARP
-      m_puhARPW[ui] = 0;
+#if NH_3D_ARP
+    m_puhARPW[ui] = 0;
 #endif
 #if H_3D_IC
@@ -915,7 +912,5 @@
     memset( m_explicitRdpcmMode[comp],             NUMBER_OF_RDPCM_MODES, iSizeInUchar );
   }
-#if H_3D_ARP
-  memset( m_puhARPW,            0, iSizeInUchar  );
-#endif
+
 
   memset( m_puhDepth,     uiDepth, iSizeInUchar );
@@ -923,4 +918,7 @@
   memset( m_puhHeight,         uhHeight, iSizeInUchar );
   memset( m_pbIPCMFlag,        0, iSizeInBool  );
+#if NH_3D_ARP
+  memset( m_puhARPW,           0, iSizeInUchar  );
+#endif
 #if H_3D_IC
   memset( m_pbICFlag,          0, iSizeInBool  );
@@ -982,6 +980,6 @@
       m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
 #endif
-#if H_3D_ARP
-      m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
+#if NH_3D_ARP
+     m_puhARPW            [ui] = pcCU->getARPW( uiPartOffset + ui );
 #endif
 #if H_3D_IC
@@ -1089,5 +1087,5 @@
   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW             = pcCU->getARPW()             + uiPart;
 #endif
@@ -1249,5 +1247,5 @@
   m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
   m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
 #endif    
@@ -1343,4 +1341,7 @@
   memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
 #endif
+#if NH_3D_ARP
+  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
+#endif
 
   memcpy( m_puhDepth  + uiOffset, pcCU->getDepth(),  iSizeInUchar );
@@ -1383,7 +1384,5 @@
   }
 
-#if H_3D_ARP
-  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
-#endif
+
 #if H_3D_IC
   memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
@@ -1473,5 +1472,7 @@
   memcpy( pCtu->getDBBPFlag()          + m_absZIdxInCtu, m_pbDBBPFlag,          iSizeInBool  );
 #endif
-
+#if NH_3D_ARP
+  memcpy( pCtu->getARPW()              + m_absZIdxInCtu, m_puhARPW,             iSizeInUchar );
+#endif
   memcpy( pCtu->getDepth()  + m_absZIdxInCtu, m_puhDepth,  iSizeInUchar );
   memcpy( pCtu->getWidth()  + m_absZIdxInCtu, m_puhWidth,  iSizeInUchar );
@@ -1506,7 +1507,5 @@
   }
 
-#if H_3D_ARP
-  memcpy( rpcCU->getARPW()             + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
-#endif
+
 #if H_3D_IC
   memcpy( rpcCU->getICFlag()           + m_uiAbsIdxInLCU, m_pbICFlag,            iSizeInBool );
@@ -1544,7 +1543,4 @@
   memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
 #endif
-#endif
-#if H_3D_ARP
-  memcpy( rpcCU->getARPW()             + uiPartOffset, m_puhARPW,             iSizeInUchar );
 #endif
 #if H_3D_IC
@@ -2102,5 +2098,5 @@
   return uiCtx;
 }
-#if H_3D_ARP
+#if NH_3D_ARP
 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
 {
@@ -2109,7 +2105,7 @@
   UInt        uiCtx = 0;
   
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
   uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
-    return uiCtx;
+  return uiCtx;
 }
 #endif
@@ -3706,5 +3702,5 @@
   Bool bICFlag = getICFlag(uiAbsPartIdx);
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
 #endif
@@ -3744,5 +3740,5 @@
       && !bICFlag
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
       && !bARPFlag
 #endif
@@ -4192,5 +4188,5 @@
       !bICFlag &&
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
       !bARPFlag &&
 #endif
@@ -6131,5 +6127,10 @@
 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
 {
+#if BUF_FIX
+  UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
+  assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight());
+#else
   UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1);
+#endif
   for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
   {
@@ -6675,9 +6676,8 @@
 }
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
 {
-  assert( sizeof( *m_puhARPW) == 1 );
-  memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
+  setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 );
 }
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 1262)
@@ -50,7 +50,4 @@
 #include "TComPattern.h"
 
-#if H_3D_ARP
-#include "TComYuv.h"
-#endif
 #if H_3D
 #include <algorithm>
@@ -176,5 +173,5 @@
   Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP ///< 0: non-SPIVMP; 1: SPIVMP
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   UChar*        m_puhARPW;
 #endif
@@ -251,5 +248,5 @@
 
   /// compute scaling factor from POC difference
-#if !H_3D_ARP
+#if !NH_3D_ARP
   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
 #endif
@@ -268,5 +265,6 @@
   // create / destroy / initialize / copy
   // -------------------------------------------------------------------------------------------------------------------
-#if H_3D_ARP
+#if NH_3D_ARP
+  /// compute scaling factor from POC difference
   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
 #endif 
@@ -318,5 +316,8 @@
   Void          getPosInPic           ( UInt uiAbsPartIndex, Int& riPosX, Int& riPosY ) const;
 #endif
-
+#if NH_3D_ARP
+  Void          setSlice              ( TComSlice* pcSlice)     { m_pcSlice = pcSlice;       }
+  Void          setPic                ( TComDataCU* pcCU  )     { m_pcPic              = pcCU->getPic(); }
+#endif
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for CU data
@@ -531,10 +532,9 @@
     );   
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   UChar*        getARPW            ()                        { return m_puhARPW;               }
   UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
   Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
   Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
-  Double        getARPWFactor      ( UInt uiIdx );
 #endif
 #if H_3D_IC
@@ -710,5 +710,4 @@
   Bool          isIC      ( UInt uiPartIdx );
 #endif
-
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for symbol prediction (most probable / mode conversion)
@@ -729,5 +728,5 @@
   UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
   UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
-#if H_3D_ARP
+#if NH_3D_ARP
   UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
 #endif  
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1262)
@@ -75,5 +75,5 @@
 };
 
-#if H_3D_ARP
+#if NH_3D_ARP
 const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
 {
@@ -361,5 +361,5 @@
  */
 Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -372,19 +372,17 @@
   else if (isLuma(compID))
   {
-#if H_3D_ARP
+    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
     if(filterType)
     {
-      filterHor<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
+      filterHor<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
     }
     else
     {
 #endif
-
-    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
-    filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
-#if H_3D_ARP
-    }
-#endif
-
+      filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
+#if NH_3D_ARP
+    }
+#endif
   }
   else
@@ -392,5 +390,16 @@
     const UInt csx = getComponentScaleX(compID, fmt);
     assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
-    filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
+#if NH_3D_ARP
+    if(filterType)
+    {
+      filterHor<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
+    }
+    else
+    {
+#endif
+      filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
+#if NH_3D_ARP
+    }
+#endif
   }
 }
@@ -414,5 +423,5 @@
  */
 Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -425,18 +434,17 @@
   else if (isLuma(compID))
   {
-#if H_3D_ARP
+    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
     if(filterType)
     {
-      filterVer<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);    
+      filterVer<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);    
     }
     else
     {
 #endif
-    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
-#if H_3D_ARP
-    }
-#endif
-
+#if NH_3D_ARP
+    }
+#endif
   }
   else
@@ -444,39 +452,17 @@
     const UInt csy = getComponentScaleY(compID, fmt);
     assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
+    if(filterType)
+    {
+      filterVer<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);    
+    }
+    else
+    {
+#endif
     filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
-  }
-}
-
-#if H_3D_ARP
-    , Bool filterType
-#endif
-
-#if H_3D_ARP
-    if(filterType)
-    {
-      filterHor<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
-    }
-    else
-    {
-#endif
-#if H_3D_ARP
-    }
-#endif
-#if H_3D_ARP
-    , Bool filterType
-#endif
-#if H_3D_ARP
-    if(filterType)
-    {
-      filterVer<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);
-    }
-    else
-    {
-#endif
-#if H_3D_ARP
-    }
-#endif
-
-
-
+#if NH_3D_ARP
+    }
+#endif
+  }
+}
 //! \}
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1262)
@@ -45,5 +45,5 @@
 //! \{
 
-#if H_3D_ARP
+#if NH_3D_ARP
 #define NTAPS_LUMA_ARP    2 ///< Number of taps for luma
 #define NTAPS_CHROMA_ARP  2 ///< Number of taps for chroma
@@ -63,5 +63,5 @@
   static const TFilterCoeff m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];     ///< Luma filter taps
   static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps
-#if H_3D_ARP
+#if NH_3D_ARP
   static const Short m_lumaFilterARP  [4][NTAPS_LUMA_ARP];     ///< Luma filter taps for ARP
   static const Short m_chromaFilterARP[8][NTAPS_CHROMA_ARP];   ///< Chroma filter taps for ARP
@@ -83,10 +83,10 @@
 
   Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
 );
   Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
@@ -94,11 +94,4 @@
 };
 
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
-
 //! \}
 
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.cpp	(revision 1262)
@@ -143,4 +143,29 @@
 }
 #if NH_3D
+#if NH_3D_ARP
+Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
+{
+  Int iMaxCUWidth   = (Int) ( getPicSym()->getSPS().getMaxCUWidth()  );
+  Int iMaxCuHeight  = (Int) ( getPicSym()->getSPS().getMaxCUHeight() );
+
+  UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth(); 
+  Int iBaseUnitWidth  = iMaxCUWidth >> uiMaxTotalCUDepth;
+  Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth;
+
+  Int iNumCuInWidth   = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth;
+  iNumCuInWidth      += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0;
+
+
+  Int iCuX            = iX / iMaxCUWidth;
+  Int iCuY            = iY / iMaxCuHeight;
+  Int iBaseX          = ( iX - iCuX * iMaxCUWidth  ) / iBaseUnitWidth;
+  Int iBaseY          = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight;
+  Int iCuSizeInBases  = iMaxCuHeight                 / iBaseUnitWidth;
+
+  riCuAddr            = iCuY   * iNumCuInWidth + iCuX;
+  Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
+  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
+}
+#endif
 Void TComPic::compressMotion(Int scale)
 #else
@@ -283,5 +308,5 @@
   return getPicYuv( layerIdInNuh, poc, recon );
 }
-#if H_3D_ARP
+#if NH_3D_ARP
 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
 {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPic.h	(revision 1262)
@@ -182,4 +182,7 @@
 #endif
 #if NH_3D
+#if NH_3D_ARP
+  Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
+#endif
   Void          compressMotion(Int scale); 
 #else   
@@ -248,5 +251,5 @@
   Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
   Int         size     ()                           { return (Int) m_lists.size(); } 
-#if H_3D_ARP
+#if NH_3D_ARP
   TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1262)
@@ -306,17 +306,4 @@
   riY                 = iCuY * m_iCuHeight + iBaseY * m_iBaseUnitHeight; 
 }
-
-Void
-TComPicYuv::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
-{
-  Int iCuX            = iX / m_iCuWidth;
-  Int iCuY            = iY / m_iCuHeight;
-  Int iBaseX          = ( iX - iCuX * m_iCuWidth  ) / m_iBaseUnitWidth;
-  Int iBaseY          = ( iY - iCuY * m_iCuHeight ) / m_iBaseUnitHeight;
-  Int iCuSizeInBases  = m_iCuWidth                  / m_iBaseUnitWidth;
-  riCuAddr            = iCuY   * m_iNumCuInWidth + iCuX;
-  Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
-  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
-}
 #endif
 Void TComPicYuv::setLumaTo( Pel pVal )
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 1262)
@@ -167,9 +167,8 @@
   // Set Function 
   Void  setLumaTo    ( Pel pVal );  
-  Void  setChromaTo  ( Pel pVal );  
-#if H_3D_IV_MERGE
+  Void  setChromaTo  ( Pel pVal ); 
+#if H_3D_IV_MERGE 
   // sample to block and block to sample conversion
   Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
-  Void  getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
 #endif
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1262)
@@ -123,5 +123,5 @@
   m_cYuvPredTemp.destroy();
 
-#if H_3D_ARP
+#if NH_3D_ARP
   m_acYuvPredBase[0].destroy();
   m_acYuvPredBase[1].destroy();
@@ -182,7 +182,7 @@
 
     m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
-#if H_3D_ARP
-    m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
-    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+#if NH_3D_ARP
+    m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
+    m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
 #endif
 #if H_3D_VSP
@@ -648,5 +648,5 @@
       Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
       Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
-#if H_3D_ARP
+#if NH_3D_ARP
       if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
 #else
@@ -1389,25 +1389,23 @@
   pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
 #endif
-#if H_3D_ARP
-  if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
-  {
-    xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
+#if NH_3D_ARP
+  if(  pcCU->getARPW( uiPartAddr ) > 0 )
+  {
+    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
+    {
+      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi ); 
+    }
+    else
+    {
+      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
+    }      
   }
   else
   {
-    if(  pcCU->getARPW( uiPartAddr ) > 0 
-      && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N 
-      && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() 
-      )
-    {
-      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
-    }
-    else
-    {
 #endif
 #if H_3D_IC
       Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() );
       xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
-#if H_3D_ARP
+#if NH_3D_ARP
         , false
 #endif
@@ -1415,5 +1413,5 @@
       bICFlag = bICFlag && (iWidth > 8);
       xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
-#if H_3D_ARP
+#if NH_3D_ARP
         , false
 #endif
@@ -1427,6 +1425,5 @@
   }
 #endif
-#if H_3D_ARP
-    }
+#if NH_3D_ARP
   }
 #endif
@@ -1479,9 +1476,10 @@
 #endif
 
-#if H_3D_ARP
-Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
-{
-  Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
-  TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+#if NH_3D_ARP
+//temporal ARP
+Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
+{
+  Int         iRefIdx      = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
+  TComMv      cMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
   Bool        bTobeScaled  = false;
   TComPic* pcPicYuvBaseCol = NULL;
@@ -1497,43 +1495,40 @@
   UChar dW = pcCU->getARPW ( uiPartAddr );
 
-  {
-    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
-    if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
+  Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
+  if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
+  {
+    dW = 0;
+    bTobeScaled = false;
+  }
+  else
+  {
+    if( arpRefIdx != iRefIdx )
     {
       bTobeScaled = true;
     }
-
     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
-
     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
-
-    if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
-    {
-      dW = 0;
-      bTobeScaled = false;
-    }
-    else
-    {
-      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
-    }
-
-    if(bTobeScaled)
-    {     
-      Int iCurrPOC    = pcCU->getSlice()->getPOC();
-      Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
-      Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
-      Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
-      if ( iScale != 4096 )
-      {
-        cMv = cMv.scaleMv( iScale );
-      }
-      iRefIdx = 0;
-    }
+  }  
+  if(bTobeScaled)
+  {     
+    Int iCurrPOC    = pcCU->getSlice()->getPOC();
+    Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx   );
+    Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
+    Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
+    if ( iScale != 4096 )
+    {
+      cMv = cMv.scaleMv( iScale );
+    }
+    iRefIdx = arpRefIdx;
   }
 
   pcCU->clipMv(cMv);
   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
-  xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
-  xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
+
+  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
+  {
+    const ComponentID compID=ComponentID(comp);
+    xPredInterBlk  ( compID,  pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+  }
 
   if( dW > 0 )
@@ -1551,25 +1546,23 @@
     pcCU->clipMv( cNBDV );
     
-    pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
-    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
-    
-    pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
-    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
-  
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
-    
+    TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec();
+    TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec();
+
+    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
+    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
+    {
+      const ComponentID compID=ComponentID(comp);
+      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+    }    
+
     pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
-
     if( 2 == dW )
     {
       pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     }
-    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
-  }
-}
-
+    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
+  }
+}
 Bool TComPrediction::xCheckBiInterviewARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc )
 {
@@ -1577,6 +1570,4 @@
   TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx );  
-  TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();
-  Int uiLCUAddr,uiAbsPartAddr;
   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
@@ -1584,6 +1575,8 @@
   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
-  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
-  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+
+  Int uiLCUAddr,uiAbsPartAddr;
+  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
 
   TComPic* pcPicYuvBaseTRef = NULL;
@@ -1636,6 +1629,6 @@
   return false;
 }
-
-Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
+//inter-view ARP
+Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
 {
   Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
@@ -1650,17 +1643,7 @@
   Bool bTMVAvai = false;     
   TComMv cBaseTMV;
-  if( pNewMvFiled )
-  {
-    iRefIdx = pNewMvFiled->getRefIdx(); 
-    cDMv = pNewMvFiled->getMv();
-  }
+
   pcCU->clipMv(cTempDMv);
 
-  assert(dW > 0);
-  if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
-  {
-    dW = 0;
-  }
-  Int uiLCUAddr,uiAbsPartAddr;
   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
@@ -1668,6 +1651,8 @@
   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
-  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
-  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+  
+  Int uiLCUAddr,uiAbsPartAddr;
+  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
   if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
   {
@@ -1714,8 +1699,7 @@
       Int iCurrTRefPoc;
       bTMVAvai = ( eBaseList != eRefPicList ) && ( pcCU->getSlice()->getViewIndex() != pcCU->getSlice()->getRefPic( eOtherRefList, iOtherRefIdx )->getViewIndex() );
-
       if ( bTMVAvai )
       {
-        if( xCheckBiInterviewARP( pcCU, uiPartAddr, iWidth, iHeight, eBaseList, pcPicYuvCurrTRef, cBaseTMV, iCurrTRefPoc ) )
+        if( xCheckBiInterviewARP( pcCU, uiPartAddr, iWidth, iHeight, eBaseList, pcPicYuvCurrTRef, cBaseTMV, iCurrTRefPoc ) ) 
         {
           pcPicYuvBaseTRef = pcCU->getSlice()->getBaseViewRefPic( iCurrTRefPoc,  pcPicYuvBaseCol->getViewIndex() );
@@ -1740,5 +1724,5 @@
       RefPicList eRefPicListCurr = RefPicList(iList);
       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
-      if( iRef != -1)
+      if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex()))
       {
         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef);  
@@ -1774,9 +1758,13 @@
   }
 
-  xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
-  xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
-
-  if( dW > 0 && bTMVAvai ) 
-  {
+  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
+  {
+    const ComponentID compID=ComponentID(comp);
+    xPredInterBlk  ( compID,  pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai );
+  }
+
+  if( dW > 0 ) 
+  {
+    assert ( bTMVAvai );
     TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
     TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
@@ -1792,13 +1780,12 @@
       pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
     }
-    xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
-
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
-
-    xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true); 
-
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true); 
+
+    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
+    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
+    {
+      const ComponentID compID=ComponentID(comp);
+      xPredInterBlk  ( compID,  pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+      xPredInterBlk  ( compID,  pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+    }
 
     pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight );  
@@ -1807,5 +1794,5 @@
       pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     }
-    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); 
+    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() ); 
   }
 }
@@ -1907,5 +1894,5 @@
 
 Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -1951,8 +1938,8 @@
     m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP 
+#if NH_3D_ARP 
     , filterType
 #endif 
-);
+     );
   }
   else if ( xFrac == 0 )
@@ -1963,8 +1950,8 @@
     m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     , filterType
 #endif
-);
+    );
   }
   else
@@ -1976,8 +1963,8 @@
 
     m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth
-#if H_3D_ARP 
+#if N_3D_ARP 
     , filterType
 #endif 
-);
+    );
 #if H_3D_IC
     m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi || bICFlag
@@ -1985,8 +1972,8 @@
     m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     , filterType
 #endif 
-);
+    );
   }
 
@@ -2028,8 +2015,4 @@
 }
 
-
-#if H_3D_ARP
-    , Bool filterType
-#endif
 #if H_3D_IC
     , Bool bICFlag
@@ -2039,48 +2022,24 @@
 #else
 #endif
-#if H_3D_ARP
-    , filterType
-#endif
 #if H_3D_IC
     m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi || bICFlag
 #else
 #endif
-#if H_3D_ARP
-    , filterType
-#endif
 #if H_3D_IC
     m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
 #else
 #endif
-#if H_3D_ARP
-    , filterType
-#endif
 #if H_3D_IC
     m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi || bICFlag
 #else
-#endif
-#if H_3D_ARP
-    , filterType
-#endif
-#if H_3D_ARP
-    , filterType
-#endif  
+#endif 
 #if H_3D_IC
     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
 #else
 #endif
-#if H_3D_ARP
-    , filterType
-#endif 
-#if H_3D_ARP
-    , filterType
-#endif 
 #if H_3D_IC
     m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi || bICFlag
 #else
 #endif
-#if H_3D_ARP
-    , filterType
-#endif 
 #if H_3D_IC
   if( bICFlag )
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 1262)
@@ -44,5 +44,7 @@
 #include "TComInterpolationFilter.h"
 #include "TComWeightPrediction.h"
-
+#if NH_3D_ARP
+#include "TComPic.h"
+#endif
 // forward declaration
 class TComMv;
@@ -77,5 +79,5 @@
   TComYuv   m_acYuvPred[NUM_REF_PIC_LIST_01];
   TComYuv   m_cYuvPredTemp;
-#if H_3D_ARP
+#if NH_3D_ARP
   TComYuv   m_acYuvPredBase[2];
 #endif
@@ -100,8 +102,8 @@
 
   // motion compensation functions
-#if H_3D_ARP
-  Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false, TComMvField * pNewMvFiled = NULL );
-  Bool xCheckBiInterviewARP     ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc );
-  Void xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled = NULL );
+#if NH_3D_ARP
+  Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
+  Void xPredInterUniARPviewRef  ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
+  Bool xCheckBiInterviewARP     ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc ); 
 #endif
 
@@ -114,5 +116,5 @@
 
   Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
@@ -122,7 +124,5 @@
  );
 
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
+
 #if H_3D_IC
     , Bool bICFlag    = false
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 1262)
@@ -1996,5 +1996,5 @@
       m_dimensionId[i][j] = 0;
     }
-#if H_3D_ARP
+#if NH_3D_ARP
 #endif
   }  
@@ -3621,5 +3621,5 @@
 #endif
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
 {
@@ -3688,4 +3688,17 @@
           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
         }
+      }
+    }
+  }
+  if( m_nARPStepNum > 1)
+  {
+    for(Int i = 0; i < getNumActiveRefLayerPics(); i ++ )
+    {
+      Int  iLayerId = getRefPicLayerId( i );
+      Int  iViewIdx =   getVPS()->getViewIndex(iLayerId);
+      Bool bIsDepth = ( getVPS()->getDepthId  ( iLayerId ) == 1 );
+      if( iViewIdx<getViewIndex() && !bIsDepth )
+      {
+        setBaseViewRefPicList( ivPicLists->getPicList( iLayerId ), iViewIdx );
       }
     }
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 1262)
@@ -2594,5 +2594,5 @@
   Int        m_aiAlterRefIdx   [2]; 
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   Bool       m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
@@ -2718,5 +2718,5 @@
   Bool                        getIcSkipParseFlag()                                   { return m_icSkipParseFlag;                                     }
 #endif                                                                                                                                               
-#if H_3D_ARP                                                                                                                                         
+#if NH_3D_ARP                                                                                                                                         
   Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                  
   Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                              
@@ -2925,5 +2925,5 @@
   Int                         getAlterRefIdx          ( RefPicList e )               { return  m_aiAlterRefIdx[e];                                   }
 #endif                                                                                                                                               
-#if H_3D_ARP                                                                                                                                         
+#if NH_3D_ARP                                                                                                                                         
   Int                         getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];                                  }
   Void                        setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;                                   }
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp	(revision 1262)
@@ -487,24 +487,26 @@
 }
 
-#if H_3D_ARP
-Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
-{
-  addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip );
-  addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip );
-}
-
-Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
+#if NH_3D_ARP
+Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
+{
+  addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip , clipBitDepths);
+  addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip , clipBitDepths);
+}
+
+Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
 {
   Int x, y;
 
-  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
-  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-
-  UInt iSrc0Stride = pcYuvSrc0->getStride();
-  UInt iSrc1Stride = pcYuvSrc1->getStride();
-  UInt iDstStride  = getStride();
-  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
+  Pel* pSrc0 = pcYuvSrc0->getAddr( COMPONENT_Y, uiAbsPartIdx );
+  Pel* pSrc1 = pcYuvSrc1->getAddr( COMPONENT_Y, uiAbsPartIdx );
+  Pel* pDst  = getAddr( COMPONENT_Y, uiAbsPartIdx );
+
+  UInt iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
+  UInt iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
+  UInt iDstStride  = getStride(COMPONENT_Y);
+  const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_LUMA];
+  Int iIFshift = IF_INTERNAL_PREC - clipbd;
   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
+
   for ( y = uiHeight-1; y >= 0; y-- )
   {
@@ -514,5 +516,5 @@
       if( bClip )
       {
-        pDst[x] = ClipY( ( pDst[x] + iOffSet ) >> iIFshift );
+        pDst[x] = Pel(ClipBD<Int>(Int( ( pDst[x] + iOffSet ) >> iIFshift ), clipbd));
       }
     }
@@ -523,20 +525,25 @@
 }
 
-Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
+Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
 {
   Int x, y;
 
-  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
-  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
-  Pel* pDstU = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV = getCrAddr( uiAbsPartIdx );
-
-  UInt  iSrc0Stride = pcYuvSrc0->getCStride();
-  UInt  iSrc1Stride = pcYuvSrc1->getCStride();
-  UInt  iDstStride  = getCStride();
-
-  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
+  Pel* pSrcU0 = pcYuvSrc0->getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcU1 = pcYuvSrc1->getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcV0 = pcYuvSrc0->getAddr( COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pSrcV1 = pcYuvSrc1->getAddr( COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pDstU = getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV = getAddr( COMPONENT_Cr, uiAbsPartIdx );
+
+  UInt  iSrc0StrideCb = pcYuvSrc0->getStride(COMPONENT_Cb);
+  UInt  iSrc1StrideCb = pcYuvSrc1->getStride(COMPONENT_Cb);
+  UInt  iDstStrideCb  = getStride(COMPONENT_Cb);
+
+  UInt  iSrc0StrideCr = pcYuvSrc0->getStride(COMPONENT_Cr);
+  UInt  iSrc1StrideCr = pcYuvSrc1->getStride(COMPONENT_Cr);
+  UInt  iDstStrideCr  = getStride(COMPONENT_Cr);
+
+  const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_CHROMA];
+  Int iIFshift = IF_INTERNAL_PREC - clipbd;
   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
 
@@ -549,9 +556,72 @@
       if( bClip )
       {
-        pDstU[x] = ClipC( ( pDstU[x] + iOffSet ) >> iIFshift );
-        pDstV[x] = ClipC( ( pDstV[x] + iOffSet ) >> iIFshift );
-      }
-    }
-
+        pDstU[x] = Pel(ClipBD<Int>( Int( ( pDstU[x] + iOffSet ) >> iIFshift ), clipbd));
+        pDstV[x] = Pel(ClipBD<Int>( Int( ( pDstV[x] + iOffSet ) >> iIFshift ), clipbd));
+      }
+    }
+
+    pSrcU0 += iSrc0StrideCb;
+    pSrcU1 += iSrc1StrideCb;
+    pSrcV0 += iSrc0StrideCr;
+    pSrcV1 += iSrc1StrideCr;
+    pDstU  += iDstStrideCb;
+    pDstV  += iDstStrideCr;
+  }
+}
+
+Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
+
+  if (uiWidth > 8 && pcYuvSrc1->getNumberValidComponents() > 1)
+  {
+    subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
+  }
+}
+
+Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  Int x, y;
+
+  Pel* pSrc0 = pcYuvSrc0->getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Pel* pSrc1 = pcYuvSrc1->getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Pel* pDst  = getAddr           (COMPONENT_Y, uiAbsPartIdx );
+
+  Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
+  Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
+  Int  iDstStride  = getStride(COMPONENT_Y);
+  for ( y = uiHeight-1; y >= 0; y-- )
+  {
+    for ( x = uiWidth-1; x >= 0; x-- )
+    {
+      pDst[x] = pSrc0[x] - pSrc1[x];
+    }
+    pSrc0 += iSrc0Stride;
+    pSrc1 += iSrc1Stride;
+    pDst  += iDstStride;
+  }
+}
+
+Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  Int x, y;
+
+  Pel* pSrcU0 = pcYuvSrc0->getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcU1 = pcYuvSrc1->getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcV0 = pcYuvSrc0->getAddr(COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pSrcV1 = pcYuvSrc1->getAddr(COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pDstU  = getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV  = getAddr(COMPONENT_Cr, uiAbsPartIdx );
+
+  Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Cb);
+  Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Cb);
+  Int  iDstStride  = getStride( COMPONENT_Cb );
+  for ( y = uiHeight-1; y >= 0; y-- )
+  {
+    for ( x = uiWidth-1; x >= 0; x-- )
+    {
+      pDstU[x] = pSrcU0[x] - pSrcU1[x];
+      pDstV[x] = pSrcV0[x] - pSrcV1[x];
+    }
     pSrcU0 += iSrc0Stride;
     pSrcU1 += iSrc1Stride;
@@ -563,71 +633,12 @@
 }
 
-Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
-
-  if (uiWidth > 8)
-    subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
-}
-
-Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  Int x, y;
-
-  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
-  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-
-  Int  iSrc0Stride = pcYuvSrc0->getStride();
-  Int  iSrc1Stride = pcYuvSrc1->getStride();
-  Int  iDstStride  = getStride();
-  for ( y = uiHeight-1; y >= 0; y-- )
-  {
-    for ( x = uiWidth-1; x >= 0; x-- )
-    {
-      pDst[x] = pSrc0[x] - pSrc1[x];
-    }
-    pSrc0 += iSrc0Stride;
-    pSrc1 += iSrc1Stride;
-    pDst  += iDstStride;
-  }
-}
-
-Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  Int x, y;
-
-  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
-  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
-  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
-
-  Int  iSrc0Stride = pcYuvSrc0->getCStride();
-  Int  iSrc1Stride = pcYuvSrc1->getCStride();
-  Int  iDstStride  = getCStride();
-  for ( y = uiHeight-1; y >= 0; y-- )
-  {
-    for ( x = uiWidth-1; x >= 0; x-- )
-    {
-      pDstU[x] = pSrcU0[x] - pSrcU1[x];
-      pDstV[x] = pSrcV0[x] - pSrcV1[x];
-    }
-    pSrcU0 += iSrc0Stride;
-    pSrcU1 += iSrc1Stride;
-    pSrcV0 += iSrc0Stride;
-    pSrcV1 += iSrc1Stride;
-    pDstU  += iDstStride;
-    pDstV  += iDstStride;
-  }
-}
-
 Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
   multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW );
 
-  if (uiWidth > 8)
+  if ( uiWidth > 8 && getNumberValidComponents() > 1 )
+  {
     multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW );
+  }
 }
 
@@ -641,6 +652,6 @@
 Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-  Int  iDstStride  = getStride();
+  Pel* pDst  = getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Int  iDstStride  = getStride(COMPONENT_Y);
   for ( Int y = uiHeight-1; y >= 0; y-- )
   {
@@ -652,8 +663,8 @@
 Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
-  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
-
-  Int  iDstStride  = getCStride();
+  Pel* pDstU  = getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV  = getAddr( COMPONENT_Cr, uiAbsPartIdx );
+
+  Int  iDstStride  = getStride( COMPONENT_Cb );
   for ( Int y = uiHeight-1; y >= 0; y-- )
   {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TComYuv.h	(revision 1262)
@@ -206,8 +206,8 @@
 #if NH_3D
   Void         addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
-#if H_3D_ARP
-  Void         addARP                     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
-  Void         addARPLuma                 ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
-  Void         addARPChroma               ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
+#if NH_3D_ARP
+  Void         addARP                     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
+  Void         addARPLuma                 ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
+  Void         addARPChroma               ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
   Void         subtractARP                ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
   Void         subtractARPLuma            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 1262)
@@ -73,4 +73,18 @@
 
 #define NH_3D_DBBP                         1
+#define TEST 0
+#define BUF_FIX 1
+#define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
+                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
+                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
+                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
+                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
+                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
+                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
+                                              // QC_I0051_ARP_SIMP          
+                                              // SHARP_ARP_CHROMA_I0104     
+                                              // MTK_I0072_IVARP_SCALING_FIX
+                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
+                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
 #endif
 
@@ -101,16 +115,4 @@
                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
                                               // LGE_SIMP_DISP_AVAIL_J0041    // Use 2 status for disparity availability - DISP_AVAILABLE and DISP_NONE
-#define H_3D_ARP                          1   // Advanced residual prediction (ARP), JCT3V-D0177
-                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
-                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
-                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
-                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
-                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
-                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
-                                              // QC_I0051_ARP_SIMP          
-                                              // SHARP_ARP_CHROMA_I0104     
-                                              // MTK_I0072_IVARP_SCALING_FIX
-                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
-                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
 #define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
                                               // Unifying rounding offset, for IC part, JCT3V-D0135
@@ -297,5 +299,5 @@
 #endif
 ///// ***** ADVANCED INTERVIEW RESIDUAL PREDICTION *********
-#if H_3D_ARP
+#if NH_3D_ARP
 #define H_3D_ARP_WFNR                     3
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1262)
@@ -3376,5 +3376,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1262)
@@ -117,5 +117,5 @@
   Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex );
-#if H_3D_ARP 
+#if NH_3D_ARP 
   Void parseARPW            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1262)
@@ -293,9 +293,9 @@
 if(!pcCU->getSlice()->isIntra())
   {
-#if H_3D_ARP && H_3D_IV_MERGE
+#if NH_3D_ARP && H_3D_IV_MERGE
     if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() )
 #else 
-#if H_3D_ARP
-    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
+#if NH_3D_ARP
+    if( pcCU->getSlice()->getIvResPredFlag( ) )
 #else
 #if H_3D_IV_MERGE
@@ -399,5 +399,5 @@
     m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
     UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1262)
@@ -105,5 +105,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -297,5 +297,5 @@
   //decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
 
-#if H_3D_ARP
+#if NH_3D_ARP
   decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1262)
@@ -85,5 +85,5 @@
   virtual Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0;
   virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex ) = 0;
-#if H_3D_ARP
+#if NH_3D_ARP
   virtual Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
@@ -174,5 +174,5 @@
   Void decodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 
-#if H_3D_ARP
+#if NH_3D_ARP
   Void decodeARPW              ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1262)
@@ -73,6 +73,6 @@
 , m_cCUMergeFlagExtSCModel                   ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUMergeIdxExtSCModel                    ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_ARP
-, m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
+#if NH_3D_ARP
+, m_cCUPUARPWSCModel                         ( 1,             1,                             NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 #if H_3D_IC
@@ -164,6 +164,6 @@
   m_cCUMergeFlagExtSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
   m_cCUMergeIdxExtSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
-#if H_3D_ARP
-  m_cCUPUARPWSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_ARPW );
+#if NH_3D_ARP
+  m_cCUPUARPWSCModel.initBuffer                   ( sliceType, qp, (UChar*)INIT_ARPW );
 #endif
 #if H_3D_IC
@@ -240,7 +240,4 @@
   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 );
 #endif
 #if H_3D_IC
@@ -2417,20 +2414,17 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
-  UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1;
   UInt uiW = 0;
   UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
   UInt uiCode = 0;
 
-  assert ( uiMaxW > 0 );
-
-  m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) );
+  m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
 
   uiW = uiCode;
   if( 1 == uiW )   
   {
-    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
+    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
     uiW += ( 1 == uiCode ? 1 : 0 );
   }
@@ -2438,4 +2432,5 @@
   DTRACE_CU("iv_res_pred_weight_idx", uiW )
 #endif
+  
   pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth );  
 }
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecSbac.h	(revision 1262)
@@ -139,5 +139,5 @@
   Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -190,5 +190,5 @@
   ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
   ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
-#if H_3D_ARP
+#if NH_3D_ARP
   ContextModel3DBuffer m_cCUPUARPWSCModel;
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1262)
@@ -1145,19 +1145,6 @@
     pcSlice->setDefaultRefView();
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     pcSlice->setARPStepNum(m_ivPicLists);
-    if( pcSlice->getARPStepNum() > 1 )
-    {
-      // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
-      for(Int iLayerId = 0; iLayerId < nalu.m_nuhLayerId; iLayerId ++ )
-      {
-        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
-        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
-        if( iViewIdx<getViewIndex() && !bIsDepth )
-        {
-          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
-        }
-      }
-    }
 #endif
 #else
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1262)
@@ -2578,5 +2578,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1262)
@@ -126,5 +126,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1262)
@@ -68,5 +68,5 @@
   m_ppcTempCU      = new TComDataCU*[m_uhTotalDepth-1];
 
-#if H_3D_ARP
+#if NH_3D_ARP
   m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1];
 #endif 
@@ -92,6 +92,6 @@
     m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
     m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
-#if H_3D_ARP
-    m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
+#if NH_3D_ARP
+    m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
 #endif  
 
@@ -146,5 +146,5 @@
       m_ppcTempCU[i]->destroy();      delete m_ppcTempCU[i];      m_ppcTempCU[i] = NULL;
     }
-#if H_3D_ARP
+#if NH_3D_ARP
     if(m_ppcWeightedTempCU[i])
     {
@@ -198,5 +198,5 @@
   }
 
-#if H_3D_ARP
+#if NH_3D_ARP
   if(m_ppcWeightedTempCU)
   {
@@ -279,4 +279,8 @@
   m_ppcBestCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
   m_ppcTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
+
+#if NH_3D_ARP
+  m_ppcWeightedTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
+#endif
 
 #if KWU_RC_MADPRED_E0227
@@ -587,9 +591,9 @@
       if( rpcTempCU->getSlice()->getSliceType() != I_SLICE )
       {
-#if H_3D_ARP && H_3D_IV_MERGE
+#if NH_3D_ARP && H_3D_IV_MERGE
         if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() )
 #else 
-#if H_3D_ARP
-        if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) )
+#if NH_3D_ARP
+        if( rpcTempCU->getSlice()->getIvResPredFlag() )
 #else
 #if H_3D_IV_MERGE
@@ -1272,5 +1276,8 @@
       TComDataCU* pcSubTempPartCU     = m_ppcTempCU[uhNextDepth];
       DEBUG_STRING_NEW(sTempDebug)
-
+#if NH_3D_ARP
+      m_ppcWeightedTempCU[uhNextDepth]->setSlice( m_ppcWeightedTempCU[ uiDepth]->getSlice()); 
+      m_ppcWeightedTempCU[uhNextDepth]->setPic  ( m_ppcWeightedTempCU[ uiDepth] ); 
+#endif
       for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
       {
@@ -1578,5 +1585,5 @@
 
     m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
@@ -1621,5 +1628,5 @@
   m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx, false );
 #endif  
-#if H_3D_ARP
+#if NH_3D_ARP
   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
@@ -1795,5 +1802,5 @@
 #endif
 
-#if H_3D_ARP
+#if NH_3D_ARP
   DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
 #else
@@ -1802,5 +1809,5 @@
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
 #if H_3D_VSP
-#if !H_3D_ARP
+#if !NH_3D_ARP
   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
@@ -1832,10 +1839,6 @@
   Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
 #endif
-#if H_3D_ARP
-for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
-#else
+
   for( UInt ui = 0; ui < numValidMergeCand; ++ui )
-#endif
-
   {
     mergeCandBuffer[ui] = 0;
@@ -1855,20 +1858,28 @@
   DEBUG_STRING_NEW(bestStr)
 
-#if H_3D_ARP
+#if NH_3D_ARP
   Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1;
+#if H_3D_IC
   if( nARPWMax < 0 || bICFlag )
+#else
+  if( nARPWMax < 0 )
+#endif
   {
     nARPWMax = 0;
   }
-  for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
-  {
-    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
-    rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
-    rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+  for( Int nARPW = nARPWMax; nARPW >= 0 ; nARPW-- )
+  {
+#if NH_3D_IV_MERGE
+    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM * sizeof(Int) );    
+#else
+    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS * sizeof(Int) );
+#endif
+    rpcTempCU->setPartSizeSubParts(   SIZE_2Nx2N , 0 , uhDepth ); // interprets depth relative to LCU level
+    rpcTempCU->setARPWSubParts    ( (UChar)nARPW , 0 , uhDepth );
 #if H_3D_IC
     rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
 #endif
     rpcTempCU->getDvInfo(0) = cOrigDisInfo;
-    rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth );
+    rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, uhDepth );
     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
@@ -1897,7 +1908,6 @@
       , numValidMergeCand 
       );
-
-#else
-    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, numValidMergeCand );
+#else
+    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
 #endif
 
@@ -1929,7 +1939,4 @@
           rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
 #endif
-#if H_3D_ARP
-          rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-#endif
           rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth );
           rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
@@ -1937,4 +1944,7 @@
           rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to CTU level
           rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to CTU level
+#if NH_3D_ARP
+          rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#endif
 #if H_3D_VSP
           rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
@@ -2112,5 +2122,4 @@
 
           rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
-
           if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
           {
@@ -2167,5 +2176,5 @@
  delete[] puhInterDirSP;
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
  }
 #endif
@@ -2187,5 +2196,5 @@
 
   // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D
+#if H_3D || NH_3D_ARP
   const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
 #endif
@@ -2195,8 +2204,12 @@
 #endif
   UChar uhDepth = rpcTempCU->getDepth( 0 );
-#if H_3D_ARP
+#if NH_3D_ARP
     Bool bFirstTime = true;
     Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
+#if H_3D_IC
     if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) )
+#else
+    if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N )
+#endif
     {
       nARPWMax = 0;
@@ -2226,18 +2239,18 @@
   rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
   rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
-#if H_3D_ARP
-      rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-#endif
-#if H_3D_ARP
-      if( bFirstTime == false && nARPWMax )
-      {
-        rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
-        rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-
-        m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
-      }
-      else
-      {
-        bFirstTime = false;
+#if NH_3D_ARP
+  rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#endif
+#if NH_3D_ARP
+  if( bFirstTime == false && nARPWMax )
+  {
+    rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
+    rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+
+    m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
+  }
+  else
+  {
+    bFirstTime = false;
 #endif
 #if AMP_MRG
@@ -2252,10 +2265,10 @@
   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
 #endif
-#if H_3D_ARP
-        if( nARPWMax )
-        {
-          m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
-        }
-      }
+#if NH_3D_ARP
+  if( nARPWMax )
+  {
+    m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
+  }
+  }
 #endif
 
@@ -2263,10 +2276,10 @@
   if ( !rpcTempCU->getMergeAMP() )
   {
-#if H_3D_ARP
-        if( nARPWMax )
-        {
-          continue;
-        }
-        else
+#if NH_3D_ARP
+    if( nARPWMax )
+    {
+      continue;
+    }
+    else
 #endif
     return;
@@ -2380,5 +2393,5 @@
       }
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     }
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncCu.h	(revision 1262)
@@ -69,5 +69,5 @@
   TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
   TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
-#if H_3D_ARP
+#if NH_3D_ARP
   TComDataCU**            m_ppcWeightedTempCU;
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1262)
@@ -184,5 +184,5 @@
 #endif
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1262)
@@ -84,5 +84,5 @@
   virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
-#if H_3D_ARP
+#if NH_3D_ARP
   virtual Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
@@ -173,5 +173,5 @@
   Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void encodeARPW         ( TComDataCU* pcCU, UInt uiAbspartIdx );
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1262)
@@ -1474,19 +1474,7 @@
     pcSlice->setDefaultRefView();
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
     pcSlice->setARPStepNum(m_ivPicLists);
-    if(pcSlice->getARPStepNum() > 1)
-    {
-      for(Int iLayerId = 0; iLayerId < getLayerId(); iLayerId ++ )
-      {
-        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
-        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
-        if( iViewIdx<getViewIndex() && !bIsDepth )
-        {
-          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
-        }
-      }
-    }
 #endif
 #if H_3D_IC
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1262)
@@ -68,5 +68,5 @@
 , m_cCUMergeFlagExtSCModel             ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUMergeIdxExtSCModel              ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_ARP
+#if NH_3D_ARP
 , m_cCUPUARPWSCModel                   ( 1,             1,                      NUM_ARPW_CTX                         , m_contextModels + m_numContextModels, m_numContextModels)
 #endif                                                                                                               
@@ -148,5 +148,5 @@
   m_cCUMergeFlagExtSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
   m_cCUMergeIdxExtSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
-#if H_3D_ARP
+#if NH_3D_ARP
   m_cCUPUARPWSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_ARPW );
 #endif
@@ -235,5 +235,5 @@
       curCost += m_cCUMergeFlagExtSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
       curCost += m_cCUMergeIdxExtSCModel.calcCost              ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
-#if H_3D_ARP
+#if NH_3D_ARP
       curCost += m_cCUPUARPWSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_ARPW );
 #endif                                                     
@@ -302,7 +302,4 @@
   m_cCUDISTypeSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
 #endif
-#if H_3D_ARP
-  m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
-#endif
 #if H_3D_IC
   m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
@@ -971,5 +968,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncSbac::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSbac.h	(revision 1262)
@@ -140,5 +140,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
@@ -212,5 +212,5 @@
   ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
   ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
-#if H_3D_ARP
+#if NH_3D_ARP
   ContextModel3DBuffer m_cCUPUARPWSCModel;
 #endif
Index: branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1246)
+++ branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1262)
@@ -5007,10 +5007,14 @@
   if ( pcCU->getSlice()->testWeightPred() && pcCU->getSlice()->getSliceType()==P_SLICE )
   {
-    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
+    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) 
+#if NH_3D_ARP
+      , false //add this for IC, otherwise, it could be removed
+#endif
+      );
   }
   else
   {
     xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) 
-#if H_3D_ARP
+#if NH_3D_ARP
       , false
 #endif
@@ -5781,5 +5785,5 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
 #endif
@@ -7097,5 +7101,5 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
 #endif
@@ -7124,5 +7128,5 @@
     m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , 0  );
 #endif
