source: 3DVCSoftware/trunk/source/Lib/TLibCommon/TComPattern.cpp @ 1313

Last change on this file since 1313 was 1313, checked in by tech, 9 years ago

Merged 14.1-update-dev1@1312.

  • Property svn:eol-style set to native
File size: 23.8 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  ( TComDataCU* pcCU, UInt uiPartIdxLT );
69Int   isAboveAvailable      ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
70Int   isLeftAvailable       ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
71Int   isAboveRightAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
72Int   isBelowLeftAvailable  ( 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  const Int  bitDepthForChannel = sps.getBitDepth(chType);
135
136  assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
137
138  const Int  iPartIdxStride   = pcCU->getPic()->getNumPartInCtuWidth();
139  const UInt uiPartIdxLT      = pcCU->getZorderIdxInCtu() + uiZorderIdxInPart;
140  const UInt uiPartIdxRT      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] +   iTUWidthInUnits  - 1                   ];
141  const UInt uiPartIdxLB      = g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + ((iTUHeightInUnits - 1) * iPartIdxStride)];
142
143  Int   iPicStride = pcCU->getPic()->getStride(compID);
144  Bool  bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1];
145  Int   iNumIntraNeighbor = 0;
146
147  bNeighborFlags[iLeftUnits] = isAboveLeftAvailable( pcCU, uiPartIdxLT );
148  iNumIntraNeighbor += bNeighborFlags[iLeftUnits] ? 1 : 0;
149  iNumIntraNeighbor  += isAboveAvailable     ( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1)                    );
150  iNumIntraNeighbor  += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1 + iTUWidthInUnits ) );
151  iNumIntraNeighbor  += isLeftAvailable      ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1)                    );
152  iNumIntraNeighbor  += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1 - iTUHeightInUnits) );
153
154  const UInt         uiROIWidth  = uiTuWidth2+1;
155  const UInt         uiROIHeight = uiTuHeight2+1;
156
157  assert(uiROIWidth*uiROIHeight <= m_iYuvExtSize);
158
159#if DEBUG_STRING
160  std::stringstream ss(stringstream::out);
161#endif
162
163  {
164    Pel *piIntraTemp   = m_piYuvExt[compID][PRED_BUF_UNFILTERED];
165    Pel *piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiZorderIdxInPart);
166#if O0043_BEST_EFFORT_DECODING
167    const Int  bitDepthForChannelInStream = sps.getStreamBitDepth(chType);
168    fillReferenceSamples (bitDepthForChannelInStream, bitDepthForChannelInStream - bitDepthForChannel,
169#else
170    fillReferenceSamples (bitDepthForChannel,
171#endif
172                          piRoiOrigin, piIntraTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
173                          uiROIWidth, uiROIHeight, iPicStride);
174
175
176#if DEBUG_STRING
177    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
178    {
179      ss << "###: generating Ref Samples for channel " << compID << " and " << rTu.getRect(compID).width << " x " << rTu.getRect(compID).height << "\n";
180      for (UInt y=0; y<uiROIHeight; y++)
181      {
182        ss << "###: - ";
183        for (UInt x=0; x<uiROIWidth; x++)
184        {
185          if (x==0 || y==0)
186          {
187            ss << piIntraTemp[y*uiROIWidth + x] << ", ";
188//          if (x%16==15) ss << "\nPart size: ~ ";
189          }
190        }
191        ss << "\n";
192      }
193    }
194#endif
195
196    if (bFilterRefSamples)
197    {
198      // generate filtered intra prediction samples
199
200            Int          stride    = uiROIWidth;
201      const Pel         *piSrcPtr  = piIntraTemp                           + (stride * uiTuHeight2); // bottom left
202            Pel         *piDestPtr = m_piYuvExt[compID][PRED_BUF_FILTERED] + (stride * uiTuHeight2); // bottom left
203
204      //------------------------------------------------
205
206      Bool useStrongIntraSmoothing = isLuma(chType) && sps.getUseStrongIntraSmoothing();
207
208      const Pel bottomLeft = piIntraTemp[stride * uiTuHeight2];
209      const Pel topLeft    = piIntraTemp[0];
210      const Pel topRight   = piIntraTemp[uiTuWidth2];
211
212      if (useStrongIntraSmoothing)
213      {
214#if O0043_BEST_EFFORT_DECODING
215        const Int  threshold     = 1 << (bitDepthForChannelInStream - 5);
216#else
217        const Int  threshold     = 1 << (bitDepthForChannel - 5);
218#endif
219        const Bool bilinearLeft  = abs((bottomLeft + topLeft ) - (2 * piIntraTemp[stride * uiTuHeight])) < threshold; //difference between the
220        const Bool bilinearAbove = abs((topLeft    + topRight) - (2 * piIntraTemp[         uiTuWidth ])) < threshold; //ends and the middle
221        if ((uiTuWidth < 32) || (!bilinearLeft) || (!bilinearAbove))
222        {
223          useStrongIntraSmoothing = false;
224        }
225      }
226
227      *piDestPtr = *piSrcPtr; // bottom left is not filtered
228      piDestPtr -= stride;
229      piSrcPtr  -= stride;
230
231      //------------------------------------------------
232
233      //left column (bottom to top)
234
235      if (useStrongIntraSmoothing)
236      {
237        const Int shift = g_aucConvertToBit[uiTuHeight] + 3; //log2(uiTuHeight2)
238
239        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride)
240        {
241          *piDestPtr = (((uiTuHeight2 - i) * bottomLeft) + (i * topLeft) + uiTuHeight) >> shift;
242        }
243
244        piSrcPtr -= stride * (uiTuHeight2 - 1);
245      }
246      else
247      {
248        for(UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride, piSrcPtr-=stride)
249        {
250          *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[-stride] + 2 ) >> 2;
251        }
252      }
253
254      //------------------------------------------------
255
256      //top-left
257
258      if (useStrongIntraSmoothing)
259      {
260        *piDestPtr = piSrcPtr[0];
261      }
262      else
263      {
264        *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[1] + 2 ) >> 2;
265      }
266      piDestPtr += 1;
267      piSrcPtr  += 1;
268
269      //------------------------------------------------
270
271      //top row (left-to-right)
272
273      if (useStrongIntraSmoothing)
274      {
275        const Int shift = g_aucConvertToBit[uiTuWidth] + 3; //log2(uiTuWidth2)
276
277        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++)
278        {
279          *piDestPtr = (((uiTuWidth2 - i) * topLeft) + (i * topRight) + uiTuWidth) >> shift;
280        }
281
282        piSrcPtr += uiTuWidth2 - 1;
283      }
284      else
285      {
286        for(UInt i=1; i<uiTuWidth2; i++, piDestPtr++, piSrcPtr++)
287        {
288          *piDestPtr = ( piSrcPtr[1] + 2*piSrcPtr[0] + piSrcPtr[-1] + 2 ) >> 2;
289        }
290      }
291
292      //------------------------------------------------
293
294      *piDestPtr=*piSrcPtr; // far right is not filtered
295
296#if DEBUG_STRING
297    if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
298    {
299      ss << "###: filtered result for channel " << compID <<"\n";
300      for (UInt y=0; y<uiROIHeight; y++)
301      {
302        ss << "###: - ";
303        for (UInt x=0; x<uiROIWidth; x++)
304        {
305          if (x==0 || y==0)
306          {
307            ss << m_piYuvExt[compID][PRED_BUF_FILTERED][y*uiROIWidth + x] << ", ";
308//          if (x%16==15) ss << "\nPart size: ~ ";
309          }
310        }
311        ss << "\n";
312      }
313    }
314#endif
315
316
317    }
318  }
319  DEBUG_STRING_APPEND(sDebug, ss.str())
320}
321
322Void fillReferenceSamples( const Int bitDepth, 
323#if O0043_BEST_EFFORT_DECODING
324                           const Int bitDepthDelta, 
325#endif
326                           const Pel* piRoiOrigin, 
327                                 Pel* piIntraTemp,
328                           const Bool* bNeighborFlags,
329                           const Int iNumIntraNeighbor, 
330                           const Int unitWidth, 
331                           const Int unitHeight, 
332                           const Int iAboveUnits, 
333                           const Int iLeftUnits,
334                           const UInt uiWidth, 
335                           const UInt uiHeight, 
336                           const Int iPicStride )
337{
338  const Pel* piRoiTemp;
339  Int  i, j;
340  Int  iDCValue = 1 << (bitDepth - 1);
341  const Int iTotalUnits = iAboveUnits + iLeftUnits + 1; //+1 for top-left
342
343  if (iNumIntraNeighbor == 0)
344  {
345    // Fill border with DC value
346    for (i=0; i<uiWidth; i++)
347    {
348      piIntraTemp[i] = iDCValue;
349    }
350    for (i=1; i<uiHeight; i++)
351    {
352      piIntraTemp[i*uiWidth] = iDCValue;
353    }
354  }
355  else if (iNumIntraNeighbor == iTotalUnits)
356  {
357    // Fill top-left border and top and top right with rec. samples
358    piRoiTemp = piRoiOrigin - iPicStride - 1;
359
360    for (i=0; i<uiWidth; i++)
361    {
362#if O0043_BEST_EFFORT_DECODING
363      piIntraTemp[i] = piRoiTemp[i] << bitDepthDelta;
364#else
365      piIntraTemp[i] = piRoiTemp[i];
366#endif
367    }
368
369    // Fill left and below left border with rec. samples
370    piRoiTemp = piRoiOrigin - 1;
371
372    for (i=1; i<uiHeight; i++)
373    {
374#if O0043_BEST_EFFORT_DECODING
375      piIntraTemp[i*uiWidth] = (*(piRoiTemp)) << bitDepthDelta;
376#else
377      piIntraTemp[i*uiWidth] = *(piRoiTemp);
378#endif
379      piRoiTemp += iPicStride;
380    }
381  }
382  else // reference samples are partially available
383  {
384    // all above units have "unitWidth" samples each, all left/below-left units have "unitHeight" samples each
385    const Int  iTotalSamples = (iLeftUnits * unitHeight) + ((iAboveUnits + 1) * unitWidth);
386    Pel  piIntraLine[5 * MAX_CU_SIZE];
387    Pel  *piIntraLineTemp;
388    const Bool *pbNeighborFlags;
389
390
391    // Initialize
392    for (i=0; i<iTotalSamples; i++)
393    {
394      piIntraLine[i] = iDCValue;
395    }
396
397    // Fill top-left sample
398    piRoiTemp = piRoiOrigin - iPicStride - 1;
399    piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight);
400    pbNeighborFlags = bNeighborFlags + iLeftUnits;
401    if (*pbNeighborFlags)
402    {
403#if O0043_BEST_EFFORT_DECODING
404      Pel topLeftVal=piRoiTemp[0] << bitDepthDelta;
405#else
406      Pel topLeftVal=piRoiTemp[0];
407#endif
408      for (i=0; i<unitWidth; i++)
409      {
410        piIntraLineTemp[i] = topLeftVal;
411      }
412    }
413
414    // Fill left & below-left samples (downwards)
415    piRoiTemp += iPicStride;
416    piIntraLineTemp--;
417    pbNeighborFlags--;
418
419    for (j=0; j<iLeftUnits; j++)
420    {
421      if (*pbNeighborFlags)
422      {
423        for (i=0; i<unitHeight; i++)
424        {
425#if O0043_BEST_EFFORT_DECODING
426          piIntraLineTemp[-i] = piRoiTemp[i*iPicStride] << bitDepthDelta;
427#else
428          piIntraLineTemp[-i] = piRoiTemp[i*iPicStride];
429#endif
430        }
431      }
432      piRoiTemp += unitHeight*iPicStride;
433      piIntraLineTemp -= unitHeight;
434      pbNeighborFlags--;
435    }
436
437    // Fill above & above-right samples (left-to-right) (each unit has "unitWidth" samples)
438    piRoiTemp = piRoiOrigin - iPicStride;
439    // offset line buffer by iNumUints2*unitHeight (for left/below-left) + unitWidth (for above-left)
440    piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight) + unitWidth;
441    pbNeighborFlags = bNeighborFlags + iLeftUnits + 1;
442    for (j=0; j<iAboveUnits; j++)
443    {
444      if (*pbNeighborFlags)
445      {
446        for (i=0; i<unitWidth; i++)
447        {
448#if O0043_BEST_EFFORT_DECODING
449          piIntraLineTemp[i] = piRoiTemp[i] << bitDepthDelta;
450#else
451          piIntraLineTemp[i] = piRoiTemp[i];
452#endif
453        }
454      }
455      piRoiTemp += unitWidth;
456      piIntraLineTemp += unitWidth;
457      pbNeighborFlags++;
458    }
459
460    // Pad reference samples when necessary
461    Int iCurrJnit = 0;
462    Pel  *piIntraLineCur   = piIntraLine;
463    const UInt piIntraLineTopRowOffset = iLeftUnits * (unitHeight - unitWidth);
464
465    if (!bNeighborFlags[0])
466    {
467      // very bottom unit of bottom-left; at least one unit will be valid.
468      {
469        Int   iNext = 1;
470        while (iNext < iTotalUnits && !bNeighborFlags[iNext])
471        {
472          iNext++;
473        }
474        Pel *piIntraLineNext = piIntraLine + ((iNext < iLeftUnits) ? (iNext * unitHeight) : (piIntraLineTopRowOffset + (iNext * unitWidth)));
475        const Pel refSample = *piIntraLineNext;
476        // Pad unavailable samples with new value
477        Int iNextOrTop = std::min<Int>(iNext, iLeftUnits);
478        // fill left column
479        while (iCurrJnit < iNextOrTop)
480        {
481          for (i=0; i<unitHeight; i++)
482          {
483            piIntraLineCur[i] = refSample;
484          }
485          piIntraLineCur += unitHeight;
486          iCurrJnit++;
487        }
488        // fill top row
489        while (iCurrJnit < iNext)
490        {
491          for (i=0; i<unitWidth; i++)
492          {
493            piIntraLineCur[i] = refSample;
494          }
495          piIntraLineCur += unitWidth;
496          iCurrJnit++;
497        }
498      }
499    }
500
501    // pad all other reference samples.
502    while (iCurrJnit < iTotalUnits)
503    {
504      if (!bNeighborFlags[iCurrJnit]) // samples not available
505      {
506        {
507          const Int numSamplesInCurrUnit = (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
508          const Pel refSample = *(piIntraLineCur-1);
509          for (i=0; i<numSamplesInCurrUnit; i++)
510          {
511            piIntraLineCur[i] = refSample;
512          }
513          piIntraLineCur += numSamplesInCurrUnit;
514          iCurrJnit++;
515        }
516      }
517      else
518      {
519        piIntraLineCur += (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
520        iCurrJnit++;
521      }
522    }
523
524    // Copy processed samples
525
526    piIntraLineTemp = piIntraLine + uiHeight + unitWidth - 2;
527    // top left, top and top right samples
528    for (i=0; i<uiWidth; i++)
529    {
530      piIntraTemp[i] = piIntraLineTemp[i];
531    }
532
533    piIntraLineTemp = piIntraLine + uiHeight - 1;
534    for (i=1; i<uiHeight; i++)
535    {
536      piIntraTemp[i*uiWidth] = piIntraLineTemp[-i];
537    }
538  }
539}
540
541Bool TComPrediction::filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
542{
543  Bool bFilter;
544
545  if (!filterIntraReferenceSamples(toChannelType(compID), chFmt, intraReferenceSmoothingDisabled))
546  {
547    bFilter=false;
548  }
549  else
550  {
551    assert(uiTuChWidth>=4 && uiTuChHeight>=4 && uiTuChWidth<128 && uiTuChHeight<128);
552
553    if (uiDirMode == DC_IDX)
554    {
555      bFilter=false; //no smoothing for DC or LM chroma
556    }
557    else
558    {
559      Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX));
560      UInt sizeIndex=g_aucConvertToBit[uiTuChWidth];
561      assert(sizeIndex < MAX_INTRA_FILTER_DEPTHS);
562      bFilter = diff > m_aucIntraFilter[toChannelType(compID)][sizeIndex];
563    }
564  }
565  return bFilter;
566}
567
568Bool isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
569{
570  Bool bAboveLeftFlag;
571  UInt uiPartAboveLeft;
572  TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
573  if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
574  {
575    bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->isIntra( uiPartAboveLeft ) );
576  }
577  else
578  {
579    bAboveLeftFlag = (pcCUAboveLeft ? true : false);
580  }
581  return bAboveLeftFlag;
582}
583
584Int isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
585{
586  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
587  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1;
588  const UInt uiIdxStep = 1;
589  Bool *pbValidFlags = bValidFlags;
590  Int iNumIntra = 0;
591
592  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
593  {
594    UInt uiPartAbove;
595    TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
596    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
597    {
598      if ( pcCUAbove && pcCUAbove->isIntra( uiPartAbove ) )
599      {
600        iNumIntra++;
601        *pbValidFlags = true;
602      }
603      else
604      {
605        *pbValidFlags = false;
606      }
607    }
608    else
609    {
610      if (pcCUAbove)
611      {
612        iNumIntra++;
613        *pbValidFlags = true;
614      }
615      else
616      {
617        *pbValidFlags = false;
618      }
619    }
620    pbValidFlags++;
621  }
622  return iNumIntra;
623}
624
625Int isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
626{
627  const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
628  const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
629  const UInt uiIdxStep = pcCU->getPic()->getNumPartInCtuWidth();
630  Bool *pbValidFlags = bValidFlags;
631  Int iNumIntra = 0;
632
633  for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
634  {
635    UInt uiPartLeft;
636    TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
637    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
638    {
639      if ( pcCULeft && pcCULeft->isIntra( uiPartLeft ) )
640      {
641        iNumIntra++;
642        *pbValidFlags = true;
643      }
644      else
645      {
646        *pbValidFlags = false;
647      }
648    }
649    else
650    {
651      if ( pcCULeft )
652      {
653        iNumIntra++;
654        *pbValidFlags = true;
655      }
656      else
657      {
658        *pbValidFlags = false;
659      }
660    }
661    pbValidFlags--; // opposite direction
662  }
663
664  return iNumIntra;
665}
666
667Int isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
668{
669  const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
670  Bool *pbValidFlags = bValidFlags;
671  Int iNumIntra = 0;
672
673  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
674  {
675    UInt uiPartAboveRight;
676    TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
677    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
678    {
679      if ( pcCUAboveRight && pcCUAboveRight->isIntra( uiPartAboveRight ) )
680      {
681        iNumIntra++;
682        *pbValidFlags = true;
683      }
684      else
685      {
686        *pbValidFlags = false;
687      }
688    }
689    else
690    {
691      if ( pcCUAboveRight )
692      {
693        iNumIntra++;
694        *pbValidFlags = true;
695      }
696      else
697      {
698        *pbValidFlags = false;
699      }
700    }
701    pbValidFlags++;
702  }
703
704  return iNumIntra;
705}
706
707Int isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
708{
709  const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
710  Bool *pbValidFlags = bValidFlags;
711  Int iNumIntra = 0;
712
713  for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
714  {
715    UInt uiPartBelowLeft;
716    TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
717    if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
718    {
719      if ( pcCUBelowLeft && pcCUBelowLeft->isIntra( uiPartBelowLeft ) )
720      {
721        iNumIntra++;
722        *pbValidFlags = true;
723      }
724      else
725      {
726        *pbValidFlags = false;
727      }
728    }
729    else
730    {
731      if ( pcCUBelowLeft )
732      {
733        iNumIntra++;
734        *pbValidFlags = true;
735      }
736      else
737      {
738        *pbValidFlags = false;
739      }
740    }
741    pbValidFlags--; // opposite direction
742  }
743
744  return iNumIntra;
745}
746//! \}
Note: See TracBrowser for help on using the repository browser.