Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 499)
@@ -1100,5 +1100,9 @@
      0.753550, 0.800000  
   }; 
+#if H_3D_CLEANUPS
+  if ( m_bUseVSO && m_bVSOLSTable )
+#else
   if ( m_bVSOLSTable )
+#endif
   {
     Int firstDepthLayer = -1; 
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.cpp	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppExtractor/TAppExtrTop.h	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppRenderer/TAppRendererTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppRenderer/TAppRendererTop.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppRenderer/TAppRendererTop.h	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 499)
@@ -2463,6 +2463,4 @@
   Int     iPosLeftAbove[2]  = {-1, -1};
 
-  //Notes from QC: DvMCP related variables.  
-  //acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = acPdmMv[2].m_bDvMcp = acPdmMv[3].m_bDvMcp = false;
 
   DisInfo cDisInfo;
@@ -2497,4 +2495,7 @@
         //clipMv(cMvPred);
         //pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx());
+#if H_3D_CLEANUPS //Notes from QC: for BVSP coded blocks, the reference index shall not be equal to -1 due to the adoption of JCT3V-D0191
+        pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,pcMvFieldNeighbours[iCount<<1].getRefIdx());
+#else
         if (pcMvFieldNeighbours[iCount<<1].getRefIdx()<0)
         {
@@ -2508,5 +2509,5 @@
           }
         }
-
+#endif
       }
       
@@ -2524,4 +2525,7 @@
           //clipMv(cMvPred);
           //pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx());
+#if H_3D_CLEANUPS
+          pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx());
+#else
           if (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()<0)
           {
@@ -2535,11 +2539,16 @@
             }
           }
-
+#endif
         }
       }
-
+#if !H_3D_CLEANUPS
       if (!((pcMvFieldNeighbours[iCount<<1].getRefIdx()<0 && !getSlice()->isInterB())
         || (pcMvFieldNeighbours[iCount<<1].getRefIdx()<0 && pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()<0 && getSlice()->isInterB())))
       {
+#endif
+#if H_3D_IDV
+        pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+        pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
         if ( mrgCandIdx == iCount )
         {
@@ -2547,4 +2556,5 @@
         }
         iCount ++;
+#if !H_3D_CLEANUPS
       }
       else
@@ -2552,4 +2562,5 @@
         assert(0);
       }
+#endif
     }
   }
@@ -2563,5 +2574,9 @@
     
   Int iPdmInterDir;
+#if H_3D_CLEANUPS
+  if( iPdmDir[0] )
+#else
   if( iPdmDir[0] && ivMvPredFlag )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
@@ -2573,5 +2588,4 @@
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
-
     if( ( iPdmInterDir & 2 ) == 2 )
     {
@@ -2584,5 +2598,12 @@
     }
     iCount ++;
-  }  
+  } 
+#if H_3D_CLEANUPS
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#endif
 #endif
 
@@ -2646,5 +2667,8 @@
       bLeftAvai = true;
       iPosLeftAbove[0] = iCount;
-
+#if H_3D_IDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
       if ( mrgCandIdx == iCount )
       {
@@ -2707,5 +2731,8 @@
     {
       iPosLeftAbove[1] = iCount;
-
+#if H_3D_IDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
       if ( mrgCandIdx == iCount )
       {
@@ -2746,4 +2773,8 @@
       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if H_3D_IDV
+    pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
     if ( mrgCandIdx == iCount )
     {
@@ -2759,5 +2790,9 @@
 
 #if H_3D_IV_MERGE 
+#if H_3D_CLEANUPS
+  if( iPdmDir[1] )
+#else
   if(ivMvPredFlag && iPdmDir[1] )
+#endif
   {
     assert(iCount < getSlice()->getMaxNumMergeCand());
@@ -2792,4 +2827,8 @@
     if(!bRemoveSpa)
     {
+#if H_3D_IDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
       if ( mrgCandIdx == iCount )
         return;
@@ -2823,4 +2862,8 @@
       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if H_3D_IDV
+    pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
     if ( mrgCandIdx == iCount )
     {
@@ -2855,4 +2898,8 @@
         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
       }
+#if H_3D_IDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
       if ( mrgCandIdx == iCount )
       {
@@ -2932,7 +2979,10 @@
       pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
     }
-    
+
     if ( getSlice()->isInterB() )
     {
+#if H_3D_TMVP
+      iRefIdx = 0;
+#endif
       bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
       if( bExistMV == false )
@@ -2951,5 +3001,8 @@
       puhInterDirNeighbours[uiArrayAddr] = dir;
       abCandIsInter[uiArrayAddr] = true;
-
+#if H_3D_IDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
       if ( mrgCandIdx == iCount )
       {
@@ -3258,5 +3311,9 @@
       }
     }
-    if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) )
+    if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col 
+#if H_3D_TMVP
+         , 0
+#endif
+    ) )
     {
       pInfo->m_acMvCand[pInfo->iN++] = cColMv;
@@ -3267,5 +3324,9 @@
       UInt uiCurLCUIdx = getAddr();
       xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
-      if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iRefIdx_Col ))
+      if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iRefIdx_Col 
+#if H_3D_TMVP
+         , 0
+#endif
+      ))
       {
         pInfo->m_acMvCand[pInfo->iN++] = cColMv;
@@ -3582,5 +3643,9 @@
  * \returns Bool
  */
-Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx )
+Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx 
+#if H_3D_TMVP
+  , Bool bMRG
+#endif
+  )
 {
   UInt uiAbsPartAddr = uiPartUnitIdx;
@@ -3630,10 +3695,41 @@
   if ( bIsCurrRefLongTerm != bIsColRefLongTerm ) 
   {
-    return false;
+#if H_3D_TMVP
+    Int iAlterRefIdx  = m_pcSlice->getAlterRefIdx(eRefPicList);
+    if(bMRG && iAlterRefIdx > 0)
+    {
+      riRefIdx = iAlterRefIdx;
+      bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
+      iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
+      assert(bIsCurrRefLongTerm == bIsColRefLongTerm);
+    }
+    else
+    {
+#endif
+      return false;
+#if H_3D_TMVP
+    }
+#endif
   }
 
   if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
   {
-    rcMv = cColMv;
+#if H_3D_TMVP
+     Int iCurrViewId    = m_pcSlice->getViewIndex (); 
+     Int iCurrRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewIndex (); 
+     Int iColViewId     = pColCU->getSlice()->getViewIndex(); 
+     Int iColRefViewId  = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewIndex(); 
+     iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
+     if ( iScale != 4096 )
+     {
+        rcMv = cColMv.scaleMv( iScale );
+     }
+     else
+     {
+#endif
+       rcMv = cColMv;
+#if H_3D_TMVP
+    }
+#endif
   }
   else
@@ -4354,12 +4450,24 @@
           clipMv( cDispVec );
           pDInfo->m_acNBDV = cDispVec;
+#if H_3D_CLEANUPS
+          pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
+          assert(pDInfo->m_aVIdxCan == 0); //Notes from QC: only works for CTC
+#else
           pDInfo->m_aVIdxCan = 0;
+#endif
 #if H_3D_NBDV_REF
+#if H_3D_CLEANUPS
+          TComPic* picDepth = getSlice()->getIvPic( true, pDInfo->m_aVIdxCan );
+#else
           TComPic* picDepth = getSlice()->getIvPic( true, 0 );
+#endif
           assert(picDepth!=NULL);
 
           if (picDepth && bDepthRefine)
+#if H_3D_CLEANUPS
+            estimateDVFromDM (pDInfo->m_aVIdxCan, uiPartIdx, picDepth, uiPartAddr, &cDispVec);
+#else
             estimateDVFromDM(0, uiPartIdx, picDepth, uiPartAddr, &cDispVec ); // from base view
-
+#endif
           pDInfo->m_acDoNBDV = cDispVec;
           
@@ -4484,5 +4592,5 @@
 
           UInt uiPartIdx = 0;   //Notes from MTK: Please confirm that using 0 as partition index and partition address is correct for CU-level DoNBDV
-          UInt uiPartAddr = 0;
+          UInt uiPartAddr = 0;  //QC: confirmed
 
           if (picDepth && bDepthRefine)
@@ -4615,6 +4723,9 @@
 {
   TComSlice*    pcSlice         = getSlice ();  
-
+#if H_3D_CLEANUPS //Notes from QC: to be aligned with the spec. 
+  Int iViewIndex = pDInfo->m_aVIdxCan;
+#else
   Bool valid     = false;
+
   Int iViewIndex = 0;
 
@@ -4642,5 +4753,5 @@
   if (!valid)
     return false;
-
+#endif
   //--- get base CU/PU and check prediction mode ---
   TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
@@ -4675,4 +4786,10 @@
 
   Bool abPdmAvailable[4] = {false, false, false, false};
+#if H_3D_IDV
+  for( Int i = 0; i < 4; i++)
+  {
+    pacPdmMv[i].setIDVFlag   (false);
+  }
+#endif
   if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
   {
@@ -4699,8 +4816,9 @@
                 abPdmAvailable[ uiCurrRefListId ] = true;
                 TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
-
-                //                  cMv.m_bDvMcp = true;
-                //                  cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();                  
-
+#if H_3D_IDV 
+                cMv.setIDVFlag   (true);
+                cMv.setIDVHor    (cDv.getHor());                  
+                cMv.setIDVVer    (cDv.getVer());  
+#endif
                 clipMv( cMv );
                 paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
@@ -4716,5 +4834,4 @@
   }
   availableMcDc[0] = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
-
   for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
   {
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 499)
@@ -213,5 +213,10 @@
 
   Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
-  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );
+  Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx 
+#if H_3D_TMVP
+  ,
+  Bool bMRG = true
+#endif
+  );
   
   /// compute required bits to encode MVD (used in AMVP)
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComMv.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComMv.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComMv.h	(revision 499)
@@ -94,5 +94,9 @@
   Void  setHor    ( Short i )                   { m_iHor = i;                               }
   Void  setVer    ( Short i )                   { m_iVer = i;                               }
-  Void  setZero   ()                            { m_iHor = m_iVer = 0;  }
+  Void  setZero   ()                            { m_iHor = m_iVer = 0;  
+ #if H_3D_NBDV
+   m_bIDV = false; m_iIDVHor = m_iIDVVer = 0;
+#endif
+  }
 #if H_3D_NBDV
   Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 499)
@@ -221,4 +221,8 @@
   m_numEntryPointOffsets = 0;
   m_enableTMVPFlag = true;
+#if H_3D_TMVP
+  m_aiAlterRefIdx[0]                  = -1;
+  m_aiAlterRefIdx[1]                  = -1;
+#endif
 }
 
@@ -699,4 +703,25 @@
 }
 #if H_3D
+#if H_3D_TMVP
+Void TComSlice::generateAlterRefforTMVP()
+{
+  for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+  {        
+    if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0)
+        continue;
+
+    Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm();
+    for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
+    {
+      if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ||
+           (!bZeroIdxLtFlag &&  this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) )
+      {
+        this->setAlterRefIdx(RefPicList(uiRefListIdx),i);
+        break;
+      }
+    }
+  }
+}
+#endif
 Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset )
 {  
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 499)
@@ -1506,5 +1506,8 @@
   Bool       m_isDepth;
   Int        m_aaiCodedScale [2][MAX_NUM_LAYERS];
-  Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];  
+  Int        m_aaiCodedOffset[2][MAX_NUM_LAYERS];
+#if H_3D_TMVP
+  Int        m_aiAlterRefIdx   [2]; 
+#endif
 #if H_3D_GEN
   TComPic*   m_ivPicsCurrPoc [2][MAX_NUM_LAYERS];  
@@ -1779,4 +1782,9 @@
   Int       getViewId             ()                 { return m_viewId;     }
 #if H_3D
+#if H_3D_TMVP
+  Void      generateAlterRefforTMVP ();   
+  Void      setAlterRefIdx          ( RefPicList e, Int i ) { m_aiAlterRefIdx[e]    = i;      }
+  Int       getAlterRefIdx          ( RefPicList e )        { return  m_aiAlterRefIdx[e];     }
+#endif
   Void      setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
   Int       getViewIndex          ()                 { return m_viewIndex;     }
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 499)
@@ -78,5 +78,5 @@
                                               // LGE_WVSO_A0119
 #define H_3D_NBDV                         1   // Neighboring block disparity derivation 
-                                              // JCT3V-A0097 
+                                              // QC_JCT3V-A0097 
                                               // LGE_DVMCP_A0126
                                               // LGE_DVMCP_MEM_REDUCTION_B0135     
@@ -88,7 +88,10 @@
                                               // QC_CU_NBDV_D0181
                                               // SEC_DEFAULT_DV_D0112
+#if H_3D_NBDV
+#define H_3D_IDV                          1   // LGE_DVMCP_A0126  QC note: this macro will be removed after merging to dev2a
 #define H_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
                                               // MTK_D0156
                                               // MERL_VSP_NBDV_RefVId_Fix_D0166
+#endif
 #define H_3D_VSP                          0   // Depth oriented neighboring block disparity derivation
 
@@ -101,5 +104,8 @@
                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
+#define H_3D_TMVP                         1   // QC_TMVP_C0047 
+                                              // Sony_M23639
 #define H_3D_GEN                          1   // Some general changes can be removed after merge 
+#define H_3D_CLEANUPS                     1
 #endif 
 
@@ -121,4 +127,12 @@
 ////   ****** Neighbouring block-based Disparity Vector  *********
 #if H_3D_NBDV
+#if H_3D_CLEANUPS
+#define DVFROM_LEFTBELOW                  0
+#define DVFROM_LEFT                       1
+#define DVFROM_ABOVERIGHT                 2
+#define DVFROM_ABOVE                      3
+#define DVFROM_ABOVELEFT                  4
+#define IDV_CANDS                         5
+#else
 #define IDV_CANDS                         6
 #define DVFROM_LEFTBELOW                  1
@@ -127,4 +141,5 @@
 #define DVFROM_ABOVE                      4
 #define DVFROM_ABOVELEFT                  5
+#endif
 #endif
 /////////////////////////////////////////////////////////////////////////////////////////
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 499)
@@ -959,4 +959,8 @@
     }
 #endif
+#if  H_3D_TMVP
+    if(pcSlice->getLayerId())
+      pcSlice->generateAlterRefforTMVP();
+#endif
   }
 
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 499)
@@ -778,5 +778,8 @@
     pcSlice->generateCombinedList();
 #endif
-
+#if H_3D_TMVP
+    if(pcSlice->getLayerId())
+      pcSlice->generateAlterRefforTMVP();
+#endif
     if (m_pcEncTop->getTMVPModeId() == 2)
     {
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibExtractor/TExtrTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 499)
@@ -115,2 +115,3 @@
 }
 #endif
+
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImage.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImage.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImage.cpp	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImagePlane.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImagePlane.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenImagePlane.cpp	(revision 499)
@@ -529,2 +529,3 @@
 template class TRenImagePlanePart<Int>;
 #endif // H_3D
+
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenInterpFilter.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenInterpFilter.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenInterpFilter.cpp	(revision 499)
@@ -51,2 +51,3 @@
 
 #endif // H_3D
+
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenModel.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenModel.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenModel.cpp	(revision 499)
Index: branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenTop.cpp	(revision 487)
+++ branches/HTM-DEV-0.3-dev2/source/Lib/TLibRenderer/TRenTop.cpp	(revision 499)
@@ -2227,2 +2227,3 @@
 }
 #endif // H_3D
+
