Index: branches/HTM-9.3-dev3-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-9.3-dev3-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 778)
+++ branches/HTM-9.3-dev3-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 781)
@@ -1862,5 +1862,11 @@
 
 #if H_3D_DIM_SDC
-Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual )
+Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, 
+#if QC_GENERIC_SDC_G0122
+  Bool bZeroResidual, Int iSDCDeltaResi
+#else
+  Bool bResidual
+#endif
+  )
 {
   UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir( uiAbsPartIdx );
@@ -1880,6 +1886,8 @@
   AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
   AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
+#if !QC_GENERIC_SDC_G0122
   AOF( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) );
   AOF( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || uiWidth < 64  );
+#endif
   
   //===== init availability pattern =====
@@ -1888,10 +1896,16 @@
   pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
-  
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
   //===== get prediction signal =====
 #if H_3D_DIM
   if( isDimMode( uiLumaPredMode ) )
   {
-    predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true );
+    predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true 
+#if QC_GENERIC_SDC_G0122
+      , dmm4Segmentation
+#endif
+      );
   }
   else
@@ -1919,5 +1933,13 @@
     uiMaskStride = pcWedgelet->getStride();
   }
-  
+#if QC_GENERIC_SDC_G0122
+  if( getDimType( uiLumaPredMode ) == DMM4_IDX )
+  {
+    uiNumSegments = 2;
+    pbMask  = dmm4Segmentation->getPattern();
+    uiMaskStride = dmm4Segmentation->getStride();
+  }
+#endif
+
   // get DC prediction for each segment
   Pel apDCPredValues[2];
@@ -1931,6 +1953,9 @@
   {
     // remap reconstructed value to valid depth values
+#if QC_GENERIC_SDC_G0122
+    Pel pDCRec = ( !bZeroResidual ) ? apDCOrigValues[uiSegment] : apDCPredValues[uiSegment];
+#else
     Pel pDCRec = bResidual?apDCOrigValues[uiSegment]:apDCPredValues[uiSegment];
-    
+#endif
     // get residual (idx)
 #if H_3D_DIM_DLT
@@ -1939,5 +1964,15 @@
     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
 #endif
-    
+#if QC_GENERIC_SDC_G0122
+    if( !bZeroResidual )
+    {
+      Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
+      Int   pTestIdx    = pPredIdx + pResidualIdx + iSDCDeltaResi;
+      if( pTestIdx >= 0 && pTestIdx < pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) )
+      {
+        pResidualIdx += iSDCDeltaResi;
+      }
+    }
+#endif
     // save SDC DC offset
     pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx);
@@ -2024,4 +2059,7 @@
 #endif
     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
+#if QC_GENERIC_SDC_G0122
+  dmm4Segmentation->destroy(); delete dmm4Segmentation;
+#endif
 }
 #endif
@@ -2901,5 +2939,7 @@
           case( DMM4_IDX ):
             {
+#if !QC_GENERIC_SDC_G0122
               if( uiWidth > 4 )
+#endif
               {
                 biSegmentation = new TComWedgelet( uiWidth, uiHeight );
@@ -2957,4 +2997,12 @@
       {
         pcCU->setSDCFlagSubParts( (uiSDC != 0), uiPartOffset, uiDepth + uiInitTrDepth );
+#if QC_GENERIC_SDC_G0122
+        for( Int iSDCDeltaResi = -2; iSDCDeltaResi <= 2; iSDCDeltaResi++ )
+        {
+          if( ( uiSDC == 0 ) && iSDCDeltaResi != 0 )
+          {
+            continue;
+          }
+#endif
 #endif
       
@@ -2966,4 +3014,10 @@
 #if H_3D_DIM_SDC
       bTestZeroResi |= pcCU->getSDCFlag(uiPartOffset);
+#endif
+#if QC_GENERIC_SDC_G0122
+      if( uiSDC != 0 && iSDCDeltaResi != 0 )
+      {
+        bTestZeroResi = false;
+      }
 #endif
 #endif
@@ -3000,5 +3054,9 @@
               
               // start encoding with SDC
+#if QC_GENERIC_SDC_G0122
+              xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( testZeroResi != 0 ), iSDCDeltaResi );
+#else
               xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, (testZeroResi!=0));
+#endif
             }
             else
@@ -3073,4 +3131,7 @@
 #if H_3D_DIM_ENC || H_3D_DIM_SDC
       }
+#endif
+#if QC_GENERIC_SDC_G0122
+        } // SDC residual loop
 #endif
 #if H_3D_DIM_SDC
