Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 185)
@@ -139,4 +139,13 @@
 #define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
 #define PDM_MERGE_POS                     0         // position of pdm in merge list (0..4)
+
+#if QC_MRG_CANS_B0048
+#if OL_DISMV_POS_B0069
+#define DMV_MERGE_POS                     4
+#else
+#define DMV_MERGE_POS                     1
+#endif
+#endif
+
 #if SAIT_IMPROV_MOTION_PRED_M24829&!QC_MULTI_DIS_CAN
 #define PDM_AMVP_POS                      0         // position of pdm in amvp list  (0..3)
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 185)
@@ -3664,9 +3664,22 @@
 
   //===== add merge with predicted depth maps =====
+#if QC_MRG_CANS_B0048
+  TComMv  acPdmMv       [4];
+  Int     aiPdmRefIdx   [4] = {-1, -1, -1, -1};
+  Bool    bLeftAvai         = false;
+#if OL_DISMV_POS_B0069
+  Int     iPosLeftAbove[2]  = {-1, -1};
+#endif
+#else
   TComMv  acPdmMv       [2];
   Int     aiPdmRefIdx   [2] = {-1, -1};
+#endif
 
 #if LGE_DVMCP
+#if QC_MRG_CANS_B0048
+  acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = acPdmMv[2].m_bDvMcp = acPdmMv[3].m_bDvMcp = false; 
+#else
   acPdmMv[0].m_bDvMcp = acPdmMv[1].m_bDvMcp = false; 
+#endif
 #endif
 
@@ -3677,5 +3690,14 @@
   {
 #if LGE_DVMCP
-    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo, true );
+#if LGE_IVMP_PARALLEL_MERGE_B0136 && !QC_SIMPLE_NBDV_B0047
+    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo, true, REF_PIC_LIST_X, -1, true );
+#else
+    getDisMvpCand2(uiPUIdx, uiAbsPartIdx, &cDisInfo
+#if LGE_IVMP_PARALLEL_MERGE_B0136==QC_SIMPLE_NBDV_B0047
+,
+true
+#endif
+);
+#endif
 #else
     getDisMvpCand (uiPUIdx, uiAbsPartIdx, &cDisInfo );
@@ -3689,21 +3711,48 @@
     cDisInfo.m_aVIdxCan[0] = 0;
   }
-  Int     iPdmInterDir      = cDisInfo.iN==0? 0:getPdmMergeCandidateDisCan ( uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo  );
+#if QC_MRG_CANS_B0048
+  Int iPdmDir[2] = {0, 0};
+#endif
+  Int     iPdmInterDir      = cDisInfo.iN==0? 0:getPdmMergeCandidateDisCan ( uiPUIdx, aiPdmRefIdx, acPdmMv, &cDisInfo  
+#if QC_MRG_CANS_B0048
+    , iPdmDir
+#endif
+    );
 #else
   Int     iPdmInterDir      = getPdmMergeCandidate( uiPUIdx, aiPdmRefIdx, acPdmMv );
 #endif
-
+#if QC_MRG_CANS_B0048
+  if( iPdmDir[0] && !bNoPdmMerge && PDM_MERGE_POS == 0 )
+#else
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 0 )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
+#if QC_MRG_CANS_B0048
+    puhInterDirNeighbours[ iCount ] = iPdmDir[0];
+    iPdmInterDir                    = iPdmDir[0];
+#else
     puhInterDirNeighbours[ iCount ] = iPdmInterDir;
+#endif
     if( ( iPdmInterDir & 1 ) == 1 )
     {
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ iCount<<1    ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     if( ( iPdmInterDir & 2 ) == 2 )
     {
       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3716,4 +3765,32 @@
 #endif
 
+#if QC_MRG_CANS_B0048
+  if(extraMergeCand)
+  {
+    if(!bNoPdmMerge && iPdmDir[1] && DMV_MERGE_POS == 1)
+    {
+      assert(iCount < MRG_MAX_NUM_CANDS_MEM);
+      abCandIsInter        [ iCount ] = true;
+      puhInterDirNeighbours[ iCount ] = iPdmDir[1];
+      if( ( iPdmDir[1] & 1 ) == 1 )
+      {
+        pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 2 ], aiPdmRefIdx[ 2 ] );
+      }
+      if( ( iPdmDir[1] & 2 ) == 2 )
+      {
+        pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 3 ], aiPdmRefIdx[ 3 ] );
+      }
+#if LGE_DVMCP
+      pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
+#if SIMP_MRG_PRUN
+      if ( mrgCandIdx == iCount )
+          return;
+#endif
+      iCount ++;
+    }    
+  }
+#endif
   //left
   UInt uiLeftPartIdx = 0;
@@ -3747,4 +3824,28 @@
       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
+#if QC_MRG_CANS_B0048
+    Bool bRemoveSpa = false; //prunign to inter-view candidates
+    Int  iCnloop    = iCount - 1;
+    for(; iCnloop >= 0; iCnloop --)
+    {
+      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+      {
+        bRemoveSpa                      = true;
+        abCandIsInter        [ iCount ] = false;
+      }
+    }
+    if(!bRemoveSpa)
+    {
+      bLeftAvai = true;
+#if OL_DISMV_POS_B0069
+      iPosLeftAbove[0] = iCount;
+#endif
+#endif
 #if LGE_DVMCP
     pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
@@ -3758,9 +3859,16 @@
 #endif
     iCount ++;
+#if QC_MRG_CANS_B0048
+      }
+#endif
   }
   }
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MRG_CANS_B0048
+  if( iPdmDir[0]   && !bNoPdmMerge && PDM_MERGE_POS == 1 )
+#else
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 1 )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
@@ -3770,8 +3878,20 @@
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ iCount<<1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     if( ( iPdmInterDir & 2 ) == 2 )
     {
       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3823,4 +3943,27 @@
       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
+#if QC_MRG_CANS_B0048
+    Bool bRemoveSpa = false; //prunign to inter-view candidates
+    Int  iCnloop    = bLeftAvai? (iCount-2): (iCount-1);
+    for(; iCnloop >= 0; iCnloop --)
+    {
+      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+      {
+        bRemoveSpa                      = true;
+        abCandIsInter        [ iCount ] = false;
+      }
+    }
+    if(!bRemoveSpa)
+    {
+#if OL_DISMV_POS_B0069
+      iPosLeftAbove[1] = iCount;
+#endif
+#endif
 #if LGE_DVMCP
     pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
@@ -3834,4 +3977,7 @@
 #endif
     iCount ++;
+#if QC_MRG_CANS_B0048
+    }
+#endif
   }
 #if !SIMP_MRG_PRUN
@@ -3840,5 +3986,9 @@
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MRG_CANS_B0048
+  if( iPdmDir[0]   && !bNoPdmMerge && PDM_MERGE_POS == 2 )
+#else
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 2 )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
@@ -3848,8 +3998,20 @@
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ iCount<<1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     if( ( iPdmInterDir & 2 ) == 2 )
     {
       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3894,4 +4056,10 @@
       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if LGE_DVMCP
     pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
@@ -3908,5 +4076,9 @@
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MRG_CANS_B0048
+  if( iPdmDir[0]   && !bNoPdmMerge && PDM_MERGE_POS == 3 )
+#else
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 3 )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
@@ -3916,8 +4088,20 @@
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ iCount<<1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     if( ( iPdmInterDir & 2 ) == 2 )
     {
       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -3930,4 +4114,47 @@
 #endif
 
+#if OL_DISMV_POS_B0069
+  if(extraMergeCand)
+  {
+    if(!bNoPdmMerge && iPdmDir[1] && DMV_MERGE_POS == 4)
+    {
+      assert(iCount < MRG_MAX_NUM_CANDS_MEM);
+      Bool bRemoveSpa = false; //prunign to A1, B1
+      abCandIsInter        [ iCount ] = true;
+      puhInterDirNeighbours[ iCount ] = iPdmDir[1];
+      if( ( iPdmDir[1] & 1 ) == 1 )
+      {
+        pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 2 ], aiPdmRefIdx[ 2 ] );
+      }
+      if( ( iPdmDir[1] & 2 ) == 2 )
+      {
+        pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 3 ], aiPdmRefIdx[ 3 ] );
+      }
+      for(Int i = 0; i < 2; i ++)
+      {
+        Int iCnloop = iPosLeftAbove[i];
+        if(iCnloop == -1) 
+          continue;
+        if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+        {
+          bRemoveSpa                      = true;
+          abCandIsInter        [ iCount ] = false;
+        }
+      }
+      if(!bRemoveSpa)
+      {
+#if LGE_DVMCP
+        pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
+        pcMvFieldNeighbours[(iCount<<1)+1].getMv().m_bDvMcp = false;
+#endif
+#if SIMP_MRG_PRUN
+        if ( mrgCandIdx == iCount )
+          return;
+#endif
+        iCount ++;
+      }
+    }    
+  }
+#endif
   //left bottom
   UInt uiLeftBottomPartIdx = 0;
@@ -3962,4 +4189,10 @@
       pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if LGE_DVMCP
     pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
@@ -3976,5 +4209,9 @@
 
 #if HHI_INTER_VIEW_MOTION_PRED
+#if QC_MRG_CANS_B0048
+  if( iPdmDir[0]   && !bNoPdmMerge && PDM_MERGE_POS == 4 )
+#else
   if( iPdmInterDir && !bNoPdmMerge && PDM_MERGE_POS == 4 )
+#endif
   {
     abCandIsInter        [ iCount ] = true;
@@ -3984,8 +4221,20 @@
       pcMvFieldNeighbours[ iCount<<1    ].setMvField( acPdmMv[ 0 ], aiPdmRefIdx[ 0 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ iCount<<1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     if( ( iPdmInterDir & 2 ) == 2 )
     {
       pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( acPdmMv[ 1 ], aiPdmRefIdx[ 1 ] );
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
 #if SIMP_MRG_PRUN
     if ( mrgCandIdx == iCount )
@@ -4039,4 +4288,10 @@
         pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
       }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+      else
+      {
+        pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( TComMv(0,0), NOT_VALID );
+      }
+#endif
 #if LGE_DVMCP
       pcMvFieldNeighbours[iCount<<1    ].getMv().m_bDvMcp = false;
@@ -4053,5 +4308,9 @@
   }
 
-  if ( getSlice()->getPPS()->getEnableTMVPFlag() )
+  if ( getSlice()->getPPS()->getEnableTMVPFlag() 
+#if QC_MRG_CANS_B0048
+       && iCount < (MRG_MAX_NUM_CANDS_SIGNALED + extraMergeCand)
+#endif
+  )
   {
     // col [2]
@@ -4153,4 +4412,7 @@
         {
           puhInterDirNeighbours[uiArrayAddr] = 1;
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+          pcMvFieldNeighbours[ ( uiArrayAddr << 1 ) + 1 ].setMvField( TComMv(0,0), NOT_VALID );
+#endif
         }
       }
@@ -4158,4 +4420,7 @@
       {
         puhInterDirNeighbours[uiArrayAddr] = 1;
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+        pcMvFieldNeighbours[ ( uiArrayAddr << 1 ) + 1 ].setMvField( TComMv(0,0), NOT_VALID );
+#endif
       }
 #if LGE_DVMCP
@@ -4395,4 +4660,10 @@
       pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
     }
+#if FIX_CU_BASED_MRG_CAND_LIST_B0136
+    else
+    {
+      pcMvFieldNeighbours[ ( uiArrayAddr << 1 ) + 1 ].setMvField( TComMv(0,0), NOT_VALID );
+    }
+#endif
     uiArrayAddr++;
   }
@@ -4959,9 +5230,22 @@
 
 #if LGE_DVMCP
-Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0 )
+#if QC_SIMPLE_NBDV_B0047
+Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+                                , Bool bParMerge
+#endif
+#else
+Void TComDataCU::getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo, Bool bMerge, RefPicList eRefPicList0, Int iRefIdx0
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+                                , Bool bParMerge
+#endif
+#endif
+                                )
 {
   PartSize eCUMode = getPartitionSize( uiPartAddr );
   TComDataCU* pcTmpCU = NULL;
+#if !QC_SIMPLE_NBDV_B0047
   TComDataCU* pcCULeft = NULL;
+#endif
   pDInfo->iN = 0;
 
@@ -4971,10 +5255,25 @@
   UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
 
-  Int   aiDvMcpDvCand[2][7] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal, DV-MCP ÁÖº¯ ºí·°¿¡¼­ »ç¿ëµÈ DV¸¦ ÀúÀå
+#if QC_SIMPLE_NBDV_B0047
+  const Int iNumofDvMCP = 7;
+  Int   aiDvMcpDvCand[2][iNumofDvMCP] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal
+  Bool  abDvMcpFlag  [2][iNumofDvMCP] = {{false,},{false,}}; 
+#else
+  Int   aiDvMcpDvCand[2][7] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal
   Bool  abDvMcpFlag  [2][7] = {{false,},{false,}}; 
   //Int   aiRefPOC     [2][7] = {{-1,},{-1}}; // debug
+#endif
   TComMv cTmpMvPred, cMv;
   Bool  bTmpIsSkipped = false;
   Bool  bDvMcpIsFound = false;
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+  Int iLCUAddrDiff = 0;
+#endif
+
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  Int xP, yP, nPSW, nPSH;
+  if( bParMerge)
+    this->getPartPosition(uiPartIdx, xP, yP, nPSW, nPSH);
+#endif
 
   deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
@@ -4987,7 +5286,25 @@
   pcTmpCU = getPULeft(uiIdx, uiPartIdxLB);
 #endif
-
+#if DV_DERIVATION_PARALLEL_B0096
+  if ( uiPartIdx == 1 && (eCUMode == SIZE_Nx2N || eCUMode == SIZE_nLx2N || eCUMode == SIZE_nRx2N) )
+  {
+    pcTmpCU = NULL;
+  }
+#endif
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP -1, yP+nPSH-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+#endif
+
+#if !QC_SIMPLE_NBDV_B0047
   pcCULeft = pcTmpCU;
   UInt uiLeftPartIdx = uiIdx;
+#endif
+
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
   {
@@ -5027,7 +5344,25 @@
   pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT);
 #endif
+#if DV_DERIVATION_PARALLEL_B0096
+  if ( uiPartIdx == 1 && (eCUMode == SIZE_2NxN || eCUMode == SIZE_2NxnU || eCUMode == SIZE_2NxnD) )
+  {
+    pcTmpCU = NULL;
+  }
+#endif
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP+nPSW-1, yP-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+#endif
 
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
   {
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
+#endif
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -5046,5 +5381,9 @@
           return;
         }
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+        else if(iLCUAddrDiff == 0) //MCP, within same LCU
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5065,6 +5404,19 @@
   pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, true, true);
 #endif
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP+nPSW, yP-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+#endif
+
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
   {
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
+#endif
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -5083,5 +5435,9 @@
           return;
         }
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+        else if(iLCUAddrDiff == 0)
+#else
         else  // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5101,4 +5457,13 @@
 #else
   pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB);
+#endif
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  if (pcTmpCU && bParMerge)
+  {
+    if (!pcTmpCU->isDiffMER(xP-1, yP+nPSH, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
@@ -5141,6 +5506,19 @@
   pcTmpCU = getPUAboveLeft(uiIdx, uiPartIdxLT, true, true, true);
 #endif
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP-1, yP-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+#endif
+
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
   {
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
+#endif
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -5159,5 +5537,9 @@
           return;
         }
+#if LGE_DVMCP_MEM_REDUCTION_B0135
+        else if(iLCUAddrDiff <= 1)
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5176,4 +5558,5 @@
   if ( getSlice()->getPPS()->getEnableTMVPFlag() )
   {
+#if !QC_SIMPLE_NBDV_B0047
     UInt uiPUIdx = uiPartIdx;
     UInt uiAbsPartAddr = uiPartAddr;
@@ -5333,9 +5716,105 @@
       }
     }
+#else
+    TComMv cColMv;
+    Int iTargetViewIdx = 0;
+    Int iTStartViewIdx = 0;
+    UInt uiPartIdxRB, uiBRIdx;
+    Int uiViewIdxCurr= getSlice()->getViewId();
+    UInt uiPartIdxCenter;
+    xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter );
+
+    Int uiLCUIdx = getAddr();
+    Int uiLCUnew = uiLCUIdx;
+    eCUMode = getPartitionSize( 0 );
+    deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB );  
+    uiBRIdx = uiPartIdxLT;
+    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+    if ( (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) &&(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ))  // image boundary check
+    {
+      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
+      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+      {
+        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+      }
+      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+      {
+        uiBRIdx = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
+        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU();
+      }
+      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+      {
+        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+        uiLCUnew = uiLCUIdx + 1;
+      }
+      else //is the right bottom corner of LCU                       
+      {
+        uiBRIdx = 0;
+        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU() + 1;
+      }
+    }
+    const Int iNumofCandPic = 2;
+    for(Int i =0; i < iNumofCandPic; i++)
+    {
+      Int lpRef=0;
+      if(i == 0)
+      {   //check the col-located picture
+        eRefPicList = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
+#if COLLOCATED_REF_IDX
+        lpRef = getSlice()->getColRefIdx();
+#else
+        Int lpRef = 0;
+#endif
+      }
+      else
+      {
+        if(!(getPic()->getRapbCheck()))
+          break;
+        eRefPicList=getPic()->getRapRefList();
+        lpRef=getPic()->getRapRefIdx();
+      }
+
+      if( m_pcSlice->getViewId() == getSlice()->getRefPic( eRefPicList, lpRef)->getViewId() ) 
+      {
+        if (uiViewIdxCurr > 1)  
+        {
+          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
+          {
+            clipMv(cColMv);
+            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+            return ;
+          }
+        }
+
+        if(xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx ))
+        {
+          clipMv(cColMv);
+          pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+          pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+          return ;
+        }
+        if(uiViewIdxCurr == 1)  
+        {
+          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) ) 
+          {
+            clipMv(cColMv);
+            pDInfo->m_acMvCand[pDInfo->iN] = cColMv;
+            pDInfo->m_aVIdxCan[pDInfo->iN++] = iTargetViewIdx;
+            return ;
+          }
+        }
+      }
+    }
+#endif
   } // if TMVP Flag
 
   if( bDvMcpIsFound ) // skip dvmcp
   {
+#if QC_SIMPLE_NBDV_B0047 
+    for( Int i=1 ; i<iNumofDvMCP-1 ; i++ ) // 5 spatial
+#else
     for( Int i=1 ; i<7 ; i++ ) // 5 spatial + 1 temporal
+#endif
     {
       for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -5353,10 +5832,7 @@
     }
   }
-
   return;
-
-}
-#endif
-
+}
+#endif
 #endif
 
@@ -5368,5 +5844,76 @@
  * \param pInfo
  */
+#if SHARP_INTERVIEW_DECOUPLE_B0111
+Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo, Int iMVPIdx)
+{
+  if (!m_pcSlice->getSPS()->getViewId() || !m_pcSlice->getSPS()->getMultiviewMvPredMode())
+  {
+    // HEVC
+    fillMvpCandBase(uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pInfo);
+  }
+  else
+  {
+    if (iMVPIdx!=0)
+    {
+      // HEVC part
+      fillMvpCandBase(uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pInfo);
+      if (iRefIdx < 0)
+      {
+        return;
+      }
+      for (Int j = AMVP_MAX_NUM_CANDS - 1; j >= 0; j--)
+      {
+        pInfo->m_acMvCand[j+1] = pInfo->m_acMvCand[j];
+      }
+      pInfo->iN++;
+    }
+    if (iMVPIdx<=0)
+    {
+      // extention part
+      DisInfo cDisInfo;
+      cDisInfo.iN = 0;
+#if LGE_DVMCP
+#if QC_SIMPLE_NBDV_B0047
+#if FIX_LGE_IVMP_PARALLEL_MERGE_B0136
+      getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false); 
+#else
+      getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo); 
+#endif
+#else
+      getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false, eRefPicList, iRefIdx );
+#endif
+#else
+      getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo );
+#endif
+      if(cDisInfo.iN==0)
+      {
+        cDisInfo.iN = 1;
+        cDisInfo.m_acMvCand[0].setHor(0);
+        cDisInfo.m_acMvCand[0].setVer(0);
+        cDisInfo.m_aVIdxCan[0] = 0;
+      }
+      TComMv  cPdmMvPred;
+#if QC_MULTI_DIS_CAN
+      if( getPdmMvPredDisCan( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred, &cDisInfo ) )
+#else
+      if( getPdmMvPred( uiPartIdx, eRefPicList, iRefIdx, cPdmMvPred ) )
+#endif
+      {
+        clipMv( cPdmMvPred );
+        pInfo->m_acMvCand[0] = cPdmMvPred;
+      }
+      else
+      {
+        pInfo->m_acMvCand[0].set(0,0);
+      }
+    }
+  }
+}
+
+
+Void TComDataCU::fillMvpCandBase( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo )
+#else
 Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo )
+#endif
 {
   PartSize eCUMode = getPartitionSize( 0 );
@@ -5381,5 +5928,5 @@
   }
   
-#if QC_MULTI_DIS_CAN
+#if QC_MULTI_DIS_CAN && !SHARP_INTERVIEW_DECOUPLE_B0111
   DisInfo cDisInfo;
   cDisInfo.iN = 0;
@@ -5387,5 +5934,13 @@
   {
 #if LGE_DVMCP
+#if QC_SIMPLE_NBDV_B0047 
+#if FIX_LGE_IVMP_PARALLEL_MERGE_B0136
+    getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false);
+#else
+    getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo);
+#endif
+#else
     getDisMvpCand2(uiPartIdx, uiPartAddr, &cDisInfo, false, eRefPicList, iRefIdx );
+#endif
 #else
     getDisMvpCand (uiPartIdx, uiPartAddr, &cDisInfo );
@@ -5400,5 +5955,5 @@
   }
 #endif 
-#if HHI_INTER_VIEW_MOTION_PRED
+#if HHI_INTER_VIEW_MOTION_PRED && !SHARP_INTERVIEW_DECOUPLE_B0111
 #if ( PDM_AMVP_POS == 0 )
   // get inter-view mv predictor (at position 0)
@@ -5459,5 +6014,5 @@
   }
 
-#if HHI_INTER_VIEW_MOTION_PRED
+#if HHI_INTER_VIEW_MOTION_PRED && !SHARP_INTERVIEW_DECOUPLE_B0111
 #if ( PDM_AMVP_POS == 1 )
   // get inter-view mv predictor (at position 1)
@@ -5511,5 +6066,5 @@
   }
 
-#if HHI_INTER_VIEW_MOTION_PRED
+#if HHI_INTER_VIEW_MOTION_PRED && !SHARP_INTERVIEW_DECOUPLE_B0111
 #if ( PDM_AMVP_POS == 2 )
   // get inter-view mv predictor (at position 2)
@@ -5535,5 +6090,5 @@
     }
   }
-#if  QC_MULTI_DIS_CAN
+#if QC_MULTI_DIS_CAN && !SHARP_INTERVIEW_DECOUPLE_B0111
   if ( getSlice()->getViewId()!=0 && pInfo->iN == 3 )
   {
@@ -5609,4 +6164,7 @@
     if ( uiLCUIdx >= 0 && xGetColMVP( eRefPicList, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx_Col ) )
     {
+#if FIX_LGE_DVMCP_B0133
+      cColMv.m_bDvMcp = false;
+#endif
       pInfo->m_acMvCand[pInfo->iN++] = cColMv;
     }
@@ -5618,4 +6176,7 @@
       if (xGetColMVP( eRefPicList, uiCurLCUIdx, uiPartIdxCenter,  cColMv, iRefIdx_Col ))
       {
+#if FIX_LGE_DVMCP_B0133
+        cColMv.m_bDvMcp = false;
+#endif
         pInfo->m_acMvCand[pInfo->iN++] = cColMv;
       }
@@ -5624,5 +6185,5 @@
   }
 
-#if HHI_INTER_VIEW_MOTION_PRED
+#if HHI_INTER_VIEW_MOTION_PRED && !SHARP_INTERVIEW_DECOUPLE_B0111
 #if ( PDM_AMVP_POS == 3 )
   // get inter-view mv predictor (at position 3)
@@ -5645,5 +6206,5 @@
 #endif
 
-#if HHI_INTER_VIEW_MOTION_PRED
+#if HHI_INTER_VIEW_MOTION_PRED && !SHARP_INTERVIEW_DECOUPLE_B0111
   const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
   if (pInfo->iN > iNumAMVPCands)
@@ -6067,5 +6628,5 @@
 Bool TComDataCU::xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv , Int & iTargetViewIdx, Int & iStartViewIdx )
 {
-#if LGE_DVMCP
+#if LGE_DVMCP && !QC_SIMPLE_NBDV_B0047
   Int  iDvMcpDispX[2] = {-1,};
   Bool bDvMcpFlag [2] = { false, }; 
@@ -6086,5 +6647,5 @@
     return false;
   }
-#if LGE_DVMCP
+#if LGE_DVMCP && !QC_SIMPLE_NBDV_B0047
   Bool bColIsSkipped = pColCU->isSkipped( uiAbsPartAddr );
 #endif
@@ -6110,5 +6671,5 @@
     if ( iColViewIdx    == iColRefViewIdx ) // temporal vector
     {
-#if LGE_DVMCP
+#if LGE_DVMCP && !QC_SIMPLE_NBDV_B0047
       if( iColViewIdx >0 )
       {
@@ -6137,5 +6698,5 @@
   }
 
-#if LGE_DVMCP
+#if LGE_DVMCP && !QC_SIMPLE_NBDV_B0047
   for( Int ilist=0 ; ilist<2 ; ilist++ )
   {
@@ -7228,9 +7789,17 @@
 #else
 Int
-TComDataCU::getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
+TComDataCU::getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo 
+#if QC_MRG_CANS_B0048
+  , Int* iPdm
+#endif
+)
 {
   TComDepthMapGenerator* pcDepthMapGenerator = m_pcSlice->getSPS()->getDepthMapGenerator();
   ROFRS( pcDepthMapGenerator, 0 );
-  return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv, pDInfo );
+  return pcDepthMapGenerator->getPdmMergeCandidate( this, uiPartIdx, paiPdmRefIdx, pacPdmMv, pDInfo 
+#if QC_MRG_CANS_B0048
+    , iPdm
+#endif
+    );
 }
 Bool
@@ -7271,5 +7840,13 @@
   m_pePartSize[0] =  SIZE_2Nx2N;
 #if LGE_DVMCP
+#if QC_SIMPLE_NBDV_B0047
+#if FIX_LGE_IVMP_PARALLEL_MERGE_B0136
+  getDisMvpCand2( 0, 0,  &cDisInfo, false);
+#else
+  getDisMvpCand2( 0, 0,  &cDisInfo);
+#endif
+#else
   getDisMvpCand2( 0, 0,  &cDisInfo, true );
+#endif
 #else
   getDisMvpCand        ( 0, 0,  &cDisInfo );
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 185)
@@ -239,5 +239,9 @@
   Bool          m_bDecSubCu;          ///< indicates decoder-mode
   Double        m_dTotalCost;         ///< sum of partition RD costs
+#if FIX_RDO_NEGDIST
+  Dist          m_uiTotalDistortion;  ///< sum of partition distortion
+#else
   UInt          m_uiTotalDistortion;  ///< sum of partition distortion
+#endif
   UInt          m_uiTotalBits;        ///< sum of partition bits
   UInt          m_uiTotalBins;       ///< sum of partition bins
@@ -543,8 +547,24 @@
 #else
   Bool          getPdmMvPredDisCan( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge = false );
-  Int           getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
+  Int           getPdmMergeCandidateDisCan( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo 
+#if QC_MRG_CANS_B0048
+    , Int* iPdm
+#endif
+  );
   Void          getDisMvpCand        ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo );
 #if LGE_DVMCP
-  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo, Bool bMerge=false, RefPicList eRefPicList=REF_PIC_LIST_X, Int iRefIdx=-1 );
+#if QC_SIMPLE_NBDV_B0047
+  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+    , Bool bParMerg = false
+#endif
+    );
+#else
+  Void          getDisMvpCand2( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo, Bool bMerge=false, RefPicList eRefPicList=REF_PIC_LIST_X, Int iRefIdx=-1
+#if LGE_IVMP_PARALLEL_MERGE_B0136
+    , Bool bParMerg = false
+#endif
+    );
+#endif
 #endif
 
@@ -594,5 +614,10 @@
   
   AMVP_MODE     getAMVPMode           ( UInt uiIdx );
+#if SHARP_INTERVIEW_DECOUPLE_B0111
+  Void          fillMvpCandBase       ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
+  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo , Int iMVPIdx=-1);
+#else
   Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
+#endif
 #if PARALLEL_MERGE 
   Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
@@ -717,5 +742,9 @@
   
   Double&       getTotalCost()                  { return m_dTotalCost;        }
+#if FIX_RDO_NEGDIST
+  Dist&         getTotalDistortion()            { return m_uiTotalDistortion; }
+#else
   UInt&         getTotalDistortion()            { return m_uiTotalDistortion; }
+#endif
   UInt&         getTotalBits()                  { return m_uiTotalBits;       }
   UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 185)
@@ -607,5 +607,9 @@
 #if QC_MULTI_DIS_CAN
 Int
-TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo )
+TComDepthMapGenerator::getPdmMergeCandidate( TComDataCU* pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo 
+#if QC_MRG_CANS_B0048
+  , Int* iPdm
+#endif
+)
 #else
 Int
@@ -626,5 +630,9 @@
   ROTRS( !bPdmMerge, 0 );
 
+#if QC_MRG_CANS_B0048
+  Bool abPdmAvailable[4] = {false, false, false, false};
+#else
   Bool abPdmAvailable[2] = {false,false};
+#endif
 
   Int iValid = 0;
@@ -725,7 +733,10 @@
   }
   Int iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 );
-
+#if QC_MRG_CANS_B0048
+  iPdm[0] = iPdmInterDir;
+#else
   if (iPdmInterDir == 0)
   {
+#endif
     for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
     {
@@ -736,6 +747,11 @@
         if( pcSlice->getRefPOC( eRefPicList, iPdmRefIdx ) == pcSlice->getPOC())
         {
+#if QC_MRG_CANS_B0048
+          abPdmAvailable[ iRefListId+2 ] = true;
+          paiPdmRefIdx  [ iRefListId+2 ] = iPdmRefIdx;
+#else
           abPdmAvailable[ iRefListId ] = true;
           paiPdmRefIdx  [ iRefListId ] = iPdmRefIdx;
+#endif
 #if QC_MULTI_DIS_CAN
           TComMv cMv = pDInfo->m_acMvCand[0]; 
@@ -745,11 +761,20 @@
 #endif
           pcCU->clipMv( cMv );
+#if QC_MRG_CANS_B0048
+          pacPdmMv      [ iRefListId + 2] = cMv;
+#else
           pacPdmMv      [ iRefListId ] = cMv;
+#endif
           break;
         }
       }
     }
+#if QC_MRG_CANS_B0048
+    iPdmInterDir = ( abPdmAvailable[2] ? 1 : 0 ) + ( abPdmAvailable[3] ? 2 : 0 ) ;
+    iPdm[1] = iPdmInterDir;
+#else
     iPdmInterDir = ( abPdmAvailable[0] ? 1 : 0 ) + ( abPdmAvailable[1] ? 2 : 0 ) ;
   }
+#endif
 
   return iPdmInterDir;
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.h	(revision 185)
@@ -152,5 +152,10 @@
 #if HHI_INTER_VIEW_MOTION_PRED
 #if QC_MULTI_DIS_CAN
-  Int   getPdmMergeCandidate ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo );
+  Int   getPdmMergeCandidate ( TComDataCU*   pcCU, UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo 
+#if QC_MRG_CANS_B0048
+    , Int* iPdm
+#endif
+    );
+
   Bool  getPdmMvPredDisCan    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
   Bool  getDisCanPdmMvPred    ( TComDataCU*   pcCU, UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv, DisInfo* pDInfo, Bool bMerge );
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 185)
@@ -94,4 +94,10 @@
   Int getHor   () const { return  m_acMv.getHor(); }
   Int getVer   () const { return  m_acMv.getVer(); }
+#if QC_MRG_CANS_B0048
+  Bool operator== ( const TComMvField& rcMv ) const
+  {
+    return (m_acMv.getHor()==rcMv.getHor() && m_acMv.getVer()==rcMv.getVer() && m_iRefIdx == rcMv.getRefIdx());
+  }
+#endif
 };
 
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 185)
@@ -84,4 +84,10 @@
   m_bReduceBitsQTL    = 0;
 #endif
+#if QC_SIMPLE_NBDV_B0047
+  m_bRapCheck = false;
+  m_eRapRefList = REF_PIC_LIST_0;
+  m_uiRapRefIdx = 0;
+#endif
+
 }
 
@@ -483,4 +489,70 @@
   }
 }
+#if QC_SIMPLE_NBDV_B0047
+Bool TComPic::getDisCandRefPictures(Int iColPOC)
+{
+  UInt uiTempLayerCurr=7;
+  TComSlice* currSlice = getCurrSlice();
+  UInt iPOCCurr=currSlice->getPOC();
+  UInt iPOCDiff = 255;
+  Bool  bRAP=false;
+  Bool bCheck = false;
+  Int MaxRef = currSlice->getNumRefIdx(RefPicList(0));
+  RefPicList eRefPicList = REF_PIC_LIST_0 ;
+  if(currSlice->isInterB())
+  {
+    if(currSlice->getNumRefIdx(RefPicList(0))< currSlice->getNumRefIdx(RefPicList(1)))
+      MaxRef = currSlice->getNumRefIdx(RefPicList(1));
+  }
+  for(Int lpRef = 0; lpRef < MaxRef; lpRef++)
+  {
+    for(Int lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
+    {
+      eRefPicList = RefPicList(0);
+      if(currSlice->isInterB())
+        eRefPicList = RefPicList(lpNr==0 ? (currSlice->getColDir()): (1-currSlice->getColDir()));
+      if(iColPOC == currSlice->getRefPOC(eRefPicList, lpRef))
+        continue;
+      if(lpRef >= currSlice->getNumRefIdx(eRefPicList)||(currSlice->getViewId() != currSlice->getRefPic( eRefPicList, lpRef)->getViewId()))
+        continue;
+      Int iTempPoc = currSlice->getRefPic(eRefPicList, lpRef)->getPOC();
+      UInt uiTempLayer = currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getTLayer(); 
+      Int iTempDiff = (iTempPoc > iPOCCurr) ? (iTempPoc - iPOCCurr): (iPOCCurr - iTempPoc);
+      bRAP = (currSlice->getRefPic(eRefPicList, lpRef)->getCurrSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV? 1:0);
+      if( bRAP)
+      {
+         bCheck = true;
+         this->setRapRefIdx(lpRef);
+         this->setRapRefList(eRefPicList);
+         return bCheck;
+      }
+      if(uiTempLayerCurr > uiTempLayer)
+      {
+        bCheck = true;
+        if(uiTempLayerCurr == uiTempLayer)
+        {
+          if(iPOCDiff > iTempDiff)
+          {
+            iPOCDiff=iTempDiff;
+            if(iPOCDiff < 255)
+            {
+              this->setRapRefIdx(lpRef);
+              this->setRapRefList(eRefPicList);
+            }
+          }
+        }
+        else
+        {
+          iPOCDiff=iTempDiff;
+          uiTempLayerCurr = uiTempLayer;
+          this->setRapRefIdx(lpRef);
+          this->setRapRefList(eRefPicList);
+        } 
+      }
+    }
+  }
+  return bCheck;
+}
+#endif
 
 #if HHI_INTERVIEW_SKIP
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TComPic.h	(revision 185)
@@ -82,4 +82,9 @@
   Bool          m_checked;
 #endif
+#if QC_SIMPLE_NBDV_B0047
+  UInt        m_uiRapRefIdx;
+  RefPicList  m_eRapRefList;
+  Bool        m_bRapCheck;
+#endif
 #endif
 #if HHI_INTER_VIEW_RESIDUAL_PRED
@@ -172,4 +177,13 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   TComPicYuv*   getResidual()         { return  m_pcResidual; }
+#endif
+#if QC_SIMPLE_NBDV_B0047
+  UInt          getRapRefIdx()                         {return m_uiRapRefIdx;}
+  RefPicList    getRapRefList()                        {return m_eRapRefList;}
+  Void          setRapRefIdx(UInt uiRapRefIdx)         {m_uiRapRefIdx = uiRapRefIdx;}
+  Void          setRapRefList(RefPicList eRefPicList)  {m_eRapRefList = eRefPicList;}
+  Bool          getRapbCheck()                         {return m_bRapCheck;}
+  Void          setRapbCheck(Bool bCheck)              {m_bRapCheck = bCheck;}
+  Bool          getDisCandRefPictures(Int iColPOC);
 #endif
 
Index: branches/HTM-4.1-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 185)
@@ -46,4 +46,5 @@
 #define MTK_UNCONSTRAINED_MVI             1    //JCT3V-B0083
 
+// A
 #define FIXES                             1
 #define POZNAN_CABAC_INIT_FLAG_FIX        1
@@ -60,4 +61,12 @@
 
 
+// B
+#define FIX_LGE_IVMP_PARALLEL_MERGE_B0136 1
+#define TMVP_DEPTH_SWITCH                 1 // related to JCT3V-B0092
+#define FIX_RDO_NEGDIST                   1
+#define FIX_DMM_NEG_DIST                  1
+
+#define DV_DERIVATION_PARALLEL_B0096      1 //JCT3V-B0096, enable parallel derivation of disparity vector
+
 #define LGE_EDGE_INTRA                    1   // JCT2-A0070
 #if LGE_EDGE_INTRA
@@ -80,6 +89,11 @@
     #define DIS_CANS                      1
 #endif                                  
-                                        
+#define QC_SIMPLE_NBDV_B0047              1   //JCT2-B0047
+#define QC_MRG_CANS_B0048                 1   //JCT2-B0048, B0086, B0069
+#if     QC_MRG_CANS_B0048
+#define OL_DISMV_POS_B0069                1   //different pos for dispairty MV candidate, B0069
+#endif
 #define MTK_INTERVIEW_MERGE_A0049         1   //  JCT2-A0049 second part
+#define SHARP_INTERVIEW_DECOUPLE_B0111    1   //  JCT3V-B0111 decoupling inter-view candidate
                                         
 #define LGE_DVMCP                         1   //  JCT2-A0126     
@@ -92,4 +106,6 @@
 #define DVFROM_COL                        6
 #endif
+#define FIX_LGE_DVMCP_B0133               1
+#define LGE_DVMCP_MEM_REDUCTION_B0135     1 
 
 
@@ -134,4 +150,7 @@
 
 #define HHI_MPI                           1   // motion parameter inheritance from texture picture for depth map coding
+#if HHI_MPI
+#define FIX_MPI_B0065                     1   //JCT3V-B0065, fix the MPI bug when RQT is off
+#endif
 #define HHI_MPI_MERGE_POS                 0
 #define HHI_FULL_PEL_DEPTH_MAP_MV_ACC     1   // full-pel mv accuracy for depth maps
@@ -162,7 +181,9 @@
 
 #define PARALLEL_MERGE  1                   //< H0082 parallel merge/skip
+#define LGE_IVMP_PARALLEL_MERGE_B0136     1 //< B0136 support of parallel merge/skip in disparity vector derivation
 #define LOG2_PARALLEL_MERGE_LEVEL_MINUS2  0 //< H0082 parallel merge level 0-> 4x4, 1-> 8x8, 2->16x16, 3->32x32, 4->64x64
 #if PARALLEL_MERGE && LOG2_PARALLEL_MERGE_LEVEL_MINUS2
 #define CU_BASED_MRG_CAND_LIST            1  //< H0240: single merge candidate list for all PUs inside a 8x8 CU conditioned on LOG2_PARALLEL_MERGE_LEVEL_MINUS2 > 0
+#define FIX_CU_BASED_MRG_CAND_LIST_B0136  1  //< B0136 bug fix for CU_BASED_MRG_CAND_LIST
 #endif
 #define MVP_AT_ENTROPYSLICE_BOUNDARY      1  //< H0362 enable motion prediction accross entropy slice boundary
Index: branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 185)
@@ -637,6 +637,22 @@
 {
 #if HHI_MPI
+#if FIX_MPI_B0065
+  if( pcCU->getTextureModeDepth( 0 ) != -1 )
+  {
+    TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
+    if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx))
+    {
+      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
+      pcCU->setPartSizeSubParts( partSize, 0, uiDepth );
+    }
+    else
+    {
+      pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
+    }
+  }
+#else
   if( pcCU->getTextureModeDepth( 0 ) != -1 )
     pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth );
+#endif
 #endif
   
Index: branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 185)
@@ -492,5 +492,9 @@
 #endif
   }
+#if SHARP_INTERVIEW_DECOUPLE_B0111
+  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo, iMVPIdx);
+#else
   pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
+#endif
   pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
   pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
@@ -1009,4 +1013,21 @@
 #endif // !UNIFIED_TRANSFORM_TREE
   }
+
+#if FIX_MPI_B0065
+  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N &&  pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1  )
+  {
+    TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
+    if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx))
+    {
+      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
+      pcCU->setPartSizeSubParts( partSize, uiAbsPartIdx, uiDepth );
+    }
+    else
+    {
+      pcCU->setPartSizeSubParts( SIZE_NxN, uiAbsPartIdx, uiDepth );
+    }
+  }
+#endif
+
 #if UNIFIED_TRANSFORM_TREE
   xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP );
@@ -1014,4 +1035,11 @@
   xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );
 #endif // UNIFIED_TRANSFORM_TREE
+
+#if FIX_MPI_B0065
+  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N &&  pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 )
+  {
+    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );  
+  }
+#endif
 }
 
Index: branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 185)
@@ -312,4 +312,11 @@
 #endif
 
+#if QC_SIMPLE_NBDV_B0047
+    if(pcSlice->getViewId() && pcSlice->getSPS()->getMultiviewMvPredMode())
+    {
+      Int iColPoc = pcSlice->getRefPOC(RefPicList(pcSlice->getColDir()), pcSlice->getColRefIdx());
+      rpcPic->setRapbCheck(rpcPic->getDisCandRefPictures(iColPoc));
+    }
+#endif
 
     m_pcSbacDecoders[0].load(m_pcSbacDecoder);
Index: branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 185)
@@ -2780,5 +2780,18 @@
     rpcTempCU->setTextureModeDepthSubParts( uhTextureModeDepth, 0, uhDepth );
     rpcTempCU->copyTextureMotionDataFrom( pcTextureCU, uhDepth, rpcTempCU->getZorderIdxInCU() );
+#if FIX_MPI_B0065
+    UInt uiAbsPartIdx = rpcTempCU->getZorderIdxInCU();
+    if( rpcTempCU->getDepth(0) > pcTextureCU->getDepth(uiAbsPartIdx))
+    {
+      rpcTempCU->setPartSizeSubParts( SIZE_NxN, 0, uhDepth );
+    }
+    else
+    {
+      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
+      rpcTempCU->setPartSizeSubParts( partSize, 0, uhDepth );
+    }
+#else
     rpcTempCU->setPartSizeSubParts( SIZE_NxN, 0, uhDepth );
+#endif
     for( UInt ui = 0; ui < rpcTempCU->getTotalNumPart(); ui++ )
     {
Index: branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 185)
@@ -1740,4 +1740,20 @@
   }
   
+#if FIX_MPI_B0065
+  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 )
+  {
+    TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() );
+    if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx))
+    {
+      PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx);
+      pcCU->setPartSizeSubParts( partSize, uiAbsPartIdx, uiDepth );
+    }
+    else
+    {
+      pcCU->setPartSizeSubParts( SIZE_NxN, uiAbsPartIdx, uiDepth );
+    }
+  }
+#endif
+
 #if UNIFIED_TRANSFORM_TREE
   UInt temp = 0;
@@ -1748,4 +1764,11 @@
   xEncodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );
 #endif // UNIFIED_TRANSFORM_TREE
+
+#if FIX_MPI_B0065
+  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N &&  pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 )
+  {
+    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );  
+  }
+#endif
 }
 
Index: branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 185)
@@ -719,4 +719,11 @@
 #endif
 
+#if QC_SIMPLE_NBDV_B0047
+      if(pcSlice->getViewId() && pcSlice->getSPS()->getMultiviewMvPredMode())
+      {
+        Int iColPoc = pcSlice->getRefPOC(RefPicList(pcSlice->getColDir()), pcSlice->getColRefIdx());
+        pcPic->setRapbCheck(pcPic->getDisCandRefPictures(iColPoc));
+      }
+#endif
       while(uiNextCUAddr<uiRealEndAddress) // determine slice boundaries
       {
Index: branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 184)
+++ branches/HTM-4.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 185)
@@ -2006,6 +2006,11 @@
   UInt    uiQNumParts    = pcCU->getTotalNumPart() >> 2;
   UInt    uiWidthBit     = pcCU->getIntraSizeIdx(0);
+#if FIX_RDO_NEGDIST
+  Dist    uiOverallDistY = 0;
+  Dist    uiOverallDistC = 0;
+#else
   UInt    uiOverallDistY = 0;
   UInt    uiOverallDistC = 0;
+#endif
   UInt    CandNum;
   Double  CandCostList[ FAST_UDI_MAX_RDMODE_NUM ];
@@ -2144,5 +2149,5 @@
         CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
 
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if (HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX) && !FIX_DMM_NEG_DIST
         if( bTestDmm ) bTestDmm = uiSad ? true : false;
 #endif
@@ -2274,6 +2279,11 @@
     
     UInt    uiBestPUMode  = 0;
+#if FIX_RDO_NEGDIST
+    Dist    uiBestPUDistY = 0;
+    Dist    uiBestPUDistC = 0;
+#else
     UInt    uiBestPUDistY = 0;
     UInt    uiBestPUDistC = 0;
+#endif
     Double  dBestPUCost   = MAX_DOUBLE;
 #if RWTH_SDC_DLT_B0036
@@ -2900,5 +2910,9 @@
  */
 #if CU_BASED_MRG_CAND_LIST
+#if LG_RESTRICTEDRESPRED_M24766
+Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* rpcResiPredYuv, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand )
+#else
 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, UInt& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand )
+#endif
 #else
 #if LG_RESTRICTEDRESPRED_M24766
@@ -3797,5 +3811,9 @@
       UInt uiMRGCost = MAX_UINT;
 #if CU_BASED_MRG_CAND_LIST
+#if LG_RESTRICTEDRESPRED_M24766
+      xMergeEstimation( pcCU, pcOrgYuv, rpcResiPredYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
+#else
       xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
+#endif
 #else
 #if LG_RESTRICTEDRESPRED_M24766
@@ -5484,6 +5502,11 @@
     }
     
+#if FIX_RDO_NEGDIST
+    Dist uiDistU = 0;
+    Dist uiDistV = 0;
+#else
     UInt uiDistU = 0;
     UInt uiDistV = 0;
+#endif
     if( bCodeChroma )
     {
@@ -5523,6 +5546,12 @@
 #endif       
         
+#if FIX_RDO_NEGDIST
+        const Dist uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
+          pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
+
+#else
         const UInt uiNonzeroDistU = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCbAddr( absTUPartIdxC), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
           pcResi->getCbAddr( absTUPartIdxC), pcResi->getCStride(), trWidthC, trHeightC
+#endif
 #if WEIGHTED_CHROMA_DISTORTION
           , true
@@ -5609,7 +5638,11 @@
         m_pcTrQuant->invtransformNxN( TEXT_CHROMA,REG_DCT, pcResiCurrV, m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(), pcCoeffCurrV, trWidthC, trHeightC, scalingListType );
 #endif
-        
+#if FIX_RDO_NEGDIST
+        const Dist uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
+          pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
+#else
         const UInt uiNonzeroDistV = m_pcRdCost->getDistPart( m_pcQTTempTComYuv[uiQTTempAccessLayer].getCrAddr( absTUPartIdxC ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getCStride(),
           pcResi->getCrAddr( absTUPartIdxC ), pcResi->getCStride(), trWidthC, trHeightC
+#endif
 #if WEIGHTED_CHROMA_DISTORTION
                                                    , true
