Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPattern.cpp


Ignore:
Timestamp:
11 May 2012, 21:20:17 (12 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComPattern.cpp

    r21 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3232 */
    3333
    34 
    35 
    3634/** \file     TComPattern.cpp
    3735    \brief    neighbouring pixel access classes
     
    4240#include "TComDataCU.h"
    4341
     42//! \ingroup TLibCommon
     43//! \{
     44
    4445// ====================================================================================================================
    4546// Tables
    4647// ====================================================================================================================
    4748
    48 const UChar g_aaucAvailableBlkMask[16][8] =
    49 {
    50   // 4x4 block neighbor availability      // MB neighbor availability
    51   {0x0,0x0,0x0,0x0,  0x0,0x8,0x0,0x08  }, // L, A, AL, AR   <== WTF (blkIdx < 8)
    52   {0x1,0x0,0x0,0x0,  0x1,0x8,0x0,0x08  }, //    A, AL, AR
    53   {0xA,0xE,0xE,0x6,  0x0,0x8,0x0,0x08  }, // L,    AL, AR
    54   {0xB,0xE,0xE,0x6,  0x1,0x8,0x0,0x08  }, //       AL, AR
    55  
    56   {0x4,0x0,0x0,0x0,  0x0,0x8,0x0,0x08  }, // L, A,     AR
    57   {0x5,0x0,0x0,0x0,  0x1,0x8,0x0,0x08  }, //    A,     AR
    58   {0xE,0xE,0xE,0x6,  0x0,0x8,0x0,0x08  }, // L,        AR
    59   {0xF,0xE,0xE,0x6,  0x1,0x8,0x0,0x08  }, //           AR
    60  
    61   {0x0,0x0,0x0,0x8,  0x0,0x8,0x0,0x08  }, // L, A, AL       <== WTF (blkIdx < 8 || blkIdx >= 8)
    62   {0x1,0x0,0x0,0x8,  0x1,0x8,0x0,0x08  }, //    A, AL
    63   {0xA,0xE,0xE,0xE,  0x0,0x8,0x0,0x08  }, // L,    AL
    64   {0xB,0xE,0xE,0xE,  0x1,0x8,0x0,0x08  }, //       AL
    65  
    66   {0x4,0x0,0x0,0x8,  0x0,0x8,0x0,0x08  }, // L, A,
    67   {0x5,0x0,0x0,0x8,  0x1,0x8,0x0,0x08  }, //    A,
    68   {0xE,0xE,0xE,0xE,  0x0,0x8,0x0,0x08  }, // L,
    69   {0xF,0xE,0xE,0xE,  0x1,0x8,0x0,0x08  }  //
     49#if LOGI_INTRA_NAME_3MPM
     50const UChar TComPattern::m_aucIntraFilter[5] =
     51{
     52  10, //4x4
     53  7, //8x8
     54  1, //16x16
     55  0, //32x32
     56  10, //64x64
    7057};
     58#else
     59const UChar TComPattern::m_aucIntraFilter[5][NUM_INTRA_MODE] =
     60{
     61  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     62  }, //4x4
     63  {1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     64  }, //8x8
     65  {1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0
     66  }, //16x16
     67  {1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
     68  }, //32x32
     69  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     70  }, //64x64
     71};
     72#endif
    7173
    7274// ====================================================================================================================
     
    124126                                         Int         iOffsetBottom,
    125127                                         UInt        uiPartDepth,
    126                                          UInt        uiAbsPartIdx
    127 #if DEPTH_MAP_GENERATION
    128                                         ,Bool        bPrdDepthMap
     128                                         UInt        uiAbsPartIdx 
     129#if DEPTH_MAP_GENERATION
     130                                         ,Bool        bPrdDepthMap
    129131#endif
    130132                                         )
     
    145147  TComPicYuv* pcPic = pcCU->getPic()->getPicYuvRec();
    146148#endif
     149
    147150  if ( iComp == 0 )
    148151  {
     
    162165#endif
    163166    if ( iComp == 1 )
     167    {
    164168      m_piPatternOrigin = pcPic->getCbAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
     169    }
    165170    else
     171    {
    166172      m_piPatternOrigin = pcPic->getCrAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
     173    }
    167174  }
    168175}
     
    190197}
    191198
    192 Void TComPattern::initPattern( TComDataCU* pcCU, UInt uiPartDepth, UInt uiAbsPartIdx
    193 #if DEPTH_MAP_GENERATION
    194                              , Bool bPrdDepthMap
    195 #endif
    196                              )
     199Void TComPattern::initPattern( TComDataCU* pcCU, UInt uiPartDepth, UInt uiAbsPartIdx 
     200#if DEPTH_MAP_GENERATION
     201                              , Bool bPrdDepthMap
     202#endif
     203                              )
    197204{
    198205  Int   uiOffsetLeft  = 0;
     
    209216 
    210217  if( uiCurrPicPelX != 0 )
     218  {
    211219    uiOffsetLeft = 1;
     220  }
     221 
    212222  if( uiCurrPicPelY != 0 )
    213223  {
     
    215225    uiOffsetAbove = 1;
    216226   
    217     if( uiCurrPicPelX + uiWidth < pcCU->getSlice()->getSPS()->getWidth() )
     227    if( uiCurrPicPelX + uiWidth < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() )
    218228    {
    219229      if( ( g_auiZscanToRaster[uiAbsZorderIdx] + uiNumPartInWidth ) % pcPic->getNumPartInWidth() ) // Not CU boundary
    220230      {
    221231        if( g_auiRasterToZscan[ (Int)g_auiZscanToRaster[uiAbsZorderIdx] - (Int)pcPic->getNumPartInWidth() + (Int)uiNumPartInWidth ] < uiAbsZorderIdx )
     232        {
    222233          uiOffsetRight = 1;
     234        }
    223235      }
    224236      else // if it is CU boundary
     
    232244  }
    233245 
    234 #if LM_CHROMA
    235   m_bLeftAvailable = uiCurrPicPelX > 0 ? true : false;
    236   m_bAboveAvailable = uiCurrPicPelY > 0 ? true : false;
    237 #endif
    238 
    239246#if DEPTH_MAP_GENERATION
    240247  m_cPatternY .setPatternParamCU( pcCU, 0, uiWidth,      uiHeight,      uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap );
     
    248255}
    249256
    250 Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft
    251 #if DEPTH_MAP_GENERATION
    252                                 , Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY
    253 #endif
    254                                 )
     257  Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft, Bool bLMmode
     258#if DEPTH_MAP_GENERATION
     259                                  , Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY
     260#endif
     261    )
    255262{
    256263  Pel*  piRoiOrigin;
     
    262269  UInt  uiWidth;
    263270  UInt  uiHeight;
    264 
    265271#if DEPTH_MAP_GENERATION
    266272  Int   iPicStride = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getStride() : pcCU->getPic()->getStride() );
     
    268274  Int   iPicStride = pcCU->getPic()->getStride();
    269275#endif
    270 
    271   Int   iCuAddr;
    272 #if REFERENCE_SAMPLE_PADDING
    273276  Int   iUnitSize = 0;
    274277  Int   iNumUnitsInCu = 0;
    275278  Int   iTotalUnits = 0;
    276   Bool* bNeighborFlags;
     279  Bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
    277280  Int   iNumIntraNeighbor = 0;
    278 #else  // REFERENCE_SAMPLE_PADDING
    279   Pel*  piRoiTemp;
    280   Bool  bAboveFlag      = false;
    281   Bool  bAboveRightFlag = false;
    282   Bool  bLeftFlag       = false;
    283   Bool  bBelowLeftFlag  = false;
    284   Bool  bAboveLeftFlag  = false;
    285 #endif // REFERENCE_SAMPLE_PADDING
    286  
    287   iCuAddr = pcCU->getAddr();
    288  
    289   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB, uiPartDum;
     281 
     282  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
     283
    290284 
    291285  pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth );
    292286  pcCU->deriveLeftBottomIdxAdi  ( uiPartIdxLB,              uiZorderIdxInPart, uiPartDepth );
    293287 
    294 #if CONSTRAINED_INTRA_PRED
    295   if ( pcCU->getSlice()->getPPS()->getConstrainedIntraPred() )
    296   {
    297 #if REFERENCE_SAMPLE_PADDING
    298     iUnitSize      = g_uiMaxCUWidth >> g_uiMaxCUDepth;
    299     iNumUnitsInCu  = uiCuWidth / iUnitSize;
    300     iTotalUnits    = (iNumUnitsInCu << 2) + 1;
    301     bNeighborFlags = new Bool[iTotalUnits];
    302 
    303     bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailableForCIP( pcCU, uiPartIdxLT );
    304     iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
    305     iNumIntraNeighbor  += isAboveAvailableForCIP     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
    306     iNumIntraNeighbor  += isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
    307     iNumIntraNeighbor  += isLeftAvailableForCIP      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
    308     iNumIntraNeighbor  += isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
    309 #else // REFERENCE_SAMPLE_PADDING
    310     bAboveFlag      = isAboveAvailableForCIP     ( pcCU, uiPartIdxLT, uiPartIdxRT );
    311     bAboveRightFlag = isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT );
    312     bLeftFlag       = isLeftAvailableForCIP      ( pcCU, uiPartIdxLT, uiPartIdxLB );
    313     bBelowLeftFlag  = isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB );
    314     bAboveLeftFlag  = isAboveLeftAvailableForCIP ( pcCU, uiPartIdxLT );
    315 #endif // REFERENCE_SAMPLE_PADDING
    316   }
    317   else
    318   {
    319 #if REFERENCE_SAMPLE_PADDING
    320     iUnitSize     = uiCuWidth;
    321     iNumUnitsInCu = 1;
    322     iTotalUnits   = 5;
    323     bNeighborFlags = new Bool[iTotalUnits];
    324 
    325     ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits);
    326     if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; }
    327     if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, 1, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; }
    328     if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; }
    329     if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; }
    330     if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; }
    331 #if MN_DC_PRED_FILTER
    332     m_bAboveFlagForDCFilt = bNeighborFlags[3];
    333     m_bLeftFlagForDCFilt  = bNeighborFlags[1];
    334 #endif
    335 #else // REFERENCE_SAMPLE_PADDING
    336     if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT,    true, false ) ) bAboveFlag      = true;
    337     if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, 1, true, false ) ) bAboveRightFlag = true;
    338     if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT,    true, false ) ) bLeftFlag       = true;
    339     if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) bBelowLeftFlag  = true;
    340     if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT,    true, false ) ) bAboveLeftFlag  = true;
    341 #if MN_DC_PRED_FILTER
    342     m_bAboveFlagForDCFilt = bAboveFlag;
    343     m_bLeftFlagForDCFilt  = bLeftFlag;
    344 #endif
    345 #endif // REFERENCE_SAMPLE_PADDING
    346   }
    347 #else //CONSTRAINED_INTRA_PRED
    348 #if REFERENCE_SAMPLE_PADDING
    349   iUnitSize     = uiCuWidth;
    350   iNumUnitsInCu = 1;
    351   iTotalUnits   = 5;
    352   bNeighborFlags = new Bool[iTotalUnits];
    353 
    354   ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits);
    355   if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; }
    356   if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; }
    357   if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; }
    358   if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; }
    359   if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; }
    360 #if MN_DC_PRED_FILTER
    361   m_bAboveFlagForDCFilt = bNeighborFlags[3];
    362   m_bLeftFlagForDCFilt  = bNeighborFlags[1];
    363 #endif
    364 #else // REFERENCE_SAMPLE_PADDING
    365   if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT, true, false ) ) bAboveFlag      = true;
    366   if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, true, false ) ) bAboveRightFlag = true;
    367   if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT, true, false ) ) bLeftFlag       = true;
    368   if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) bBelowLeftFlag  = true;
    369   if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT, true, false ) ) bAboveLeftFlag  = true;
    370 #if MN_DC_PRED_FILTER
    371   m_bAboveFlagForDCFilt = bAboveFlag;
    372   m_bLeftFlagForDCFilt  = bLeftFlag;
    373 #endif
    374 #endif // REFERENCE_SAMPLE_PADDING
    375 #endif //CONSTRAINED_INTRA_PRED
    376 
    377 #if MN_DC_PRED_FILTER
    378   m_bDCPredFilterFlag = (m_bAboveFlagForDCFilt && m_bLeftFlagForDCFilt) ? true : false;
    379 #endif
    380  
    381 #if REFERENCE_SAMPLE_PADDING
     288  iUnitSize      = g_uiMaxCUWidth >> g_uiMaxCUDepth;
     289  iNumUnitsInCu  = uiCuWidth / iUnitSize;
     290  iTotalUnits    = (iNumUnitsInCu << 2) + 1;
     291
     292  bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
     293  iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
     294  iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
     295  iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
     296  iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
     297  iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
     298 
    382299  bAbove = true;
    383300  bLeft  = true;
    384 #else // REFERENCE_SAMPLE_PADDING
    385   bAbove = bAboveFlag;
    386   bLeft  = bLeftFlag;
    387 
    388   Int iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) );
    389 #endif // REFERENCE_SAMPLE_PADDING
    390  
     301
    391302#if DEPTH_MAP_GENERATION
    392303  if ( bPrdDepthMap )
     
    397308  else
    398309  {
     310    uiWidth=uiCuWidth2+1;
     311    uiHeight=uiCuHeight2+1;
     312  }
     313#else
    399314  uiWidth=uiCuWidth2+1;
    400315  uiHeight=uiCuHeight2+1;
    401   }
    402 #else
    403   uiWidth=uiCuWidth2+1;
    404   uiHeight=uiCuHeight2+1;
    405316#endif
    406317 
    407318  if (((uiWidth<<2)>iOrgBufStride)||((uiHeight<<2)>iOrgBufHeight))
     319  {
    408320    return;
     321  }
    409322 
    410323  piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart);
     
    415328  {
    416329    piRoiOrigin = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiZorderIdxInPart );
    417 #if REFERENCE_SAMPLE_PADDING
    418 #else
    419     iDCValue    = PDM_UNDEFINED_DEPTH;
    420 #endif
    421   }
    422 #endif
    423 
    424 
    425 #if REFERENCE_SAMPLE_PADDING
     330  }
     331#endif
     332
    426333#if DEPTH_MAP_GENERATION
    427334  if ( bPrdDepthMap )
    428     fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize >> uiSubSampExpX, iNumUnitsInCu, iTotalUnits, uiCuWidth >> uiSubSampExpX, uiCuHeight >> uiSubSampExpY, uiWidth, uiHeight, iPicStride, bPrdDepthMap );
     335    fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize >> uiSubSampExpX, iNumUnitsInCu, iTotalUnits, uiCuWidth >> uiSubSampExpX, uiCuHeight >> uiSubSampExpY, uiWidth, uiHeight, iPicStride, bLMmode, bPrdDepthMap );
    429336  else
    430   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bPrdDepthMap );
    431 #else
    432   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride );
    433 #endif
    434   delete [] bNeighborFlags;
    435   bNeighborFlags = NULL;
    436 #else // REFERENCE_SAMPLE_PADDING
    437   //BB: fill border with DC value - needed if( bAboveFlag=false || bLeftFlag=false )
    438   for (i=0;i<uiWidth;i++)
    439     piAdiTemp[i]=iDCValue;
    440   for (i=0;i<uiHeight;i++) //BB: can start from 1?
    441     piAdiTemp[i*uiWidth]=iDCValue;
    442  
    443   piRoiTemp=piRoiOrigin; //BB: not needed?
    444  
    445   if (bAboveFlag)
    446   {
    447     // BB: fill top border with rec. samples
    448     piRoiTemp=piRoiOrigin-iPicStride;
    449     for (i=0;i<uiCuWidth;i++)
    450       piAdiTemp[1+i]=piRoiTemp[i];
    451     // BB: fill top right border with rec. samples
    452     if (bAboveRightFlag)
    453     {
    454       piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth;
    455       for (i=0;i<uiCuWidth;i++)
    456         piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i];
    457     }
    458     // BB: fill top right border with last sample from top
    459     else
    460     {
    461       for (i=0;i<uiCuWidth;i++)
    462         piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth];
    463     }
    464   }
    465  
    466   if (bAboveLeftFlag)
    467   {
    468     piRoiTemp=piRoiOrigin-iPicStride-1;
    469     piAdiTemp[0]=piRoiTemp[0];
    470   }
    471 
    472   if (bLeftFlag)
    473   {
    474     // BB: fill left border with rec. samples
    475     piRoiTemp=piRoiOrigin-1;
    476     for (i=0;i<uiCuHeight;i++)
    477     {
    478       piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0];
    479       piRoiTemp+=iPicStride;
    480     }
    481     // BB: fill below left border with rec. samples
    482     if (bBelowLeftFlag)
    483     {
    484       for (i=0;i<uiCuHeight;i++)
    485       {
    486         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0];
    487         piRoiTemp+=iPicStride;
    488       }
    489     }
    490     // BB: fill below left border with last sample from left
    491     else
    492     {
    493       for (i=0;i<uiCuHeight;i++)
    494         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth];
    495     }
    496   }
    497 #endif // REFERENCE_SAMPLE_PADDING
    498  
    499 #if QC_MDIS
     337    fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bLMmode, bPrdDepthMap );
     338#else
     339  fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bLMmode);
     340#endif
     341
     342 
     343  Int   i;
    500344  // generate filtered intra prediction samples
    501345  Int iBufSize = uiCuHeight2 + uiCuWidth2 + 1;  // left and left above border + above and above right border + top left corner = length of 3. filter buffer
    502   Int   i;
    503346
    504347  UInt uiWH = uiWidth * uiHeight;               // number of elements in one buffer
     
    512355  // left border from bottom to top
    513356  for (i = 0; i < uiCuHeight2; i++)
     357  {
    514358    piFilterBuf[l++] = piAdiTemp[uiWidth * (uiCuHeight2 - i)];
     359  }
    515360  // top left corner
    516361  piFilterBuf[l++] = piAdiTemp[0];
    517362  // above border from left to right
    518363  for (i=0; i < uiCuWidth2; i++)
     364  {
    519365    piFilterBuf[l++] = piAdiTemp[1 + i];
     366  }
    520367
    521368  // 1. filtering with [1 2 1]
     
    523370  piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1];
    524371  for (i = 1; i < iBufSize - 1; i++)
     372  {
    525373    piFilterBufN[i] = (piFilterBuf[i - 1] + 2 * piFilterBuf[i]+piFilterBuf[i + 1] + 2) >> 2;
     374  }
    526375
    527376  // fill 1. filter buffer with filtered values
    528377  l=0;
    529378  for (i = 0; i < uiCuHeight2; i++)
     379  {
    530380    piFilteredBuf1[uiWidth * (uiCuHeight2 - i)] = piFilterBufN[l++];
     381  }
    531382  piFilteredBuf1[0] = piFilterBufN[l++];
    532383  for (i = 0; i < uiCuWidth2; i++)
     384  {
    533385    piFilteredBuf1[1 + i] = piFilterBufN[l++];
    534 
    535 #if !MN_MDIS_SIMPLIFICATION
    536   // 2. filtering with [1 2 1]
    537   piFilterBuf[0] = piFilterBufN[0];                   
    538   piFilterBuf[iBufSize - 1] = piFilterBufN[iBufSize - 1];
    539   for (i = 1; i < iBufSize - 1; i++)
    540     piFilterBuf[i] = (piFilterBufN[i - 1] + 2 * piFilterBufN[i] + piFilterBufN[i + 1] + 2) >> 2;
    541 
    542   // fill 2. filter buffer with filtered values
    543   l=0;
    544   for (i = 0; i < uiCuHeight2; i++)
    545     piFilteredBuf2[uiWidth * (uiCuHeight2 - i)] = piFilterBuf[l++];
    546   piFilteredBuf2[0] = piFilterBuf[l++];
    547   for (i = 0; i < uiCuWidth2; i++)
    548     piFilteredBuf2[1 + i] = piFilterBuf[l++];
    549 #endif
    550 #endif //QC_MDIS
    551  
     386  }
    552387}
    553388
     
    561396  UInt  uiHeight;
    562397  Int   iPicStride = pcCU->getPic()->getCStride();
    563   Int   iCuAddr;
    564 #if REFERENCE_SAMPLE_PADDING
     398
    565399  Int   iUnitSize = 0;
    566400  Int   iNumUnitsInCu = 0;
    567401  Int   iTotalUnits = 0;
    568   Bool* bNeighborFlags;
     402  Bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
    569403  Int   iNumIntraNeighbor = 0;
    570 #else // REFERENCE_SAMPLE_PADDING
    571   Pel*  piRoiTemp;
    572   Int   i;
    573   Bool  bAboveFlag=false;
    574   Bool  bAboveRightFlag=false;
    575   Bool  bLeftFlag=false;
    576   Bool  bBelowLeftFlag=false;
    577   Bool  bAboveLeftFlag    = false;
    578 #endif // REFERENCE_SAMPLE_PADDING
    579  
    580   iCuAddr = pcCU->getAddr();
    581  
    582   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB,uiPartDum;
     404 
     405  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    583406 
    584407  pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth );
    585408  pcCU->deriveLeftBottomIdxAdi  ( uiPartIdxLB,              uiZorderIdxInPart, uiPartDepth );
    586409 
    587 #if CONSTRAINED_INTRA_PRED
    588   if ( pcCU->getSlice()->getPPS()->getConstrainedIntraPred() )
    589   {
    590 #if REFERENCE_SAMPLE_PADDING
    591     iUnitSize      = (g_uiMaxCUWidth >> g_uiMaxCUDepth) >> 1; // for chroma
    592     iNumUnitsInCu  = (uiCuWidth / iUnitSize) >> 1;            // for chroma
    593     iTotalUnits    = (iNumUnitsInCu << 2) + 1;
    594     bNeighborFlags = new Bool[iTotalUnits];
    595 
    596     bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailableForCIP( pcCU, uiPartIdxLT );
    597     iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
    598     iNumIntraNeighbor  += isAboveAvailableForCIP     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
    599     iNumIntraNeighbor  += isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
    600     iNumIntraNeighbor  += isLeftAvailableForCIP      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
    601     iNumIntraNeighbor  += isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
    602 #else // REFERENCE_SAMPLE_PADDING
    603     bAboveFlag      = isAboveAvailableForCIP     ( pcCU, uiPartIdxLT, uiPartIdxRT );
    604     bAboveRightFlag = isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT );
    605     bLeftFlag       = isLeftAvailableForCIP      ( pcCU, uiPartIdxLT, uiPartIdxLB );
    606     bBelowLeftFlag  = isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB );
    607     bAboveLeftFlag  = isAboveLeftAvailableForCIP ( pcCU, uiPartIdxLT );
    608 #endif // REFERENCE_SAMPLE_PADDING
    609   }
    610   else
    611   {
    612 #if REFERENCE_SAMPLE_PADDING
    613     iUnitSize     = uiCuWidth >> 1;
    614     iNumUnitsInCu = 1;
    615     iTotalUnits   = 5;
    616     bNeighborFlags = new Bool[iTotalUnits];
    617 
    618     ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits);
    619     if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; }
    620     if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, 1, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; }
    621     if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; }
    622     if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; }
    623     if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT,    true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; }
    624 #else // REFERENCE_SAMPLE_PADDING
    625     if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT,    true, false ) ) bAboveFlag      = true;
    626     if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, 1, true, false ) ) bAboveRightFlag = true;
    627     if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT,    true, false ) ) bLeftFlag       = true;
    628     if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) bBelowLeftFlag  = true;
    629     if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT,    true, false ) ) bAboveLeftFlag  = true;
    630 #endif // REFERENCE_SAMPLE_PADDING
    631   }
    632 #else //CONSTRAINED_INTRA_PRED
    633 #if REFERENCE_SAMPLE_PADDING
    634   iUnitSize     = uiCuWidth >> 1;
    635   iNumUnitsInCu = 1;
    636   iTotalUnits   = 5;
    637   bNeighborFlags = new Bool[iTotalUnits];
    638 
    639   ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits);
    640   if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; }
    641   if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; }
    642   if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; }
    643   if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; }
    644   if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; }
    645 #else // REFERENCE_SAMPLE_PADDING
    646   if( pcCU->getPUAbove        ( uiPartDum,             uiPartIdxLT, true, false ) ) bAboveFlag      = true;
    647   if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth,  uiPartIdxRT, true, false ) ) bAboveRightFlag = true;
    648   if( pcCU->getPULeft         ( uiPartDum,             uiPartIdxLT, true, false ) ) bLeftFlag       = true;
    649   if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) bBelowLeftFlag  = true;
    650   if( pcCU->getPUAboveLeft    ( uiPartDum,             uiPartIdxLT, true, false ) ) bAboveLeftFlag  = true;
    651 #endif // REFERENCE_SAMPLE_PADDING
    652 #endif //CONSTRAINED_INTRA_PRED
    653  
    654 #if REFERENCE_SAMPLE_PADDING
     410  iUnitSize      = (g_uiMaxCUWidth >> g_uiMaxCUDepth) >> 1; // for chroma
     411  iNumUnitsInCu  = (uiCuWidth / iUnitSize) >> 1;            // for chroma
     412  iTotalUnits    = (iNumUnitsInCu << 2) + 1;
     413
     414  bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
     415  iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
     416  iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
     417  iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
     418  iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
     419  iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
     420 
    655421  bAbove = true;
    656422  bLeft  = true;
    657 #else // REFERENCE_SAMPLE_PADDING
    658   bAbove = bAboveFlag;
    659   bLeft  = bLeftFlag;
    660 
    661   Int iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) );
    662 #endif // REFERENCE_SAMPLE_PADDING
    663423 
    664424  uiCuWidth=uiCuWidth>>1;  // for chroma
     
    669429 
    670430  if ((4*uiWidth>iOrgBufStride)||(4*uiHeight>iOrgBufHeight))
     431  {
    671432    return;
     433  }
    672434 
    673435  // get Cb pattern
     
    675437  piAdiTemp   = piAdiBuf;
    676438
    677 #if REFERENCE_SAMPLE_PADDING
    678 #if DEPTH_MAP_GENERATION
    679   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false );
    680 #else
    681   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride );
    682 #endif
    683 #else // REFERENCE_SAMPLE_PADDING
    684   for (i=0;i<uiWidth;i++)
    685     piAdiTemp[i]=iDCValue;
    686   for (i=0;i<uiHeight;i++)
    687     piAdiTemp[i*uiWidth]=iDCValue;
    688  
    689   piRoiTemp=piRoiOrigin;
    690  
    691   if (bAboveFlag)
    692   {
    693     piRoiTemp=piRoiOrigin-iPicStride;
    694     for (i=0;i<uiCuWidth;i++)
    695       piAdiTemp[1+i]=piRoiTemp[i];
    696     if (bAboveRightFlag)
    697     {
    698       piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth;
    699       for (i=0;i<uiCuWidth;i++)
    700         piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i];
    701     }
    702     else
    703     {
    704       for (i=0;i<uiCuWidth;i++)
    705         piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth];
    706     }
    707   }
    708  
    709   if (bAboveLeftFlag)
    710   {
    711     piRoiTemp=piRoiOrigin-iPicStride-1;
    712     piAdiTemp[0]=piRoiTemp[0];
    713   }
    714 
    715   if (bLeftFlag)
    716   {
    717     piRoiTemp=piRoiOrigin-1;
    718     for (i=0;i<uiCuHeight;i++)
    719     {
    720       piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0];
    721       piRoiTemp+=iPicStride;
    722     }
    723     if (bBelowLeftFlag)
    724     {
    725       for (i=0;i<uiCuHeight;i++)
    726       {
    727         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0];
    728         piRoiTemp+=iPicStride;
    729       }
    730     }
    731     else
    732     {
    733       for (i=0;i<uiCuHeight;i++)
    734         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth];
    735     }
    736   }
    737 #endif // REFERENCE_SAMPLE_PADDING
     439#if DEPTH_MAP_GENERATION
     440  fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false, false );
     441#else
     442  fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride);
     443#endif
    738444 
    739445  // get Cr pattern
     
    741447  piAdiTemp   = piAdiBuf+uiWidth*uiHeight;
    742448 
    743 #if REFERENCE_SAMPLE_PADDING
    744 #if DEPTH_MAP_GENERATION
    745   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false );
    746 #else
    747   fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride );
    748 #endif
    749   delete [] bNeighborFlags;
    750   bNeighborFlags = NULL;
    751 #else // REFERENCE_SAMPLE_PADDING
    752   for (i=0;i<uiWidth;i++)
    753     piAdiTemp[i]=iDCValue;
    754   for (i=0;i<uiHeight;i++)
    755     piAdiTemp[i*uiWidth]=iDCValue;
    756  
    757   piRoiTemp=piRoiOrigin;
    758  
    759   if (bAboveFlag)
    760   {
    761     piRoiTemp=piRoiOrigin-iPicStride;
    762     for (i=0;i<uiCuWidth;i++)
    763       piAdiTemp[1+i]=piRoiTemp[i];
    764     if (bAboveRightFlag)
    765     {
    766       piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth;
    767       for (i=0;i<uiCuWidth;i++)
    768         piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i];
    769     }
    770     else
    771     {
    772       for (i=0;i<uiCuWidth;i++)
    773         piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth];
    774     }
    775   }
    776 
    777   if (bAboveLeftFlag)
    778   {
    779     piRoiTemp=piRoiOrigin-iPicStride-1;
    780     piAdiTemp[0]=piRoiTemp[0];
    781   }
    782 
    783   if (bLeftFlag)
    784   {
    785     piRoiTemp=piRoiOrigin-1;
    786     for (i=0;i<uiCuHeight;i++)
    787     {
    788       piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0];
    789       piRoiTemp+=iPicStride;
    790     }
    791     if (bBelowLeftFlag)
    792     {
    793       for (i=0;i<uiCuHeight;i++)
    794       {
    795         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0];
    796         piRoiTemp+=iPicStride;
    797       }
    798     }
    799     else
    800     {
    801       for (i=0;i<uiCuHeight;i++)
    802         piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth];
    803     }
    804   }
    805 #endif // REFERENCE_SAMPLE_PADDING
    806 }
    807 
    808 #if REFERENCE_SAMPLE_PADDING
    809 Void TComPattern::fillReferenceSamples( TComDataCU* pcCU, Pel* piRoiOrigin, Int* piAdiTemp, Bool* bNeighborFlags, Int iNumIntraNeighbor, Int iUnitSize, Int iNumUnitsInCu, Int iTotalUnits, UInt uiCuWidth, UInt uiCuHeight, UInt uiWidth, UInt uiHeight, Int iPicStride
    810 #if DEPTH_MAP_GENERATION
    811                                         , Bool bPrdDepthMap
    812 #endif
    813                                         )
     449#if DEPTH_MAP_GENERATION
     450  fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false, false );
     451#else
     452  fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride);
     453#endif
     454
     455}
     456
     457Void TComPattern::fillReferenceSamples( TComDataCU* pcCU, Pel* piRoiOrigin, Int* piAdiTemp, Bool* bNeighborFlags, Int iNumIntraNeighbor, Int iUnitSize, Int iNumUnitsInCu, Int iTotalUnits, UInt uiCuWidth, UInt uiCuHeight, UInt uiWidth, UInt uiHeight, Int iPicStride, Bool bLMmode
     458#if DEPTH_MAP_GENERATION
     459                                       , Bool bPrdDepthMap
     460#endif
     461                                       )
    814462{
    815463  Pel* piRoiTemp;
     
    820468  Int  iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) );
    821469#endif
    822  
     470
    823471  if (iNumIntraNeighbor == 0)
    824472  {
    825473    // Fill border with DC value
    826474    for (i=0; i<uiWidth; i++)
     475    {
    827476      piAdiTemp[i] = iDCValue;
     477    }
    828478    for (i=1; i<uiHeight; i++)
     479    {
    829480      piAdiTemp[i*uiWidth] = iDCValue;
     481    }
    830482  }
    831483  else if (iNumIntraNeighbor == iTotalUnits)
     
    837489    // Fill left border with rec. samples
    838490    piRoiTemp = piRoiOrigin - 1;
     491
     492    if (bLMmode)
     493    {
     494      piRoiTemp --; // move to the second left column
     495    }
     496
    839497    for (i=0; i<uiCuHeight; i++)
    840498    {
     
    853511    piRoiTemp = piRoiOrigin - iPicStride;
    854512    for (i=0; i<uiCuWidth; i++)
     513    {
    855514      piAdiTemp[1+i] = piRoiTemp[i];
    856 
     515    }
     516   
    857517    // Fill top right border with rec. samples
    858518    piRoiTemp = piRoiOrigin - iPicStride + uiCuWidth;
    859519    for (i=0; i<uiCuWidth; i++)
     520    {
    860521      piAdiTemp[1+uiCuWidth+i] = piRoiTemp[i];
     522    }
    861523  }
    862524  else // reference samples are partially available
     
    864526    Int  iNumUnits2 = iNumUnitsInCu<<1;
    865527    Int  iTotalSamples = iTotalUnits*iUnitSize;
    866     Pel  *piAdiLine = new Pel[iTotalSamples];
     528    Pel  piAdiLine[5 * MAX_CU_SIZE];
    867529    Pel  *piAdiLineTemp;
    868530    Bool *pbNeighborFlags;
    869     Int  iPrev, iNext, iCurr;
     531    Int  iNext, iCurr;
    870532    Pel  piRef = 0;
    871533
    872534    // Initialize
    873535    for (i=0; i<iTotalSamples; i++)
     536    {
    874537      piAdiLine[i] = iDCValue;
    875 
     538    }
     539   
    876540    // Fill top-left sample
    877541    piRoiTemp = piRoiOrigin - iPicStride - 1;
     
    882546      piAdiLineTemp[0] = piRoiTemp[0];
    883547      for (i=1; i<iUnitSize; i++)
     548      {
    884549        piAdiLineTemp[i] = piAdiLineTemp[0];
     550      }
    885551    }
    886552
    887553    // Fill left & below-left samples
    888554    piRoiTemp += iPicStride;
     555    if (bLMmode)
     556    {
     557      piRoiTemp --; // move the second left column
     558    }
    889559    piAdiLineTemp--;
    890560    pbNeighborFlags--;
     
    894564      {
    895565        for (i=0; i<iUnitSize; i++)
     566        {
    896567          piAdiLineTemp[-i] = piRoiTemp[i*iPicStride];
     568        }
    897569      }
    898570      piRoiTemp += iUnitSize*iPicStride;
     
    910582      {
    911583        for (i=0; i<iUnitSize; i++)
     584        {
    912585          piAdiLineTemp[i] = piRoiTemp[i];
     586        }
    913587      }
    914588      piRoiTemp += iUnitSize;
     
    918592
    919593    // Pad reference samples when necessary
    920     iPrev = -1;
    921594    iCurr = 0;
    922595    iNext = 1;
     
    924597    while (iCurr < iTotalUnits)
    925598    {
    926       if (bNeighborFlags[iCurr])
    927       {
    928         // Move on to next block if current unit is available
    929         piAdiLineTemp += iUnitSize;
    930         iPrev++;
    931         iCurr++;
    932         iNext++;
    933       }
    934       else
    935       {
    936         // Interpolate from nearest samples if current unit is not available
    937        
    938         while (iNext < iTotalUnits && !bNeighborFlags[iNext])
    939           iNext++;
    940 
    941         if (iPrev >= 0 && iNext < iTotalUnits)
    942           piRef = (piAdiLine[iCurr*iUnitSize-1] + piAdiLine[iNext*iUnitSize] + 1) >> 1;
    943         else if (iPrev >= 0)
     599      if (!bNeighborFlags[iCurr])
     600      {
     601        if(iCurr == 0)
     602        {
     603          while (iNext < iTotalUnits && !bNeighborFlags[iNext])
     604          {
     605            iNext++;
     606          }
     607          piRef = piAdiLine[iNext*iUnitSize];
     608          // Pad unavailable samples with new value
     609          while (iCurr < iNext)
     610          {
     611            for (i=0; i<iUnitSize; i++)
     612            {
     613              piAdiLineTemp[i] = piRef;
     614            }
     615            piAdiLineTemp += iUnitSize;
     616            iCurr++;
     617          }
     618        }
     619        else
     620        {
    944621          piRef = piAdiLine[iCurr*iUnitSize-1];
    945         else if (iNext < iTotalUnits)
    946           piRef = piAdiLine[iNext*iUnitSize];
    947         else
    948           printf("\nERROR! No valid samples to interpolate.\n");
    949 
    950         // Pad unavailable samples with new value
    951         while (iCurr < iNext)
    952         {
    953622          for (i=0; i<iUnitSize; i++)
     623          {
    954624            piAdiLineTemp[i] = piRef;
     625          }
    955626          piAdiLineTemp += iUnitSize;
    956           iPrev++;
    957627          iCurr++;
    958628        }
    959         iNext++;
     629      }
     630      else
     631      {
     632        piAdiLineTemp += iUnitSize;
     633        iCurr++;
    960634      }
    961635    }
     
    964638    piAdiLineTemp = piAdiLine + uiHeight + iUnitSize - 2;
    965639    for (i=0; i<uiWidth; i++)
     640    {
    966641      piAdiTemp[i] = piAdiLineTemp[i];
     642    }
    967643    piAdiLineTemp = piAdiLine + uiHeight - 1;
    968644    for (i=1; i<uiHeight; i++)
     645    {
    969646      piAdiTemp[i*uiWidth] = piAdiLineTemp[-i];
    970 
    971     delete [] piAdiLine;
    972     piAdiLine = NULL;
    973   }
    974 }
    975 #endif // REFERENCE_SAMPLE_PADDING
     647    }
     648  }
     649}
    976650
    977651Int* TComPattern::getAdiOrgBuf( Int iCuWidth, Int iCuHeight, Int* piAdiBuf)
     
    990664}
    991665
    992 #if QC_MDIS
    993 Int* TComPattern::getPredictorPtr ( UInt uiDirMode, UInt uiWidthBits, Int iCuWidth, Int iCuHeight, Int* piAdiBuf )
    994 {
    995 #if MN_MDIS_SIMPLIFICATION
    996   static const UChar g_aucIntraFilter[7][34] =
    997   {
    998       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2x2
    999       {0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4x4
    1000       {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //8x8
    1001       {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //16x16
    1002       {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //32x32
    1003       {0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //64x64
    1004       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}  //128x128
    1005   };
    1006 #else
    1007   static const UChar g_aucIntraFilter[7][34] =
    1008   {
    1009       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2x2
    1010       {0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4x4
    1011       {0, 0, 0, 1, 1, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //8x8
    1012       {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //16x16
    1013       {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, //32x32
    1014       {0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //64x64
    1015       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}  //128x128
    1016   };
    1017 #endif
    1018 
     666/** Get pointer to reference samples for intra prediction
     667 * \param uiDirMode   prediction mode index
     668 * \param log2BlkSize size of block (2 = 4x4, 3 = 8x8, 4 = 16x16, 5 = 32x32, 6 = 64x64)
     669 * \param piAdiBuf    pointer to unfiltered reference samples
     670 * \return            pointer to (possibly filtered) reference samples
     671 *
     672 * The prediction mode index is used to determine whether a smoothed reference sample buffer is returned.
     673 */
     674Int* TComPattern::getPredictorPtr( UInt uiDirMode, UInt log2BlkSize, Int* piAdiBuf )
     675{
    1019676  Int* piSrc;
    1020 #if ADD_PLANAR_MODE
    1021   mapPlanartoDC( uiDirMode );
    1022 #endif
     677  assert(log2BlkSize >= 2 && log2BlkSize < 7);
    1023678#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    1024   UChar ucFiltIdx = 0;
    1025   if ( uiDirMode < 34 )
    1026   {
    1027     ucFiltIdx = g_aucIntraFilter[uiWidthBits][uiDirMode];
    1028   }
    1029 #else
    1030   UChar ucFiltIdx = g_aucIntraFilter[uiWidthBits][uiDirMode];
    1031 #endif
    1032 
    1033 #if MN_MDIS_SIMPLIFICATION
     679  mapDMMtoIntraMode( uiDirMode );
     680#endif
     681#if LOGI_INTRA_NAME_3MPM
     682  Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
     683  UChar ucFiltIdx = diff > m_aucIntraFilter[log2BlkSize - 2] ? 1 : 0;
     684  if (uiDirMode == DC_IDX || uiDirMode == LM_CHROMA_IDX)
     685  {
     686    ucFiltIdx = 0; //no smoothing for DC or LM chroma
     687  }
     688#else
     689  UChar ucFiltIdx = m_aucIntraFilter[log2BlkSize - 2][uiDirMode];
     690#endif
     691
    1034692  assert( ucFiltIdx <= 1 );
    1035 #else
    1036   assert( ucFiltIdx <= 2 );
    1037 #endif
    1038 
    1039   piSrc = getAdiOrgBuf( iCuWidth, iCuHeight, piAdiBuf );
     693
     694  Int width  = 1 << log2BlkSize;
     695  Int height = 1 << log2BlkSize;
     696 
     697  piSrc = getAdiOrgBuf( width, height, piAdiBuf );
    1040698
    1041699  if ( ucFiltIdx )
    1042700  {
    1043 #if MN_MDIS_SIMPLIFICATION
    1044     piSrc += ((iCuWidth << 1) + 1) * ((iCuHeight << 1) + 1);
    1045 #else
    1046     piSrc += (((iCuWidth << 1) + 1) * ((iCuHeight << 1) + 1) << (ucFiltIdx - 1));
    1047 #endif
     701    piSrc += (2 * width + 1) * (2 * height + 1);
    1048702  }
    1049703
    1050704  return piSrc;
    1051705}
    1052 #endif //QC_MDIS
    1053 
    1054 #if CONSTRAINED_INTRA_PRED
    1055 Bool TComPattern::isAboveLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT )
     706
     707Bool TComPattern::isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
    1056708{
    1057709  Bool bAboveLeftFlag;
    1058710  UInt uiPartAboveLeft;
    1059711  TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT, true, false );
    1060   bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->getPredictionMode( uiPartAboveLeft ) == MODE_INTRA );
     712  if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     713  {
     714    bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->getPredictionMode( uiPartAboveLeft ) == MODE_INTRA );
     715  }
     716  else
     717  {
     718    bAboveLeftFlag = (pcCUAboveLeft ? true : false);
     719  }
    1061720  return bAboveLeftFlag;
    1062721}
    1063722
    1064 #if REFERENCE_SAMPLE_PADDING
    1065 Int TComPattern::isAboveAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    1066 #else
    1067 Bool TComPattern::isAboveAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT )
    1068 #endif
     723Int TComPattern::isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    1069724{
    1070725  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
    1071726  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1;
    1072727  const UInt uiIdxStep = 1;
    1073 #if REFERENCE_SAMPLE_PADDING
    1074728  Bool *pbValidFlags = bValidFlags;
    1075729  Int iNumIntra = 0;
    1076 #else
    1077   Bool bAboveFlag = true;
    1078 #endif
    1079 #if MN_DC_PRED_FILTER
    1080   m_bAboveFlagForDCFilt = true;
    1081 #endif
    1082730
    1083731  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
     
    1085733    UInt uiPartAbove;
    1086734    TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart], true, false );
    1087 #if REFERENCE_SAMPLE_PADDING
    1088     if ( pcCUAbove && pcCUAbove->getPredictionMode( uiPartAbove ) == MODE_INTRA )
    1089     {
    1090       iNumIntra++;
    1091       *pbValidFlags = true;
     735    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     736    {
     737      if ( pcCUAbove && pcCUAbove->getPredictionMode( uiPartAbove ) == MODE_INTRA )
     738      {
     739        iNumIntra++;
     740        *pbValidFlags = true;
     741      }
     742      else
     743      {
     744        *pbValidFlags = false;
     745      }
    1092746    }
    1093747    else
    1094748    {
    1095       *pbValidFlags = false;
    1096 #if MN_DC_PRED_FILTER
    1097       m_bAboveFlagForDCFilt = false;
    1098 #endif
     749      if (pcCUAbove)
     750      {
     751        iNumIntra++;
     752        *pbValidFlags = true;
     753      }
     754      else
     755      {
     756        *pbValidFlags = false;
     757      }
    1099758    }
    1100759    pbValidFlags++;
    1101 #else
    1102     if ( !pcCUAbove || pcCUAbove->getPredictionMode( uiPartAbove ) != MODE_INTRA )
    1103     {
    1104       bAboveFlag = false;
    1105 #if MN_DC_PRED_FILTER
    1106       m_bAboveFlagForDCFilt = false;
    1107 #endif
    1108       break;
    1109     }
    1110 #endif
    1111   }
    1112 #if REFERENCE_SAMPLE_PADDING
     760  }
    1113761  return iNumIntra;
    1114 #else
    1115   return bAboveFlag;
    1116 #endif
    1117 }
    1118 
    1119 #if REFERENCE_SAMPLE_PADDING
    1120 Int TComPattern::isLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    1121 #else
    1122 Bool TComPattern::isLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB )
    1123 #endif
     762}
     763
     764Int TComPattern::isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    1124765{
    1125766  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
    1126767  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
    1127768  const UInt uiIdxStep = pcCU->getPic()->getNumPartInWidth();
    1128 #if REFERENCE_SAMPLE_PADDING
    1129769  Bool *pbValidFlags = bValidFlags;
    1130770  Int iNumIntra = 0;
    1131 #else
    1132   Bool bLeftFlag = true;
    1133 #endif
    1134 #if MN_DC_PRED_FILTER
    1135   m_bLeftFlagForDCFilt = true;
    1136 #endif
    1137771
    1138772  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
     
    1140774    UInt uiPartLeft;
    1141775    TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart], true, false );
    1142 #if REFERENCE_SAMPLE_PADDING
    1143     if ( pcCULeft && pcCULeft->getPredictionMode( uiPartLeft ) == MODE_INTRA )
    1144     {
    1145       iNumIntra++;
    1146       *pbValidFlags = true;
     776    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     777    {
     778      if ( pcCULeft && pcCULeft->getPredictionMode( uiPartLeft ) == MODE_INTRA )
     779      {
     780        iNumIntra++;
     781        *pbValidFlags = true;
     782      }
     783      else
     784      {
     785        *pbValidFlags = false;
     786      }
    1147787    }
    1148788    else
    1149789    {
    1150       *pbValidFlags = false;
    1151 #if MN_DC_PRED_FILTER
    1152       m_bLeftFlagForDCFilt = false;
    1153 #endif
     790      if ( pcCULeft )
     791      {
     792        iNumIntra++;
     793        *pbValidFlags = true;
     794      }
     795      else
     796      {
     797        *pbValidFlags = false;
     798      }
    1154799    }
    1155800    pbValidFlags--; // opposite direction
    1156 #else
    1157     if ( !pcCULeft || pcCULeft->getPredictionMode( uiPartLeft ) != MODE_INTRA )
    1158     {
    1159       bLeftFlag = false;
    1160 #if MN_DC_PRED_FILTER
    1161       m_bLeftFlagForDCFilt = false;
    1162 #endif
    1163       break;
    1164     }
    1165 #endif
    1166   }
    1167 
    1168 #if REFERENCE_SAMPLE_PADDING
     801  }
     802
    1169803  return iNumIntra;
    1170 #else
    1171   return bLeftFlag;
    1172 #endif
    1173 }
    1174 
    1175 #if REFERENCE_SAMPLE_PADDING
    1176 Int TComPattern::isAboveRightAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    1177 #else
    1178 Bool TComPattern::isAboveRightAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT )
    1179 #endif
     804}
     805
     806Int TComPattern::isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    1180807{
    1181808  const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
    1182809  const UInt uiPuWidth = uiNumUnitsInPU * pcCU->getPic()->getMinCUWidth();
    1183 #if REFERENCE_SAMPLE_PADDING
    1184810  Bool *pbValidFlags = bValidFlags;
    1185811  Int iNumIntra = 0;
    1186 #else
    1187   Bool bAboveRightFlag = true;
    1188 #endif
    1189812
    1190813  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
     
    1192815    UInt uiPartAboveRight;
    1193816    TComDataCU* pcCUAboveRight = pcCU->getPUAboveRightAdi( uiPartAboveRight, uiPuWidth, uiPartIdxRT, uiOffset, true, false );
    1194 #if REFERENCE_SAMPLE_PADDING
    1195     if ( pcCUAboveRight && pcCUAboveRight->getPredictionMode( uiPartAboveRight ) == MODE_INTRA )
    1196     {
    1197       iNumIntra++;
    1198       *pbValidFlags = true;
     817    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     818    {
     819      if ( pcCUAboveRight && pcCUAboveRight->getPredictionMode( uiPartAboveRight ) == MODE_INTRA )
     820      {
     821        iNumIntra++;
     822        *pbValidFlags = true;
     823      }
     824      else
     825      {
     826        *pbValidFlags = false;
     827      }
    1199828    }
    1200829    else
    1201830    {
    1202       *pbValidFlags = false;
     831      if ( pcCUAboveRight )
     832      {
     833        iNumIntra++;
     834        *pbValidFlags = true;
     835      }
     836      else
     837      {
     838        *pbValidFlags = false;
     839      }
    1203840    }
    1204841    pbValidFlags++;
    1205 #else
    1206     if ( !pcCUAboveRight || pcCUAboveRight->getPredictionMode( uiPartAboveRight ) != MODE_INTRA )
    1207     {
    1208       bAboveRightFlag = false;
    1209       break;
    1210     }
    1211 #endif
    1212   }
    1213 
    1214 #if REFERENCE_SAMPLE_PADDING
     842  }
     843
    1215844  return iNumIntra;
    1216 #else
    1217   return bAboveRightFlag;
    1218 #endif
    1219 }
    1220 
    1221 #if REFERENCE_SAMPLE_PADDING
    1222 Int TComPattern::isBelowLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    1223 #else
    1224 Bool TComPattern::isBelowLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB )
    1225 #endif
     845}
     846
     847Int TComPattern::isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    1226848{
    1227849  const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInWidth() + 1;
    1228850  const UInt uiPuHeight = uiNumUnitsInPU * pcCU->getPic()->getMinCUHeight();
    1229 #if REFERENCE_SAMPLE_PADDING
    1230851  Bool *pbValidFlags = bValidFlags;
    1231852  Int iNumIntra = 0;
    1232 #else
    1233   Bool bBelowLeftFlag = true;
    1234 #endif
    1235853
    1236854  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
     
    1238856    UInt uiPartBelowLeft;
    1239857    TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeftAdi( uiPartBelowLeft, uiPuHeight, uiPartIdxLB, uiOffset, true, false );
    1240 #if REFERENCE_SAMPLE_PADDING
    1241     if ( pcCUBelowLeft && pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) == MODE_INTRA )
    1242     {
    1243       iNumIntra++;
    1244       *pbValidFlags = true;
     858    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     859    {
     860      if ( pcCUBelowLeft && pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) == MODE_INTRA )
     861      {
     862        iNumIntra++;
     863        *pbValidFlags = true;
     864      }
     865      else
     866      {
     867        *pbValidFlags = false;
     868      }
    1245869    }
    1246870    else
    1247871    {
    1248       *pbValidFlags = false;
     872      if ( pcCUBelowLeft )
     873      {
     874        iNumIntra++;
     875        *pbValidFlags = true;
     876      }
     877      else
     878      {
     879        *pbValidFlags = false;
     880      }
    1249881    }
    1250882    pbValidFlags--; // opposite direction
    1251 #else
    1252     if ( !pcCUBelowLeft || pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) != MODE_INTRA )
    1253     {
    1254       bBelowLeftFlag = false;
    1255       break;
    1256     }
    1257 #endif
    1258   }
    1259 
    1260 #if REFERENCE_SAMPLE_PADDING
     883  }
     884
    1261885  return iNumIntra;
    1262 #else
    1263   return bBelowLeftFlag;
    1264 #endif
    1265 }
    1266 #endif //CONSTRAINED_INTRA_PRED
     886}
     887//! \}
Note: See TracChangeset for help on using the changeset viewer.