53 const Int bitDepthDelta,
55 const Pel* piRoiOrigin,
57 const Bool* bNeighborFlags,
58 const Int iNumIntraNeighbor,
61 const Int iAboveUnits,
65 const Int iPicStride );
97 m_roiWidth = roiWidth;
98 m_roiHeight = roiHeight;
99 m_patternStride = stride;
100 m_bitDepth = bitDepthLuma;
128 const UInt uiTuWidth2 = uiTuWidth << 1;
129 const UInt uiTuHeight2 = uiTuHeight << 1;
134 const Int iTUWidthInUnits = uiTuWidth / iUnitWidth;
135 const Int iTUHeightInUnits = uiTuHeight / iUnitHeight;
136 const Int iAboveUnits = iTUWidthInUnits << 1;
137 const Int iLeftUnits = iTUHeightInUnits << 1;
140 assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
145 const UInt uiPartIdxLB =
g_auiRasterToZscan[ g_auiZscanToRaster[ uiPartIdxLT ] + ((iTUHeightInUnits - 1) * iPartIdxStride)];
149 Int iNumIntraNeighbor = 0;
152 iNumIntraNeighbor += bNeighborFlags[iLeftUnits] ? 1 : 0;
153 iNumIntraNeighbor +=
isAboveAvailable ( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1) );
154 iNumIntraNeighbor +=
isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, (bNeighborFlags + iLeftUnits + 1 + iTUWidthInUnits ) );
155 iNumIntraNeighbor +=
isLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1) );
156 iNumIntraNeighbor +=
isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, (bNeighborFlags + iLeftUnits - 1 - iTUHeightInUnits) );
158 const UInt uiROIWidth = uiTuWidth2+1;
159 const UInt uiROIHeight = uiTuHeight2+1;
164 std::stringstream ss(stringstream::out);
170 #if O0043_BEST_EFFORT_DECODING
171 const Int bitDepthForChannelInStream = sps.getStreamBitDepth(chType);
172 fillReferenceSamples (bitDepthForChannelInStream, bitDepthForChannelInStream - bitDepthForChannel,
176 piRoiOrigin, piIntraTemp, bNeighborFlags, iNumIntraNeighbor, iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
177 uiROIWidth, uiROIHeight, iPicStride);
181 if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(
MODE_INTRA))
183 ss <<
"###: generating Ref Samples for channel " << compID <<
" and " << rTu.
getRect(compID).
width <<
" x " << rTu.
getRect(compID).
height <<
"\n";
184 for (
UInt y=0; y<uiROIHeight; y++)
187 for (
UInt x=0; x<uiROIWidth; x++)
191 ss << piIntraTemp[y*uiROIWidth + x] <<
", ";
200 if (bFilterRefSamples)
204 Int stride = uiROIWidth;
205 const Pel *piSrcPtr = piIntraTemp + (stride * uiTuHeight2);
212 const Pel bottomLeft = piIntraTemp[stride * uiTuHeight2];
213 const Pel topLeft = piIntraTemp[0];
214 const Pel topRight = piIntraTemp[uiTuWidth2];
216 if (useStrongIntraSmoothing)
218 #if O0043_BEST_EFFORT_DECODING
219 const Int threshold = 1 << (bitDepthForChannelInStream - 5);
221 const Int threshold = 1 << (bitDepthForChannel - 5);
223 const Bool bilinearLeft = abs((bottomLeft + topLeft ) - (2 * piIntraTemp[stride * uiTuHeight])) < threshold;
224 const Bool bilinearAbove = abs((topLeft + topRight) - (2 * piIntraTemp[ uiTuWidth ])) < threshold;
225 if ((uiTuWidth < 32) || (!bilinearLeft) || (!bilinearAbove))
227 useStrongIntraSmoothing =
false;
231 *piDestPtr = *piSrcPtr;
239 if (useStrongIntraSmoothing)
243 for(
UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride)
245 *piDestPtr = (((uiTuHeight2 - i) * bottomLeft) + (i * topLeft) + uiTuHeight) >> shift;
248 piSrcPtr -= stride * (uiTuHeight2 - 1);
252 for(
UInt i=1; i<uiTuHeight2; i++, piDestPtr-=stride, piSrcPtr-=stride)
254 *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[-stride] + 2 ) >> 2;
262 if (useStrongIntraSmoothing)
264 *piDestPtr = piSrcPtr[0];
268 *piDestPtr = ( piSrcPtr[stride] + 2*piSrcPtr[0] + piSrcPtr[1] + 2 ) >> 2;
277 if (useStrongIntraSmoothing)
281 for(
UInt i=1; i<uiTuWidth2; i++, piDestPtr++)
283 *piDestPtr = (((uiTuWidth2 - i) * topLeft) + (i * topRight) + uiTuWidth) >> shift;
286 piSrcPtr += uiTuWidth2 - 1;
290 for(
UInt i=1; i<uiTuWidth2; i++, piDestPtr++, piSrcPtr++)
292 *piDestPtr = ( piSrcPtr[1] + 2*piSrcPtr[0] + piSrcPtr[-1] + 2 ) >> 2;
298 *piDestPtr=*piSrcPtr;
301 if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(
MODE_INTRA))
303 ss <<
"###: filtered result for channel " << compID <<
"\n";
304 for (
UInt y=0; y<uiROIHeight; y++)
307 for (
UInt x=0; x<uiROIWidth; x++)
328 const Int bitDepthDelta,
330 const Pel* piRoiOrigin,
332 const Bool* bNeighborFlags,
333 const Int iNumIntraNeighbor,
335 const Int unitHeight,
336 const Int iAboveUnits,
337 const Int iLeftUnits,
340 const Int iPicStride )
342 const Pel* piRoiTemp;
344 Int iDCValue = 1 << (bitDepth - 1);
345 const Int iTotalUnits = iAboveUnits + iLeftUnits + 1;
347 if (iNumIntraNeighbor == 0)
350 for (i=0; i<uiWidth; i++)
352 piIntraTemp[i] = iDCValue;
354 for (i=1; i<uiHeight; i++)
356 piIntraTemp[i*uiWidth] = iDCValue;
359 else if (iNumIntraNeighbor == iTotalUnits)
362 piRoiTemp = piRoiOrigin - iPicStride - 1;
364 for (i=0; i<uiWidth; i++)
366 #if O0043_BEST_EFFORT_DECODING
367 piIntraTemp[i] = piRoiTemp[i] << bitDepthDelta;
369 piIntraTemp[i] = piRoiTemp[i];
374 piRoiTemp = piRoiOrigin - 1;
376 for (i=1; i<uiHeight; i++)
378 #if O0043_BEST_EFFORT_DECODING
379 piIntraTemp[i*uiWidth] = (*(piRoiTemp)) << bitDepthDelta;
381 piIntraTemp[i*uiWidth] = *(piRoiTemp);
383 piRoiTemp += iPicStride;
389 const Int iTotalSamples = (iLeftUnits * unitHeight) + ((iAboveUnits + 1) * unitWidth);
391 Pel *piIntraLineTemp;
392 const Bool *pbNeighborFlags;
396 for (i=0; i<iTotalSamples; i++)
398 piIntraLine[i] = iDCValue;
402 piRoiTemp = piRoiOrigin - iPicStride - 1;
403 piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight);
404 pbNeighborFlags = bNeighborFlags + iLeftUnits;
405 if (*pbNeighborFlags)
407 #if O0043_BEST_EFFORT_DECODING
408 Pel topLeftVal=piRoiTemp[0] << bitDepthDelta;
410 Pel topLeftVal=piRoiTemp[0];
412 for (i=0; i<unitWidth; i++)
414 piIntraLineTemp[i] = topLeftVal;
419 piRoiTemp += iPicStride;
423 for (j=0; j<iLeftUnits; j++)
425 if (*pbNeighborFlags)
427 for (i=0; i<unitHeight; i++)
429 #if O0043_BEST_EFFORT_DECODING
430 piIntraLineTemp[-i] = piRoiTemp[i*iPicStride] << bitDepthDelta;
432 piIntraLineTemp[-i] = piRoiTemp[i*iPicStride];
436 piRoiTemp += unitHeight*iPicStride;
437 piIntraLineTemp -= unitHeight;
442 piRoiTemp = piRoiOrigin - iPicStride;
444 piIntraLineTemp = piIntraLine + (iLeftUnits * unitHeight) + unitWidth;
445 pbNeighborFlags = bNeighborFlags + iLeftUnits + 1;
446 for (j=0; j<iAboveUnits; j++)
448 if (*pbNeighborFlags)
450 for (i=0; i<unitWidth; i++)
452 #if O0043_BEST_EFFORT_DECODING
453 piIntraLineTemp[i] = piRoiTemp[i] << bitDepthDelta;
455 piIntraLineTemp[i] = piRoiTemp[i];
459 piRoiTemp += unitWidth;
460 piIntraLineTemp += unitWidth;
466 Pel *piIntraLineCur = piIntraLine;
467 const UInt piIntraLineTopRowOffset = iLeftUnits * (unitHeight - unitWidth);
469 if (!bNeighborFlags[0])
474 while (iNext < iTotalUnits && !bNeighborFlags[iNext])
478 Pel *piIntraLineNext = piIntraLine + ((iNext < iLeftUnits) ? (iNext * unitHeight) : (piIntraLineTopRowOffset + (iNext * unitWidth)));
479 const Pel refSample = *piIntraLineNext;
481 Int iNextOrTop = std::min<Int>(iNext, iLeftUnits);
483 while (iCurrJnit < iNextOrTop)
485 for (i=0; i<unitHeight; i++)
487 piIntraLineCur[i] = refSample;
489 piIntraLineCur += unitHeight;
493 while (iCurrJnit < iNext)
495 for (i=0; i<unitWidth; i++)
497 piIntraLineCur[i] = refSample;
499 piIntraLineCur += unitWidth;
506 while (iCurrJnit < iTotalUnits)
508 if (!bNeighborFlags[iCurrJnit])
511 const Int numSamplesInCurrUnit = (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
512 const Pel refSample = *(piIntraLineCur-1);
513 for (i=0; i<numSamplesInCurrUnit; i++)
515 piIntraLineCur[i] = refSample;
517 piIntraLineCur += numSamplesInCurrUnit;
523 piIntraLineCur += (iCurrJnit >= iLeftUnits) ? unitWidth : unitHeight;
530 piIntraLineTemp = piIntraLine + uiHeight + unitWidth - 2;
532 for (i=0; i<uiWidth; i++)
534 piIntraTemp[i] = piIntraLineTemp[i];
537 piIntraLineTemp = piIntraLine + uiHeight - 1;
538 for (i=1; i<uiHeight; i++)
540 piIntraTemp[i*uiWidth] = piIntraLineTemp[-i];
555 assert(uiTuChWidth>=4 && uiTuChHeight>=4 && uiTuChWidth<128 && uiTuChHeight<128);
575 UInt uiPartAboveLeft;
579 bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->
isIntra( uiPartAboveLeft ) );
583 bAboveLeftFlag = (pcCUAboveLeft ?
true :
false);
585 return bAboveLeftFlag;
590 const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
591 const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1;
592 const UInt uiIdxStep = 1;
593 Bool *pbValidFlags = bValidFlags;
596 for (
UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
602 if ( pcCUAbove && pcCUAbove->
isIntra( uiPartAbove ) )
605 *pbValidFlags =
true;
609 *pbValidFlags =
false;
617 *pbValidFlags =
true;
621 *pbValidFlags =
false;
631 const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
632 const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1;
634 Bool *pbValidFlags = bValidFlags;
637 for (
UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep )
643 if ( pcCULeft && pcCULeft->
isIntra( uiPartLeft ) )
646 *pbValidFlags =
true;
650 *pbValidFlags =
false;
658 *pbValidFlags =
true;
662 *pbValidFlags =
false;
673 const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
674 Bool *pbValidFlags = bValidFlags;
677 for (
UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
679 UInt uiPartAboveRight;
683 if ( pcCUAboveRight && pcCUAboveRight->
isIntra( uiPartAboveRight ) )
686 *pbValidFlags =
true;
690 *pbValidFlags =
false;
695 if ( pcCUAboveRight )
698 *pbValidFlags =
true;
702 *pbValidFlags =
false;
714 Bool *pbValidFlags = bValidFlags;
717 for (
UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ )
719 UInt uiPartBelowLeft;
723 if ( pcCUBelowLeft && pcCUBelowLeft->
isIntra( uiPartBelowLeft ) )
726 *pbValidFlags =
true;
730 *pbValidFlags =
false;
738 *pbValidFlags =
true;
742 *pbValidFlags =
false;
SChar g_aucConvertToBit[MAX_CU_SIZE+1]
Bool getUseStrongIntraSmoothing() const
static const Int HOR_IDX
index for intra HORIZONTAL mode
prediction class (header)
const TComDataCU * getPUBelowLeft(UInt &uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset=1, Bool bEnforceSliceRestriction=true) const
returns CU and part index of the PU left of the lefthand column of the current uiCurrPartUnitIdx of t...
static const UInt MAX_INTRA_FILTER_DEPTHS
Void initPattern(Pel *piY, Int roiWidth, Int roiHeight, Int stride, Int bitDepthLuma, Int roiPosX, Int roiPosY)
set parameters from Pel buffers for accessing neighbouring pixels
Int m_tileRightBottomPelPosY
Int isBelowLeftAvailable(const TComDataCU *pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags)
static Bool filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled)
static const UChar m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS]
Int isAboveRightAvailable(const TComDataCU *pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags)
const TComDataCU * getPUAboveRight(UInt &uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset=1, Bool bEnforceSliceRestriction=true) const
returns CU and part index of the PU above the top row of the current uiCurrPartUnitIdx of the CU...
UInt getZorderIdxInCtu() const
TComPicYuv * getPicYuvRec()
UInt GetAbsPartIdxTU() const
#define O0043_BEST_EFFORT_DECODING
0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort d...
Int isLeftAvailable(const TComDataCU *pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags)
UInt getMaxTotalCUDepth() const
UInt getNumPartInCtuWidth() const
Int getStride(const ComponentID id) const
UInt getComponentScaleY(const ComponentID id) const
UInt getComponentScaleX(const ComponentID id) const
Bool isIntra(UInt uiPartIdx) const
const TComDataCU * getPULeft(UInt &uiLPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true, Bool bEnforceTileRestriction=true) const
static const Int VER_IDX
index for intra VERTICAL mode
Bool isAboveLeftAvailable(const TComDataCU *pcCU, UInt uiPartIdxLT)
constrained intra prediction
#define DEBUG_STRING_APPEND(str1, str2)
static const Int DC_IDX
index for intra DC mode
Int getBitDepth(ChannelType type) const
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
const TComRectangle & getRect(const ComponentID compID) const
UInt g_auiZscanToRaster[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
const TComPPS * getPPS() const
UInt g_auiRasterToZscan[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
const TComDataCU * getPUAboveLeft(UInt &uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true) const
#define DEBUG_STRING_FN_DECLARE(name)
neighbouring pixel access classes (header)
const TComDataCU * getPUAbove(UInt &uiAPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true, Bool planarAtCTUBoundary=false, Bool bEnforceTileRestriction=true) const
static const Int MAX_CU_SIZE
= 1<<(MAX_CU_DEPTH)
Pel * getAddr(const ComponentID ch)
Int m_tileRightBottomPelPosX
Void initIntraPatternChType(TComTU &rTu, const ComponentID compID, const Bool bFilterRefSamples)
set parameters from CU data for accessing intra data
Int isAboveAvailable(const TComDataCU *pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags)
static const Int MAX_NUM_PART_IDXS_IN_CTU_WIDTH
maximum number of partition indices across the width of a CTU (or height of a CTU) ...
Bool getConstrainedIntraPred() const
CU data structure (header)
Void fillReferenceSamples(const Int bitDepth, const Pel *piRoiOrigin, Pel *piIntraTemp, const Bool *bNeighborFlags, const Int iNumIntraNeighbor, const Int unitWidth, const Int unitHeight, const Int iAboveUnits, const Int iLeftUnits, const UInt uiWidth, const UInt uiHeight, const Int iPicStride)
padding of unavailable reference samples for intra prediction
Pel * m_piYuvExt[MAX_NUM_COMPONENT][NUM_PRED_BUF]
Defines types and objects for environment-variable-based debugging and feature control.
UInt getMaxCUWidth() const
const TComSPS * getSPS() const
Void setTileBorders(Int tileLeftTopPelPosX, Int tileLeftTopPelPosY, Int tileRightBottomPelPosX, Int tileRightBottomPelPosY)