Index: branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComRom.cpp	(revision 1142)
+++ branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComRom.cpp	(revision 1143)
@@ -739,6 +739,10 @@
   assert( uiWidth == uiHeight );
 
+#if SHARP_DMM_CLEAN_K0042
+  Int posStart = 0, posEnd = 0;
+#else
   UChar    uhStartX = 0,    uhStartY = 0,    uhEndX = 0,    uhEndY = 0;
   Int   iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0;
+#endif
 
   UInt uiBlockSize = 0;
@@ -752,4 +756,5 @@
   for( UInt uiOri = 0; uiOri < 6; uiOri++ )
   {
+#if !SHARP_DMM_CLEAN_K0042
     // init the edge line parameters for each of the 6 wedgelet types
     switch( uiOri )
@@ -762,13 +767,39 @@
     case( 5 ): {  uhStartX = (uiBlockSize-1); uhStartY = 0;               uhEndX = 0;               uhEndY = 0;               iStepStartX =  0; iStepStartY = +1; iStepEndX =  0; iStepEndY = +1; break; }
     }
-
+#endif
+
+#if SHARP_DMM_CLEAN_K0042
+    posEnd = racWedgeList.size();
+    if (uiOri == 0 || uiOri == 4)
+    {
+#endif
     for( Int iK = 0; iK < uiBlockSize; iK += (uiWidth>=16 ?2:1))
     {
       for( Int iL = 0; iL < uiBlockSize; iL += ((uiWidth>=16 && uiOri<4)?2:1) )
       {
+#if SHARP_DMM_CLEAN_K0042
+        Int xS = iK;
+        Int yS = 0;
+        Int xE = (uiOri == 0) ? 0 : iL;
+        Int yE = (uiOri == 0) ? iL : uiBlockSize - 1;
+        cTempWedgelet.setWedgelet( xS, yS, xE, yE, 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, ((iL%2)==0 && (iK%2)==0) );
+#endif
         addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
       }
     }
+#if SHARP_DMM_CLEAN_K0042
+    }
+    else
+    {
+      for (Int pos = posStart; pos < posEnd; pos++)
+      {
+        cTempWedgelet.generateWedgePatternByRotate(racWedgeList[pos], uiOri);
+        addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
+      }
+    }
+    posStart = posEnd;
+#endif
   }
 
Index: branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.cpp
===================================================================
--- branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.cpp	(revision 1142)
+++ branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.cpp	(revision 1143)
@@ -177,4 +177,39 @@
 }
 
+#if SHARP_DMM_CLEAN_K0042
+Void TComWedgelet::generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate)
+{
+  Int stride = m_uiWidth;
+  Int sinc, offsetI, offsetJ;
+  
+  sinc = 1;
+  offsetI = ( sinc) < 0 ? stride-1 : 0; // 0
+  offsetJ = (-sinc) < 0 ? stride-1 : 0; // stride - 1
+
+  for (Int y = 0; y < stride; y++)
+  {
+    for (Int x = 0; x < stride; x++)
+    {
+      Int i = offsetI + sinc * y; // y
+      Int j = offsetJ - sinc * x; // stride - 1 - x
+      m_pbPattern[(y * stride) + x] = !rcWedge.m_pbPattern[(j * stride) + i];
+    }
+  }
+  Int blocksize = rcWedge.m_uiWidth * (rcWedge.m_eWedgeRes == HALF_PEL ? 2 : 1);
+  Int offsetX = (-sinc) < 0 ? blocksize - 1 : 0;
+  Int offsetY = ( sinc) < 0 ? blocksize - 1 : 0;
+  m_uhXs = offsetX - sinc * rcWedge.m_uhYs;
+  m_uhYs = offsetY + sinc * rcWedge.m_uhXs;
+  m_uhXe = offsetX - sinc * rcWedge.m_uhYe;
+  m_uhYe = offsetY + sinc * rcWedge.m_uhXe;
+  m_uhOri = rotate;
+  m_eWedgeRes = rcWedge.m_eWedgeRes;
+  m_bIsCoarse = rcWedge.m_bIsCoarse;
+  m_uiAng = rcWedge.m_uiAng;
+  m_uiWidth  = rcWedge.m_uiWidth;
+  m_uiHeight = rcWedge.m_uiHeight;
+}
+#endif
+
 Void TComWedgelet::xGenerateWedgePattern()
 {
@@ -193,4 +228,19 @@
   xDrawEdgeLine( uhXs, uhYs, uhXe, uhYe, pbTempPattern, iTempStride );
 
+#if SHARP_DMM_CLEAN_K0042
+  Int shift = (m_eWedgeRes == HALF_PEL) ? 1 : 0;
+  Int endPos = uhYe>>shift;
+  for (Int y = 0; y <= endPos; y++)
+  {
+    for (Int x = 0; x < m_uiWidth && pbTempPattern[(y * m_uiWidth) + x] == 0; x++)
+    {
+      pbTempPattern[(y * m_uiWidth) + x] = true;
+    }
+  }
+  for( UInt k = 0; k < (m_uiWidth * m_uiHeight); k++ )
+  {
+    m_pbPattern[k] = pbTempPattern[k];
+  };
+#else
   switch( m_uhOri )
   {
@@ -252,4 +302,5 @@
     break;
   }
+#endif
 
   if( pbTempPattern )
@@ -294,6 +345,13 @@
   for( Int x = x0; x <= x1; x++ )
   {
+#if SHARP_DMM_CLEAN_K0042
+    Int shift = (m_eWedgeRes == HALF_PEL) ? 1 : 0;
+    Int stride = iPatternStride >> shift;
+    if( steep ) { pbPattern[((x>>shift) * stride) + (y>>shift)] = true; }
+    else        { pbPattern[((y>>shift) * stride) + (x>>shift)] = true; }
+#else
     if( steep ) { pbPattern[(x * iPatternStride) + y] = true; }
     else        { pbPattern[(y * iPatternStride) + x] = true; }
+#endif
 
     error += deltaerr;
Index: branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.h
===================================================================
--- branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.h	(revision 1142)
+++ branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TComWedgelet.h	(revision 1143)
@@ -124,4 +124,7 @@
   Bool*           getScaledPattern(UInt uiWidth);
 
+#if SHARP_DMM_CLEAN_K0042
+  Void  generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate);
+#endif
   Void  setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false );
   Void  findClosestAngle();
Index: branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TypeDef.h	(revision 1142)
+++ branches/HTM-13.1-dev2-Sharp/source/Lib/TLibCommon/TypeDef.h	(revision 1143)
@@ -350,4 +350,5 @@
                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
                                               // LG_ZEROINTRADEPTHRESI_A0087
+#define SHARP_DMM_CLEAN_K0042             1   // Generate DMM pattern with rotation 
 
 #define TICKET083_IVPFLAG_FIX             1
