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-2012, 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 TComPic.h |
---|
35 | \brief picture class (header) |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef __TCOMPIC__ |
---|
39 | #define __TCOMPIC__ |
---|
40 | |
---|
41 | // Include files |
---|
42 | #include "CommonDef.h" |
---|
43 | #include "TComPicSym.h" |
---|
44 | #include "TComPicYuv.h" |
---|
45 | #include "TComBitStream.h" |
---|
46 | #if AVC_BASE || SYNTAX_OUTPUT |
---|
47 | #include <fstream> |
---|
48 | #endif |
---|
49 | |
---|
50 | |
---|
51 | //! \ingroup TLibCommon |
---|
52 | //! \{ |
---|
53 | |
---|
54 | class SEImessages; |
---|
55 | |
---|
56 | // ==================================================================================================================== |
---|
57 | // Class definition |
---|
58 | // ==================================================================================================================== |
---|
59 | |
---|
60 | /// picture class (symbol + YUV buffers) |
---|
61 | class TComPic |
---|
62 | { |
---|
63 | private: |
---|
64 | UInt m_uiTLayer; // Temporal layer |
---|
65 | #if SVC_EXTENSION |
---|
66 | UInt m_layerId; // Layer ID |
---|
67 | #endif |
---|
68 | Bool m_bUsedByCurr; // Used by current picture |
---|
69 | Bool m_bIsLongTerm; // IS long term picture |
---|
70 | Bool m_bIsUsedAsLongTerm; // long term picture is used as reference before |
---|
71 | TComPicSym* m_apcPicSym; // Symbol |
---|
72 | |
---|
73 | TComPicYuv* m_apcPicYuv[2]; // Texture, 0:org / 1:rec |
---|
74 | |
---|
75 | TComPicYuv* m_pcPicYuvPred; // Prediction |
---|
76 | TComPicYuv* m_pcPicYuvResi; // Residual |
---|
77 | Bool m_bReconstructed; |
---|
78 | Bool m_bNeededForOutput; |
---|
79 | UInt m_uiCurrSliceIdx; // Index of current slice |
---|
80 | Int* m_pSliceSUMap; |
---|
81 | Bool* m_pbValidSlice; |
---|
82 | Int m_sliceGranularityForNDBFilter; |
---|
83 | Bool m_bIndependentSliceBoundaryForNDBFilter; |
---|
84 | Bool m_bIndependentTileBoundaryForNDBFilter; |
---|
85 | TComPicYuv* m_pNDBFilterYuvTmp; //!< temporary picture buffer when non-cross slice/tile boundary in-loop filtering is enabled |
---|
86 | Bool m_bCheckLTMSB; |
---|
87 | std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink; |
---|
88 | |
---|
89 | SEImessages* m_SEIs; ///< Any SEI messages that have been received. If !NULL we own the object. |
---|
90 | |
---|
91 | #if SVC_EXTENSION |
---|
92 | Bool m_bSpatialEnhLayer; // whether current layer is a spatial enhancement layer, |
---|
93 | TComPicYuv* m_pcFullPelBaseRec; // upsampled base layer recontruction for difference domain inter prediction |
---|
94 | #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM |
---|
95 | Bool m_bIsILR; // Is ILR picture |
---|
96 | #endif |
---|
97 | #endif |
---|
98 | |
---|
99 | public: |
---|
100 | TComPic(); |
---|
101 | virtual ~TComPic(); |
---|
102 | |
---|
103 | #if SVC_UPSAMPLING |
---|
104 | Void create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); |
---|
105 | #if REF_IDX_FRAMEWORK |
---|
106 | Void createWithOutYuv( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); |
---|
107 | Void setPicYuvRec(TComPicYuv *pPicYuv) { m_apcPicYuv[1]=pPicYuv; } |
---|
108 | #endif |
---|
109 | #else |
---|
110 | Void create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Bool bIsVirtual = false ); |
---|
111 | #endif |
---|
112 | virtual Void destroy(); |
---|
113 | |
---|
114 | UInt getTLayer() { return m_uiTLayer; } |
---|
115 | Void setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; } |
---|
116 | #if SVC_EXTENSION |
---|
117 | Void setLayerId (UInt layerId) { m_layerId = layerId; } |
---|
118 | UInt getLayerId () { return m_layerId; } |
---|
119 | Bool isSpatialEnhLayer() { return m_bSpatialEnhLayer; } |
---|
120 | Void setSpatialEnhLayerFlag (Bool b) { m_bSpatialEnhLayer = b; } |
---|
121 | Void setFullPelBaseRec ( TComPicYuv* p) { m_pcFullPelBaseRec = p; } |
---|
122 | TComPicYuv* getFullPelBaseRec () { return m_pcFullPelBaseRec; } |
---|
123 | #endif |
---|
124 | #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM |
---|
125 | Void setIsILR( Bool bIsILR) {m_bIsILR = bIsILR;} |
---|
126 | Bool getIsILR() {return m_bIsILR;} |
---|
127 | #endif |
---|
128 | |
---|
129 | #if REF_IDX_MFM |
---|
130 | Void copyUpsampledMvField ( TComPic* pcPicBase ); |
---|
131 | Void deriveUnitIdxBase ( UInt uiUpsamplePelX, UInt uiUpsamplePelY, UInt ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx ); |
---|
132 | #endif |
---|
133 | |
---|
134 | Bool getUsedByCurr() { return m_bUsedByCurr; } |
---|
135 | Void setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; } |
---|
136 | Bool getIsLongTerm() { return m_bIsLongTerm; } |
---|
137 | Void setIsLongTerm( Bool lt ) { m_bIsLongTerm = lt; } |
---|
138 | Bool getIsUsedAsLongTerm() { return m_bIsUsedAsLongTerm; } |
---|
139 | Void setIsUsedAsLongTerm( Bool lt ) { m_bIsUsedAsLongTerm = lt; } |
---|
140 | Void setCheckLTMSBPresent (Bool b ) {m_bCheckLTMSB=b;} |
---|
141 | Bool getCheckLTMSBPresent () { return m_bCheckLTMSB;} |
---|
142 | |
---|
143 | TComPicSym* getPicSym() { return m_apcPicSym; } |
---|
144 | TComSlice* getSlice(Int i) { return m_apcPicSym->getSlice(i); } |
---|
145 | Int getPOC() { return m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getPOC(); } |
---|
146 | TComDataCU*& getCU( UInt uiCUAddr ) { return m_apcPicSym->getCU( uiCUAddr ); } |
---|
147 | |
---|
148 | TComPicYuv* getPicYuvOrg() { return m_apcPicYuv[0]; } |
---|
149 | TComPicYuv* getPicYuvRec() { return m_apcPicYuv[1]; } |
---|
150 | |
---|
151 | TComPicYuv* getPicYuvPred() { return m_pcPicYuvPred; } |
---|
152 | TComPicYuv* getPicYuvResi() { return m_pcPicYuvResi; } |
---|
153 | Void setPicYuvPred( TComPicYuv* pcPicYuv ) { m_pcPicYuvPred = pcPicYuv; } |
---|
154 | Void setPicYuvResi( TComPicYuv* pcPicYuv ) { m_pcPicYuvResi = pcPicYuv; } |
---|
155 | |
---|
156 | UInt getNumCUsInFrame() { return m_apcPicSym->getNumberOfCUsInFrame(); } |
---|
157 | UInt getNumPartInWidth() { return m_apcPicSym->getNumPartInWidth(); } |
---|
158 | UInt getNumPartInHeight() { return m_apcPicSym->getNumPartInHeight(); } |
---|
159 | UInt getNumPartInCU() { return m_apcPicSym->getNumPartition(); } |
---|
160 | UInt getFrameWidthInCU() { return m_apcPicSym->getFrameWidthInCU(); } |
---|
161 | UInt getFrameHeightInCU() { return m_apcPicSym->getFrameHeightInCU(); } |
---|
162 | UInt getMinCUWidth() { return m_apcPicSym->getMinCUWidth(); } |
---|
163 | UInt getMinCUHeight() { return m_apcPicSym->getMinCUHeight(); } |
---|
164 | |
---|
165 | UInt getParPelX(UChar uhPartIdx) { return getParPelX(uhPartIdx); } |
---|
166 | UInt getParPelY(UChar uhPartIdx) { return getParPelX(uhPartIdx); } |
---|
167 | |
---|
168 | Int getStride() { return m_apcPicYuv[1]->getStride(); } |
---|
169 | Int getCStride() { return m_apcPicYuv[1]->getCStride(); } |
---|
170 | |
---|
171 | Void setReconMark (Bool b) { m_bReconstructed = b; } |
---|
172 | Bool getReconMark () { return m_bReconstructed; } |
---|
173 | Void setOutputMark (Bool b) { m_bNeededForOutput = b; } |
---|
174 | Bool getOutputMark () { return m_bNeededForOutput; } |
---|
175 | |
---|
176 | |
---|
177 | Void compressMotion(); |
---|
178 | UInt getCurrSliceIdx() { return m_uiCurrSliceIdx; } |
---|
179 | Void setCurrSliceIdx(UInt i) { m_uiCurrSliceIdx = i; } |
---|
180 | UInt getNumAllocatedSlice() {return m_apcPicSym->getNumAllocatedSlice();} |
---|
181 | Void allocateNewSlice() {m_apcPicSym->allocateNewSlice(); } |
---|
182 | Void clearSliceBuffer() {m_apcPicSym->clearSliceBuffer(); } |
---|
183 | |
---|
184 | Void createNonDBFilterInfo (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth |
---|
185 | ,std::vector<Bool>* LFCrossSliceBoundary |
---|
186 | ,Int numTiles = 1 |
---|
187 | ,Bool bNDBFilterCrossTileBoundary = true); |
---|
188 | Void createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight); |
---|
189 | Void destroyNonDBFilterInfo(); |
---|
190 | |
---|
191 | Bool getValidSlice (Int sliceID) {return m_pbValidSlice[sliceID];} |
---|
192 | #if !REMOVE_FGS |
---|
193 | Int getSliceGranularityForNDBFilter () {return m_sliceGranularityForNDBFilter;} |
---|
194 | #endif |
---|
195 | Bool getIndependentSliceBoundaryForNDBFilter () {return m_bIndependentSliceBoundaryForNDBFilter;} |
---|
196 | Bool getIndependentTileBoundaryForNDBFilter () {return m_bIndependentTileBoundaryForNDBFilter; } |
---|
197 | TComPicYuv* getYuvPicBufferForIndependentBoundaryProcessing() {return m_pNDBFilterYuvTmp;} |
---|
198 | std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter (Int sliceID) { return m_vSliceCUDataLink[sliceID];} |
---|
199 | |
---|
200 | /** transfer ownership of seis to this picture */ |
---|
201 | void setSEIs(SEImessages* seis) { m_SEIs = seis; } |
---|
202 | |
---|
203 | /** |
---|
204 | * return the current list of SEI messages associated with this picture. |
---|
205 | * Pointer is valid until this->destroy() is called */ |
---|
206 | SEImessages* getSEIs() { return m_SEIs; } |
---|
207 | |
---|
208 | /** |
---|
209 | * return the current list of SEI messages associated with this picture. |
---|
210 | * Pointer is valid until this->destroy() is called */ |
---|
211 | const SEImessages* getSEIs() const { return m_SEIs; } |
---|
212 | #if REF_IDX_FRAMEWORK |
---|
213 | Void copyUpsampledPictureYuv(TComPicYuv* pcPicYuvIn, TComPicYuv* pcPicYuvOut); |
---|
214 | #endif |
---|
215 | #if AVC_SYNTAX |
---|
216 | Void readBLSyntax( fstream* filestream, UInt numBytes ); |
---|
217 | #endif |
---|
218 | #if SYNTAX_OUTPUT |
---|
219 | Void wrireBLSyntax( fstream* filestream, UInt numBytes ); |
---|
220 | #endif |
---|
221 | |
---|
222 | };// END CLASS DEFINITION TComPic |
---|
223 | |
---|
224 | //! \} |
---|
225 | |
---|
226 | #endif // __TCOMPIC__ |
---|
227 | |
---|