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 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 | #include "SEI.h" |
---|
47 | #if AVC_BASE || SYNTAX_OUTPUT |
---|
48 | #include <fstream> |
---|
49 | #endif |
---|
50 | |
---|
51 | //! \ingroup TLibCommon |
---|
52 | //! \{ |
---|
53 | |
---|
54 | // ==================================================================================================================== |
---|
55 | // Class definition |
---|
56 | // ==================================================================================================================== |
---|
57 | |
---|
58 | /// picture class (symbol + YUV buffers) |
---|
59 | class TComPic |
---|
60 | { |
---|
61 | private: |
---|
62 | UInt m_uiTLayer; // Temporal layer |
---|
63 | Bool m_bUsedByCurr; // Used by current picture |
---|
64 | Bool m_bIsLongTerm; // IS long term picture |
---|
65 | TComPicSym* m_apcPicSym; // Symbol |
---|
66 | |
---|
67 | TComPicYuv* m_apcPicYuv[2]; // Texture, 0:org / 1:rec |
---|
68 | |
---|
69 | TComPicYuv* m_pcPicYuvPred; // Prediction |
---|
70 | TComPicYuv* m_pcPicYuvResi; // Residual |
---|
71 | Bool m_bReconstructed; |
---|
72 | Bool m_bNeededForOutput; |
---|
73 | UInt m_uiCurrSliceIdx; // Index of current slice |
---|
74 | Bool m_bCheckLTMSB; |
---|
75 | |
---|
76 | Int m_numReorderPics[MAX_TLAYER]; |
---|
77 | Window m_conformanceWindow; |
---|
78 | Window m_defaultDisplayWindow; |
---|
79 | |
---|
80 | Bool m_isTop; |
---|
81 | Bool m_isField; |
---|
82 | |
---|
83 | std::vector<std::vector<TComDataCU*> > m_vSliceCUDataLink; |
---|
84 | |
---|
85 | SEIMessages m_SEIs; ///< Any SEI messages that have been received. If !NULL we own the object. |
---|
86 | #if SVC_EXTENSION |
---|
87 | UInt m_layerId; // Layer ID |
---|
88 | Bool m_bSpatialEnhLayer[MAX_LAYERS]; // whether current layer is a spatial enhancement layer, |
---|
89 | TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS]; // upsampled base layer recontruction for difference domain inter prediction |
---|
90 | #endif |
---|
91 | #if Q0048_CGS_3D_ASYMLUT |
---|
92 | Int m_nFrameBit; |
---|
93 | #endif |
---|
94 | |
---|
95 | public: |
---|
96 | TComPic(); |
---|
97 | virtual ~TComPic(); |
---|
98 | |
---|
99 | #if SVC_EXTENSION |
---|
100 | #if AUXILIARY_PICTURES |
---|
101 | Void create( Int iWidth, Int iHeight, ChromaFormat chromaFormatIDC, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, |
---|
102 | Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); |
---|
103 | #else |
---|
104 | Void create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, |
---|
105 | Int *numReorderPics, TComSPS* pcSps = NULL, Bool bIsVirtual = false ); |
---|
106 | #endif |
---|
107 | #else |
---|
108 | Void create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, |
---|
109 | Int *numReorderPics, Bool bIsVirtual = false ); |
---|
110 | #endif //SVC_EXTENSION |
---|
111 | |
---|
112 | virtual Void destroy(); |
---|
113 | |
---|
114 | UInt getTLayer() { return m_uiTLayer; } |
---|
115 | Void setTLayer( UInt uiTLayer ) { m_uiTLayer = uiTLayer; } |
---|
116 | |
---|
117 | Bool getUsedByCurr() { return m_bUsedByCurr; } |
---|
118 | Void setUsedByCurr( Bool bUsed ) { m_bUsedByCurr = bUsed; } |
---|
119 | Bool getIsLongTerm() { return m_bIsLongTerm; } |
---|
120 | Void setIsLongTerm( Bool lt ) { m_bIsLongTerm = lt; } |
---|
121 | Void setCheckLTMSBPresent (Bool b ) {m_bCheckLTMSB=b;} |
---|
122 | Bool getCheckLTMSBPresent () { return m_bCheckLTMSB;} |
---|
123 | |
---|
124 | TComPicSym* getPicSym() { return m_apcPicSym; } |
---|
125 | TComSlice* getSlice(Int i) { return m_apcPicSym->getSlice(i); } |
---|
126 | Int getPOC() { return m_apcPicSym->getSlice(m_uiCurrSliceIdx)->getPOC(); } |
---|
127 | TComDataCU*& getCU( UInt uiCUAddr ) { return m_apcPicSym->getCU( uiCUAddr ); } |
---|
128 | |
---|
129 | TComPicYuv* getPicYuvOrg() { return m_apcPicYuv[0]; } |
---|
130 | TComPicYuv* getPicYuvRec() { return m_apcPicYuv[1]; } |
---|
131 | |
---|
132 | TComPicYuv* getPicYuvPred() { return m_pcPicYuvPred; } |
---|
133 | TComPicYuv* getPicYuvResi() { return m_pcPicYuvResi; } |
---|
134 | Void setPicYuvPred( TComPicYuv* pcPicYuv ) { m_pcPicYuvPred = pcPicYuv; } |
---|
135 | Void setPicYuvResi( TComPicYuv* pcPicYuv ) { m_pcPicYuvResi = pcPicYuv; } |
---|
136 | |
---|
137 | UInt getNumCUsInFrame() { return m_apcPicSym->getNumberOfCUsInFrame(); } |
---|
138 | UInt getNumPartInWidth() { return m_apcPicSym->getNumPartInWidth(); } |
---|
139 | UInt getNumPartInHeight() { return m_apcPicSym->getNumPartInHeight(); } |
---|
140 | UInt getNumPartInCU() { return m_apcPicSym->getNumPartition(); } |
---|
141 | UInt getFrameWidthInCU() { return m_apcPicSym->getFrameWidthInCU(); } |
---|
142 | UInt getFrameHeightInCU() { return m_apcPicSym->getFrameHeightInCU(); } |
---|
143 | UInt getMinCUWidth() { return m_apcPicSym->getMinCUWidth(); } |
---|
144 | UInt getMinCUHeight() { return m_apcPicSym->getMinCUHeight(); } |
---|
145 | |
---|
146 | UInt getParPelX(UChar uhPartIdx) { return getParPelX(uhPartIdx); } |
---|
147 | UInt getParPelY(UChar uhPartIdx) { return getParPelX(uhPartIdx); } |
---|
148 | |
---|
149 | Int getStride() { return m_apcPicYuv[1]->getStride(); } |
---|
150 | Int getCStride() { return m_apcPicYuv[1]->getCStride(); } |
---|
151 | |
---|
152 | Void setReconMark (Bool b) { m_bReconstructed = b; } |
---|
153 | Bool getReconMark () { return m_bReconstructed; } |
---|
154 | Void setOutputMark (Bool b) { m_bNeededForOutput = b; } |
---|
155 | Bool getOutputMark () { return m_bNeededForOutput; } |
---|
156 | |
---|
157 | Void setNumReorderPics(Int i, UInt tlayer) { m_numReorderPics[tlayer] = i; } |
---|
158 | Int getNumReorderPics(UInt tlayer) { return m_numReorderPics[tlayer]; } |
---|
159 | |
---|
160 | Void compressMotion(); |
---|
161 | UInt getCurrSliceIdx() { return m_uiCurrSliceIdx; } |
---|
162 | Void setCurrSliceIdx(UInt i) { m_uiCurrSliceIdx = i; } |
---|
163 | UInt getNumAllocatedSlice() {return m_apcPicSym->getNumAllocatedSlice();} |
---|
164 | Void allocateNewSlice() {m_apcPicSym->allocateNewSlice(); } |
---|
165 | Void clearSliceBuffer() {m_apcPicSym->clearSliceBuffer(); } |
---|
166 | |
---|
167 | Window& getConformanceWindow() { return m_conformanceWindow; } |
---|
168 | Window& getDefDisplayWindow() { return m_defaultDisplayWindow; } |
---|
169 | |
---|
170 | Bool getSAOMergeAvailability(Int currAddr, Int mergeAddr); |
---|
171 | |
---|
172 | /* field coding parameters*/ |
---|
173 | |
---|
174 | Void setTopField(bool b) {m_isTop = b;} |
---|
175 | Bool isTopField() {return m_isTop;} |
---|
176 | Void setField(bool b) {m_isField = b;} |
---|
177 | Bool isField() {return m_isField;} |
---|
178 | |
---|
179 | /** transfer ownership of seis to this picture */ |
---|
180 | void setSEIs(SEIMessages& seis) { m_SEIs = seis; } |
---|
181 | |
---|
182 | /** |
---|
183 | * return the current list of SEI messages associated with this picture. |
---|
184 | * Pointer is valid until this->destroy() is called */ |
---|
185 | SEIMessages& getSEIs() { return m_SEIs; } |
---|
186 | |
---|
187 | /** |
---|
188 | * return the current list of SEI messages associated with this picture. |
---|
189 | * Pointer is valid until this->destroy() is called */ |
---|
190 | const SEIMessages& getSEIs() const { return m_SEIs; } |
---|
191 | |
---|
192 | #if SVC_EXTENSION |
---|
193 | Void setLayerId (UInt layerId) { m_layerId = layerId; } |
---|
194 | UInt getLayerId () { return m_layerId; } |
---|
195 | Bool isSpatialEnhLayer(UInt refLayerIdc) { return m_bSpatialEnhLayer[refLayerIdc]; } |
---|
196 | Void setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; } |
---|
197 | Void setFullPelBaseRec (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; } |
---|
198 | TComPicYuv* getFullPelBaseRec (UInt refLayerIdc) { return m_pcFullPelBaseRec[refLayerIdc]; } |
---|
199 | #if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM |
---|
200 | Bool isILR( UInt currLayerId ) { return ( m_bIsLongTerm && m_layerId < currLayerId ); } |
---|
201 | #endif |
---|
202 | #if REF_IDX_MFM |
---|
203 | Void copyUpsampledMvField ( UInt refLayerIdc, TComPic* pcPicBase ); |
---|
204 | Void initUpsampledMvField (); |
---|
205 | #endif |
---|
206 | #if MFM_ENCCONSTRAINT |
---|
207 | Bool checkSameRefInfo(); |
---|
208 | #endif |
---|
209 | #if AUXILIARY_PICTURES |
---|
210 | ChromaFormat getChromaFormat() const { return m_apcPicYuv[1]->getChromaFormat(); } |
---|
211 | #endif |
---|
212 | Void copyUpsampledPictureYuv(TComPicYuv* pcPicYuvIn, TComPicYuv* pcPicYuvOut); |
---|
213 | #if AVC_SYNTAX |
---|
214 | Void readBLSyntax( fstream* filestream, UInt numBytes ); |
---|
215 | #endif |
---|
216 | #endif |
---|
217 | #if SYNTAX_OUTPUT |
---|
218 | Void wrireBLSyntax( fstream* filestream, UInt numBytes ); |
---|
219 | #endif |
---|
220 | |
---|
221 | #if Q0048_CGS_3D_ASYMLUT |
---|
222 | Void setFrameBit( Int n ) { m_nFrameBit = n; } |
---|
223 | Int getFrameBit() { return m_nFrameBit; } |
---|
224 | #endif |
---|
225 | };// END CLASS DEFINITION TComPic |
---|
226 | |
---|
227 | //! \} |
---|
228 | |
---|
229 | #endif // __TCOMPIC__ |
---|