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

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

port rev 4324 (g_uiMaxDepth, g_uiAddDepth)

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