HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TComLoopFilter.h
Go to the documentation of this file.
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-2017, 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 
38 #ifndef __TCOMLOOPFILTER__
39 #define __TCOMLOOPFILTER__
40 
41 #include "CommonDef.h"
42 #include "TComPic.h"
43 
46 
47 #define DEBLOCK_SMALLEST_BLOCK 8
48 
49 // ====================================================================================================================
50 // Class definition
51 // ====================================================================================================================
52 
55 {
56 private:
57 
62 
64 
65 protected:
67  Void xDeblockCU ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir );
68 
69  // set / get functions
70  Void xSetLoopfilterParam ( TComDataCU* pcCU, UInt uiAbsZorderIdx );
71  // filtering functions
72  Void xSetEdgefilterTU ( TComTU &rTu );
73  Void xSetEdgefilterPU ( TComDataCU* pcCU, UInt uiAbsZorderIdx );
74  Void xGetBoundaryStrengthSingle ( TComDataCU* pCtu, DeblockEdgeDir edgeDir, UInt uiPartIdx );
75  UInt xCalcBsIdx ( TComDataCU* pcCU, UInt absZIdxInCtu, DeblockEdgeDir edgeDir, Int iEdgeIdx, Int iBaseUnitIdx, const struct TComRectangle *rect=NULL )
76  {
77  TComPic* const pcPic = pcCU->getPic();
78  const UInt ctuWidthInBaseUnits = pcPic->getNumPartInCtuWidth();
79  Int rasterOffsetTU=0;
80  if (rect != NULL)
81  {
82  const UInt minCuWidth =pcPic->getMinCUWidth();
83  const UInt minCuHeight=pcPic->getMinCUHeight();
84  rasterOffsetTU = rect->x0/minCuWidth + (rect->y0/minCuHeight)*ctuWidthInBaseUnits;
85  }
86  if( edgeDir == EDGE_VER )
87  {
88  return g_auiRasterToZscan[g_auiZscanToRaster[absZIdxInCtu] + iBaseUnitIdx * ctuWidthInBaseUnits + iEdgeIdx + rasterOffsetTU ];
89  }
90  else
91  {
92  return g_auiRasterToZscan[g_auiZscanToRaster[absZIdxInCtu] + iEdgeIdx * ctuWidthInBaseUnits + iBaseUnitIdx + rasterOffsetTU ];
93  }
94  }
95 
97  UInt uiAbsZorderIdx,
98  UInt uiDepth,
99  DeblockEdgeDir edgeDir,
100  Int iEdgeIdx,
101  Bool bValue,
102  UInt uiWidthInBaseUnits = 0,
103  UInt uiHeightInBaseUnits = 0,
104  const TComRectangle *rect = 0
105  );
106 
107  Void xEdgeFilterLuma ( TComDataCU* const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge );
108  Void xEdgeFilterChroma ( TComDataCU* const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge );
109 
110  __inline Void xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma);
111  __inline Void xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma);
112 
113 
114  __inline Bool xUseStrongFiltering( Int offset, Int d, Int beta, Int tc, Pel* piSrc);
115  __inline Int xCalcDP( Pel* piSrc, Int iOffset);
116  __inline Int xCalcDQ( Pel* piSrc, Int iOffset);
117 
118  static const UChar sm_tcTable[54];
119  static const UChar sm_betaTable[52];
120 
121 public:
122  TComLoopFilter();
123  virtual ~TComLoopFilter();
124 
125  Void create ( UInt uiMaxCUDepth );
126  Void destroy ();
127 
129  Void setCfg( Bool bLFCrossTileBoundary );
130 
132  Void loopFilterPic( TComPic* pcPic );
133 
134  static Int getBeta( Int qp )
135  {
136  Int indexB = Clip3( 0, MAX_QP, qp );
137  return sm_betaTable[ indexB ];
138  }
139 };
140 
142 
143 #endif
Void create(UInt uiMaxCUDepth)
CU data structure class.
Definition: TComDataCU.h:64
__inline Int xCalcDQ(Pel *piSrc, Int iOffset)
picture class (symbol + YUV buffers)
Definition: TComPic.h:56
Defines version information, constants and small in-line functions.
void Void
Definition: TypeDef.h:203
LFCUParam m_stLFCUParam
status structure
Void xSetEdgefilterMultiple(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir, Int iEdgeIdx, Bool bValue, UInt uiWidthInBaseUnits=0, UInt uiHeightInBaseUnits=0, const TComRectangle *rect=0)
#define NULL
Definition: CommonDef.h:107
Bool * m_aapbEdgeFilter[NUM_EDGE_DIR]
unsigned int UInt
Definition: TypeDef.h:212
Short Pel
pixel type
Definition: TypeDef.h:249
deblocking filter class
picture class (header)
static Int getBeta(Int qp)
Void xSetEdgefilterTU(TComTU &rTu)
parameters for deblocking filter
Definition: TypeDef.h:798
__inline Int xCalcDP(Pel *piSrc, Int iOffset)
UInt getMinCUWidth() const
Definition: TComPic.h:133
Bool m_bLFCrossTileBoundary
UInt getNumPartInCtuWidth() const
Definition: TComPic.h:128
virtual ~TComLoopFilter()
bool Bool
Definition: TypeDef.h:204
UInt getMinCUHeight() const
Definition: TComPic.h:134
static const UChar sm_betaTable[52]
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
Definition: CommonDef.h:252
static const UChar sm_tcTable[54]
__inline Void xPelFilterLuma(Pel *piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma)
unsigned char UChar
Definition: TypeDef.h:208
__inline Void xPelFilterChroma(Pel *piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma)
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]
Definition: TComRom.cpp:284
UInt g_auiRasterToZscan[MAX_NUM_PART_IDXS_IN_CTU_WIDTH *MAX_NUM_PART_IDXS_IN_CTU_WIDTH]
Definition: TComRom.cpp:285
Void loopFilterPic(TComPic *pcPic)
picture-level deblocking filter
Void setCfg(Bool bLFCrossTileBoundary)
set configuration
TComPic * getPic()
Definition: TComDataCU.h:200
Definition: TComTU.h:48
__inline Bool xUseStrongFiltering(Int offset, Int d, Int beta, Int tc, Pel *piSrc)
Void xSetLoopfilterParam(TComDataCU *pcCU, UInt uiAbsZorderIdx)
int Int
Definition: TypeDef.h:211
UChar * m_aapucBS[NUM_EDGE_DIR]
Bs for [Ver/Hor][Y/U/V][Blk_Idx].
DeblockEdgeDir
Definition: TypeDef.h:340
Void xGetBoundaryStrengthSingle(TComDataCU *pCtu, DeblockEdgeDir edgeDir, UInt uiPartIdx)
static const Int MAX_QP
Definition: CommonDef.h:126
Void xEdgeFilterLuma(TComDataCU *const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge)
Void xEdgeFilterChroma(TComDataCU *const pcCU, const UInt uiAbsZorderIdx, const UInt uiDepth, const DeblockEdgeDir edgeDir, const Int iEdge)
Void xDeblockCU(TComDataCU *pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir)
CU-level deblocking function.