53 #define DEFAULT_INTRA_TC_OFFSET 2
61 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,8,9,10,11,13,14,16,18,20,22,24
66 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64
74 : m_uiNumPartitions(0)
75 , m_bLFCrossTileBoundary(true)
178 UInt uiQNumParts = uiCurNumParts>>2;
181 if( pcCU->
getDepth(uiAbsZorderIdx) > uiDepth )
183 for (
UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++, uiAbsZorderIdx+=uiQNumParts )
189 xDeblockCU( pcCU, uiAbsZorderIdx, uiDepth+1, edgeDir );
202 for(
UInt uiPartIdx = uiAbsZorderIdx; uiPartIdx < uiAbsZorderIdx + uiCurNumParts; uiPartIdx++ )
205 if( uiPelsInPart == 4 )
207 uiBSCheck = (edgeDir ==
EDGE_VER && uiPartIdx%2 == 0) || (edgeDir ==
EDGE_HOR && (uiPartIdx-((uiPartIdx>>2)<<2))/2 == 0);
227 for (
Int iEdge = 0; iEdge < uiSizeInPU ; iEdge+=PartIdxIncr)
247 UInt uiWidthInBaseUnits,
248 UInt uiHeightInBaseUnits,
251 if ( uiWidthInBaseUnits == 0 )
255 if ( uiHeightInBaseUnits == 0 )
259 const UInt uiNumElem = edgeDir ==
EDGE_VER ? uiHeightInBaseUnits : uiWidthInBaseUnits;
260 assert( uiNumElem > 0 );
261 assert( uiWidthInBaseUnits > 0 );
262 assert( uiHeightInBaseUnits > 0 );
263 for(
UInt ui = 0; ui < uiNumElem; ui++ )
265 const UInt uiBsIdx =
xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdgeIdx, ui, rect );
304 const UInt uiHWidthInBaseUnits = uiWidthInBaseUnits >> 1;
305 const UInt uiHHeightInBaseUnits = uiHeightInBaseUnits >> 1;
306 const UInt uiQWidthInBaseUnits = uiWidthInBaseUnits >> 2;
307 const UInt uiQHeightInBaseUnits = uiHeightInBaseUnits >> 2;
383 if ( pcTempCU !=
NULL )
405 if ( pcTempCU !=
NULL )
422 const UInt uiPartQ = uiAbsPartIdx4x4BlockWithinCtu;
448 UInt nsPartQ = uiPartQ;
449 UInt nsPartP = uiPartP;
491 if ( ((piRefP0==piRefQ0)&&(piRefP1==piRefQ1)) || ((piRefP0==piRefQ1)&&(piRefP1==piRefQ0)) )
493 if ( piRefP0 != piRefP1 )
495 if ( piRefP0 == piRefQ0 )
497 uiBs = ((abs(pcMvQ0.
getHor() - pcMvP0.
getHor()) >= 4) ||
504 uiBs = ((abs(pcMvQ1.
getHor() - pcMvP0.
getHor()) >= 4) ||
512 uiBs = ((abs(pcMvQ0.
getHor() - pcMvP0.
getHor()) >= 4) ||
546 uiBs = ((piRefP0 != piRefQ0) ||
553 m_aapucBS[edgeDir][uiAbsPartIdx4x4BlockWithinCtu] = uiBs;
561 Pel *piTmpSrc = piSrc;
574 UInt uiBsAbsIdx = 0, uiBs = 0;
575 Int iOffset, iSrcStep;
578 Bool bPartPNoFilter =
false;
579 Bool bPartQNoFilter =
false;
591 piTmpSrc += iEdge*uiPelsInPart;
597 piTmpSrc += iEdge*uiPelsInPart*iStride;
600 const Int iBitdepthScale = 1 << (bitDepthLuma-8);
602 for (
UInt iIdx = 0; iIdx < uiNumParts; iIdx++ )
604 uiBsAbsIdx =
xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdge, iIdx);
608 iQP_Q = pcCU->
getQP( uiBsAbsIdx );
609 uiPartQIdx = uiBsAbsIdx;
620 iQP_P = pcCUP->
getQP(uiPartPIdx);
621 iQP = (iQP_P + iQP_Q + 1) >> 1;
628 Int iSideThreshold = (iBeta+(iBeta>>1))>>3;
629 Int iThrCut = iTc*10;
632 UInt uiBlocksInPart = uiPelsInPart / 4 ? uiPelsInPart / 4 : 1;
633 for (
UInt iBlkIdx = 0; iBlkIdx<uiBlocksInPart; iBlkIdx ++)
635 Int dp0 =
xCalcDP( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+0), iOffset);
636 Int dq0 =
xCalcDQ( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+0), iOffset);
637 Int dp3 =
xCalcDP( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+3), iOffset);
638 Int dq3 =
xCalcDQ( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+3), iOffset);
646 if (bPCMFilter || ppsTransquantBypassEnabledFlag)
649 bPartPNoFilter = (bPCMFilter && pcCUP->
getIPCMFlag(uiPartPIdx));
650 bPartQNoFilter = (bPCMFilter && pcCUQ->
getIPCMFlag(uiPartQIdx));
653 bPartPNoFilter = bPartPNoFilter || (pcCUP->
isLosslessCoded(uiPartPIdx) );
654 bPartQNoFilter = bPartQNoFilter || (pcCUQ->
isLosslessCoded(uiPartQIdx) );
659 Bool bFilterP = (dp < iSideThreshold);
660 Bool bFilterQ = (dq < iSideThreshold);
663 &&
xUseStrongFiltering( iOffset, 2*d3, iBeta, iTc, piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+3));
667 xPelFilterLuma( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+i), iOffset, iTc, sw, bPartPNoFilter, bPartQNoFilter, iThrCut, bFilterP, bFilterQ, bitDepthLuma);
692 Int iOffset, iSrcStep;
698 Bool bPartPNoFilter =
false;
699 Bool bPartQNoFilter =
false;
725 Pel* piTmpSrcCb = piSrcCb;
726 Pel* piTmpSrcCr = piSrcCr;
732 piTmpSrcCb += iEdge*uiPelsInPartChromaH;
733 piTmpSrcCr += iEdge*uiPelsInPartChromaH;
734 uiLoopLength=uiPelsInPartChromaV;
740 piTmpSrcCb += iEdge*iStride*uiPelsInPartChromaV;
741 piTmpSrcCr += iEdge*iStride*uiPelsInPartChromaV;
742 uiLoopLength=uiPelsInPartChromaH;
747 for (
UInt iIdx = 0; iIdx < uiNumParts; iIdx++ )
749 uiBsAbsIdx =
xCalcBsIdx( pcCU, uiAbsZorderIdx, edgeDir, iEdge, iIdx);
754 iQP_Q = pcCU->
getQP( uiBsAbsIdx );
755 UInt uiPartQIdx = uiBsAbsIdx;
769 iQP_P = pcCUP->
getQP(uiPartPIdx);
774 bPartPNoFilter = (bPCMFilter && pcCUP->
getIPCMFlag(uiPartPIdx));
775 bPartQNoFilter = (bPCMFilter && pcCUQ->
getIPCMFlag(uiPartQIdx));
778 bPartPNoFilter = bPartPNoFilter || (pcCUP->
isLosslessCoded(uiPartPIdx));
779 bPartQNoFilter = bPartQNoFilter || (pcCUQ->
isLosslessCoded(uiPartQIdx));
782 for (
UInt chromaIdx = 0; chromaIdx < 2; chromaIdx++ )
785 Pel* piTmpSrcChroma = (chromaIdx == 0) ? piTmpSrcCb : piTmpSrcCr;
787 iQP = ((iQP_P + iQP_Q + 1) >> 1) + chromaQPOffset;
807 for (
UInt uiStep = 0; uiStep < uiLoopLength; uiStep++ )
809 xPelFilterChroma( piTmpSrcChroma + iSrcStep*(uiStep+iIdx*uiLoopLength), iOffset, iTc , bPartPNoFilter, bPartQNoFilter, bitDepthChroma);
835 Pel m3 = piSrc[-iOffset];
836 Pel m5 = piSrc[ iOffset];
837 Pel m2 = piSrc[-iOffset*2];
838 Pel m6 = piSrc[ iOffset*2];
839 Pel m1 = piSrc[-iOffset*3];
840 Pel m7 = piSrc[ iOffset*3];
841 Pel m0 = piSrc[-iOffset*4];
845 piSrc[-iOffset] =
Clip3(m3-2*tc, m3+2*tc, ((m1 + 2*m2 + 2*m3 + 2*m4 + m5 + 4) >> 3));
846 piSrc[0] =
Clip3(m4-2*tc, m4+2*tc, ((m2 + 2*m3 + 2*m4 + 2*m5 + m6 + 4) >> 3));
847 piSrc[-iOffset*2] =
Clip3(m2-2*tc, m2+2*tc, ((m1 + m2 + m3 + m4 + 2)>>2));
848 piSrc[ iOffset] =
Clip3(m5-2*tc, m5+2*tc, ((m3 + m4 + m5 + m6 + 2)>>2));
849 piSrc[-iOffset*3] =
Clip3(m1-2*tc, m1+2*tc, ((2*m0 + 3*m1 + m2 + m3 + m4 + 4 )>>3));
850 piSrc[ iOffset*2] =
Clip3(m6-2*tc, m6+2*tc, ((m3 + m4 + m5 + 3*m6 + 2*m7 +4 )>>3));
855 delta = (9*(m4-m3) -3*(m5-m2) + 8)>>4 ;
857 if ( abs(delta) < iThrCut )
859 delta =
Clip3(-tc, tc, delta);
860 piSrc[-iOffset] =
ClipBD((m3+delta), bitDepthLuma);
861 piSrc[0] =
ClipBD((m4-delta), bitDepthLuma);
866 Int delta1 =
Clip3(-tc2, tc2, (( ((m1+m3+1)>>1)- m2+delta)>>1));
867 piSrc[-iOffset*2] =
ClipBD((m2+delta1), bitDepthLuma);
871 Int delta2 =
Clip3(-tc2, tc2, (( ((m6+m4+1)>>1)- m5-delta)>>1));
872 piSrc[ iOffset] =
ClipBD((m5+delta2), bitDepthLuma);
879 piSrc[-iOffset] = m3;
880 piSrc[-iOffset*2] = m2;
881 piSrc[-iOffset*3] = m1;
886 piSrc[ iOffset] = m5;
887 piSrc[ iOffset*2] = m6;
906 Pel m3 = piSrc[-iOffset];
907 Pel m5 = piSrc[ iOffset];
908 Pel m2 = piSrc[-iOffset*2];
910 delta =
Clip3(-tc,tc, (((( m4 - m3 ) << 2 ) + m2 - m5 + 4 ) >> 3) );
911 piSrc[-iOffset] =
ClipBD((m3+delta), bitDepthChroma);
912 piSrc[0] =
ClipBD((m4-delta), bitDepthChroma);
916 piSrc[-iOffset] = m3;
936 Pel m3 = piSrc[-offset];
937 Pel m7 = piSrc[ offset*3];
938 Pel m0 = piSrc[-offset*4];
940 Int d_strong = abs(m0-m3) + abs(m7-m4);
942 return ( (d_strong < (beta>>3)) && (d<(beta>>2)) && ( abs(m3-m4) < ((tc*5+1)>>1)) );
947 return abs( piSrc[-iOffset*3] - 2*piSrc[-iOffset*2] + piSrc[-iOffset] ) ;
952 return abs( piSrc[0] - 2*piSrc[iOffset] + piSrc[iOffset*2] );
Bool getPCMFilterDisableFlag() const
Void create(UInt uiMaxCUDepth)
Int getRefIdx(Int iIdx) const
SChar * getPartitionSize()
__inline Int xCalcDQ(Pel *piSrc, Int iOffset)
deblocking filter (header)
UInt getNumberOfCtusInFrame() const
picture class (symbol + YUV buffers)
LFCUParam m_stLFCUParam
status structure
Int getStride(const ComponentID id) const
UChar * getTransformIdx()
Void xSetEdgefilterMultiple(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir, Int iEdgeIdx, Bool bValue, UInt uiWidthInBaseUnits=0, UInt uiHeightInBaseUnits=0, const TComRectangle *rect=0)
slice header and SPS class (header)
Bool * m_aapbEdgeFilter[NUM_EDGE_DIR]
UInt getNumPartitionsInCtu() const
#define DEBLOCK_SMALLEST_BLOCK
symmetric motion partition, 2Nx N
Int getDeblockingFilterBetaOffsetDiv2() const
Bool bLeftEdge
indicates left edge
UInt getMaxCUHeight() const
T ClipBD(const T x, const Int bitDepth)
UChar getCbf(UInt uiIdx, ComponentID eType) const
Int getDeblockingFilterTcOffsetDiv2() const
Bool nextSection(const TComTU &parent)
Void xSetEdgefilterTU(TComTU &rTu)
Bool getTransquantBypassEnabledFlag() const
__inline Int xCalcDP(Pel *piSrc, Int iOffset)
Bool m_bLFCrossTileBoundary
UInt getNumPartInCtuHeight() const
TComPicYuv * getPicYuvRec()
UInt GetAbsPartIdxTU() const
Bool bInternalEdge
indicates internal edge
UInt getMaxTotalCUDepth() const
UInt getNumPartInCtuWidth() const
virtual ~TComLoopFilter()
symmetric motion partition, 2Nx2N
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
Bool isLosslessCoded(UInt absPartIdx) const
asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)
asymmetric motion partition, (3N/2)x2N + ( N/2)x2N
static const UChar sm_betaTable[52]
UInt getPicHeightInLumaSamples() const
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
static const UChar sm_tcTable[54]
TComMv const & getMv(Int iIdx) const
Int getBitDepth(ChannelType type) const
__inline Void xPelFilterLuma(Pel *piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma)
Bool getLFCrossSliceBoundaryFlag()
Int getComponentScaleX(const ComponentID id) const
motion vector class (header)
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
__inline Void xPelFilterChroma(Pel *piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma)
const TComRectangle & getRect(const ComponentID compID) const
Void xSetEdgefilterPU(TComDataCU *pcCU, UInt uiAbsZorderIdx)
UInt xCalcBsIdx(TComDataCU *pcCU, UInt absZIdxInCtu, DeblockEdgeDir edgeDir, Int iEdgeIdx, Int iBaseUnitIdx, const struct TComRectangle *rect=0)
UInt g_auiZscanToRaster[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
const TComPPS * getPPS() const
UInt getPicWidthInLumaSamples() const
Void loopFilterPic(TComPic *pcPic)
picture-level deblocking filter
ChromaFormat getChromaFormat() const
Void setCfg(Bool bLFCrossTileBoundary)
set configuration
asymmetric motion partition, ( N/2)x2N + (3N/2)x2N
TComDataCU * getCtu(UInt ctuRsAddr)
const TComDataCU * getPUAbove(UInt &uiAPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true, Bool planarAtCTUBoundary=false, Bool bEnforceTileRestriction=true) const
Bool bTopEdge
indicates top edge
__inline Bool xUseStrongFiltering(Int offset, Int d, Int beta, Int tc, Pel *piSrc)
Int getQpOffset(ComponentID compID) const
#define DEFAULT_INTRA_TC_OFFSET
Default intra TC offset.
Pel * getAddr(const ComponentID ch)
Void xSetLoopfilterParam(TComDataCU *pcCU, UInt uiAbsZorderIdx)
TComCUMvField * getCUMvField(RefPicList e)
static const Int chromaQPMappingTableSize
basic motion vector class
UChar * m_aapucBS[NUM_EDGE_DIR]
Bs for [Ver/Hor][Y/U/V][Blk_Idx].
Int getComponentScaleY(const ComponentID id) const
UInt GetAbsPartIdxCU() const
Void xGetBoundaryStrengthSingle(TComDataCU *pCtu, DeblockEdgeDir edgeDir, UInt uiPartIdx)
asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)
symmetric motion partition, Nx N
UInt g_auiRasterToPelX[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
Bool getDeblockingFilterDisable() const
TComPic * getRefPic(RefPicList e, Int iRefIdx)
Void xEdgeFilterLuma(TComDataCU *const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge)
symmetric motion partition, Nx2N
Void xEdgeFilterChroma(TComDataCU *const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge)
UInt g_auiRasterToPelY[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
UInt GetTransformDepthTotal() const
UInt getMaxCUWidth() const
const TComSPS * getSPS() const
ChromaFormat getChromaFormat() const
Void xDeblockCU(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir)
CU-level deblocking function.