Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/ContextTables.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/ContextTables.h	(revision 373)
@@ -487,4 +487,14 @@
 #endif
 };
+#if QC_ARP_D0177
+#define NUM_ARPW_CTX                  4       ///< number of context models for generalized residual prediction weighting factor
+static const UChar 
+INIT_ARPW[3][NUM_ARPW_CTX] = 
+{
+  { 154 , 154 , 154 , 154 }, 
+  { 154 , 154 , 154 , 154 }, 
+  { 154 , 154 , 154 , 154 }, 
+};
+#endif
 
 #if LGE_EDGE_INTRA_A0070
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 373)
@@ -225,4 +225,7 @@
   m_pbResPredFlag      = NULL;
 #endif
+#if QC_ARP_D0177
+  m_puhARPW           = NULL;
+#endif
 #if LGE_EDGE_INTRA_A0070
   m_pucEdgeCode         = NULL;
@@ -301,4 +304,7 @@
     m_pbResPredAvailable = (Bool*  )xMalloc(Bool,   uiNumPartition);
     m_pbResPredFlag      = (Bool*  )xMalloc(Bool,   uiNumPartition);
+#if QC_ARP_D0177
+    m_puhARPW            = new UChar[ uiNumPartition];
+#endif
 #endif
     m_puhLumaIntraDir    = (UChar* )xMalloc(UChar,  uiNumPartition);
@@ -463,4 +469,7 @@
     if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
 #endif
+#if QC_ARP_D0177
+    if ( m_puhARPW           )  { delete[] m_puhARPW;          m_puhARPW          = NULL; }
+#endif
     if ( m_puhLumaIntraDir    ) { xFree(m_puhLumaIntraDir);     m_puhLumaIntraDir   = NULL; }
     if ( m_puhChromaIntraDir  ) { xFree(m_puhChromaIntraDir);   m_puhChromaIntraDir = NULL; }
@@ -636,4 +645,7 @@
     m_pbSDCFlag[ui] = pcFrom->getSDCFlag(ui);
 #endif
+#if QC_ARP_D0177
+    m_puhARPW[ui] = pcFrom->getARPW( ui );
+#endif
     m_puhWidth  [ui] = pcFrom->getWidth(ui);
     m_puhHeight [ui] = pcFrom->getHeight(ui);
@@ -733,4 +745,7 @@
     memset( m_pbResPredFlag            + firstElement, 0    , sizeof( Bool ) * numElements );
 #endif
+#if QC_ARP_D0177
+    memset( m_puhARPW                  + firstElement, 0    , sizeof( UChar ) * numElements  );
+#endif
   }
   
@@ -875,4 +890,7 @@
       m_pbResPredFlag[ui]      = 0;
 #endif
+#if QC_ARP_D0177
+      m_puhARPW[ui] = 0;
+#endif
       m_puhLumaIntraDir[ui] = 2;
       m_puhChromaIntraDir[ui] = 0;
@@ -985,4 +1003,7 @@
   memset( m_pbResPredAvailable, 0, iSizeInBool  );
   memset( m_pbResPredFlag,      0, iSizeInBool  );
+#endif
+#if QC_ARP_D0177
+  memset( m_puhARPW,            0, iSizeInUchar  );
 #endif
   memset( m_puhLumaIntraDir,    2, iSizeInUchar );
@@ -1102,4 +1123,7 @@
       m_pbResPredFlag     [ui] = pcCU->m_pbResPredFlag     [ uiPartOffset + ui ];
 #endif
+#if QC_ARP_D0177
+      m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
+#endif
 #if RWTH_SDC_DLT_B0036
       m_pbSDCFlag         [ui] = pcCU->m_pbSDCFlag         [ uiPartOffset + ui ];
@@ -1224,4 +1248,7 @@
   m_pbResPredFlag       = pcCU->getResPredFlag ()     + uiPart;
 #endif
+#if QC_ARP_D0177
+  m_puhARPW             = pcCU->getARPW() + uiPart;
+#endif
   m_puhLumaIntraDir     = pcCU->getLumaIntraDir()     + uiPart;
   m_puhChromaIntraDir   = pcCU->getChromaIntraDir()   + uiPart;
@@ -1392,4 +1419,7 @@
   m_pbResPredFlag      = pcCU->getResPredFlag ()          + uiAbsPartIdx;
 #endif
+#if QC_ARP_D0177
+  m_puhARPW           = pcCU->getARPW()                 + uiAbsPartIdx;
+#endif
   m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
   m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
@@ -1409,5 +1439,10 @@
 // Copy small CU to bigger CU.
 // One of quarter parts overwritten by predicted sub part.
-Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth )
+Void TComDataCU::copyPartFrom( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth 
+#if QC_ARP_D0177
+     ,
+    Bool bRP
+#endif
+    )
 {
   assert( uiPartUnitIdx<4 );
@@ -1446,4 +1481,7 @@
   memcpy( m_pbResPredFlag       + uiOffset, pcCU->getResPredFlag(),       iSizeInBool  );
 #endif
+#if QC_ARP_D0177
+  memcpy( m_puhARPW            + uiOffset,  pcCU->getARPW(),              iSizeInUchar );
+#endif
   memcpy( m_puhLumaIntraDir     + uiOffset, pcCU->getLumaIntraDir(),      iSizeInUchar );
   memcpy( m_puhChromaIntraDir   + uiOffset, pcCU->getChromaIntraDir(),    iSizeInUchar );
@@ -1522,5 +1560,9 @@
 
 #if LGE_EDGE_INTRA_A0070
+#if QC_ARP_D0177
+  if( !bRP && pcCU->getSlice()->getSPS()->isDepth() )
+#else
   if( getSlice()->getSPS()->isDepth() )
+#endif
   {
     memcpy( getEdgeCode( uiOffset ), pcCU->getEdgeCode(0), iSizeInUchar * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
@@ -1588,4 +1630,7 @@
   memcpy( rpcCU->getResPredFlag()       + m_uiAbsIdxInLCU, m_pbResPredFlag,       iSizeInBool  );
 #endif
+#if QC_ARP_D0177
+  memcpy( rpcCU->getARPW()              + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
+#endif
   memcpy( rpcCU->getLumaIntraDir()      + m_uiAbsIdxInLCU, m_puhLumaIntraDir,     iSizeInUchar );
   memcpy( rpcCU->getChromaIntraDir()    + m_uiAbsIdxInLCU, m_puhChromaIntraDir,   iSizeInUchar );
@@ -1718,4 +1763,7 @@
   memcpy( rpcCU->getResPredAvail()      + uiPartOffset, m_pbResPredAvailable,  iSizeInBool  );
   memcpy( rpcCU->getResPredFlag()       + uiPartOffset, m_pbResPredFlag,       iSizeInBool  );
+#endif
+#if QC_ARP_D0177
+  memcpy( rpcCU->getARPW()              + uiPartOffset, m_puhARPW,            iSizeInUchar );
 #endif
   memcpy( rpcCU->getLumaIntraDir()      + uiPartOffset, m_puhLumaIntraDir,     iSizeInUchar );
@@ -2709,5 +2757,20 @@
   return uiCtx;
 }
-
+#if QC_ARP_D0177
+UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
+{
+  TComDataCU* pcTempCU;
+  UInt        uiTempPartIdx;
+  UInt        uiCtx = 0;
+  
+  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
+  
+  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx   += ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1): 0;
+  
+  return uiCtx;
+}
+#endif
 #if LGE_ILLUCOMP_B0045
 UInt TComDataCU::getCtxICFlag( UInt uiAbsPartIdx )
@@ -3632,5 +3695,5 @@
 #endif //H3D_NBDV
 
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   Bool bDVAvail = true;
 #endif
@@ -3689,5 +3752,5 @@
     cDisInfo.m_aVIdxCan[0] = 0;
 #endif
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
     bDVAvail = false;
 #endif
@@ -3752,5 +3815,5 @@
   iPdmDir[1] = iPdmInterDir; 
 #endif // H3D_NBDV
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   if (m_pcSlice->getSPS()->getMultiviewResPredMode()==1 && iPdmDir[0] && !bNoPdmMerge && cCurPS == SIZE_2Nx2N && bDVAvail)
   {
@@ -7278,6 +7341,9 @@
 TComDataCU::getResidualSamples( UInt uiPartIdx, Bool bRecon, TComYuv* pcYuv )
 {
+#if !QC_ARP_D0177
   TComResidualGenerator*  pcResidualGenerator = m_pcSlice->getSPS()->getResidualGenerator();
   ROFRS( pcResidualGenerator, false );
+#endif
+
 #if H3D_NBDV
   DisInfo cDisInfo;
@@ -7308,5 +7374,4 @@
 #if !QC_CU_NBDV_D0181
   getDisMvpCandNBDV( 0, 0,  &cDisInfo, false );  
-
   if( cDisInfo.iN == 0)
 #else
@@ -7326,4 +7391,13 @@
   }
   else
+#if QC_ARP_D0177
+  if(m_pcSlice->getSPS()->getUseAdvRP())  
+  {
+     m_pePartSize[0] = m_peSaved;
+     return true;
+  }
+  else
+    return false;
+#else
   {
     Bool bAvailable = pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, cDisInfo.m_acMvCand[0], bRecon );       
@@ -7331,4 +7405,5 @@
     return bAvailable;
   }
+#endif
 #else
   return pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, bRecon ); 
@@ -7336,5 +7411,11 @@
 }
 #endif
-
+#if QC_ARP_D0177
+Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( sizeof( *m_puhARPW) == 1 );
+  memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
+}
+#endif
 #if LGE_EDGE_INTRA_A0070
 Void TComDataCU::reconPartition( UInt uiAbsPartIdx, UInt uiDepth, Bool bLeft, UChar ucStartPos, UChar ucNumEdge, UChar* pucEdgeCode, Bool* pbRegion )
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 373)
@@ -214,5 +214,7 @@
   Bool*         m_pbResPredFlag;      ///< array of residual prediction flags
 #endif
-
+#if QC_ARP_D0177
+  UChar*        m_puhARPW;
+#endif
 #if LGE_EDGE_INTRA_A0070
   UChar*        m_pucEdgeCode;          ///< array of edge code
@@ -301,6 +303,7 @@
   
   /// compute scaling factor from POC difference
+#if !QC_ARP_D0177
   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
-  
+#endif
   Void xDeriveCenterIdx( PartSize eCUMode, UInt uiPartIdx, UInt& ruiPartIdxCenter );
   Bool xGetCenterCol( UInt uiPartIdx, RefPicList eRefPicList, int iRefIdx, TComMv *pcMv );
@@ -316,5 +319,8 @@
   // create / destroy / initialize / copy
   // -------------------------------------------------------------------------------------------------------------------
-  
+#if QC_ARP_D0177
+  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
+#endif  
+
   Void          create                ( UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
 #if ADAPTIVE_QP_SELECTION
@@ -337,5 +343,10 @@
 #endif
   );
-  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
+  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth 
+#if QC_ARP_D0177
+      ,
+      Bool bRP = false
+#endif
+  );
   
   Void          copyToPic             ( UChar uiDepth );
@@ -585,4 +596,11 @@
   Bool          getResidualSamples( UInt uiPartIdx, Bool bRecon, TComYuv* pcYuv = 0 );
 #endif
+#if QC_ARP_D0177
+  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
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for accessing partition information
@@ -705,5 +723,7 @@
   UInt          getCtxResPredFlag               ( UInt   uiAbsPartIdx                                 );
 #endif
-  
+#if QC_ARP_D0177
+  UInt          getCTXARPWFlag                 ( UInt   uiAbsPartIdx                                 );
+#endif  
   UInt          getSliceStartCU         ( UInt pos )                  { return m_uiSliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
   UInt          getEntropySliceStartCU  ( UInt pos )                  { return m_uiEntropySliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                   }
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 373)
@@ -80,5 +80,5 @@
 
   UInt      getPdm  ()                            { if( m_aacActiveSPS[0][1] ) { return m_aacActiveSPS[0][1]->getPredDepthMapGeneration(); } return 0; }
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   UInt      getResPrd ()                          { if( m_aacActiveSPS[0][1] ) { return m_aacActiveSPS[0][1]->getMultiviewResPredMode  (); } return 0; }
 #endif
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 373)
@@ -72,5 +72,24 @@
   { -2, 10, 58, -2 }
 };
-
+#if QC_ARP_D0177
+const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
+{
+  {64,  0},
+  {48, 16},
+  {32, 32},
+  {16, 48}
+};
+const Short TComInterpolationFilter::m_chromaFilterARP[8][NTAPS_CHROMA_ARP] =
+{
+  {64,  0},
+  {56,  8},
+  {48, 16},
+  {40, 24},
+  {32, 32},
+  {24, 40},
+  {16, 48},
+  {8,  56}
+};
+#endif
 // ====================================================================================================================
 // Private member functions
@@ -320,5 +339,10 @@
  * \param  isLast     Flag indicating whether it is the last filtering operation
  */
-Void TComInterpolationFilter::filterHorLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast )
+Void TComInterpolationFilter::filterHorLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast 
+#if QC_ARP_D0177
+    ,
+    Bool filterType
+#endif
+    )
 {
   assert(frac >= 0 && frac < 4);
@@ -330,5 +354,10 @@
   else
   {
-    filterHor<NTAPS_LUMA>(src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
+#if QC_ARP_D0177
+    if(filterType)
+      filterHor<NTAPS_LUMA_ARP>(src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
+    else
+#endif
+      filterHor<NTAPS_LUMA>(src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
   }
 }
@@ -347,5 +376,10 @@
  * \param  isLast     Flag indicating whether it is the last filtering operation
  */
-Void TComInterpolationFilter::filterVerLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast )
+Void TComInterpolationFilter::filterVerLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType
+#endif
+    )
 {
   assert(frac >= 0 && frac < 4);
@@ -357,5 +391,10 @@
   else
   {
-    filterVer<NTAPS_LUMA>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);    
+#if QC_ARP_D0177
+    if(filterType)
+      filterVer<NTAPS_LUMA_ARP>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);    
+    else
+#endif
+      filterVer<NTAPS_LUMA>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);    
   }
 }
@@ -373,5 +412,10 @@
  * \param  isLast     Flag indicating whether it is the last filtering operation
  */
-Void TComInterpolationFilter::filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast )
+Void TComInterpolationFilter::filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType
+#endif
+    )
 {
   assert(frac >= 0 && frac < 8);
@@ -383,4 +427,9 @@
   else
   {
+#if QC_ARP_D0177
+    if(filterType)
+      filterHor<NTAPS_CHROMA_ARP>(src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);   
+    else
+#endif
     filterHor<NTAPS_CHROMA>(src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac]);
   }
@@ -400,5 +449,10 @@
  * \param  isLast     Flag indicating whether it is the last filtering operation
  */
-Void TComInterpolationFilter::filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast )
+Void TComInterpolationFilter::filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType
+#endif
+    )
 {
   assert(frac >= 0 && frac < 8);
@@ -410,5 +464,10 @@
   else
   {
-    filterVer<NTAPS_CHROMA>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);    
+#if QC_ARP_D0177
+    if(filterType)
+      filterVer<NTAPS_CHROMA_ARP>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);  
+    else
+#endif
+      filterVer<NTAPS_CHROMA>(src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);    
   }
 }
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 373)
@@ -44,4 +44,8 @@
 //! \ingroup TLibCommon
 //! \{
+#if QC_ARP_D0177
+#define NTAPS_LUMA_ARP    2 ///< Number of taps for luma
+#define NTAPS_CHROMA_ARP  2 ///< Number of taps for chroma
+#endif
 
 #define NTAPS_LUMA        8 ///< Number of taps for luma
@@ -58,5 +62,9 @@
   static const Short m_lumaFilter[4][NTAPS_LUMA];     ///< Luma filter taps
   static const Short m_chromaFilter[8][NTAPS_CHROMA]; ///< Chroma filter taps
-  
+#if QC_ARP_D0177
+  static const Short m_lumaFilterARP  [4][NTAPS_LUMA_ARP];     ///< Luma filter taps
+  static const Short m_chromaFilterARP[8][NTAPS_CHROMA_ARP]; ///< Chroma filter taps
+#endif
+
   static Void filterCopy(const Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast);
   
@@ -73,8 +81,28 @@
   ~TComInterpolationFilter() {}
 
-  Void filterHorLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast );
-  Void filterVerLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast );
-  Void filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast );
-  Void filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast );
+  Void filterHorLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType = 0
+#endif
+    );
+  Void filterVerLuma  (Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast 
+#if QC_ARP_D0177
+    ,
+    Bool filterType = 0
+#endif
+    );
+  Void filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType = 0
+#endif
+    );
+  Void filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
+#if QC_ARP_D0177
+    ,
+    Bool filterType = 0
+#endif
+    );
 };
 
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 373)
@@ -488,4 +488,11 @@
   }
 }
-
+#if QC_ARP_D0177
+Void  TComPicYuv::clearPic()
+{
+  ::memset ( m_apiPicBufY, 0 , sizeof (Pel) * ( m_iPicWidth       + (m_iLumaMarginX   << 1)) * ( m_iPicHeight       + (m_iLumaMarginY   << 1)) );
+  ::memset ( m_apiPicBufU, 0 , sizeof (Pel) * ((m_iPicWidth >> 1) + (m_iChromaMarginX << 1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY << 1)) );
+  ::memset ( m_apiPicBufV, 0 , sizeof (Pel) * ((m_iPicWidth >> 1) + (m_iChromaMarginX << 1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY << 1)) );
+}
+#endif
 //! \}
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 373)
@@ -183,5 +183,7 @@
   Void  setLumaTo    ( Pel pVal );  
   Void  setChromaTo  ( Pel pVal );  
-
+#if QC_ARP_D0177
+  Void    clearPic();
+#endif
 };// END CLASS DEFINITION TComPicYuv
 
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 373)
@@ -78,5 +78,10 @@
 
   m_cYuvPredTemp.destroy();
-
+#if QC_ARP_D0177
+  m_acYuvPredBase[0].destroy();
+  m_acYuvPredBase[1].destroy();
+  m_acYuvDiff[0].destroy();
+  m_acYuvDiff[1].destroy();
+#endif
   if( m_pLumaRecBuffer )
   {
@@ -119,4 +124,10 @@
 
     m_cYuvPredTemp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+#if QC_ARP_D0177
+    m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+    m_acYuvDiff    [0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+    m_acYuvDiff    [1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+#endif
   }
 
@@ -751,5 +762,5 @@
 }
 
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
 Void TComPrediction::residualPrediction(TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred)
 {
@@ -810,5 +821,18 @@
   }
 #endif
-
+#if QC_ARP_D0177
+  if( pcCU->getSlice()->getSPS()->isDepth() == false
+    && pcCU->getSlice()->getSPS()->getViewId() > 0
+    && pcCU->getSlice()->getSPS()->getUseAdvRP() > 0
+    && pcCU->getARPW( uiPartAddr ) > 0 
+    && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC()
+    && (pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N || pcCU->isSkipped(uiPartAddr))
+    )
+  {
+    xPredInterUniARP( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , iPartIdx , bi );
+  }
+  else
+  {
+#endif
 #if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
   if( pcCU->getSlice()->getSPS()->isDepth() )
@@ -911,6 +935,124 @@
    }
 #endif
-}
-
+#if QC_ARP_D0177
+  }
+#endif
+}
+
+#if QC_ARP_D0177
+Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi, TComMvField * pNewMvFiled )
+{
+  Int         iRefIdx     = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
+  TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  Bool        bTobeScaled = false;
+  UChar dW = pcCU->getARPW ( uiPartAddr );
+  TComPic* pcPicYuvBaseCol =  NULL;
+  TComPic* pcPicYuvBaseRef =  NULL;
+  DisInfo cDistparity;
+
+  if( pNewMvFiled )
+  {
+    iRefIdx = pNewMvFiled->getRefIdx(); 
+    cMv = pNewMvFiled->getMv();
+  }
+
+#if QC_CU_NBDV_D0181
+  cDistparity.bDV           = pcCU->getDvInfo(uiPartAddr).bDV;
+  if( cDistparity.bDV )
+  {
+#if MERL_VSP_C0152
+    cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCandNoRef[0];
+#else
+    cDistparity.m_acMvCand[0] = pcCU->getDvInfo(0).m_acMvCand[0];
+#endif
+    assert(pcCU->getDvInfo(uiPartAddr).bDV ==  pcCU->getDvInfo(0).bDV);
+    cDistparity.m_aVIdxCan[0] = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan[0];
+    cDistparity.iN            = pcCU->getDvInfo(uiPartAddr).iN;
+  }
+  else
+    cDistparity.iN    =  0;
+#else
+  pcCU->getDisMvpCandNBDV( iPartIdx, uiPartAddr,  &cDistparity, false );
+#endif
+
+  dW = !cDistparity.iN ? 0: dW;
+  if( cDistparity.iN ) 
+  {
+    if(dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC())
+      bTobeScaled = true;
+    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan[0] );
+    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan[0] );
+    if( (!pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC()) || (!pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ))
+    {
+      dW = 0;
+      bTobeScaled = false;
+    }
+    else
+      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->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;
+    }
+  }
+  pcCU->clipMv(cMv);
+  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
+  xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
+#if LGE_ILLUCOMP_B0045
+    , false
+#endif
+    , true 
+    );
+  xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi
+#if LGE_ILLUCOMP_B0045
+    , false
+#endif
+    , true
+    );
+  if( dW > 0 )
+  {
+    TComYuv * pYuvmB0 = &m_acYuvPredBase[0];
+    TComYuv * pYuvB1  = &m_acYuvPredBase[1];
+    assert ( cDistparity.iN == 1 );
+    pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
+    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi
+#if LGE_ILLUCOMP_B0045
+      , false
+#endif
+      ,  true
+      );
+    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cDistparity.m_acMvCand[0], iWidth, iHeight, pYuvB1, bi 
+#if LGE_ILLUCOMP_B0045
+      , false
+#endif
+      , true
+      );
+    pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
+    TComMv cMVwithDisparity = cMv + cDistparity.m_acMvCand[0];
+    pcCU->clipMv(cMVwithDisparity);
+    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi 
+#if LGE_ILLUCOMP_B0045
+      , false
+#endif
+      , true
+      );
+    xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvmB0, bi 
+#if LGE_ILLUCOMP_B0045
+      , false
+#endif
+      , true
+      );
+    pYuvB1->subtractARP( pYuvB1 , pYuvmB0 , uiPartAddr , iWidth , iHeight );
+    if(dW == 2)
+      pYuvB1->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
+    rpcYuvPred->addARP( rpcYuvPred , pYuvB1 , uiPartAddr , iWidth , iHeight , !bi );
+  }
+}
+#endif
 
 #if MERL_VSP_C0152
@@ -1108,7 +1250,17 @@
  */
 #if LGE_ILLUCOMP_B0045
-Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag)
-#else
-Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
+Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag
+#if QC_ARP_D0177
+    ,
+    Int filterType
+#endif 
+    )
+#else
+Void TComPrediction::xPredInterLumaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
+#if QC_ARP_D0177
+    ,
+    Int filterType
+#endif 
+    )
 #endif
 {
@@ -1129,9 +1281,19 @@
   if ( yFrac == 0 )
   {
-    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi );
+    m_if.filterHorLuma( ref, refStride, dst, dstStride, width, height, xFrac,       !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif
+    );
   }
   else if ( xFrac == 0 )
   {
-    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi );
+    m_if.filterVerLuma( ref, refStride, dst, dstStride, width, height, yFrac, true, !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif
+    );
   }
   else
@@ -1143,6 +1305,16 @@
     Int halfFilterSize = ( filterSize >> 1 );
 
-    m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     );
-    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi);    
+    m_if.filterHorLuma(ref - (halfFilterSize-1)*refStride, refStride, tmp, tmpStride, width, height+filterSize-1, xFrac, false     
+ #if QC_ARP_D0177
+    ,
+    filterType
+#endif 
+    );
+    m_if.filterVerLuma(tmp + (halfFilterSize-1)*tmpStride, tmpStride, dst, dstStride, width, height,              yFrac, false, !bi
+ #if QC_ARP_D0177
+    ,
+    filterType
+#endif 
+    );    
   }
 
@@ -1185,7 +1357,16 @@
  */
 #if LGE_ILLUCOMP_B0045
-Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag )
-#else
-Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi )
+Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag
+#if QC_ARP_D0177
+    ,
+    Int filterType
+#endif    
+    )
+#else
+Void TComPrediction::xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
+#if QC_ARP_D0177
+  , Int filterType
+#endif
+  )
 #endif
 {
@@ -1215,19 +1396,59 @@
   if ( yFrac == 0 )
   {
-    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);    
-    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);    
+    m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );    
+    m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );    
   }
   else if ( xFrac == 0 )
   {
-    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);    
-    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);    
+    m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi
+ #if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );    
+    m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi
+ #if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );    
   }
   else
   {
-    m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
-    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);
+    m_if.filterHorChroma(refCb - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );
+    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCb, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );
     
-    m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false);
-    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi);    
+    m_if.filterHorChroma(refCr - (halfFilterSize-1)*refStride, refStride, extY,  extStride, cxWidth, cxHeight+filterSize-1, xFrac, false
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );
+    m_if.filterVerChroma(extY  + (halfFilterSize-1)*extStride, extStride, dstCr, dstStride, cxWidth, cxHeight  , yFrac, false, !bi
+#if QC_ARP_D0177
+    ,
+    filterType
+#endif   
+    );    
   }
 #if LGE_ILLUCOMP_B0045
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 373)
@@ -69,4 +69,8 @@
   TComYuv   m_acYuvPred[2];
   TComYuv   m_cYuvPredTemp;
+#if QC_ARP_D0177
+  TComYuv   m_acYuvPredBase[2];
+  TComYuv   m_acYuvDiff[2];
+#endif
   TComYuv m_filteredBlock[4][4];
   TComYuv m_filteredBlockTmp[4];
@@ -86,4 +90,7 @@
   
   // motion compensation functions
+#if QC_ARP_D0177
+  Void xPredInterUniARP       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi=false, TComMvField * pNewMvFiled = NULL );
+#endif
 #if MERL_VSP_C0152
   Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,       UInt uiAbsPartIdx,        Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, UInt uiSubSampExpX = 0, UInt uiSubSampExpY = 0, Bool bi=false );
@@ -113,9 +120,29 @@
 
 #if LGE_ILLUCOMP_B0045
-  Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag = false );
-  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag = false );
-#else
-  Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi );
-  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi );
+  Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag = false
+#if QC_ARP_D0177
+    ,
+    Int filterType = 0
+#endif
+    );
+  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi, Bool bICFlag = false
+#if QC_ARP_D0177
+    ,
+    Int filterType = 0
+#endif
+    );
+#else
+  Void xPredInterLumaBlk  ( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
+#if QC_ARP_D0177
+    ,
+    Int filterType = 0
+#endif
+    );
+  Void xPredInterChromaBlk( TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi
+#if QC_ARP_D0177
+    ,
+    Int filterType = 0
+#endif
+    );
 #endif
   Void xWeightedAverage         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
@@ -169,5 +196,5 @@
 #endif
 
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   Void residualPrediction         (TComDataCU* pcCU, TComYuv* pcYuvPred, TComYuv* pcYuvResPred);
 #endif
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 373)
@@ -44,5 +44,5 @@
 
 
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
 
 
@@ -225,5 +225,7 @@
   }
 }
-
+#endif
+
+#if !QC_ARP_D0177
 #if H3D_NBDV
 Bool
@@ -249,5 +251,5 @@
 }
   
-#if H3D_NBDV
+#if H3D_NBDV 
 Bool
 TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp, Bool bRecon)  
@@ -263,4 +265,8 @@
   }
   UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos;
+#if QC_ARP_D0177
+  if(pcPic->getSPS()->getMultiviewResPredMode())
+  {
+#endif
 #if H3D_NBDV
   xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp, &uiXPosInRefView , &uiYPosInRefView , bRecon  );
@@ -269,4 +275,9 @@
 #endif
   return true;
+#if QC_ARP_D0177
+  }
+  else
+    return true;
+#endif
 }
 
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 373)
@@ -50,5 +50,5 @@
 
 
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
 
 class TComResidualGenerator
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 373)
@@ -1386,5 +1386,36 @@
 }
 #endif
-
+#if QC_ARP_D0177
+Void TComSlice::setARPStepNum()                                  
+{
+  Bool bAllIvRef = false;
+  if(!getSPS()->getUseAdvRP())
+    m_nARPStepNum = 0;
+  else
+  {
+    for( Int iRefListId = 0; iRefListId < 2; iRefListId++ )
+    {
+      RefPicList  eRefPicList = RefPicList( iRefListId );
+      Int iNumRefIdx = getNumRefIdx(eRefPicList);
+      if( iNumRefIdx <= 0 )
+        continue;
+      for (Int i = 0; i < iNumRefIdx; i++)
+      {
+        if(getRefPic( REF_PIC_LIST_0, i)->getPOC() != getPOC())
+        {
+          bAllIvRef = true;
+          break;
+        }
+      }
+      if( bAllIvRef == true )
+        break;
+    }
+    if(bAllIvRef== true)
+      m_nARPStepNum = getSPS()->getARPStepNum();
+    else
+      m_nARPStepNum = 0;
+  }
+}
+#endif
 // ------------------------------------------------------------------------------------------------
 // Video parameter set (VPS)
@@ -1576,5 +1607,8 @@
   m_uiMultiviewMvPredMode    = 0;
 #endif
-
+#if QC_ARP_D0177
+  m_nUseAdvResPred           = 0;
+  m_nARPStepNum              = 1;
+#endif
   ::memset( m_aiUsableInterViewRefs, 0, sizeof( m_aiUsableInterViewRefs ) );
   
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 373)
@@ -54,5 +54,5 @@
 class TComDepthMapGenerator;
 #endif
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
 class TComResidualGenerator;
 #endif
@@ -390,5 +390,10 @@
 #endif
 #if H3D_IVRP
+#if QC_ARP_D0177
+  UInt         m_nUseAdvResPred;
+  UInt         m_nARPStepNum;
+#else
   UInt  m_uiMultiviewResPredMode;
+#endif
 #endif
 
@@ -396,5 +401,5 @@
   TComDepthMapGenerator* m_pcDepthMapGenerator;
 #endif
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   TComResidualGenerator* m_pcResidualGenerator;
 #endif
@@ -643,5 +648,5 @@
   Void setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode = 0, UInt uiPdmMvPredMode = 0, UInt uiPdmPrec = 0, Int** aaiPdmScaleNomDelta = 0, Int** aaiPdmOffset = 0 );
 #endif
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   Void  setMultiviewResPredMode  ( UInt uiResPrdMode ) { m_uiMultiviewResPredMode = uiResPrdMode; }
 #endif
@@ -658,5 +663,12 @@
 #endif
 #if H3D_IVRP
+#if QC_ARP_D0177
+  UInt  getUseAdvRP()              { return m_nUseAdvResPred;   }
+  Void  setUseAdvRP(UInt n)        { m_nUseAdvResPred = n;      }
+  UInt  getARPStepNum()            { return m_nARPStepNum;      }
+  Void  setARPStepNum(UInt n)      { m_nARPStepNum = n;         }
+#else
   UInt  getMultiviewResPredMode  ()          { return m_uiMultiviewResPredMode;   }
+#endif
 #endif
 
@@ -665,5 +677,5 @@
   TComDepthMapGenerator*  getDepthMapGenerator()                                              { return m_pcDepthMapGenerator; }
 #endif
-#if H3D_IVRP
+#if H3D_IVRP & !QC_ARP_D0177
   Void                    setResidualGenerator( TComResidualGenerator* pcResidualGenerator )  { m_pcResidualGenerator = pcResidualGenerator; }
   TComResidualGenerator*  getResidualGenerator()                                              { return m_pcResidualGenerator; }
@@ -1107,4 +1119,8 @@
   Bool        m_bApplyIC;
 #endif
+#if QC_ARP_D0177
+  TComList<TComPic*> * m_pBaseViewRefPicList[MAX_VIEW_NUM];
+  UInt                 m_nARPStepNum; 
+#endif
 #if INTER_VIEW_VECTOR_SCALING_C0115|QC_MVHEVC_B0046
   Bool       m_bIVScalingFlag;
@@ -1253,5 +1269,10 @@
   Void      setRefPicListMvc    ( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcInterViewRefPics );
   Void      setRefPOCnViewListsMvc();
-
+#if QC_ARP_D0177
+  Void      setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }
+  TComPic*  getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )                       { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
+  Void      setARPStepNum();                                 
+  UInt      getARPStepNum( )                                      { return m_nARPStepNum;      }  
+#endif
   Void      setColDir           ( UInt uiDir ) { m_uiColDir = uiDir; }
 #if COLLOCATED_REF_IDX
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.cpp	(revision 373)
@@ -741,3 +741,169 @@
   }
 }
+#if QC_ARP_D0177
+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 )
+{
+  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();
+  for ( y = uiHeight-1; y >= 0; y-- )
+  {
+    for ( x = uiWidth-1; x >= 0; x-- )
+    {
+      pDst[x] = pSrc0[x] + pSrc1[x];
+      if( bClip )
+        pDst[x] = Clip( pDst[x] );
+    }
+    pSrc0 += iSrc0Stride;
+    pSrc1 += iSrc1Stride;
+    pDst  += iDstStride;
+  }
+}
+
+Void TComYuv::addARPChroma(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip )
+{
+  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();
+  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];
+      if( bClip )
+      {
+        pDstU[x] = Clip( pDstU[x] );
+        pDstV[x] = Clip( pDstV[x] );
+      }
+    }
+
+    pSrcU0 += iSrc0Stride;
+    pSrcU1 += iSrc1Stride;
+    pSrcV0 += iSrc0Stride;
+    pSrcV1 += iSrc1Stride;
+    pDstU  += iDstStride;
+    pDstV  += iDstStride;
+  }
+}
+
+Void TComYuv::subtractARP(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight)
+{
+  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
+  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 );
+  multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW );
+}
+
+Void TComYuv::xxMultiplyLine( Pel * pSrcDst , UInt uiWidth , UChar dW )
+{
+  assert( dW == 2 );
+  for( UInt x = 0 ; x < uiWidth ; x++ )
+    pSrcDst[x] =  pSrcDst[x] >> 1;
+}
+
+Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
+{
+  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
+  Int  iDstStride  = getStride();
+  for ( Int y = uiHeight-1; y >= 0; y-- )
+  {
+    xxMultiplyLine( pDst , uiWidth , dW );
+    pDst  += iDstStride;
+  }
+}
+
+Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
+{
+  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
+  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
+
+  Int  iDstStride  = getCStride();
+  for ( Int y = uiHeight-1; y >= 0; y-- )
+  {
+    xxMultiplyLine( pDstU , uiWidth , dW );
+    xxMultiplyLine( pDstV , uiWidth , dW );
+    pDstU  += iDstStride;
+    pDstV  += iDstStride;
+  }
+}
+#endif
 //! \}
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TComYuv.h	(revision 373)
@@ -199,4 +199,17 @@
 
   __inline Pel  xClip  (Pel x )      { return ( (x < 0) ? 0 : (x > (Pel)g_uiIBDI_MAX) ? (Pel)g_uiIBDI_MAX : x ); }
+#if QC_ARP_D0177
+  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 );
+  Void    subtractARP      ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
+  Void    subtractARPLuma  ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
+  Void    subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
+  Void    multiplyARP      ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
+  Void    multiplyARPLuma  ( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
+  Void    multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW );
+private:
+  Void    xxMultiplyLine( Pel * pSrcDst , UInt uiWidth , UChar dW );
+#endif
 };// END CLASS DEFINITION TComYuv
 
Index: branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 351)
+++ branches/HTM-6.2-dev2-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 373)
@@ -95,4 +95,8 @@
                                               // FIX_LG_RESTRICTEDRESPRED_M24766   1
 
+#define QC_ARP_D0177            1      ////< advanced residual prediction
+#if QC_ARP_D0177
+#define QC_ARP_WFNR       3
+#endif
 ///// ***** DISPARITY VECTOR DERIVATION *********
 #define H3D_NBDV                          1   // Neighboring block disparity derivation 
