source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp @ 1465

Last change on this file since 1465 was 1465, checked in by seregin, 9 years ago

port rev 4597

  • Property svn:eol-style set to native
File size: 24.0 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TComPattern.cpp
35    \brief    neighbouring pixel access classes
36*/
37
38#include "TComPic.h"
39#include "TComPattern.h"
40#include "TComDataCU.h"
41#include "TComTU.h"
42#include "Debug.h"
43#include "TComPrediction.h"
44
45//! \ingroup TLibCommon
46//! \{
47
48// Forward declarations
49
50/// padding of unavailable reference samples for intra prediction
51Void fillReferenceSamples( const Int bitDepth, 
52#if O0043_BEST_EFFORT_DECODING
53                           const Int bitDepthDelta, 
54#endif
55                           const Pel* piRoiOrigin, 
56                                 Pel* piIntraTemp,
57                           const Bool* bNeighborFlags,
58                           const Int iNumIntraNeighbor, 
59                           const Int unitWidth, 
60                           const Int unitHeight, 
61                           const Int iAboveUnits, 
62                           const Int iLeftUnits,
63                           const UInt uiWidth, 
64                           const UInt uiHeight, 
65                           const Int iPicStride );
66
67/// constrained intra prediction
68Bool  isAboveLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT );
69Int   isAboveAvailable      ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
70Int   isLeftAvailable       ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
71Int   isAboveRightAvailable ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
72Int   isBelowLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
73
74
75// ====================================================================================================================
76// Public member functions (TComPatternParam)
77// ====================================================================================================================
78
79/**
80 \param  piTexture     pixel data
81 \param  iRoiWidth     pattern width
82 \param  iRoiHeight    pattern height
83 \param  iStride       buffer stride
84 \param  bitDepth      bit depth
85 */
86Void TComPatternParam::setPatternParamPel ( Pel* piTexture,
87                                           Int iRoiWidth,
88                                           Int iRoiHeight,
89                                           Int iStride,
90                                           Int bitDepth
91                                           )
92{
93  m_piROIOrigin    = piTexture;
94  m_iROIWidth      = iRoiWidth;
95  m_iROIHeight     = iRoiHeight;
96  m_iPatternStride = iStride;
97  m_bitDepth       = bitDepth;
98}
99
100// ====================================================================================================================
101// Public member functions (TComPattern)
102// ====================================================================================================================
103
104Void TComPattern::initPattern (Pel* piY,
105                               Int iRoiWidth,
106                               Int iRoiHeight,
107                               Int iStride,
108                               Int bitDepthLuma)
109{
110  m_cPatternY. setPatternParamPel( piY,  iRoiWidth, iRoiHeight, iStride, bitDepthLuma);
111}
112
113
114// TODO: move this function to TComPrediction.cpp.
115Void TComPrediction::initIntraPatternChType( TComTU &rTu, const ComponentID compID, const Bool bFilterRefSamples DEBUG_STRING_FN_DECLARE(sDebug))
116{
117  const ChannelType chType    = toChannelType(compID);
118
119  TComDataCU *pcCU=rTu.getCU();
120  const TComSPS &sps = *(pcCU->getSlice()->getSPS());
121  const UInt uiZorderIdxInPart=rTu.GetAbsPartIdxTU();
122  const UInt uiTuWidth        = rTu.getRect(compID).width;
123  const UInt uiTuHeight       = rTu.getRect(compID).height;
124  const UInt uiTuWidth2       = uiTuWidth  << 1;
125  const UInt uiTuHeight2      = uiTuHeight << 1;
126
127  const Int  iBaseUnitSize    = sps.getMaxCUWidth() >> sps.getMaxTotalCUDepth();
128  const Int  iUnitWidth       = iBaseUnitSize  >> pcCU->getPic()->getPicYuvRec()->getComponentScaleX(compID);
129  const Int  iUnitHeight      = iBaseUnitSize  >> pcCU->getPic()->getPicYuvRec()->getComponentScaleY(compID);
130  const Int  iTUWidthInUnits  = uiTuWidth  / iUnitWidth;
131  const Int  iTUHeightInUnits = uiTuHeight / iUnitHeight;
132  const Int  iAboveUnits      = iTUWidthInUnits  << 1;
133  const Int  iLeftUnits       = iTUHeightInUnits << 1;
134#if SVC_EXTENSION
135  const Int  bitDepthForChannel = pcCU->getSlice()->getBitDepth(chType);
136#else
137  const Int  bitDepthForChannel = sps.getBitDepth(chType);
138#endif
139
140  assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
141
142  const Int  iPartIdxStride   = pcCU->getPic()->getNumPartInCtuWidth();
143  const UInt uiPartIdxLT      = pcCU->getZorderIdxInCtu() + uiZorderIdxInPart;
144  const UInt uiPartIdxRT      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] +   iTUWidthInUnits  - 1                   ];
145  const UInt uiPartIdxLB      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + ((iTUHeightInUnits - 1) * iPartIdxStride)];
146
147  Int   iPicStride = pcCU->getPic()->getStride(compID);
148  Bool  bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1];
149  Int   iNumIntraNeighbor = 0;
150
151  bNeighborFlags[iLeftUnits] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
152  iNumIntraNeighbor += bNeighborFlags[iLeftUnits] ? 1 : 0;
153  iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1)                    );
154  iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1 + iTUWidthInUnits ) );
155  iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1)                    );
156  iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1 - iTUHeightInUnits) );
157
158  const UInt         uiROIWidth  = uiTuWidth2+1;
159  const UInt         uiROIHeight = uiTuHeight2+1;
160
161  assert(uiROIWidth*uiROIHeight <= m_iYuvExtSize);
162
163#if DEBUG_STRING
164  std::stringstream ss(stringstream::out);
165#endif
166
167  {
168    Pel *piIntraTemp   = m_piYuvExt[compID][PRED_BUF_UNFILTERED];
169    Pel *piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiZorderIdxInPart);
170#if O0043_BEST_EFFORT_DECODING
171    const Int  bitDepthForChannelInStream = sps.getStreamBitDepth(chType);
172    fillReferenceSamples (bitDepthForChannelInStream, bitDepthForChannelInStream - bitDepthForChannel,
173#else
174    fillReferenceSamples (bitDepthForChannel,
175#endif
176                          piRoiOrigin, piIntraTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
177                          uiROIWidth, uiROIHeight, iPicStride);
178
179
180#if DEBUG_STRING
181    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
182    {
183      ss << "###: generating Ref Samples for channel " << compID << " and " << rTu.getRect(compID).width << " x " << rTu.getRect(compID).height << "\n";
184      for (UInt y=0; y<uiROIHeight; y++)
185      {
186        ss << "###: - ";
187        for (UInt x=0; x<uiROIWidth; x++)
188        {
189          if (x==0 || y==0)
190          {
191            ss << piIntraTemp[y*uiROIWidth + x] << ", ";
192//          if (x%16==15) ss << "\nPart size: ~ ";
193          }
194        }
195        ss << "\n";
196      }
197    }
198#endif
199
200    if (bFilterRefSamples)
201    {
202      // generate filtered intra prediction samples
203
204            Int          stride    = uiROIWidth;
205      const Pel         *piSrcPtr  = piIntraTemp                           + (stride * uiTuHeight2); // bottom left
206            Pel         *piDestPtr = m_piYuvExt[compID][PRED_BUF_FILTERED] + (stride * uiTuHeight2); // bottom left
207
208      //------------------------------------------------
209
210      Bool useStrongIntraSmoothing = isLuma(chType) && sps.getUseStrongIntraSmoothing();
211
212      const Pel bottomLeft = piIntraTemp[stride * uiTuHeight2];
213      const Pel topLeft    = piIntraTemp[0];
214      const Pel topRight   = piIntraTemp[uiTuWidth2];
215
216      if (useStrongIntraSmoothing)
217      {
218#if O0043_BEST_EFFORT_DECODING
219        const Int  threshold     = 1 << (bitDepthForChannelInStream - 5);
220#else
221        const Int  threshold     = 1 << (bitDepthForChannel - 5);
222#endif
223        const Bool bilinearLeft  = abs((bottomLeft + topLeft ) - (2 * piIntraTemp[stride * uiTuHeight])) < threshold; //difference between the
224        const Bool bilinearAbove = abs((topLeft    + topRight) - (2 * piIntraTemp[         uiTuWidth ])) < threshold; //ends and the middle
225        if ((uiTuWidth < 32) || (!bilinearLeft) || (!bilinearAbove))
226        {
227          useStrongIntraSmoothing = false;
228        }
229      }
230
231      *piDestPtr = *piSrcPtr; // bottom left is not filtered
232      piDestPtr -= stride;
233      piSrcPtr  -= stride;
234
235      //------------------------------------------------
236
237      //left column (bottom to top)
238
239      if (useStrongIntraSmoothing)
240      {
241        const Int shift = g_aucConvertToBit[uiTuHeight] + 3; //log2(uiTuHeight2)
242
243        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride)
244        {
245          *piDestPtr = (((uiTuHeight2 - i) * bottomLeft) + (i * topLeft) + uiTuHeight) >> shift;
246        }
247
248        piSrcPtr -= stride * (uiTuHeight2 - 1);
249      }
250      else
251      {
252        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride, piSrcPtr-=stride)
253        {
254          *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[-stride] + 2 ) >> 2;
255        }
256      }
257
258      //------------------------------------------------
259
260      //top-left
261
262      if (useStrongIntraSmoothing)
263      {
264        *piDestPtr = piSrcPtr[0];
265      }
266      else
267      {
268        *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[1] + 2 ) >> 2;
269      }
270      piDestPtr += 1;
271      piSrcPtr  += 1;
272
273      //------------------------------------------------
274
275      //top row (left-to-right)
276
277      if (useStrongIntraSmoothing)
278      {
279        const Int shift = g_aucConvertToBit[uiTuWidth] + 3; //log2(uiTuWidth2)
280
281        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++)
282        {
283          *piDestPtr = (((uiTuWidth2 - i) * topLeft) + (i * topRight) + uiTuWidth) >> shift;
284        }
285
286        piSrcPtr += uiTuWidth2 - 1;
287      }
288      else
289      {
290        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++, piSrcPtr++)
291        {
292          *piDestPtr = ( piSrcPtr[1] + 2*piSrcPtr[0] + piSrcPtr[-1] + 2 ) >> 2;
293        }
294      }
295
296      //------------------------------------------------
297
298      *piDestPtr=*piSrcPtr; // far right is not filtered
299
300#if DEBUG_STRING
301    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
302    {
303      ss << "###: filtered result for channel " << compID <<"\n";
304      for (UInt y=0; y<uiROIHeight; y++)
305      {
306        ss << "###: - ";
307        for (UInt x=0; x<uiROIWidth; x++)
308        {
309          if (x==0 || y==0)
310          {
311            ss << m_piYuvExt[compID][PRED_BUF_FILTERED][y*uiROIWidth + x] << ", ";
312//          if (x%16==15) ss << "\nPart size: ~ ";
313          }
314        }
315        ss << "\n";
316      }
317    }
318#endif
319
320
321    }
322  }
323  DEBUG_STRING_APPEND(sDebug, ss.str())
324}
325
326Void fillReferenceSamples( const Int bitDepth, 
327#if O0043_BEST_EFFORT_DECODING
328                           const Int bitDepthDelta, 
329#endif
330                           const Pel* piRoiOrigin, 
331                                 Pel* piIntraTemp,
332                           const Bool* bNeighborFlags,
333                           const Int iNumIntraNeighbor, 
334                           const Int unitWidth, 
335                           const Int unitHeight, 
336                           const Int iAboveUnits, 
337                           const Int iLeftUnits,
338                           const UInt uiWidth, 
339                           const UInt uiHeight, 
340                           const Int iPicStride )
341{
342  const Pel* piRoiTemp;
343  Int  i, j;
344  Int  iDCValue = 1 << (bitDepth - 1);
345  const Int iTotalUnits = iAboveUnits + iLeftUnits + 1; //+1 for top-left
346
347  if (iNumIntraNeighbor == 0)
348  {
349    // Fill border with DC value
350    for (i=0; i<uiWidth; i++)
351    {
352      piIntraTemp[i] = iDCValue;
353    }
354    for (i=1; i<uiHeight; i++)
355    {
356      piIntraTemp[i*uiWidth] = iDCValue;
357    }
358  }
359  else if (iNumIntraNeighbor == iTotalUnits)
360  {
361    // Fill top-left border and top and top right with rec. samples
362    piRoiTemp = piRoiOrigin - iPicStride - 1;
363
364    for (i=0; i<uiWidth; i++)
365    {
366#if O0043_BEST_EFFORT_DECODING
367      piIntraTemp[i] = piRoiTemp[i] << bitDepthDelta;
368#else
369      piIntraTemp[i] = piRoiTemp[i];
370#endif
371    }
372
373    // Fill left and below left border with rec. samples
374    piRoiTemp = piRoiOrigin - 1;
375
376    for (i=1; i<uiHeight; i++)
377    {
378#if O0043_BEST_EFFORT_DECODING
379      piIntraTemp[i*uiWidth] = (*(piRoiTemp)) << bitDepthDelta;
380#else
381      piIntraTemp[i*uiWidth] = *(piRoiTemp);
382#endif
383      piRoiTemp += iPicStride;
384    }
385  }
386  else // reference samples are partially available
387  {
388    // all above units have "unitWidth" samples each, all left/below-left units have "unitHeight" samples each
389    const Int  iTotalSamples = (iLeftUnits * unitHeight) + ((iAboveUnits + 1) * unitWidth);
390    Pel  piIntraLine[5 * MAX_CU_SIZE];
391    Pel  *piIntraLineTemp;
392    const Bool *pbNeighborFlags;
393
394
395    // Initialize
396    for (i=0; i<iTotalSamples; i++)
397    {
398      piIntraLine[i] = iDCValue;
399    }
400
401    // Fill top-left sample
402    piRoiTemp = piRoiOrigin - iPicStride - 1;
403    piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight);
404    pbNeighborFlags = bNeighborFlags + iLeftUnits;
405    if (*pbNeighborFlags)
406    {
407#if O0043_BEST_EFFORT_DECODING
408      Pel topLeftVal=piRoiTemp[0] << bitDepthDelta;
409#else
410      Pel topLeftVal=piRoiTemp[0];
411#endif
412      for (i=0; i<unitWidth; i++)
413      {
414        piIntraLineTemp[i] = topLeftVal;
415      }
416    }
417
418    // Fill left & below-left samples (downwards)
419    piRoiTemp += iPicStride;
420    piIntraLineTemp--;
421    pbNeighborFlags--;
422
423    for (j=0; j<iLeftUnits; j++)
424    {
425      if (*pbNeighborFlags)
426      {
427        for (i=0; i<unitHeight; i++)
428        {
429#if O0043_BEST_EFFORT_DECODING
430          piIntraLineTemp[-i] = piRoiTemp[i*iPicStride] << bitDepthDelta;
431#else
432          piIntraLineTemp[-i] = piRoiTemp[i*iPicStride];
433#endif
434        }
435      }
436      piRoiTemp += unitHeight*iPicStride;
437      piIntraLineTemp -= unitHeight;
438      pbNeighborFlags--;
439    }
440
441    // Fill above & above-right samples (left-to-right) (each unit has "unitWidth" samples)
442    piRoiTemp = piRoiOrigin - iPicStride;
443    // offset line buffer by iNumUints2*unitHeight (for left/below-left) + unitWidth (for above-left)
444    piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight) + unitWidth;
445    pbNeighborFlags = bNeighborFlags + iLeftUnits + 1;
446    for (j=0; j<iAboveUnits; j++)
447    {
448      if (*pbNeighborFlags)
449      {
450        for (i=0; i<unitWidth; i++)
451        {
452#if O0043_BEST_EFFORT_DECODING
453          piIntraLineTemp[i] = piRoiTemp[i] << bitDepthDelta;
454#else
455          piIntraLineTemp[i] = piRoiTemp[i];
456#endif
457        }
458      }
459      piRoiTemp += unitWidth;
460      piIntraLineTemp += unitWidth;
461      pbNeighborFlags++;
462    }
463
464    // Pad reference samples when necessary
465    Int iCurrJnit = 0;
466    Pel  *piIntraLineCur   = piIntraLine;
467    const UInt piIntraLineTopRowOffset = iLeftUnits * (unitHeight - unitWidth);
468
469    if (!bNeighborFlags[0])
470    {
471      // very bottom unit of bottom-left; at least one unit will be valid.
472      {
473        Int   iNext = 1;
474        while (iNext < iTotalUnits && !bNeighborFlags[iNext])
475        {
476          iNext++;
477        }
478        Pel *piIntraLineNext = piIntraLine + ((iNext < iLeftUnits) ? (iNext * unitHeight) : (piIntraLineTopRowOffset + (iNext * unitWidth)));
479        const Pel refSample = *piIntraLineNext;
480        // Pad unavailable samples with new value
481        Int iNextOrTop = std::min<Int>(iNext, iLeftUnits);
482        // fill left column
483        while (iCurrJnit < iNextOrTop)
484        {
485          for (i=0; i<unitHeight; i++)
486          {
487            piIntraLineCur[i] = refSample;
488          }
489          piIntraLineCur += unitHeight;
490          iCurrJnit++;
491        }
492        // fill top row
493        while (iCurrJnit < iNext)
494        {
495          for (i=0; i<unitWidth; i++)
496          {
497            piIntraLineCur[i] = refSample;
498          }
499          piIntraLineCur += unitWidth;
500          iCurrJnit++;
501        }
502      }
503    }
504
505    // pad all other reference samples.
506    while (iCurrJnit < iTotalUnits)
507    {
508      if (!bNeighborFlags[iCurrJnit]) // samples not available
509      {
510        {
511          const Int numSamplesInCurrUnit = (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
512          const Pel refSample = *(piIntraLineCur-1);
513          for (i=0; i<numSamplesInCurrUnit; i++)
514          {
515            piIntraLineCur[i] = refSample;
516          }
517          piIntraLineCur += numSamplesInCurrUnit;
518          iCurrJnit++;
519        }
520      }
521      else
522      {
523        piIntraLineCur += (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
524        iCurrJnit++;
525      }
526    }
527
528    // Copy processed samples
529
530    piIntraLineTemp = piIntraLine + uiHeight + unitWidth - 2;
531    // top left, top and top right samples
532    for (i=0; i<uiWidth; i++)
533    {
534      piIntraTemp[i] = piIntraLineTemp[i];
535    }
536
537    piIntraLineTemp = piIntraLine + uiHeight - 1;
538    for (i=1; i<uiHeight; i++)
539    {
540      piIntraTemp[i*uiWidth] = piIntraLineTemp[-i];
541    }
542  }
543}
544
545Bool TComPrediction::filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
546{
547  Bool bFilter;
548
549  if (!filterIntraReferenceSamples(toChannelType(compID), chFmt, intraReferenceSmoothingDisabled))
550  {
551    bFilter=false;
552  }
553  else
554  {
555    assert(uiTuChWidth>=4 && uiTuChHeight>=4 && uiTuChWidth<128 && uiTuChHeight<128);
556
557    if (uiDirMode == DC_IDX)
558    {
559      bFilter=false; //no smoothing for DC or LM chroma
560    }
561    else
562    {
563      Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
564      UInt sizeIndex=g_aucConvertToBit[uiTuChWidth];
565      assert(sizeIndex < MAX_INTRA_FILTER_DEPTHS);
566      bFilter = diff > m_aucIntraFilter[toChannelType(compID)][sizeIndex];
567    }
568  }
569  return bFilter;
570}
571
572Bool isAboveLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT )
573{
574  Bool bAboveLeftFlag;
575  UInt uiPartAboveLeft;
576  const TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
577  if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
578  {
579    bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->isIntra( uiPartAboveLeft ) );
580  }
581  else
582  {
583    bAboveLeftFlag = (pcCUAboveLeft ? true : false);
584  }
585  return bAboveLeftFlag;
586}
587
588Int isAboveAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
589{
590  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
591  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1;
592  const UInt uiIdxStep = 1;
593  Bool *pbValidFlags = bValidFlags;
594  Int iNumIntra = 0;
595
596  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
597  {
598    UInt uiPartAbove;
599    const TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
600    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
601    {
602      if ( pcCUAbove && pcCUAbove->isIntra( uiPartAbove ) )
603      {
604        iNumIntra++;
605        *pbValidFlags = true;
606      }
607      else
608      {
609        *pbValidFlags = false;
610      }
611    }
612    else
613    {
614      if (pcCUAbove)
615      {
616        iNumIntra++;
617        *pbValidFlags = true;
618      }
619      else
620      {
621        *pbValidFlags = false;
622      }
623    }
624    pbValidFlags++;
625  }
626  return iNumIntra;
627}
628
629Int isLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
630{
631  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
632  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
633  const UInt uiIdxStep = pcCU->getPic()->getNumPartInCtuWidth();
634  Bool *pbValidFlags = bValidFlags;
635  Int iNumIntra = 0;
636
637  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
638  {
639    UInt uiPartLeft;
640    const TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
641    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
642    {
643      if ( pcCULeft && pcCULeft->isIntra( uiPartLeft ) )
644      {
645        iNumIntra++;
646        *pbValidFlags = true;
647      }
648      else
649      {
650        *pbValidFlags = false;
651      }
652    }
653    else
654    {
655      if ( pcCULeft )
656      {
657        iNumIntra++;
658        *pbValidFlags = true;
659      }
660      else
661      {
662        *pbValidFlags = false;
663      }
664    }
665    pbValidFlags--; // opposite direction
666  }
667
668  return iNumIntra;
669}
670
671Int isAboveRightAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
672{
673  const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
674  Bool *pbValidFlags = bValidFlags;
675  Int iNumIntra = 0;
676
677  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
678  {
679    UInt uiPartAboveRight;
680    const TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
681    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
682    {
683      if ( pcCUAboveRight && pcCUAboveRight->isIntra( uiPartAboveRight ) )
684      {
685        iNumIntra++;
686        *pbValidFlags = true;
687      }
688      else
689      {
690        *pbValidFlags = false;
691      }
692    }
693    else
694    {
695      if ( pcCUAboveRight )
696      {
697        iNumIntra++;
698        *pbValidFlags = true;
699      }
700      else
701      {
702        *pbValidFlags = false;
703      }
704    }
705    pbValidFlags++;
706  }
707
708  return iNumIntra;
709}
710
711Int isBelowLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
712{
713  const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
714  Bool *pbValidFlags = bValidFlags;
715  Int iNumIntra = 0;
716
717  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
718  {
719    UInt uiPartBelowLeft;
720    const TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
721    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
722    {
723      if ( pcCUBelowLeft && pcCUBelowLeft->isIntra( uiPartBelowLeft ) )
724      {
725        iNumIntra++;
726        *pbValidFlags = true;
727      }
728      else
729      {
730        *pbValidFlags = false;
731      }
732    }
733    else
734    {
735      if ( pcCUBelowLeft )
736      {
737        iNumIntra++;
738        *pbValidFlags = true;
739      }
740      else
741      {
742        *pbValidFlags = false;
743      }
744    }
745    pbValidFlags--; // opposite direction
746  }
747
748  return iNumIntra;
749}
750//! \}
Note: See TracBrowser for help on using the repository browser.