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-2016, 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 TComPicSym.h |
---|
35 | \brief picture symbol class (header) |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef __TCOMPICSYM__ |
---|
39 | #define __TCOMPICSYM__ |
---|
40 | |
---|
41 | |
---|
42 | // Include files |
---|
43 | #include <deque> |
---|
44 | #include "CommonDef.h" |
---|
45 | #include "TComSlice.h" |
---|
46 | #include "TComDataCU.h" |
---|
47 | class TComSampleAdaptiveOffset; |
---|
48 | class TComPPS; |
---|
49 | |
---|
50 | //! \ingroup TLibCommon |
---|
51 | //! \{ |
---|
52 | |
---|
53 | // ==================================================================================================================== |
---|
54 | // Class definition |
---|
55 | // ==================================================================================================================== |
---|
56 | |
---|
57 | class TComTile |
---|
58 | { |
---|
59 | private: |
---|
60 | UInt m_tileWidthInCtus; |
---|
61 | UInt m_tileHeightInCtus; |
---|
62 | UInt m_rightEdgePosInCtus; |
---|
63 | UInt m_bottomEdgePosInCtus; |
---|
64 | UInt m_firstCtuRsAddr; |
---|
65 | |
---|
66 | public: |
---|
67 | TComTile(); |
---|
68 | virtual ~TComTile(); |
---|
69 | |
---|
70 | Void setTileWidthInCtus ( UInt i ) { m_tileWidthInCtus = i; } |
---|
71 | UInt getTileWidthInCtus () const { return m_tileWidthInCtus; } |
---|
72 | Void setTileHeightInCtus ( UInt i ) { m_tileHeightInCtus = i; } |
---|
73 | UInt getTileHeightInCtus () const { return m_tileHeightInCtus; } |
---|
74 | Void setRightEdgePosInCtus ( UInt i ) { m_rightEdgePosInCtus = i; } |
---|
75 | UInt getRightEdgePosInCtus () const { return m_rightEdgePosInCtus; } |
---|
76 | Void setBottomEdgePosInCtus ( UInt i ) { m_bottomEdgePosInCtus = i; } |
---|
77 | UInt getBottomEdgePosInCtus () const { return m_bottomEdgePosInCtus; } |
---|
78 | Void setFirstCtuRsAddr ( UInt i ) { m_firstCtuRsAddr = i; } |
---|
79 | UInt getFirstCtuRsAddr () const { return m_firstCtuRsAddr; } |
---|
80 | }; |
---|
81 | |
---|
82 | /// picture symbol class |
---|
83 | class TComPicSym |
---|
84 | { |
---|
85 | private: |
---|
86 | UInt m_frameWidthInCtus; |
---|
87 | UInt m_frameHeightInCtus; |
---|
88 | |
---|
89 | UInt m_uiMinCUWidth; |
---|
90 | UInt m_uiMinCUHeight; |
---|
91 | |
---|
92 | UChar m_uhTotalDepth; ///< max. depth |
---|
93 | UInt m_numPartitionsInCtu; |
---|
94 | UInt m_numPartInCtuWidth; |
---|
95 | UInt m_numPartInCtuHeight; |
---|
96 | UInt m_numCtusInFrame; |
---|
97 | |
---|
98 | std::deque<TComSlice*> m_apSlices; |
---|
99 | TComDataCU** m_pictureCtuArray; ///< array of CU data. |
---|
100 | |
---|
101 | Int m_numTileColumnsMinus1; |
---|
102 | Int m_numTileRowsMinus1; |
---|
103 | std::vector<TComTile> m_tileParameters; |
---|
104 | UInt* m_ctuTsToRsAddrMap; ///< for a given TS (Tile-Scan; coding order) address, returns the RS (Raster-Scan) address. cf CtbAddrTsToRs in specification. |
---|
105 | UInt* m_puiTileIdxMap; ///< the map of the tile index relative to CTU raster scan address |
---|
106 | UInt* m_ctuRsToTsAddrMap; ///< for a given RS (Raster-Scan) address, returns the TS (Tile-Scan; coding order) address. cf CtbAddrRsToTs in specification. |
---|
107 | |
---|
108 | #if REDUCED_ENCODER_MEMORY |
---|
109 | public: |
---|
110 | struct DPBPerCtuData |
---|
111 | { |
---|
112 | Bool isInter(const UInt absPartAddr) const { return m_pePredMode[absPartAddr] == MODE_INTER; } |
---|
113 | PartSize getPartitionSize( const UInt absPartAddr ) const { return static_cast<PartSize>( m_pePartSize[absPartAddr] ); } |
---|
114 | const TComCUMvField* getCUMvField ( RefPicList e ) const { return &m_CUMvField[e]; } |
---|
115 | const TComSlice* getSlice() const { return m_pSlice; } |
---|
116 | |
---|
117 | SChar * m_pePredMode; |
---|
118 | SChar * m_pePartSize; |
---|
119 | TComCUMvField m_CUMvField[NUM_REF_PIC_LIST_01]; |
---|
120 | TComSlice * m_pSlice; |
---|
121 | }; |
---|
122 | |
---|
123 | private: |
---|
124 | DPBPerCtuData *m_dpbPerCtuData; |
---|
125 | #endif |
---|
126 | SAOBlkParam *m_saoBlkParams; |
---|
127 | #if ADAPTIVE_QP_SELECTION |
---|
128 | TCoeff* m_pParentARLBuffer; |
---|
129 | #endif |
---|
130 | TComSPS m_sps; |
---|
131 | TComPPS m_pps; |
---|
132 | |
---|
133 | Void xInitTiles( ); |
---|
134 | Void xInitCtuTsRsAddrMaps(); |
---|
135 | Void setNumTileColumnsMinus1( Int i ) { m_numTileColumnsMinus1 = i; } |
---|
136 | Void setNumTileRowsMinus1( Int i ) { m_numTileRowsMinus1 = i; } |
---|
137 | Void setCtuTsToRsAddrMap( Int ctuTsAddr, Int ctuRsAddr ) { *(m_ctuTsToRsAddrMap + ctuTsAddr) = ctuRsAddr; } |
---|
138 | Void setCtuRsToTsAddrMap( Int ctuRsAddr, Int ctuTsOrder ) { *(m_ctuRsToTsAddrMap + ctuRsAddr) = ctuTsOrder; } |
---|
139 | |
---|
140 | #if SVC_EXTENSION |
---|
141 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
142 | Int* m_piTileSetIdxMap; //the map of the tile set index relative to LCU raster scan address |
---|
143 | UChar* m_pucTileSetType; |
---|
144 | Bool* m_pbSkippedTileSetFlag; |
---|
145 | #endif |
---|
146 | #endif |
---|
147 | |
---|
148 | public: |
---|
149 | #if SVC_EXTENSION |
---|
150 | #if REDUCED_ENCODER_MEMORY |
---|
151 | Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray , const UInt layerId ); |
---|
152 | #else |
---|
153 | Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const UInt layerId ); |
---|
154 | #endif |
---|
155 | #if CGS_3D_ASYMLUT |
---|
156 | TComPPS* getPPSToUpdate() { return &m_pps; } |
---|
157 | #endif |
---|
158 | #else |
---|
159 | #if REDUCED_ENCODER_MEMORY |
---|
160 | Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth, const Bool bAllocateCtuArray ); |
---|
161 | #else |
---|
162 | Void create ( const TComSPS &sps, const TComPPS &pps, UInt uiMaxDepth ); |
---|
163 | #endif |
---|
164 | #endif |
---|
165 | #if REDUCED_ENCODER_MEMORY |
---|
166 | Void prepareForReconstruction(); |
---|
167 | Void releaseReconstructionIntermediateData(); |
---|
168 | Void releaseAllReconstructionData(); |
---|
169 | #endif |
---|
170 | Void destroy (); |
---|
171 | |
---|
172 | TComPicSym (); |
---|
173 | ~TComPicSym(); |
---|
174 | |
---|
175 | TComSlice* getSlice(UInt i) { return m_apSlices[i]; } |
---|
176 | const TComSlice* getSlice(UInt i) const { return m_apSlices[i]; } |
---|
177 | UInt getFrameWidthInCtus() const { return m_frameWidthInCtus; } |
---|
178 | UInt getFrameHeightInCtus() const { return m_frameHeightInCtus; } |
---|
179 | UInt getMinCUWidth() const { return m_uiMinCUWidth; } |
---|
180 | UInt getMinCUHeight() const { return m_uiMinCUHeight; } |
---|
181 | UInt getNumberOfCtusInFrame() const { return m_numCtusInFrame; } |
---|
182 | TComDataCU* getCtu( UInt ctuRsAddr ) { return m_pictureCtuArray[ctuRsAddr]; } |
---|
183 | const TComDataCU* getCtu( UInt ctuRsAddr ) const { return m_pictureCtuArray[ctuRsAddr]; } |
---|
184 | const TComSPS& getSPS() const { return m_sps; } |
---|
185 | const TComPPS& getPPS() const { return m_pps; } |
---|
186 | #if REDUCED_ENCODER_MEMORY |
---|
187 | Bool hasDPBPerCtuData() const { return (m_dpbPerCtuData!=0); }; |
---|
188 | DPBPerCtuData& getDPBPerCtuData(UInt ctuRsAddr) { return m_dpbPerCtuData[ctuRsAddr]; } |
---|
189 | const DPBPerCtuData& getDPBPerCtuData(UInt ctuRsAddr) const { return m_dpbPerCtuData[ctuRsAddr]; } |
---|
190 | #endif |
---|
191 | |
---|
192 | TComSlice * swapSliceObject(TComSlice* p, UInt i) { p->setSPS(&m_sps); p->setPPS(&m_pps); TComSlice *pTmp=m_apSlices[i];m_apSlices[i] = p; pTmp->setSPS(0); pTmp->setPPS(0); return pTmp; } |
---|
193 | UInt getNumAllocatedSlice() const { return UInt(m_apSlices.size()); } |
---|
194 | Void allocateNewSlice(); |
---|
195 | Void clearSliceBuffer(); |
---|
196 | UInt getNumPartitionsInCtu() const { return m_numPartitionsInCtu; } |
---|
197 | UInt getNumPartInCtuWidth() const { return m_numPartInCtuWidth; } |
---|
198 | UInt getNumPartInCtuHeight() const { return m_numPartInCtuHeight; } |
---|
199 | Int getNumTileColumnsMinus1() const { return m_numTileColumnsMinus1; } |
---|
200 | Int getNumTileRowsMinus1() const { return m_numTileRowsMinus1; } |
---|
201 | Int getNumTiles() const { return (m_numTileRowsMinus1+1)*(m_numTileColumnsMinus1+1); } |
---|
202 | TComTile* getTComTile ( UInt tileIdx ) { return &(m_tileParameters[tileIdx]); } |
---|
203 | const TComTile* getTComTile ( UInt tileIdx ) const { return &(m_tileParameters[tileIdx]); } |
---|
204 | UInt getCtuTsToRsAddrMap( Int ctuTsAddr ) const { return *(m_ctuTsToRsAddrMap + (ctuTsAddr>=m_numCtusInFrame ? m_numCtusInFrame : ctuTsAddr)); } |
---|
205 | UInt getTileIdxMap( Int ctuRsAddr ) const { return *(m_puiTileIdxMap + ctuRsAddr); } |
---|
206 | UInt getCtuRsToTsAddrMap( Int ctuRsAddr ) const { return *(m_ctuRsToTsAddrMap + (ctuRsAddr>=m_numCtusInFrame ? m_numCtusInFrame : ctuRsAddr)); } |
---|
207 | SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;} |
---|
208 | const SAOBlkParam* getSAOBlkParam() const { return m_saoBlkParams;} |
---|
209 | Void deriveLoopFilterBoundaryAvailibility(Int ctuRsAddr, |
---|
210 | Bool& isLeftAvail, Bool& isRightAvail, Bool& isAboveAvail, Bool& isBelowAvail, |
---|
211 | Bool& isAboveLeftAvail, Bool& isAboveRightAvail, Bool& isBelowLeftAvail, Bool& isBelowRightAvail); |
---|
212 | protected: |
---|
213 | UInt xCalculateNextCtuRSAddr( UInt uiCurrCtuRSAddr ); |
---|
214 | |
---|
215 | #if SVC_EXTENSION |
---|
216 | public: |
---|
217 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
218 | Void setTileSetIdxMap( Int i, Int tileSetIdx, UChar setType, Bool skipFlag ) |
---|
219 | { |
---|
220 | m_piTileSetIdxMap[i] = tileSetIdx; |
---|
221 | m_pucTileSetType[i] = setType; |
---|
222 | m_pbSkippedTileSetFlag[i] = skipFlag; |
---|
223 | } |
---|
224 | Int getTileSetIdxMap( Int i ) { return *(m_piTileSetIdxMap + i); } |
---|
225 | UChar getTileSetType( Int i ) { return *(m_pucTileSetType + i); } |
---|
226 | Bool getSkippedTileSetFlag( Int i ) { return *(m_pbSkippedTileSetFlag + i); } |
---|
227 | #endif |
---|
228 | Void inferSpsForNonHEVCBL(TComVPS *vps, const UInt maxCuWidth, const UInt maxCuHeight) { m_sps.inferSPS(0, vps); m_sps.setMaxCUWidth(maxCuWidth), m_sps.setMaxCUHeight(maxCuHeight); } |
---|
229 | #endif //SVC_EXTENSION |
---|
230 | |
---|
231 | };// END CLASS DEFINITION TComPicSym |
---|
232 | |
---|
233 | //! \} |
---|
234 | |
---|
235 | #endif // __TCOMPICSYM__ |
---|
236 | |
---|