Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComPrediction.cpp	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComPrediction.cpp	(revision 158)
@@ -2117,5 +2117,4 @@
 {
   assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );
-  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
 
   // get copy of co-located texture luma block
@@ -2136,5 +2135,5 @@
   UInt uiPredStride = cPredYuv.getStride();
 
-  // regular wedge search
+  // wedge search
   TComWedgeDist cWedgeDist;
   UInt uiBestDist = MAX_UINT;
@@ -2142,5 +2141,71 @@
   Int  iDC1 = 0;
   Int  iDC2 = 0;
-
+  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
+
+#if HHIQC_DMMFASTSEARCH_B0039
+  TComPic*      pcPicTex = pcCU->getSlice()->getTexturePic();
+  TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr());
+  UInt      uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+  Int   uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
+
+  std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]];
+  if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 )
+  {
+    std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2];
+    for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ )
+    {
+      UInt uiIdx     =   pauiWdgLst->at(uiIdxW);
+      calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piRefBlkY, uiWidth,      iDC1, iDC2 );
+      assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred,    uiPredStride, iDC1, iDC2 );
+
+      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
+
+      if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
+      {
+        uiBestDist   = uiActDist;
+        uiBestTabIdx = uiIdx;
+      }
+    }
+  }
+  else
+  {
+    WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
+    UInt uiBestNodeDist = MAX_UINT;
+    UInt uiBestNodeId   = 0;
+    for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
+    {
+      calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRefBlkY, uiWidth,      iDC1, iDC2 );
+      assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred,    uiPredStride, iDC1, iDC2 );
+
+      UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
+
+      if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT )
+      {
+        uiBestNodeDist = uiActDist;
+        uiBestNodeId   = uiNodeId;
+      }
+    }
+
+    // refinement
+    uiBestDist   = uiBestNodeDist;
+    uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
+    for( UInt uiRefId = 0; uiRefId < NUM_WEDGE_REFINES; uiRefId++ )
+    {
+      if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != NO_IDX )
+      {
+        calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piRefBlkY, uiWidth,      iDC1, iDC2 );
+        assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piPred,    uiPredStride, iDC1, iDC2 );
+
+        UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piRefBlkY, uiWidth, uiWidth, uiHeight, WedgeDist_SAD );
+
+        if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
+        {
+          uiBestDist   = uiActDist;
+          uiBestTabIdx = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId );
+        }
+      }
+    }
+  }
+#else
   for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ )
   {
@@ -2156,4 +2221,5 @@
     }
   }
+#endif
 
   cPredYuv.destroy();
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.cpp	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.cpp	(revision 158)
@@ -174,4 +174,14 @@
     g_aacWedgeRefLists.clear();
   }
+#if HHIQC_DMMFASTSEARCH_B0039
+  if ( !g_aacWedgeNodeLists.empty() )
+  {
+    for ( UInt ui = 0; ui < g_aacWedgeNodeLists.size(); ui++ )
+    {
+      g_aacWedgeNodeLists[ui].clear();
+    }
+    g_aacWedgeNodeLists.clear();
+  }
+#endif
 #endif
 }
@@ -1170,4 +1180,9 @@
 std::vector< std::vector<TComWedgeRef> > g_aacWedgeRefLists;
 
+#if HHIQC_DMMFASTSEARCH_B0039
+std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
+std::vector< std::vector< TComWedgeNode> >      g_aacWedgeNodeLists;
+#endif
+
 Void initWedgeLists()
 {
@@ -1180,4 +1195,67 @@
     g_aacWedgeLists.push_back( acWedgeList );
     g_aacWedgeRefLists.push_back( acWedgeRefList );
+
+#if HHIQC_DMMFASTSEARCH_B0039
+    // create WedgeNodeList
+    std::vector<TComWedgeNode> acWedgeNodeList;
+    for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
+    {
+      if( acWedgeList[uiPos].getIsCoarse() )
+      {
+        TComWedgeNode cWedgeNode;
+        cWedgeNode.setPatternIdx( uiPos );
+
+        // set refinement idxs
+        UInt uiRefPos = 0;
+        for( Int iOffS = -1; iOffS <= 1; iOffS++ )
+        {
+          for( Int iOffE = -1; iOffE <= 1; iOffE++ )
+          {
+            if( iOffS == 0 && iOffE == 0 ) { continue; }
+
+            Int iSx = (Int)acWedgeList[uiPos].getStartX();
+            Int iSy = (Int)acWedgeList[uiPos].getStartY();
+            Int iEx = (Int)acWedgeList[uiPos].getEndX();
+            Int iEy = (Int)acWedgeList[uiPos].getEndY();
+
+            switch( acWedgeList[uiPos].getOri() )
+            {
+            case( 0 ): { iSx += iOffS; iEy += iOffE; } break;
+            case( 1 ): { iSy += iOffS; iEx -= iOffE; } break;
+            case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break;
+            case( 3 ): { iSy -= iOffS; iEx += iOffE; } break;
+            case( 4 ): { iSx += iOffS; iEx += iOffE; } break;
+            case( 5 ): { iSy += iOffS; iEy += iOffE; } break;
+            default: assert( 0 );
+            }
+
+            for( UInt k = 0; k < acWedgeRefList.size(); k++ )
+            {
+              if( iSx == (Int)acWedgeRefList[k].getStartX() && 
+                iSy == (Int)acWedgeRefList[k].getStartY() && 
+                iEx == (Int)acWedgeRefList[k].getEndX() && 
+                iEy == (Int)acWedgeRefList[k].getEndY()    )
+              {
+                if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() )
+                {
+                  Bool bNew = true;
+                  for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } }
+
+                  if( bNew ) 
+                  {
+                    cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos );
+                    uiRefPos++;
+                    break;
+                  }
+                }
+              }
+            }
+          }
+        }
+        acWedgeNodeList.push_back( cWedgeNode );
+      }
+    }
+    g_aacWedgeNodeLists.push_back( acWedgeNodeList );
+#endif
   }
   return;
@@ -1217,9 +1295,32 @@
       for( Int iL = 0; iL < uiBlockSize; iL++ )
       {
+#if HHIQC_DMMFASTSEARCH_B0039
+        cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) );
+#else
         cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes );
+#endif
         addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
       }
     }
   }
+#if HHIQC_DMMFASTSEARCH_B0039
+  UInt uiThrSz = DMM3_SIMPLIFY_TR;
+
+  std::vector< std::vector<UInt> > auiWdgListSz;
+  for( Int idxM=2; idxM<=34 ; idxM++)
+  {
+    std::vector<UInt> auiWdgList;
+    for( Int idxW=0; idxW<racWedgeList.size(); idxW++)
+    {
+      UInt uiAbsDiff = abs(idxM-(Int)racWedgeList[idxW].getAng());
+      if( uiAbsDiff <= uiThrSz )
+      {
+        auiWdgList.push_back(idxW);
+      }
+    }
+    auiWdgListSz.push_back(auiWdgList);
+  }
+  g_aauiWdgLstM3.push_back(auiWdgListSz);
+#endif
 }
 
@@ -1257,4 +1358,7 @@
   if( bValid )
   {
+#if HHIQC_DMMFASTSEARCH_B0039
+  cWedgelet.findClosetAngle();
+#endif
     racWedgeList.push_back( cWedgelet );
     TComWedgeRef cWedgeRef;
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.h	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComRom.h	(revision 158)
@@ -193,4 +193,9 @@
 extern       std::vector< std::vector<TComWedgeRef> >  g_aacWedgeRefLists;
 
+#if HHIQC_DMMFASTSEARCH_B0039
+extern       std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
+extern       std::vector< std::vector<TComWedgeNode> >       g_aacWedgeNodeLists;
+#endif
+
 Void initWedgeLists();
 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.cpp
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.cpp	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.cpp	(revision 158)
@@ -52,4 +52,7 @@
                                                             m_uhOri    ( 0 ),
                                                             m_eWedgeRes( FULL_PEL )
+#if HHIQC_DMMFASTSEARCH_B0039
+                                                            , m_bIsCoarse( false )
+#endif
 {
   create( uiWidth, uiHeight );
@@ -62,4 +65,8 @@
                                                             m_uhOri    ( rcWedge.m_uhOri     ),
                                                             m_eWedgeRes( rcWedge.m_eWedgeRes ),
+#if HHIQC_DMMFASTSEARCH_B0039
+                                                            m_bIsCoarse( rcWedge.m_bIsCoarse ),
+                                                            m_uiAng    ( rcWedge.m_uiAng     ),
+#endif
                                                             m_uiWidth  ( rcWedge.m_uiWidth   ),
                                                             m_uiHeight ( rcWedge.m_uiHeight  ),
@@ -94,5 +101,38 @@
 }
 
+#if HHIQC_DMMFASTSEARCH_B0039
+Void TComWedgelet::findClosetAngle()
+{
+  UInt uiAng=0,uiOptAng=0;
+  UInt uiMinD=MAX_UINT;
+  UInt uiTmpD=0;
+  Int angTable[9]    = {0,    2,    5,   9,  13,  17,  21,  26,  32};
+  
+  UChar uhXs = m_uhXs;
+  UChar uhYs = m_uhYs;
+  UChar uhXe = m_uhXe;
+  UChar uhYe = m_uhYe;
+
+  for(uiAng=2; uiAng<=34; uiAng++)
+  {
+    Int iSign    = (uiAng<VER_IDX && uiAng>HOR_IDX ) ? -1 : 1;
+    Int iVer     = uiAng>17 ? 32 : angTable[(uiAng>10) ? (uiAng-10) : (10-uiAng)];
+    Int iHor     = uiAng<19 ? 32 : angTable[(uiAng>26) ? (uiAng-26) : (26-uiAng)];
+
+    uiTmpD  = abs(iVer*iSign*(uhXs-uhXe) - iHor*(uhYe-uhYs));
+    
+    if( uiTmpD < uiMinD )
+    {
+      uiMinD = uiTmpD;
+      uiOptAng = uiAng;
+    }
+  }
+  m_uiAng = uiOptAng;
+}
+
+Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse )
+#else
 Void TComWedgelet::setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes )
+#endif
 {
   m_uhXs      = uhXs;
@@ -102,4 +142,7 @@
   m_uhOri     = uhOri;
   m_eWedgeRes = eWedgeRes;
+#if HHIQC_DMMFASTSEARCH_B0039
+  m_bIsCoarse = bIsCoarse;
+#endif
 
   xGenerateWedgePattern();
@@ -644,6 +687,20 @@
   case( 2 ): { for( UInt iX = uiTempBlockSize-1; iX > uhXs;            iX-- ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } } break;
   case( 3 ): { for( UInt iY = uiTempBlockSize-1; iY > uhYs;            iY-- ) { UInt iX = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } break;
+#if HHIQC_DMMFASTSEARCH_B0039
+  case( 4 ): 
+    { 
+      if( (uhXs+uhXe) < uiTempBlockSize ) { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } }
+      else                                { for( UInt iY = 0; iY < uiTempBlockSize; iY++ ) { UInt iX = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX--; } } }
+    }
+    break;
+  case( 5 ): 
+    { 
+      if( (uhYs+uhYe) < uiTempBlockSize ) { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } }
+      else                                { for( UInt iX = 0; iX < uiTempBlockSize; iX++ ) { UInt iY = uiTempBlockSize-1; while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY--; } } }
+    }
+#else
   case( 4 ): { for( UInt iY = 0;               iY < uiTempBlockSize; iY++ ) { UInt iX = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iX++; } } } break;
   case( 5 ): { for( UInt iX = 0;               iX < uiTempBlockSize; iX++ ) { UInt iY = 0;                 while( pbTempPattern[(iY * iTempStride) + iX] == false ) { pbTempPattern[(iY * iTempStride) + iX] = true; iY++; } } } break;
+#endif
   }
 
@@ -664,6 +721,21 @@
       case( 2 ): { uiOffX = 1; uiOffY = 1; } break;
       case( 3 ): { uiOffX = 0; uiOffY = 1; } break;
+#if HHIQC_DMMFASTSEARCH_B0039
+      case( 4 ): 
+        { 
+          if( (uhXs+uhXe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; }
+          else                                { uiOffX = 1; uiOffY = 0; }
+        } 
+        break;
+      case( 5 ): 
+        { 
+          if( (uhYs+uhYe) < uiTempBlockSize ) { uiOffX = 0; uiOffY = 0; }
+          else                                { uiOffX = 0; uiOffY = 1; }
+        } 
+        break;
+#else
       case( 4 ): { uiOffX = 0; uiOffY = 0; } break;
       case( 5 ): { uiOffX = 0; uiOffY = 0; } break;
+#endif
       default:   { uiOffX = 0; uiOffY = 0; } break;
       }
@@ -732,4 +804,34 @@
   }
 }
+
+#if HHIQC_DMMFASTSEARCH_B0039
+TComWedgeNode::TComWedgeNode()
+{
+  m_uiPatternIdx = NO_IDX;
+  for( UInt uiPos = 0; uiPos < NUM_WEDGE_REFINES; uiPos++ )
+  {
+    m_uiRefineIdx[uiPos] = NO_IDX;
+  }
+}
+
+UInt TComWedgeNode::getPatternIdx()
+{
+  return m_uiPatternIdx;
+}
+UInt TComWedgeNode::getRefineIdx( UInt uiPos )
+{
+  assert( uiPos < NUM_WEDGE_REFINES );
+  return m_uiRefineIdx[uiPos];
+}
+Void TComWedgeNode::setPatternIdx( UInt uiIdx )
+{
+  m_uiPatternIdx = uiIdx;
+}
+Void TComWedgeNode::setRefineIdx( UInt uiIdx, UInt uiPos )
+{
+  assert( uiPos < NUM_WEDGE_REFINES );
+  m_uiRefineIdx[uiPos] = uiIdx;  
+}
+#endif
 
 #if HHI_DMM_PRED_TEX
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.h
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.h	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TComWedgelet.h	(revision 158)
@@ -50,4 +50,9 @@
 };
 
+#if HHIQC_DMMFASTSEARCH_B0039
+#define NUM_WEDGE_REFINES 8
+#define NO_IDX MAX_UINT
+#endif
+
 // ====================================================================================================================
 // Class definition TComWedgelet
@@ -62,4 +67,8 @@
   UChar           m_uhOri;                      // orientation index
   WedgeResolution m_eWedgeRes;                  // start/end pos resolution
+#if HHIQC_DMMFASTSEARCH_B0039
+  Bool            m_bIsCoarse; 
+  UInt            m_uiAng;
+#endif
 
   UInt  m_uiWidth;
@@ -90,6 +99,13 @@
   UChar           getEndY    () { return m_uhYe; }
   UChar           getOri     () { return m_uhOri; }
-
+#if HHIQC_DMMFASTSEARCH_B0039
+  Bool            getIsCoarse() { return m_bIsCoarse; }
+  UInt            getAng     () { return m_uiAng; }
+  Void            findClosetAngle();
+
+  Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
+#else
   Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes );
+#endif
 
   Bool  checkNotPlain();
@@ -136,4 +152,29 @@
 // type definition wedgelet reference list
 typedef std::vector<TComWedgeRef> WedgeRefList;
+
+#if HHIQC_DMMFASTSEARCH_B0039
+// ====================================================================================================================
+// Class definition TComWedgeNode
+// ====================================================================================================================
+class TComWedgeNode
+{
+private:
+  UInt            m_uiPatternIdx;
+  UInt            m_uiRefineIdx[NUM_WEDGE_REFINES];
+
+public:
+  TComWedgeNode();
+  virtual ~TComWedgeNode() {}
+
+  UInt            getPatternIdx();
+  UInt            getRefineIdx ( UInt uiPos );
+
+  Void            setPatternIdx( UInt uiIdx );
+  Void            setRefineIdx ( UInt uiIdx, UInt uiPos );
+};  // END CLASS DEFINITION TComWedgeNode
+
+// type definition wedgelet node list
+typedef std::vector<TComWedgeNode> WedgeNodeList;
+#endif
 
 #if HHI_DMM_PRED_TEX
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TypeDef.h	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibCommon/TypeDef.h	(revision 158)
@@ -127,4 +127,9 @@
 #endif
 
+#define HHIQC_DMMFASTSEARCH_B0039         1   // JCT3V-B0039: fast Wedgelet search for DMM modes 1 and 3
+#if HHIQC_DMMFASTSEARCH_B0039
+#define DMM3_SIMPLIFY_TR                  1
+#endif
+
 #define HHI_MPI                           1   // motion parameter inheritance from texture picture for depth map coding
 #define HHI_MPI_MERGE_POS                 0
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 158)
@@ -6336,5 +6336,10 @@
   WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
   Dist iDist = RDO_DIST_MAX;
+#if HHIQC_DMMFASTSEARCH_B0039
+  WedgeNodeList* pacWedgeNodeList = &g_aacWedgeNodeLists[(g_aucConvertToBit[uiWidth])];
+  xSearchWedgeFullMinDistFast( pcCU, uiAbsPtIdx, pacWedgeNodeList, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist );
+#else
   xSearchWedgeFullMinDist( pcCU, uiAbsPtIdx, pacWedgeList, piOrig, uiStride, uiWidth, uiHeight, ruiTabIdx, iDist );
+#endif
 
   TComWedgelet* pcBestWedgelet = &(pacWedgeList->at(ruiTabIdx));
@@ -6446,4 +6451,125 @@
   return;
 }
+
+#if HHIQC_DMMFASTSEARCH_B0039
+Void TEncSearch::xSearchWedgeFullMinDistFast( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeNodeList* pacWedgeNodeList, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Dist& riDist )
+{
+  ruiTabIdx = 0;
+
+  // local pred buffer
+  TComYuv cPredYuv;
+  cPredYuv.create( uiWidth, uiHeight );
+  cPredYuv.clear();
+
+  UInt uiPredStride = cPredYuv.getStride();
+  Pel* piPred       = cPredYuv.getLumaAddr();
+
+  Int  iDC1 = 0;
+  Int  iDC2 = 0;
+
+  // coarse wedge search
+  Dist uiBestDist   = RDO_DIST_MAX;
+  UInt uiBestNodeId = 0;
+  for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ )
+  {
+    calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piRef,  uiRefStride,  iDC1, iDC2 );
+    assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())), piPred, uiPredStride, iDC1, iDC2 );
+
+    Dist uiActDist = RDO_DIST_MAX;
+#if HHI_VSO
+    if( m_pcRdCost->getUseVSO() )
+    {
+#if SAIT_VSO_EST_A0033
+      if ( m_pcRdCost->getUseEstimatedVSD() )
+      {          
+        TComPicYuv* pcVirRec = m_pcRdCost->getVideoRecPicYuv();
+        TComPicYuv* pcVirOrg = m_pcRdCost->getDepthPicYuv();
+        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, pcVirRec->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirOrg->getLumaAddr(pcCU->getAddr(),pcCU->getZorderIdxInCU()), pcVirRec->getStride(), uiWidth, uiHeight );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSDWeight = m_pcRdCost->getVSDWeight() * m_pcRdCost->getVSDWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSDWeight * (Int) uiActDist) / ( iDWeight + iVSDWeight);
+        }
+#endif
+      }
+      else
+#endif
+      {
+        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSOWeight * (Int) uiActDist) / ( iDWeight + iVSOWeight);
+        }
+#endif
+      }
+    }
+    else
+    {
+      uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+    }
+#else
+    uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+#endif
+    if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
+    {
+      uiBestDist   = uiActDist;
+      uiBestNodeId = uiNodeId;
+    }
+  }
+
+  // refinement
+  Dist uiBestDistRef = uiBestDist;
+  UInt uiBestTabIdxRef  = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx();
+  for( UInt uiRefId = 0; uiRefId < NUM_WEDGE_REFINES; uiRefId++ )
+  {
+    if( pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ) != NO_IDX )
+    {
+      calcWedgeDCs       ( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piRef,  uiRefStride,  iDC1, iDC2 );
+      assignWedgeDCs2Pred( &(pacWedgeList->at(pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId ))), piPred, uiPredStride, iDC1, iDC2 );
+
+      Dist uiActDist = RDO_DIST_MAX;
+#if HHI_VSO
+      if( m_pcRdCost->getUseVSO() )
+      {
+        uiActDist = m_pcRdCost->getDistVS( pcCU, 0, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, 0 );
+#if LGE_WVSO_A0119
+        if ( m_pcRdCost->getUseWVSO() )
+        {    
+          Int iDWeight = m_pcRdCost->getDWeight() * m_pcRdCost->getDWeight();
+          Int iVSOWeight = m_pcRdCost->getVSOWeight() * m_pcRdCost->getVSOWeight();
+          Dist iD = (Dist) m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+          uiActDist = (iDWeight * iD + iVSOWeight * (Int) uiActDist) / ( iDWeight + iVSOWeight);
+        }
+#endif
+      }
+      else
+      {
+        uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+      }
+#else
+      uiActDist = m_pcRdCost->getDistPart( piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false, DF_SAD );
+#endif
+      if( uiActDist < uiBestDistRef || uiBestDistRef == RDO_DIST_MAX )
+      {
+        uiBestDistRef   = uiActDist;
+        uiBestTabIdxRef = pacWedgeNodeList->at(uiBestNodeId).getRefineIdx( uiRefId );
+      }
+    }
+  }
+
+  riDist    = uiBestDistRef;
+  ruiTabIdx = uiBestTabIdxRef;
+
+  cPredYuv.destroy();
+  return;
+}
+#endif
 
 Void TEncSearch::xSearchWedgePredDirMinDist( TComDataCU* pcCU, UInt uiAbsPtIdx, WedgeList* pacWedgeList, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd )
Index: branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.h	(revision 157)
+++ branches/HTM-4.1-dev2-HHI/source/Lib/TLibEncoder/TEncSearch.h	(revision 158)
@@ -374,4 +374,16 @@
                                     UInt&          ruiTabIdx, 
                                     Dist&          riDist );
+#if HHIQC_DMMFASTSEARCH_B0039
+  Void xSearchWedgeFullMinDistFast( TComDataCU*    pcCU, 
+                                    UInt           uiAbsPtIdx, 
+                                    WedgeNodeList* pacWedgeNodeList, 
+                                    WedgeList*     pacWedgeList, 
+                                    Pel*           piRef, 
+                                    UInt           uiRefStride, 
+                                    UInt           uiWidth, 
+                                    UInt           uiHeight, 
+                                    UInt&          ruiTabIdx, 
+                                    Dist&          riDist );
+#endif
   Void xSearchWedgePredDirMinDist ( TComDataCU*    pcCU, 
                                     UInt           uiAbsPtIdx, 
