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-2014, 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 "TComPic.h" |
---|
44 | #include "TComMotionInfo.h" |
---|
45 | #include "TComPattern.h" |
---|
46 | #include "TComTrQuant.h" |
---|
47 | #include "TComInterpolationFilter.h" |
---|
48 | #include "TComWeightPrediction.h" |
---|
49 | |
---|
50 | class TComTU; // forward declaration |
---|
51 | |
---|
52 | #if SVC_EXTENSION |
---|
53 | #include "TComUpsampleFilter.h" |
---|
54 | #endif |
---|
55 | //! \ingroup TLibCommon |
---|
56 | //! \{ |
---|
57 | |
---|
58 | // ==================================================================================================================== |
---|
59 | // Class definition |
---|
60 | // ==================================================================================================================== |
---|
61 | |
---|
62 | /// prediction class |
---|
63 | typedef enum PRED_BUF_E |
---|
64 | { |
---|
65 | PRED_BUF_UNFILTERED=0, |
---|
66 | PRED_BUF_FILTERED=1, |
---|
67 | NUM_PRED_BUF=2 |
---|
68 | } PRED_BUF; |
---|
69 | |
---|
70 | static const UInt MAX_INTRA_FILTER_DEPTHS=5; |
---|
71 | |
---|
72 | class TComPrediction : public TComWeightPrediction |
---|
73 | { |
---|
74 | private: |
---|
75 | static const UChar m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS]; |
---|
76 | |
---|
77 | protected: |
---|
78 | Pel* m_piYuvExt[MAX_NUM_COMPONENT][NUM_PRED_BUF]; |
---|
79 | Int m_iYuvExtSize; |
---|
80 | |
---|
81 | TComYuv m_acYuvPred[NUM_REF_PIC_LIST_01]; |
---|
82 | TComYuv m_cYuvPredTemp; |
---|
83 | TComYuv m_filteredBlock[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]; |
---|
84 | TComYuv m_filteredBlockTmp[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS]; |
---|
85 | |
---|
86 | TComInterpolationFilter m_if; |
---|
87 | |
---|
88 | Pel* m_pLumaRecBuffer; ///< array for downsampled reconstructed luma sample |
---|
89 | Int m_iLumaRecStride; ///< stride of #m_pLumaRecBuffer array |
---|
90 | |
---|
91 | Void xPredIntraAng ( Int bitDepth, const Pel* pSrc, Int srcStride, Pel* pDst, Int dstStride, UInt width, UInt height, ChannelType channelType, ChromaFormat format, UInt dirMode, Bool blkAboveAvailable, Bool blkLeftAvailable, const Bool bEnableEdgeFilters ); |
---|
92 | Void xPredIntraPlanar ( const Pel* pSrc, Int srcStride, Pel* rpDst, Int dstStride, UInt width, UInt height, ChannelType channelType, ChromaFormat format ); |
---|
93 | |
---|
94 | // motion compensation functions |
---|
95 | Void xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi=false ); |
---|
96 | Void xPredInterBi ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvPred ); |
---|
97 | Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi ); |
---|
98 | Void xWeightedAverage ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvDst ); |
---|
99 | |
---|
100 | 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) ); |
---|
101 | |
---|
102 | Void xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType ); |
---|
103 | Bool xCheckIdenticalMotion ( TComDataCU* pcCU, UInt PartAddr); |
---|
104 | Void destroy(); |
---|
105 | |
---|
106 | #if SVC_EXTENSION |
---|
107 | TComUpsampleFilter m_cUsf; |
---|
108 | #endif |
---|
109 | |
---|
110 | public: |
---|
111 | TComPrediction(); |
---|
112 | virtual ~TComPrediction(); |
---|
113 | |
---|
114 | Void initTempBuff(ChromaFormat chromaFormatIDC); |
---|
115 | |
---|
116 | ChromaFormat getChromaFormat() const { return m_cYuvPredTemp.getChromaFormat(); } |
---|
117 | |
---|
118 | // inter |
---|
119 | Void motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 ); |
---|
120 | |
---|
121 | // motion vector prediction |
---|
122 | Void getMvPredAMVP ( TComDataCU* pcCU, UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, TComMv& rcMvPred ); |
---|
123 | |
---|
124 | // Angular Intra |
---|
125 | 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 ); |
---|
126 | |
---|
127 | Pel predIntraGetPredValDC ( const Pel* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, ChannelType channelType, ChromaFormat format, Bool bAbove, Bool bLeft ); |
---|
128 | |
---|
129 | Pel* getPredictorPtr ( const ComponentID compID, const Bool bUseFilteredPredictions ) |
---|
130 | { |
---|
131 | return m_piYuvExt[compID][bUseFilteredPredictions?PRED_BUF_FILTERED:PRED_BUF_UNFILTERED]; |
---|
132 | } |
---|
133 | |
---|
134 | // This function is actually still in TComPattern.cpp |
---|
135 | /// set parameters from CU data for accessing ADI data |
---|
136 | Void initAdiPatternChType ( TComTU &rTu, |
---|
137 | Bool& bAbove, |
---|
138 | Bool& bLeft, |
---|
139 | const ComponentID compID, const Bool bFilterRefSamples |
---|
140 | DEBUG_STRING_FN_DECLARE(sDebug) |
---|
141 | ); |
---|
142 | |
---|
143 | static Bool filteringIntraReferenceSamples(const ComponentID compID, UInt uiDirMode, UInt uiTuChWidth, UInt uiTuChHeight, const ChromaFormat chFmt, const Bool intraReferenceSmoothingDisabled); |
---|
144 | |
---|
145 | static Bool UseDPCMForFirstPassIntraEstimation(TComTU &rTu, const UInt uiDirMode); |
---|
146 | |
---|
147 | #if SVC_EXTENSION |
---|
148 | #if O0215_PHASE_ALIGNMENT_REMOVAL |
---|
149 | Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic ); |
---|
150 | #else |
---|
151 | #if O0215_PHASE_ALIGNMENT |
---|
152 | #if O0194_JOINT_US_BITSHIFT |
---|
153 | Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, Bool phaseAlignFlag ); |
---|
154 | #else |
---|
155 | Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, Bool phaseAlignFlag ); |
---|
156 | #endif |
---|
157 | #else |
---|
158 | #if O0194_JOINT_US_BITSHIFT |
---|
159 | #if REF_REGION_OFFSET |
---|
160 | Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, const Window altRefWindow ); |
---|
161 | #else |
---|
162 | Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window ); |
---|
163 | #endif |
---|
164 | #else |
---|
165 | Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window ); |
---|
166 | #endif |
---|
167 | #endif |
---|
168 | #endif |
---|
169 | #endif //SVC_EXTENSION |
---|
170 | }; |
---|
171 | |
---|
172 | //! \} |
---|
173 | |
---|
174 | #endif // __TCOMPREDICTION__ |
---|