Index: branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TComPrediction.cpp	(revision 900)
+++ branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TComPrediction.cpp	(revision 905)
@@ -851,4 +851,9 @@
   
   UInt  uiMaskStride= MAX_CU_SIZE;
+#if SEC_DBBP_FILTERING_H0104
+  Pel  filSrc = 0;
+  Pel* tmpTar = 0;
+  tmpTar = (Pel *)xMalloc(Pel, uiWidth*uiHeight);
+#endif
   
   // backup pointer
@@ -864,4 +869,7 @@
       
       // filtering
+#if SEC_DBBP_FILTERING_H0104
+      tmpTar[y*uiWidth+x] = piSrc[ucSegment][x];
+#else
       Bool t = (y==0)?pMaskStart[(y+1)*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
       Bool l = (x==0)?pMaskStart[y*uiMaskStride+x+1]:pMaskStart[y*uiMaskStride+x-1];
@@ -871,11 +879,51 @@
       Bool bBlend = !((t&&l&&b&&r) || (!t&&!l&&!b&&!r));
       piDst[x] = bBlend?((piSrc[0][x]+piSrc[1][x]+1)>>1):piSrc[ucSegment][x];
+#endif
     }
     
     piSrc[0]  += uiSrcStride;
     piSrc[1]  += uiSrcStride;
+#if !SEC_DBBP_FILTERING_H0104
     piDst     += uiDstStride;
+#endif
     pMask     += uiMaskStride;
   }
+
+#if SEC_DBBP_FILTERING_H0104
+  for (Int y=0; y<uiHeight; y++)
+  {
+    for (Int x=0; x<uiWidth; x++)
+    {
+      Bool t = (y==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
+      Bool l = (x==0)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x-1];
+      Bool b = (y==uiHeight-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
+      Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x]:pMaskStart[y*uiMaskStride+x+1];
+      Bool c =pMaskStart[y*uiMaskStride+x];
+
+      Pel left, right, top, bottom;
+      left   = (x==0)          ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x-1];
+      right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
+      top    = (y==0)          ? tmpTar[y*uiWidth+x] : tmpTar[(y-1)*uiWidth+x];
+      bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
+
+      if(!((l&&r&&c) || (!l&&!r&&!c)))
+      {
+        filSrc = Clip3( Pel( 0 ), Pel( 255 ), Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ));
+      }
+      else
+      {
+        filSrc = tmpTar[y*uiWidth+x];
+      }
+
+      if(!((t&&b&&c) || (!t&&!b&&!c)))
+      {
+        filSrc = Clip3( Pel( 0 ), Pel( 255 ), Pel(( top + (filSrc << 1) + bottom ) >> 2 ));
+      }
+      piDst[x] = filSrc;
+    }
+    piDst     += uiDstStride;
+  }
+  if ( tmpTar    ) { xFree(tmpTar);             tmpTar        = NULL; }
+#endif
   
   // now combine chroma
@@ -888,4 +936,10 @@
   UInt  uiWidthC        = uiWidth >> 1;
   UInt  uiHeightC       = uiHeight >> 1;
+#if SEC_DBBP_FILTERING_H0104
+  Pel  filSrcU = 0, filSrcV = 0;
+  Pel* tmpTarU = 0, *tmpTarV = 0;
+  tmpTarU = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
+  tmpTarV = (Pel *)xMalloc(Pel, uiWidthC*uiHeightC);
+#endif
   pMask = pMaskStart;
   
@@ -898,4 +952,8 @@
       
       // filtering
+#if SEC_DBBP_FILTERING_H0104
+      tmpTarU[y*uiWidthC+x] = piSrcU[ucSegment][x];
+      tmpTarV[y*uiWidthC+x] = piSrcV[ucSegment][x];
+#else
       Bool t = (y==0)?pMaskStart[(y+1)*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
       Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+(x+1)*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
@@ -907,4 +965,5 @@
       piDstU[x] = bBlend?((piSrcU[0][x]+piSrcU[1][x]+1)>>1):piSrcU[ucSegment][x];
       piDstV[x] = bBlend?((piSrcV[0][x]+piSrcV[1][x]+1)>>1):piSrcV[ucSegment][x];
+#endif
     }
     
@@ -913,8 +972,60 @@
     piSrcV[0]   += uiSrcStrideC;
     piSrcV[1]   += uiSrcStrideC;
+#if !SEC_DBBP_FILTERING_H0104
     piDstU      += uiDstStrideC;
     piDstV      += uiDstStrideC;
+#endif
     pMask       += 2*uiMaskStride;
   }
+
+#if SEC_DBBP_FILTERING_H0104
+  for (Int y=0; y<uiHeightC; y++)
+  {
+    for (Int x=0; x<uiWidthC; x++)
+    {
+      Bool t = (y==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
+      Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
+      Bool b = (y==uiHeightC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
+      Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+x*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
+      Bool c =pMaskStart[y*2*uiMaskStride+x*2];
+
+      Pel leftU, rightU, topU, bottomU;
+      leftU   = (x==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x-1];
+      rightU  = (x==uiWidthC-1)  ? tmpTarU[y*uiWidthC+x] : tmpTarU[y*uiWidthC+x+1];
+      topU    = (y==0)           ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y-1)*uiWidthC+x];
+      bottomU = (y==uiHeightC-1) ? tmpTarU[y*uiWidthC+x] : tmpTarU[(y+1)*uiWidthC+x];
+
+      Pel leftV, rightV, topV, bottomV;
+      leftV   = (x==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x-1];
+      rightV  = (x==uiWidthC-1)  ? tmpTarV[y*uiWidthC+x] : tmpTarV[y*uiWidthC+x+1];
+      topV    = (y==0)           ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y-1)*uiWidthC+x];
+      bottomV = (y==uiHeightC-1) ? tmpTarV[y*uiWidthC+x] : tmpTarV[(y+1)*uiWidthC+x];
+
+      if(!((l&&r&&c) || (!l&&!r&&!c)))
+      {
+        filSrcU = Clip3( Pel( 0 ), Pel( 255 ), Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
+        filSrcV = Clip3( Pel( 0 ), Pel( 255 ), Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
+      }
+      else
+      {
+        filSrcU = tmpTarU[y*uiWidthC+x];
+        filSrcV = tmpTarV[y*uiWidthC+x];
+      }
+
+      if(!((t&&b&&c) || (!t&&!b&&!c)))
+      {
+        filSrcU = Clip3( Pel( 0 ), Pel( 255 ), Pel(( topU + (filSrcU << 1) + bottomU ) >> 2 ));
+        filSrcV = Clip3( Pel( 0 ), Pel( 255 ), Pel(( topV + (filSrcV << 1) + bottomV ) >> 2 ));
+      }
+
+      piDstU[x] = filSrcU;
+      piDstV[x] = filSrcV;
+    }
+    piDstU      += uiDstStrideC;
+    piDstV      += uiDstStrideC;
+  }
+  if ( tmpTarU    ) { xFree(tmpTarU);             tmpTarU        = NULL; }
+  if ( tmpTarV    ) { xFree(tmpTarV);             tmpTarV        = NULL; }
+#endif
 }
 #endif
Index: branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TypeDef.h	(revision 900)
+++ branches/HTM-10.2-dev2-Samsung/source/Lib/TLibCommon/TypeDef.h	(revision 905)
@@ -297,4 +297,5 @@
 #define MTK_DBBP_AMP_REM_H0072                 1
 #define RWTH_DBBP_NO_SPU_H0057                 1
+#define SEC_DBBP_FILTERING_H0104               1
 #endif
 
