Ignore:
Timestamp:
26 Feb 2015, 00:21:54 (10 years ago)
Author:
seregin
Message:

merge with SHM-upgrade branch

Location:
branches/SHM-dev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev

  • branches/SHM-dev/source

  • branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp

    r595 r1029  
    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 *
    66 * Copyright (c) 2010-2014, ITU/ISO/IEC
     
    3939#include "TComPattern.h"
    4040#include "TComDataCU.h"
     41#include "TComTU.h"
     42#include "Debug.h"
     43#include "TComPrediction.h"
    4144
    4245//! \ingroup TLibCommon
    4346//! \{
    4447
    45 // ====================================================================================================================
    46 // Tables
    47 // ====================================================================================================================
    48 
    49 const UChar TComPattern::m_aucIntraFilter[5] =
    50 {
    51   10, //4x4
    52   7, //8x8
    53   1, //16x16
    54   0, //32x32
    55   10, //64x64
    56 };
     48// Forward declarations
     49
     50/// padding of unavailable reference samples for intra prediction
     51#if O0043_BEST_EFFORT_DECODING
     52Void fillReferenceSamples( const Int bitDepth, const Int bitDepthDelta, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
     53#else
     54Void fillReferenceSamples( const Int bitDepth, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
     55#endif
     56                           const Int iNumIntraNeighbor, const Int unitWidth, const Int unitHeight, const Int iAboveUnits, const Int iLeftUnits,
     57                           const UInt uiCuWidth, const UInt uiCuHeight, const UInt uiWidth, const UInt uiHeight, const Int iPicStride,
     58                           const ChannelType chType, const ChromaFormat chFmt );
     59
     60/// constrained intra prediction
     61Bool  isAboveLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT );
     62Int   isAboveAvailable      ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
     63Int   isLeftAvailable       ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
     64Int   isAboveRightAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
     65Int   isBelowLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
     66
    5767
    5868// ====================================================================================================================
     
    6575 \param  iStride       buffer stride
    6676 \param  iOffsetLeft   neighbour offset (left)
     77 \param  iOffsetRight  neighbour offset (right)
    6778 \param  iOffsetAbove  neighbour offset (above)
     79 \param  iOffsetBottom neighbour offset (bottom)
    6880 */
    6981Void TComPatternParam::setPatternParamPel ( Pel* piTexture,
    7082                                           Int iRoiWidth,
    7183                                           Int iRoiHeight,
    72                                            Int iStride,
    73                                            Int iOffsetLeft,
    74                                            Int iOffsetAbove )
    75 {
    76   m_piPatternOrigin = piTexture;
     84                                           Int iStride
     85                                           )
     86{
     87  m_piROIOrigin    = piTexture;
    7788  m_iROIWidth       = iRoiWidth;
    7889  m_iROIHeight      = iRoiHeight;
    7990  m_iPatternStride  = iStride;
    80   m_iOffsetLeft     = iOffsetLeft;
    81   m_iOffsetAbove    = iOffsetAbove;
    82 }
    83 
    84 /**
    85  \param  pcCU          CU data structure
    86  \param  iComp         component index (0=Y, 1=Cb, 2=Cr)
    87  \param  iRoiWidth     pattern width
    88  \param  iRoiHeight    pattern height
    89  \param  iStride       buffer stride
    90  \param  iOffsetLeft   neighbour offset (left)
    91  \param  iOffsetAbove  neighbour offset (above)
    92  \param  uiAbsPartIdx  part index
    93  */
    94 Void TComPatternParam::setPatternParamCU( TComDataCU* pcCU,
    95                                          UChar       iComp,
    96                                          UChar       iRoiWidth,
    97                                          UChar       iRoiHeight,
    98                                          Int         iOffsetLeft,
    99                                          Int         iOffsetAbove,
    100                                          UInt        uiAbsPartIdx )
    101 {
    102   m_iOffsetLeft   = iOffsetLeft;
    103   m_iOffsetAbove  = iOffsetAbove;
    104  
    105   m_iROIWidth     = iRoiWidth;
    106   m_iROIHeight    = iRoiHeight;
    107  
    108   UInt uiAbsZorderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    109  
    110   if ( iComp == 0 )
    111   {
    112     m_iPatternStride  = pcCU->getPic()->getStride();
    113     m_piPatternOrigin = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
    114   }
    115   else
    116   {
    117     m_iPatternStride = pcCU->getPic()->getCStride();
    118     if ( iComp == 1 )
    119     {
    120       m_piPatternOrigin = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
    121     }
    122     else
    123     {
    124       m_piPatternOrigin = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft;
    125     }
    126   }
    12791}
    12892
     
    13195// ====================================================================================================================
    13296
    133 Void TComPattern::initPattern ( Pel* piY,
    134                                Pel* piCb,
    135                                Pel* piCr,
     97Void TComPattern::initPattern (Pel* piY,
    13698                               Int iRoiWidth,
    13799                               Int iRoiHeight,
    138                                Int iStride,
    139                                Int iOffsetLeft,
    140                                Int iOffsetAbove )
    141 {
    142   m_cPatternY. setPatternParamPel( piY,  iRoiWidth,      iRoiHeight,      iStride,      iOffsetLeft,      iOffsetAbove      );
    143   m_cPatternCb.setPatternParamPel( piCb, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetAbove >> 1 );
    144   m_cPatternCr.setPatternParamPel( piCr, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetAbove >> 1 );
    145  
    146   return;
    147 }
    148 
    149 Void TComPattern::initPattern( TComDataCU* pcCU, UInt uiPartDepth, UInt uiAbsPartIdx )
    150 {
    151   Int   uiOffsetLeft  = 0;
    152   Int   uiOffsetAbove = 0;
    153  
    154   UChar uiWidth          = pcCU->getWidth (0)>>uiPartDepth;
    155   UChar uiHeight         = pcCU->getHeight(0)>>uiPartDepth;
    156  
    157   UInt  uiAbsZorderIdx   = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
    158   UInt  uiCurrPicPelX    = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ];
    159   UInt  uiCurrPicPelY    = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ];
    160  
    161   if( uiCurrPicPelX != 0 )
    162   {
    163     uiOffsetLeft = 1;
    164   }
    165  
    166   if( uiCurrPicPelY != 0 )
    167   {
    168     uiOffsetAbove = 1;
    169   }
    170  
    171   m_cPatternY .setPatternParamCU( pcCU, 0, uiWidth,      uiHeight,      uiOffsetLeft, uiOffsetAbove, uiAbsPartIdx );
    172   m_cPatternCb.setPatternParamCU( pcCU, 1, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetAbove, uiAbsPartIdx );
    173   m_cPatternCr.setPatternParamCU( pcCU, 2, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetAbove, uiAbsPartIdx );
    174 }
    175 
    176 Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft, Bool bLMmode )
    177 {
    178   Pel*  piRoiOrigin;
    179   Int*  piAdiTemp;
    180   UInt  uiCuWidth   = pcCU->getWidth(0) >> uiPartDepth;
    181   UInt  uiCuHeight  = pcCU->getHeight(0)>> uiPartDepth;
    182   UInt  uiCuWidth2  = uiCuWidth<<1;
    183   UInt  uiCuHeight2 = uiCuHeight<<1;
    184   UInt  uiWidth;
    185   UInt  uiHeight;
    186   Int   iPicStride = pcCU->getPic()->getStride();
    187   Int   iUnitSize = 0;
    188   Int   iNumUnitsInCu = 0;
    189   Int   iTotalUnits = 0;
     100                               Int iStride)
     101{
     102  m_cPatternY. setPatternParamPel( piY,  iRoiWidth, iRoiHeight, iStride);
     103}
     104
     105
     106// TODO: move this function to TComPrediction.cpp.
     107Void TComPrediction::initAdiPatternChType( TComTU &rTu, Bool& bAbove, Bool& bLeft, const ComponentID compID, const Bool bFilterRefSamples DEBUG_STRING_FN_DECLARE(sDebug))
     108{
     109  const ChannelType chType    = toChannelType(compID);
     110
     111  TComDataCU *pcCU=rTu.getCU();
     112  const UInt uiZorderIdxInPart=rTu.GetAbsPartIdxTU();
     113  const UInt uiTuWidth        = rTu.getRect(compID).width;
     114  const UInt uiTuHeight       = rTu.getRect(compID).height;
     115  const UInt uiTuWidth2       = uiTuWidth  << 1;
     116  const UInt uiTuHeight2      = uiTuHeight << 1;
     117
     118  const Int  iBaseUnitSize    = g_uiMaxCUWidth >> g_uiMaxCUDepth;
     119  const Int  iUnitWidth       = iBaseUnitSize  >> pcCU->getPic()->getPicYuvRec()->getComponentScaleX(compID);
     120  const Int  iUnitHeight      = iBaseUnitSize  >> pcCU->getPic()->getPicYuvRec()->getComponentScaleY(compID);
     121  const Int  iTUWidthInUnits  = uiTuWidth  / iUnitWidth;
     122  const Int  iTUHeightInUnits = uiTuHeight / iUnitHeight;
     123  const Int  iAboveUnits      = iTUWidthInUnits  << 1;
     124  const Int  iLeftUnits       = iTUHeightInUnits << 1;
     125
     126  assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
     127
     128  const Int  iPartIdxStride   = pcCU->getPic()->getNumPartInCtuWidth();
     129  const UInt uiPartIdxLT      = pcCU->getZorderIdxInCtu() + uiZorderIdxInPart;
     130  const UInt uiPartIdxRT      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] +   iTUWidthInUnits  - 1                   ];
     131  const UInt uiPartIdxLB      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + ((iTUHeightInUnits - 1) * iPartIdxStride)];
     132
     133  Int   iPicStride = pcCU->getPic()->getStride(compID);
    190134  Bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
    191135  Int   iNumIntraNeighbor = 0;
    192  
    193   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    194 
    195  
    196   pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth );
    197   pcCU->deriveLeftBottomIdxAdi  ( uiPartIdxLB,              uiZorderIdxInPart, uiPartDepth );
    198  
    199   iUnitSize      = g_uiMaxCUWidth >> g_uiMaxCUDepth;
    200   iNumUnitsInCu  = uiCuWidth / iUnitSize;
    201   iTotalUnits    = (iNumUnitsInCu << 2) + 1;
    202 
    203   bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
    204   iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
    205   iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
    206   iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
    207   iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
    208   iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
    209  
     136
     137  bNeighborFlags[iLeftUnits] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
     138  iNumIntraNeighbor += bNeighborFlags[iLeftUnits] ? 1 : 0;
     139  iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1)                    );
     140  iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1 + iTUWidthInUnits ) );
     141  iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1)                    );
     142  iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1 - iTUHeightInUnits) );
     143
    210144  bAbove = true;
    211145  bLeft  = true;
    212146
    213   uiWidth=uiCuWidth2+1;
    214   uiHeight=uiCuHeight2+1;
    215  
    216   if (((uiWidth<<2)>iOrgBufStride)||((uiHeight<<2)>iOrgBufHeight))
    217   {
    218     return;
    219   }
    220  
    221   piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart);
    222   piAdiTemp   = piAdiBuf;
    223 
    224   fillReferenceSamples (g_bitDepthY, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bLMmode);
    225  
    226   Int   i;
    227   // generate filtered intra prediction samples
    228   Int iBufSize = uiCuHeight2 + uiCuWidth2 + 1;  // left and left above border + above and above right border + top left corner = length of 3. filter buffer
    229 
    230   UInt uiWH = uiWidth * uiHeight;               // number of elements in one buffer
    231 
    232   Int* piFilteredBuf1 = piAdiBuf + uiWH;        // 1. filter buffer
    233   Int* piFilteredBuf2 = piFilteredBuf1 + uiWH;  // 2. filter buffer
    234   Int* piFilterBuf = piFilteredBuf2 + uiWH;     // buffer for 2. filtering (sequential)
    235   Int* piFilterBufN = piFilterBuf + iBufSize;   // buffer for 1. filtering (sequential)
    236 
    237   Int l = 0;
    238   // left border from bottom to top
    239   for (i = 0; i < uiCuHeight2; i++)
    240   {
    241     piFilterBuf[l++] = piAdiTemp[uiWidth * (uiCuHeight2 - i)];
    242   }
    243   // top left corner
    244   piFilterBuf[l++] = piAdiTemp[0];
    245   // above border from left to right
    246   for (i=0; i < uiCuWidth2; i++)
    247   {
    248     piFilterBuf[l++] = piAdiTemp[1 + i];
    249   }
    250 
    251   if (pcCU->getSlice()->getSPS()->getUseStrongIntraSmoothing())
    252   {
    253     Int blkSize = 32;
    254     Int bottomLeft = piFilterBuf[0];
    255     Int topLeft = piFilterBuf[uiCuHeight2];
    256     Int topRight = piFilterBuf[iBufSize-1];
    257     Int threshold = 1 << (g_bitDepthY - 5);
    258     Bool bilinearLeft = abs(bottomLeft+topLeft-2*piFilterBuf[uiCuHeight]) < threshold;
    259     Bool bilinearAbove  = abs(topLeft+topRight-2*piFilterBuf[uiCuHeight2+uiCuHeight]) < threshold;
    260  
    261     if (uiCuWidth>=blkSize && (bilinearLeft && bilinearAbove))
    262     {
    263       Int shift = g_aucConvertToBit[uiCuWidth] + 3;  // log2(uiCuHeight2)
    264       piFilterBufN[0] = piFilterBuf[0];
    265       piFilterBufN[uiCuHeight2] = piFilterBuf[uiCuHeight2];
    266       piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1];
    267       for (i = 1; i < uiCuHeight2; i++)
    268       {
    269         piFilterBufN[i] = ((uiCuHeight2-i)*bottomLeft + i*topLeft + uiCuHeight) >> shift;
    270       }
    271  
    272       for (i = 1; i < uiCuWidth2; i++)
    273       {
    274         piFilterBufN[uiCuHeight2 + i] = ((uiCuWidth2-i)*topLeft + i*topRight + uiCuWidth) >> shift;
    275       }
    276     }
    277     else
    278     {
    279       // 1. filtering with [1 2 1]
    280       piFilterBufN[0] = piFilterBuf[0];
    281       piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1];
    282       for (i = 1; i < iBufSize - 1; i++)
    283       {
    284         piFilterBufN[i] = (piFilterBuf[i - 1] + 2 * piFilterBuf[i]+piFilterBuf[i + 1] + 2) >> 2;
    285       }
    286     }
    287   }
    288   else
    289   {
    290     // 1. filtering with [1 2 1]
    291     piFilterBufN[0] = piFilterBuf[0];
    292     piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1];
    293     for (i = 1; i < iBufSize - 1; i++)
    294     {
    295       piFilterBufN[i] = (piFilterBuf[i - 1] + 2 * piFilterBuf[i]+piFilterBuf[i + 1] + 2) >> 2;
    296     }
    297   }
    298 
    299   // fill 1. filter buffer with filtered values
    300   l=0;
    301   for (i = 0; i < uiCuHeight2; i++)
    302   {
    303     piFilteredBuf1[uiWidth * (uiCuHeight2 - i)] = piFilterBufN[l++];
    304   }
    305   piFilteredBuf1[0] = piFilterBufN[l++];
    306   for (i = 0; i < uiCuWidth2; i++)
    307   {
    308     piFilteredBuf1[1 + i] = piFilterBufN[l++];
    309   }
    310 }
    311 
    312 Void TComPattern::initAdiPatternChroma( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft )
    313 {
    314   Pel*  piRoiOrigin;
    315   Int*  piAdiTemp;
    316   UInt  uiCuWidth  = pcCU->getWidth (0) >> uiPartDepth;
    317   UInt  uiCuHeight = pcCU->getHeight(0) >> uiPartDepth;
    318   UInt  uiWidth;
    319   UInt  uiHeight;
    320   Int   iPicStride = pcCU->getPic()->getCStride();
    321 
    322   Int   iUnitSize = 0;
    323   Int   iNumUnitsInCu = 0;
    324   Int   iTotalUnits = 0;
    325   Bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
    326   Int   iNumIntraNeighbor = 0;
    327  
    328   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
    329  
    330   pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth );
    331   pcCU->deriveLeftBottomIdxAdi  ( uiPartIdxLB,              uiZorderIdxInPart, uiPartDepth );
    332  
    333   iUnitSize      = (g_uiMaxCUWidth >> g_uiMaxCUDepth) >> 1; // for chroma
    334   iNumUnitsInCu  = (uiCuWidth / iUnitSize) >> 1;            // for chroma
    335   iTotalUnits    = (iNumUnitsInCu << 2) + 1;
    336 
    337   bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
    338   iNumIntraNeighbor  += (Int)(bNeighborFlags[iNumUnitsInCu*2]);
    339   iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 );
    340   iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 );
    341   iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 );
    342   iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu   -1 );
    343  
    344   bAbove = true;
    345   bLeft  = true;
    346  
    347   uiCuWidth=uiCuWidth>>1;  // for chroma
    348   uiCuHeight=uiCuHeight>>1;  // for chroma
    349  
    350   uiWidth=uiCuWidth*2+1;
    351   uiHeight=uiCuHeight*2+1;
    352  
    353   if ((4*uiWidth>iOrgBufStride)||(4*uiHeight>iOrgBufHeight))
    354   {
    355     return;
    356   }
    357  
    358   // get Cb pattern
    359   piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart);
    360   piAdiTemp   = piAdiBuf;
    361 
    362   fillReferenceSamples (g_bitDepthC, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride);
    363  
    364   // get Cr pattern
    365   piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart);
    366   piAdiTemp   = piAdiBuf+uiWidth*uiHeight;
    367  
    368   fillReferenceSamples (g_bitDepthC, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride);
    369 }
    370 
    371 Void TComPattern::fillReferenceSamples(Int bitDepth, 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 )
    372 {
    373   Pel* piRoiTemp;
     147  const ChromaFormat chFmt       = rTu.GetChromaFormat();
     148  const UInt         uiROIWidth  = uiTuWidth2+1;
     149  const UInt         uiROIHeight = uiTuHeight2+1;
     150
     151  assert(uiROIWidth*uiROIHeight <= m_iYuvExtSize);
     152
     153#ifdef DEBUG_STRING
     154  std::stringstream ss(stringstream::out);
     155#endif
     156
     157  {
     158    Pel *piAdiTemp   = m_piYuvExt[compID][PRED_BUF_UNFILTERED];
     159    Pel *piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiZorderIdxInPart);
     160#if O0043_BEST_EFFORT_DECODING
     161    fillReferenceSamples (g_bitDepthInStream[chType], g_bitDepthInStream[chType] - g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
     162#else
     163    fillReferenceSamples (g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
     164#endif
     165                          uiTuWidth, uiTuHeight, uiROIWidth, uiROIHeight, iPicStride, toChannelType(compID), chFmt);
     166
     167
     168#ifdef DEBUG_STRING
     169    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
     170    {
     171      ss << "###: generating Ref Samples for channel " << compID << " and " << rTu.getRect(compID).width << " x " << rTu.getRect(compID).height << "\n";
     172      for (UInt y=0; y<uiROIHeight; y++)
     173      {
     174        ss << "###: - ";
     175        for (UInt x=0; x<uiROIWidth; x++)
     176        {
     177          if (x==0 || y==0)
     178            ss << piAdiTemp[y*uiROIWidth + x] << ", ";
     179//          if (x%16==15) ss << "\nPart size: ~ ";
     180        }
     181        ss << "\n";
     182      }
     183    }
     184#endif
     185
     186    if (bFilterRefSamples)
     187    {
     188      // generate filtered intra prediction samples
     189
     190            Int          stride    = uiROIWidth;
     191      const Pel         *piSrcPtr  = piAdiTemp                             + (stride * uiTuHeight2); // bottom left
     192            Pel         *piDestPtr = m_piYuvExt[compID][PRED_BUF_FILTERED] + (stride * uiTuHeight2); // bottom left
     193
     194      //------------------------------------------------
     195
     196      Bool useStrongIntraSmoothing = isLuma(chType) && pcCU->getSlice()->getSPS()->getUseStrongIntraSmoothing();
     197
     198      const Pel bottomLeft = piAdiTemp[stride * uiTuHeight2];
     199      const Pel topLeft    = piAdiTemp[0];
     200      const Pel topRight   = piAdiTemp[uiTuWidth2];
     201
     202      if (useStrongIntraSmoothing)
     203      {
     204#if O0043_BEST_EFFORT_DECODING
     205        const Int  threshold     = 1 << (g_bitDepthInStream[chType] - 5);
     206#else
     207        const Int  threshold     = 1 << (g_bitDepth[chType] - 5);
     208#endif
     209        const Bool bilinearLeft  = abs((bottomLeft + topLeft ) - (2 * piAdiTemp[stride * uiTuHeight])) < threshold; //difference between the
     210        const Bool bilinearAbove = abs((topLeft    + topRight) - (2 * piAdiTemp[         uiTuWidth ])) < threshold; //ends and the middle
     211        if ((uiTuWidth < 32) || (!bilinearLeft) || (!bilinearAbove))
     212          useStrongIntraSmoothing = false;
     213      }
     214
     215      *piDestPtr = *piSrcPtr; // bottom left is not filtered
     216      piDestPtr -= stride;
     217      piSrcPtr  -= stride;
     218
     219      //------------------------------------------------
     220
     221      //left column (bottom to top)
     222
     223      if (useStrongIntraSmoothing)
     224      {
     225        const Int shift = g_aucConvertToBit[uiTuHeight] + 3; //log2(uiTuHeight2)
     226
     227        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride)
     228        {
     229          *piDestPtr = (((uiTuHeight2 - i) * bottomLeft) + (i * topLeft) + uiTuHeight) >> shift;
     230        }
     231
     232        piSrcPtr -= stride * (uiTuHeight2 - 1);
     233      }
     234      else
     235      {
     236        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride, piSrcPtr-=stride)
     237        {
     238          *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[-stride] + 2 ) >> 2;
     239        }
     240      }
     241
     242      //------------------------------------------------
     243
     244      //top-left
     245
     246      if (useStrongIntraSmoothing)
     247      {
     248        *piDestPtr = piSrcPtr[0];
     249      }
     250      else
     251      {
     252        *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[1] + 2 ) >> 2;
     253      }
     254      piDestPtr += 1;
     255      piSrcPtr  += 1;
     256
     257      //------------------------------------------------
     258
     259      //top row (left-to-right)
     260
     261      if (useStrongIntraSmoothing)
     262      {
     263        const Int shift = g_aucConvertToBit[uiTuWidth] + 3; //log2(uiTuWidth2)
     264
     265        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++)
     266        {
     267          *piDestPtr = (((uiTuWidth2 - i) * topLeft) + (i * topRight) + uiTuWidth) >> shift;
     268        }
     269
     270        piSrcPtr += uiTuWidth2 - 1;
     271      }
     272      else
     273      {
     274        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++, piSrcPtr++)
     275        {
     276          *piDestPtr = ( piSrcPtr[1] + 2*piSrcPtr[0] + piSrcPtr[-1] + 2 ) >> 2;
     277        }
     278      }
     279
     280      //------------------------------------------------
     281
     282      *piDestPtr=*piSrcPtr; // far right is not filtered
     283
     284#ifdef DEBUG_STRING
     285    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
     286    {
     287      ss << "###: filtered result for channel " << compID <<"\n";
     288      for (UInt y=0; y<uiROIHeight; y++)
     289      {
     290        ss << "###: - ";
     291        for (UInt x=0; x<uiROIWidth; x++)
     292        {
     293          if (x==0 || y==0)
     294            ss << m_piYuvExt[compID][PRED_BUF_FILTERED][y*uiROIWidth + x] << ", ";
     295//          if (x%16==15) ss << "\nPart size: ~ ";
     296        }
     297        ss << "\n";
     298      }
     299    }
     300#endif
     301
     302
     303    }
     304  }
     305  DEBUG_STRING_APPEND(sDebug, ss.str())
     306}
     307
     308#if O0043_BEST_EFFORT_DECODING
     309Void fillReferenceSamples( const Int bitDepth, const Int bitDepthDelta, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
     310#else
     311Void fillReferenceSamples( const Int bitDepth, TComDataCU* pcCU, const Pel* piRoiOrigin, Pel* piAdiTemp, const Bool* bNeighborFlags,
     312#endif
     313                           const Int iNumIntraNeighbor, const Int unitWidth, const Int unitHeight, const Int iAboveUnits, const Int iLeftUnits,
     314                           const UInt uiCuWidth, const UInt uiCuHeight, const UInt uiWidth, const UInt uiHeight, const Int iPicStride,
     315                           const ChannelType chType, const ChromaFormat chFmt )
     316{
     317  const Pel* piRoiTemp;
    374318  Int  i, j;
    375319  Int  iDCValue = 1 << (bitDepth - 1);
     320  const Int iTotalUnits = iAboveUnits + iLeftUnits + 1; //+1 for top-left
    376321
    377322  if (iNumIntraNeighbor == 0)
     
    389334  else if (iNumIntraNeighbor == iTotalUnits)
    390335  {
    391     // Fill top-left border with rec. samples
     336    // Fill top-left border and top and top right with rec. samples
    392337    piRoiTemp = piRoiOrigin - iPicStride - 1;
    393     piAdiTemp[0] = piRoiTemp[0];
    394 
    395     // Fill left border with rec. samples
     338
     339    for (i=0; i<uiWidth; i++)
     340    {
     341#if O0043_BEST_EFFORT_DECODING
     342      piAdiTemp[i] = piRoiTemp[i] << bitDepthDelta;
     343#else
     344      piAdiTemp[i] = piRoiTemp[i];
     345#endif
     346    }
     347
     348    // Fill left and below left border with rec. samples
    396349    piRoiTemp = piRoiOrigin - 1;
    397350
    398     if (bLMmode)
    399     {
    400       piRoiTemp --; // move to the second left column
    401     }
    402 
    403     for (i=0; i<uiCuHeight; i++)
    404     {
    405       piAdiTemp[(1+i)*uiWidth] = piRoiTemp[0];
     351    for (i=1; i<uiHeight; i++)
     352    {
     353#if O0043_BEST_EFFORT_DECODING
     354      piAdiTemp[i*uiWidth] = (*(piRoiTemp)) << bitDepthDelta;
     355#else
     356      piAdiTemp[i*uiWidth] = *(piRoiTemp);
     357#endif
    406358      piRoiTemp += iPicStride;
    407359    }
    408 
    409     // Fill below left border with rec. samples
    410     for (i=0; i<uiCuHeight; i++)
    411     {
    412       piAdiTemp[(1+uiCuHeight+i)*uiWidth] = piRoiTemp[0];
    413       piRoiTemp += iPicStride;
    414     }
    415 
    416     // Fill top border with rec. samples
    417     piRoiTemp = piRoiOrigin - iPicStride;
    418     for (i=0; i<uiCuWidth; i++)
    419     {
    420       piAdiTemp[1+i] = piRoiTemp[i];
    421     }
    422    
    423     // Fill top right border with rec. samples
    424     piRoiTemp = piRoiOrigin - iPicStride + uiCuWidth;
    425     for (i=0; i<uiCuWidth; i++)
    426     {
    427       piAdiTemp[1+uiCuWidth+i] = piRoiTemp[i];
    428     }
    429360  }
    430361  else // reference samples are partially available
    431362  {
    432     Int  iNumUnits2 = iNumUnitsInCu<<1;
    433     Int  iTotalSamples = iTotalUnits*iUnitSize;
     363    // all above units have "unitWidth" samples each, all left/below-left units have "unitHeight" samples each
     364    const Int  iTotalSamples = (iLeftUnits * unitHeight) + ((iAboveUnits + 1) * unitWidth);
    434365    Pel  piAdiLine[5 * MAX_CU_SIZE];
    435     Pel  *piAdiLineTemp;
    436     Bool *pbNeighborFlags;
    437     Int  iNext, iCurr;
    438     Pel  piRef = 0;
     366    Pel  *piAdiLineTemp;
     367    const Bool *pbNeighborFlags;
     368
    439369
    440370    // Initialize
     
    443373      piAdiLine[i] = iDCValue;
    444374    }
    445    
     375
    446376    // Fill top-left sample
    447377    piRoiTemp = piRoiOrigin - iPicStride - 1;
    448     piAdiLineTemp = piAdiLine + (iNumUnits2*iUnitSize);
    449     pbNeighborFlags = bNeighborFlags + iNumUnits2;
     378    piAdiLineTemp = piAdiLine + (iLeftUnits * unitHeight);
     379    pbNeighborFlags = bNeighborFlags + iLeftUnits;
    450380    if (*pbNeighborFlags)
    451381    {
    452       piAdiLineTemp[0] = piRoiTemp[0];
    453       for (i=1; i<iUnitSize; i++)
    454       {
    455         piAdiLineTemp[i] = piAdiLineTemp[0];
    456       }
    457     }
    458 
    459     // Fill left & below-left samples
     382#if O0043_BEST_EFFORT_DECODING
     383      Pel topLeftVal=piRoiTemp[0] << bitDepthDelta;
     384#else
     385      Pel topLeftVal=piRoiTemp[0];
     386#endif
     387      for (i=0; i<unitWidth; i++)
     388      {
     389        piAdiLineTemp[i] = topLeftVal;
     390      }
     391    }
     392
     393    // Fill left & below-left samples (downwards)
    460394    piRoiTemp += iPicStride;
    461     if (bLMmode)
    462     {
    463       piRoiTemp --; // move the second left column
    464     }
    465395    piAdiLineTemp--;
    466396    pbNeighborFlags--;
    467     for (j=0; j<iNumUnits2; j++)
     397
     398    for (j=0; j<iLeftUnits; j++)
    468399    {
    469400      if (*pbNeighborFlags)
    470401      {
    471         for (i=0; i<iUnitSize; i++)
    472         {
     402        for (i=0; i<unitHeight; i++)
     403        {
     404#if O0043_BEST_EFFORT_DECODING
     405          piAdiLineTemp[-i] = piRoiTemp[i*iPicStride] << bitDepthDelta;
     406#else
    473407          piAdiLineTemp[-i] = piRoiTemp[i*iPicStride];
    474         }
    475       }
    476       piRoiTemp += iUnitSize*iPicStride;
    477       piAdiLineTemp -= iUnitSize;
     408#endif
     409        }
     410      }
     411      piRoiTemp += unitHeight*iPicStride;
     412      piAdiLineTemp -= unitHeight;
    478413      pbNeighborFlags--;
    479414    }
    480415
    481     // Fill above & above-right samples
     416    // Fill above & above-right samples (left-to-right) (each unit has "unitWidth" samples)
    482417    piRoiTemp = piRoiOrigin - iPicStride;
    483     piAdiLineTemp = piAdiLine + ((iNumUnits2+1)*iUnitSize);
    484     pbNeighborFlags = bNeighborFlags + iNumUnits2 + 1;
    485     for (j=0; j<iNumUnits2; j++)
     418    // offset line buffer by iNumUints2*unitHeight (for left/below-left) + unitWidth (for above-left)
     419    piAdiLineTemp = piAdiLine + (iLeftUnits * unitHeight) + unitWidth;
     420    pbNeighborFlags = bNeighborFlags + iLeftUnits + 1;
     421    for (j=0; j<iAboveUnits; j++)
    486422    {
    487423      if (*pbNeighborFlags)
    488424      {
    489         for (i=0; i<iUnitSize; i++)
    490         {
     425        for (i=0; i<unitWidth; i++)
     426        {
     427#if O0043_BEST_EFFORT_DECODING
     428          piAdiLineTemp[i] = piRoiTemp[i] << bitDepthDelta;
     429#else
    491430          piAdiLineTemp[i] = piRoiTemp[i];
    492         }
    493       }
    494       piRoiTemp += iUnitSize;
    495       piAdiLineTemp += iUnitSize;
     431#endif
     432        }
     433      }
     434      piRoiTemp += unitWidth;
     435      piAdiLineTemp += unitWidth;
    496436      pbNeighborFlags++;
    497437    }
    498438
    499439    // Pad reference samples when necessary
    500     iCurr = 0;
    501     iNext = 1;
    502     piAdiLineTemp = piAdiLine;
    503     while (iCurr < iTotalUnits)
    504     {
    505       if (!bNeighborFlags[iCurr])
    506       {
    507         if(iCurr == 0)
    508         {
    509           while (iNext < iTotalUnits && !bNeighborFlags[iNext])
     440    Int iCurrJnit = 0;
     441    Pel  *piAdiLineCur   = piAdiLine;
     442    const UInt piAdiLineTopRowOffset = iLeftUnits * (unitHeight - unitWidth);
     443
     444    if (!bNeighborFlags[0])
     445    {
     446      // very bottom unit of bottom-left; at least one unit will be valid.
     447      {
     448        Int   iNext = 1;
     449        while (iNext < iTotalUnits && !bNeighborFlags[iNext])
     450        {
     451          iNext++;
     452        }
     453        Pel *piAdiLineNext = piAdiLine + ((iNext < iLeftUnits) ? (iNext * unitHeight) : (piAdiLineTopRowOffset + (iNext * unitWidth)));
     454        const Pel refSample = *piAdiLineNext;
     455        // Pad unavailable samples with new value
     456        Int iNextOrTop = std::min<Int>(iNext, iLeftUnits);
     457        // fill left column
     458        while (iCurrJnit < iNextOrTop)
     459        {
     460          for (i=0; i<unitHeight; i++)
    510461          {
    511             iNext++;
     462            piAdiLineCur[i] = refSample;
    512463          }
    513           piRef = piAdiLine[iNext*iUnitSize];
    514           // Pad unavailable samples with new value
    515           while (iCurr < iNext)
     464          piAdiLineCur += unitHeight;
     465          iCurrJnit++;
     466        }
     467        // fill top row
     468        while (iCurrJnit < iNext)
     469        {
     470          for (i=0; i<unitWidth; i++)
    516471          {
    517             for (i=0; i<iUnitSize; i++)
    518             {
    519               piAdiLineTemp[i] = piRef;
    520             }
    521             piAdiLineTemp += iUnitSize;
    522             iCurr++;
     472            piAdiLineCur[i] = refSample;
    523473          }
    524         }
    525         else
    526         {
    527           piRef = piAdiLine[iCurr*iUnitSize-1];
    528           for (i=0; i<iUnitSize; i++)
     474          piAdiLineCur += unitWidth;
     475          iCurrJnit++;
     476        }
     477      }
     478    }
     479
     480    // pad all other reference samples.
     481    while (iCurrJnit < iTotalUnits)
     482    {
     483      if (!bNeighborFlags[iCurrJnit]) // samples not available
     484      {
     485        {
     486          const Int numSamplesInCurrUnit = (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
     487          const Pel refSample = *(piAdiLineCur-1);
     488          for (i=0; i<numSamplesInCurrUnit; i++)
    529489          {
    530             piAdiLineTemp[i] = piRef;
     490            piAdiLineCur[i] = refSample;
    531491          }
    532           piAdiLineTemp += iUnitSize;
    533           iCurr++;
    534         }
    535       }
    536       else
    537       {
    538         piAdiLineTemp += iUnitSize;
    539         iCurr++;
     492          piAdiLineCur += numSamplesInCurrUnit;
     493          iCurrJnit++;
     494        }
     495      }
     496      else
     497      {
     498        piAdiLineCur += (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
     499        iCurrJnit++;
    540500      }
    541501    }
    542502
    543503    // Copy processed samples
    544     piAdiLineTemp = piAdiLine + uiHeight + iUnitSize - 2;
     504
     505    piAdiLineTemp = piAdiLine + uiHeight + unitWidth - 2;
     506    // top left, top and top right samples
    545507    for (i=0; i<uiWidth; i++)
    546508    {
    547509      piAdiTemp[i] = piAdiLineTemp[i];
    548510    }
     511
    549512    piAdiLineTemp = piAdiLine + uiHeight - 1;
    550513    for (i=1; i<uiHeight; i++)
     
    553516    }
    554517  }
    555 }
    556 
    557 Int* TComPattern::getAdiOrgBuf( Int /*iCuWidth*/, Int /*iCuHeight*/, Int* piAdiBuf)
    558 {
    559   return piAdiBuf;
    560 }
    561 
    562 Int* TComPattern::getAdiCbBuf( Int /*iCuWidth*/, Int /*iCuHeight*/, Int* piAdiBuf)
    563 {
    564   return piAdiBuf;
    565 }
    566 
    567 Int* TComPattern::getAdiCrBuf(Int iCuWidth,Int iCuHeight, Int* piAdiBuf)
    568 {
    569   return piAdiBuf+(iCuWidth*2+1)*(iCuHeight*2+1);
    570518}
    571519
     
    578526 * The prediction mode index is used to determine whether a smoothed reference sample buffer is returned.
    579527 */
    580 Int* TComPattern::getPredictorPtr( UInt uiDirMode, UInt log2BlkSize, Int* piAdiBuf )
    581 {
    582   Int* piSrc;
    583   assert(log2BlkSize >= 2 && log2BlkSize < 7);
    584   Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
    585   UChar ucFiltIdx = diff > m_aucIntraFilter[log2BlkSize - 2] ? 1 : 0;
    586   if (uiDirMode == DC_IDX)
    587   {
    588     ucFiltIdx = 0; //no smoothing for DC or LM chroma
    589   }
    590 
    591   assert( ucFiltIdx <= 1 );
    592 
    593   Int width  = 1 << log2BlkSize;
    594   Int height = 1 << log2BlkSize;
    595  
    596   piSrc = getAdiOrgBuf( width, height, piAdiBuf );
    597 
    598   if ( ucFiltIdx )
    599   {
    600     piSrc += (2 * width + 1) * (2 * height + 1);
    601   }
    602 
    603   return piSrc;
    604 }
    605 
    606 Bool TComPattern::isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
     528
     529Bool TComPrediction::filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
     530{
     531  Bool bFilter;
     532
     533  if (!filterIntraReferenceSamples(toChannelType(compID), chFmt, intraReferenceSmoothingDisabled))
     534  {
     535    bFilter=false;
     536  }
     537  else
     538  {
     539    assert(uiTuChWidth>=4 && uiTuChHeight>=4 && uiTuChWidth<128 && uiTuChHeight<128);
     540
     541    if (uiDirMode == DC_IDX)
     542    {
     543      bFilter=false; //no smoothing for DC or LM chroma
     544    }
     545    else
     546    {
     547      Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
     548      UInt sizeIndex=g_aucConvertToBit[uiTuChWidth];
     549      assert(sizeIndex < MAX_INTRA_FILTER_DEPTHS);
     550      bFilter = diff > m_aucIntraFilter[toChannelType(compID)][sizeIndex];
     551    }
     552  }
     553  return bFilter;
     554}
     555
     556Bool isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
    607557{
    608558  Bool bAboveLeftFlag;
     
    611561  if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    612562  {
    613     bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->getPredictionMode( uiPartAboveLeft ) == MODE_INTRA );
     563    bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->isIntra( uiPartAboveLeft ) );
    614564  }
    615565  else
     
    620570}
    621571
    622 Int TComPattern::isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
     572Int isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    623573{
    624574  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
     
    634584    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    635585    {
    636       if ( pcCUAbove && pcCUAbove->getPredictionMode( uiPartAbove ) == MODE_INTRA )
     586      if ( pcCUAbove && pcCUAbove->isIntra( uiPartAbove ) )
    637587      {
    638588        iNumIntra++;
     
    661611}
    662612
    663 Int TComPattern::isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
     613Int isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    664614{
    665615  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
    666616  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
    667   const UInt uiIdxStep = pcCU->getPic()->getNumPartInWidth();
     617  const UInt uiIdxStep = pcCU->getPic()->getNumPartInCtuWidth();
    668618  Bool *pbValidFlags = bValidFlags;
    669619  Int iNumIntra = 0;
     
    675625    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    676626    {
    677       if ( pcCULeft && pcCULeft->getPredictionMode( uiPartLeft ) == MODE_INTRA )
     627      if ( pcCULeft && pcCULeft->isIntra( uiPartLeft ) )
    678628      {
    679629        iNumIntra++;
     
    703653}
    704654
    705 Int TComPattern::isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
     655Int isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
    706656{
    707657  const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
     
    715665    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    716666    {
    717       if ( pcCUAboveRight && pcCUAboveRight->getPredictionMode( uiPartAboveRight ) == MODE_INTRA )
     667      if ( pcCUAboveRight && pcCUAboveRight->isIntra( uiPartAboveRight ) )
    718668      {
    719669        iNumIntra++;
     
    743693}
    744694
    745 Int TComPattern::isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
    746 {
    747   const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInWidth() + 1;
     695Int isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
     696{
     697  const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
    748698  Bool *pbValidFlags = bValidFlags;
    749699  Int iNumIntra = 0;
     
    755705    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
    756706    {
    757       if ( pcCUBelowLeft && pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) == MODE_INTRA )
     707      if ( pcCUBelowLeft && pcCUBelowLeft->isIntra( uiPartBelowLeft ) )
    758708      {
    759709        iNumIntra++;
Note: See TracChangeset for help on using the changeset viewer.