Index: trunk/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 1179)
+++ trunk/source/Lib/TLibCommon/TComPic.cpp	(revision 1313)
@@ -2,7 +2,7 @@
  * License, included below. This software may be subject to other third party
  * and contributor rights, including patent rights, and no such rights are
- * granted under this license.  
+ * granted under this license.
  *
-* Copyright (c) 2010-2015, ITU/ISO/IEC
+ * Copyright (c) 2010-2015, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -50,18 +50,17 @@
 , m_bUsedByCurr                           (false)
 , m_bIsLongTerm                           (false)
-, m_apcPicSym                             (NULL)
 , m_pcPicYuvPred                          (NULL)
 , m_pcPicYuvResi                          (NULL)
 , m_bReconstructed                        (false)
 , m_bNeededForOutput                      (false)
-#if H_MV
+#if NH_MV
 , m_bPicOutputFlag                        (false)
 #endif
 , m_uiCurrSliceIdx                        (0)
 , m_bCheckLTMSB                           (false)
-#if H_MV
+#if NH_MV
 , m_layerId                               (0)
 , m_viewId                                (0)
-#if H_3D
+#if NH_3D
 , m_viewIndex                             (0)
 , m_isDepth                               (false)
@@ -70,11 +69,14 @@
 #endif
 #endif
-{
-  m_apcPicYuv[0]      = NULL;
-  m_apcPicYuv[1]      = NULL;
-#if H_3D_QTLPC
+
+{
+  for(UInt i=0; i<NUM_PIC_YUV; i++)
+  {
+    m_apcPicYuv[i]      = NULL;
+  }
+#if NH_3D_QTLPC
   m_bReduceBitsQTL    = 0;
 #endif
-#if H_3D_NBDV
+#if NH_3D_NBDV
   m_iNumDdvCandPics   = 0;
   m_eRapRefList       = REF_PIC_LIST_0;
@@ -87,15 +89,21 @@
 }
 
-Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow,
-                      Int *numReorderPics, Bool bIsVirtual)
-
-{
-  m_apcPicSym     = new TComPicSym;  m_apcPicSym   ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
+Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual)
+{
+  const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
+  const Int          iWidth          = sps.getPicWidthInLumaSamples();
+  const Int          iHeight         = sps.getPicHeightInLumaSamples();
+  const UInt         uiMaxCuWidth    = sps.getMaxCUWidth();
+  const UInt         uiMaxCuHeight   = sps.getMaxCUHeight();
+  const UInt         uiMaxDepth      = sps.getMaxTotalCUDepth();
+
+  m_picSym.create( sps, pps, uiMaxDepth );
   if (!bIsVirtual)
   {
-    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
-  }
-  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );
-  
+    m_apcPicYuv[PIC_YUV_ORG    ]   = new TComPicYuv;  m_apcPicYuv[PIC_YUV_ORG     ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
+    m_apcPicYuv[PIC_YUV_TRUE_ORG]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
+  }
+  m_apcPicYuv[PIC_YUV_REC]  = new TComPicYuv;  m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
+
   // there are no SEI messages associated with this picture initially
   if (m_SEIs.size() > 0)
@@ -104,13 +112,4 @@
   }
   m_bUsedByCurr = false;
-
-  /* store conformance window parameters with picture */
-  m_conformanceWindow = conformanceWindow;
-  
-  /* store display window parameters with picture */
-  m_defaultDisplayWindow = defaultDisplayWindow;
-
-  /* store number of reorder pics with picture */
-  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
 
 #if H_3D_FCO
@@ -125,33 +124,48 @@
 #endif
 
-  return;
 }
 
 Void TComPic::destroy()
 {
-  if (m_apcPicSym)
-  {
-    m_apcPicSym->destroy();
-    delete m_apcPicSym;
-    m_apcPicSym = NULL;
-  }
-  
-  if (m_apcPicYuv[0])
-  {
-    m_apcPicYuv[0]->destroy();
-    delete m_apcPicYuv[0];
-    m_apcPicYuv[0]  = NULL;
-  }
-  
-  if (m_apcPicYuv[1])
-  {
-    m_apcPicYuv[1]->destroy();
-    delete m_apcPicYuv[1];
-    m_apcPicYuv[1]  = NULL;
-  }
-  
+  m_picSym.destroy();
+
+  for(UInt i=0; i<NUM_PIC_YUV; i++)
+  {
+    if (m_apcPicYuv[i])
+    {
+      m_apcPicYuv[i]->destroy();
+      delete m_apcPicYuv[i];
+      m_apcPicYuv[i]  = NULL;
+    }
+  }
+
   deleteSEIs(m_SEIs);
 }
-#if H_3D
+#if NH_3D
+#if NH_3D_ARP
+Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
+{
+  Int iMaxCUWidth   = (Int) ( getPicSym()->getSPS().getMaxCUWidth()  );
+  Int iMaxCuHeight  = (Int) ( getPicSym()->getSPS().getMaxCUHeight() );
+
+  UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth(); 
+  Int iBaseUnitWidth  = iMaxCUWidth >> uiMaxTotalCUDepth;
+  Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth;
+
+  Int iNumCuInWidth   = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth;
+  iNumCuInWidth      += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0;
+
+
+  Int iCuX            = iX / iMaxCUWidth;
+  Int iCuY            = iY / iMaxCuHeight;
+  Int iBaseX          = ( iX - iCuX * iMaxCUWidth  ) / iBaseUnitWidth;
+  Int iBaseY          = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight;
+  Int iCuSizeInBases  = iMaxCuHeight                 / iBaseUnitWidth;
+
+  riCuAddr            = iCuY   * iNumCuInWidth + iCuX;
+  Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
+  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
+}
+#endif
 Void TComPic::compressMotion(Int scale)
 #else
@@ -159,24 +173,62 @@
 #endif
 {
-  TComPicSym* pPicSym = getPicSym(); 
-  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getFrameHeightInCU()*pPicSym->getFrameWidthInCU(); uiCUAddr++ )
-  {
-    TComDataCU* pcCU = pPicSym->getCU(uiCUAddr);
-#if H_3D
-    pcCU->compressMV(scale); 
+  TComPicSym* pPicSym = getPicSym();
+  for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ )
+  {
+    TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr);
+#if NH_3D
+    pCtu->compressMV(scale); 
 #else
-    pcCU->compressMV(); 
-#endif
-  } 
+    pCtu->compressMV();
+#endif
+    
+  }
 }
 
 Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
 {
-  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCUOrderMap(getCU(currAddr)->getSlice()->getSliceCurStartCUAddr()/getNumPartInCU()));
+  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr()));
   Bool mergeCtbInTile     = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
   return (mergeCtbInSliceSeg && mergeCtbInTile);
 }
 
-#if H_MV
+UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
+{
+  UInt subStrm;
+  const bool bWPPEnabled=pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag();
+  const TComPicSym &picSym            = *(getPicSym());
+
+  if ((bWPPEnabled && picSym.getFrameHeightInCtus()>1) || (picSym.getNumTiles()>1)) // wavefronts, and possibly tiles being used.
+  {
+    if (bWPPEnabled)
+    {
+      const UInt ctuRsAddr                = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
+      const UInt frameWidthInCtus         = picSym.getFrameWidthInCtus();
+      const UInt tileIndex                = picSym.getTileIdxMap(ctuRsAddr);
+      const UInt numTileColumns           = (picSym.getNumTileColumnsMinus1()+1);
+      const TComTile *pTile               = picSym.getTComTile(tileIndex);
+      const UInt firstCtuRsAddrOfTile     = pTile->getFirstCtuRsAddr();
+      const UInt tileYInCtus              = firstCtuRsAddrOfTile / frameWidthInCtus;
+      // independent tiles => substreams are "per tile"
+      const UInt ctuLine                  = ctuRsAddr / frameWidthInCtus;
+      const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns));
+      subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus);
+    }
+    else
+    {
+      const UInt ctuRsAddr                = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr);
+      const UInt tileIndex                = picSym.getTileIdxMap(ctuRsAddr);
+      subStrm=tileIndex;
+    }
+  }
+  else
+  {
+    // dependent tiles => substreams are "per frame".
+    subStrm = 0;
+  }
+  return subStrm;
+}
+
+#if NH_MV
 Void TComPic::print( Bool legend )
 {
@@ -204,5 +256,5 @@
 }
 
-#if H_3D
+#if NH_3D
 TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
 {
@@ -250,5 +302,5 @@
 }
 
-#if H_3D
+#if NH_3D
 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
 {  
@@ -256,5 +308,5 @@
   return getPicYuv( layerIdInNuh, poc, recon );
 }
-#if H_3D_ARP
+#if NH_3D_ARP
 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
 {
@@ -274,8 +326,8 @@
 #endif
 #endif
-#endif // H_MV
-
-#if H_3D_NBDV 
-Int TComPic::getDisCandRefPictures( Int iColPOC )
+#endif // NH_MV
+
+#if NH_3D_NBDV 
+Int TComPic::getDisCandRefPictures(Int iColPOC)
 {
   UInt       uiTempLayerCurr = 7;
@@ -283,6 +335,8 @@
   UInt       numDdvCandPics  = 0;
 
-  if ( !currSlice->getEnableTMVPFlag() )
+  if(!currSlice->getEnableTMVPFlag())
+  {
     return numDdvCandPics;
+  }
 
   numDdvCandPics += 1;
@@ -291,18 +345,18 @@
   UInt pocDiff = 255;
 
-  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
-  {
-    UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
-
-    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
+  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr++)
+  {
+    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
+
+    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     {
       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() 
-        && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
+         && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) && numDdvCandPics != 2)
       {
         TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
-        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0; 
+        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP()) ? 1 : 0; 
         UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer(); 
         
-        if( bRAP )
+        if(bRAP)
         {
           this->setRapRefIdx(i);
@@ -323,15 +377,15 @@
   UInt idx = 0;
   
-  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
-  {
-    UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
+  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2 : 1); lpNr++)
+  {
+    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
     
-    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
+    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     {
       Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
-      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
+      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr) : (pocCurr - iTempPoc);
       
-      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) 
-        && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
+      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) 
+         && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
       {
         pocDiff = iTempDiff;
@@ -342,8 +396,8 @@
   }
 
-  if( pocDiff < 255 )
+  if(pocDiff < 255)
   {
     this->setRapRefIdx(idx);
-    this->setRapRefList((RefPicList) z );
+    this->setRapRefList((RefPicList) z);
     numDdvCandPics = 2;
   }
@@ -356,11 +410,12 @@
   TComSlice* currSlice = getSlice(getCurrSliceIdx());
   const Int numCandPics = this->getNumDdvCandPics();
+
   for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
   {
     RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
     Int        curCandPicRefIdx = 0;
-    if( curCandPic == 0 ) 
+    if(curCandPic == 0) 
     { 
-      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
+      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1 - currSlice->getColFromL0Flag() : 0);
       curCandPicRefIdx = currSlice->getColRefIdx();
     }
@@ -370,24 +425,27 @@
       curCandPicRefIdx = this->getRapRefIdx();
     }
-    TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
-    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
+
+    TComPic* pcCandColPic = currSlice->getRefPic(eCurRefPicList, curCandPicRefIdx);
+    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0); // currently only support single slice
 
     if(!pcCandColSlice->isIntra())
     {
-      for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
-      {
-        for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
+      for(Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2 : 1); iColRefDir++)
+      {
+        for(Int iColRefIdx = 0; iColRefIdx < pcCandColSlice->getNumRefIdx((RefPicList)iColRefDir); iColRefIdx++)
         {
           m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
           Int iColViewIdx    = pcCandColSlice->getViewIndex();
-          Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
+          Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex();
           if(iColViewIdx == iColRefViewIdx)
+          {
             continue;
-
-          for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
+          }
+
+          for(Int iCurrRefDir = 0; (iCurrRefDir < (currSlice->isInterB() ? 2 : 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false); iCurrRefDir++)
           {
-            for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
+            for(Int iCurrRefIdx = 0; iCurrRefIdx < currSlice->getNumRefIdx((RefPicList)iCurrRefDir); iCurrRefIdx++)
             {
-              if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
+              if(currSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iColRefViewIdx)
               {  
                 m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
@@ -401,4 +459,5 @@
   }
 }
+
 Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
 {
@@ -406,38 +465,36 @@
 }
 
-Void TComPic::checkTextureRef(  )
+Void TComPic::checkTextureRef()
 {
   TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
-  TComPic* pcTextPic = pcCurrSlice->getTexturePic();
+  TComPic* pcTextPic = pcCurrSlice->getIvPic(0, getViewIndex());
 #if H_3D_FCO
   if ( pcTextPic )
   {
 #endif
-
-  TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
-
-  for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
-  {
-    for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
-    {
-      Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
-      Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
-      m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
-      Int iCurrRefDir = iTextRefDir;
-      for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
-      {
-        if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
-          pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
-        {  
-          m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
+    TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
+
+    for(Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB() ? 2 :1) ) && !pcTextSlice->isIntra(); iTextRefDir++)
+    {
+      for(Int iTextRefIdx =0; iTextRefIdx < pcTextSlice->getNumRefIdx((RefPicList)iTextRefDir); iTextRefIdx++)
+      {
+        Int iTextRefPOC    = pcTextSlice->getRefPOC((RefPicList)iTextRefDir, iTextRefIdx);
+        Int iTextRefViewId = pcTextSlice->getRefPic((RefPicList)iTextRefDir, iTextRefIdx)->getViewIndex();
+        m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
+        Int iCurrRefDir = iTextRefDir;
+
+        for(Int iCurrRefIdx = 0; (iCurrRefIdx<pcCurrSlice->getNumRefIdx((RefPicList)iCurrRefDir)) && (m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0); iCurrRefIdx++)
+        {
+          if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
+             pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
+          {  
+            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
+          }
         }
       }
     }
-
-  }
 #if H_3D_FCO
   }
 #endif
-
 }
 
@@ -447,3 +504,5 @@
 }
 #endif
+
+
 //! \}
