Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 193)
@@ -58,5 +58,5 @@
 
 #define HM_VERSION        "6.1"
-#define NV_VERSION        "4.0.1"                 ///< Current software version
+#define NV_VERSION        "4.1"                  ///< Current software version
 
 // ====================================================================================================================
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/DebugLog.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/DebugLog.cpp	(revision 166)
+++ 	(revision )
@@ -1,565 +1,0 @@
-#include "CommonDef.h"
-#include "TComYuv.h"
-#include "TComPic.h"
-#include "../TLibDecoder/TDecCu.h"
-#include "DebugLog.h"
-
-
-char* pcPartSizeName[] =
-{
-  "SIZE_2Nx2N",           ///< symmetric motion partition,  2Nx2N
-  "SIZE_2NxN",            ///< symmetric motion partition,  2Nx N
-  "SIZE_Nx2N",            ///< symmetric motion partition,   Nx2N
-  "SIZE_NxN",             ///< symmetric motion partition,   Nx N
-
-  "SIZE_2NxnU",           ///< asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)
-  "SIZE_2NxnD",           ///< asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)
-  "SIZE_nLx2N",           ///< asymmetric motion partition, ( N/2)x2N + (3N/2)x2N
-  "SIZE_nRx2N"            ///< asymmetric motion partition, (3N/2)x2N + ( N/2)x2N
-};
-
-char* pcPredModeName[] = 
-{
-  "MODE_SKIP",            ///< SKIP mode
-  "MODE_INTER",           ///< inter-prediction mode
-  "MODE_INTRA"            ///< intra-prediction mode
-#if FORCE_REF_VSP==1
-  ,"MODE_SYNTH"           ///< vsp skip mode
-#endif
-};
-
-void printMotionInfo( TComDataCU* pcCU, UInt uiIdx, FILE* pfFile )
-{
-  UInt iInterDir = pcCU->getInterDir( uiIdx );
-  fprintf(pfFile, "interDir,%d, ", iInterDir );
-  if (iInterDir != 2) {
-    fprintf(pfFile, "L0Idx,%d, ", pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx( uiIdx ));
-    fprintf(pfFile, "L0Mv(,%d,%d,), ", pcCU->getCUMvField(REF_PIC_LIST_0)->getMv( uiIdx ).getHor(), pcCU->getCUMvField(REF_PIC_LIST_0)->getMv( uiIdx ).getVer() );
-  } else {
-    fprintf(pfFile, "L0Idx,-, L0Mv(,-,-,), ");
-  }
-  if (iInterDir != 1) {
-    fprintf(pfFile, "L1Idx,%d, ", pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx( uiIdx ));
-    fprintf(pfFile, "L1Mv(,%d,%d,), ", pcCU->getCUMvField(REF_PIC_LIST_1)->getMv( uiIdx ).getHor(), pcCU->getCUMvField(REF_PIC_LIST_1)->getMv( uiIdx ).getVer() );
-  } else {
-    fprintf(pfFile, "L1Idx,-, L1Mv(,-,-,), ");
-  }
-}
-
-bool DebugLog::DebugLogOut( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  if ( !m_pfDebugLogFile ) return false;
-
-  int iIdxWidth = (pcCU->getWidth( uiAbsPartIdx ) << uiDepth) >> 2;
-  int iXoffset  = (g_auiZscanToRaster[uiAbsPartIdx] % iIdxWidth) << 2;
-  int iYoffset  = (g_auiZscanToRaster[uiAbsPartIdx] / iIdxWidth) << 2;
-  fprintf(m_pfDebugLogFile, "Pos(,%d,%d,) , PartIdx,%d, ", pcCU->getCUPelX()+iXoffset, pcCU->getCUPelY()+iYoffset, uiAbsPartIdx);
-#if (VSP_N)
-  {
-    char cRefVsp = 0; Int aiRefIdx[2] = {-1, -1};
-    Int iRefIdx = pcCU->getCUMvField( RefPicList(0) )->getRefIdx( uiAbsPartIdx ); aiRefIdx[0] = iRefIdx;
-    if( iRefIdx >= 0 ) cRefVsp |= (pcCU->getSlice()->getRefViewId( RefPicList(0), iRefIdx ) == NUM_VIEW_VSP ? 0x01 : 0);
-    iRefIdx = pcCU->getCUMvField( RefPicList(1) )->getRefIdx( uiAbsPartIdx ); aiRefIdx[1] = iRefIdx;
-    if( iRefIdx >= 0 ) cRefVsp |= (pcCU->getSlice()->getRefViewId( RefPicList(1), iRefIdx ) == NUM_VIEW_VSP ? 0x02 : 0);
-    fprintf(m_pfDebugLogFile, "VSP,%d, RefIdx(,%d,%d,), ", cRefVsp, aiRefIdx[0], aiRefIdx[1] ); // 0:not VSP, 1:VSP L0, 2:VSP L1, 3:VSP Bi
-    fprintf(m_pfDebugLogFile, "MV(");
-    if(aiRefIdx[0]>=0)fprintf(m_pfDebugLogFile, "(,%d,%d,)",pcCU->getCUMvField( RefPicList(0) )->getMv(uiAbsPartIdx).getHor(),pcCU->getCUMvField( RefPicList(0) )->getMv(uiAbsPartIdx).getVer());
-    else              fprintf(m_pfDebugLogFile, "(,-,-,)");
-    if(aiRefIdx[1]>=0)fprintf(m_pfDebugLogFile, "(,%d,%d,)",pcCU->getCUMvField( RefPicList(1) )->getMv(uiAbsPartIdx).getHor(),pcCU->getCUMvField( RefPicList(1) )->getMv(uiAbsPartIdx).getVer());
-    else              fprintf(m_pfDebugLogFile, "(,-,-,)");
-    fprintf(m_pfDebugLogFile, ")");
-  }
-#endif
-    fprintf(m_pfDebugLogFile, "depth,%d,(,%d x %d,), ", uiDepth, pcCU->getWidth( uiAbsPartIdx ), pcCU->getHeight( uiAbsPartIdx ));
-    fprintf(m_pfDebugLogFile, "Predmode,%s, ", 
-#if FORCE_REF_VSP==1
-    pcCU->getPredictionMode( uiAbsPartIdx ) < 4 ? 
-#else
-    pcCU->getPredictionMode( uiAbsPartIdx ) < 3 ? 
-#endif
-    pcPredModeName[(int)pcCU->getPredictionMode( uiAbsPartIdx )] : "SIZE_NONE");
-#if FORCE_REF_VSP==1
-    fprintf(m_pfDebugLogFile, "VspSkipFlg,%d,", pcCU->getPredictionMode( uiAbsPartIdx )==MODE_SYNTH?1:0);
-#endif
-#if HHI_MPI
-    fprintf(m_pfDebugLogFile, "TextModeDepFlg,%d,", pcCU->getSlice()->getIsDepth() ? (pcCU->getTextureModeDepth( uiAbsPartIdx )==uiDepth) : 0 );
-#endif
-    fprintf(m_pfDebugLogFile, "Mergeflag,%d,MergeIdx,%d,", pcCU->getMergeFlag( uiAbsPartIdx ), pcCU->getMergeIndex( uiAbsPartIdx ) );
-    fprintf(m_pfDebugLogFile, "Partsize,%s, ", pcCU->getPartitionSize( uiAbsPartIdx ) < 8 ? pcPartSizeName[(int)pcCU->getPartitionSize( uiAbsPartIdx )] : "SIZE_NONE");
-    fprintf(m_pfDebugLogFile, "Cbf(,%d,%d,%d,), ", pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA), pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U), pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) );
-
-#if OUT_PRED_INFO
-  UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
-  if (pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA) {
-    //InterDirectionNum,L0Idx,L0Mv,L1Idx,L1Mv
-    printMotionInfo( pcCU, uiAbsPartIdx, m_pfDebugLogFile );
-    switch ( pcCU->getPartitionSize( uiAbsPartIdx ) )
-    {
-      case SIZE_2Nx2N:{ break; }
-      case SIZE_2NxN: { printMotionInfo( pcCU, uiAbsPartIdx + (uiPartOffset << 1), m_pfDebugLogFile );    break; }
-      case SIZE_Nx2N: { printMotionInfo( pcCU, uiAbsPartIdx +  uiPartOffset      , m_pfDebugLogFile );    break; }
-      case SIZE_NxN:  
-      {
-        for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) {
-          printMotionInfo( pcCU, uiAbsPartIdx + uiPartOffset * iPartIdx, m_pfDebugLogFile );
-        }
-        break;
-      }
-#if ASYMMETRIC_USE
-      case SIZE_2NxnU:{ printMotionInfo( pcCU, uiAbsPartIdx + (uiPartOffset >> 1)                      , m_pfDebugLogFile );    break; }
-      case SIZE_2NxnD:{ printMotionInfo( pcCU, uiAbsPartIdx + (uiPartOffset << 1) + (uiPartOffset >> 1), m_pfDebugLogFile ); break; }
-      case SIZE_nLx2N:{ printMotionInfo( pcCU, uiAbsPartIdx + (uiPartOffset >> 2)                      , m_pfDebugLogFile );    break; }
-      case SIZE_nRx2N:{ printMotionInfo( pcCU, uiAbsPartIdx + (uiPartOffset     ) + (uiPartOffset >> 2), m_pfDebugLogFile ); break; }
-#endif
-      default:        { break; }
-    }
-  } else {
-    //IntraPredDirection
-    fprintf( m_pfDebugLogFile, "IntraDir(L,%d,C,%d,), ", pcCU->getLumaIntraDir( uiAbsPartIdx ), pcCU->getChromaIntraDir( uiAbsPartIdx ) );
-    if (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN)
-    {
-      for (int i=1; i < 4; i++) {
-        fprintf( m_pfDebugLogFile, "IntraDir(L,%d,C,%d,), ", pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset * i ), pcCU->getChromaIntraDir( uiAbsPartIdx + uiPartOffset * i ) );
-      }
-    }
-  }
-#endif
-  fprintf(m_pfDebugLogFile, "\n");
-  return true;
-}
-
-
-//Color set function of TComYuv 
-#if DEBUGIMGOUT
-Void TComYuv::colsetToPicYuv   ( const UChar ucColor[3], Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx, Bool bDrawLine )
-{
-  colsetToPicLuma  ( ucColor[0],             iOffset, pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx, bDrawLine );
-  for (int i=0; i < 2; i++)
-    for (int j=0; j < 2; j++)
-      iOffset[i][j] >>= 1;
-  colsetToPicChroma( ucColor[1], ucColor[2], iOffset, pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx, bDrawLine );
-}
-
-Void TComYuv::colsetToPicLuma  ( const UChar ucLumaOffCol, Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx, Bool bDrawLine )
-{
-  Int  offset  = (g_uiBitIncrement>0)?(1<<(g_uiBitIncrement-1)):0;
-  Int  iStartX = bDrawLine ? 1:0;
-  Int  y, x, iWidth, iHeight;
-  iWidth  = m_iWidth >>uiPartDepth;
-  iHeight = m_iHeight>>uiPartDepth;
-
-  Pel* pSrc     = getLumaAddr(uiPartIdx, iWidth);
-  Pel* pDst     = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
-
-  UInt  iSrcStride  = getStride();
-  UInt  iDstStride  = pcPicYuvDst->getStride();
-
-  pSrc += iOffset[0][1] * iSrcStride + iOffset[0][0]; //TopLeft
-  pDst += iOffset[0][1] * iDstStride + iOffset[0][0]; //TopLeft
-  iWidth  = iOffset[1][0];  //ButtomRight
-  iHeight = iOffset[1][1];  //ButtomRight
-
-
-  if( bDrawLine )
-  {
-    for( x = 0; x < iWidth; x++ )
-      pDst[x] = (((pSrc[x] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL2;  //Top line
-    pDst += iDstStride;
-    pSrc += iSrcStride;
-    iHeight--;
-  }
-
-  if( ucLumaOffCol == 0 )
-  {
-    for ( y = iHeight; y != 0; y-- )
-    {
-      if( bDrawLine )
-        pDst[0] =  (((pSrc[0] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL2;  //Left line
-      for( x = iStartX; x < iWidth; x++ )
-        pDst[x] = (pSrc[x] + offset) >> g_uiBitIncrement;  //glay scale
-      pDst += iDstStride;
-      pSrc += iSrcStride;
-    }
-  } else {
-    for ( y = iHeight; y != 0; y-- )
-    {
-      if( bDrawLine )
-        pDst[0] =  (((pSrc[0] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL2;  //Left line
-      for( x = iStartX; x < iWidth; x++ )
-        pDst[x] = (((pSrc[x] + offset) >> g_uiBitIncrement) >> 2) + ucLumaOffCol;
-      pDst += iDstStride;
-      pSrc += iSrcStride;
-    }
-  }
-}
-
-Void TComYuv::colsetToPicChroma( const UChar ucUCol, const UChar ucVCol, Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx, Bool bDrawLine )
-{
-  Int  y, x, iWidth, iHeight;
-  iWidth  = m_iCWidth >>uiPartDepth;
-  iHeight = m_iCHeight>>uiPartDepth;
-  Int  iStartX = bDrawLine ? 1:0;
-
-  Pel* pDstU      = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx );
-  Pel* pDstV      = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx );
-
-  UInt  iDstStride = pcPicYuvDst->getCStride();
-
-  pDstU += iOffset[0][1] * iDstStride + iOffset[0][0]; //TopLeft
-  pDstV += iOffset[0][1] * iDstStride + iOffset[0][0]; //TopLeft
-  iWidth  = iOffset[1][0];  //ButtomRight
-  iHeight = iOffset[1][1];  //ButtomRight
-
-  if( bDrawLine )
-  {
-    for( x = 0; x < iWidth; x++ )
-    {
-      pDstU[x] = LINE_CB_COL2;  //Top line color
-      pDstV[x] = LINE_CR_COL2;  //Top line color
-    }
-    pDstV += iDstStride;
-    pDstU += iDstStride;
-    iHeight--;
-  }
-  for ( y = iHeight; y != 0; y-- )
-  {
-    if( bDrawLine ) {
-      pDstU[0] =  LINE_CB_COL2;  //Left line color
-      pDstV[0] =  LINE_CR_COL2;  //Left line color
-    }
-    for( x = iStartX; x < iWidth; x++ )
-    {
-      pDstU[x] = ucUCol;
-      pDstV[x] = ucVCol;
-    }
-    pDstU += iDstStride;
-    pDstV += iDstStride;
-  }
-}
-
-Void TComYuv::drawLineToPicYuv ( bool bHor, bool bVer, UInt uiSize, TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx )
-{
-  Int  offset  = (g_uiBitIncrement>0)?(1<<(g_uiBitIncrement-1)):0;
-  Int  y, x, iWidth, iHeight, iWidthC, iHeightC;
-
-  iWidth   = m_iWidth >>uiPartDepth;
-  iHeight  = m_iHeight>>uiPartDepth;
-  iWidthC  = m_iCWidth >>uiPartDepth;
-  iHeightC = m_iCHeight>>uiPartDepth;
-
-
-  Pel* pSrc     = getLumaAddr(uiPartIdx, iWidth);
-  Pel* pDst     = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
-  Pel* pDstU    = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx );
-  Pel* pDstV    = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx );
-
-  UInt  iSrcStride  = getStride();
-  UInt  iDstStride  = pcPicYuvDst->getStride();
-  UInt  iDstStrideC = pcPicYuvDst->getCStride();
-
-  if ( bHor )
-  {
-    //Luma
-    Pel* pDstHor = pDst + iDstStride * ((iHeight * uiSize) >> 2);
-    Pel* pSrcHor = pSrc + iSrcStride * ((iHeight * uiSize) >> 2);
-    for( x = 1; x < iWidth; x++ )
-      pDstHor[x] = (((pSrcHor[x] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL;
-    //CbCr
-    Pel* pDstUHor = pDstU + iDstStrideC * ((iHeightC * uiSize) >> 2);
-    Pel* pDstVHor = pDstV + iDstStrideC * ((iHeightC * uiSize) >> 2);
-    for( x = 1; x < iWidthC; x++ )
-    {
-      pDstUHor[x] = LINE_CB_COL;
-      pDstVHor[x] = LINE_CR_COL;
-    }
-  }
-  if ( bVer )
-  {
-    //Luma
-    Pel* pDstVer = pDst + iDstStride;
-    Pel* pSrcVer = pSrc + iSrcStride;
-    x = (iWidth * uiSize) >> 2;
-    for ( y = iHeight; y != 1; y-- )
-    {
-      pDstVer[x] = (((pSrcVer[x] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL;
-      pDstVer += iDstStride;
-      pSrcVer += iSrcStride;
-    }
-    //CbCr
-    Pel* pDstVerU = pDstU + iDstStrideC;
-    Pel* pDstVerV = pDstV + iDstStrideC;
-    x = (iHeightC * uiSize) >> 2;
-    for ( y = iHeightC; y != 1; y-- )
-    {
-      pDstVerU[x] = LINE_CB_COL;
-      pDstVerV[x] = LINE_CR_COL;
-      pDstVerU += iDstStrideC;
-      pDstVerV += iDstStrideC;
-    }
-  }
-  
-}
-
-Void TComYuv::drawRectToPicYuv ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx )
-{
-  Int  offset  = (g_uiBitIncrement>0)?(1<<(g_uiBitIncrement-1)):0;
-  Int  y, x, iWidth, iHeight, iWidthC, iHeightC;
-
-  iWidth   = m_iWidth >>uiPartDepth;
-  iHeight  = m_iHeight>>uiPartDepth;
-  iWidthC  = m_iCWidth >>uiPartDepth;
-  iHeightC = m_iCHeight>>uiPartDepth;
-
-
-  Pel* pSrc     = getLumaAddr(uiPartIdx, iWidth);
-  Pel* pDst     = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
-  Pel* pDstU    = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx );
-  Pel* pDstV    = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx );
-
-  UInt  iSrcStride  = getStride();
-  UInt  iDstStride  = pcPicYuvDst->getStride();
-  UInt  iDstStrideC = pcPicYuvDst->getCStride();
-
-  //X
-  {
-    //Luma
-    Pel* pDstHor = pDst;
-    Pel* pSrcHor = pSrc;
-    for( x = 0; x < iWidth; x++ )
-      pDstHor[x] = (((pSrcHor[x] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL2;
-  //CbCr
-    Pel* pDstUHor = pDstU;
-    Pel* pDstVHor = pDstV;
-    for( x = 0; x < iWidthC; x++ )
-    {
-      pDstUHor[x] = LINE_CB_COL2;
-      pDstVHor[x] = LINE_CR_COL2;
-    }
-  }
-
-  //Y
-  {
-    //Luma
-    Pel* pDstVer = pDst;
-    Pel* pSrcVer = pSrc;
-    x = 0;
-    for ( y = iHeight; y >= 0; y-- )
-    {
-      pDstVer[x] = (((pSrcVer[x] + offset) >> g_uiBitIncrement) >> 2) + LINE_LUMA_OFF_COL2;
-      pDstVer += iDstStride;
-      pSrcVer += iSrcStride;
-    }
-    //CbCr
-    Pel* pDstVerU = pDstU;
-    Pel* pDstVerV = pDstV;
-    x = 0;
-    for ( y = iHeightC; y >= 0; y-- )
-    {
-      pDstVerU[x] = LINE_CB_COL2;
-      pDstVerV[x] = LINE_CR_COL2;
-      pDstVerU += iDstStrideC;
-      pDstVerV += iDstStrideC;
-    }
-  }
-  
-}
-
-Void TDecCu::xColsetToPic( TComDataCU* pcCU, TComPicYuv* pcPicYuv, UInt uiZorderIdx, UInt uiDepth )
-{
-  int       iIdxWidth = (pcCU->getWidth( 0 ) << uiDepth) >> 2;
-  UInt      uiCUAddr  = pcCU->getAddr();
-  PredMode  ePredMode = pcCU->getPredictionMode( 0 );
-  Int       iRect[2][2] = {{0,0}, {0,0}};
-  Int       iColorIdx = 0;
-  UInt      uiPartAddr;
-
-  if ( ePredMode == MODE_INTER )
-  {
-    for (int iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
-    {
-      pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRect[1][0], iRect[1][1] );
-      iRect[0][0]  = (g_auiZscanToRaster[uiPartAddr] % iIdxWidth) << 2;
-      iRect[0][1]  = (g_auiZscanToRaster[uiPartAddr] / iIdxWidth) << 2;
-
-#if (VSP_N)
-      {
-        Char cRefVsp = 0x00;
-        Int iRefIdx = pcCU->getCUMvField( RefPicList(0) )->getRefIdx(iPartIdx);
-        if( iRefIdx >= 0 && pcCU->getSlice()->getRefViewId( RefPicList(0), iRefIdx ) == NUM_VIEW_VSP )
-          cRefVsp |= 0x01;
-        iRefIdx = pcCU->getCUMvField( RefPicList(1) )->getRefIdx(iPartIdx);
-        if( iRefIdx >= 0 && pcCU->getSlice()->getRefViewId( RefPicList(1), iRefIdx ) == NUM_VIEW_VSP )
-          cRefVsp |= 0x02;
-#if FORCE_REF_VSP
-        if( pcCU->isVspMode(iPartIdx) )
-          cRefVsp |= 0x04;
-#endif
-
-        switch( cRefVsp )
-        {
-        case 0: // INTER
-          iColorIdx = 2;
-          break;
-        case 1: // VSP L0
-          iColorIdx = 4;
-          break;
-        case 2: // VSP L1
-          iColorIdx = 6;
-          break;
-        case 3: // VSP Bi
-          iColorIdx = 7;
-          break;
-#if FORCE_REF_VSP
-        case 4: // VSP Skip
-          iColorIdx = 5;
-          break;
-#endif
-        default:
-          assert(0);
-          break;
-        }
-      }
-#else
-      iColorIdx = 2;
-#endif
-
-      m_ppcYuvReco[uiDepth]->colsetToPicYuv    ( g_ucCol[iColorIdx], iRect, pcPicYuv, uiCUAddr, uiZorderIdx );
-    }
-  } else {
-    iRect[0][0]=iRect[0][1]=0;
-    iRect[1][0]=pcCU->getWidth(0);
-    iRect[1][1]=pcCU->getHeight(0);
-
-    iColorIdx = ePredMode==MODE_SKIP ? 0 : 1;
-
-    m_ppcYuvReco[uiDepth]->colsetToPicYuv      ( g_ucCol[iColorIdx], iRect, pcPicYuv, uiCUAddr, uiZorderIdx );
-  }
-
-  switch ( pcCU->getPartitionSize( 0 ) )
-  {
-    case SIZE_2Nx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, false, 4, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_2NxN:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_Nx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_NxN:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , true , 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_2NxnU:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 1, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_2NxnD:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 3, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_nLx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 1, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_nRx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 3, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    default:
-      break;
-  }
-}
-
-Void TDecCu::xColsetToPicMerge( TComDataCU* pcCU, TComPicYuv* pcPicYuv, UInt uiZorderIdx, UInt uiDepth )
-{
-  int       iIdxWidth = (pcCU->getWidth( 0 ) << uiDepth) >> 2;
-  UInt      uiCUAddr  = pcCU->getAddr();
-  PredMode  ePredMode = pcCU->getPredictionMode( 0 );
-  Int       iRect[2][2] = {{0,0}, {0,0}};
-  Int       iColorIdx = 0;
-  UInt      uiPartAddr;
-  UInt      uiMergeIdx;
-  Bool      bSkip     = ePredMode == MODE_SKIP ? true : false;
-
-  if ( ePredMode == MODE_INTER || bSkip )
-  {
-    for (int iPartIdx = 0; iPartIdx < pcCU->getNumPartInter(); iPartIdx++ )
-    {
-      pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRect[1][0], iRect[1][1] );
-      iRect[0][0]  = (g_auiZscanToRaster[uiPartAddr] % iIdxWidth) << 2;
-      iRect[0][1]  = (g_auiZscanToRaster[uiPartAddr] / iIdxWidth) << 2;
-      Bool bMerge  = pcCU->getMergeFlag( iPartIdx );
-
-      if( bSkip || bMerge ) {
-        uiMergeIdx   = pcCU->getMergeIndex( iPartIdx );
-#if (FORCE_REF_VSP)
-        {
-          iColorIdx = bSkip ? 1 : (bMerge ? 5 : 0);
-          Int iRefIdx = pcCU->getCUMvField( RefPicList(0) )->getRefIdx(iPartIdx);
-          char cRefVsp = 0x00;
-          if( iRefIdx >= 0 && pcCU->getSlice()->getRefViewId( RefPicList(0), iRefIdx ) == NUM_VIEW_VSP )
-            cRefVsp |= 0x01;
-          iRefIdx = pcCU->getCUMvField( RefPicList(1) )->getRefIdx(iPartIdx);
-          if( iRefIdx >= 0 && pcCU->getSlice()->getRefViewId( RefPicList(1), iRefIdx ) == NUM_VIEW_VSP )
-            cRefVsp |= 0x02;
-
-          if( cRefVsp ) {
-            iColorIdx += 1;
-          } else if ( uiMergeIdx ) {
-            iColorIdx += 3;
-          }
-        }
-#else
-        iColorIdx = 2;
-#endif
-        assert( iColorIdx > 0 && iColorIdx < 10 );
-
-        m_ppcYuvReco[uiDepth]->colsetToPicYuv  ( g_ucCol[iColorIdx], iRect, pcPicYuv, uiCUAddr, uiZorderIdx );
-
-      } else {
-
-        //Inter Not Merge
-        m_ppcYuvReco[uiDepth]->colsetToPicYuv  ( g_ucCol[0], iRect, pcPicYuv, uiCUAddr, uiZorderIdx );
-
-      }
-    } // end iPartIdx loop
-
-  } else
-  {
-    //Intra , Not Merge Inter
-    iRect[0][0]=iRect[0][1]=0;
-    iRect[1][0]=pcCU->getWidth(0);
-    iRect[1][1]=pcCU->getHeight(0);
-
-    iColorIdx = 0;
-
-    m_ppcYuvReco[uiDepth]->colsetToPicYuv      ( g_ucCol[iColorIdx], iRect, pcPicYuv, uiCUAddr, uiZorderIdx );
-  }
-
-  switch ( pcCU->getPartitionSize( 0 ) )
-  {
-    case SIZE_2Nx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, false, 4, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_2NxN:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_Nx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    case SIZE_NxN:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , true , 2, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_2NxnU:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 1, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_2NxnD:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( true , false, 3, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_nLx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 1, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break; 
-    case SIZE_nRx2N:
-      m_ppcYuvReco[uiDepth]->drawLineToPicYuv  ( false, true , 3, pcPicYuv, uiCUAddr, uiZorderIdx );
-      break;
-    default:
-      break;
-  }
-}
-#endif //DEBUGIMGOUT
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/DebugLog.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/DebugLog.h	(revision 166)
+++ 	(revision )
@@ -1,53 +1,0 @@
-#ifndef __DEBUGLOG_H__
-#define __DEBUGLOG_H__
-
-#define OUT_PRED_INFO  0  //pred info(IntraDir/InterDirNum,Idx,Mv) output
-#define ASYMMETRIC_USE 1
-
-#include "TComDataCU.h"
-
-#define DECLOGFILENAME  "debuglogDec.txt"
-
-class DebugLog 
-{
-private:
-    FILE*  m_pfDebugLogFile;
-
-public:
-    DebugLog() { m_pfDebugLogFile = NULL; }
-    ~DebugLog() {}
-
-    bool   DebugLogFileOpen( char* pcFname ) { m_pfDebugLogFile = fopen( pcFname, "wt" ); return (m_pfDebugLogFile!=NULL); }
-    void   DebugLogFileClose()               { if (m_pfDebugLogFile) fclose(m_pfDebugLogFile); m_pfDebugLogFile=NULL; }
-
-    bool   DebugLogOut( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
-};
-
-
-//Colors
-//     Y=Org/2 + YOffset      YOffset  U    V        
-const UChar g_ucCol[11][3] = { {000, 128, 128}, //0 gray scale
-                               {128, 255, 000}, //1 light blue
-                               {128, 255, 128}, //2 lavender
-                               {128, 000, 000}, //3 green yellow
-                               {128, 000, 128}, //4 yellow
-                               {128, 255, 255}, //5 pink
-                               {128, 000, 255}, //6 orange
-                               {064, 000, 255}, //7 red 
-                               {064, 255, 000}, //8 blue
-                               {016, 000, 000}, //9 green
-                               {064, 128, 128}  //10 light gray scale
-                             };
-
-//CU
-#define LINE_LUMA_OFF_COL   g_ucCol[9][0] //9 green
-#define LINE_CB_COL         g_ucCol[9][1]
-#define LINE_CR_COL         g_ucCol[9][2]
-
-//PU
-#define LINE_LUMA_OFF_COL2  g_ucCol[7][0] //7 red
-#define LINE_CB_COL2        g_ucCol[7][1]
-#define LINE_CR_COL2        g_ucCol[7][2]
-
-
-#endif //__DEBUGLOG_H__
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 193)
@@ -76,6 +76,8 @@
   if( ucVspMergePos == VSP_MERGE_POS )
   {
-#if VSP_TEXT_ONLY
-    if( !getSlice()->getSPS()->isDepth() )
+#if VSP_CFG
+    if( getSlice()->getSPS()->getVspDepthPresentFlag() || !getSlice()->getSPS()->isDepth() )
+#else
+    if( !getSlice()->getVspDepthDisableFlag() || !getSlice()->getSPS()->isDepth() )
 #endif
     if( getSlice()->getSPS()->getViewId()!=0 && !bVspMvZeroDone )
@@ -150,7 +152,10 @@
   m_pcTrCoeffCr        = NULL;
 #if ADAPTIVE_QP_SELECTION  
+#if FIX_MEM_LEAKS
+  m_ArlCoeffIsAliasedAllocation = false;
   m_pcArlCoeffY        = NULL;
   m_pcArlCoeffCb       = NULL;
   m_pcArlCoeffCr       = NULL;
+#endif
 #endif
   
@@ -211,4 +216,16 @@
   m_piEdgeDeltaDC1      = NULL;
 #endif
+#endif
+#if OL_DEPTHLIMIT_A0044
+  //add a variable to store the partition information
+  //a 2D array in part_symbol, uidepth format
+  //initialize m_partInfo to OL_END_CU
+  for (Int i=0; i < OL_PART_BUF_SIZE; i++)
+  {
+    for (Int j=0; j < 2; j++)
+    {
+      m_uiPartInfo[i][j] = OL_END_CU;
+    }
+  }
 #endif
 }
@@ -295,4 +312,7 @@
       m_pcArlCoeffCb       = m_pcGlbArlCoeffCb;
       m_pcArlCoeffCr       = m_pcGlbArlCoeffCr;
+#if FIX_MEM_LEAKS
+      m_ArlCoeffIsAliasedAllocation = true;
+#endif
     }
     else
@@ -410,4 +430,12 @@
     if ( m_pcTrCoeffCr        ) { xFree(m_pcTrCoeffCr);         m_pcTrCoeffCr       = NULL; }
 #if ADAPTIVE_QP_SELECTION
+#if FIX_MEM_LEAKS
+    if (!m_ArlCoeffIsAliasedAllocation)
+    {
+      xFree(m_pcArlCoeffY); m_pcArlCoeffY = 0;
+      xFree(m_pcArlCoeffCb); m_pcArlCoeffCb = 0;
+      xFree(m_pcArlCoeffCr); m_pcArlCoeffCr = 0;
+    }
+#endif
     if ( m_pcGlbArlCoeffY     ) { xFree(m_pcGlbArlCoeffY);      m_pcGlbArlCoeffY    = NULL; }
     if ( m_pcGlbArlCoeffCb    ) { xFree(m_pcGlbArlCoeffCb);     m_pcGlbArlCoeffCb   = NULL; }
@@ -516,4 +544,7 @@
 Void TComDataCU::initCU( TComPic* pcPic, UInt iCUAddr )
 {
+#if OL_DEPTHLIMIT_A0044
+  TComDataCU* pcCU     = pcPic->getCU(iCUAddr);
+#endif
 
   m_pcPic              = pcPic;
@@ -732,4 +763,7 @@
     m_apcCUColocated[1] = getSlice()->getRefPic( REF_PIC_LIST_1, 0)->getCU( m_uiCUAddr );
   }
+#if OL_DEPTHLIMIT_A0044
+  setPartDumpFlag (pcCU->getPartDumpFlag());
+#endif
 }
 
@@ -1061,4 +1095,7 @@
   memcpy(m_uiSliceStartCU,pcCU->m_uiSliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition);
   memcpy(m_uiEntropySliceStartCU,pcCU->m_uiEntropySliceStartCU+uiPartOffset,sizeof(UInt)*m_uiNumPartition);
+#if OL_DEPTHLIMIT_A0044
+  setPartDumpFlag (pcCU->getPartDumpFlag());
+#endif
 }
 
@@ -2346,4 +2383,8 @@
 #if H0204_QP_PREDICTION
   UInt        lPartIdx, aPartIdx;
+#if FIX_COMP_WARNING_INIT
+  lPartIdx = 0; 
+  aPartIdx = 0;
+#endif
   TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU );
   TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_uiAbsIdxInLCU + uiCurrAbsIdxInLCU );
@@ -3146,5 +3187,9 @@
     RefPicList eRefList = uiRefIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
     Int iBestRefIdx = getCUMvField(eRefList)->getRefIdx(uiPartAddr);
-    if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx))
+    if(iBestRefIdx >= 0 && getSlice()->getViewId() == getSlice()->getRefViewId(eRefList, iBestRefIdx)
+#if VSP_N
+                        && getSlice()->getPOC() != getSlice()->getRefPOC(eRefList, iBestRefIdx)
+#endif
+      )
       iAddResiShift++;
   }
@@ -4614,7 +4659,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -4625,5 +4667,11 @@
       {
         Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+#if VSP_N & VSP_BUGFIX
+        Int refPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId);
+        //if( !pcTmpCU->isVspRef( eRefPicList, refId ) )
+        if ( refViewIdx!= m_pcSlice->getViewId() || refPOC != m_pcSlice->getPOC())
+#else
         if (refViewIdx!= m_pcSlice->getViewId())
+#endif
         {
            TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -4643,7 +4691,4 @@
 
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -4654,5 +4699,11 @@
       {
         Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+#if VSP_N & VSP_BUGFIX
+        Int refPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId);
+        //if( !pcTmpCU->isVspRef( eRefPicList, refId ) )
+        if ( refViewIdx!= m_pcSlice->getViewId() || refPOC != m_pcSlice->getPOC())
+#else
         if (refViewIdx!= m_pcSlice->getViewId())
+#endif
         {
            TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -4672,7 +4723,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -4683,5 +4731,11 @@
       {
         Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+#if VSP_N & VSP_BUGFIX
+        Int refPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId);
+        //if( !pcTmpCU->isVspRef( eRefPicList, refId ) )
+        if ( refViewIdx!= m_pcSlice->getViewId() || refPOC != m_pcSlice->getPOC())
+#else
         if (refViewIdx!= m_pcSlice->getViewId())
+#endif
         {
            TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -4700,7 +4754,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -4711,5 +4762,11 @@
       {
         Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+#if VSP_N & VSP_BUGFIX
+        Int refPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId);
+        //if( !pcTmpCU->isVspRef( eRefPicList, refId ) )
+        if ( refViewIdx!= m_pcSlice->getViewId() || refPOC != m_pcSlice->getPOC())
+#else
         if (refViewIdx!= m_pcSlice->getViewId())
+#endif
         {
            TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -4731,7 +4788,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
@@ -4742,5 +4796,11 @@
       {
         Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
+#if VSP_N & VSP_BUGFIX
+        Int refPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId);
+        //if( !pcTmpCU->isVspRef( eRefPicList, refId ) )
+        if ( refViewIdx!= m_pcSlice->getViewId() || refPOC != m_pcSlice->getPOC())
+#else
         if (refViewIdx!= m_pcSlice->getViewId())
+#endif
         {
            TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -4965,7 +5025,4 @@
   UInt uiLeftPartIdx = uiIdx;
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
@@ -4985,5 +5042,9 @@
           return;
         }
+#if VSP_N & VSP_BUGFIX
+        else if (pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId) != m_pcSlice->getPOC()) // MCP 
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5006,7 +5067,4 @@
 
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
@@ -5026,5 +5084,9 @@
           return;
         }
+#if VSP_N & VSP_BUGFIX
+        else if (pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId) != m_pcSlice->getPOC()) // MCP 
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5046,7 +5108,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
@@ -5066,5 +5125,9 @@
           return;
         }
-        else  // MCP 
+#if VSP_N & VSP_BUGFIX
+        else if (pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId) != m_pcSlice->getPOC()) // MCP 
+#else
+        else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5086,7 +5149,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
@@ -5106,5 +5166,9 @@
           return;
         }
+#if VSP_N & VSP_BUGFIX
+        else if (pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId) != m_pcSlice->getPOC()) // MCP 
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5128,7 +5192,4 @@
 #endif
   if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-#if VSP_N
-  if(pcTmpCU->getSlice()->getViewId() != NUM_VIEW_VSP)
-#endif
   {
     bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
@@ -5148,5 +5209,9 @@
           return;
         }
+#if VSP_N & VSP_BUGFIX
+        else if (pcTmpCU->getSlice()->getRefPOC( eRefPicList, refId) != m_pcSlice->getPOC()) // MCP 
+#else
         else // MCP 
+#endif
         {
           cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
@@ -5753,5 +5818,5 @@
   {
     aiRefIdx[iList] = getCUMvField( RefPicList(iList) )->getRefIdx( uiPartIdx );
-    if( aiRefIdx[iList] >= 0 && getSlice()->getRefViewId( RefPicList(iList), aiRefIdx[iList] ) == NUM_VIEW_VSP )
+    if( aiRefIdx[iList] >= 0 && isVspRef( RefPicList(iList), aiRefIdx[iList] ) )
     {
       iRet |= (iList ? 0x02 : 0x01); // L0=1, L1=2, BI=3
@@ -5802,4 +5867,17 @@
   return iRet; 
 }
+
+Bool TComDataCU::isVspRef ( RefPicList e, Int iRefIdx )
+{
+  if( iRefIdx < 0 ) return false;
+
+  if( getSlice()->getRefPic( e, iRefIdx )->getViewId() == getSlice()->getViewId()
+   && getSlice()->getRefPic( e, iRefIdx )->getPOC()    == getSlice()->getPOC()   )
+  {
+    return true;
+  }
+
+  return false;
+}
 #endif
 
@@ -5866,5 +5944,5 @@
  
 #if AMVP_VSP_UNAVAILABLE
-  if( pcTmpCU != NULL && pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && pcTmpCU->getSlice()->getRefViewId( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) == NUM_VIEW_VSP )
+  if( pcTmpCU != NULL && pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && pcTmpCU->isVspRef( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) )
   {
     return false;
@@ -5908,4 +5986,8 @@
       return false;
     }
+#if VSP_N ///
+    if( pcTmpCU->isVspRef( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) )
+      return false;
+#endif
     iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
@@ -6035,5 +6117,5 @@
 
 #if AMVP_VSP_UNAVAILABLE
-  if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && pcTmpCU->getSlice()->getRefViewId( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) == NUM_VIEW_VSP )
+  if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && pcTmpCU->isVspRef( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) )
   {
     return false;
@@ -6061,4 +6143,8 @@
     if( pcTmpCU->getSlice()->getRefViewId( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) != m_pcSlice->getRefViewId( eRefPicList, iRefIdx ) )
       return false;
+#if VSP_N ///
+    if( pcTmpCU->isVspRef( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) )
+      return false;
+#endif
     if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
     {
@@ -6084,7 +6170,11 @@
       return false;
     }
+#if VSP_N ///
+    if( pcTmpCU->isVspRef( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) )
+      return false;
+#endif
 
 #if VSP_N
-    if( pcTmpCU->getSlice()->getRefViewId( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) == NUM_VIEW_VSP )
+    if( pcTmpCU->isVspRef( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ) )
     {
       bRefVsp = true;
@@ -6119,7 +6209,11 @@
       return false;
     }
+#if VSP_N ///
+    if( pcTmpCU->isVspRef( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) )
+      return false;
+#endif
 
 #if VSP_N
-    if( pcTmpCU->getSlice()->getRefViewId( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) == NUM_VIEW_VSP )
+    if( pcTmpCU->isVspRef( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) ) )
     {
       bRefVsp = true;
@@ -6161,23 +6255,13 @@
   Int iColViewIdx, iColRefViewIdx;
   TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
-#if VSP_MV_ZERO // shimizu
+#if VSP_N
+  if( pColPic->getSlice(0)->getViewId() == getSlice()->getViewId() && pColPic->getSlice(0)->getPOC() == getSlice()->getPOC() )
+  {
+    return false;
+  }
+#endif
   TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
   iColViewIdx = pColCU->getSlice()->getViewId();
-#if VSP_N
-  if( iColViewIdx == NUM_VIEW_VSP )
-  {
-    return false;
-  }
-#endif
-#else  
-#if VSP_N
-  if( pColPic->getSlice(0)->getViewId() == NUM_VIEW_VSP )
-  {
-    return false;
-  }
-#endif
-  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
-  iColViewIdx = pColCU->getSlice()->getViewId();
-#endif
+
 
   if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiAbsPartAddr))
@@ -6207,5 +6291,5 @@
     iColRefViewIdx = pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getViewId();
 #if VSP_N
-    if( iColRefViewIdx == NUM_VIEW_VSP )
+    if( iColRefViewIdx == pColCU->getSlice()->getViewId() && pColCU->getSlice()->getRefPic(eColRefPicList, iColRefIdx)->getPOC() == pColCU->getSlice()->getPOC() )
     {
       continue;
@@ -6351,5 +6435,5 @@
 //  UInt uiColRefViewId = pColCU->getSlice()->getRefPic( eColRefPicList, pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr))->getViewId();
   UInt uiCurRefViewId = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getViewId();
-  if( uiCurRefViewId == NUM_VIEW_VSP )
+  if( uiCurRefViewId == m_pcSlice->getViewId() && m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC() == m_pcSlice->getPOC() )
     iScale = 4096;
   else
@@ -6368,5 +6452,5 @@
   {
 #if VSP_MV_ZERO
-    if( uiCurRefViewId == NUM_VIEW_VSP )
+    if( uiCurRefViewId == m_pcSlice->getViewId() && m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC() == m_pcSlice->getPOC() )
       rcMv.setZero();
     else
@@ -6481,4 +6565,10 @@
     return false;
   }
+#if VSP_N ///
+  if( isVspRef( eRefPicList, iRefIdx ) )
+  {
+    return false;
+  }
+#endif
 
   // Prefer a vector crossing us.  Prefer shortest.
@@ -6495,4 +6585,9 @@
     }
     int iColRefPOC = pColCU->getSlice()->getRefPOC(RefPicList(l), iColRefIdx);
+#if VSP_N ///
+    Bool bColVsp    = pColCU->isVspRef( RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0), getSlice()->getColRefIdx() );
+    Bool bColRefVsp = pColCU->isVspRef( RefPicList(l), iColRefIdx );
+    if( ( bColRefVsp && !bColVsp) || (!bColRefVsp &&  bColVsp) )
+#endif
     if( pColCU->getSlice()->getRefViewId( RefPicList(l), iColRefIdx ) != pColCU->getSlice()->getViewId() )
     {
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 193)
@@ -159,4 +159,7 @@
   Int*          m_pcArlCoeffCb;       ///< ARL coefficient buffer (Cb)
   Int*          m_pcArlCoeffCr;       ///< ARL coefficient buffer (Cr)
+#if FIX_MEM_LEAKS
+  Bool          m_ArlCoeffIsAliasedAllocation; ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
+#endif 
 
   static Int*   m_pcGlbArlCoeffY;     ///< ARL coefficient buffer (Y)
@@ -237,4 +240,12 @@
   UInt*         m_uiSliceStartCU;    ///< Start CU address of current slice
   UInt*         m_uiEntropySliceStartCU; ///< Start CU address of current slice
+
+#if OL_DEPTHLIMIT_A0044 
+  //add a variable to store the partition information
+  //a 2D array in uidepth, part_symbol format
+  UInt          m_uiPartInfo[OL_PART_BUF_SIZE][2];
+  UInt          m_uiPartNum;
+  Bool          m_dumpPartInfo;
+#endif 
   
   // -------------------------------------------------------------------------------------------------------------------
@@ -600,4 +611,13 @@
   
   Void          compressMV            ();
+
+#if OL_DEPTHLIMIT_A0044
+  Void        resetPartInfo     () {m_uiPartNum = 0;};
+  Void        incrementPartInfo () {m_uiPartNum ++;};
+  Void        updatePartInfo(UInt uiSymbol, UInt uiDepth) { m_uiPartInfo[m_uiPartNum][0] = uiSymbol; m_uiPartInfo[m_uiPartNum][1] = uiDepth;};
+  UInt*       readPartInfo()                              { return (UInt*)m_uiPartInfo;};
+  Void        setPartDumpFlag(Bool flag)                  { m_dumpPartInfo = flag; };
+  Bool        getPartDumpFlag()                           { return m_dumpPartInfo; };
+#endif
   
   // -------------------------------------------------------------------------------------------------------------------
@@ -665,4 +685,5 @@
   Int           isVspMode ( UInt uiPartIdx );
   Int           isVspMode ( UInt uiPartIdx, TComMv cCompMv );
+  Bool          isVspRef  ( RefPicList e, Int iRefIdx );
 #endif
   
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 193)
@@ -743,5 +743,5 @@
       {
 #if VSP_N
-        if( pcSlice->getRefViewId( eRefPicList, iPdmRefIdx ) != NUM_VIEW_VSP )
+        if( !pcCU->isVspRef( eRefPicList, iPdmRefIdx ) )
 #endif
         if( pcSlice->getRefPOC( eRefPicList, iPdmRefIdx ) == pcSlice->getPOC())
@@ -846,5 +846,5 @@
   Bool          bInterview  = ( uiRefViewId < m_uiCurrViewId );
 #if VSP_N
-  Bool          bVsp        = ( pcRefPic->getViewId() == NUM_VIEW_VSP );
+  Bool          bVsp        = pcCU->isVspRef( eRefPicList, iRefIdx );
   AOT(  bInterview &&  bVsp && iRefPoc != pcSlice->getPOC() );
   AOT( !bInterview && !bVsp && iRefPoc == pcSlice->getPOC() );
@@ -947,5 +947,5 @@
   Bool          bInterview  = ( uiRefViewId < m_uiCurrViewId );
 #if VSP_N
-  Bool          bVsp        = ( pcRefPic->getViewId() == NUM_VIEW_VSP );
+  Bool          bVsp        = pcCU->isVspRef( eRefPicList, iRefIdx );
   AOT(  bInterview &&  bVsp && iRefPoc != pcSlice->getPOC() );
   AOT( !bInterview && !bVsp && iRefPoc == pcSlice->getPOC() );
@@ -1502,6 +1502,6 @@
     Bool            bUsesInterViewPrd = ( abCurrIntView[0] || abCurrIntView[1] );
 #if VSP_N
-    if(( aiCurrRefIdx[0] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, aiCurrRefIdx[0] )->getViewId() == NUM_VIEW_VSP ) ||
-       ( aiCurrRefIdx[1] >= 0 && pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, aiCurrRefIdx[1] )->getViewId() == NUM_VIEW_VSP )) {
+    if(( aiCurrRefIdx[0] >= 0 && pcCU->isVspRef( REF_PIC_LIST_0, aiCurrRefIdx[0] ) ) ||
+       ( aiCurrRefIdx[1] >= 0 && pcCU->isVspRef( REF_PIC_LIST_1, aiCurrRefIdx[1] ) )) {
       //if refpic is VSP, copy to Original cuurent PDM
       TComPicYuv* pcPdm = pcCU->getPic()->getPredDepthMap();
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 193)
@@ -69,7 +69,4 @@
   m_pcResidual        = NULL;
 #endif
-#if DEBUGIMGOUT
-  m_acPicYuvDebug     = NULL;
-#endif
   m_pcPicYuvPred      = NULL;
   m_pcPicYuvResi      = NULL;
@@ -102,8 +99,5 @@
   }
   m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
-#if DEBUGIMGOUT
-  m_acPicYuvDebug    = new TComPicYuv;  m_acPicYuvDebug->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
-#endif
-
+  
   /* there are no SEI messages associated with this picture initially */
   m_SEIs = NULL;
@@ -172,12 +166,4 @@
     delete m_pcResidual;
     m_pcResidual = NULL;
-  }
-#endif
-#if DEBUGIMGOUT
-  if (m_acPicYuvDebug)
-  {
-    m_acPicYuvDebug->destroy();
-    delete m_acPicYuvDebug;
-    m_acPicYuvDebug = NULL;
   }
 #endif
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPic.h	(revision 193)
@@ -91,7 +91,4 @@
   TComPicYuv*           m_pcResidual;             //  residual buffer (coded or inter-view predicted residual)
 #endif
-#if DEBUGIMGOUT
-  TComPicYuv*           m_acPicYuvDebug;          //  debug image
-#endif
 
   TComPicYuv*           m_pcPicYuvPred;           //  Prediction
@@ -120,4 +117,9 @@
   Int**                 m_aaiCodedScale;
   Int**                 m_aaiCodedOffset;
+
+#if OL_DEPTHLIMIT_A0044
+  UInt*                 m_texPartInfo;
+  UInt                  m_uiTexPartIndex;
+#endif
 
 public:
@@ -183,8 +185,4 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   TComPicYuv*   getResidual()         { return  m_pcResidual; }
-#endif
-
-#if DEBUGIMGOUT
-  TComPicYuv*   getPicYuvRecDbg()     { return  m_acPicYuvDebug; }
 #endif
 
@@ -262,4 +260,13 @@
   Void          removeResidualBuffer    ();
 #endif
+
+#if OL_DEPTHLIMIT_A0044
+  UInt        accessPartInfo        ( UInt count )   { return m_texPartInfo[m_uiTexPartIndex + count]; };
+  Void        incrementTexPartIndex (            )   { m_uiTexPartIndex += 2;    };
+  UInt        getTexPartIndex       ()               { return m_uiTexPartIndex;  };
+  Void        setTexPartIndex       ( UInt idx   )   { m_uiTexPartIndex = idx; };
+  Void        setPartInfo           ( UInt* texPart) { m_texPartInfo    = texPart;  };
+#endif
+
   Bool          getValidSlice                                  (Int sliceID)  {return m_pbValidSlice[sliceID];}
   Int           getSliceGranularityForNDBFilter                ()             {return m_sliceGranularityForNDBFilter;}
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicSym.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicSym.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicSym.cpp	(revision 193)
@@ -126,4 +126,15 @@
   m_apcTComDataCU = NULL;
 
+
+#if FIX_MEM_LEAKS
+  if( m_apcTComTile )
+  {
+    for( i=0; i<(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
+    {
+      if ( m_apcTComTile[i] )  delete m_apcTComTile[i];
+    }
+  }
+#endif
+
   delete [] m_apcTComTile;
   m_apcTComTile = NULL;
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicYuv.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPicYuv.h	(revision 193)
@@ -184,13 +184,4 @@
   Void  setChromaTo  ( Pel pVal );  
 
-#if DEBUGIMGOUT
-  // Degub tools
-public:
-  Void colsetToPicYuv   ( const UChar ucColor[3],                 Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void colsetToPicLuma  ( const UChar ucLumaOffCol,               Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void colsetToPicChroma( const UChar ucUCol, const UChar ucVCol, Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void drawLineToPicYuv ( bool bHor, bool bVer, UInt uiSize,      TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-#endif
-
 };// END CLASS DEFINITION TComPicYuv
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 193)
@@ -95,4 +95,5 @@
   Void xPredInterPrdDepthMap    ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv, UInt uiRShift, UInt uiOffset );
 #endif
+
 #if DEPTH_MAP_GENERATION
   Void xWeightedAveragePdm      ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst, UInt uiSubSampExpX, UInt uiSubSampExpY );
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComRdCost.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComRdCost.h	(revision 193)
@@ -377,4 +377,10 @@
   Bool                    m_bUseEstimatedVSD; 
 #endif
+#if LGE_WVSO_A0119
+  Int                     m_iDWeight;
+  Int                     m_iVSOWeight;
+  Int                     m_iVSDWeight;
+  Bool                    m_bUseWVSO;
+#endif
 
   Bool                    m_bUseVSO;
@@ -410,5 +416,14 @@
   Void    setVSOMode( UInt uiIn);
   UInt    getVSOMode( )                  { return m_uiVSOMode; }
-
+#if LGE_WVSO_A0119
+  Void    setUseWVSO ( Bool bIn )         { m_bUseWVSO = bIn; }; 
+  Bool    getUseWVSO ( )                  { return m_bUseWVSO;};
+  Void    setDWeight   ( Int iDWeight   ) { m_iDWeight = iDWeight; };
+  Int     getDWeight   ()                 { return m_iDWeight; };
+  Void    setVSOWeight ( Int iVSOWeight ) { m_iVSOWeight = iVSOWeight; };
+  Int     getVSOWeight ()                 { return m_iVSOWeight; };
+  Void    setVSDWeight ( Int iVSDWeight ) { m_iVSDWeight = iVSDWeight; };
+  Int     getVSDWeight ()                 { return m_iVSDWeight; };
+#endif 
 #if HHI_VSO_DIST_INT
   Void    setAllowNegDist ( Bool bAllowNegDist );
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 193)
@@ -112,4 +112,7 @@
 , m_iViewOrderIdx                 ( 0 )
 #endif
+#if VSP_CFG
+, m_uiNumVspRefPics               ( 0 )
+#endif
 {
   m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
@@ -146,4 +149,10 @@
 #if VSP_SLICE_HEADER
   m_bVspFlag = false;
+#if VSP_CFG
+  memset( m_uiVspRefPos[0], 0, sizeof(UInt)*MAX_NUM_REF_PICS );
+  memset( m_uiVspRefPos[1], 0, sizeof(UInt)*MAX_NUM_REF_PICS );
+#else
+  m_bVspDepthDisableFlag = false;
+#endif
 #endif
 }
@@ -195,4 +204,11 @@
 #if VSP_SLICE_HEADER
   m_bVspFlag = false;
+#if VSP_CFG
+  m_uiNumVspRefPics = 0;
+  memset( m_uiVspRefPos[0], 0, sizeof(UInt)*MAX_NUM_REF_PICS );
+  memset( m_uiVspRefPos[1], 0, sizeof(UInt)*MAX_NUM_REF_PICS );
+#else
+  m_bVspDepthDisableFlag = false;
+#endif
 #endif
 
@@ -544,8 +560,19 @@
   }
 
+#if VSP_CFG
+  UInt cIdxTmp;
+  for( cIdx = 0, cIdxTmp = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++ )
+#else
   for( cIdx = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++ )
+#endif
   {
 #if VSP_N
+#if VSP_CFG
+    Int iVspRefPos = getVspRefPos(REF_PIC_LIST_0, 0);
+    iVspRefPos = ( iVspRefPos > 0 ? iVspRefPos - 1 : -1 );
+    if( pcVspPic && iVspRefPos != -1 && cIdx == (iVspRefPos >= num_ref_idx_l0_active_minus1 ? num_ref_idx_l0_active_minus1 : iVspRefPos) )
+#else
     if( pcVspPic && cIdx == num_ref_idx_l0_active_minus1 )
+#endif
     {
       m_apcRefPicList[0][cIdx] = RefPicSetVspCurr[0];
@@ -555,5 +582,12 @@
     }
     else
+    {
+#if VSP_CFG
+      m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdxTmp) ] : refPicListTemp0[cIdxTmp];
+      cIdxTmp++;
+#else
       m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx];
+#endif
+    }
 #else
     m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx];
@@ -567,8 +601,18 @@
   else
   {
+#if VSP_CFG
+    for( cIdx = 0, cIdxTmp = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++ )
+#else
     for( cIdx = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++ )
+#endif
     {
 #if VSP_N
+#if VSP_CFG
+      Int iVspRefPos = getVspRefPos(REF_PIC_LIST_1, 0);
+      iVspRefPos = ( iVspRefPos > 0 ? iVspRefPos - 1 : -1 );
+      if( pcVspPic && iVspRefPos != -1 && cIdx == (iVspRefPos >= num_ref_idx_l1_active_minus1 ? num_ref_idx_l1_active_minus1 : iVspRefPos) )
+#else
       if( pcVspPic && cIdx == num_ref_idx_l1_active_minus1 )
+#endif
       {
         m_apcRefPicList[1][cIdx] = RefPicSetVspCurr[0];
@@ -578,5 +622,12 @@
       }
       else
+      {
+#if VSP_CFG
+        m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdxTmp) ] : refPicListTemp1[cIdxTmp];
+        cIdxTmp++;
+#else
         m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx];
+#endif
+      }
 #else
       m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx];
@@ -1501,4 +1552,13 @@
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
 , m_bUseDMM                   (false)
+#endif
+#if OL_DEPTHLIMIT_A0044
+, m_bDepthPartitionLimiting   (false)
+#endif
+#if VSP_N
+, m_bVspPresentFlag           (false)
+#if VSP_CFG
+, m_bVspDepthPresentFlag      (false)
+#endif
 #endif
 {
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 193)
@@ -45,4 +45,5 @@
 #include "TComRom.h"
 #include "TComList.h"
+
 //! \ingroup TLibCommon
 //! \{
@@ -353,4 +354,8 @@
 #endif
 
+#if OL_DEPTHLIMIT_A0044
+  Bool m_bDepthPartitionLimiting;
+#endif
+
 #if DEPTH_MAP_GENERATION
   UInt  m_uiPredDepthMapGeneration;
@@ -372,4 +377,11 @@
 #if HHI_INTER_VIEW_RESIDUAL_PRED
   TComResidualGenerator* m_pcResidualGenerator;
+#endif
+
+#if VSP_N
+  Bool  m_bVspPresentFlag;
+#if VSP_CFG
+  Bool  m_bVspDepthPresentFlag;
+#endif
 #endif
 
@@ -618,4 +630,9 @@
 #endif
 
+#if OL_DEPTHLIMIT_A0044
+  Void setUseDPL(Bool b) {m_bDepthPartitionLimiting = b; }
+  Bool getUseDPL()       {return m_bDepthPartitionLimiting;}
+#endif
+
   Void initMultiviewSPS      ( UInt uiViewId, Int iViewOrderIdx = 0, UInt uiCamParPrecision = 0, Bool bCamParSlice = false, Int** aaiScale = 0, Int** aaiOffset = 0 );
   Void initMultiviewSPSDepth ( UInt uiViewId, Int iViewOrderIdx );
@@ -660,4 +677,13 @@
   Void                    setResidualGenerator( TComResidualGenerator* pcResidualGenerator )  { m_pcResidualGenerator = pcResidualGenerator; }
   TComResidualGenerator*  getResidualGenerator()                                              { return m_pcResidualGenerator; }
+#endif
+
+#if VSP_N
+  Void  setVspPresentFlag( Bool b ) { m_bVspPresentFlag = b; }
+  Bool  getVspPresentFlag()         { return m_bVspPresentFlag; }
+#if VSP_CFG
+  Void  setVspDepthPresentFlag( Bool b ) { m_bVspDepthPresentFlag = b; }
+  Bool  getVspDepthPresentFlag()         { return m_bVspDepthPresentFlag; }
+#endif
 #endif
 };
@@ -1277,4 +1303,10 @@
 #if VSP_SLICE_HEADER
   Bool      m_bVspFlag;
+#if VSP_CFG
+  UInt      m_uiNumVspRefPics;
+  UInt      m_uiVspRefPos[2][MAX_NUM_REF_PICS];
+#else
+  Bool      m_bVspDepthDisableFlag;
+#endif
 #endif
 
@@ -1584,4 +1616,13 @@
   Void      setVspFlag          ( Bool val )    { m_bVspFlag = val; }
   Bool      getVspFlag          ()              { return m_bVspFlag; }
+#if VSP_CFG
+  Void      setNumVspRefPics( UInt val )        { m_uiNumVspRefPics = val; }
+  UInt      getNumVspRefPics()                  { return m_uiNumVspRefPics; }
+  Void      setVspRefPos( UInt dir, UInt idx, UInt val )  { m_uiVspRefPos[dir][idx] = val; }
+  UInt      getVspRefPos( UInt dir, UInt idx )            { return m_uiVspRefPos[dir][idx]; }
+#else
+  Void      setVspDepthDisableFlag( Bool val )  { m_bVspDepthDisableFlag = val; }
+  Bool      getVspDepthDisableFlag()            { return m_bVspDepthDisableFlag; }
+#endif
 #endif
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComWedgelet.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComWedgelet.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComWedgelet.h	(revision 193)
@@ -198,5 +198,4 @@
   static UInt xGetSAD16         ( WedgeDistParam* pcDtParam );
   static UInt xGetSAD32         ( WedgeDistParam* pcDtParam );
-  //static UInt xGetSAD64         ( WedgeDistParam* pcDtParam );
 
   static UInt xGetSSE4          ( WedgeDistParam* pcDtParam );
@@ -204,5 +203,4 @@
   static UInt xGetSSE16         ( WedgeDistParam* pcDtParam );
   static UInt xGetSSE32         ( WedgeDistParam* pcDtParam );
-  //static UInt xGetSSE64         ( WedgeDistParam* pcDtParam );
 
 };// END CLASS DEFINITION TComWedgeDist
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComYuv.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TComYuv.h	(revision 193)
@@ -213,13 +213,4 @@
 
   __inline Pel  xClip  (Pel x )      { return ( (x < 0) ? 0 : (x > (Pel)g_uiIBDI_MAX) ? (Pel)g_uiIBDI_MAX : x ); }
-
-#if DEBUGIMGOUT
-public:
-  Void colsetToPicYuv   ( const UChar ucColor[3],                 Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void colsetToPicLuma  ( const UChar ucLumaOffCol,               Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void colsetToPicChroma( const UChar ucUCol, const UChar ucVCol, Int iOffset[2][2], TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-  Void drawLineToPicYuv ( bool bHor, bool bVer, UInt uiSize,      TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth = 0, UInt uiPartIdx = 0 );
-#endif
-
 };// END CLASS DEFINITION TComYuv
 
Index: branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 166)
+++ branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 193)
@@ -44,9 +44,8 @@
 #define VSP_N                             1
 #if VSP_N
-#define VSP_TEXT_ONLY                     1
-#define NUM_VIEW_VSP                      99
+#define VSP_BUGFIX                        1
 #define VSP_N_DUMP                        0
 #define FORCE_REF_VSP                     2   // 0=NotUseVSPSKIP 1:VSPSKIPforFlag 2:VSPSKIPforMergeIdx
-#define VSP_MV_ZERO                       0   // use zero vector for VSP
+#define VSP_MV_ZERO                       1   // use zero vector for VSP
 #if VSP_MV_ZERO
 #define AMVP_VSP_UNAVAILABLE              1
@@ -54,10 +53,11 @@
 #define VSP_MERGE_POS                     5   // position of vsp in merge list (0..5)
 #define NTT_SUBPEL                        1
-#endif
-#define DEBUGIMGOUT                       0   //Debug YUVImage Out
-#define DEBUGLOGOUT                       0   //Debug Log Out
+#define VSP_CFG                           1
+#endif
 
 #define VSP_SLICE_HEADER                  1
+#if !VSP_CFG
 #define VSP_FRAME_INTERVAL                2
+#endif
 
 #define FIXES                             1
@@ -66,7 +66,11 @@
 #define FIX_INIT_ROM                      1
 #define FIX_VIRT_DESTRUCTOR               1
-#define FIX_DBL_CONTROL_DEFAULT           1
+#define FIX_MEM_LEAKS                     1
+#define FIX_VSO_SETUP                     1
+#define FIX_COMP_WARNING_INIT             1
 #define FIX_RDO_MACRO                     1
 #define FIX_LG_RESTRICTEDRESPRED_M24766   1
+#define FIX_REMOVE_TILE_DEPENDENCE        1
+#define FIX_DBL_CONTROL_DEFAULT           1
 
 
@@ -116,5 +120,12 @@
 #define SAIT_VSO_EST_A0033                1 // JCT2-A0033 modification 3
 #define LGE_VSO_EARLY_SKIP_A0093          1 // JCT2-A0093 modification 4
-
+#define LGE_WVSO_A0119                    1 // JCT2-A0119 Depth Metric with a weighted depth fidelity term
+
+#define OL_DEPTHLIMIT_A0044               1 //JCT2-A0044
+#if OL_DEPTHLIMIT_A0044
+#define OL_DO_NOT_LIMIT_INTRA_SLICES_PART 1 //Turn this on to not perform depth limiting for I-SLICES.
+#define OL_END_CU                         MAX_INT //Default for initializing the partition information buffer
+#define OL_PART_BUF_SIZE                  86 //maximum number of possible partition bits in a CU
+#endif
 
 #define HHI_INTERVIEW_SKIP                1
