Index: branches/HTM-5.0-Nokia/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg
===================================================================
--- branches/HTM-5.0-Nokia/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 199)
+++ branches/HTM-5.0-Nokia/CommonTestConditionsCfgs/baseCfg_3view+depth.cfg	(revision 200)
@@ -201,4 +201,6 @@
 DisparitySearchRangeRestriction : 0                                # 0: No disparity restriction 1: Use disparity restriction
 VerticalDisparitySearchRange    : 56                               # vertical disparity search range (in luma samples)
+FCO			  : 0                                      # Flexible coding order flag in 3DV
+FCOCodingOrder		  : T0D0D1D2T1T2                           # Coding order for Flexible coding order in 3DV
 
 
@@ -213,4 +215,5 @@
 #========== view synthesis optimization (VSO) ==========
 VSOConfig                 : [cx0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][cx2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string
+#VSOConfig                 : [ox0 B(cc1) I(s0.25 s0.5 s0.75)][cx1 B(oo0) B(oo2) I(s0.25 s0.5 s0.75 s1.25 s1.5 s1.75)][ox2 B(cc1) I(s1.25 s1.5 s1.75)] # VSO configuration string for FCO = 1
 WVSO                       : 1                                     # use of WVSO (Depth distortion metric with a weighted depth fidelity term) 
 VSOWeight                  : 10                                    # weight of VSO ( in SAD case, cf. squared in SSE case )
Index: branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.cpp	(revision 200)
@@ -88,4 +88,12 @@
 #endif
   
+#if FLEX_CODING_ORDER
+  Int iDepthViewIdx = 0;
+  Int iTextureViewIdx=0;
+  Bool first_frame=1;
+  Bool viewid_zero=true;
+  Int FCO_index=0;  //when the current frame is not first frame,use FCO_index stand for viewDepth. 
+#endif
+
 #if SONY_COLPIC_AVAILABILITY
   m_tDecTop[0]->setViewOrderIdx(0);
@@ -102,4 +110,8 @@
     pcListPic[i] = NULL;
     newPicture[i] = false;
+#if FLEX_CODING_ORDER
+    FCO_Order[i]=NULL;
+#endif
+
   }
 
@@ -161,9 +173,111 @@
         depth = getVPSAccess()->getActiveVPS()->getDepthFlag(nalu.m_layerId);
       }
-      viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
+#if FLEX_CODING_ORDER
+      if (viewId>0)
+      {
+        viewid_zero=false;
+      }
+      if (viewid_zero==false&&viewId==0)
+      {
+        first_frame=0; //if viewId has been more than zero and now it set to zero again, we can see that it is not the first view
+      }
+      if (first_frame)
+      { // if the current view is first frame, we set the viewDepthId as texture plus depth and get the FCO order 
+        viewDepthId = iDepthViewIdx+iTextureViewIdx;
+        FCO_viewDepthId=viewDepthId;
+      }
+      else
+      {//if current view is not first frame, we set the viewDepthId depended on the FCO order
+        viewDepthId=0;
+        if (depth)
+        {
+          for (FCO_index=0;FCO_index<2*MAX_VIEW_NUM;FCO_index++ )
+          {
+            if (FCO_Order[FCO_index]=='D')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+        else
+        {
+          for (FCO_index=0;FCO_index<2*MAX_VIEW_NUM;FCO_index++ )
+          {
+            if (FCO_Order[FCO_index]=='T')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+
+        viewDepthId=FCO_index;
+
+      }
+
+
+#else
+       viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
+#endif
+    
 #else
       Int viewId = nalu.m_viewId;
       Int depth = nalu.m_isDepth ? 1 : 0;
-      viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
+#if FLEX_CODING_ORDER
+      if (viewId>0)
+      {
+        viewid_zero=false;
+      }
+      if (viewid_zero==false&&viewId==0)
+      {
+        first_frame=0;
+      }
+      if (first_frame)
+      {
+        viewDepthId = iDepthViewIdx+iTextureViewIdx;
+        FCO_viewDepthId=viewDepthId;
+      }
+      else
+      {
+        viewDepthId=0;
+        if (depth)
+        {
+          for (FCO_index=0;FCO_index<2*MAX_VIEW_NUM;FCO_index++ )
+          {
+            if (FCO_Order[FCO_index]=='D')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+        else
+        {
+          for (FCO_index=0;FCO_index<2*MAX_VIEW_NUM;FCO_index++ )
+          {
+            if (FCO_Order[FCO_index]=='T')
+            {
+              if (viewId==viewDepthId)
+                break;
+              else
+                viewDepthId++;
+            }
+          }
+        }
+
+        viewDepthId=FCO_index;
+
+      }
+#else
+  viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
+#endif
+     
 #endif
 #endif     
@@ -224,4 +338,20 @@
         {
           previousPictureDecoded = true;
+#if FLEX_CODING_ORDER
+          if (first_frame)
+          {
+            if (depth)
+            {
+                iDepthViewIdx++;
+                FCO_Order[viewDepthId]='D';
+            }
+            else
+           {
+                iTextureViewIdx++;
+                FCO_Order[viewDepthId]='T';
+           }
+          }
+
+#endif
         }
       }
@@ -527,5 +657,60 @@
 TDecTop* TAppDecTop::getTDecTop( Int viewId, Bool isDepth )
 { 
+#if FLEX_CODING_ORDER
+  Int viewnumber=0;
+  Int i=0;
+  Bool FCO_flag=0;
+  if (viewId>FCO_viewDepthId)
+  {
+    return NULL;
+  }
+  else
+  {
+    if (isDepth)
+   {
+      for ( i=0; i<=FCO_viewDepthId;i++)
+      {
+         if (FCO_Order[i]=='D')
+         {
+           if (viewnumber==viewId)
+           {
+             FCO_flag=1;
+             break;
+           }
+           else
+             viewnumber++;
+         }
+      }
+    }
+    else
+    {
+      for ( i=0; i<=FCO_viewDepthId;i++)
+      {
+        if (FCO_Order[i]=='T')
+        {
+          if (viewnumber==viewId)
+          {
+            FCO_flag=1;
+            break;
+          }
+          else
+            viewnumber++;
+        }
+      }
+    }
+    if (FCO_flag)
+    {
+      return m_tDecTop[i];
+    }
+    else
+      return NULL;
+    
+  }
+
+    // coding order T0D0T1D1T2D2
+#else
   return m_tDecTop[(isDepth ? 1 : 0) + viewId * 2];  // coding order T0D0T1D1T2D2
+#endif
+ 
 } 
 
@@ -546,4 +731,23 @@
   assert( ( viewId >= 0 ) );
 
+#if FLEX_CODING_ORDER
+if (getTDecTop(viewId,isDepth))
+{
+   TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
+   TComPic* pcPic = NULL;
+   for( TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++ )
+   {
+     if( (*it)->getPOC() == poc )
+     {
+       pcPic = *it;
+       break;
+     }
+   }
+   return pcPic;
+}
+else
+  return NULL;
+#else
+
   TComList<TComPic*>* apcListPic = getTDecTop( viewId, isDepth )->getListPic();
   TComPic* pcPic = NULL;
@@ -557,4 +761,5 @@
   }
   return pcPic;
+#endif
 }
 //! \}
Index: branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/App/TAppDecoder/TAppDecTop.h	(revision 200)
@@ -71,4 +71,9 @@
   Bool                            m_useDepth;
 
+#if FLEX_CODING_ORDER
+  Int  FCO_viewDepthId;
+  Char FCO_Order[MAX_VIEW_NUM*2];
+#endif
+
   FILE*                           m_pScaleOffsetFile;
   CamParsCollector                m_cCamParsCollector;
Index: branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 200)
@@ -111,4 +111,12 @@
   if (m_pchBitstreamFile != NULL)
     free (m_pchBitstreamFile) ;
+
+#if FLEX_CODING_ORDER
+  if (m_pchMVCJointCodingOrder != NULL)
+  {
+    free(m_pchMVCJointCodingOrder) ;
+  }
+#endif
+
 #if HHI_VSO
   if (  m_pchVSOConfig != NULL)
@@ -203,4 +211,9 @@
   string cfg_RowHeight;
   string cfg_ScalingListFile;
+
+ #if FLEX_CODING_ORDER
+  string cfg_JointCodingOrdering;
+#endif
+
   po::Options opts;
   opts.addOptions()
@@ -246,4 +259,10 @@
   
   ("NumberOfViews",         m_iNumberOfViews,    0, "Number of views")
+
+#if FLEX_CODING_ORDER
+  ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
+  ("FCOCodingOrder",   cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
+#endif
+
   /* Unit definition parameters */
   ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
@@ -533,4 +552,48 @@
   m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
+  
+#if FLEX_CODING_ORDER
+  m_pchMVCJointCodingOrder= cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
+  // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
+#if HHI_VSO && DISABLE_FCO_FOR_VSO
+  Bool depthComesFirst = false;
+  int iter = 0;
+  if ( m_b3DVFlexOrder )
+  {
+    for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
+    {
+      iter = 0; 
+      for ( Int ii=1; ii<12; ii+=2 )
+      {
+        Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
+        if ( iViewIdxCfg == iViewIdx )
+        {
+          iter ++; 
+          if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
+          {
+            if(iter == 1)
+           { 
+            depthComesFirst = true;
+            break;
+           }
+          }
+          else
+          {
+            assert(m_pchMVCJointCodingOrder[ii-1]=='T');
+          }
+        }
+      }
+    }
+  }
+  if (depthComesFirst)
+  {
+    m_bUseVSO = false;
+  }
+#endif
+#endif
+
+
+
+
   
   m_pchColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
Index: branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncCfg.h	(revision 200)
@@ -88,4 +88,10 @@
   Int       m_iNumberOfViews;                                 ///< number Views to Encode
   Bool      m_bUsingDepthMaps;
+  
+#if FLEX_CODING_ORDER
+  char*  m_pchMVCJointCodingOrder;      ///<  texture-depth coding order
+  Bool    m_b3DVFlexOrder;    ///<  flexible coding order flag
+#endif
+
   // coding structure
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
Index: branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncTop.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/App/TAppEncoder/TAppEncTop.cpp	(revision 200)
@@ -400,4 +400,29 @@
     for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
     {
+
+#if FLEX_CODING_ORDER
+      // Detect whether depth comes before than texture for this view
+      Bool isDepthFirst = false;
+      if ( m_b3DVFlexOrder )
+      {
+        for ( Int ii=1; ii<12; ii+=2 )
+        {
+          Int iViewIdxCfg = (Int)(m_pchMVCJointCodingOrder[ii]-'0');
+          if ( iViewIdxCfg == iViewIdx )
+          {
+            if ( m_pchMVCJointCodingOrder[ii-1]=='D' ) // depth comes first for this view
+            {
+              isDepthFirst = true;
+            }
+            else
+            {
+              assert(m_pchMVCJointCodingOrder[ii-1]=='T');
+            }
+            break;
+          }
+        }
+      }
+#endif
+
       m_depthFrameRcvd.push_back(0);
       m_acTEncDepthTopList.push_back(new TEncTop); 
@@ -682,10 +707,22 @@
     m_acTEncDepthTopList[iViewIdx]->setUseDMM                     ( m_bUseDMM );
 #endif
+
+#if FLEX_CODING_ORDER && HHI_DMM_PRED_TEX
+    m_acTEncDepthTopList[iViewIdx]->setUseDMM34( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseDMM );
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
     m_acTEncDepthTopList[iViewIdx]->setUseQTLPC                   (m_bUseQTLPC);
 #endif
+
 #if HHI_MPI
-     m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
-#endif
+#if FLEX_CODING_ORDER
+    m_acTEncDepthTopList[iViewIdx]->setUseMVI( (m_b3DVFlexOrder && isDepthFirst) ? false : m_bUseMVI );
+#else
+    m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
+#endif
+#endif
+
+
 #if RWTH_SDC_DLT_B0036
       m_acTEncDepthTopList[iViewIdx]->setUseDLT                   ( m_bUseDLT );
@@ -1003,4 +1040,62 @@
       }
 #endif
+
+#if FLEX_CODING_ORDER
+      if (m_b3DVFlexOrder)
+      {
+        Int  iNumDepthEncoded = 0;
+        iNumEncoded = 0;
+        Int i=0;
+        Int iViewIdx=0;
+        Int iNumberofDepthViews = m_bUsingDepthMaps?m_iNumberOfViews:0;
+        for (Int j=0; j < (m_iNumberOfViews+ iNumberofDepthViews); j++ )
+        {
+          if (m_pchMVCJointCodingOrder[i]=='T')
+          {
+
+            i++;
+            assert(isdigit(m_pchMVCJointCodingOrder[i]));
+            iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
+
+            m_acTEncTopList[iViewIdx]->encode( eos[iViewIdx], pcPicYuvOrg, *m_picYuvRec[iViewIdx], outputAccessUnits, iNumEncoded, gopId );
+            xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, iViewIdx, false);
+            outputAccessUnits.clear();
+            i++;
+          }
+          else if ( m_pchMVCJointCodingOrder[i] == 'D')
+          {
+
+            i++;
+            if( m_bUsingDepthMaps )
+            {
+              assert(isdigit(m_pchMVCJointCodingOrder[i]));
+              iViewIdx = (Int)(m_pchMVCJointCodingOrder[i]-'0');
+#if SAIT_VSO_EST_A0033
+              if( m_bUseVSO && iNextPoc < m_iFrameToBeEncoded )
+              {
+                m_cCameraData.xSetDispCoeff( iNextPoc, iViewIdx );
+                m_acTEncDepthTopList[iViewIdx]->setDispCoeff( m_cCameraData.getDispCoeff() );
+              }
+#endif
+              m_acTEncDepthTopList[iViewIdx]->encode( depthEos[iViewIdx], pcDepthPicYuvOrg, *m_picYuvDepthRec[iViewIdx], outputAccessUnits, iNumDepthEncoded, gopId );
+              xWriteOutput(bitstreamFile, iNumDepthEncoded, outputAccessUnits, iViewIdx, true);
+              outputAccessUnits.clear();
+              i++;
+            }
+          }
+        }
+      }
+      else
+      {
+
+#endif
+
+//original code
+
+
+
+
+
+
       for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
       {
@@ -1026,4 +1121,9 @@
         }
       }
+ 
+#if FLEX_CODING_ORDER
+      }
+#endif
+
 #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED
       for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ )
Index: branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.cpp	(revision 200)
@@ -1594,4 +1594,9 @@
 , m_bUseDMM                   (false)
 #endif
+
+#if FLEX_CODING_ORDER && HHI_DMM_PRED_TEX
+, m_bUseDMM34                   (false)
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
 , m_bUseQTLPC                 (false)
Index: branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TComSlice.h	(revision 200)
@@ -394,4 +394,8 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Bool  m_bUseDMM34;
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Bool m_bUseQTLPC;
@@ -674,4 +678,9 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Bool getUseDMM34()         { return m_bUseDMM34; }
+  Void setUseDMM34( Bool b ) { m_bUseDMM34 = b;    }
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Void setUseQTLPC( Bool b ) { m_bUseQTLPC = b;    }
Index: branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TypeDef.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibCommon/TypeDef.h	(revision 200)
@@ -62,4 +62,10 @@
 
 
+// FCO 
+#define FLEX_CODING_ORDER               1
+#if FLEX_CODING_ORDER
+  #define DISABLE_FCO_FOR_VSO             0 // Optional compile settings to disable VSO with FCO.
+#endif
+
 ///// ***** PATCHES *********
 #define TMVP_DEPTH_SWITCH                 1   // JCT3V-B0092 additional encoder option only 
Index: branches/HTM-5.0-Nokia/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibDecoder/TDecTop.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibDecoder/TDecTop.cpp	(revision 200)
@@ -1002,6 +1002,16 @@
     assert( m_tAppDecTop != NULL );
     TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView(  m_viewId, pcSlice->getPOC(), false ) : NULL;
+
+#if FLEX_CODING_ORDER
+    if (pcTexturePic != NULL)
+    {
+      assert( !m_isDepth || pcTexturePic != NULL );
+      pcSlice->setTexturePic( pcTexturePic );
+    }
+#else
     assert( !m_isDepth || pcTexturePic != NULL );
     pcSlice->setTexturePic( pcTexturePic );
+#endif
+
 
     std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() );
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncCfg.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncCfg.h	(revision 200)
@@ -327,4 +327,8 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Bool m_bUseDMM34;
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Bool     m_bUseQTLPC;
@@ -844,4 +848,9 @@
 #endif
 
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  Void setUseDMM34( Bool b) { m_bUseDMM34 = b;    }
+  Bool getUseDMM34()        { return m_bUseDMM34; }
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   Void      setUseQTLPC( Bool b ) { m_bUseQTLPC = b;    }
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 200)
@@ -363,8 +363,34 @@
       assert( tAppEncTop != NULL );
 
+
+#if FLEX_CODING_ORDER
+      TComPic * pcTexturePic; 
+      if(m_pcEncTop->getIsDepth() == 1)
+      {
+        TComPicYuv * recText;
+        recText = tAppEncTop->getPicYuvFromView(m_pcEncTop->getViewId(), pcSlice->getPOC(), false ,true);
+        if(recText == NULL)
+        {
+           pcSlice->setTexturePic(NULL);
+        }
+        else
+        {
+           pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
+           pcSlice->setTexturePic( pcTexturePic );
+        }
+      }
+      else
+    {
+        pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
+        assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL );
+          pcSlice->setTexturePic( pcTexturePic );
+      }
+
+#else
       TComPic * const pcTexturePic = m_pcEncTop->getIsDepth() ? tAppEncTop->getPicFromView( m_pcEncTop->getViewId(), pcSlice->getPOC(), false ) : NULL;
       assert( !m_pcEncTop->getIsDepth() || pcTexturePic != NULL );
       pcSlice->setTexturePic( pcTexturePic );
 
+#endif 
       std::vector<TComPic*> apcInterViewRefPics = tAppEncTop->getInterViewRefPics( m_pcEncTop->getViewId(), pcSlice->getPOC(), m_pcEncTop->getIsDepth(), pcSlice->getSPS() );
       pcSlice->setRefPicListMvc( rcListPic, apcInterViewRefPics );
@@ -466,6 +492,10 @@
 
 #if SAIT_VSO_EST_A0033
-    m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true ) );
+{
+   Bool flag_rec;
+   flag_rec =  ((m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, true) == NULL) ? false: true);
+    m_pcRdCost->setVideoRecPicYuv( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), false, flag_rec ) );
     m_pcRdCost->setDepthPicYuv   ( m_pcEncTop->getEncTop()->getPicYuvFromView( pcSlice->getViewId(), pcSlice->getPOC(), true, false ) );
+}
 #endif
 #if LGE_WVSO_A0119
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 200)
@@ -1076,4 +1076,13 @@
 #endif
 #if HHI_DMM_PRED_TEX
+
+#if FLEX_CODING_ORDER
+    if ( !pcCU->getSlice()->getSPS()->getUseDMM34() )
+    {
+      assert( uiDir != DMM_WEDGE_PREDTEX_D_IDX );
+      assert( uiDir != DMM_CONTOUR_PREDTEX_D_IDX );
+    }
+#endif
+
     if( uiDir == DMM_WEDGE_PREDTEX_D_IDX )     { xCodeWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx ); }
     if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX )   { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); }
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 200)
@@ -2244,4 +2244,9 @@
 #endif
 #if HHI_DMM_PRED_TEX
+      
+#if FLEX_CODING_ORDER
+      if ( pcCU->getSlice()->getSPS()->getUseDMM34() )
+      {
+#endif
       UInt uiTexTabIdx  = 0;
       Int  iTexDeltaDC1 = 0;
@@ -2267,4 +2272,7 @@
         uiRdModeList[ numModesForFullRD++ ] = DMM_CONTOUR_PREDTEX_D_IDX;
       }
+#if FLEX_CODING_ORDER
+      }
+#endif
 #endif
     }
@@ -2311,9 +2319,19 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+      if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getUseDMM34() ) 
+#if LGE_EDGE_INTRA
+        && uiOrgMode < EDGE_INTRA_IDX
+#endif
+        )
+
+#else
+
       if( m_pcEncCfg->getIsDepth() && !predIntraLumaDMMAvailable( uiOrgMode, uiWidth, uiHeight ) 
-#if LGE_EDGE_INTRA_A0070
+#if LGE_EDGE_INTRA
         && uiOrgMode < EDGE_INTRA_IDX
 #endif
         )
+#endif
       {
         continue;
@@ -6466,5 +6484,9 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+#if ((HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX)&&FLEX_CODING_ORDER)
+Bool TEncSearch::predIntraLumaDMMAvailable( UInt uiMode, UInt uiWidth, UInt uiHeight, Bool bDMMAvailable34 )
+#else
 Bool TEncSearch::predIntraLumaDMMAvailable( UInt uiMode, UInt uiWidth, UInt uiHeight )
+#endif
 {
   if( uiMode < NUM_INTRA_MODE ) return true;
@@ -6494,4 +6516,12 @@
       bDMMAvailable = false;
     }
+
+#if FLEX_CODING_ORDER
+    if ( !bDMMAvailable34 )
+    {
+      bDMMAvailable = false;
+    }
+#endif
+
   }
 #endif
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.h	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncSearch.h	(revision 200)
@@ -333,7 +333,14 @@
 
 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+
   Bool predIntraLumaDMMAvailable  ( UInt           uiMode, 
                                     UInt           uiWidth, 
-                                    UInt           uiHeight );
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+                                    UInt         uiHeight, 
+                                    Bool         bDMMAvailable34 );
+#else
+                                    UInt         uiHeight );
+#endif
+
   Void xGetWedgeDeltaDCsMinDist   ( TComWedgelet*  pcWedgelet, 
                                     TComDataCU*    pcCU, 
Index: branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncTop.cpp	(revision 199)
+++ branches/HTM-5.0-Nokia/source/Lib/TLibEncoder/TEncTop.cpp	(revision 200)
@@ -769,4 +769,9 @@
   m_cSPS.setUseDMM( m_bUseDMM );
 #endif
+
+#if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER
+  m_cSPS.setUseDMM34( m_bUseDMM34 );
+#endif
+
 #if OL_QTLIMIT_PREDCODING_B0068
   m_cSPS.setUseQTLPC( m_bUseQTLPC );
