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

Last change on this file since 1288 was 1287, checked in by seregin, 10 years ago

port rev 4322 (g_bitDepth)

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