Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 1317)
@@ -278,4 +278,6 @@
 static const Int  MAX_NUM_VIDEO_SIGNAL_INFO =                     16 ;
 static const Int  MAX_NUM_SCALED_REF_LAYERS =     MAX_NUM_LAYERS - 1 ; 
+static const Int  MAX_NUM_PICS_RPS          =                     16 ; 
+static const Int  MAX_NUM_REF_LAYERS        =                     63 ;  
 #endif
 
@@ -367,4 +369,73 @@
 #endif
 
+#if NH_MV
+static const std::string NALU_TYPE_STR[] = {  
+    "CODED_SLICE_TRAIL_N   ",  // 0
+    "CODED_SLICE_TRAIL_R   ",  // 1
+    "CODED_SLICE_TSA_N     ",  // 2
+    "CODED_SLICE_TSA_R     ",  // 3
+    "CODED_SLICE_STSA_N    ",  // 4
+    "CODED_SLICE_STSA_R    ",  // 5
+    "CODED_SLICE_RADL_N    ",  // 6
+    "CODED_SLICE_RADL_R    ",  // 7
+    "CODED_SLICE_RASL_N    ",  // 8
+    "CODED_SLICE_RASL_R    ",  // 9
+    "RESERVED_VCL_N10      ",
+    "RESERVED_VCL_R11      ",
+    "RESERVED_VCL_N12      ",
+    "RESERVED_VCL_R13      ",
+    "RESERVED_VCL_N14      ",
+    "RESERVED_VCL_R15      ",
+    "CODED_SLICE_BLA_W_LP  ",  // 16
+    "CODED_SLICE_BLA_W_RADL",  // 17
+    "CODED_SLICE_BLA_N_LP  ",  // 18
+    "CODED_SLICE_IDR_W_RADL",  // 19
+    "CODED_SLICE_IDR_N_LP  ",  // 20
+    "CODED_SLICE_CRA       ",  // 21
+    "RESERVED_IRAP_VCL22   ",
+    "RESERVED_IRAP_VCL23   ",
+    "RESERVED_VCL24        ",
+    "RESERVED_VCL25        ",
+    "RESERVED_VCL26        ",
+    "RESERVED_VCL27        ",
+    "RESERVED_VCL28        ",
+    "RESERVED_VCL29        ",
+    "RESERVED_VCL30        ",
+    "RESERVED_VCL31        ",
+    "VPS                   ",   // 32
+    "SPS                   ",   // 33
+    "PPS                   ",   // 34
+    "ACCESS_UNIT_DELIMITER ",   // 35
+    "EOS                   ",   // 36
+    "EOB                   ",   // 37
+    "FILLER_DATA           ",   // 38
+    "PREFIX_SEI            ",   // 39
+    "SUFFIX_SEI            ",   // 40
+    "RESERVED_NVCL41       ",
+    "RESERVED_NVCL42       ",
+    "RESERVED_NVCL43       ",
+    "RESERVED_NVCL44       ",
+    "RESERVED_NVCL45       ",
+    "RESERVED_NVCL46       ",
+    "RESERVED_NVCL47       ",
+    "UNSPECIFIED_48        ",
+    "UNSPECIFIED_49        ",
+    "UNSPECIFIED_50        ",
+    "UNSPECIFIED_51        ",
+    "UNSPECIFIED_52        ",
+    "UNSPECIFIED_53        ",
+    "UNSPECIFIED_54        ",
+    "UNSPECIFIED_55        ",
+    "UNSPECIFIED_56        ",
+    "UNSPECIFIED_57        ",
+    "UNSPECIFIED_58        ",
+    "UNSPECIFIED_59        ",
+    "UNSPECIFIED_60        ",
+    "UNSPECIFIED_61        ",
+    "UNSPECIFIED_62        ",
+    "UNSPECIFIED_63        ",
+    "INVALID               "               
+  };
+#endif
 
 #if NH_3D
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/Debug.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/Debug.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/Debug.cpp	(revision 1317)
@@ -152,10 +152,10 @@
 EnvVar DebugOptionList::ForceLumaMode         ("FORCE_LUMA_MODE",   "0", "Force a particular intra direction for Luma (0-34)"                                             );
 EnvVar DebugOptionList::ForceChromaMode       ("FORCE_CHROMA_MODE", "0", "Force a particular intra direction for chroma (0-5)"                                            );
-
-#if DEBUG_STRING
-EnvVar DebugOptionList::DebugString_Structure ("DEBUG_STRUCTURE",   "3", "Produce output on chosen structure                        bit0=intra, bit1=inter");
-EnvVar DebugOptionList::DebugString_Pred      ("DEBUG_PRED",        "3", "Produce output on prediction data.                        bit0=intra, bit1=inter");
-EnvVar DebugOptionList::DebugString_Resi      ("DEBUG_RESI",        "3", "Produce output on residual data.                          bit0=intra, bit1=inter");
-EnvVar DebugOptionList::DebugString_Reco      ("DEBUG_RECO",        "3", "Produce output on reconstructed data.                     bit0=intra, bit1=inter");
+                                                                      
+#if DEBUG_STRING                                                      
+EnvVar DebugOptionList::DebugString_Structure ("DEBUG_STRUCTURE",   "0", "Produce output on chosen structure                        bit0=intra, bit1=inter");
+EnvVar DebugOptionList::DebugString_Pred      ("DEBUG_PRED",        "0", "Produce output on prediction data.                        bit0=intra, bit1=inter");
+EnvVar DebugOptionList::DebugString_Resi      ("DEBUG_RESI",        "0", "Produce output on residual data.                          bit0=intra, bit1=inter");
+EnvVar DebugOptionList::DebugString_Reco      ("DEBUG_RECO",        "0", "Produce output on reconstructed data.                     bit0=intra, bit1=inter");
 EnvVar DebugOptionList::DebugString_InvTran   ("DEBUG_INV_QT",      "0", "Produce output on inverse-quantiser and transform stages. bit0=intra, bit1=inter");
 #endif
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/NAL.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/NAL.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/NAL.h	(revision 1317)
@@ -98,4 +98,35 @@
         || m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R;
   }
+#if NH_MV
+  Bool isIrap()
+  {
+   return  m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
+        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+        || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP
+        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
+        || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP
+        || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA;
+  }
+
+  Bool isIdr()
+  {
+    return  m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
+         || m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP;
+  }
+
+  Bool isBla()
+  {
+    return  m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
+         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
+         || m_nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP;
+  }
+
+  Bool isCra()
+  {
+   return  m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA; 
+  }
+
+
+#endif
   Bool isSei()
   {
@@ -108,4 +139,10 @@
     return ( (UInt)m_nalUnitType < 32 );
   }
+#if NH_MV
+  Void print( )
+  {
+    std::cout << "Type: " << NALU_TYPE_STR[m_nalUnitType] << " LayerId: " << m_nuhLayerId << " TemporalId: " << m_temporalId; 
+  }
+#endif
 };
 
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp	(revision 1317)
@@ -41,5 +41,7 @@
 #include <string.h>
 #include <memory.h>
-
+#if NH_MV
+#include "TComRom.h" // This is only here, since ENC_DEC_TRACE is currently there. Consider removing when this has changed.
+#endif
 using namespace std;
 
@@ -258,4 +260,14 @@
   m_numBitsRead += uiNumberOfBits;
 
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  if ( g_traceBitsRead )
+  {
+      Bool oldJustDoIt = g_bJustDoIt;
+      g_bJustDoIt = true; 
+      writeToTraceFile( "Bits: ", m_numBitsRead, true );
+      g_bJustDoIt = oldJustDoIt; 
+  }
+#endif
+
   /* NB, bits are extracted from the MSB of each byte. */
   UInt retval = 0;
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComCodingStatistics.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1317)
@@ -102,5 +102,5 @@
   STATS__CABAC_BITS__3D_IC,
 #endif
-#if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
+#if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
   STATS__CABAC_BITS__DELTADC_SIGN_EP,
   STATS__CABAC_BITS__DELTADC_PREFIX,
@@ -174,5 +174,5 @@
     "CABAC_BITS__3D_IC"
 #endif
-#if NH_3D_DMM || NH_3D_SDC_INTRA || H_3D_INTER_SDC
+#if NH_3D_DMM || NH_3D_SDC_INTRA || NH_3D_SDC_INTER
    ,"STATS__CABAC_BITS__DELTADC_SIGN_EP"
    ,"STATS__CABAC_BITS__DELTADC_PREFIX"
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1317)
@@ -2934,5 +2934,5 @@
 }
 
-#if NH_3D_FIX_PRUNING
+#if NH_3D
 Bool TComDataCU::hasEqualMotion( Int dirA, const TComMvField* mvFieldA, Int dirB, const TComMvField* mvFieldB )
 {
@@ -3046,9 +3046,5 @@
       if( !iLoop && ivCandDir[0] > 0)
       {
-#if NH_3D_FIX_PRUNING
         if( hasEqualMotion(tmpDir, tmpMV, m_mergCands[MRG_IVMC].m_uDir, m_mergCands[MRG_IVMC].m_cMvField )) 
-#else
-        if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1])
-#endif
         {
             bRemove                         = true;
@@ -3101,4 +3097,16 @@
   }
 
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  if ( g_traceMergeCandListConst ) 
+  {
+    for (Int i = 0; i<MRG_IVSHIFT+1; i++)
+    {
+      m_mergCands[i].print( i ); 
+    }
+  }
+#endif
+
+
   Int iCount = 0;
   TComMv cZeroMv;
@@ -3156,4 +3164,5 @@
     pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
   }
+
   // copy extMergeCandList to output
   for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
@@ -3161,7 +3170,49 @@
     puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui];
     pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx());
+
     if ( getSlice()->isInterB() )
+    {
       pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx());
-  }
+    }
+  }
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  if ( g_traceMergeCandListConst )
+  {
+    std::cout << std::setfill(' ')                          << std::setw( 15 )
+      <<  "Num"                                             << std::setw( 15 )
+      <<  "Dir "                                            << std::setw( 15 )
+      <<  "L0 RefIdx"                                       << std::setw( 15 )
+      <<  "L0 Hor"                                          << std::setw( 15 )
+      <<  "L0 Ver"                                          << std::setw( 15 )
+      <<  "L1 RefIdx"                                       << std::setw( 15 )
+      <<  "L1 Hor"                                          << std::setw( 15 )
+      <<  "L1 Ver"                                          << std::setw( 15 )
+      << std::endl; 
+
+    // copy extMergeCandList to output
+    for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
+    {
+      UChar curDir        = puhInterDirNeighbours[ui];
+      TComMvField& curf   = pcMvFieldNeighbours[ui<<1];
+      TComMvField& curf2  = pcMvFieldNeighbours[(ui<<1)+1];
+
+      std::cout << std::setfill(' ')                         << std::setw( 15 )
+        << ui                                                << std::setw( 15 )        
+        << (UInt) curDir                                     << std::setw( 15 )    
+        << ((curDir & 1) ? curf.getRefIdx()       : MIN_INT) << std::setw( 15 )
+        << ((curDir & 1) ? curf.getMv().getHor()  : MIN_INT) << std::setw( 15 )
+        << ((curDir & 1) ? curf.getMv().getVer()  : MIN_INT) << std::setw( 15 );
+
+      if ( getSlice()->isInterB() )
+      {      
+        std::cout << ((curDir & 2) ? curf2.getRefIdx() : MIN_INT) << std::setw( 15 )
+          << ((curDir & 1) ? curf2.getMv().getHor()    : MIN_INT) << std::setw( 15 )
+          << ((curDir & 1) ? curf2.getMv().getVer()    : MIN_INT) << std::setw( 15 );
+      }
+      std::cout << std::endl; 
+    }
+  }
+#endif
   numValidMergeCand = iCount;
   assert(iCount == getSlice()->getMaxNumMergeCand());
@@ -3503,9 +3554,5 @@
           continue;
         }
-#if NH_3D_FIX_PRUNING
         if (hasEqualMotion( tmpDir, tmpMV, m_mergCands[MRG_A1+iCnloop].m_uDir, m_mergCands[MRG_A1+iCnloop].m_cMvField ) )
-#else
-        if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1])
-#endif
         {
           m_mergCands[MRG_A1+iCnloop].m_bAvailable = false;
@@ -3581,9 +3628,5 @@
           continue;
         }
-#if NH_3D_FIX_PRUNING
         if (hasEqualMotion(ivCandDir[0], tmpMV, m_mergCands[MRG_A1+i].m_uDir,  m_mergCands[MRG_A1+i].m_cMvField) )
-#else
-        if (ivCandDir[0] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
-#endif
         {
           m_mergCands[MRG_A1+i].m_bAvailable = false;
@@ -3594,9 +3637,5 @@
     else
     {
-#if NH_3D_FIX_PRUNING
       if( hasEqualMotion( ivCandDir[0], tmpMV, m_mergCands[MRG_T].m_uDir, m_mergCands[MRG_T].m_cMvField ) )
-#else
-      if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1])
-#endif
       {
         bRemoveSpa                      = true;
@@ -3647,5 +3686,5 @@
       !bARPFlag &&
 #endif
-#if H_3D || NH_3D_FIX_VSP
+#if NH_3D
       (nPSW + nPSH > 12) &&
 #endif
@@ -3694,9 +3733,5 @@
         continue;
       }
-#if NH_3D_FIX_PRUNING
       if ( hasEqualMotion(ivCandDir[1], tmpMV, m_mergCands[MRG_A1+i].m_uDir, m_mergCands[MRG_A1+i].m_cMvField) )
-#else
-      if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
-#endif
       {
         bRemoveSpa                      = true;
@@ -4852,4 +4887,16 @@
   }
 }
+#if NH_3D
+Void TComDataCU::printMV( )
+{  
+
+  for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
+  {
+    std::cout << "L" << i; 
+    m_acCUMvField[i].print(m_pePredMode);
+  }
+
+}
+#endif
 
 UInt TComDataCU::getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const
@@ -5284,5 +5331,5 @@
 #if NH_3D_NBDV_REF
           TComPic* picDepth = NULL;
-          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());          
+          assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());            
 #if H_3D_FCO_VSP_DONBDV_E0163
           picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
@@ -5627,5 +5674,5 @@
     if(!m_pcSlice->getIsDepth())
     {
-#if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
+#if NH_3D_DBBP
       if (!getDBBPFlag(0))
 #else
@@ -5803,5 +5850,5 @@
       iCurrPosY  += ( iHeight >> 1 );
     }
-#if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
+#if NH_3D_DBBP
     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
 #else
@@ -5878,5 +5925,5 @@
     }
 #if NH_3D_SPIVMP
-#if H_3D_DBBP || NH_3D_ALIGN_SPIVMP_DBBP
+#if NH_3D_DBBP
     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
 #else
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 1317)
@@ -601,4 +601,5 @@
 #if NH_3D
   Void          compressMV            ( Int scale );
+  Void          printMV               ( );
 #else            
   Void          compressMV            ();
@@ -644,5 +645,5 @@
 
   Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
-#if NH_3D_FIX_PRUNING
+#if NH_3D
   Bool          hasEqualMotion              ( Int dirA, const TComMvField* mvFieldA,  Int dirB, const TComMvField* mvFieldB  );
 #endif
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1317)
@@ -44,5 +44,7 @@
 #include "TComPic.h"
 #endif
-
+#if NH_MV
+#include <iomanip>
+#endif
 //! \ingroup TLibCommon
 //! \{
@@ -377,3 +379,66 @@
   }
 }
+
+#if NH_MV
+Void TComCUMvField::print(Char* pePredMode)
+{
+  for ( Int uiPartIdx = 0; uiPartIdx < m_uiNumPartition; uiPartIdx += 1 )
+  {
+    PredMode predMode = static_cast<PredMode>( pePredMode[ uiPartIdx ] );
+
+    if ( predMode == MODE_INTRA)
+    {
+      std::cout << std::setfill(' ') << "(" 
+        << std::setw(3) <<  "   "    << ","
+        << std::setw(3) <<  "   "    << ","
+        << std::setw(3) <<  "   "    << ")";
+    }
+    else
+    {
+      ;
+      std::cout << std::setfill(' ') << "(" 
+        << std::setw(3) <<  (Int) m_piRefIdx[ uiPartIdx ]        << ","
+        << std::setw(3) <<  m_pcMv[ uiPartIdx ].getHor()   << ","
+        << std::setw(3) <<  m_pcMv[ uiPartIdx ].getVer()   << ")";
+    }    
+  }
+}
+
+#if NH_3D_MLC
+Void TComMotionCand::print( Int i )
+{
+  if (i == 0  )
+  {
+
+    std::cout << std::setfill(' ')                          << std::setw( 15 )
+      << "Num"                                              << std::setw( 15 )
+      << "Avai"                                             << std::setw( 15 )
+      << "Dir "                                             << std::setw( 15 )
+      <<  "L0 RefIdx"                                       << std::setw( 15 )
+      <<  "L0 Hor"                                          << std::setw( 15 )
+      <<  "L0 Ver"                                          << std::setw( 15 )
+      <<  "L1 RefIdx"                                       << std::setw( 15 )
+      <<  "L1 Hor"                                          << std::setw( 15 )
+      <<  "L1 Ver"                                          << std::setw( 15 )
+      << "VspFlag"                                          << std::setw( 15 )
+      << "SPIVMPFlag"                                       
+      << std::endl; 
+  }
+
+  std::cout << std::setfill(' ')                                  << std::setw( 15 )
+    << i                                                          << std::setw( 15 )
+    << m_bAvailable                                               << std::setw( 15 )
+    << (UInt) m_uDir                                              << std::setw( 15 )
+    << ((m_uDir & 1) ? m_cMvField[0].getRefIdx()       : MIN_INT) << std::setw( 15 )
+    << ((m_uDir & 1) ? m_cMvField[0].getMv().getHor()  : MIN_INT) << std::setw( 15 )
+    << ((m_uDir & 1) ? m_cMvField[0].getMv().getVer()  : MIN_INT) << std::setw( 15 )
+    << ((m_uDir & 2) ? m_cMvField[1].getRefIdx()       : MIN_INT) << std::setw( 15 )
+    << ((m_uDir & 2) ? m_cMvField[1].getMv().getHor()  : MIN_INT) << std::setw( 15 )
+    << ((m_uDir & 2) ? m_cMvField[1].getMv().getVer()  : MIN_INT) << std::setw( 15 )
+    << m_iVspFlag                                                 << std::setw( 15 )
+    << m_bSPIVMPFlag                                              << std::setw( 15 )
+    << std::endl;
+}
+#endif
+#endif
 //! \}
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1317)
@@ -43,4 +43,5 @@
 #include "CommonDef.h"
 #include "TComMv.h"
+
 //! \ingroup TLibCommon
 //! \{
@@ -188,4 +189,7 @@
   
   Void compress(Char* pePredMode, Int scale); 
+#if NH_MV
+  Void print   (Char* pePredMode);
+#endif
 };
 
@@ -281,5 +285,11 @@
 #endif
   }
+
+
+  Void print( Int i );
+
 };
+
+
 #endif
 
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 1317)
@@ -54,7 +54,4 @@
 , m_bReconstructed                        (false)
 , m_bNeededForOutput                      (false)
-#if NH_MV
-, m_bPicOutputFlag                        (false)
-#endif
 , m_uiCurrSliceIdx                        (0)
 , m_bCheckLTMSB                           (false)
@@ -62,4 +59,5 @@
 , m_layerId                               (0)
 , m_viewId                                (0)
+, m_bPicOutputFlag                        (false)
 #if NH_3D
 , m_viewIndex                             (0)
@@ -82,4 +80,16 @@
   m_eRapRefList       = REF_PIC_LIST_0;
   m_uiRapRefIdx       = 0;
+#endif
+#if NH_MV
+  m_isPocResettingPic = false;   
+  m_hasGeneratedRefPics = false; 
+  m_isFstPicOfAllLayOfPocResetPer = false; 
+  m_decodingOrder     = 0; 
+  m_noRaslOutputFlag  = false;  
+  m_noClrasOutputFlag = false; 
+  m_picLatencyCount   = 0; 
+  m_isGenerated       = false;
+  m_isGeneratedCl833  = false; 
+  m_activatesNewVps   = false; 
 #endif
 }
@@ -185,4 +195,5 @@
   }
 }
+
 
 Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
@@ -231,100 +242,101 @@
 
 #if NH_MV
-Void TComPic::print( Bool legend )
-{
-  if ( legend )
-    std::cout  << std::endl << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            <<  "\t" << "OutMark" <<  "\t" << "OutFlag" << std::endl;
-  else
-    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<std::endl;
-}
-
-TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc )
-{
-  TComPic* pcPic = NULL;
-  for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++)
-  {    
-    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++)
-    {
-      TComPic* currPic = (*itP); 
-      if ( ( currPic->getPOC() == poc ) && ( currPic->getLayerId() == layerIdInNuh ) )
-      {
-        pcPic = currPic ;      
-      }
-    }
-  }
-  return pcPic;
+Bool TComPic::getPocResetPeriodId()
+{
+  return getSlice(0)->getPocResetIdc(); 
+}
+
+Void TComPic::markAsUsedForShortTermReference()
+{
+  getSlice(0)->setReferenced( true );
+  setIsLongTerm( false ); 
+}
+
+Void TComPic::markAsUsedForLongTermReference()
+{
+  getSlice(0)->setReferenced( true );
+  setIsLongTerm( true ); 
+}
+
+
+Void TComPic::markAsUnusedForReference()
+{
+  getSlice(0)->setReferenced( false );
+  setIsLongTerm( false ); 
+}
+
+
+Bool TComPic::getMarkedUnUsedForReference()
+{
+  return !getSlice(0)->isReferenced( );
+}
+
+
+Bool TComPic::getMarkedAsShortTerm()
+{
+  return ( getSlice(0)->isReferenced( ) && !getIsLongTerm() );
+}
+
+Void TComPic::print( Int outputLevel )
+{
+  if ( outputLevel== 0  )
+  {
+    std::cout  << std::endl 
+      << "LId"
+      << "\t" << "POC"
+      << "\t" << "Rec"
+      << "\t" << "Ref"
+      << "\t" << "LT"
+      << "\t" << "OutMark"
+      << "\t" << "OutFlag" 
+      << "\t" << "Type"
+      << "\t" << "PReFlag"
+      << std::endl;
+  }
+  else if( outputLevel == 1  )
+  {
+    std::cout  << getLayerId()
+      << "\t" << getPOC()
+      << "\t" << getReconMark()
+      << "\t" << getSlice(0)->isReferenced()
+      << "\t" << getIsLongTerm()
+      << "\t" << getOutputMark()
+      << "\t" << getSlice(0)->getPicOutputFlag()
+      << "\t" << getSlice(0)->getNalUnitTypeString()
+      << "\t" << getSlice(0)->getPocResetFlag() 
+      << std::endl;
+  }
+  else if ( outputLevel == 2  )
+  {
+    std::cout  << std:: setfill(' ')
+      << " LayerId: "         << std::setw(2) << getLayerId()
+      << "\t"  << " POC: "             << std::setw(5) << getPOC()
+      << "\t"  << " Dec. Order: "      << std::setw(5) << getDecodingOrder()
+      << "\t"  << " Referenced: "      << std::setw(1) << getSlice(0)->isReferenced()
+      << "\t"  << " Pic type: "        <<                 getSlice(0)->getNalUnitTypeString()
+      << "\t"  << " Generated: "       << std::setw(1) << getIsGenerated()
+      << "\t"  << " Gen. Ref. Pics: "  << std::setw(1) << getHasGeneratedRefPics();
+  }
+  else if ( outputLevel == 4  )
+  {
+    std::cout  << std:: setfill(' ')
+      << " LayerId: "         << std::setw(2) << getLayerId()
+      << "\t"  << " POC: "             << std::setw(5) << getPOC()      
+      << "\t"  << " Referenced: "      << std::setw(1) << getSlice(0)->isReferenced() << std::endl; 
+  }
 }
 
 #if NH_3D
-TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
-{
-  return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
-}
-#endif
-Void TComPicLists::print()
-{
-  Bool first = true;     
-  for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++)
-  {    
-    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
-    {
-      if ( first )
-      {
-        (*itP)->print( true );       
-        first = false; 
-      }
-      (*itP)->print( false );       
-    }
-  }
-}
-
-TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag )
-{
-  TComPic*    pcPic = getPic( layerIdInNuh, poc );
-  TComPicYuv* pcPicYuv = NULL;
-
-  if (pcPic != NULL)
-  {
-    if( reconFlag )
-    {
-      if ( pcPic->getReconMark() )
-      {
-        pcPicYuv = pcPic->getPicYuvRec();
-      }
-    }
-    else
-    {
-      pcPicYuv = pcPic->getPicYuvOrg();
-    }
-  };
-
-  return pcPicYuv;
-}
-
-#if NH_3D
-TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
-{  
-  Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag ); 
-  return getPicYuv( layerIdInNuh, poc, recon );
-}
-#if NH_3D_ARP
-TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
-{
-  TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin();
-  Int iLayer = 0;
-
-  assert( layerIdInNuh < m_lists.size() );
-
-  while( iLayer != layerIdInNuh )
-  {
-    itL++;
-    iLayer++;
-  }
-
-  return *itL;
-}
-#endif
-#endif
-#endif // NH_MV
+Void TComPic::printMotion()
+{
+  TComPicSym* pPicSym = getPicSym();
+  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
+  {
+    TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
+    std::cout << "CUAddr " << uiCUAddr << std::endl; 
+    pCtu->printMV();
+    std::cout << std::endl; 
+  }
+}
 
 #if NH_3D_NBDV 
@@ -437,5 +449,11 @@
           m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
           Int iColViewIdx    = pcCandColSlice->getViewIndex();
+#if H_3D_FIX_ARP_CHECK_NOT_IN_DPB
+          // The picture pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx) might not be in DPB anymore
+          // So don't access it directly.
+          Int iColRefViewIdx = pcCandColSlice->getVPS()->getViewOrderIdx( pcCandColSlice->getRefLayerId( (RefPicList)iColRefDir, iColRefIdx ) );       
+#else
           Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex();
+#endif
           if(iColViewIdx == iColRefViewIdx)
           {
@@ -487,7 +505,7 @@
         {
           if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
-             pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
+            pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
           {  
-            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
+            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;            
           }
         }
@@ -504,5 +522,494 @@
 }
 #endif
+#endif
+
+Void TComAu::setPicLatencyCount( Int picLatenyCount )
+{
+  for(TComList<TComPic*>::iterator itP= begin();  itP!= end(); itP++)
+  {      
+    (*itP)->setPicLatencyCount( picLatenyCount ); 
+  }
+}
+
+TComPic* TComAu::getPic( Int nuhLayerId )
+{
+  TComPic* pic = NULL; 
+  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
+  {      
+    if ( (*itP)->getLayerId() == nuhLayerId )
+    {
+      pic = (*itP); 
+    }
+  }
+  return pic;
+}
+
+Void TComAu::addPic( TComPic* pic, Bool pocUnkown )
+{
+  if ( !empty() )
+  {
+    if (!pocUnkown)
+    {
+      assert( pic->getPOC()   == ( getPoc() ));
+    }      
+    pic->setPicLatencyCount( getPicLatencyCount() ); 
+
+    assert( getPic( pic->getLayerId() ) == NULL );
+
+    // Add sorted 
+    TComAu::iterator itP = begin(); 
+    Bool inserted = false; 
+    while( !inserted )
+    {
+      if ( ( itP == end()) || pic->getLayerId() < (*itP)->getLayerId() )
+      {
+        insert(itP, pic ); 
+        inserted = true; 
+      }
+      else
+      {
+        ++itP; 
+      }        
+    }      
+  } 
+  else
+  { 
+    pushBack( pic );      
+  }
+}
+
+Bool TComAu::containsPic( TComPic* pic )
+{
+  Bool isInList = false; 
+  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (!isInList) ); itP++)
+  { 
+    isInList = isInList || ( pic == (*itP)); 
+  }
+  return isInList;
+}
+
+TComSubDpb::TComSubDpb( Int nuhLayerid )
+{
+  m_nuhLayerId = nuhLayerid;
+}
+
+TComPic* TComSubDpb::getPic( Int poc )
+{
+  TComPic* pic = NULL; 
+  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
+  {      
+    if ( (*itP)->getPOC() == poc )
+    {
+      pic = (*itP); 
+    }
+  }
+  return pic;
+}
+
+TComPic* TComSubDpb::getPicFromLsb( Int pocLsb, Int maxPicOrderCntLsb )
+{
+  TComPic* pic = NULL; 
+  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
+  {      
+    if ( ( (*itP)->getPOC() & ( maxPicOrderCntLsb - 1 ) ) == pocLsb )
+    {
+      pic = (*itP); 
+    }
+  }
+  return pic;
+}
+
+TComPic* TComSubDpb::getShortTermRefPic( Int poc )
+{
+  TComPic* pic = NULL; 
+  for(TComList<TComPic*>::iterator itP= begin(); ( itP!= end() && (pic == NULL) ); itP++)
+  {      
+    if ( (*itP)->getPOC() == poc && (*itP)->getMarkedAsShortTerm() )
+    {
+      pic = (*itP); 
+    }
+  }
+  return pic;
+}
+
+TComList<TComPic*> TComSubDpb::getPicsMarkedNeedForOutput()
+{
+  TComList<TComPic*> picsMarkedNeedForOutput; 
+
+  for(TComList<TComPic*>::iterator itP= begin();  itP!= end() ; itP++ )
+  {      
+    if ( (*itP)->getOutputMark() )
+    {
+      picsMarkedNeedForOutput.push_back( (*itP) );
+    }
+  }
+  return picsMarkedNeedForOutput;
+}
+
+Void TComSubDpb::markAllAsUnusedForReference()
+{
+  for(TComList<TComPic*>::iterator itP= begin();  itP!= end() ; itP++ )
+  {      
+    (*itP)->markAsUnusedForReference(); 
+  }
+}
+
+Void TComSubDpb::addPic( TComPic* pic )
+{
+  assert( pic != NULL ); 
+  assert( m_nuhLayerId == pic->getLayerId() || m_nuhLayerId == -1);      
+  if ( !empty() )
+  {
+    assert( getPic( pic->getPOC() ) == NULL ); // Don't add twice; assert( pic->getLayerId() == m_nuhLayerId );            
+
+    // Add sorted 
+    TComSubDpb::iterator itP = begin(); 
+    Bool inserted = false; 
+    while( !inserted )
+    {
+      if ( ( itP == end()) || pic->getPOC() < (*itP)->getPOC() )
+      {
+        insert(itP, pic ); 
+        inserted = true; 
+      }
+      else
+      {
+        ++itP; 
+      }        
+    }      
+  } 
+  else
+  { 
+    pushBack( pic );
+  }
+}
+
+Void TComSubDpb::removePics( std::vector<TComPic*> picToRemove )
+{
+  for (Int i = 0; i < picToRemove.size(); i++ )
+  {
+    if( picToRemove[i] != NULL)
+    {
+      remove( picToRemove[i] ); 
+    }
+  }
+}
+
+Bool TComSubDpb::areAllPicsMarkedNotNeedForOutput()
+{
+  return ( getPicsMarkedNeedForOutput().size() == 0 );
+}
+
+
+TComPicLists::~TComPicLists()
+{
+  emptyAllSubDpbs();
+  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end()); itL++)
+  {      
+    if ( (*itL) != NULL )
+    {
+      delete (*itL); 
+      (*itL) = NULL; 
+    }
+  }
+}
+
+Void TComPicLists::addNewPic( TComPic* pic )
+{
+  getSubDpb ( pic->getLayerId() , true )->addPic( pic ); 
+  getAu     ( pic->getPOC()     , true )->addPic( pic , false ); 
+  if ( m_printPicOutput )
+  {
+    std::cout << "  Add    picture: ";
+    pic->print( 2 );
+    std::cout << std::endl;
+  }
+}
+
+Void TComPicLists::removePic( TComPic* pic )
+{
+  if (pic != NULL)
+  {
+
+    TComSubDpb* curSubDpb = getSubDpb( pic->getLayerId(), false ); 
+    curSubDpb->remove( pic );
+
+    TComAu* curAu = getAu     ( pic->getPOC(), false );       
+
+    if (curAu != NULL)
+    {    
+      curAu->remove( pic );
+      // Remove AU when empty. 
+      if (curAu->empty() )
+      {
+        m_aus.remove( curAu ); 
+        delete curAu; 
+      }
+    }
+
+    if ( m_printPicOutput )
+    {
+      std::cout << "  Remove picture: ";
+      pic->print( 2 );
+      std::cout << std::endl;
+    }
+
+    pic->destroy();
+    delete pic; 
+  }
+}
+
+TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc )
+{
+  TComPic* pcPic = NULL;
+  TComSubDpb* subDpb = getSubDpb( layerIdInNuh, false ); 
+  if ( subDpb != NULL )
+  {
+    pcPic = subDpb->getPic( poc ); 
+  }
+  return pcPic;
+}
+
+TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag )
+{
+  TComPic*    pcPic = getPic( layerIdInNuh, poc );
+  TComPicYuv* pcPicYuv = NULL;
+
+  if (pcPic != NULL)
+  {
+    if( reconFlag )
+    {
+      if ( pcPic->getReconMark() )
+      {
+        pcPicYuv = pcPic->getPicYuvRec();
+      }
+    }
+    else
+    {
+      pcPicYuv = pcPic->getPicYuvOrg();
+    }
+  };
+
+  return pcPicYuv;
+}
+
+TComSubDpb* TComPicLists::getSubDpb( Int nuhLayerId, Bool create )
+{
+  TComSubDpb* subDpb = NULL;
+  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end() && subDpb == NULL ); itL++)
+  {      
+    if ( (*itL)->getLayerId() == nuhLayerId )
+    {        
+      subDpb = (*itL); 
+    }
+  }  
+  if ( subDpb == NULL && create )
+  {
+    m_subDpbs.push_back( new TComSubDpb(nuhLayerId) ); 
+  }
+  return subDpb;
+}
+
+TComList<TComSubDpb*>* TComPicLists::getSubDpbs()
+{
+  return (&m_subDpbs);
+}
+
+TComAu* TComPicLists::addAu( Int poc )
+{
+  TComList<TComAu*>::iterator itA = m_aus.begin(); 
+
+  assert( getAu(poc, false) == NULL );
+  Bool inserted = false; 
+  while( !inserted)
+  {      
+    if ( ( itA == m_aus.end()) || poc < (*itA)->getPoc() )
+    {        
+      m_aus.insert(itA, new TComAu );        
+      inserted = true; 
+      --itA; 
+    }
+    else
+    {
+      ++itA; 
+    }
+  }
+  return (*itA);
+}
+
+TComAu* TComPicLists::getAu( Int poc, Bool create )
+{
+  TComAu* au = NULL;
+
+  for( TComList<TComAu*>::iterator itA = m_aus.begin(); ( itA != m_aus.end() && au == NULL ); itA++)
+  { 
+    if ( (*itA)->getPoc() == poc )
+    {        
+      au = (*itA); 
+    }
+  }  
+
+  if ( au == NULL && create )
+  {
+    au = addAu( poc ); 
+  }
+  return au;
+}
+
+TComList<TComAu*>* TComPicLists::getAus()
+{
+  return (&m_aus);
+}
+
+TComList<TComAu*> TComPicLists::getAusHavingPicsMarkedForOutput()
+{
+  TComList<TComAu*> ausHavingPicsForOutput; 
+  for(TComList<TComAu*>::iterator itA= m_aus.begin(); ( itA!=m_aus.end()); itA++)
+  {
+    Bool hasPicMarkedAsNeedForOutput = false;
+    for( TComAu::iterator itP= (*itA)->begin(); (itP!=(*itA)->end() && !hasPicMarkedAsNeedForOutput); itP++  )
+    {
+      if( (*itP)->getOutputMark() )
+      {
+        hasPicMarkedAsNeedForOutput = true; 
+      }
+    }
+    if (hasPicMarkedAsNeedForOutput)
+    {
+      ausHavingPicsForOutput.pushBack( (*itA) );
+    }
+  }
+  return ausHavingPicsForOutput;
+}
+
+Void TComPicLists::markSubDpbAsUnusedForReference( Int layerIdInNuh )
+{
+  TComSubDpb* subDpb = getSubDpb( layerIdInNuh, false ); 
+  markSubDpbAsUnusedForReference( *subDpb );
+}
+
+Void TComPicLists::markSubDpbAsUnusedForReference( TComSubDpb& subDpb )
+{
+  for(TComList<TComPic*>::iterator itP=subDpb.begin(); ( itP!=subDpb.end()); itP++)
+  {
+    (*itP)->markAsUnusedForReference(); 
+  }
+}
+
+Void TComPicLists::markAllSubDpbAsUnusedForReference()
+{
+  for(TComList<TComSubDpb*>::iterator itS= m_subDpbs.begin(); ( itS!=m_subDpbs.end()); itS++)
+  {
+    markSubDpbAsUnusedForReference( *(*itS) ); 
+  }
+}
+
+Void TComPicLists::decrementPocsInSubDpb( Int nuhLayerId, Int deltaPocVal )
+{
+  TComSubDpb* subDpb = getSubDpb( nuhLayerId, false ); 
+
+  for(TComSubDpb::iterator itP = subDpb->begin(); itP!=subDpb->end(); itP++)
+  {
+    TComPic* pic = (*itP); 
+    for (Int i = 0; i < pic->getNumAllocatedSlice(); i++)
+    {
+      TComSlice* slice = pic->getSlice(i);
+      slice->setPOC( slice->getPOC() - deltaPocVal ); 
+    }    
+  }
+}
+Void TComPicLists::emptyAllSubDpbs()
+{
+  emptySubDpbs( &m_subDpbs );
+}
+
+Void TComPicLists::emptySubDpbs( TComList<TComSubDpb*>* subDpbs )
+{
+  assert( subDpbs != NULL ); 
+  for( TComList<TComSubDpb*>::iterator itS = subDpbs->begin(); itS != subDpbs->end(); itS++ )
+  {
+    emptySubDpb( (*itS) ); 
+  }
+}
+
+Void TComPicLists::emptySubDpb( TComSubDpb* subDpb )
+{
+  if(subDpb != NULL)
+  {
+    while( !subDpb->empty() )
+    {
+      TComPic* curPic = *(subDpb->begin()); 
+      removePic( curPic ); 
+    }
+  }
+}
+
+Void TComPicLists::emptySubDpb( Int nuhLayerId )
+{
+  emptySubDpb( getSubDpb( nuhLayerId , false) );
+}
+
+Void TComPicLists::emptyNotNeedForOutputAndUnusedForRef()
+{
+  for(TComList<TComSubDpb*>::iterator itS= m_subDpbs.begin(); ( itS!=m_subDpbs.end()); itS++)
+  {
+    emptySubDpbNotNeedForOutputAndUnusedForRef( *(*itS) ); 
+  }
+}
+
+Void TComPicLists::emptySubDpbNotNeedForOutputAndUnusedForRef( Int layerId )
+{
+  TComSubDpb* subDpb = getSubDpb( layerId, false ); 
+  emptySubDpbNotNeedForOutputAndUnusedForRef( *subDpb );
+}
+
+Void TComPicLists::emptySubDpbNotNeedForOutputAndUnusedForRef( TComSubDpb subDpb )
+{
+  for(TComSubDpb::iterator itP= subDpb.begin(); ( itP!=subDpb.end()); itP++)
+  {
+    TComPic* pic = (*itP); 
+    if ( !pic->getOutputMark() && pic->getMarkedUnUsedForReference() )
+    {
+      removePic( pic ); 
+    }
+  }
+}
+
+Void TComPicLists::print()
+{
+  Bool first = true;     
+  for(TComList<TComSubDpb*>::iterator itL = m_subDpbs.begin(); ( itL != m_subDpbs.end() ); itL++)
+  {    
+    for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++)
+    {
+      if ( first )
+      {
+        (*itP)->print( true );       
+        first = false; 
+      }
+      (*itP)->print( false );       
+    }
+  }
+}
+
+#if NH_3D
+TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
+{  
+  Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag ); 
+  return getPicYuv( layerIdInNuh, poc, recon );
+}
+
+TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
+{
+  return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
+}
+
+#endif
+
+#endif
+
+
 
 
 //! \}
+
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPic.h	(revision 1317)
@@ -54,4 +54,60 @@
 /// picture class (symbol + YUV buffers)
 
+
+
+#if NH_MV
+class TComPic; 
+
+class TComDecodedRps
+{
+public: 
+
+  TComDecodedRps()
+  {
+    m_refPicSetsCurr[0] = &m_refPicSetStCurrBefore;
+    m_refPicSetsCurr[1] = &m_refPicSetStCurrAfter ;
+    m_refPicSetsCurr[2] = &m_refPicSetLtCurr      ; 
+
+    m_refPicSetsLt  [0] = &m_refPicSetLtCurr      ; 
+    m_refPicSetsLt  [1] = &m_refPicSetLtFoll      ;
+
+    m_refPicSetsAll [0] = &m_refPicSetStCurrBefore;
+    m_refPicSetsAll [1] = &m_refPicSetStCurrAfter ;
+    m_refPicSetsAll [2] = &m_refPicSetStFoll      ;
+    m_refPicSetsAll [3] = &m_refPicSetLtCurr      ;
+    m_refPicSetsAll [4] = &m_refPicSetLtFoll      ;
+  };    
+
+  std::vector<Int>       m_pocStCurrBefore;
+  std::vector<Int>       m_pocStCurrAfter;
+  std::vector<Int>       m_pocStFoll;    
+  std::vector<Int>       m_pocLtCurr;
+  std::vector<Int>       m_pocLtFoll; 
+
+  Int                    m_numPocStCurrBefore;
+  Int                    m_numPocStCurrAfter;
+  Int                    m_numPocStFoll;
+  Int                    m_numPocLtCurr;
+  Int                    m_numPocLtFoll;
+
+  std::vector<TComPic*>  m_refPicSetStCurrBefore; 
+  std::vector<TComPic*>  m_refPicSetStCurrAfter; 
+  std::vector<TComPic*>  m_refPicSetStFoll; 
+  std::vector<TComPic*>  m_refPicSetLtCurr; 
+  std::vector<TComPic*>  m_refPicSetLtFoll;   
+
+  std::vector<TComPic*>* m_refPicSetsCurr[3];
+  std::vector<TComPic*>* m_refPicSetsLt  [2];
+  std::vector<TComPic*>* m_refPicSetsAll [5];
+
+  // Annex F
+  Int                    m_numActiveRefLayerPics0;
+  Int                    m_numActiveRefLayerPics1;     
+
+  std::vector<TComPic*>  m_refPicSetInterLayer0;
+  std::vector<TComPic*>  m_refPicSetInterLayer1;
+};
+#endif
+
 class TComPic
 {
@@ -72,7 +128,5 @@
   Bool                  m_bReconstructed;
   Bool                  m_bNeededForOutput;
-#if NH_MV
-  Bool                  m_bPicOutputFlag;         // Semantics variable 
-#endif
+
   UInt                  m_uiCurrSliceIdx;         // Index of current slice
   Bool                  m_bCheckLTMSB;
@@ -87,4 +141,17 @@
   Int                   m_layerId;
   Int                   m_viewId;
+  Bool                  m_bPicOutputFlag;                // Semantics variable 
+  Bool                  m_hasGeneratedRefPics; 
+  Bool                  m_isPocResettingPic; 
+  Bool                  m_isFstPicOfAllLayOfPocResetPer; 
+  Int64                 m_decodingOrder; 
+  Bool                  m_noRaslOutputFlag; 
+  Bool                  m_noClrasOutputFlag; 
+  Int                   m_picLatencyCount; 
+  Bool                  m_isGenerated;
+  Bool                  m_isGeneratedCl833; 
+  Bool                  m_activatesNewVps;
+  TComDecodedRps        m_decodedRps;
+#endif
 #if NH_3D
   Int                   m_viewIndex;
@@ -92,17 +159,15 @@
   Int**                 m_aaiCodedScale;
   Int**                 m_aaiCodedOffset;
-#endif
-#endif
 #if NH_3D_QTLPC
   Bool                  m_bReduceBitsQTL;
 #endif
 #if NH_3D_NBDV
-  UInt        m_uiRapRefIdx;
-  RefPicList  m_eRapRefList;
-  Int         m_iNumDdvCandPics;
-  Bool        m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
-  Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
-#endif
-
+  UInt                   m_uiRapRefIdx;
+  RefPicList             m_eRapRefList;
+  Int                    m_iNumDdvCandPics;
+  Bool                   m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
+  Int                    m_aiTexToDepRef  [2][MAX_NUM_REF];
+#endif
+#endif
 public:
   TComPic();
@@ -115,25 +180,4 @@
   UInt          getTLayer() const               { return m_uiTLayer;   }
   Void          setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; }
-#if NH_MV
-  Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
-  Int           getLayerId            ()                 { return m_layerId;    }
-  Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
-  Int           getViewId             ()                 { return m_viewId;     }
-#if NH_3D
-  Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
-  Int           getViewIndex          ()                 { return m_viewIndex;     }
-
-  Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
-  Bool          getIsDepth            ()                 { return m_isDepth; }
-
-  Void          setScaleOffset( Int** pS, Int** pO )  { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
-  Int**         getCodedScale ()                      { return m_aaiCodedScale;  }
-  Int**         getCodedOffset()                      { return m_aaiCodedOffset; }
-#endif
-#endif
-#if NH_3D_QTLPC
-  Bool          getReduceBitsFlag ()             { return m_bReduceBitsQTL;     }
-  Void          setReduceBitsFlag ( Bool bFlag ) { m_bReduceBitsQTL = bFlag;    }
-#endif
 
   Bool          getUsedByCurr() const            { return m_bUsedByCurr; }
@@ -177,14 +221,6 @@
   Void          setOutputMark (Bool b) { m_bNeededForOutput = b;     }
   Bool          getOutputMark () const      { return m_bNeededForOutput;  }
- #if NH_MV
-  Void          setPicOutputFlag(Bool b) { m_bPicOutputFlag = b;      }
-  Bool          getPicOutputFlag()       { return m_bPicOutputFlag ;  }
-#endif
-#if NH_3D
-#if NH_3D_ARP
-  Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
-#endif
-  Void          compressMotion(Int scale); 
-#else   
+
+#if !NH_3D
   Void          compressMotion();
 #endif
@@ -210,18 +246,102 @@
 
 #if NH_MV
-  Void          print( Bool legend );
+   Void          setLayerId            ( Int layerId )    { m_layerId      = layerId; }
+   Int           getLayerId            ()                 { return m_layerId;    }
+   
+   Void          setViewId             ( Int viewId )     { m_viewId = viewId;   }
+   Int           getViewId             ()                 { return m_viewId;     }
+
+   Void          setPicOutputFlag(Bool b)                 { m_bPicOutputFlag = b;      }
+   Bool          getPicOutputFlag()                       { return m_bPicOutputFlag ;  }
+
+   Bool          getPocResetPeriodId();
+
+   Void          markAsUsedForShortTermReference();
+   Void          markAsUsedForLongTermReference(); 
+   Void          markAsUnusedForReference(); 
+
+   Bool          getMarkedUnUsedForReference();
+   Bool          getMarkedAsShortTerm();
+
+   Void          setHasGeneratedRefPics(Bool val)       { m_hasGeneratedRefPics  = val;    }
+   Bool          getHasGeneratedRefPics( )              { return m_hasGeneratedRefPics;   }
+
+   Void          setIsPocResettingPic(Bool val)         { m_isPocResettingPic = val;    }
+   Bool          getIsPocResettingPic( )                { return m_isPocResettingPic;   }
+
+   Void          setIsFstPicOfAllLayOfPocResetPer(Bool val) { m_isFstPicOfAllLayOfPocResetPer = val;  }
+   Bool          getIsFstPicOfAllLayOfPocResetPer( )        { return m_isFstPicOfAllLayOfPocResetPer; }
+
+   Int64         getDecodingOrder( )                    { return m_decodingOrder;       }
+   Void          setDecodingOrder( UInt64 val  )        { m_decodingOrder = val;        }
+
+   Bool          getNoRaslOutputFlag()                  { return m_noRaslOutputFlag;     }
+   Void          setNoRaslOutputFlag( Bool b )          { m_noRaslOutputFlag = b;        }
+
+   Bool          getNoClrasOutputFlag()                 { return m_noClrasOutputFlag;    }
+   Void          setNoClrasOutputFlag( Bool b )         { m_noClrasOutputFlag = b;       }
+
+   Int           getPicLatencyCount()                   { return m_picLatencyCount;      }
+   Void          setPicLatencyCount( Int val )          { m_picLatencyCount = val;       }
+
+   Bool          getIsGenerated() const                 { return m_isGenerated;          }
+   Void          setIsGenerated( Bool b )               { m_isGenerated = b;             }
+
+   Bool          getIsGeneratedCl833() const            { return m_isGeneratedCl833;     }
+   Void          setIsGeneratedCl833( Bool b )          { m_isGeneratedCl833 = b;        }
+
+   Int           getTemporalId( )                       { return getSlice(0)->getTemporalId(); }
+
+   Bool          getActivatesNewVps()                   { return m_activatesNewVps;      }
+   Void          setActivatesNewVps( Bool b )           { m_activatesNewVps = b;         }
+
+   TComDecodedRps* getDecodedRps()                      { return &m_decodedRps;          }
+
+   Bool          isIrap()                               { return getSlice(0)->isIRAP(); } 
+   Bool          isBla ()                               { return getSlice(0)->isBla (); } 
+   Bool          isIdr ()                               { return getSlice(0)->isIdr (); } 
+   Bool          isCra ()                               { return getSlice(0)->isCra (); } 
+   Bool          isSlnr ()                              { return getSlice(0)->isSlnr (); }
+   Bool          isRasl ()                              { return getSlice(0)->isRasl (); }
+   Bool          isRadl ()                              { return getSlice(0)->isRadl (); }
+   Bool          isStsa ()                              { return getSlice(0)->isStsa (); }
+   Bool          isTsa ()                               { return getSlice(0)->isTsa  (); }
+
+   Void          print( Int outputLevel );
+
+#if NH_3D
+   Void          setViewIndex          ( Int viewIndex )  { m_viewIndex = viewIndex;   }
+   Int           getViewIndex          ()                 { return m_viewIndex;     }
+
+   Void          setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
+   Bool          getIsDepth            ()                 { return m_isDepth; }
+
+   Void          setScaleOffset( Int** pS, Int** pO )     { m_aaiCodedScale = pS; m_aaiCodedOffset = pO; }
+   Int**         getCodedScale ()                         { return m_aaiCodedScale;  }
+   Int**         getCodedOffset()                         { return m_aaiCodedOffset; }
+
+   Void          compressMotion(Int scale); 
+   Void          printMotion( );
+#if NH_3D_ARP
+   Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
+#endif
+#if NH_3D_QTLPC
+   Bool          getReduceBitsFlag ()                     { return m_bReduceBitsQTL;     }
+   Void          setReduceBitsFlag ( Bool bFlag )         { m_bReduceBitsQTL = bFlag;    }
 #endif
 #if NH_3D_NBDV
-  Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
-  Int           getDisCandRefPictures(Int iColPOC);
-  Void          setRapRefIdx(UInt uiRapRefIdx)         {m_uiRapRefIdx = uiRapRefIdx;}
-  Void          setRapRefList(RefPicList eRefPicList)  {m_eRapRefList = eRefPicList;}
-  Void          setNumDdvCandPics (Int i)              {m_iNumDdvCandPics = i;       }
-  UInt          getRapRefIdx()                         {return m_uiRapRefIdx;       }
-  RefPicList    getRapRefList()                        {return m_eRapRefList;       }
-  Void          checkTemporalIVRef();
-  Bool          isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
-  Void          checkTextureRef(  );
-  Int           isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
+  Int            getNumDdvCandPics()                      { return m_iNumDdvCandPics;    }
+  Int            getDisCandRefPictures(Int iColPOC);        
+  Void           setRapRefIdx(UInt uiRapRefIdx)           { m_uiRapRefIdx = uiRapRefIdx; }
+  Void           setRapRefList(RefPicList eRefPicList)    { m_eRapRefList = eRefPicList; }
+  Void           setNumDdvCandPics (Int i)                { m_iNumDdvCandPics = i;       }
+  UInt           getRapRefIdx()                           { return m_uiRapRefIdx;        }
+  RefPicList     getRapRefList()                          { return m_eRapRefList;        }
+  Void           checkTemporalIVRef();                     
+  Bool           isTempIVRefValid(Int currCandPic, Int iTempRefDir, Int iTempRefIdx);
+  Void           checkTextureRef(  );
+  Int            isTextRefValid(Int iTextRefDir, Int iTextRefIdx);
+#endif
+#endif
 #endif
 
@@ -241,30 +361,101 @@
 
 #if NH_MV
+
+class TComAu : public TComList<TComPic*>
+{
+  
+public:
+
+  Int                 getPoc            ( )                     {  assert(!empty()); return back()->getPOC            ();  }
+  Void                setPicLatencyCount( Int picLatenyCount );
+  Int                 getPicLatencyCount( )                     {  assert(!empty()); return back()->getPicLatencyCount();  }  
+  TComPic*            getPic            ( Int nuhLayerId  );
+  Void                addPic            ( TComPic* pic, Bool pocUnkown );
+  Bool                containsPic       ( TComPic* pic );  
+};
+
+
+class TComSubDpb : public TComList<TComPic*>
+{
+private: 
+  Int m_nuhLayerId; 
+public:  
+  TComSubDpb( Int nuhLayerid );
+
+  Int                 getLayerId                      ( ) { return m_nuhLayerId; }
+
+  TComPic*            getPic                          ( Int poc  );
+  TComPic*            getPicFromLsb                   ( Int pocLsb, Int maxPicOrderCntLsb );
+  TComPic*            getShortTermRefPic              ( Int poc  );
+  TComList<TComPic*>  getPicsMarkedNeedForOutput      ( );
+
+  Void                markAllAsUnusedForReference     ( );
+
+  Void                addPic                          ( TComPic* pic );
+  Void                removePics                      ( std::vector<TComPic*> picToRemove );
+  Bool                areAllPicsMarkedNotNeedForOutput( );
+};
+
 class TComPicLists 
 {
 private: 
-  TComList<TComList<TComPic*>*> m_lists; 
-#if NH_3D
-  const TComVPS*                     m_vps; 
+  TComList<TComAu*    >       m_aus;  
+  TComList<TComSubDpb*>       m_subDpbs; 
+  Bool                        m_printPicOutput; 
+#if NH_3D                     
+  const TComVPS*              m_vps; 
 #endif
 public: 
-  Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
-  Int         size     ()                           { return (Int) m_lists.size(); } 
-#if NH_3D_ARP
-  TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
-#endif
-  TComPic*    getPic   ( Int layerIdInNuh,              Int poc );    
-  TComPicYuv* getPicYuv( Int layerIdInNuh,              Int poc, Bool recon ); 
-#if NH_3D
-  Void        setVPS   ( const TComVPS* vps ) { m_vps = vps;  }; 
-  TComPic*    getPic   ( Int viewIndex, Bool depthFlag, Int poc );
-  TComPicYuv* getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon );
+  ~TComPicLists();
+
+  // Add and remove single pictures
+  Void                   addNewPic( TComPic* pic );
+  Void                   removePic( TComPic* pic );
+
+  // Get Pics
+  TComPic*               getPic                         ( Int layerIdInNuh, Int poc );
+  TComPicYuv*            getPicYuv                      ( Int layerIdInNuh, Int poc, Bool recon );
+
+  // Get and AUs and SubDPBs
+  TComSubDpb*            getSubDpb                      ( Int nuhLayerId, Bool create );
+  TComList<TComSubDpb*>* getSubDpbs                     ( );
+                                                        
+  TComAu*                addAu                          ( Int poc  );
+  TComAu*                getAu                          ( Int poc, Bool create );
+  TComList<TComAu*>*     getAus                         ( );
+  TComList<TComAu*>      getAusHavingPicsMarkedForOutput( );
+
+  // Mark pictures and set POCs
+  Void                   markSubDpbAsUnusedForReference ( Int layerIdInNuh );
+  Void                   markSubDpbAsUnusedForReference ( TComSubDpb& subDpb );
+  Void                   markAllSubDpbAsUnusedForReference(  );
+  Void                   decrementPocsInSubDpb          ( Int nuhLayerId, Int deltaPocVal );
+  
+  // Empty Sub DPBs
+  Void                   emptyAllSubDpbs                ( );
+  Void                   emptySubDpbs                   ( TComList<TComSubDpb*>* subDpbs);
+  Void                   emptySubDpb                    ( TComSubDpb* subDpb);
+  Void                   emptySubDpb                    ( Int nuhLayerId );
+
+  Void                   emptyNotNeedForOutputAndUnusedForRef      ( );
+  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( Int layerId  );
+  Void                   emptySubDpbNotNeedForOutputAndUnusedForRef( TComSubDpb subDpb );  
+
+  // For printing to std::out 
+  Void                   setPrintPicOutput ( Bool printPicOutput ) { m_printPicOutput = printPicOutput; };
+  Void                   print(); 
+
+#if NH_3D                                   
+  Void                   setVPS                        ( const TComVPS* vps ) { m_vps = vps;  }; 
+  TComPic*               getPic                        ( Int viewIndex, Bool depthFlag, Int poc );
+  TComPicYuv*            getPicYuv                     ( Int viewIndex, Bool depthFlag, Int poc, Bool recon );
 #endif  
 
-  Void print( );  
-
-}; // END CLASS DEFINITION TComPicLists
-
-#endif 
+}; 
+
+// END CLASS DEFINITION TComPicLists
+
+#endif
+
 
 //! \}
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPicYuv.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPicYuv.h	(revision 1317)
@@ -166,4 +166,7 @@
   // Set border extension flag
   Void          setBorderExtension(Bool b) { m_bIsBorderExtended = b; }
+#if NH_MV
+  Bool          getBorderExtension( )     { return m_bIsBorderExtended; }
+#endif
 #if NH_3D
   // Set Function 
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1317)
@@ -584,5 +584,5 @@
     pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
   }
-#if H_3D_ARP || NH_3D_ALIGN_SPIVMP_RP // check this!
+#if NH_3D_ARP
   if( pcCU->getARPW( uiPartAddr ) != 0 )
   {
@@ -1302,4 +1302,15 @@
   TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
   pcCU->clipMv(cMv);
+
+#if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC
+  if ( g_traceMotionInfoBeforUniPred  )
+  {
+    std::cout << "RefPic POC     : " << pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()     << std::endl; 
+    std::cout << "RefPic Layer Id: " << pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getLayerId() << std::endl; 
+    std::cout << "RefIdx         : " << iRefIdx                                                           << std::endl; 
+    std::cout << "RefPIcList     : " << eRefPicList                                                        << std::endl; 
+  }
+#endif
+
 #if NH_MV
   pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
@@ -1309,20 +1320,21 @@
   {
     if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
-  {
+    {
       xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi ); 
-  }
-  else
-  {
+    }
+    else
+    {
       xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
     }      
-    }
-    else
-    {
-#endif
-  for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
-  {
-    const ComponentID compID=ComponentID(comp);
+  }
+  else
+  {
+#endif
+
+    for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
+    {
+      const ComponentID compID=ComponentID(comp);
 #if NH_3D_IC
-    Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
+      Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
       xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
 #if NH_3D_ARP
@@ -1331,7 +1343,7 @@
         , bICFlag );
 #else
-    xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
-#endif
-  }
+      xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
+#endif
+    }
 #if NH_3D_ARP
   }
@@ -1813,4 +1825,7 @@
 )
 {
+#if NH_MV
+  assert( refPic->getBorderExtension() ); 
+#endif
   Int     refStride  = refPic->getStride(compID);
   Int     dstStride  = dstPic->getStride(compID);
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 1317)
@@ -176,7 +176,7 @@
   Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY );
 #endif
-
+#if NH_3D
   Pel  predIntraGetPredValDC      ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
-
+#endif
   Pel*  getPredictorPtr           ( const ComponentID compID, const Bool bUseFilteredPredictions )
   {
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1317)
@@ -133,5 +133,7 @@
   }
 
+#if NH_MV
   D_PRINT_INDENT( g_traceRDCost,  "Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost)); 
+#endif
   return dRdCost;
 }
@@ -603,7 +605,5 @@
   cDtParam.bitDepth   = bitDepth;
 
-#if NH_3D_IC_FIX
   cDtParam.bUseIC       = false;
-#endif
 #if NH_3D_SDC_INTER
   cDtParam.bUseSDCMRSAD = false;
@@ -3685,5 +3685,7 @@
   }
 
+#if NH_MV
   D_PRINT_INDENT( g_traceRDCost, "VSO Dist: " + n2s(uiDistortion) + " Bits: " + n2s(uiBits) + " RD Cost: " + n2s(dRdCost)); 
+#endif
 
   return dRdCost;
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 1317)
@@ -222,9 +222,9 @@
 #if NH_MV
 #if H_MV_HLS_PTL_LIMITS 
- g_generalTierAndLevelLimits[ Level::LEVEL1   ] = TComGeneralTierAndLevelLimits(    36864,     350,  INT_MIN,   16,   1,   1 );
- g_generalTierAndLevelLimits[ Level::LEVEL2   ] = TComGeneralTierAndLevelLimits(   122880,    1500,  INT_MIN,   16,   1,   1 );
- g_generalTierAndLevelLimits[ Level::LEVEL2_1 ] = TComGeneralTierAndLevelLimits(   245760,    3000,  INT_MIN,   20,   1,   1 );
- g_generalTierAndLevelLimits[ Level::LEVEL3   ] = TComGeneralTierAndLevelLimits(   552960,    6000,  INT_MIN,   30,   2,   2 );
- g_generalTierAndLevelLimits[ Level::LEVEL3_1 ] = TComGeneralTierAndLevelLimits(   983040,   10000,  INT_MIN,   40,   3,   3 );
+ g_generalTierAndLevelLimits[ Level::LEVEL1   ] = TComGeneralTierAndLevelLimits(    36864,     350,  MIN_INT,   16,   1,   1 );
+ g_generalTierAndLevelLimits[ Level::LEVEL2   ] = TComGeneralTierAndLevelLimits(   122880,    1500,  MIN_INT,   16,   1,   1 );
+ g_generalTierAndLevelLimits[ Level::LEVEL2_1 ] = TComGeneralTierAndLevelLimits(   245760,    3000,  MIN_INT,   20,   1,   1 );
+ g_generalTierAndLevelLimits[ Level::LEVEL3   ] = TComGeneralTierAndLevelLimits(   552960,    6000,  MIN_INT,   30,   2,   2 );
+ g_generalTierAndLevelLimits[ Level::LEVEL3_1 ] = TComGeneralTierAndLevelLimits(   983040,   10000,  MIN_INT,   40,   3,   3 );
  g_generalTierAndLevelLimits[ Level::LEVEL4   ] = TComGeneralTierAndLevelLimits(  2228224,   12000,    30000,   75,   5,   5 );
  g_generalTierAndLevelLimits[ Level::LEVEL4_1 ] = TComGeneralTierAndLevelLimits(  2228224,   20000,    50000,   75,   5,   5 );
@@ -546,13 +546,13 @@
 Bool g_disableNumbering = false; 
 Bool g_disableHLSTrace = false; 
-UInt64 g_stopAtCounter         = 4660; 
-Bool g_traceCopyBack           = false; 
-Bool g_decTraceDispDer         = false; 
-Bool g_decTraceMvFromMerge     = false; 
-Bool g_decTracePicOutput       = false; 
+UInt64 g_stopAtCounter       = 4660; 
+Bool g_traceCopyBack         = false; 
+Bool g_decTraceDispDer       = false; 
+Bool g_decTraceMvFromMerge   = false; 
+Bool g_decTracePicOutput     = false; 
 Bool g_startStopTrace          = false; 
-Bool g_outputPos               = false;
-Bool g_traceCameraParameters   = false; 
-Bool g_encNumberOfWrittenBits  = false; 
+Bool g_outputPos             = false;   
+Bool g_traceCameraParameters = false; 
+Bool g_encNumberOfWrittenBits     = false; 
 Bool g_traceEncFracBits        = false; 
 Bool g_traceIntraSearchCost    = false; 
@@ -561,4 +561,8 @@
 Bool g_traceModeCheck          = false; 
 UInt g_indent                  = false; 
+Bool g_decNumBitsRead          = false; 
+Bool g_traceMotionInfoBeforUniPred = false; 
+Bool g_traceMergeCandListConst = false; 
+Bool g_traceSubPBMotion       = false; 
 #endif
 #endif
@@ -693,7 +697,7 @@
   Bool startTrace = false; 
   if ( g_startStopTrace && poc == 0 && layerId == 0 )
-  {    
+  {
     startTrace = ( cuPelX  == 0 ) && ( cuPelY  == 0 ) && ( cuWidth == 64 ) && ( cuHeight == 64 ); 
-  }
+    }
   if ( startTrace )
   { 
@@ -705,5 +709,5 @@
     g_traceModeCheck         = true; 
     g_traceCopyBack          = false; 
-  }  
+    }
   Bool stopTrace = false; 
   if ( g_startStopTrace && poc == 0 && layerId == 0 )
@@ -752,34 +756,4 @@
     fflush ( g_hTrace );    
   }
-}
-Void printStr( std::string str )
-{
-  std::cout << str << std::endl; 
-}
-Void printStrIndent( Bool b, std::string strStr )
-{
-  if ( b )
-  {  
-    std::cout << std::string(g_indent, ' ');
-    printStr( strStr );
-  }
-}
-Void prinStrIncIndent( Bool b,  std::string strStr )
-{
-  if ( b )
-  {
-    printStrIndent( true,  strStr );
-    if (g_indent < 50)
-    {
-      g_indent++;
-    }
-  }  
-}
-Void decIndent( Bool b )
-{
-  if (b && g_indent > 0)
-  {
-    g_indent--;  
-  }  
 }
 #endif
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 1317)
@@ -91,8 +91,9 @@
 extern const UChar  g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH];
 extern const UChar  g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE];
+#if NH_3D_DMM
 // ====================================================================================================================
 // Depth coding modes
 // ====================================================================================================================
-#if NH_3D_DMM
+
 extern const WedgeResolution                                 g_dmmWedgeResolution [6];
 extern const UChar                                           g_dmm1TabIdxBits     [6];
@@ -193,4 +194,7 @@
  extern Bool   g_traceSAOCost; 
  extern UInt   g_indent; 
+extern Bool   g_traceMotionInfoBeforUniPred; 
+ extern Bool   g_traceMergeCandListConst; 
+ extern Bool   g_traceSubPBMotion; 
 #define DTRACE_CU(x,y)             writeToTraceFile( x,y, g_traceCU );
 #define DTRACE_PU(x,y)             writeToTraceFile( x,y, g_tracePU );
@@ -232,4 +236,5 @@
 #define DTRACE_CABAC_R( x,y )
 #define DTRACE_CABAC_N
+#if NH_MV
 #define DTRACE_CU(x,y) ;             
 #define DTRACE_PU(x,y) ;            
@@ -242,5 +247,5 @@
 #define D_PRINT_INC_INDENT( b, str );
 #define D_PRINT_INDENT( b, str );
-
+#endif
 #endif
 const Char* nalUnitTypeToString(NalUnitType type);
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1317)
@@ -6,4 +6,5 @@
  * Copyright (c) 2010-2015, ITU/ISO/IEC
  * All rights reserved.
+
  *
  * Redistribution and use in source and binary forms, with or without
@@ -112,5 +113,4 @@
 , m_encCABACTableIdx              (I_SLICE)
 #if NH_MV
-, m_availableForTMVPRefFlag       ( true )
 , m_refPicSetInterLayer0          ( NULL )
 , m_refPicSetInterLayer1          ( NULL )
@@ -121,8 +121,6 @@
 , m_isDepth                       (false)
 #endif
-#if !H_MV_HLS7_GEN
+#if NH_MV
 , m_pocResetFlag                  (false)
-#endif
-#if NH_MV
 , m_crossLayerBlaFlag             (false)
 #endif
@@ -134,8 +132,9 @@
 , m_pocResetIdc                   (0)
 , m_pocResetPeriodId              (0)
+, m_hasPocResetPeriodIdPresent    (false)
 , m_fullPocResetFlag              (false)
 , m_pocLsbVal                     (0)
-, m_pocMsbValPresentFlag          (false)
-, m_pocMsbVal                     (0)
+, m_pocMsbCycleValPresentFlag     (false)
+, m_pocMsbCycleVal                (0)
 , m_pocMsbValRequiredFlag         (false)
 #endif
@@ -155,4 +154,16 @@
 #endif
 {
+
+#if NH_MV
+  m_shortTermRefPicSetIdx = 0; 
+  m_numLongTermSps        = 0; 
+  m_numLongTermPics       = 0; 
+  for (Int i = 0; i < MAX_NUM_PICS_RPS; i++)
+  {
+    m_ltIdxSps          [i] = 0; 
+    m_deltaPocMsbCycleLt[i] = 0;
+  }
+  setSliceTemporalMvpEnabledFlag( false ); 
+#endif
   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
   {
@@ -790,4 +801,5 @@
 #endif
 
+
 Int TComSlice::getNumRpsCurrTempList() const
 {
@@ -806,5 +818,5 @@
   }
 #if NH_MV
-  numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics();
+    numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics();
 #endif
   return numRpsCurrTempList;
@@ -1097,5 +1109,6 @@
   m_pcVPS                = pSrc->m_pcVPS;
 #endif
-  m_pRPS                = pSrc->m_pRPS;  m_iLastIDR             = pSrc->m_iLastIDR;
+  m_pRPS                = pSrc->m_pRPS;
+  m_iLastIDR             = pSrc->m_iLastIDR;
 
   m_pcPic                = pSrc->m_pcPic;
@@ -1155,7 +1168,5 @@
 #if NH_MV
   // Additional slice header syntax elements 
-#if !H_MV_HLS7_GEN
   m_pocResetFlag               = pSrc->m_pocResetFlag; 
-#endif
   m_discardableFlag            = pSrc->m_discardableFlag; 
   m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag; 
@@ -2670,6 +2681,6 @@
   }
 }
-#endif
-
+
+#endif
 #endif // NH_MV
 
@@ -2719,4 +2730,7 @@
 , m_uiBitsForPOC              (  8)
 , m_numLongTermRefPicSPS      (  0)
+#if NH_MV
+, m_numShortTermRefPicSets    (   0)
+#endif
 , m_uiMaxTrSize               ( 32)
 , m_bUseSAO                   (false)
@@ -2750,5 +2764,9 @@
   for ( Int i = 0; i < MAX_TLAYER; i++ )
   {
+#if NH_MV
+    m_uiSpsMaxLatencyIncreasePlus1[i] = 0;
+#else
     m_uiMaxLatencyIncrease[i] = 0;
+#endif
     m_uiMaxDecPicBuffering[i] = 1;
     m_numReorderPics[i]       = 0;
@@ -3081,8 +3099,7 @@
 Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder )
 {
-  const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); 
-
   if ( getMultiLayerExtSpsFlag() )
   {
+    const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); 
     Int layerIdx = 0;         
     while (layerIdx < (Int) targetDecLayerIdList.size() )
@@ -3109,5 +3126,5 @@
         // This preliminary fix needs to be checked.
         assert( getNumReorderPics( i )     == maxNumReorderPics       ); 
-        assert( getMaxLatencyIncrease( i ) == maxLatencyIncreasePlus1 ); 
+        assert( getSpsMaxLatencyIncreasePlus1( i ) == maxLatencyIncreasePlus1 ); 
 
       }
@@ -3117,5 +3134,5 @@
         setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); 
         setNumReorderPics    ( maxNumReorderPics, i );
-        setMaxLatencyIncrease( maxLatencyIncreasePlus1 - 1 , i); 
+        setSpsMaxLatencyIncreasePlus1( maxLatencyIncreasePlus1 , i); 
       }
     }    
@@ -3412,5 +3429,4 @@
   }
 }
-
 Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 )
 {
@@ -3435,7 +3451,7 @@
     for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++)
     {      
-      if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true );
+      if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( 1 );
+      m_apcRefPicList[li][rIdx]->print( 0 );      
         
-      m_apcRefPicList[li][rIdx]->print( false );
     }
   }
@@ -3456,4 +3472,22 @@
   m_refPicSetInterLayer1 = refPicSetInterLayer1; 
 }
+
+TComPic* TComSlice::getRefPicSetInterLayer( Int setIdc, Int i ) const
+{
+  TComPic* pic = NULL; 
+  if (setIdc == 0 )
+  {
+    pic = (*m_refPicSetInterLayer0)[ i ]; 
+  }
+  else if (setIdc == 1 )
+  {
+    pic = (*m_refPicSetInterLayer1)[ i ]; 
+  }
+
+  assert( pic != NULL );   
+
+  return pic; 
+}
+
 
 TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) const
@@ -3572,4 +3606,5 @@
 #endif
 }
+#endif
 #if NH_3D_NBDV
 Void TComSlice::setDefaultRefView()
@@ -3687,5 +3722,5 @@
       if( iViewIdx<getViewIndex() && !bIsDepth )
       {
-        setBaseViewRefPicList( ivPicLists->getPicList( iLayerId ), iViewIdx );
+        setBaseViewRefPicList( ivPicLists->getSubDpb( iLayerId, false ), iViewIdx );
       }
     }
@@ -3710,5 +3745,5 @@
         if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
         {
-          existInterViewRef = true;        
+          existInterViewRef = true;
         }
       }
@@ -3833,7 +3868,7 @@
 #if NH_3D
 Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists )
-{
+{  
   for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
-  {     
+  { 
     for ( Int depthId = 0; depthId < 2; depthId++ )
     {
@@ -3920,5 +3955,5 @@
 }
 #endif
-#endif
+
 
 
@@ -3933,5 +3968,5 @@
 }
 
-Bool TComSlice::inferPocMsbValPresentFlag()
+Bool TComSlice::inferPocMsbCycleValPresentFlag()
 {
   Bool pocMsbValPresentFlag; 
@@ -3952,4 +3987,324 @@
 }
 
+
+Void TComSlice::f834decProcForRefPicListConst()
+{
+  // This process is invoked at the beginning of the decoding process for each P or B slice.
+  assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE );
+
+  // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into 
+  // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B 
+  // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0.
+
+  // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1 
+  // are derived as follows:
+
+  // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr )
+  Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() );
+
+  // and the list RefPicListTemp0 is constructed as follows:
+  std::vector<TComPic*> refPicListTemp0;
+  refPicListTemp0.resize((MAX_NUM_REF+1),NULL);
+
+  const TComDecodedRps* decRps = getPic()->getDecodedRps(); 
+
+  const std::vector<TComPic*>& refPicSetStCurrBefore  = decRps->m_refPicSetStCurrBefore; 
+  const std::vector<TComPic*>& refPicSetStCurrAfter   = decRps->m_refPicSetStCurrAfter;
+  const std::vector<TComPic*>& refPicSetLtCurr        = decRps->m_refPicSetLtCurr; 
+
+  const Int                    numPocStCurrBefore     = decRps->m_numPocStCurrBefore; 
+  const Int                    numPocStCurrAfter      = decRps->m_numPocStCurrAfter;
+  const Int                    numPocLtCurr           = decRps->m_numPocLtCurr;
+
+  const Int                    numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0;
+  const Int                    numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1;
+
+  const std::vector<TComPic*>& refPicSetInterLayer0   = decRps->m_refPicSetInterLayer0;
+  const std::vector<TComPic*>& refPicSetInterLayer1   = decRps->m_refPicSetInterLayer1;
+
+  Int rIdx = 0;
+  while( rIdx < numRpsCurrTempList0 )
+  {
+    for(Int  i = 0; i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ];
+    }    
+
+    for(Int  i = 0; i < numActiveRefLayerPics0; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetInterLayer0[ i ];
+    }
+
+    for(Int  i = 0;  i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )  // (F 65)
+    {
+      refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ];
+    }
+
+    for(Int  i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ]; 
+    }
+
+    for(Int  i = 0; i < numActiveRefLayerPics1; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetInterLayer1[ i ];
+    }
+  }
+
+  // The list RefPicList0 is constructed as follows:
+  TComRefPicListModification* rplm  = getRefPicListModification(); 
+  for( rIdx = 0; rIdx  <=  getNumRefIdxL0ActiveMinus1(); rIdx++ )      //  (F 66)
+  {
+    m_apcRefPicList[ 0 ][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ];
+    // The decoding process below slice level requires the status
+    // of the reference pictures, when decoding the RPS. So store it here.
+    m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm();
+    m_aiRefPOCList     [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC();
+    m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId();
+  }  
+
+  std::vector<TComPic*> refPicListTemp1;
+  refPicListTemp1.resize((MAX_NUM_REF+1),NULL);
+
+  if (getSliceType() == B_SLICE )
+  {
+    // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to 
+    // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows:       
+    Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() );
+
+    rIdx = 0; 
+    while( rIdx < numRpsCurrTempList1 )
+    {
+      for( Int i = 0; i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ]; 
+      }
+      for( Int i = 0; i< numActiveRefLayerPics1; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetInterLayer1[ i ]; 
+      }
+      for( Int i = 0;  i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )  // (F 67)
+      {
+        refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ];
+      }         
+      for( Int i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ];
+      }
+      for( Int i = 0; i< numActiveRefLayerPics0; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetInterLayer0[ i ]; 
+      }
+    }
+  }
+
+  if (getSliceType() == B_SLICE )
+  {
+    //   When the slice is a B slice, the list RefPicList1 is constructed as follows:
+    for( rIdx = 0; rIdx  <=  getNumRefIdxL1ActiveMinus1(); rIdx++ )      // (F 68)
+    {
+      m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ]; 
+
+      // The decoding process below slice level requires the marking status
+      // of the reference pictures, when decoding the RPS. So store it here.
+      m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm();
+      m_aiRefPOCList     [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC();
+      m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId();
+    }    
+  }
+}
+
+
+Void TComSlice::cl834DecProcForRefPicListConst()
+{
+  // This process is invoked at the beginning of the decoding process for each P or B slice.
+  assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE );
+
+  // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into 
+  // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B 
+  // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0.
+
+  // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1 
+  // are derived as follows:
+
+  // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr ) 
+  Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() );
+
+  // and the list RefPicListTemp0 is constructed as follows:
+  std::vector<TComPic*> refPicListTemp0; 
+  refPicListTemp0.resize((MAX_NUM_REF+1),NULL);
+
+  const TComDecodedRps* decRps = getPic()->getDecodedRps(); 
+
+  const std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; 
+  const std::vector<TComPic*>& refPicSetStCurrAfter  = decRps->m_refPicSetStCurrAfter;
+  const std::vector<TComPic*>& refPicSetLtCurr       = decRps->m_refPicSetLtCurr; 
+    
+  const Int                    numPocStCurrBefore    = decRps->m_numPocStCurrBefore; 
+  const Int                    numPocStCurrAfter     = decRps->m_numPocStCurrAfter;
+  const Int                    numPocLtCurr          = decRps->m_numPocLtCurr;
+
+  Int rIdx = 0;
+  while( rIdx < numRpsCurrTempList0 )
+  {
+    for(Int  i = 0; i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ];
+    }    
+
+    for(Int  i = 0;  i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )  // (8 8)
+    {
+      refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ];
+    }
+
+    for(Int  i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList0; rIdx++, i++ )
+    {
+      refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ]; 
+    }
+  }
+
+  // The list RefPicList0 is constructed as follows:
+
+  TComRefPicListModification* rplm = getRefPicListModification(); 
+  for( rIdx = 0; rIdx  <=  getNumRefIdxL0ActiveMinus1(); rIdx++ )      //   (8-9)
+  {
+    m_apcRefPicList[0][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ];
+
+    // The decoding process below slice level requires the marking status 
+    // of the reference pictures, when decoding the RPS. So store it here.
+    m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm();
+    m_aiRefPOCList     [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC();
+    m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId();
+  }
+
+  std::vector<TComPic*> refPicListTemp1;
+  refPicListTemp1.resize((MAX_NUM_REF+1),NULL);
+
+  if (getSliceType() == B_SLICE )
+  {
+    // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to 
+    // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows:
+    Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() );
+
+    rIdx = 0; 
+    while( rIdx < numRpsCurrTempList1 )
+    {
+      for( Int i = 0; i < numPocStCurrAfter  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ]; 
+      }
+      for( Int i = 0;  i < numPocStCurrBefore  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )  // (8-10)
+      {
+        refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ];
+      }         
+      for( Int i = 0; i < numPocLtCurr  &&  rIdx < numRpsCurrTempList1; rIdx++, i++ )
+      {
+        refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ];
+      }
+    }
+  }
+
+  if (getSliceType() == B_SLICE )
+  {
+    //   When the slice is a B slice, the list RefPicList1 is constructed as follows:
+    for( rIdx = 0; rIdx  <=  getNumRefIdxL1ActiveMinus1(); rIdx++ )      // (F 68)
+    {
+      m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ]; 
+
+      // The decoding process below slice level requires the marking status 
+      // of the reference pictures, when decoding the RPS. So store it here.
+      m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm();
+      m_aiRefPOCList     [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC();
+      m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId();
+    }
+  }
+}
+
+Int TComSlice::getNumPicTotalCurr() const
+{
+  Int numPicTotalCurr = 0;
+#if NH_MV_FIX_NUM_POC_TOTAL_CUR
+  if ( !isIdr()  )
+  {
+    const TComStRefPicSet* stRps = getStRps( getCurrRpsIdx() ); 
+#endif
+    for( Int i = 0; i < stRps->getNumNegativePicsVar(); i++ )
+    {
+      if( stRps->getUsedByCurrPicS0Var( i ) )
+      {
+        numPicTotalCurr++;
+      }
+    }
+    for( Int i = 0; i < stRps->getNumPositivePicsVar(); i++)  //(7 55)
+    {
+      if( stRps->getUsedByCurrPicS1Var(i) )
+      {
+        numPicTotalCurr++;
+      }
+    }
+    for( Int i = 0; i < getNumLongTermSps() + getNumLongTermPics(); i++ )
+    {
+      if( getUsedByCurrPicLtVar( i ) )
+      {
+        numPicTotalCurr++;
+      }
+    }
+#if NH_MV_FIX_NUM_POC_TOTAL_CUR
+  }
+#endif
+
+  if ( decProcAnnexF() )
+  {
+    numPicTotalCurr += getNumActiveRefLayerPics(); 
+  }
+  return numPicTotalCurr;
+}
+
+
+
+Int TComSlice::getPocLsbLtVar( Int i )
+{
+  Int pocLsbLtVar; 
+  if (i < getNumLongTermSps() )
+  {
+
+    pocLsbLtVar = getSPS()->getLtRefPicPocLsbSps( getLtIdxSps( i ) ); 
+  }
+  else
+  {
+    pocLsbLtVar = getPocLsbLt( i ); 
+  }
+  return pocLsbLtVar;
+}
+
+
+Bool TComSlice::getUsedByCurrPicLtVar( Int i ) const
+{
+  Bool usedByCurrPicLtVar; 
+  if (i < getNumLongTermSps() )
+  {
+    usedByCurrPicLtVar = getSPS()->getUsedByCurrPicLtSPSFlag( getLtIdxSps( i ) ); 
+  }
+  else
+  {
+    usedByCurrPicLtVar = getUsedByCurrPicLtFlag( i ); 
+  }
+  return usedByCurrPicLtVar;
+}
+
+
+Int TComSlice::getDeltaPocMsbCycleLtVar( Int i ) const
+{
+  Int deltaPocMsbCycleVar; 
+  if (i == 0 || i == getNumLongTermSps() )
+  {
+    deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i ); 
+  }
+  else
+  {
+    deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i ) + getDeltaPocMsbCycleLtVar( i - 1 ); 
+  }
+  return deltaPocMsbCycleVar;
+}
 
 #endif
@@ -4074,13 +4429,27 @@
 
 Void TComSlice::checkInCompPredRefLayers()
-{
+{  
   if ( getInCompPredFlag() )
   {
     for (Int i = 0; i < getNumCurCmpLIds(); i++ )
-    {
+    {      
       assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL );       
       //  It is a requirement of bitstream conformance that there 
       //  is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture, 
       //  and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ].
+    }
+  } 
+}
+
+Void TComSlice::setPocsInCurrRPSs()
+{
+  // Currently only needed at decoder side; 
+  m_pocsInCurrRPSs.clear();    
+  std::vector<TComPic*>** rpsCurr = getPic()->getDecodedRps()->m_refPicSetsCurr;
+  for (Int i = 0 ; i < 3; i++ )
+  {
+    for( Int j = 0; j < rpsCurr[i]->size(); j++ )
+    {
+      m_pocsInCurrRPSs.push_back( (*rpsCurr[i])[j]->getPOC() ); 
     }
   }
@@ -4613,4 +4982,5 @@
 
   ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); 
+  assert( curProfileTierLevel != NULL ); 
 
   if( !profilePresentFlag )
@@ -4644,6 +5014,5 @@
 Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL)
 {
-  assert( k == 0 || refPTL != NULL ); 
-
+  assert( k == 0 || refPTL != NULL );   
   for (Int i = maxNumSubLayersMinus1; i >= 0; i--)
   {
@@ -4665,5 +5034,7 @@
     }    
 
+    assert( refProfileTierLevel != NULL ); 
     ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); 
+    assert( curProfileTierLevel != NULL ); 
     if( !getSubLayerLevelPresentFlag( i ) )
     {
@@ -4883,4 +5254,10 @@
 }
 
+
+Int TComDpbSize::getVpsMaxLatencyPictures( Int i, Int j ) const
+{
+  return getMaxVpsNumReorderPics( i, j ) + getMaxVpsLatencyIncreasePlus1(i, j) - 1; 
+}
+
 Void Window::scaleOffsets( Int scal )
 {
@@ -4894,3 +5271,108 @@
   }
 }
-#endif
+
+Void TComStRefPicSet::inferRps( Int stRpsIdx, TComSPS* sps, Bool encoder )
+{
+  if ( getInterRefPicSetPredictionFlag() )
+  {
+    // When inter_ref_pic_set_prediction_flag is equal to 1, the variables DeltaPocS0[ stRpsIdx ][ i ], UsedByCurrPicS0[ stRpsIdx ][ i ], 
+    // NumNegativePics[ stRpsIdx ], DeltaPocS1[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ] and NumPositivePics[ stRpsIdx ] are 
+    // derived as follows:
+
+    Int i = 0;
+    Int refRpsIdx = getRefRpsIdx( stRpsIdx );
+    TComStRefPicSet* refRps = sps->getStRefPicSet( refRpsIdx ); 
+
+    for( Int j = refRps->getNumPositivePicsVar( ) - 1; j >= 0; j-- ) 
+    {
+      Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps();
+      if( dPoc < 0  &&  getUseDeltaFlag( refRps->getNumNegativePicsVar( ) + j ) ) 
+      {
+        setDeltaPocS0Var     ( i, dPoc );
+        setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumNegativePicsVar( ) + j ) );
+      }
+    }
+    if( getDeltaRps() < 0  && getUseDeltaFlag( refRps->getNumDeltaPocs() ) )   //   (7 59)
+    {
+      setDeltaPocS0Var( i,  getDeltaRps() ); 
+      setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() ) );
+    }
+    for( Int j = 0; j < refRps->getNumNegativePicsVar(); j++ )
+    {
+      Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps(); 
+      if( dPoc < 0  &&  getUseDeltaFlag( j ) ) 
+      {
+        setDeltaPocS0Var( i , dPoc);
+        setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( j )) ;
+      }
+    }
+
+    setNumNegativePicsVar( i );
+
+    i = 0;
+    for( Int j = refRps->getNumNegativePicsVar() - 1; j  >=  0; j-- )
+    {
+      Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps(); 
+      if( dPoc > 0  &&  getUseDeltaFlag( j ) )
+      {
+        setDeltaPocS1Var( i, dPoc );
+        setUsedByCurrPicS1Var(  i++, getUsedByCurrPicFlag( j ) ) ;
+      }
+    }
+
+    if( getDeltaRps() > 0  &&  getUseDeltaFlag( refRps->getNumDeltaPocs() ) ) //  (7 60)
+    { 
+      setDeltaPocS1Var( i , getDeltaRps() );
+      setUsedByCurrPicS1Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() ));
+    }
+
+    for( Int j = 0; j < refRps->getNumPositivePicsVar( ); j++) 
+    {
+      Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps(); 
+      if( dPoc > 0  &&  getUseDeltaFlag( refRps->getNumNegativePicsVar() + j ) ) 
+      {
+        setDeltaPocS1Var( i, dPoc);
+        setUsedByCurrPicS1Var( i++, getUsedByCurrPicFlag( refRps->getNumNegativePicsVar() + j ));
+      }
+    }
+    setNumPositivePicsVar(  i );
+  }
+  else
+  {
+    // When inter_ref_pic_set_prediction_flag is equal to 0, the variables NumNegativePics[ stRpsIdx ], NumPositivePics[ stRpsIdx ], 
+    // UsedByCurrPicS0[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ], DeltaPocS0[ stRpsIdx ][ i ] and DeltaPocS1[ stRpsIdx ][ i ] 
+    // are derived as follows:
+
+    setNumNegativePicsVar( getNumNegativePics( ) );        //  (7 61)
+    setNumPositivePicsVar( getNumPositivePics( ) );         //  (7 62)
+
+    for (Int i = 0 ; i < getNumNegativePics(); i++ )
+    {      
+      setUsedByCurrPicS0Var( i,  getUsedByCurrPicS0Flag( i ) ); //  (7 63)
+      if (i == 0 )
+      {
+        setDeltaPocS0Var( i , -( getDeltaPocS0Minus1( i ) + 1 )); // (7 65)
+      }
+      else
+      {
+        setDeltaPocS0Var( i , getDeltaPocS0Var( i - 1 ) - ( getDeltaPocS0Minus1( i ) + 1 )); //  (7 67)
+      }
+    }
+
+    for (Int i = 0 ; i < getNumPositivePics(); i++ )
+    {      
+      setUsedByCurrPicS1Var( i,  getUsedByCurrPicS1Flag( i ) ); //  (7 64)
+
+      if (i == 0 )
+      {
+        setDeltaPocS1Var( i , getDeltaPocS1Minus1( i ) + 1    );      // (7 66)
+      }
+      else
+      {
+        setDeltaPocS1Var( i , getDeltaPocS1Var( i - 1 ) + ( getDeltaPocS1Minus1( i ) + 1 )); //  (7 68)
+      }
+    }
+  }
+}
+
+#endif
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1317)
@@ -53,4 +53,5 @@
 class TComTrQuant;
 #if NH_MV
+class TComDecodedRps;
 class TComPicLists; 
 class TComVPS; 
@@ -68,4 +69,114 @@
 
 /// Reference Picture Set class
+
+#if NH_MV
+class TComStRefPicSet 
+{
+  // This class is currently only used by the decoder. 
+  // TBD: Modify encoder to use also it.
+
+private: 
+
+  // Syntax elements: 
+
+  Bool m_interRefPicSetPredictionFlag;
+  Int  m_deltaIdxMinus1;
+  Bool m_deltaRpsSign;
+  Int  m_absDeltaRpsMinus1;
+  Bool m_usedByCurrPicFlag  [ MAX_NUM_PICS_RPS ];
+  Bool m_useDeltaFlag       [ MAX_NUM_PICS_RPS ];
+  Int  m_numNegativePics;   
+  Int  m_numPositivePics;   
+  Int  m_deltaPocS0Minus1   [ MAX_NUM_PICS_RPS ];
+  Bool m_usedByCurrPicS0Flag[ MAX_NUM_PICS_RPS ];
+  Int  m_deltaPocS1Minus1   [ MAX_NUM_PICS_RPS ];
+  Bool m_usedByCurrPicS1Flag[ MAX_NUM_PICS_RPS ];
+
+  // Semantic variables: 
+  Int m_deltaPocS0Var       [ MAX_NUM_PICS_RPS ];
+  Int m_deltaPocS1Var       [ MAX_NUM_PICS_RPS ];
+  Int m_usedByCurrPicS0Var  [ MAX_NUM_PICS_RPS ];
+  Int m_usedByCurrPicS1Var  [ MAX_NUM_PICS_RPS ];
+  Int m_numNegativePicsVar  ;
+  Int m_numPositivePicsVar  ;
+
+public:
+
+  TComStRefPicSet( )
+  {
+    // Set default inheritance values: 
+    setInterRefPicSetPredictionFlag( false ); 
+    setDeltaIdxMinus1( 0 );
+    for (Int j = 0; j < MAX_NUM_PICS_RPS; j++)
+    {
+      setUseDeltaFlag( j, true  ); 
+    }    
+  }
+
+  // Syntax elements: 
+  Void  setInterRefPicSetPredictionFlag( Bool flag )           { m_interRefPicSetPredictionFlag = flag; }
+  Bool  getInterRefPicSetPredictionFlag(  ) const              { return m_interRefPicSetPredictionFlag; }
+
+  Void  setDeltaIdxMinus1( Int  val )                          { m_deltaIdxMinus1 = val;                }
+  Int   getDeltaIdxMinus1(  ) const                            { return m_deltaIdxMinus1;               }
+
+  Void  setDeltaRpsSign( Bool flag )                           { m_deltaRpsSign = flag;                 }
+  Bool  getDeltaRpsSign(  ) const                              { return m_deltaRpsSign;                 }
+
+  Void  setAbsDeltaRpsMinus1( Int  val )                       { m_absDeltaRpsMinus1 = val;             }
+  Int   getAbsDeltaRpsMinus1(  ) const                         { return m_absDeltaRpsMinus1;            }
+
+  Void  setUsedByCurrPicFlag( Int j, Bool flag )               { m_usedByCurrPicFlag[j] = flag;         }
+  Bool  getUsedByCurrPicFlag( Int j ) const                    { return m_usedByCurrPicFlag[j];         }
+
+  Void  setUseDeltaFlag( Int j, Bool flag )                    { m_useDeltaFlag[j] = flag;              }
+  Bool  getUseDeltaFlag( Int j ) const                         { return m_useDeltaFlag[j];              }
+
+  Void  setNumNegativePics( Int  val )                         { m_numNegativePics = val;               }
+  Int   getNumNegativePics(  ) const                           { return m_numNegativePics;              }
+
+  Void  setNumPositivePics( Int  val )                         { m_numPositivePics = val;               }
+  Int   getNumPositivePics(  ) const                           { return m_numPositivePics;              }
+
+  Void  setDeltaPocS0Minus1( Int i, Int  val )                 { m_deltaPocS0Minus1[i] = val;           }
+  Int   getDeltaPocS0Minus1( Int i ) const                     { return m_deltaPocS0Minus1[i];          }
+
+  Void  setUsedByCurrPicS0Flag( Int i, Bool flag )             { m_usedByCurrPicS0Flag[i] = flag;       }
+  Bool  getUsedByCurrPicS0Flag( Int i ) const                  { return m_usedByCurrPicS0Flag[i];       }
+
+  Void  setDeltaPocS1Minus1( Int i, Int  val )                 { m_deltaPocS1Minus1[i] = val;           }
+  Int   getDeltaPocS1Minus1( Int i ) const                     { return m_deltaPocS1Minus1[i];          }
+
+  Void  setUsedByCurrPicS1Flag( Int i, Bool flag )             { m_usedByCurrPicS1Flag[i] = flag;       }
+  Bool  getUsedByCurrPicS1Flag( Int i ) const                  { return m_usedByCurrPicS1Flag[i];       }
+
+  // Semantics variables: 
+  Int   getRefRpsIdx(Int stRpsIdx ) const                      { return ( stRpsIdx - (getDeltaIdxMinus1() +  1) ); }
+  Int   getDeltaRps()  const                                   { return (  ( 1 - 2 * getDeltaRpsSign() ) * ( getAbsDeltaRpsMinus1() + 1 ) ); }
+  Int   getNumDeltaPocs() const                                { return ( getNumNegativePicsVar() + getNumPositivePicsVar());    }
+
+  Void  setNumNegativePicsVar( Int  val )                      { m_numNegativePicsVar = val;            }
+  Int   getNumNegativePicsVar(  ) const                        { return m_numNegativePicsVar;           }
+
+  Void  setNumPositivePicsVar( Int  val )                      { m_numPositivePicsVar = val;            }
+  Int   getNumPositivePicsVar(  ) const                        { return m_numPositivePicsVar;           }
+
+  Void  setDeltaPocS0Var( Int i, Int  val )                    { m_deltaPocS0Var[i] = val;              }
+  Int   getDeltaPocS0Var( Int i ) const                        { return m_deltaPocS0Var[i];             }
+
+  Void  setUsedByCurrPicS0Var( Int i, Bool flag )              { m_usedByCurrPicS0Var[i] = flag;       }
+  Bool  getUsedByCurrPicS0Var( Int i ) const                   { return m_usedByCurrPicS0Var[i];       }
+
+  Void  setDeltaPocS1Var( Int i, Int  val )                    { m_deltaPocS1Var[i] = val;             }
+  Int   getDeltaPocS1Var( Int i ) const                        { return m_deltaPocS1Var[i];            }
+
+  Void  setUsedByCurrPicS1Var( Int i, Bool flag )              { m_usedByCurrPicS1Var[i] = flag;       }
+  Bool  getUsedByCurrPicS1Var( Int i ) const                   { return m_usedByCurrPicS1Var[i];       }
+
+  Void  inferRps( Int stRpsIdx, TComSPS* sps, Bool encoder );
+};
+
+#endif
+
 class TComReferencePictureSet
 {
@@ -302,7 +413,13 @@
 {
   ProfileTierLevel m_generalPTL;
+#if !NH_MV
   ProfileTierLevel m_subLayerPTL    [MAX_TLAYER-1];      // max. value of max_sub_layers_minus1 is MAX_TLAYER-1 (= 6)
   Bool m_subLayerProfilePresentFlag [MAX_TLAYER-1];
   Bool m_subLayerLevelPresentFlag   [MAX_TLAYER-1];
+#else
+  ProfileTierLevel m_subLayerPTL    [MAX_TLAYER];        // However, highest index is 6, so we need one more. 
+  Bool m_subLayerProfilePresentFlag [MAX_TLAYER];
+  Bool m_subLayerLevelPresentFlag   [MAX_TLAYER];
+#endif
 
 public:
@@ -804,5 +921,6 @@
 
   Void          setMaxVpsLatencyIncreasePlus1( Int i, Int j, Int  val )              { m_maxVpsLatencyIncreasePlus1[i][j] = val;                  }
-  Int           getMaxVpsLatencyIncreasePlus1( Int i, Int j ) const                  { return m_maxVpsLatencyIncreasePlus1[i][j];                 }
+  Int           getMaxVpsLatencyIncreasePlus1( Int i, Int j ) const                  { return m_maxVpsLatencyIncreasePlus1[i][j];                 } 
+  Int           getVpsMaxLatencyPictures     ( Int i, Int j ) const;
 };
 #endif
@@ -901,12 +1019,7 @@
   Int         m_defaultDirectDependencyType;
   
-#if H_MV_HLS7_GEN
-  Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
-#endif
   Bool        m_vpsVuiPresentFlag;
   TComVPSVUI  m_vpsVUI; 
-#if !H_MV_HLS7_GEN
   Int         m_directDependencyType     [MAX_NUM_LAYERS] [MAX_NUM_LAYERS];
-#endif
 
   // VPS EXTENSION SEMANTICS VARIABLES
@@ -1119,9 +1232,5 @@
   Void    setLayerSetIdxForOlsMinus1( Int outLayerSetIdx, Int val )             { m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]  = val; } 
   Int     getLayerSetIdxForOlsMinus1( Int outLayerSetIdx )           const      { return m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]; } 
-#if NH_MV_FIX_TICKET_105
   Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() - 1 ); } 
-#else
-  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )        const      { return gCeilLog2( getNumLayerSets() ); } 
-#endif
 
   Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )            { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
@@ -1803,4 +1912,7 @@
 
   TComRPSList      m_RPSList;
+#if NH_MV
+  std::vector<TComStRefPicSet> m_stRefPicSets; 
+#endif
   Bool             m_bLongTermRefsPresent;
   Bool             m_TMVPFlagsPresent;
@@ -1825,4 +1937,7 @@
   UInt             m_uiBitsForPOC;
   UInt             m_numLongTermRefPicSPS;
+#if NH_MV
+  Int              m_numShortTermRefPicSets;
+#endif
   UInt             m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
   Bool             m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS];
@@ -1838,5 +1953,10 @@
   TComScalingList  m_scalingList;
   UInt             m_uiMaxDecPicBuffering[MAX_TLAYER];
+#if NH_MV
+  UInt             m_uiSpsMaxLatencyIncreasePlus1[MAX_TLAYER];  
+  // Calling a member m_uiMaxLatencyIncrease although it is m_uiMaxLatencyIncreasePlus1 is really bad style.  
+#else
   UInt             m_uiMaxLatencyIncrease[MAX_TLAYER];  // Really max latency increase plus 1 (value 0 expresses no limit)
+#endif
 
   Bool             m_useStrongIntraSmoothing;
@@ -1911,4 +2031,8 @@
   Void                   setConformanceWindow(Window& conformanceWindow )                                { m_conformanceWindow = conformanceWindow;                             }
 
+#if NH_MV
+  UInt                   getNumLongTermRefPicsSps() const                                                 { return m_numLongTermRefPicSPS;                                       }
+#endif
+  
   UInt                   getNumLongTermRefPicSPS() const                                                 { return m_numLongTermRefPicSPS;                                       }
   Void                   setNumLongTermRefPicSPS(UInt val)                                               { m_numLongTermRefPicSPS = val;                                        }
@@ -1939,4 +2063,8 @@
   Void                   setBitsForPOC( UInt u )                                                         { m_uiBitsForPOC = u;                                                  }
   UInt                   getBitsForPOC() const                                                           { return m_uiBitsForPOC;                                               }
+#if NH_MV
+  UInt                   getMaxPicOrderCntLsb() const                                                    { return (1 << ( getLog2MaxPicOrderCntLsbMinus4() + 4) );  }
+  Int                    getLog2MaxPicOrderCntLsbMinus4() const                                          { return (getBitsForPOC() - 4);  }
+#endif
   Bool                   getUseAMP() const                                                               { return m_useAMP;                                                     }
   Void                   setUseAMP( Bool b )                                                             { m_useAMP = b;                                                        }
@@ -1954,8 +2082,19 @@
   const TComRPSList*     getRPSList() const                                                              { return &m_RPSList;                                                   }
   TComRPSList*           getRPSList()                                                                    { return &m_RPSList;                                                   }
+#if NH_MV
+  Void                   initStRefPicSets( )                                                             { m_stRefPicSets.resize( getNumShortTermRefPicSets() );                }
+  TComStRefPicSet*       getStRefPicSet( Int i )                                                         { return &(m_stRefPicSets[i]);                                         }
+  const TComStRefPicSet* getStRefPicSet( Int i ) const                                                   { return &(m_stRefPicSets[i]);                                         }
+  Bool                   getLongTermRefPicsPresentFlag() const                                           { return m_bLongTermRefsPresent;                                       }
+  Void                   setLongTermRefPicsPresentFlag(Bool b)                                           { m_bLongTermRefsPresent=b;                                            }
+#else
   Bool                   getLongTermRefsPresent() const                                                  { return m_bLongTermRefsPresent;                                       }
   Void                   setLongTermRefsPresent(Bool b)                                                  { m_bLongTermRefsPresent=b;                                            }
+#endif
   Bool                   getTMVPFlagsPresent() const                                                     { return m_TMVPFlagsPresent;                                           }
   Void                   setTMVPFlagsPresent(Bool b)                                                     { m_TMVPFlagsPresent=b;                                                }
+#if NH_MV
+  Bool                   getSpsTemporalMvpEnabledFlag() const                                            { return m_TMVPFlagsPresent;                                           }
+#endif
   // physical transform
   Void                   setMaxTrSize( UInt u )                                                          { m_uiMaxTrSize = u;                                                   }
@@ -1988,5 +2127,8 @@
   Void                   setPCMFilterDisableFlag( Bool bValue )                                          { m_bPCMFilterDisableFlag = bValue;                                    }
   Bool                   getPCMFilterDisableFlag() const                                                 { return m_bPCMFilterDisableFlag;                                      }
-
+#if NH_MV
+  Void                  setNumShortTermRefPicSets( Int  val )                                            { m_numShortTermRefPicSets = val; } 
+  Int                   getNumShortTermRefPicSets(  )const                                               { return m_numShortTermRefPicSets; } 
+#endif
   Bool                   getScalingListFlag() const                                                      { return m_scalingListEnabledFlag;                                     }
   Void                   setScalingListFlag( Bool b )                                                    { m_scalingListEnabledFlag  = b;                                       }
@@ -1998,6 +2140,17 @@
   UInt                   getMaxDecPicBuffering(UInt tlayer) const                                        { return m_uiMaxDecPicBuffering[tlayer];                               }
   Void                   setMaxDecPicBuffering( UInt ui, UInt tlayer )                                   { assert(tlayer < MAX_TLAYER); m_uiMaxDecPicBuffering[tlayer] = ui;    }
+#if NH_MV
+  UInt                   getSpsMaxDecPicBufferingMinus1(UInt tlayer) const                               { return m_uiMaxDecPicBuffering[tlayer] -1 ;                           }
+  UInt                   getSpsMaxLatencyIncreasePlus1(UInt tlayer) const                                { return m_uiSpsMaxLatencyIncreasePlus1[tlayer];                       }
+  Void                   setSpsMaxLatencyIncreasePlus1( UInt ui , UInt tlayer)                           { m_uiSpsMaxLatencyIncreasePlus1[tlayer] = ui;                         }
+  Int                    getSpsMaxLatencyPictures( Int i )  const                                       { return ( getSpsMaxNumReorderPics(i) + getSpsMaxLatencyIncreasePlus1(i)-1); }
+#else
   UInt                   getMaxLatencyIncrease(UInt tlayer) const                                        { return m_uiMaxLatencyIncrease[tlayer];                               }
   Void                   setMaxLatencyIncrease( UInt ui , UInt tlayer)                                   { m_uiMaxLatencyIncrease[tlayer] = ui;                                 }
+#endif
+
+#if NH_MV
+  Int                    getSpsMaxNumReorderPics(Int i ) const                                           { return getNumReorderPics( i );                                       }
+#endif
 
   Void                   setUseStrongIntraSmoothing(Bool bVal)                                           { m_useStrongIntraSmoothing = bVal;                                    }
@@ -2133,9 +2286,19 @@
   Void    setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
 #if NH_MV
-  // Why not a listIdx for all members, would avoid code duplication?? 
+  
   Void    setRefPicSetIdxL(UInt li, UInt idx, UInt refPicSetIdx) {( li==0 ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ) = refPicSetIdx;              }
   UInt    getRefPicSetIdxL(UInt li, UInt idx )                   { return ( li == 0 ) ? m_RefPicSetIdxL0[idx] : m_RefPicSetIdxL1[idx] ;                  }
   Void    setRefPicListModificationFlagL(UInt li, Bool flag)     { ( li==0  ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1 ) = flag;  }
   Bool    getRefPicListModificationFlagL(UInt li )               { return ( li== 0) ? m_refPicListModificationFlagL0 : m_refPicListModificationFlagL1;   }
+
+  Int     getListEntryL0( Int i) const                           { assert(i<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL0[i];         }
+  Int     getListEntryL1( Int i) const                           { assert(i<REF_PIC_LIST_NUM_IDX); return m_RefPicSetIdxL1[i];         }
+
+  Int     getListEntryLXLen( Int numPicTotalCur ) const          { return gCeilLog2( numPicTotalCur );                                 }  
+
+  Void    setListEntryL0( Int i, Int  val )                      { m_RefPicSetIdxL0[i] = val;                                          } 
+  Void    setListEntryL1( Int i, Int  val )                      { m_RefPicSetIdxL1[i] = val;                                          } 
+
+
 #endif
 };
@@ -2470,4 +2633,7 @@
 private:
   //  Bitstream writing
+#if NH_MV
+  Bool                       m_firstSliceSegmentInPicFlag; 
+#endif
   Bool                       m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE];
   Int                        m_iPPSId;               ///< picture parameter set ID
@@ -2475,4 +2641,15 @@
 #if NH_MV
   Int                        m_slicePicOrderCntLsb;   
+  Bool                       m_shortTermRefPicSetSpsFlag;
+  Int                        m_shortTermRefPicSetIdx;
+  Int                        m_numLongTermSps;
+  Int                        m_numLongTermPics;
+  Int                        m_ltIdxSps                     [MAX_NUM_PICS_RPS];
+  Int                        m_pocLsbLt                     [MAX_NUM_PICS_RPS];
+  Bool                       m_usedByCurrPicLtFlag          [MAX_NUM_PICS_RPS];
+  Bool                       m_deltaPocMsbPresentFlag       [MAX_NUM_PICS_RPS];
+  Int                        m_deltaPocMsbCycleLt           [MAX_NUM_PICS_RPS];
+  Bool                       m_sliceTemporalMvpEnabledFlag;
+  TComStRefPicSet            m_stRefPicSet; 
 #endif  
   Int                        m_iPOC;
@@ -2510,5 +2687,5 @@
   Int                        m_aiRefPOCList  [NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
 #if NH_MV
-  Int         m_aiRefLayerIdList[2][MAX_NUM_REF+1];
+  Int                        m_aiRefLayerIdList[2][MAX_NUM_REF+1];
 #endif
   Bool                       m_bIsUsedAsLongTerm[NUM_REF_PIC_LIST_01][MAX_NUM_REF+1];
@@ -2570,8 +2747,5 @@
   SliceType                  m_encCABACTableIdx;           // Used to transmit table selection across slices.
 #if NH_MV
-  Bool       m_availableForTMVPRefFlag;
-#endif
-
-#if NH_MV
+
   std::vector<TComPic*>* m_refPicSetInterLayer0; 
   std::vector<TComPic*>* m_refPicSetInterLayer1; 
@@ -2584,7 +2758,6 @@
 
 // Additional slice header syntax elements 
-#if !H_MV_HLS7_GEN
   Bool       m_pocResetFlag; 
-#endif
+
   Bool       m_crossLayerBlaFlag;
   Bool       m_discardableFlag;
@@ -2596,8 +2769,12 @@
   Int        m_pocResetIdc;
   Int        m_pocResetPeriodId;
+
+  Bool       m_hasPocResetPeriodIdPresent; 
+  DecodingProcess m_decodingProcess; 
+  DecodingProcess m_decProcPocAndRps; 
   Bool       m_fullPocResetFlag;
   Int        m_pocLsbVal;
-  Bool       m_pocMsbValPresentFlag;
-  Int        m_pocMsbVal;
+  Bool       m_pocMsbCycleValPresentFlag;
+  Int        m_pocMsbCycleVal;
   Bool       m_pocMsbValRequiredFlag;
 
@@ -2676,4 +2853,7 @@
   Void                        setSlicePicOrderCntLsb( Int i )                        { m_slicePicOrderCntLsb = i;                                    }
   Int                         getSlicePicOrderCntLsb(  )  const                      { return m_slicePicOrderCntLsb;                                 }
+
+  Bool                        getFirstSliceSegementInPicFlag() const                 {  return m_firstSliceSegmentInPicFlag;                         }
+  Void                        setFirstSliceSegementInPicFlag(Bool val)               { m_firstSliceSegmentInPicFlag = val;                           }
 #endif
   Bool                        getPicOutputFlag() const                               { return m_PicOutputFlag;                                       }
@@ -2734,4 +2914,6 @@
   Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                  
   Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                              
+  Void                        setPocsInCurrRPSs( );
+
   TComPic*                    getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )     { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
   UInt                        getARPStepNum( )                                       { return m_nARPStepNum;                                         }  
@@ -2746,4 +2928,7 @@
   Bool                        getMvdL1ZeroFlag() const                               { return m_bLMvdL1Zero;                                         }
   Int                         getNumRpsCurrTempList() const;
+#if NH_MV
+  Int                         getNumPicTotalCurr() const;
+#endif
   Int                         getList1IdxToList0Idx( Int list1Idx ) const            { return m_list1IdxToList0Idx[list1Idx];                        }
   Void                        setReferenced(Bool b)                                  { m_bRefenced = b;                                              }
@@ -2753,7 +2938,39 @@
   Void                        setNalUnitType( NalUnitType e )                        { m_eNalUnitType      = e;                                      }
   NalUnitType                 getNalUnitType() const                                 { return m_eNalUnitType;                                        }
+#if NH_MV
+  std::string                 getNalUnitTypeString(    )                             { return NALU_TYPE_STR[ getNalUnitType() ]; };
+#endif
   Bool                        getRapPicFlag() const;
   Bool                        getIdrPicFlag() const                                  { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; }
   Bool                        isIRAP() const                                         { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23);  }
+#if NH_MV  
+  Bool                        isBla() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); }
+  Bool                        isIdr() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ); }
+  Bool                        isCra() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ); }
+
+  Bool                        isSlnr() const                                         { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N  ||    
+                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N    ||    
+                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N   ||    
+                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N   ||    
+                                                                                                getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N   ||    
+                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10     ||
+                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12     ||            
+                                                                                                getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14     );  }
+  
+  Bool                        isRasl() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N ); }
+  Bool                        isRadl() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N ); }
+  Bool                        isStsa() const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )  || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ); }
+  Bool                        isTsa()  const                                          { return ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R )   || ( getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ); }
+
+  Bool                        decProcClause8() const                                  { return ( m_decodingProcess == CLAUSE_8  ); }    
+  Bool                        decProcAnnexF()  const                                  { return ( decProcAnnexG()  || decProcAnnexH() || decProcAnnexI() ) ; }
+  Bool                        decProcAnnexG()  const                                  { return ( m_decodingProcess == ANNEX_G || decProcAnnexI()  ); }    
+  Bool                        decProcAnnexH()  const                                  { return ( m_decodingProcess == ANNEX_H  ); }    
+  Bool                        decProcAnnexI()  const                                  { return ( m_decodingProcess == ANNEX_I  ); }    
+  Int                         getCurrRpsIdx() const                                   { return ( getShortTermRefPicSetSpsFlag() ? getShortTermRefPicSetIdx() : getSPS()->getNumShortTermRefPicSets() ) ;}
+
+#endif
+
+
   Void                        checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
   Void                        decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled);
@@ -2774,4 +2991,8 @@
   Void                        setRefPOC( Int i, RefPicList e, Int iRefIdx )          { m_aiRefPOCList[e][iRefIdx] = i;                               }
   Void                        setNumRefIdx( RefPicList e, Int i )                    { m_aiNumRefIdx[e]    = i;                                      }
+#if NH_MV
+  Int                         getNumRefIdxL0ActiveMinus1() const                     { return ( getNumRefIdx(REF_PIC_LIST_0) -1);                    }
+  Int                         getNumRefIdxL1ActiveMinus1() const                     { return ( getNumRefIdx(REF_PIC_LIST_1) -1);                    }
+#endif
   Void                        setPic( TComPic* p )                                   { m_pcPic             = p;                                      }
   Void                        setDepth( Int iDepth )                                 { m_iDepth            = iDepth;                                 }
@@ -2827,5 +3048,5 @@
   Void                        setTLayer( UInt uiTLayer )                             { m_uiTLayer = uiTLayer;                                        }
 #if NH_MV
-  Int                         getTemporalId          ( )                             { return (Int) m_uiTLayer;                                      }
+  Int                         getTemporalId( ) const                                 { return (Int) m_uiTLayer;                                      }
 #endif
 
@@ -2836,4 +3057,7 @@
 #if NH_MV
   Void                        createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 );
+  Void                        f834decProcForRefPicListConst();
+  Void                        cl834DecProcForRefPicListConst();
+
   static Void                 markIvRefPicsAsShortTerm    ( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 );
   static Void                 markCurrPic                 ( TComPic* currPic );
@@ -2852,4 +3076,5 @@
   Void                        setNoRaslOutputFlag( Bool val )                        { m_noRaslOutputFlag = val;                                     }
   Bool                        getNoRaslOutputFlag() const                            { return m_noRaslOutputFlag;                                    }
+
 
   Void                        setHandleCraAsBlaFlag( Bool val )                      { m_handleCraAsBlaFlag = val;                                   }
@@ -2915,4 +3140,43 @@
   Bool                        getLFCrossSliceBoundaryFlag()                          { return m_LFCrossSliceBoundaryFlag;                            }
 
+#if NH_MV
+  Void                        setShortTermRefPicSetSpsFlag( Bool flag )              { m_shortTermRefPicSetSpsFlag = flag;                           }
+  Bool                        getShortTermRefPicSetSpsFlag(  ) const                 { return m_shortTermRefPicSetSpsFlag;                           }
+
+  Int                         getShortTermRefPicSetIdxLen() const                    { return gCeilLog2( getSPS()->getNumShortTermRefPicSets() );    }
+  Void                        setShortTermRefPicSetIdx( Int  val )                   { m_shortTermRefPicSetIdx = val;                                }
+  Int                         getShortTermRefPicSetIdx(  ) const                     { return m_shortTermRefPicSetIdx;                               }
+  
+  Void                        setNumLongTermSps( Int  val )                          { m_numLongTermSps = val;                                       }
+  Int                         getNumLongTermSps(  ) const                            { return m_numLongTermSps;                                      }
+
+  Void                        setNumLongTermPics( Int  val )                         { m_numLongTermPics = val;                                      }
+  Int                         getNumLongTermPics(  ) const                           { return m_numLongTermPics;                                     }
+  
+  Int                         getLtIdxSpsLen() const                                 { return gCeilLog2( getSPS()->getNumLongTermRefPicsSps() );     }
+  Void                        setLtIdxSps( Int i, Int  val )                         { m_ltIdxSps[i] = val;                                          }
+  Int                         getLtIdxSps( Int i ) const                             { return m_ltIdxSps[i];                                         }
+
+  Int                         getPocLsbLtLen() const                                 { return (getSPS()->getLog2MaxPicOrderCntLsbMinus4()+ 4);       }
+  Void                        setPocLsbLt( Int i, Int  val )                         { m_pocLsbLt[i] = val;                                          }
+  Int                         getPocLsbLt( Int i ) const                             { return m_pocLsbLt[i];                                         }
+
+  Void                        setUsedByCurrPicLtFlag( Int i, Bool flag )             { m_usedByCurrPicLtFlag[i] = flag;                              }
+  Bool                        getUsedByCurrPicLtFlag( Int i ) const                  { return m_usedByCurrPicLtFlag[i];                              }
+
+  Void                        setDeltaPocMsbPresentFlag( Int i, Bool flag )          { m_deltaPocMsbPresentFlag[i] = flag;                           }
+  Bool                        getDeltaPocMsbPresentFlag( Int i ) const               { return m_deltaPocMsbPresentFlag[i];                           }
+
+  Void                        setDeltaPocMsbCycleLt( Int i, Int  val )               { m_deltaPocMsbCycleLt[i] = val;                                }
+  Int                         getDeltaPocMsbCycleLt( Int i ) const                   { return m_deltaPocMsbCycleLt[i];                               }
+
+  Void                        setSliceTemporalMvpEnabledFlag( Bool flag )            { m_enableTMVPFlag = flag;                         }
+  Bool                        getSliceTemporalMvpEnabledFlag(  ) const               { return m_enableTMVPFlag;                         }
+
+  TComStRefPicSet*            getLocalStRps( )                                       { return &m_stRefPicSet; };
+  const TComStRefPicSet*      getStRps( Int stRpsIdx ) const                         { return ( (stRpsIdx == getSPS()->getNumShortTermRefPicSets()) ? &m_stRefPicSet : getSPS()->getStRefPicSet( stRpsIdx ) ); };
+
+#endif
+
   Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
   Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
@@ -2922,7 +3186,4 @@
 
 #if NH_MV
-  Void                        setAvailableForTMVPRefFlag( Bool   b )                 { m_availableForTMVPRefFlag = b;                                }
-  Bool                        getAvailableForTMVPRefFlag()                           { return m_availableForTMVPRefFlag;                             }
-
   Void                        setLayerId     ( Int layerId )                         { m_layerId      = layerId;                                     }
   Int                         getLayerId     ()                 const                { return m_layerId;                                             }
@@ -2932,4 +3193,8 @@
   Void                        setViewIndex   ( Int viewIndex )                       { m_viewIndex = viewIndex;                                      }
   Int                         getViewIndex   ()                 const                { return m_viewIndex;                                           }
+
+  Void                        setDecodingProcess ( DecodingProcess decProc )         { m_decodingProcess = decProc;                                  }
+
+
 #if NH_3D
 #if NH_3D_TMVP
@@ -2986,5 +3251,5 @@
   Void                        checkCrossLayerBlaFlag ( ) const ;
 
-#if !H_MV_HLS7_GEN
+#if NH_MV
   Void                        setPocResetFlag( Bool flag )                           { m_pocResetFlag = flag;                                        }
   Bool                        getPocResetFlag(  ) const                              { return m_pocResetFlag;                                        }
@@ -3010,4 +3275,5 @@
   Void                        checkPocResetIdc( ) const                              { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !(getSlicePicOrderCntLsb() > 0 ) || !( getPocResetIdc() == 2) ); }
 
+  
   Void                        setPocResetPeriodId( Int  val )                        { m_pocResetPeriodId = val;                                     }
   Int                         getPocResetPeriodId(  ) const                          { return m_pocResetPeriodId;                                    }
@@ -3020,4 +3286,19 @@
   Void                        checkPocLsbVal( ) const                                { assert( !(getVPS()->getPocLsbNotPresentFlag( getLayerIdInVps() ) )  || !getFullPocResetFlag() || ( getPocLsbVal() == 0 ) ); }
 
+#if NH_MV
+  Void                        setHasPocResetPeriodIdPresent( Bool  val )              { m_hasPocResetPeriodIdPresent = val;                                }
+  Bool                        getHasPocResetPeriodIdPresent(  ) const                { return m_hasPocResetPeriodIdPresent;                               }
+
+  Void                        setPocMsbCycleValPresentFlag( Bool flag )              { m_pocMsbCycleValPresentFlag = flag;                                }
+  Bool                        getPocMsbCycleValPresentFlag(  )          const        { return m_pocMsbCycleValPresentFlag;                                }
+
+  Void                        setPocMsbCycleVal( Int  val )                          { m_pocMsbCycleVal = val;                                            }
+  Int                         getPocMsbCycleVal(  )         const                    { return m_pocMsbCycleVal;                                           }
+  
+  Int                         getPocLsbLtVar(Int i);
+  Bool                        getUsedByCurrPicLtVar(Int i) const;
+  Int                         getDeltaPocMsbCycleLtVar( Int i ) const;
+
+#else
   Void                        setPocMsbValPresentFlag( Bool flag )                   { m_pocMsbValPresentFlag = flag;                                }
   Bool                        getPocMsbValPresentFlag(  )          const             { return m_pocMsbValPresentFlag;                                }
@@ -3025,9 +3306,11 @@
   Void                        setPocMsbVal( Int  val )                               { m_pocMsbVal = val;                                            }
   Int                         getPocMsbVal(  )         const                         { return m_pocMsbVal;                                           }
+#endif
+
 
   Bool                        getCraOrBlaPicFlag()       const                       { return ( getCraPicFlag() || getBlaPicFlag() );                }
   Bool                        getPocMsbValRequiredFlag() const                       { return ( getCraOrBlaPicFlag() && ( getVPS()->getVpsPocLsbAlignedFlag() || getVPS()->getNumDirectRefLayers( getLayerIdInVps() ) == 0 ) );  }
 
-  UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4
+  UInt                        getPocLsbValLen() const                                { return getSPS()->getBitsForPOC();                             }; //log2_max_pic_order_cnt_lsb_minus4 + 4  
 
   Bool getBlaPicFlag() const
@@ -3069,5 +3352,5 @@
   Void                        deriveInCmpPredAndCpAvailFlag( );
   Void                        init3dToolParameters();
-  Void                        checkInCompPredRefLayers();;
+  Void                        checkInCompPredRefLayers();
 
   Bool                        getIvMvPredFlag           ( )                          { return m_ivMvPredFlag           ;                             };
@@ -3095,6 +3378,14 @@
 #endif
 #endif
+#if NH_MV
+ TComPic*                     getRefPicSetInterLayer( Int setIdc, Int i ) const; 
+#endif
+
   // Inference 
+#if NH_MV
+  Bool                        inferPocMsbCycleValPresentFlag();
+#else
   Bool                        inferPocMsbValPresentFlag();
+#endif
 #endif
 protected:
Index: branches/HTM-15.0-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-15.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1316)
+++ branches/HTM-15.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1317)
@@ -61,71 +61,21 @@
 #define NH_3D          ( HEVC_EXT == 2)
 /////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////   FIXES           ///////////////////////////////////  
+/////////////////////////////////////////////////////////////////////////////////////////
+#if NH_MV
+#define NH_MV_FIX_NO_REF_PICS_CHECK               1 // !!SPEC!! 
+#define NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS  1 // Derivation of NumActiveRefLayerPIcs. !!SPEC!! 
+#define NH_MV_FIX_NUM_POC_TOTAL_CUR               1 // Derivation of NumPocTotalCur for IDR pictures. !!SPEC!!
+#endif
+#if NH_3D
+#define H_3D_FIX_ARP_CHECK_NOT_IN_DPB     1
+#endif
+/////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   MAJOR DEFINES   ///////////////////////////////////  
 /////////////////////////////////////////////////////////////////////////////////////////
 #if NH_MV
-#define NH_MV_FIX_TICKET_105              1 // layer_set_idx_for_ols_minus1 length
-#define NH_MV_FIX_TICKET_100              1 // Extra slice header bits
 #define H_MV_ENC_DEC_TRAC                 1  //< CU/PU level tracking
-#define H_MV_ENC_DEC_TRAC_FIX             1  // by SHARP
 #if NH_3D
-// FIXES 
-#define NH_3D_FIX_TICKET_98               1 // Writing of depth intra skip flag
-#define NH_3D_FIX_TICKET_101              ( 1 && NH_3D_VER141_DEC_COMP_FLAG )  // Camera parameters for depth
-#define NH_3D_DIS_FIX                     1
-#define NH_3D_ENC_DEPTH_FIX               1 // Fix Intra TU coding. 
-#define NH_3D_INTRA_SDC_RD_FIX            1 // Fix in RD- decision of intra SDC.
-#define NH_3D_DLT_FIX                     1 // Fixes numbers of parsed DLTs 
-#define NH_3D_VER141_DEC_COMP_FLAG        0 // Makes decoding of this version compatible to HTM-14.1 by re-introducing HTM-14.1 bugs.
-#define NH_3D_ALIGN_SPIVMP_DBBP           1 // Further alignment of DBBP and SBP motion
-#define NH_3D_ALIGN_SPIVMP_RP             1 // Alignment of DBBP and RP
-#define NH_3D_FIX_VSP                     1 
-#define NH_3D_VSO                         1
-#define NH_3D_NBDV                        1
-#define NH_3D_TMVP                        1   // QC_TMVP_C0047 
-                                              // Sony_M23639
-                                              // H_3D_TMVP_SCALING_FIX_K0053       1   // QC/CY for K0053
-#define NH_3D_IC                          1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
-                                              // Unifying rounding offset, for IC part, JCT3V-D0135
-                                              // SHARP_ILLUCOMP_REFINE_E0046
-                                              // MTK_CLIPPING_ALIGN_IC_E0168       // To support simplify bi-prediction PU with identical motion checking, JCT3V-E0168
-                                              // LGE_IC_CTX_F0160 //JCT3V-F0160
-                                              // SEC_ONLY_TEXTURE_IC_F0151
-                                              // MTK_IC_FLAG_CABAC_SIMP_G0061
-                                              // SEC_IC_ARP_SIG_G0072, Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
-                                              // MTK_LOW_LATENCY_IC_ENCODING_H0086  Low-latency IC encoding in JCT3V-H0086
-                                              // MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX  1  // Remove the global variables used in JCT3V-H0086
-                                              // SEC_IC_NEIGHBOR_CLIP_I0080    // Clipping of neighboring sample position, JCT3V-I0080
-                                              // LGE_CHROMA_IC_J0050_J0034
-#define NH_3D_IC_FIX                      1   // Fix uninitialized value in cDtParam.bUseIC (it happened on intra block)
-#define NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC   1   // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
-#define NH_3D_QTLPC                       1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
-                                              // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units 
-                                              // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
-#define NH_3D_NBDV_REF                    1
-#define NH_3D_MLC                         1
-#define NH_3D_FIX_PRUNING                 1
-#define NH_3D_VSP                         1
-#define NH_3D_IV_MERGE                    1
-#define NH_3D_SPIVMP                      1
 #define NH_3D_INTEGER_MV_DEPTH            1
-#define NH_3D_TEXT_MERGE                  1
-#define NH_3D_DBBP                         1
-#define BUF_FIX 1
-#define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
-                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
-                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
-                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
-                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
-                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
-                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
-                                              // QC_I0051_ARP_SIMP          
-                                              // SHARP_ARP_CHROMA_I0104     
-                                              // MTK_I0072_IVARP_SCALING_FIX
-                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
-                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
-#define NH_3D_DMM                         1   // Depth modeling modes
-#define NH_3D_DLT                         1   // Depth Lookup Table
-#define NH_3D_SDC_INTRA                   1   // Segment-wise DC Coding method for INTRA
-#define NH_3D_SDC_INTER                   1   // Segment-wise DC Coding method for INTER  
 #define NH_3D_ENC_DEPTH                   1   // Encoder optimizations for depth, incl.
                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
@@ -133,12 +83,21 @@
                                               // HHI_DMM4_ENC_I0066
                                               // H_3D_FAST_DEPTH_INTRA
-#define NH_3D_DIS                         1
 #define NH_3D_FAST_TEXTURE_ENCODING       1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
-#endif
-#if H_3D
-#define H_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
+#define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
+                                             // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
+                                             // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
+                                             // LGE_ARP_CTX_F0161                JCT3V-F0161
+                                             // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
+                                             // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
+                                             // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
+                                             // QC_I0051_ARP_SIMP          
+                                             // SHARP_ARP_CHROMA_I0104     
+                                             // MTK_I0072_IVARP_SCALING_FIX
+                                             // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
+                                             // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
+#define NH_3D_QTLPC                        1   // OL_QTLIMIT_PREDCODING_B0068 //JCT3V-B0068
                                               // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units 
                                               // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
-#define H_3D_VSO                          1   // VSO, View synthesis optimization, includes: 
+#define NH_3D_VSO                          1   // VSO, View synthesis optimization, includes: 
                                               // HHI_VSO
                                               // HHI_VSO_LS_TABLE_M23714 enable table base Lagrange multiplier optimization
@@ -146,5 +105,5 @@
                                               // LGE_WVSO_A0119
                                               // SCU_HS_VSD_BUGFIX_IMPROV_G0163
-#define H_3D_NBDV                         1   // Neighboring block disparity derivation 
+#define NH_3D_NBDV                         1   // Neighboring block disparity derivation 
                                               // QC_JCT3V-A0097 
                                               // LGE_DVMCP_A0126
@@ -162,5 +121,5 @@
                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
                                               // LGE_SIMP_DISP_AVAIL_J0041    // Use 2 status for disparity availability - DISP_AVAILABLE and DISP_NONE
-#define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
+#define NH_3D_IC                          1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
                                               // Unifying rounding offset, for IC part, JCT3V-D0135
                                               // Full Pel Interpolation for Depth, HHI_FULL_PEL_DEPTH_MAP_MV_ACC
@@ -176,5 +135,5 @@
                                               // LGE_CHROMA_IC_J0050_J0034
 #if NH_3D_NBDV
-#define H_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
+#define NH_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
                                               // MTK_D0156
                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
@@ -184,5 +143,5 @@
                                               // SEC_VER_DONBDV_H0103          Vertical DV Restriction for DoNBDV
 #endif
-#define H_3D_VSP                          1   // View synthesis prediction
+#define NH_3D_VSP                          1   // View synthesis prediction
                                               // MERL_C0152: Basic VSP
                                               // MERL_D0166: Reference view selection in NBDV & Bi-VSP
@@ -202,5 +161,6 @@
                                               // MTK_MRG_LIST_SIZE_CLEANUP_J0059   1   // Include VSP for deriving merge candidate list size, JCT3V-J0059
                                               // SEC_A1_BASED_VSP_J0039            1   // Removal of redundant VSP in Merge list
-#define H_3D_IV_MERGE                     1   // Inter-view motion merge candidate
+#define NH_3D_MLC                          1
+#define NH_3D_IV_MERGE                     1  // Inter-view motion merge candidate
                                               // HHI_INTER_VIEW_MOTION_PRED 
                                               // SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
@@ -209,8 +169,6 @@
                                               // MTK_INTERVIEW_MERGE_A0049     , second part
                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
-                                              // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
                                               // QC_INRIA_MTK_MRG_E0126 
                                               // ETRIKHU_MERGE_REUSE_F0093 QC_DEPTH_IV_MRG_F0125, JCT3V-F0125: Depth oriented Inter-view MV candidate
-                                              // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
                                               // MTK_NBDV_IVREF_FIX_G0067      , Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
                                               // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
@@ -225,32 +183,51 @@
                                               // SEC_SIMP_SHIFTED_DV_I0086     Simplification of Shifted DV candidate, JCT3V-I0086
                                               // SEC_SHIFTED_IVMC_POS_K0036    Position Derivation for Shifted-IVMC, JCT3V-K0036
-#define H_3D_TMVP                         1   // QC_TMVP_C0047 
+#define NH_3D_TEXT_MERGE                  1
+                                              // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
+                                              // EC_MPI_ENABLING_MERGE_F0150, MPI flag in VPS and enabling in Merge mode
+#define NH_3D_TMVP                        1   // QC_TMVP_C0047 
                                               // Sony_M23639
                                               // H_3D_TMVP_SCALING_FIX_K0053       1   // QC/CY for K0053
-#define H_3D_DIM                          1   // DIM, Depth intra modes, includes:
+#define NH_3D_DMM                         1   // Depth modeling modes
+                                              // HHI_DMM_PRED_TEX
                                               // HHI_DMM_WEDGE_INTRA
-                                              // HHI_DMM_PRED_TEX
                                               // FIX_WEDGE_NOFLOAT_D0036
                                               // LGE_EDGE_INTRA_A0070
                                               // LGE_DMM3_SIMP_C0044
                                               // QC_DC_PREDICTOR_D0183
+                                              // LGE_CONCATENATE_D0141
+                                              // PKU_QC_DEPTH_INTRA_UNI_D0195
+                                              // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
+                                              // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
+                                              // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
+                                              // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
+                                              // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
+                                              // HHI_DIM_PREDSAMP_FIX_F0171
+                                              // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
+                                              // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
+                                              // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding 
+                                              // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
+                                              // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
+                                              // HS_DMM_SIGNALLING_I0120
+                                              // SHARP_DMM1_I0110 LUT size reduction for DMM1 proposed in JCT3V-I0110 
+                                              // MTK_DMM_SIM_J0035
+                                              // SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation 
+#define NH_3D_DLT                         1   // Depth Lookup Table
                                               // HHI_DELTADC_DLT_D0035
-                                              // PKU_QC_DEPTH_INTRA_UNI_D0195
+                                              // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
+                                              // SEC_NO_RESI_DLT_H0105    
+                                              // MTK_DLT_CODING_FIX_H0091 
+                                              // H_3D_DELTA_DLT
+                                              // RWTH_DLT_CLIP_I0057
+                                              // SHARP_DLT_SIMP_J0029 DLT(DepthValue2Idx[]) table derivation cleanup  
+#define NH_3D_SDC_INTRA                   1   // Segment-wise DC Coding method for INTRA
+#define NH_3D_SDC_INTER                   1   // Segment-wise DC Coding method for INTER  
                                               // RWTH_SDC_DLT_B0036
                                               // INTEL_SDC64_D0193
                                               // RWTH_SDC_CTX_SIMPL_D0032
-                                              // LGE_CONCATENATE_D0141
                                               // FIX_SDC_ENC_RD_WVSO_D0163
                                               // MTK_SAMPLE_BASED_SDC_D0110
-                                              // SEC_DMM2_E0146_HHIFIX Removal of DMM2 from DMMs
-                                              // ZJU_DEPTH_INTRA_MODE_E0204 Simplified Binarization for depth_intra_mode
                                               // KWU_SDC_SIMPLE_DC_E0117 Simplified DC calculation for SDC
-                                              // SCU_HS_DMM4_REMOVE_DIV_E0242 DMM4 Division Removal
                                               // LGE_SDC_REMOVE_DC_E0158 Removal of DC mode from SDC
-                                              // LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 1   Removal of overlap between DMM3 and DMM1
-                                              // LGE_PRED_RES_CODING_DLT_DOMAIN_F0159 JCT3V-F0159
-                                              // HHI_DIM_PREDSAMP_FIX_F0171
-                                              // SEC_DMM3_RBC_F0147 Removal of DMM3 and RBC from DMMs
-                                              // QC_DIM_DELTADC_UNIFY_F0132 Unify delta DC coding in depth intra modes
                                               // Unify intra SDC and inter SDC
                                               // QC_GENERIC_SDC_G0122 Generalize SDC to all depth intra modes
@@ -259,31 +236,16 @@
                                               // QC_PKU_SDC_SPLIT_G0123 Intra SDC Split
                                               // HS_DMM_SDC_PREDICTOR_UNIFY_H0108  Unification of DMM and SDC predictor derivation
-                                              // LGE_SIMP_DIM_NOT_PRESENT_FLAG_CODING_H0119_H0135  Use only one context for CABAC of dim_not_present_flag
-                                              // QC_SIMP_DELTADC_CODING_H0131   Simplify detaDC entropy coding 
-                                              // MTK_DMM_SIMP_CODE_H0092        Remove CABAC context for DMM1 mode coding
-                                              // MTK_DELTA_DC_FLAG_ONE_CONTEXT_H0084_H0100_H0113 Use only one context for CABAC of delta_dc_flag as in JCTVC-H0084, JCTVC-H0100 and JCTVC-H0113
                                               // MTK_SDC_FLAG_FIX_H0095                          Remove conditional check of PCM flag based on SDC flag, JCTVC-H0095
-                                              // SEC_NO_RESI_DLT_H0105    
-                                              // MTK_DLT_CODING_FIX_H0091 
-                                              // HS_DMM_SIGNALLING_I0120
-                                              // SHARP_DMM1_I0110 LUT size reduction for DMM1 proposed in JCT3V-I0110 
                                               // FAST_SDC_OFFSET_DECISION_I0084
                                               // SEPARATE_FLAG_I0085
-                                              // H_3D_DELTA_DLT
-                                              // RWTH_DLT_CLIP_I0057
-                                              // MTK_DMM_SIM_J0035
                                               // MTK_J0033
-                                              // SHARP_DLT_SIMP_J0029 DLT(DepthValue2Idx[]) table derivation cleanup
-                                              // SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation 
-#define H_3D_INTER_SDC                    1   // INTER SDC, Inter simplified depth coding
                                               // LGE_INTER_SDC_E0156 Enable inter SDC for depth coding
                                               // SEC_INTER_SDC_G0101 Improved inter SDC with multiple DC candidates
-#define H_3D_INTER_SDC_FIX                1
-#define H_3D_SPIVMP                       1   // H_3D_SPIVMP JCT3V-F0110: Sub-PU level inter-view motion prediction
+#define NH_3D_SPIVMP                       1   // H_3D_SPIVMP JCT3V-F0110: Sub-PU level inter-view motion prediction
                                               // SEC_SPIVMP_MCP_SIZE_G0077, Apply SPIVMP only to 2Nx2N partition, JCT3V-G0077
                                               // QC_SPIVMP_MPI_G0119 Sub-PU level MPI merge candidate
                                               // Simplification on Sub-PU level temporal interview motion prediction
                                               // MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
-#define H_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
+#define NH_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
                                               // MTK_DBBP_AMP_REM_H0072   
                                               // RWTH_DBBP_NO_SPU_H0057   
@@ -298,18 +260,10 @@
                                               // RWTH_DBBP_NO_SATD_K0028
                                               // HS_DBBP_CLEAN_K0048
-#define H_3D_DDD                          1   // Disparity derived depth coding
-                                              // LGE_DDD_REMOVAL_J0042_J0030 DDD removal
-#define H_3D_DIS                          1   // Depth intra skip 
+#define NH_3D_DIS                         1   // Depth intra skip 
                                               // SEC_DEPTH_INTRA_SKIP_MODE_K0033  Depth intra skip mode
 #define H_3D_FCO                          0   // Flexible coding order for 3D
-#define H_3D_FAST_INTRA_SDC               1   // I0123
 // OTHERS
                                               // MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 // Progressive MV Compression, JCT3V-E0170
-#define H_3D_FAST_TEXTURE_ENCODING        1   // Fast merge mode decision and early CU determination for texture component of dependent view, JCT3V-E0173
                                               // MTK_FAST_TEXTURE_ENCODING_E0173
-#if H_3D_DIM
-#define H_3D_FAST_DEPTH_INTRA             1   // Fast DMM Selection
-                                              // SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX
-#endif
 //HLS
                                              // HHI_DEPENDENCY_SIGNALLING_I1_J0107
@@ -321,8 +275,8 @@
                                              // H_3D_DIRECT_DEP_TYPE     
 // Rate Control
-#define KWU_FIX_URQ                       1
+#define KWU_FIX_URQ                       0
 #define KWU_RC_VIEWRC_E0227               0  ///< JCT3V-E0227, view-wise target bitrate allocation
 #define KWU_RC_MADPRED_E0227              0  ///< JCT3V-E0227, inter-view MAD prediction
-#endif // H_3D
+#endif // NH_3D
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   DERIVED DEFINES ///////////////////////////////////  
@@ -349,14 +303,4 @@
 #if NH_3D_ARP
 #define H_3D_ARP_WFNR                     3
-#endif
-///// ***** DEPTH INTRA MODES *********
-#if H_3D_DIM
-                                              // HHI_DMM4_ENC_I0066
-#define H_3D_DIM_DMM                      1   // Depth Modeling Modes
-#define H_3D_DIM_SDC                      1   // Simplified Depth Coding method
-#define H_3D_DIM_DLT                      1   // Depth Lookup Table
-#define H_3D_DIM_ENC                      1   // Depth Intra encoder optimizations, includes:
-                                              // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
-                                              // LG_ZEROINTRADEPTHRESI_A0087
 #endif
 /////////////////////////////////////////////////////////////////////////////////////
@@ -389,32 +333,4 @@
 // TBD: Check if integration is necessary. 
 #define H_MV_HLS_PTL_LIMITS                  0
-#define H_MV_HLS7_GEN                        0  // General changes (not tested)
-// POC
-// #define H_MV_HLS_7_POC_P0041_3            0 // (POC/P0041/POC reset) #3 It was remarked that we should require each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. This was agreed. Decision: Adopt (with constraint for discardable_flag as described above) 
-// #define H_MV_HLS_7_POC_P0041_FIXES        0 // (POC/P0041/Fixes) For each non-IRAP picture that has discardable_flag equal to 1 to have NUT value indicating that it is a sub-layer non-reference picture. 
-// #define H_MV_HLS_7_POC_P0056_4            0 // (POC/P0056/layer tree poc) #4 Proposal 1: If the POC reset approach is adopted as the basis for multi-layer POC derivation, it is proposed to derive the POC anchor picture from the previous TID0 picture (that is not a RASL picture, a RADL picture or a sub-layer non-reference picture and not with discardable_flag equal to 1) of  the current layer or any of its reference layer. This is asserted to improve loss resilience and reduce bit rate overhead. Decision: Adopt Proposal 1 (with the suggested modifications Ewith text provided as P0297).
-// SEI related
-//#define H_MV_HLS_8_SEI_NODOC_53  0 // #53 (SEI    /NODOC/Added Multiview view position SEI message) Plain copy from AVC.
-//#define H_MV_HLS_8_SEI_NODOC_52  0 // #52 (SEI    /NODOC/Added Multiview acquisition information SEI) Plain copy from AVC. 
-//#define H_MV_HLS_8_SEI_NODOC_51  0 // #51 (SEI    /NODOC/Added Multiview scene information SEI message)
-//#define H_MV_HLS_8_SEI_Q0189_35  0 // #35 (SEI    /Q0189/SEI message for indicating constraints on TMVP) Proposal 2.3,  SEI message for indicating constraints on TMVP
-//#define H_MV_HLS_8_EDF_Q0116_29  0 // #29 (ED.FIX /Q0116/Recovery point SEI) , consider adding a note regarding how random accessibility is affected by the recovery point SEI message
-//#define H_MV_HLS_8_GEN_Q0183_23  0 // #23 (GEN    /Q0183/SEI clean-ups) numerous small clean-ups on SEI messages.
-//#define H_MV_HLS_8_MIS_Q0247_49  0 // #49 (MISC   /Q0247/frame-field information SEI message)
-//#define H_MV_HLS_8_MIS_Q0189_34  0 // #34 (MISC   /Q0189/slice temporal mvp enabled flag) Proposal 2.2, clarification of semantics of slice temporal mvp enabled flag
-//#define H_MV_HLS_8_EDF_Q0081_01  0 // #1  (ED.FIX /Q0081/alpha channel persist) On reuse of alpha planes in auxiliary pictures. It was asked why there would not be a presumption that the alpha channel content would simply persist, without needing the flag to indicate it. Decision (Ed.): Delegated to editors to clarify, as necessary, that the alpha channel content persists until cancelled or updated in output order.
-//#define H_MV_HLS_8_SEI_Q0253_37  0 // #37 (SEI    /Q0253/layer not present), modified semantics of layers not present SEI message to correct bug introduced during editing 
-//#define H_MV_HLS_8_SEI_Q0045_11  0 // #11 (SEI    /Q0045/Overlay) Proposal for an SEI message on selectable overlays. Decision: Adopt (modified for variable-length strings).
-//#define H_MV_HLS_7_SEI_P0133_28  0 // (SEI/P0133/Recovery point SEI) #28 Decision: Adopt change to recover point semantics only (-v3)
-//#define H_MV_HLS_7_SEI_P0123_25  0 // (SEI/P0123/Alpha channel info) #25 Add alpha channel information SEI message Decision: Adopt. Constrain the bit depth indicated to be equal to the coded bit depth of the aux picture. 
-// DPB
-//#define H_MV_HLS_8_HRD_Q0102_09  0 // #9  (HRD    /Q0102/NoOutputOfPriorPicsFlag) It was suggested that also the separate_colour_plane_flag should affect inference of NoOutputOfPriorPicsFlag. Decision (Ed.): Agreed (affects RExt text).
-//#define H_MV_HLS_8_DBP_Q0154_38  0 // #38 (DBP    /Q0154/VPS DPB) Proposal in C.5.2.1: Add in the decoding process that when a new VPS is activated, all pictures in the DPB are marked as unused for reference
-//#define H_MV_HLS_8_HRD_Q0154_10  0 // #10 (HRD    /Q0154/DPB Flushing and parameters) On picture flushing and DPB parameters Decision: Adopted (some details to be discussed further in BoG).
-//#define H_MV_HLS_7_OTHER_P0187_1 0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
-// OTHERS
-//#define H_MV_HLS_8_HSB_Q0041_03  0 // #3  (HS     /Q0041/hybrid scalability) The proposed text was endorsed, with non-editorial open issues considered as follows ?// #define H_MV_HLS_7_OTHER_P0187_1          0 // (OTHER/P0187/NoOutputOfPriorPicsFlag) #1 Inference of NoOutputOfPriorPicsFlag and proposes to take into account colour format and bit depth for the inference in addition to spatial resolution 
-//#define H_MV_HLS_8_MIS_Q0078_24  0 // #24 (MISC   /Q0078/scan and pic type) , Items 3 b,c and 4, clarifying which pictures in an output layer sets are applied the values of general_progressive_source_flag, general_interlaced_source_flag, general_non_packed_constraint_flag and general_frame_only_constraint_flag.
-//#define H_MV_HLS_7_HRD_P0138_6   0 //     (HRD/P0138/HRD parameters for bitstreams excluding) #6 Decision: Adopt (as revised in updated contribution, with the specification of a flag in the BP SEI (HRD/P0192/sub-DPB) #12 Establish sub-DPBs based on the representation format indicated at the VPS level. It was suggested that the expressed shared capacity limit would need to be less than or equal to the sum of the individual capacity limits. Decision: Adopt as modified. Further study is encouraged on profile/level constraint selections. 
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
@@ -871,4 +787,16 @@
 #define NUM_SAO_BO_CLASSES_LOG2  5
 #define NUM_SAO_BO_CLASSES       (1<<NUM_SAO_BO_CLASSES_LOG2)
+#if NH_MV
+enum DecodingProcess
+{
+  INVALID,
+  CLAUSE_8,
+  ANNEX_C,
+  ANNEX_F,
+  ANNEX_G,
+  ANNEX_H,
+  ANNEX_I  
+};
+#endif
 namespace Profile
 {
@@ -1017,4 +945,9 @@
   AUX_ID = 3,
 };
+enum DecProcPart
+{
+  START_PIC,
+  FINALIZE_PIC
+};
 #endif
 #if NH_3D
