source: 3DVCSoftware/branches/0.2-poznan-univ/source/Lib/TLibCommon/TComPrediction.h @ 28

Last change on this file since 28 was 12, checked in by poznan-univ, 13 years ago

Poznan Tools

  • Depth base motion vector prediction
  • Property svn:eol-style set to native
File size: 16.1 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-2011, 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 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
35
36/** \file     TComPrediction.h
37    \brief    prediction class (header)
38*/
39
40#ifndef __TCOMPREDICTION__
41#define __TCOMPREDICTION__
42
43
44// Include files
45#include "TComPic.h"
46#include "TComMotionInfo.h"
47#include "TComPattern.h"
48#include "TComTrQuant.h"
49#include "TComPredFilter.h"
50#ifdef WEIGHT_PRED
51  #include "TComWeightPrediction.h"
52#endif
53
54#if POZNAN_MP
55#include "../TLibCommon/TComMP.h"
56#endif
57
58// ====================================================================================================================
59// Class definition
60// ====================================================================================================================
61
62/// prediction class
63class TComPrediction : public TComPredFilter
64#ifdef WEIGHT_PRED
65  , public TComWeightPrediction
66#endif
67{
68protected:
69  Int*      m_piYuvExt;
70  Int       m_iYuvExtStride;
71  Int       m_iYuvExtHeight;
72 
73  TComYuv   m_acYuvPred[2];
74  TComYuv   m_cYuvPredTemp;
75  TComYuv   m_cYuvExt;
76 
77#if LM_CHROMA
78  Pel*   m_pLumaRecBuffer;       // array for downsampled reconstructed luma sample
79  Int    m_iLumaRecStride;
80  UInt   m_uiaShift[ 65 ];       // Table for multiplication to substitue of division operation
81#endif
82
83  Void xPredIntraAng            ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable );
84#if ADD_PLANAR_MODE
85#if REFERENCE_SAMPLE_PADDING
86  Void xPredIntraPlanar         ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height );
87#else
88  Void xPredIntraPlanar         ( Int* pSrc, Int srcStride, Pel*& rpDst, Int dstStride, UInt width, UInt height, Bool blkAboveAvailable, Bool blkLeftAvailable );
89#endif
90#endif
91 
92  // motion compensation functions
93#if HIGH_ACCURACY_BI
94#if DEPTH_MAP_GENERATION
95  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi=false );
96#else
97  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi=false );
98#endif
99#else
100#if DEPTH_MAP_GENERATION
101  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
102#else
103  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx );
104#endif
105#endif
106  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap );
107  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
108  Void xPredInterLumaBlk        ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv );
109  Void xPredInterChromaBlk      ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv                            );
110  Void xWeightedAverage         ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
111  Void xDCTIF_FilterC ( Pel*  piRefC, Int iRefStride,Pel*  piDstC,Int iDstStride,Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac);
112
113#if HIGH_ACCURACY_BI
114  Void xPredInterLumaBlk_ha        ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv );
115  Void xPredInterChromaBlk_ha      ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iWidth, Int iHeight,                         TComYuv*& rpcYuv                            );
116  Void xDCTIF_FilterC_ha ( Pel*  piRefC, Int iRefStride,Pel*  piDstC,Int iDstStride,Int iWidth, Int iHeight,Int iMVyFrac,Int iMVxFrac);
117#endif
118
119#if POZNAN_EIVD
120#if HIGH_ACCURACY_BI
121  Void xPredInterUni_EIVD       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi=false          );
122#else
123  Void xPredInterUni_EIVD       ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap          );
124#endif
125  Void xPredInterBi_EIVD        ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iPosX, Int iPosY,                         TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap          );
126  Void xPredInterPrdDepthMap_EIVD( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                     TComYuv*& rpcYuv, UInt uiRShift, UInt uiFilterMode ); // 0:std, 1:bilin, 2:nearest neighbour
127  Void xPredInterLumaBlk_EIVD   ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
128  Void xPredInterChromaBlk_EIVD ( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv                            );
129  Void xWeightedAverage_EIVD    ( TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iPosX, Int iPosY, TComYuv*& rpcYuvDst );
130 
131#if HIGH_ACCURACY_BI
132  Void xPredInterLumaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv );
133  Void xPredInterChromaBlk_EIVD_ha( TComDataCU* pcCU, TComPicYuv* pcPicYuvRef, UInt uiPartAddr, TComMv* pcMv, Int iPosX, Int iPosY,                         TComYuv*& rpcYuv                            );
134#endif
135#endif
136
137#if HHI_DMM_WEDGE_INTRA
138  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 );
139
140  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 );
141  Void xGetBlockOffset           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY );
142  Bool xGetWedgeIntraDirPredData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY );
143  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 );
144#endif
145#if HHI_DMM_PRED_TEX
146  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 );
147  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 );
148#endif
149#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
150  Void xDeltaDCQuantScaleUp      ( TComDataCU* pcCU, Int& riDeltaDC );
151#endif
152
153#if LM_CHROMA
154  Void xGetRecPixels     ( TComPattern* pcPattern, Pel* pRecSrc, Int iRecSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth0, UInt uiHeight0 );   
155  Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 );
156#endif
157
158#if MN_DC_PRED_FILTER
159  Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
160#endif
161
162public:
163  TComPrediction();
164  virtual ~TComPrediction();
165 
166  Void    initTempBuff();
167 
168  // inter
169  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false );
170 
171#if POZNAN_EIVD
172  Void motionCompensation_EIVD         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1, Bool bPrdDepthMap = false );
173#endif
174
175  // motion vector prediction
176  Void getMvPredAMVP              ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMvPred );
177 
178  // Angular Intra
179  Void predIntraLumaAng           ( TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight,  TComDataCU* pcCU, Bool bAbove, Bool bLeft );
180  Void predIntraChromaAng         ( TComPattern* pcTComPattern, Int* piSrc, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, TComDataCU* pcCU, Bool bAbove, Bool bLeft );
181 
182#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
183  Void  predIntraLumaDMM         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder );
184
185  Void  getWedgePredDCs         ( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft );
186  Void  calcWedgeDCs             ( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 );
187  Void  assignWedgeDCs2Pred      ( TComWedgelet* pcWedgelet, Pel* piPred,  UInt uiStride, Int   iDC1, Int   iDC2 );
188#endif
189#if HHI_DMM_PRED_TEX
190  Void  getBestContourFromText   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge, Pel* piTextureBlock = NULL );
191  UInt  getBestWedgeFromText     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist = WedgeDist_SAD, Pel* piTextureBlock = NULL );
192  Void  fillTexturePicTempBlock  ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piTempBlockY, UInt uiWidth, UInt uiHeight );
193#endif
194#if HHI_DMM_WEDGE_INTRA
195  UInt  getBestContinueWedge     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd = 0 );
196  Bool  getWedgeListIdx          ( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe );
197#endif
198 
199  Pel  predIntraGetPredValDC      ( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
200 
201  Int* getPredicBuf()             { return m_piYuvExt;      }
202  Int  getPredicBufWidth()        { return m_iYuvExtStride; }
203  Int  getPredicBufHeight()       { return m_iYuvExtHeight; }
204
205#if LM_CHROMA
206  Void predLMIntraChroma( TComPattern* pcPattern, Int* piSrc, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId );
207#endif
208
209  // simplified intra pred for "virtual" depth maps
210  Void  predIntraDepthAng ( TComPattern* pcTComPattern, UInt uiDirMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight );
211  Int   xGetDCDepth       ( Int* pSrc, Int iDelta, Int iBlkSize );
212  Int   xGetDCValDepth    ( Int iVal1, Int iVal2, Int iVal3, Int iVal4 );
213  Void  xPredIntraAngDepth( Int* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, UInt dirMode );
214};
215
216#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
217// ====================================================================================================================
218// Class definition TComWedgeDist
219// ====================================================================================================================
220class TComWedgeDist
221{
222private:
223  // for distortion
224  Int                     m_iBlkWidth;
225  Int                     m_iBlkHeight;
226
227  FpDistFunc              m_afpDistortFunc[8]; // [eDFunc]
228#ifdef ROUNDING_CONTROL_BIPRED
229  FpDistFuncRnd           m_afpDistortFuncRnd[4];
230#endif
231
232public:
233  TComWedgeDist();
234  virtual ~TComWedgeDist();
235
236  // Distortion Functions
237  Void    init();
238
239  Void    setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist, DistParam& rcDistParam );
240  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
241  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
242  Void    setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
243
244#ifdef ROUNDING_CONTROL_BIPRED
245  Void    setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
246  Void    setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
247#endif
248
249private:
250
251  //   static UInt xGetSAD           ( DistParam* pcDtParam );
252  static UInt xGetSAD4          ( DistParam* pcDtParam );
253  static UInt xGetSAD8          ( DistParam* pcDtParam );
254  static UInt xGetSAD16         ( DistParam* pcDtParam );
255  static UInt xGetSAD32         ( DistParam* pcDtParam );
256  //   static UInt xGetSAD64         ( DistParam* pcDtParam );
257
258  static UInt xGetSSE4          ( DistParam* pcDtParam );
259  static UInt xGetSSE8          ( DistParam* pcDtParam );
260  static UInt xGetSSE16         ( DistParam* pcDtParam );
261  static UInt xGetSSE32         ( DistParam* pcDtParam );
262
263#ifdef ROUNDING_CONTROL_BIPRED
264  //   static UInt xGetSAD           ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
265  static UInt xGetSAD4          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
266  static UInt xGetSAD8          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
267  static UInt xGetSAD16         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
268  static UInt xGetSAD32         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
269  //   static UInt xGetSAD64         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
270#endif
271
272public:
273  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, WedgeDist eWDist = WedgeDist_SAD );
274
275};// END CLASS DEFINITION TComWedgeDist
276#endif
277
278#endif // __TCOMPREDICTION__
279
Note: See TracBrowser for help on using the repository browser.