source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibCommon/TComPattern.cpp @ 1200

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

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

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