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 TEncGOP.h |
---|
35 | \brief GOP encoder class (header) |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef __TENCGOP__ |
---|
39 | #define __TENCGOP__ |
---|
40 | |
---|
41 | #include <list> |
---|
42 | |
---|
43 | #include <stdlib.h> |
---|
44 | |
---|
45 | #include "TLibCommon/TComList.h" |
---|
46 | #include "TLibCommon/TComPic.h" |
---|
47 | #include "TLibCommon/TComBitCounter.h" |
---|
48 | #include "TLibCommon/TComLoopFilter.h" |
---|
49 | #include "TLibCommon/AccessUnit.h" |
---|
50 | #include "TEncSampleAdaptiveOffset.h" |
---|
51 | #include "TEncSlice.h" |
---|
52 | #include "TEncEntropy.h" |
---|
53 | #include "TEncCavlc.h" |
---|
54 | #include "TEncSbac.h" |
---|
55 | #include "SEIwrite.h" |
---|
56 | |
---|
57 | #include "TEncAnalyze.h" |
---|
58 | #include "TEncRateCtrl.h" |
---|
59 | #include <vector> |
---|
60 | |
---|
61 | //! \ingroup TLibEncoder |
---|
62 | //! \{ |
---|
63 | |
---|
64 | class TEncTop; |
---|
65 | |
---|
66 | // ==================================================================================================================== |
---|
67 | // Class definition |
---|
68 | // ==================================================================================================================== |
---|
69 | |
---|
70 | /// GOP encoder class |
---|
71 | class TEncGOP |
---|
72 | { |
---|
73 | private: |
---|
74 | // Data |
---|
75 | Bool m_bLongtermTestPictureHasBeenCoded; |
---|
76 | Bool m_bLongtermTestPictureHasBeenCoded2; |
---|
77 | UInt m_numLongTermRefPicSPS; |
---|
78 | UInt m_ltRefPicPocLsbSps[33]; |
---|
79 | Bool m_ltRefPicUsedByCurrPicFlag[33]; |
---|
80 | Int m_iLastIDR; |
---|
81 | Int m_iGopSize; |
---|
82 | Int m_iNumPicCoded; |
---|
83 | Bool m_bFirst; |
---|
84 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
85 | Int m_iLastRecoveryPicPOC; |
---|
86 | #endif |
---|
87 | |
---|
88 | // Access channel |
---|
89 | TEncTop* m_pcEncTop; |
---|
90 | TEncCfg* m_pcCfg; |
---|
91 | TEncSlice* m_pcSliceEncoder; |
---|
92 | TComList<TComPic*>* m_pcListPic; |
---|
93 | |
---|
94 | TEncEntropy* m_pcEntropyCoder; |
---|
95 | TEncCavlc* m_pcCavlcCoder; |
---|
96 | TEncSbac* m_pcSbacCoder; |
---|
97 | TEncBinCABAC* m_pcBinCABAC; |
---|
98 | TComLoopFilter* m_pcLoopFilter; |
---|
99 | |
---|
100 | SEIWriter m_seiWriter; |
---|
101 | |
---|
102 | //--Adaptive Loop filter |
---|
103 | TEncSampleAdaptiveOffset* m_pcSAO; |
---|
104 | TComBitCounter* m_pcBitCounter; |
---|
105 | TEncRateCtrl* m_pcRateCtrl; |
---|
106 | // indicate sequence first |
---|
107 | Bool m_bSeqFirst; |
---|
108 | |
---|
109 | // clean decoding refresh |
---|
110 | Bool m_bRefreshPending; |
---|
111 | Int m_pocCRA; |
---|
112 | std::vector<Int> m_storedStartCUAddrForEncodingSlice; |
---|
113 | std::vector<Int> m_storedStartCUAddrForEncodingSliceSegment; |
---|
114 | #if FIX1172 |
---|
115 | NalUnitType m_associatedIRAPType; |
---|
116 | Int m_associatedIRAPPOC; |
---|
117 | #endif |
---|
118 | |
---|
119 | std::vector<Int> m_vRVM_RP; |
---|
120 | UInt m_lastBPSEI; |
---|
121 | UInt m_totalCoded; |
---|
122 | UInt m_cpbRemovalDelay; |
---|
123 | UInt m_tl0Idx; |
---|
124 | UInt m_rapIdx; |
---|
125 | Bool m_activeParameterSetSEIPresentInAU; |
---|
126 | Bool m_bufferingPeriodSEIPresentInAU; |
---|
127 | Bool m_pictureTimingSEIPresentInAU; |
---|
128 | Bool m_nestedBufferingPeriodSEIPresentInAU; |
---|
129 | Bool m_nestedPictureTimingSEIPresentInAU; |
---|
130 | |
---|
131 | #if SVC_EXTENSION |
---|
132 | UInt m_layerId; |
---|
133 | TEncTop** m_ppcTEncTop; |
---|
134 | #if SVC_UPSAMPLING |
---|
135 | TEncSearch* m_pcPredSearch; ///< encoder search class |
---|
136 | #endif |
---|
137 | #endif |
---|
138 | |
---|
139 | public: |
---|
140 | TEncGOP(); |
---|
141 | virtual ~TEncGOP(); |
---|
142 | |
---|
143 | #if SVC_EXTENSION |
---|
144 | Void create ( UInt layerId ); |
---|
145 | #else |
---|
146 | Void create (); |
---|
147 | #endif |
---|
148 | Void destroy (); |
---|
149 | |
---|
150 | Void init ( TEncTop* pcTEncTop ); |
---|
151 | #if SVC_EXTENSION |
---|
152 | Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); |
---|
153 | #else |
---|
154 | Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); |
---|
155 | #endif |
---|
156 | Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); |
---|
157 | |
---|
158 | |
---|
159 | Int getGOPSize() { return m_iGopSize; } |
---|
160 | |
---|
161 | TComList<TComPic*>* getListPic() { return m_pcListPic; } |
---|
162 | |
---|
163 | #if !SVC_EXTENSION |
---|
164 | Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField); |
---|
165 | #endif |
---|
166 | Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); |
---|
167 | |
---|
168 | TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } |
---|
169 | NalUnitType getNalUnitType( Int pocCurr, Int lastIdr, Bool isField ); |
---|
170 | Void arrangeLongtermPicturesInRPS(TComSlice *, TComList<TComPic*>& ); |
---|
171 | protected: |
---|
172 | TEncRateCtrl* getRateCtrl() { return m_pcRateCtrl; } |
---|
173 | |
---|
174 | protected: |
---|
175 | |
---|
176 | Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); |
---|
177 | Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); |
---|
178 | Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); |
---|
179 | |
---|
180 | Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); |
---|
181 | Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); |
---|
182 | |
---|
183 | UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); |
---|
184 | |
---|
185 | Double xCalculateRVM(); |
---|
186 | |
---|
187 | SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); |
---|
188 | SEIFramePacking* xCreateSEIFramePacking(); |
---|
189 | SEIDisplayOrientation* xCreateSEIDisplayOrientation(); |
---|
190 | |
---|
191 | SEIToneMappingInfo* xCreateSEIToneMappingInfo(); |
---|
192 | |
---|
193 | Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); |
---|
194 | Int xGetFirstSeiLocation (AccessUnit &accessUnit); |
---|
195 | Void xResetNonNestedSEIPresentFlags() |
---|
196 | { |
---|
197 | m_activeParameterSetSEIPresentInAU = false; |
---|
198 | m_bufferingPeriodSEIPresentInAU = false; |
---|
199 | m_pictureTimingSEIPresentInAU = false; |
---|
200 | } |
---|
201 | Void xResetNestedSEIPresentFlags() |
---|
202 | { |
---|
203 | m_nestedBufferingPeriodSEIPresentInAU = false; |
---|
204 | m_nestedPictureTimingSEIPresentInAU = false; |
---|
205 | } |
---|
206 | Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); |
---|
207 | |
---|
208 | #if SVC_EXTENSION |
---|
209 | #if LAYERS_NOT_PRESENT_SEI |
---|
210 | SEILayersNotPresent* xCreateSEILayersNotPresent (); |
---|
211 | #endif |
---|
212 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
213 | Void xBuildTileSetsMap(TComPicSym* picSym); |
---|
214 | SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets(); |
---|
215 | #endif |
---|
216 | #if O0164_MULTI_LAYER_HRD |
---|
217 | SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice); |
---|
218 | #endif |
---|
219 | #endif //SVC_EXTENSION |
---|
220 | };// END CLASS DEFINITION TEncGOP |
---|
221 | |
---|
222 | // ==================================================================================================================== |
---|
223 | // Enumeration |
---|
224 | // ==================================================================================================================== |
---|
225 | enum PROCESSING_STATE |
---|
226 | { |
---|
227 | EXECUTE_INLOOPFILTER, |
---|
228 | ENCODE_SLICE |
---|
229 | }; |
---|
230 | |
---|
231 | enum SCALING_LIST_PARAMETER |
---|
232 | { |
---|
233 | SCALING_LIST_OFF, |
---|
234 | SCALING_LIST_DEFAULT, |
---|
235 | SCALING_LIST_FILE_READ |
---|
236 | }; |
---|
237 | |
---|
238 | //! \} |
---|
239 | |
---|
240 | #endif // __TENCGOP__ |
---|
241 | |
---|