source: 3DVCSoftware/branches/HTM-14.1-update-dev2-Orange/source/Lib/TLibCommon/TComPrediction.h @ 1232

Last change on this file since 1232 was 1225, checked in by sharpjp-htm, 10 years ago

Migration of illumination compensation(NH_3D_IC) and small fix(H_MV_ENC_DEC_TRAC_FIX)

  • Property svn:eol-style set to native
File size: 10.4 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-2015, 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
34/** \file     TComPrediction.h
35    \brief    prediction class (header)
36*/
37
38#ifndef __TCOMPREDICTION__
39#define __TCOMPREDICTION__
40
41
42// Include files
43#include "TComYuv.h"
44#include "TComInterpolationFilter.h"
45#include "TComWeightPrediction.h"
46
47// forward declaration
48class TComMv;
49class TComTU; 
50
51//! \ingroup TLibCommon
52//! \{
53
54// ====================================================================================================================
55// Class definition
56// ====================================================================================================================
57
58/// prediction class
59typedef enum PRED_BUF_E
60{
61  PRED_BUF_UNFILTERED=0,
62  PRED_BUF_FILTERED=1,
63  NUM_PRED_BUF=2
64} PRED_BUF;
65
66static const UInt MAX_INTRA_FILTER_DEPTHS=5;
67
68class TComPrediction : public TComWeightPrediction
69{
70private:
71  static const UChar m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS];
72
73protected:
74  Pel*      m_piYuvExt[MAX_NUM_COMPONENT][NUM_PRED_BUF];
75  Int       m_iYuvExtSize;
76
77  TComYuv   m_acYuvPred[NUM_REF_PIC_LIST_01];
78  TComYuv   m_cYuvPredTemp;
79#if H_3D_ARP
80  TComYuv   m_acYuvPredBase[2];
81#endif
82  TComYuv m_filteredBlock[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS];
83  TComYuv m_filteredBlockTmp[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS];
84
85  TComInterpolationFilter m_if;
86
87  Pel*   m_pLumaRecBuffer;       ///< array for downsampled reconstructed luma sample
88  Int    m_iLumaRecStride;       ///< stride of #m_pLumaRecBuffer array
89#if NH_3D_IC
90  UInt   m_uiaShift[ 64 ];       // Table for multiplication to substitue of division operation
91#endif
92
93#if H_3D_VSP
94  Int*    m_pDepthBlock;         ///< Store a depth block, local variable, to prevent memory allocation every time
95  TComYuv m_cYuvDepthOnVsp;
96#endif
97
98  Void xPredIntraAng            ( Int bitDepth, const Pel* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, ChannelType channelType, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, const Bool bEnableEdgeFilters );
99  Void xPredIntraPlanar         ( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height );
100
101  // motion compensation functions
102#if H_3D_ARP
103  Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false, TComMvField * pNewMvFiled = NULL );
104  Bool xCheckBiInterviewARP     ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc );
105  Void xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled = NULL );
106#endif
107
108  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi=false          );
109  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv* pcYuvPred          );
110#if H_3D_VSP
111  Void xPredInterUniVSP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
112  Void xPredInterBiVSP          ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred );
113#endif
114
115  Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
116#if H_3D_ARP
117    , Bool filterType = false
118#endif
119#if NH_3D_IC
120    , Bool bICFlag    = false
121#endif
122 );
123
124#if H_3D_ARP
125    , Bool filterType = false
126#endif
127#if H_3D_VSP
128  Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
129#endif
130
131  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths  );
132
133  Void xGetLLSPrediction ( const Pel* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0, const ChromaFormat chFmt  DEBUG_STRING_FN_DECLARE(sDebug) );
134#if NH_3D_IC
135  Void xGetLLSICPrediction( const ComponentID compID, TComDataCU* pcCU, TComMv *pMv, TComPicYuv *pRefPic, Int &a, Int &b, const Int bitDepth);
136#endif
137  Void xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType );
138  Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
139#if H_3D_SPIVMP
140  Bool xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 );
141  Void xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr );
142#endif
143#if H_3D_DIM
144  // depth intra functions
145  Void xPredBiSegDCs            ( Int* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& predDC1, Pel& predDC2 );
146  Void xAssignBiSegDCs          ( Pel* ptrDst, UInt dstStride, Bool* biSegPattern, Int patternStride, Pel   valDC1, Pel   valDC2 );
147#if H_3D_DIM_DMM
148  UInt xPredWedgeFromTex        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx );
149  Void xPredContourFromTex      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge );
150  Void xCopyTextureLumaBlock    ( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piDestBlockY, UInt uiWidth, UInt uiHeight );
151#endif
152#endif
153
154  Void destroy();
155
156public:
157  TComPrediction();
158  virtual ~TComPrediction();
159
160  Void    initTempBuff(ChromaFormat chromaFormatIDC);
161
162  ChromaFormat getChromaFormat() const { return m_cYuvPredTemp.getChromaFormat(); }
163
164  // inter
165  Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
166
167  // motion vector prediction
168  Void getMvPredAMVP              ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred );
169
170  // Angular Intra
171  Void predIntraAng               ( const ComponentID compID, UInt uiDirMode, Pel *piOrg /* Will be null for decoding */, UInt uiOrgStride, Pel* piPred, UInt uiStride, TComTU &rTu, Bool bAbove, Bool bLeft, const Bool bUseFilteredPredSamples, const Bool bUseLosslessDPCM = false );
172
173#if H_3D_DIM
174  // Depth intra
175  Void predIntraLumaDepth         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc = false 
176    , TComWedgelet* dmm4Segmentation = NULL
177    );
178#if H_3D_DIM_SDC
179  Void analyzeSegmentsSDC         ( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
180                                    ,UInt uiIntraMode
181                                    ,Bool orgDC=false
182    );
183#endif
184#endif
185 
186#if H_3D_DBBP
187  PartSize      getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU);
188  Bool          getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU);
189  Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize );
190#endif
191
192  Pel  predIntraGetPredValDC      ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
193
194  Pel*  getPredictorPtr           ( const ComponentID compID, const Bool bUseFilteredPredictions )
195  {
196    return m_piYuvExt[compID][bUseFilteredPredictions?PRED_BUF_FILTERED:PRED_BUF_UNFILTERED];
197  }
198
199  // This function is actually still in TComPattern.cpp
200  /// set parameters from CU data for accessing intra data
201  Void initIntraPatternChType ( TComTU &rTu,
202                              Bool&       bAbove,
203                              Bool&       bLeft,
204                              const ComponentID compID, const Bool bFilterRefSamples
205                              DEBUG_STRING_FN_DECLARE(sDebug)
206                              );
207
208  static Bool filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled);
209
210  static Bool UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode);
211};
212
213//! \}
214
215#endif // __TCOMPREDICTION__
Note: See TracBrowser for help on using the repository browser.