1 | |
---|
2 | |
---|
3 | /** \file TComPrediction.h |
---|
4 | \brief prediction class (header) |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __TCOMPREDICTION__ |
---|
8 | #define __TCOMPREDICTION__ |
---|
9 | |
---|
10 | |
---|
11 | // Include files |
---|
12 | #include "TComPic.h" |
---|
13 | #include "TComMotionInfo.h" |
---|
14 | #include "TComPattern.h" |
---|
15 | #include "TComTrQuant.h" |
---|
16 | #include "TComPredFilter.h" |
---|
17 | #ifdef WEIGHT_PRED |
---|
18 | #include "TComWeightPrediction.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | // ==================================================================================================================== |
---|
22 | // Class definition |
---|
23 | // ==================================================================================================================== |
---|
24 | |
---|
25 | /// prediction class |
---|
26 | class TComPrediction : public TComPredFilter |
---|
27 | #ifdef WEIGHT_PRED |
---|
28 | , public TComWeightPrediction |
---|
29 | #endif |
---|
30 | { |
---|
31 | protected: |
---|
32 | Int* m_piYuvExt; |
---|
33 | Int m_iYuvExtStride; |
---|
34 | Int m_iYuvExtHeight; |
---|
35 | |
---|
36 | TComYuv m_acYuvPred[2]; |
---|
37 | TComYuv m_cYuvPredTemp; |
---|
38 | TComYuv m_cYuvExt; |
---|
39 | |
---|
40 | #if LM_CHROMA |
---|
41 | Pel* m_pLumaRecBuffer; // array for downsampled reconstructed luma sample |
---|
42 | Int m_iLumaRecStride; |
---|
43 | UInt m_uiaShift[ 65 ]; // Table for multiplication to substitue of division operation |
---|
44 | #endif |
---|
45 | |
---|
46 | Void xPredIntraAng ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable ); |
---|
47 | #if ADD_PLANAR_MODE |
---|
48 | #if REFERENCE_SAMPLE_PADDING |
---|
49 | Void xPredIntraPlanar ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height ); |
---|
50 | #else |
---|
51 | Void xPredIntraPlanar ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, Bool blkAboveAvailable, Bool blkLeftAvailable ); |
---|
52 | #endif |
---|
53 | #endif |
---|
54 | |
---|
55 | // motion compensation functions |
---|
56 | #if HIGH_ACCURACY_BI |
---|
57 | Void xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi=false ); |
---|
58 | #else |
---|
59 | Void xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ); |
---|
60 | #endif |
---|
61 | Void xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap ); |
---|
62 | Void xPredInterPrdDepthMap ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ); // 0:std, 1:bilin, 2:nearest neighbour |
---|
63 | Void xPredInterLumaBlk ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ); |
---|
64 | Void xPredInterChromaBlk ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ); |
---|
65 | Void xWeightedAverage ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst ); |
---|
66 | Void xDCTIF_FilterC ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride,Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac); |
---|
67 | |
---|
68 | #if HIGH_ACCURACY_BI |
---|
69 | Void xPredInterLumaBlk_ha ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ); |
---|
70 | Void xPredInterChromaBlk_ha ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight, TComYuv*& rpcYuv ); |
---|
71 | Void xDCTIF_FilterC_ha ( Pel* piRefC, Int iRefStride,Pel* piDstC,Int iDstStride,Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac); |
---|
72 | #endif |
---|
73 | |
---|
74 | #if HHI_DMM_INTRA |
---|
75 | Void xPredIntraWedgeFull ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 ); |
---|
76 | Void xPredIntraWedgeDir ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 ); |
---|
77 | |
---|
78 | Void xPredIntraWedgeTex ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 ); |
---|
79 | Void xPredIntraContourTex ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1 = 0, Int iDeltaDC2 = 0 ); |
---|
80 | |
---|
81 | Void xGetBlockOffset ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY ); |
---|
82 | Bool xGetWedgeIntraDirPredData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY ); |
---|
83 | Void xGetWedgeIntraDirStartEnd ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd = 0 ); |
---|
84 | Void xDeltaDCQuantScaleUp ( TComDataCU* pcCU, Int& riDeltaDC ); |
---|
85 | #endif |
---|
86 | |
---|
87 | #if LM_CHROMA |
---|
88 | Void xGetRecPixels ( TComPattern* pcPattern, Pel* pRecSrc, Int iRecSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth0, UInt uiHeight0 ); |
---|
89 | Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 ); |
---|
90 | #endif |
---|
91 | |
---|
92 | #if MN_DC_PRED_FILTER |
---|
93 | Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight ); |
---|
94 | #endif |
---|
95 | |
---|
96 | public: |
---|
97 | TComPrediction(); |
---|
98 | virtual ~TComPrediction(); |
---|
99 | |
---|
100 | Void initTempBuff(); |
---|
101 | |
---|
102 | // inter |
---|
103 | Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false ); |
---|
104 | |
---|
105 | // motion vector prediction |
---|
106 | Void getMvPredAMVP ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred ); |
---|
107 | |
---|
108 | // Angular Intra |
---|
109 | Void predIntraLumaAng ( TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ); |
---|
110 | Void predIntraChromaAng ( TComPattern* pcTComPattern, Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft ); |
---|
111 | |
---|
112 | #if HHI_DMM_INTRA |
---|
113 | Void predIntraLumaDMM ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder ); |
---|
114 | |
---|
115 | UInt getBestContinueWedge ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd = 0 ); |
---|
116 | Void getBestContourFromText ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge ); |
---|
117 | |
---|
118 | Void getWedgePredDCs ( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft ); |
---|
119 | |
---|
120 | Bool getWedgeListIdx ( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe ); |
---|
121 | |
---|
122 | UInt getBestWedgeFromText ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist = WedgeDist_SAD ); |
---|
123 | Void calcWedgeDCs ( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 ); |
---|
124 | Void assignWedgeDCs2Pred ( TComWedgelet* pcWedgelet, Pel* piPred, UInt uiStride, Int iDC1, Int iDC2 ); |
---|
125 | #endif |
---|
126 | |
---|
127 | Pel predIntraGetPredValDC ( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft ); |
---|
128 | |
---|
129 | Int* getPredicBuf() { return m_piYuvExt; } |
---|
130 | Int getPredicBufWidth() { return m_iYuvExtStride; } |
---|
131 | Int getPredicBufHeight() { return m_iYuvExtHeight; } |
---|
132 | |
---|
133 | #if LM_CHROMA |
---|
134 | Void predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId ); |
---|
135 | #endif |
---|
136 | |
---|
137 | // simplified intra pred for "virtual" depth maps |
---|
138 | Void predIntraDepthAng ( TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight ); |
---|
139 | Int xGetDCDepth ( Int* pSrc, Int iDelta, Int iBlkSize ); |
---|
140 | Int xGetDCValDepth ( Int iVal1, Int iVal2, Int iVal3, Int iVal4 ); |
---|
141 | Void xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode ); |
---|
142 | }; |
---|
143 | |
---|
144 | #if HHI_DMM_INTRA |
---|
145 | // ==================================================================================================================== |
---|
146 | // Class definition TComWedgeDist |
---|
147 | // ==================================================================================================================== |
---|
148 | class TComWedgeDist |
---|
149 | { |
---|
150 | private: |
---|
151 | // for distortion |
---|
152 | Int m_iBlkWidth; |
---|
153 | Int m_iBlkHeight; |
---|
154 | |
---|
155 | FpDistFunc m_afpDistortFunc[8]; // [eDFunc] |
---|
156 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
157 | FpDistFuncRnd m_afpDistortFuncRnd[4]; |
---|
158 | #endif |
---|
159 | |
---|
160 | public: |
---|
161 | TComWedgeDist(); |
---|
162 | virtual ~TComWedgeDist(); |
---|
163 | |
---|
164 | // Distortion Functions |
---|
165 | Void init(); |
---|
166 | |
---|
167 | Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, DistParam& rcDistParam ); |
---|
168 | Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ); |
---|
169 | Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false ); |
---|
170 | Void setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false ); |
---|
171 | |
---|
172 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
173 | Void setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ); |
---|
174 | Void setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false ); |
---|
175 | #endif |
---|
176 | |
---|
177 | private: |
---|
178 | |
---|
179 | // static UInt xGetSAD ( DistParam* pcDtParam ); |
---|
180 | static UInt xGetSAD4 ( DistParam* pcDtParam ); |
---|
181 | static UInt xGetSAD8 ( DistParam* pcDtParam ); |
---|
182 | static UInt xGetSAD16 ( DistParam* pcDtParam ); |
---|
183 | static UInt xGetSAD32 ( DistParam* pcDtParam ); |
---|
184 | // static UInt xGetSAD64 ( DistParam* pcDtParam ); |
---|
185 | |
---|
186 | static UInt xGetSSE4 ( DistParam* pcDtParam ); |
---|
187 | static UInt xGetSSE8 ( DistParam* pcDtParam ); |
---|
188 | static UInt xGetSSE16 ( DistParam* pcDtParam ); |
---|
189 | static UInt xGetSSE32 ( DistParam* pcDtParam ); |
---|
190 | |
---|
191 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
192 | // static UInt xGetSAD ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
193 | static UInt xGetSAD4 ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
194 | static UInt xGetSAD8 ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
195 | static UInt xGetSAD16 ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
196 | static UInt xGetSAD32 ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
197 | // static UInt xGetSAD64 ( DistParam* pcDtParam, Pel* pRefY, Bool bRound ); |
---|
198 | #endif |
---|
199 | |
---|
200 | public: |
---|
201 | UInt getDistPart( Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist = WedgeDist_SAD ); |
---|
202 | |
---|
203 | };// END CLASS DEFINITION TComWedgeDist |
---|
204 | #endif |
---|
205 | |
---|
206 | #endif // __TCOMPREDICTION__ |
---|
207 | |
---|