1 | |
---|
2 | |
---|
3 | /** \file TAppEncTop.cpp |
---|
4 | \brief Encoder application class |
---|
5 | */ |
---|
6 | |
---|
7 | #include <list> |
---|
8 | #include <stdio.h> |
---|
9 | #include <fcntl.h> |
---|
10 | #include <assert.h> |
---|
11 | |
---|
12 | #include "TAppEncTop.h" |
---|
13 | |
---|
14 | // ==================================================================================================================== |
---|
15 | // Constructor / destructor / initialization / destroy |
---|
16 | // ==================================================================================================================== |
---|
17 | |
---|
18 | TAppEncTop::TAppEncTop() |
---|
19 | { |
---|
20 | //GT VSO |
---|
21 | m_iLastFramePutInERViewBuffer = -1; |
---|
22 | //GT VSO end |
---|
23 | } |
---|
24 | |
---|
25 | TAppEncTop::~TAppEncTop() |
---|
26 | { |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | Void TAppEncTop::xInitLibCfg() |
---|
31 | { |
---|
32 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
33 | { |
---|
34 | m_iFrameRcvdVector.push_back(0) ; |
---|
35 | m_acTEncTopList.push_back(new TEncTop); |
---|
36 | |
---|
37 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
38 | |
---|
39 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
40 | m_cListPicYuvRecList.push_back(new TComList<TComPicYuv*>) ; |
---|
41 | m_aiNextPocToDump.push_back( 0 ); |
---|
42 | m_cListPicYuvRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() ); |
---|
43 | m_acTEncTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
44 | m_acTEncTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
45 | m_acTEncTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
46 | m_acTEncTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
47 | m_acTEncTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
48 | |
---|
49 | //====== Coding Structure ======== |
---|
50 | #if DCM_DECODING_REFRESH |
---|
51 | m_acTEncTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
52 | #endif |
---|
53 | m_acTEncTopList[iViewIdx]->setCPSSize ( m_uiCodedPictureStoreSize ); |
---|
54 | m_acTEncTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
55 | m_acTEncTopList[iViewIdx]->setRateGOPSize ( m_iRateGOPSize ); |
---|
56 | |
---|
57 | // // SB |
---|
58 | m_acTEncTopList[iViewIdx]->setSeqStructure ( m_cInputFormatString ); |
---|
59 | |
---|
60 | m_acTEncTopList[iViewIdx]->setQP ( m_aiQP[0] ); |
---|
61 | |
---|
62 | m_acTEncTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
63 | m_acTEncTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
64 | |
---|
65 | //===== Slice ======== |
---|
66 | |
---|
67 | //====== Entropy Coding ======== |
---|
68 | m_acTEncTopList[iViewIdx]->setSymbolMode ( m_iSymbolMode ); |
---|
69 | |
---|
70 | //====== Loop/Deblock Filter ======== |
---|
71 | m_acTEncTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[0] ); |
---|
72 | m_acTEncTopList[iViewIdx]->setLoopFilterAlphaC0Offset ( m_iLoopFilterAlphaC0Offset ); |
---|
73 | m_acTEncTopList[iViewIdx]->setLoopFilterBetaOffset ( m_iLoopFilterBetaOffset ); |
---|
74 | |
---|
75 | //====== Motion search ======== |
---|
76 | m_acTEncTopList[iViewIdx]->setFastSearch ( m_iFastSearch ); |
---|
77 | m_acTEncTopList[iViewIdx]->setSearchRange ( m_iSearchRange ); |
---|
78 | m_acTEncTopList[iViewIdx]->setBipredSearchRange ( m_bipredSearchRange ); |
---|
79 | m_acTEncTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
80 | |
---|
81 | //====== VSO ========= |
---|
82 | //GT VSO |
---|
83 | m_acTEncTopList[iViewIdx]->setForceLambdaScaleVSO ( false ); |
---|
84 | m_acTEncTopList[iViewIdx]->setLambdaScaleVSO ( 1 ); |
---|
85 | m_acTEncTopList[iViewIdx]->setVSOMode ( 0 ); |
---|
86 | //GT VSO end |
---|
87 | |
---|
88 | //====== Tool list ======== |
---|
89 | m_acTEncTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
90 | m_acTEncTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
91 | m_acTEncTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
92 | m_acTEncTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
93 | m_acTEncTopList[iViewIdx]->setUseALF ( m_abUseALF[0] ); |
---|
94 | #if MQT_ALF_NPASS |
---|
95 | m_acTEncTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
96 | #endif |
---|
97 | #if DCM_COMB_LIST |
---|
98 | m_acTEncTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
99 | m_acTEncTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
100 | #endif |
---|
101 | m_acTEncTopList[iViewIdx]->setdQPs ( m_aidQP ); |
---|
102 | m_acTEncTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[0] ); |
---|
103 | m_acTEncTopList[iViewIdx]->setUseLDC ( m_bUseLDC ); |
---|
104 | m_acTEncTopList[iViewIdx]->setUsePAD ( m_bUsePAD ); |
---|
105 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
106 | m_acTEncTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
107 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
108 | m_acTEncTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
109 | m_acTEncTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
110 | |
---|
111 | //GT VSO |
---|
112 | m_acTEncTopList[iViewIdx]->setUseVSO ( false ); //GT: might be enabled later for VSO Mode 4 |
---|
113 | //GT VSO end |
---|
114 | |
---|
115 | m_acTEncTopList[iViewIdx]->setViewId ( (UInt)iViewIdx ); |
---|
116 | m_acTEncTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
117 | m_acTEncTopList[iViewIdx]->setIsDepth ( false ); |
---|
118 | m_acTEncTopList[iViewIdx]->setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
---|
119 | m_acTEncTopList[iViewIdx]->setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
---|
120 | m_acTEncTopList[iViewIdx]->setCodedScale ( m_cCameraData.getCodedScale () ); |
---|
121 | m_acTEncTopList[iViewIdx]->setCodedOffset ( m_cCameraData.getCodedOffset () ); |
---|
122 | m_acTEncTopList[iViewIdx]->setPredDepthMapGeneration ( m_uiPredDepthMapGeneration ); |
---|
123 | m_acTEncTopList[iViewIdx]->setMultiviewMvPredMode ( m_uiMultiviewMvPredMode ); |
---|
124 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegMode ( iViewIdx ? m_uiMultiviewMvRegMode : 0 ); |
---|
125 | m_acTEncTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( iViewIdx ? m_dMultiviewMvRegLambdaScale : 0.0 ); |
---|
126 | m_acTEncTopList[iViewIdx]->setPdmPrecision ( (UInt)m_cCameraData.getPdmPrecision () ); |
---|
127 | m_acTEncTopList[iViewIdx]->setPdmScaleNomDelta ( m_cCameraData.getPdmScaleNomDelta () ); |
---|
128 | m_acTEncTopList[iViewIdx]->setPdmOffset ( m_cCameraData.getPdmOffset () ); |
---|
129 | m_acTEncTopList[iViewIdx]->setMultiviewResPredMode ( m_uiMultiviewResPredMode ); |
---|
130 | |
---|
131 | #if SB_INTERVIEW_SKIP |
---|
132 | m_acTEncTopList[iViewIdx]->setInterViewSkip ( iViewIdx ? m_uiInterViewSkip : 0 ); |
---|
133 | #if SB_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
134 | m_acTEncTopList[iViewIdx]->setInterViewSkipLambdaScale ( iViewIdx ? m_dInterViewSkipLambdaScale : 1 ); |
---|
135 | #endif |
---|
136 | #endif |
---|
137 | m_acTEncTopList[iViewIdx]->setUseMRG ( m_bUseMRG ); // SOPH: |
---|
138 | |
---|
139 | #if LM_CHROMA |
---|
140 | m_acTEncTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
141 | #endif |
---|
142 | |
---|
143 | #if HHI_RMP_SWITCH |
---|
144 | m_acTEncTopList[iViewIdx]->setUseRMP ( m_bUseRMP ); |
---|
145 | #endif |
---|
146 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
147 | m_acTEncTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred); |
---|
148 | #endif |
---|
149 | #if HHI_DMM_INTRA |
---|
150 | m_acTEncTopList[iViewIdx]->setUseDepthModelModes( false ); |
---|
151 | #endif |
---|
152 | #if CONSTRAINED_INTRA_PRED |
---|
153 | m_acTEncTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
154 | #endif |
---|
155 | #ifdef WEIGHT_PRED |
---|
156 | //====== Weighted Prediction ======== |
---|
157 | m_acTEncTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
158 | m_acTEncTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
159 | #endif |
---|
160 | //====== Slice ======== |
---|
161 | m_acTEncTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
162 | m_acTEncTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
163 | |
---|
164 | //====== Entropy Slice ======== |
---|
165 | m_acTEncTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
166 | m_acTEncTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
167 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
168 | if(m_iSliceMode == 0 ) |
---|
169 | { |
---|
170 | m_bLFCrossSliceBoundaryFlag = true; |
---|
171 | } |
---|
172 | m_acTEncTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
173 | #endif |
---|
174 | #if MTK_SAO |
---|
175 | m_acTEncTopList[iViewIdx]->setUseSAO ( m_abUseSAO[0] ); |
---|
176 | #endif |
---|
177 | m_acTEncTopList[iViewIdx]->setUseMVI( false ); |
---|
178 | |
---|
179 | m_acTEncTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
180 | m_acTEncTopList[iViewIdx]->setOmitUnusedBlocks ( m_bOmitUnusedBlocks && (iViewIdx != 0) ); |
---|
181 | |
---|
182 | m_acTEncTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame ); |
---|
183 | m_acTEncTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo ); |
---|
184 | m_acTEncTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth ); |
---|
185 | } |
---|
186 | if( m_bUsingDepthMaps ) |
---|
187 | { |
---|
188 | |
---|
189 | //GT VSO |
---|
190 | for (Int iViewIdx=0; iViewIdx<m_iNumberOfExternalRefs; iViewIdx++) |
---|
191 | { |
---|
192 | m_acTVideoIOYuvERFileList.push_back(new TVideoIOYuv); |
---|
193 | } |
---|
194 | //GT VSO end |
---|
195 | |
---|
196 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
197 | { |
---|
198 | m_iDepthFrameRcvdVector.push_back(0) ; |
---|
199 | m_acTEncDepthTopList.push_back(new TEncTop); |
---|
200 | |
---|
201 | m_acTVideoIOYuvDepthInputFileList.push_back(new TVideoIOYuv); |
---|
202 | |
---|
203 | m_acTVideoIOYuvDepthReconFileList.push_back(new TVideoIOYuv); |
---|
204 | m_cListPicYuvDepthRecList.push_back(new TComList<TComPicYuv*>) ; |
---|
205 | m_aiNextDepthPocToDump.push_back( 0 ); |
---|
206 | m_cListPicYuvDepthRecMap.push_back( std::map<PicOrderCnt,TComPicYuv*>() ); |
---|
207 | m_acTEncDepthTopList[iViewIdx]->setFrameRate ( m_iFrameRate ); |
---|
208 | m_acTEncDepthTopList[iViewIdx]->setFrameSkip ( m_FrameSkip ); |
---|
209 | m_acTEncDepthTopList[iViewIdx]->setSourceWidth ( m_iSourceWidth ); |
---|
210 | m_acTEncDepthTopList[iViewIdx]->setSourceHeight ( m_iSourceHeight ); |
---|
211 | m_acTEncDepthTopList[iViewIdx]->setFrameToBeEncoded ( m_iFrameToBeEncoded ); |
---|
212 | |
---|
213 | //====== Coding Structure ======== |
---|
214 | #if DCM_DECODING_REFRESH |
---|
215 | m_acTEncDepthTopList[iViewIdx]->setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
216 | #endif |
---|
217 | m_acTEncDepthTopList[iViewIdx]->setCPSSize ( m_uiCodedPictureStoreSize ); |
---|
218 | m_acTEncDepthTopList[iViewIdx]->setGOPSize ( m_iGOPSize ); |
---|
219 | m_acTEncDepthTopList[iViewIdx]->setRateGOPSize ( m_iRateGOPSize ); |
---|
220 | |
---|
221 | // // SB |
---|
222 | m_acTEncDepthTopList[iViewIdx]->setSeqStructure ( m_cInputFormatString ); |
---|
223 | |
---|
224 | m_acTEncDepthTopList[iViewIdx]->setQP ( m_aiQP[1] ); |
---|
225 | |
---|
226 | m_acTEncDepthTopList[iViewIdx]->setTemporalLayerQPOffset ( m_aiTLayerQPOffset ); |
---|
227 | m_acTEncDepthTopList[iViewIdx]->setPad ( m_aiPad ); |
---|
228 | |
---|
229 | //===== Slice ======== |
---|
230 | |
---|
231 | //====== Entropy Coding ======== |
---|
232 | m_acTEncDepthTopList[iViewIdx]->setSymbolMode ( m_iSymbolMode ); |
---|
233 | |
---|
234 | //====== Loop/Deblock Filter ======== |
---|
235 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterDisable ( m_abLoopFilterDisable[1] ); |
---|
236 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterAlphaC0Offset ( m_iLoopFilterAlphaC0Offset ); |
---|
237 | m_acTEncDepthTopList[iViewIdx]->setLoopFilterBetaOffset ( m_iLoopFilterBetaOffset ); |
---|
238 | |
---|
239 | //====== Motion search ======== |
---|
240 | m_acTEncDepthTopList[iViewIdx]->setFastSearch ( m_iFastSearch ); |
---|
241 | m_acTEncDepthTopList[iViewIdx]->setSearchRange ( m_iSearchRange ); |
---|
242 | m_acTEncDepthTopList[iViewIdx]->setBipredSearchRange ( m_bipredSearchRange ); |
---|
243 | m_acTEncDepthTopList[iViewIdx]->setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
244 | |
---|
245 | //====== Tool list ======== |
---|
246 | m_acTEncDepthTopList[iViewIdx]->setUseSBACRD ( m_bUseSBACRD ); |
---|
247 | m_acTEncDepthTopList[iViewIdx]->setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
248 | m_acTEncDepthTopList[iViewIdx]->setUseASR ( m_bUseASR ); |
---|
249 | m_acTEncDepthTopList[iViewIdx]->setUseHADME ( m_bUseHADME ); |
---|
250 | m_acTEncDepthTopList[iViewIdx]->setUseALF ( m_abUseALF[1] ); |
---|
251 | #if MQT_ALF_NPASS |
---|
252 | m_acTEncDepthTopList[iViewIdx]->setALFEncodePassReduction ( m_iALFEncodePassReduction ); |
---|
253 | #endif |
---|
254 | #if DCM_COMB_LIST |
---|
255 | m_acTEncDepthTopList[iViewIdx]->setUseLComb ( m_bUseLComb ); |
---|
256 | m_acTEncDepthTopList[iViewIdx]->setLCMod ( m_bLCMod ); |
---|
257 | #endif |
---|
258 | m_acTEncDepthTopList[iViewIdx]->setdQPs ( m_aidQP ); |
---|
259 | m_acTEncDepthTopList[iViewIdx]->setUseRDOQ ( m_abUseRDOQ[1] ); |
---|
260 | m_acTEncDepthTopList[iViewIdx]->setUseLDC ( m_bUseLDC ); |
---|
261 | m_acTEncDepthTopList[iViewIdx]->setUsePAD ( m_bUsePAD ); |
---|
262 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
263 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
264 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
265 | m_acTEncDepthTopList[iViewIdx]->setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
266 | m_acTEncDepthTopList[iViewIdx]->setUseFastEnc ( m_bUseFastEnc ); |
---|
267 | |
---|
268 | //GT VSO |
---|
269 | m_acTEncDepthTopList[iViewIdx]->setUseVSO ( m_bUseVSO ); //GT: might be enabled/disabled later for VSO Mode 4 |
---|
270 | m_acTEncDepthTopList[iViewIdx]->setForceLambdaScaleVSO ( m_bForceLambdaScaleVSO ); |
---|
271 | m_acTEncDepthTopList[iViewIdx]->setLambdaScaleVSO ( m_dLambdaScaleVSO ); |
---|
272 | #if RDO_DIST_INT |
---|
273 | m_acTEncDepthTopList[iViewIdx]->setAllowNegDist ( m_bAllowNegDist ); |
---|
274 | #endif |
---|
275 | m_acTEncDepthTopList[iViewIdx]->setVSOMode ( m_uiVSOMode ); |
---|
276 | //GT VSO end |
---|
277 | |
---|
278 | m_acTEncDepthTopList[iViewIdx]->setViewId ( (UInt)iViewIdx ); |
---|
279 | m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] ); |
---|
280 | m_acTEncDepthTopList[iViewIdx]->setIsDepth ( true ); |
---|
281 | m_acTEncDepthTopList[iViewIdx]->setCamParPrecision ( 0 ); |
---|
282 | m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader ( false ); |
---|
283 | m_acTEncDepthTopList[iViewIdx]->setCodedScale ( 0 ); |
---|
284 | m_acTEncDepthTopList[iViewIdx]->setCodedOffset ( 0 ); |
---|
285 | m_acTEncDepthTopList[iViewIdx]->setPredDepthMapGeneration ( 0 ); |
---|
286 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvPredMode ( 0 ); |
---|
287 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegMode ( 0 ); |
---|
288 | m_acTEncDepthTopList[iViewIdx]->setMultiviewMvRegLambdaScale ( 0.0 ); |
---|
289 | m_acTEncDepthTopList[iViewIdx]->setMultiviewResPredMode ( 0 ); |
---|
290 | |
---|
291 | #if SB_INTERVIEW_SKIP |
---|
292 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkip ( 0 ); |
---|
293 | #if SB_INTERVIEW_SKIP_LAMBDA_SCALE |
---|
294 | m_acTEncDepthTopList[iViewIdx]->setInterViewSkipLambdaScale ( 1 ); |
---|
295 | #endif |
---|
296 | #endif |
---|
297 | m_acTEncDepthTopList[iViewIdx]->setUseMRG ( m_bUseMRG ); // SOPH: |
---|
298 | |
---|
299 | #if LM_CHROMA |
---|
300 | m_acTEncDepthTopList[iViewIdx]->setUseLMChroma ( m_bUseLMChroma ); |
---|
301 | #endif |
---|
302 | |
---|
303 | #if HHI_RMP_SWITCH |
---|
304 | m_acTEncDepthTopList[iViewIdx]->setUseRMP ( m_bUseRMP ); |
---|
305 | #endif |
---|
306 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
307 | m_acTEncDepthTopList[iViewIdx]->setUseRoundingControlBipred(m_useRoundingControlBipred); |
---|
308 | #endif |
---|
309 | #if HHI_DMM_INTRA |
---|
310 | m_acTEncDepthTopList[iViewIdx]->setUseDepthModelModes( m_bUseDepthModelModes ); |
---|
311 | #endif |
---|
312 | #if CONSTRAINED_INTRA_PRED |
---|
313 | m_acTEncDepthTopList[iViewIdx]->setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
314 | #endif |
---|
315 | #ifdef WEIGHT_PRED |
---|
316 | //====== Weighted Prediction ======== |
---|
317 | m_acTEncDepthTopList[iViewIdx]->setUseWP ( m_bUseWeightPred ); |
---|
318 | m_acTEncDepthTopList[iViewIdx]->setWPBiPredIdc ( m_uiBiPredIdc ); |
---|
319 | #endif |
---|
320 | //====== Slice ======== |
---|
321 | m_acTEncDepthTopList[iViewIdx]->setSliceMode ( m_iSliceMode ); |
---|
322 | m_acTEncDepthTopList[iViewIdx]->setSliceArgument ( m_iSliceArgument ); |
---|
323 | |
---|
324 | //====== Entropy Slice ======== |
---|
325 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceMode ( m_iEntropySliceMode ); |
---|
326 | m_acTEncDepthTopList[iViewIdx]->setEntropySliceArgument ( m_iEntropySliceArgument ); |
---|
327 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
328 | if(m_iSliceMode == 0 ) |
---|
329 | { |
---|
330 | m_bLFCrossSliceBoundaryFlag = true; |
---|
331 | } |
---|
332 | m_acTEncDepthTopList[iViewIdx]->setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
333 | #endif |
---|
334 | #if MTK_SAO |
---|
335 | m_acTEncDepthTopList[iViewIdx]->setUseSAO ( m_abUseSAO[1] ); |
---|
336 | #endif |
---|
337 | m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI ); |
---|
338 | |
---|
339 | m_acTEncDepthTopList[iViewIdx]->setPictureDigestEnabled(m_pictureDigestEnabled); |
---|
340 | m_acTEncDepthTopList[iViewIdx]->setOmitUnusedBlocks ( m_bOmitUnusedBlocks && (iViewIdx != 0) ); |
---|
341 | |
---|
342 | m_acTEncDepthTopList[iViewIdx]->setQpChangeFrame( m_iQpChangeFrame ); |
---|
343 | m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetVideo( m_iQpChangeOffsetVideo ); |
---|
344 | m_acTEncDepthTopList[iViewIdx]->setQpChangeOffsetDepth( m_iQpChangeOffsetDepth ); |
---|
345 | } |
---|
346 | } |
---|
347 | else if( m_uiMultiviewMvRegMode ) |
---|
348 | { |
---|
349 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
350 | { |
---|
351 | m_acTVideoIOYuvDepthInputFileList.push_back( new TVideoIOYuv ); |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | //GT VSO |
---|
356 | if ( m_bUseVSO ) |
---|
357 | { |
---|
358 | if ( m_uiVSOMode == 4 ) |
---|
359 | { |
---|
360 | #if GERHARD_RM_DEBUG_MM |
---|
361 | m_cMMCheckModel .create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 ); |
---|
362 | #endif |
---|
363 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, m_iSourceHeight, LOG2_DISP_PREC_LUT, 0 ); |
---|
364 | |
---|
365 | for ( Int iViewNum = 0; iViewNum < m_iNumberOfViews; iViewNum++ ) |
---|
366 | { |
---|
367 | for (Int iContent = 0; iContent < 2; iContent++ ) |
---|
368 | { |
---|
369 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
370 | Bool bUseVSO = (iNumOfModels != 0); |
---|
371 | |
---|
372 | TEncTop* pcEncTop = ( iContent == 0 ) ? m_acTEncTopList[iViewNum] : m_acTEncDepthTopList[iViewNum]; |
---|
373 | pcEncTop->setUseVSO( bUseVSO ); |
---|
374 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
375 | |
---|
376 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
377 | { |
---|
378 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
379 | |
---|
380 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
381 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
382 | #if GERHARD_RM_DEBUG_MM |
---|
383 | m_cMMCheckModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
384 | #endif |
---|
385 | } |
---|
386 | } |
---|
387 | } |
---|
388 | } |
---|
389 | else |
---|
390 | { |
---|
391 | m_cRendererTop.init(m_iSourceWidth, m_iSourceHeight,true,0,0,true, 0,0,0,0,0,0,0,1,0,0 ); //GT: simplest configuration |
---|
392 | } |
---|
393 | |
---|
394 | } |
---|
395 | //GT VSO end |
---|
396 | m_cUsedPelsRenderer.init(m_iSourceWidth, m_iSourceHeight, true, 0, LOG2_DISP_PREC_LUT, true, 0, 0, 0, 0, 0, 6, 4, 1, 0, 6 ); |
---|
397 | } |
---|
398 | |
---|
399 | Void TAppEncTop::xCreateLib() |
---|
400 | { |
---|
401 | // Video I/O |
---|
402 | m_cTVideoIOBitsFile.openBits( m_pchBitstreamFile, true ); // write mode |
---|
403 | |
---|
404 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
405 | { |
---|
406 | m_acTVideoIOYuvInputFileList[iViewIdx]->open( m_pchInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
407 | m_acTVideoIOYuvInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight); |
---|
408 | m_acTVideoIOYuvReconFileList[iViewIdx]->open( m_pchReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
409 | |
---|
410 | // Neo Decoder |
---|
411 | m_acTEncTopList[iViewIdx]->create(); |
---|
412 | |
---|
413 | if( m_bUsingDepthMaps ) |
---|
414 | { |
---|
415 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
416 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight); |
---|
417 | |
---|
418 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->open( m_pchDepthReconFileList[iViewIdx], true, m_uiOutputBitDepth, m_uiInternalBitDepth); // write mode |
---|
419 | |
---|
420 | // Neo Decoder |
---|
421 | m_acTEncDepthTopList[iViewIdx]->create(); |
---|
422 | } |
---|
423 | else if( m_uiMultiviewMvRegMode ) |
---|
424 | { |
---|
425 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
426 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->skipFrames(m_FrameSkip, m_iSourceWidth, m_iSourceHeight); |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | //GT VSO |
---|
431 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++) |
---|
432 | { |
---|
433 | m_acTVideoIOYuvERFileList[iViewIdx]->open( m_pchERRefFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth ); // read mode |
---|
434 | } |
---|
435 | //GT VSO end |
---|
436 | } |
---|
437 | |
---|
438 | Void TAppEncTop::xDestroyLib() |
---|
439 | { |
---|
440 | |
---|
441 | m_cTVideoIOBitsFile.closeBits(); |
---|
442 | |
---|
443 | //GT VSO |
---|
444 | for ( Int iViewIdx = 0; iViewIdx < m_iNumberOfExternalRefs; iViewIdx++ ) |
---|
445 | { |
---|
446 | m_acTVideoIOYuvERFileList[iViewIdx]->close(); |
---|
447 | delete m_acTVideoIOYuvERFileList[iViewIdx]; |
---|
448 | m_acTVideoIOYuvERFileList[iViewIdx] = 0; |
---|
449 | }; |
---|
450 | //GT VSO end |
---|
451 | |
---|
452 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
453 | { |
---|
454 | m_acTVideoIOYuvInputFileList[iViewIdx]->close(); |
---|
455 | m_acTVideoIOYuvReconFileList[iViewIdx]->close(); |
---|
456 | |
---|
457 | delete m_acTVideoIOYuvInputFileList[iViewIdx] ; m_acTVideoIOYuvInputFileList[iViewIdx] = NULL; |
---|
458 | delete m_acTVideoIOYuvReconFileList[iViewIdx] ; m_acTVideoIOYuvReconFileList[iViewIdx] = NULL; |
---|
459 | |
---|
460 | delete m_cListPicYuvRecList[iViewIdx] ; m_cListPicYuvRecList[iViewIdx] = NULL; |
---|
461 | |
---|
462 | m_acTEncTopList[iViewIdx]->destroy(); |
---|
463 | delete m_acTEncTopList[iViewIdx] ; m_acTEncTopList[iViewIdx] = NULL; |
---|
464 | |
---|
465 | if( iViewIdx < Int( m_acTVideoIOYuvDepthInputFileList.size() ) && m_acTVideoIOYuvDepthInputFileList[iViewIdx] ) |
---|
466 | { |
---|
467 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->close( ); |
---|
468 | delete m_acTVideoIOYuvDepthInputFileList[iViewIdx] ; |
---|
469 | } |
---|
470 | if( iViewIdx < Int( m_acTVideoIOYuvDepthReconFileList.size() ) && m_acTVideoIOYuvDepthReconFileList[iViewIdx] ) |
---|
471 | { |
---|
472 | m_acTVideoIOYuvDepthReconFileList[iViewIdx]->close () ; |
---|
473 | delete m_acTVideoIOYuvDepthReconFileList[iViewIdx]; |
---|
474 | } |
---|
475 | if( iViewIdx < Int( m_acTEncDepthTopList.size() ) && m_acTEncDepthTopList[iViewIdx] ) |
---|
476 | { |
---|
477 | m_acTEncDepthTopList[iViewIdx]->destroy(); |
---|
478 | delete m_acTEncDepthTopList[iViewIdx]; |
---|
479 | } |
---|
480 | if( iViewIdx < Int( m_cListPicYuvDepthRecList.size() ) && m_cListPicYuvDepthRecList[iViewIdx] ) |
---|
481 | { |
---|
482 | delete m_cListPicYuvDepthRecList[iViewIdx ]; |
---|
483 | } |
---|
484 | } |
---|
485 | } |
---|
486 | |
---|
487 | Void TAppEncTop::xInitLib() |
---|
488 | { |
---|
489 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
490 | { |
---|
491 | m_acTEncTopList[iViewIdx]->init( this ); |
---|
492 | } |
---|
493 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
494 | { |
---|
495 | m_acTEncTopList[iViewIdx]->setTEncTopList( &m_acTEncTopList ); |
---|
496 | } |
---|
497 | if ( m_bUsingDepthMaps ) |
---|
498 | { |
---|
499 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
500 | { |
---|
501 | m_acTEncDepthTopList[iViewIdx]->init( this ); |
---|
502 | } |
---|
503 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
504 | { |
---|
505 | m_acTEncDepthTopList[iViewIdx]->setTEncTopList( &m_acTEncDepthTopList ); |
---|
506 | } |
---|
507 | } |
---|
508 | } |
---|
509 | |
---|
510 | // ==================================================================================================================== |
---|
511 | // Public member functions |
---|
512 | // ==================================================================================================================== |
---|
513 | |
---|
514 | /** |
---|
515 | - create internal class |
---|
516 | - initialize internal variable |
---|
517 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
518 | - delete allocated buffers |
---|
519 | - destroy internal class |
---|
520 | . |
---|
521 | */ |
---|
522 | //GT PRE LOAD ENC BUFFER |
---|
523 | Void TAppEncTop::encode() |
---|
524 | { |
---|
525 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
526 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
527 | TComPicYuv* pcPdmDepthOrg = new TComPicYuv; |
---|
528 | TComPicYuv* pcPicYuvRec = NULL; |
---|
529 | //TComPicYuv* pcDepthPicYuvRec = NULL; |
---|
530 | |
---|
531 | // initialize internal class & member variables |
---|
532 | xInitLibCfg(); |
---|
533 | xCreateLib(); |
---|
534 | xInitLib(); |
---|
535 | |
---|
536 | // main encoder loop |
---|
537 | |
---|
538 | //GT: setup and init Bools for Eos and Continue Reading |
---|
539 | Bool bAllEos = false; |
---|
540 | Bool bAllContinueReadingPics; |
---|
541 | std::vector<Bool> bEos ; |
---|
542 | std::vector<Bool> bContinueReadingPics ; |
---|
543 | |
---|
544 | Bool bAllDepthEos = false; |
---|
545 | Bool bAllContinueReadingDepthPics; |
---|
546 | std::vector<Bool> bDepthEos ; |
---|
547 | std::vector<Bool> bContinueReadingDepthPics ; |
---|
548 | |
---|
549 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
550 | { |
---|
551 | bEos.push_back( false ) ; |
---|
552 | bContinueReadingPics.push_back( true ); |
---|
553 | if( m_bUsingDepthMaps) |
---|
554 | { |
---|
555 | bDepthEos.push_back( false ) ; |
---|
556 | bContinueReadingDepthPics.push_back( true ) ; |
---|
557 | } |
---|
558 | } |
---|
559 | // allocate original YUV buffer |
---|
560 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
561 | if( m_bUsingDepthMaps) |
---|
562 | { |
---|
563 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
564 | } |
---|
565 | if( m_uiMultiviewMvRegMode ) |
---|
566 | { |
---|
567 | pcPdmDepthOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
568 | } |
---|
569 | |
---|
570 | TComBitstream* pcBitstream = new TComBitstream; |
---|
571 | pcBitstream->create( (m_iSourceWidth * m_iSourceHeight * 3) >> 1 ) ; //GT: is size reasonable ?? |
---|
572 | |
---|
573 | while ( !(bAllEos&& bAllContinueReadingPics) ) |
---|
574 | { |
---|
575 | bAllContinueReadingPics = false; |
---|
576 | bAllContinueReadingDepthPics = false; |
---|
577 | |
---|
578 | //GT: Read all Buffers |
---|
579 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) //GT; store frames first |
---|
580 | { |
---|
581 | if (!bEos[iViewIdx] && bContinueReadingPics[iViewIdx] ) //GT: read frames to buffer |
---|
582 | { |
---|
583 | // get buffers |
---|
584 | xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream |
---|
585 | // read input YUV file |
---|
586 | m_acTVideoIOYuvInputFileList[iViewIdx]->read( pcPicYuvOrg, m_aiPad ) ; |
---|
587 | bEos[iViewIdx] = ( m_acTVideoIOYuvInputFileList[iViewIdx]->isEof() == 1 ? true : false ); //GT: End of File |
---|
588 | bEos[iViewIdx] = ( m_iFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ? true : bEos[iViewIdx] ); //GT: FramesToBeEncoded Reached |
---|
589 | bAllEos = bAllEos|bEos[iViewIdx] ; |
---|
590 | |
---|
591 | if( m_uiMultiviewMvRegMode && iViewIdx ) |
---|
592 | { |
---|
593 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcPdmDepthOrg, m_aiPad, m_bUsingDepthMaps ); |
---|
594 | } |
---|
595 | |
---|
596 | // increase number of received frames |
---|
597 | m_iFrameRcvdVector[iViewIdx]++ ; |
---|
598 | } |
---|
599 | |
---|
600 | m_acTEncTopList[iViewIdx]->receivePic( bEos[iViewIdx], pcPicYuvOrg, m_cListPicYuvRecList[iViewIdx]->back(), ( m_uiMultiviewMvRegMode && iViewIdx ? pcPdmDepthOrg : 0 ) ); |
---|
601 | |
---|
602 | if( m_bUsingDepthMaps ) |
---|
603 | { |
---|
604 | if (!bDepthEos[iViewIdx] && bContinueReadingDepthPics[iViewIdx] ) |
---|
605 | { |
---|
606 | // get buffers |
---|
607 | xGetBuffer( pcPicYuvRec, iViewIdx, m_cListPicYuvDepthRecList ); // ringbuffer of size gopsize -> m_cListPicYuvRec, m_cListBitstream |
---|
608 | // read input YUV file |
---|
609 | m_acTVideoIOYuvDepthInputFileList[iViewIdx]->read( pcDepthPicYuvOrg, m_aiPad ) ; |
---|
610 | bDepthEos[iViewIdx] = ( m_acTVideoIOYuvDepthInputFileList[iViewIdx]->isEof() == 1 ? true : false ); |
---|
611 | bDepthEos[iViewIdx] = ( m_iDepthFrameRcvdVector[iViewIdx] == (m_iFrameToBeEncoded - 1) ? true : bDepthEos[iViewIdx] ); |
---|
612 | bAllDepthEos = bAllDepthEos|bDepthEos[iViewIdx] ; |
---|
613 | // increase number of received frames |
---|
614 | m_iDepthFrameRcvdVector[iViewIdx]++ ; |
---|
615 | } |
---|
616 | m_acTEncDepthTopList[iViewIdx]->receivePic( bDepthEos[iViewIdx], pcDepthPicYuvOrg, m_cListPicYuvDepthRecList[iViewIdx]->back() ); |
---|
617 | } |
---|
618 | } |
---|
619 | |
---|
620 | //===== store current POC ===== |
---|
621 | Bool bCurrPocCoded = m_acTEncTopList[ 0 ]->currentPocWillBeCoded(); |
---|
622 | Int iCurrPoc = m_acTEncTopList[ 0 ]->getNextFrameId(); |
---|
623 | |
---|
624 | //===== update camera parameters ===== |
---|
625 | if( bCurrPocCoded ) |
---|
626 | { |
---|
627 | m_cCameraData.update( (UInt)iCurrPoc ); |
---|
628 | } |
---|
629 | |
---|
630 | //GT VSO |
---|
631 | if ( m_bUseVSO && ( m_uiVSOMode != 4) ) |
---|
632 | { |
---|
633 | //GT: Read external reference pics or render references |
---|
634 | xStoreVSORefPicsInBuffer(); //GT; |
---|
635 | } |
---|
636 | //GT VSO end |
---|
637 | |
---|
638 | //GT: Encode |
---|
639 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) // Start encoding |
---|
640 | { |
---|
641 | bool bThisViewContinueReadingPics = bContinueReadingPics[iViewIdx]; |
---|
642 | m_acTEncTopList[iViewIdx]->encode( bEos[iViewIdx], m_cListPicYuvRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingPics ); |
---|
643 | bContinueReadingPics[iViewIdx]=bThisViewContinueReadingPics; |
---|
644 | bAllContinueReadingPics = bAllContinueReadingPics||bContinueReadingPics[iViewIdx]; |
---|
645 | |
---|
646 | if(pcBitstream->getNumberOfWrittenBits()!=0) |
---|
647 | { |
---|
648 | m_cTVideoIOBitsFile.writeBits( pcBitstream ); |
---|
649 | } |
---|
650 | pcBitstream->resetBits(); //GT: also done later in .... |
---|
651 | pcBitstream->rewindStreamPacket( ); |
---|
652 | // write bistream to file if necessary |
---|
653 | xWriteOutput( iViewIdx ); //GT: Write Reconfiles (when gop is complete?) |
---|
654 | |
---|
655 | if( m_bUsingDepthMaps ) |
---|
656 | { |
---|
657 | bool bThisViewContinueReadingDepthPics = bContinueReadingDepthPics[iViewIdx]; |
---|
658 | m_acTEncDepthTopList[iViewIdx]->encode( bDepthEos[iViewIdx], m_cListPicYuvDepthRecMap[iViewIdx], pcBitstream, bThisViewContinueReadingDepthPics ); |
---|
659 | bContinueReadingDepthPics[iViewIdx]=bThisViewContinueReadingDepthPics; |
---|
660 | |
---|
661 | bAllContinueReadingDepthPics = bAllContinueReadingDepthPics||bContinueReadingDepthPics[iViewIdx]; |
---|
662 | if(pcBitstream->getNumberOfWrittenBits()!=0) |
---|
663 | { |
---|
664 | m_cTVideoIOBitsFile.writeBits( pcBitstream ); |
---|
665 | } |
---|
666 | pcBitstream->resetBits(); |
---|
667 | pcBitstream->rewindStreamPacket( ); |
---|
668 | // write bistream to file if necessary |
---|
669 | xWriteOutput( iViewIdx, true ); |
---|
670 | } |
---|
671 | } |
---|
672 | |
---|
673 | // delete extra picture buffers |
---|
674 | if( bCurrPocCoded ) |
---|
675 | { |
---|
676 | for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
677 | { |
---|
678 | if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] ) |
---|
679 | { |
---|
680 | m_acTEncTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc ); |
---|
681 | } |
---|
682 | if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] ) |
---|
683 | { |
---|
684 | m_acTEncDepthTopList[iViewIdx]->deleteExtraPicBuffers( iCurrPoc ); |
---|
685 | } |
---|
686 | } |
---|
687 | } |
---|
688 | |
---|
689 | #if AMVP_BUFFERCOMPRESS |
---|
690 | // compress motion for entire access |
---|
691 | if( bCurrPocCoded ) |
---|
692 | { |
---|
693 | for( Int iViewIdx = 0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
694 | { |
---|
695 | if( iViewIdx < (Int)m_acTEncTopList.size() && m_acTEncTopList[iViewIdx] ) |
---|
696 | { |
---|
697 | m_acTEncTopList[iViewIdx]->compressMotion( iCurrPoc ); |
---|
698 | } |
---|
699 | if( iViewIdx < (Int)m_acTEncDepthTopList.size() && m_acTEncDepthTopList[iViewIdx] ) |
---|
700 | { |
---|
701 | m_acTEncDepthTopList[iViewIdx]->compressMotion( iCurrPoc ); |
---|
702 | } |
---|
703 | } |
---|
704 | } |
---|
705 | #endif |
---|
706 | } |
---|
707 | |
---|
708 | // write output |
---|
709 | for(Int iViewIdx=0; iViewIdx < m_iNumberOfViews; iViewIdx++ ) |
---|
710 | { |
---|
711 | m_acTEncTopList[iViewIdx]->printOutSummary(m_acTEncTopList[iViewIdx]->getNumAllPicCoded()); |
---|
712 | if ( m_bUsingDepthMaps ) |
---|
713 | { |
---|
714 | m_acTEncDepthTopList[iViewIdx]->printOutSummary(m_acTEncDepthTopList[iViewIdx]->getNumAllPicCoded()); |
---|
715 | } |
---|
716 | } |
---|
717 | |
---|
718 | // delete original YUV buffer |
---|
719 | pcPicYuvOrg->destroy(); |
---|
720 | delete pcPicYuvOrg; |
---|
721 | pcPicYuvOrg = NULL; |
---|
722 | |
---|
723 | // valgrind |
---|
724 | if( m_bUsingDepthMaps) |
---|
725 | { |
---|
726 | pcDepthPicYuvOrg->destroy(); |
---|
727 | } |
---|
728 | delete pcDepthPicYuvOrg ; |
---|
729 | pcDepthPicYuvOrg = NULL ; |
---|
730 | |
---|
731 | // SB valgrid |
---|
732 | pcBitstream->destroy(); |
---|
733 | delete pcBitstream; |
---|
734 | pcBitstream = NULL ; |
---|
735 | |
---|
736 | |
---|
737 | // delete used buffers in encoder class |
---|
738 | for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++) |
---|
739 | { |
---|
740 | m_acTEncTopList[iViewIdx]->deletePicBuffer() ; |
---|
741 | } |
---|
742 | |
---|
743 | if( m_bUsingDepthMaps) |
---|
744 | { |
---|
745 | for(Int iViewIdx =0; iViewIdx < m_iNumberOfViews; iViewIdx++) |
---|
746 | { |
---|
747 | m_acTEncDepthTopList[iViewIdx]->deletePicBuffer() ; |
---|
748 | } |
---|
749 | } |
---|
750 | |
---|
751 | if ( pcPdmDepthOrg ) |
---|
752 | { |
---|
753 | pcPdmDepthOrg->destroy(); |
---|
754 | delete pcPdmDepthOrg; |
---|
755 | pcPdmDepthOrg = NULL; |
---|
756 | } |
---|
757 | |
---|
758 | // delete buffers & classes |
---|
759 | xDeleteBuffer(); |
---|
760 | xDestroyLib(); |
---|
761 | } |
---|
762 | |
---|
763 | // ==================================================================================================================== |
---|
764 | // Protected member functions |
---|
765 | // ==================================================================================================================== |
---|
766 | |
---|
767 | /** |
---|
768 | - application has picture buffer list with size of GOP |
---|
769 | - picture buffer list acts as ring buffer |
---|
770 | - end of the list has the latest picture |
---|
771 | . |
---|
772 | */ |
---|
773 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, Int iViewIdx, std::vector< TComList<TComPicYuv*>*>& racBuffer ) |
---|
774 | { |
---|
775 | if ( m_uiCodedPictureStoreSize == 0 ) |
---|
776 | { |
---|
777 | if (racBuffer[iViewIdx]->size() == 0) |
---|
778 | { |
---|
779 | rpcPicYuvRec = new TComPicYuv; |
---|
780 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
781 | |
---|
782 | racBuffer[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
783 | } |
---|
784 | rpcPicYuvRec = racBuffer[iViewIdx]->popFront(); //GT why? only one in list ?? A: only to get rpcPicYuvRec |
---|
785 | racBuffer[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
786 | return; |
---|
787 | } |
---|
788 | |
---|
789 | // org. buffer |
---|
790 | if ( racBuffer[iViewIdx]->size() == (UInt)m_uiCodedPictureStoreSize ) |
---|
791 | { |
---|
792 | rpcPicYuvRec = racBuffer[iViewIdx]->popFront(); |
---|
793 | } |
---|
794 | else |
---|
795 | { |
---|
796 | rpcPicYuvRec = new TComPicYuv; |
---|
797 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
798 | } |
---|
799 | racBuffer[iViewIdx]->pushBack( rpcPicYuvRec ); |
---|
800 | } |
---|
801 | |
---|
802 | Void TAppEncTop::xDeleteBuffer( ) |
---|
803 | { |
---|
804 | TComList<TComBitstream*>::iterator iterBitstream = m_cListBitstream.begin(); |
---|
805 | |
---|
806 | Int iSize = Int( m_cListBitstream.size() ); |
---|
807 | |
---|
808 | for ( Int i = 0; i < iSize; i++ ) |
---|
809 | { |
---|
810 | TComBitstream* pcBitstream = *(iterBitstream++); |
---|
811 | |
---|
812 | pcBitstream->destroy(); |
---|
813 | |
---|
814 | delete pcBitstream; pcBitstream = NULL; |
---|
815 | } |
---|
816 | |
---|
817 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
818 | { |
---|
819 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRecList[iViewIdx]->begin(); |
---|
820 | |
---|
821 | iSize = Int( m_cListPicYuvRecList[iViewIdx]->size() ); |
---|
822 | |
---|
823 | for ( Int i = 0; i < iSize; i++ ) |
---|
824 | { |
---|
825 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
826 | pcPicYuvRec->destroy(); |
---|
827 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
828 | } |
---|
829 | } |
---|
830 | if( m_bUsingDepthMaps) |
---|
831 | { |
---|
832 | for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++) |
---|
833 | { |
---|
834 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvDepthRecList[iViewIdx]->begin(); |
---|
835 | |
---|
836 | iSize = Int( m_cListPicYuvDepthRecList[iViewIdx]->size() ); |
---|
837 | |
---|
838 | for ( Int i = 0; i < iSize; i++ ) |
---|
839 | { |
---|
840 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
841 | pcPicYuvRec->destroy(); |
---|
842 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
843 | } |
---|
844 | } |
---|
845 | } |
---|
846 | |
---|
847 | // Delete ERFiles |
---|
848 | |
---|
849 | //GT VSO |
---|
850 | std::map< Int,vector<TComPicYuv*> >::iterator iterMapPicExtRefView = m_cMapPicExtRefView.begin(); |
---|
851 | while ( iterMapPicExtRefView != m_cMapPicExtRefView.end() ) |
---|
852 | { |
---|
853 | for ( UInt uiViewNumber = 0; uiViewNumber < iterMapPicExtRefView->second.size(); uiViewNumber++ ) |
---|
854 | { |
---|
855 | if ( iterMapPicExtRefView->second[uiViewNumber] ) |
---|
856 | { |
---|
857 | iterMapPicExtRefView->second[uiViewNumber]->destroy(); |
---|
858 | delete iterMapPicExtRefView->second[uiViewNumber]; |
---|
859 | } |
---|
860 | } |
---|
861 | iterMapPicExtRefView++; |
---|
862 | } |
---|
863 | //GT VSO end |
---|
864 | } |
---|
865 | |
---|
866 | /** \param iNumEncoded number of encoded frames |
---|
867 | */ |
---|
868 | Void TAppEncTop::xWriteOutput( Int iViewIdx, Bool isDepth ) |
---|
869 | { |
---|
870 | std::map<PicOrderCnt, TComPicYuv*> &rcMap = ( isDepth ? m_cListPicYuvDepthRecMap : m_cListPicYuvRecMap )[iViewIdx]; |
---|
871 | PicOrderCnt &riNextPocToDump = ( isDepth ? m_aiNextDepthPocToDump : m_aiNextPocToDump )[iViewIdx]; |
---|
872 | TVideoIOYuv* &rpcTVideoIOYuvReconFile = ( isDepth ? m_acTVideoIOYuvDepthReconFileList : m_acTVideoIOYuvReconFileList )[iViewIdx]; |
---|
873 | std::map<PicOrderCnt, TComPicYuv*>::iterator i; |
---|
874 | |
---|
875 | while( ! rcMap.empty() && ( i = rcMap.begin() )->first == riNextPocToDump ) |
---|
876 | { |
---|
877 | riNextPocToDump++; |
---|
878 | rpcTVideoIOYuvReconFile->write( i->second, m_aiPad ); |
---|
879 | rcMap.erase( i ); |
---|
880 | } |
---|
881 | } |
---|
882 | |
---|
883 | // GT FIX |
---|
884 | std::vector<TComPic*> TAppEncTop::getSpatialRefPics( Int iViewIdx, Int iPoc, Bool bIsDepthCoder ) |
---|
885 | { |
---|
886 | std::vector<TComPic*> apcRefPics( iViewIdx, (TComPic*)NULL ); |
---|
887 | for( int iRefViewIdx = 0; iRefViewIdx < iViewIdx; iRefViewIdx++ ) |
---|
888 | { |
---|
889 | // GT FIX |
---|
890 | TComPic* pcRefPic = xGetPicFromView(iRefViewIdx, iPoc, bIsDepthCoder); |
---|
891 | |
---|
892 | assert( pcRefPic != NULL ); |
---|
893 | apcRefPics[iRefViewIdx] = pcRefPic; |
---|
894 | } |
---|
895 | return apcRefPics; |
---|
896 | } |
---|
897 | |
---|
898 | |
---|
899 | TComPic* TAppEncTop::xGetPicFromView( Int iViewIdx, Int iPoc, bool bDepth ) |
---|
900 | { |
---|
901 | assert( ( iViewIdx >= 0) && ( iViewIdx < m_iNumberOfViews ) ); |
---|
902 | |
---|
903 | TComPic* pcPic = 0; |
---|
904 | TComList<TComPic*>* apcListPic; |
---|
905 | |
---|
906 | apcListPic = (bDepth ? m_acTEncDepthTopList[iViewIdx] : m_acTEncTopList[iViewIdx])->getListPic() ; |
---|
907 | |
---|
908 | for(TComList<TComPic*>::iterator it=apcListPic->begin(); it!=apcListPic->end(); it++) |
---|
909 | { |
---|
910 | if( (*it)->getPOC() == iPoc ) |
---|
911 | { |
---|
912 | pcPic = *it ; |
---|
913 | break ; |
---|
914 | } |
---|
915 | } |
---|
916 | |
---|
917 | return pcPic; |
---|
918 | }; |
---|
919 | |
---|
920 | TComPicYuv* TAppEncTop::xGetPicYuvFromView( Int iViewIdx, Int iPoc, Bool bDepth, Bool bRecon ) |
---|
921 | { |
---|
922 | TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth); |
---|
923 | TComPicYuv* pcPicYuv = NULL; |
---|
924 | |
---|
925 | if (pcPic != NULL) |
---|
926 | { |
---|
927 | if( bRecon ) |
---|
928 | { |
---|
929 | if ( pcPic->getReconMark() ) |
---|
930 | { |
---|
931 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
932 | } |
---|
933 | } |
---|
934 | else |
---|
935 | { |
---|
936 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
937 | } |
---|
938 | }; |
---|
939 | |
---|
940 | return pcPicYuv; |
---|
941 | }; |
---|
942 | |
---|
943 | Void TAppEncTop::xSetBasePicYuv( Int iViewIdx, Int iPoc, TComMVDRefData* pcRefInfo, InterViewReference eView, bool bDepth ) |
---|
944 | { |
---|
945 | |
---|
946 | if ( ( iViewIdx < 0) || ( iViewIdx >= m_iNumberOfViews ) ) |
---|
947 | return; |
---|
948 | |
---|
949 | if ( !m_bUsingDepthMaps && bDepth ) |
---|
950 | return; |
---|
951 | |
---|
952 | TComPic* pcPic = xGetPicFromView( iViewIdx, iPoc, bDepth); |
---|
953 | |
---|
954 | if (pcPic == 0) |
---|
955 | return; |
---|
956 | |
---|
957 | pcRefInfo->setPicYuvBaseView(eView, bDepth, pcPic->getPicYuvOrg(), pcPic->getReconMark() ? pcPic->getPicYuvRec() : NULL ); |
---|
958 | |
---|
959 | }; |
---|
960 | |
---|
961 | Void TAppEncTop::setMVDPic( Int iViewIdx, Int iPoc, TComMVDRefData* pcMVDRefData ) |
---|
962 | { |
---|
963 | AOF( iViewIdx >= 0); |
---|
964 | AOF( iViewIdx < m_iNumberOfViews ); |
---|
965 | |
---|
966 | xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, false); |
---|
967 | xSetBasePicYuv(iViewIdx , iPoc, pcMVDRefData, CURRVIEW, false ); |
---|
968 | xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, false ); |
---|
969 | |
---|
970 | if ( m_bUsingDepthMaps ) |
---|
971 | { |
---|
972 | xSetBasePicYuv(iViewIdx - 1, iPoc, pcMVDRefData, PREVVIEW, true ); |
---|
973 | xSetBasePicYuv(iViewIdx , iPoc, pcMVDRefData, CURRVIEW, true ); |
---|
974 | xSetBasePicYuv(iViewIdx + 1, iPoc, pcMVDRefData, NEXTVIEW, true ); |
---|
975 | } |
---|
976 | |
---|
977 | //GT campara |
---|
978 | xSetBaseLUT (iViewIdx, iViewIdx-1 , pcMVDRefData, PREVVIEW ); |
---|
979 | xSetBaseLUT (iViewIdx, iViewIdx+1 , pcMVDRefData, NEXTVIEW ); |
---|
980 | //GT campara end |
---|
981 | |
---|
982 | //GT VSO |
---|
983 | if ( m_bUseVSO && m_uiVSOMode != 4) |
---|
984 | { |
---|
985 | xSetERPicYuvs (iViewIdx, iPoc, pcMVDRefData); |
---|
986 | pcMVDRefData->setShiftLUTsERView(m_cCameraData.getSynthViewShiftLUTD()[iViewIdx], m_cCameraData.getSynthViewShiftLUTI()[iViewIdx] ); |
---|
987 | pcMVDRefData->setRefViewInd (m_aaiBaseViewRefInd[iViewIdx], m_aaiERViewRefInd[iViewIdx], m_aaiERViewRefLutInd[iViewIdx]); |
---|
988 | } |
---|
989 | //GT VSO end |
---|
990 | |
---|
991 | }; |
---|
992 | |
---|
993 | //GT campara |
---|
994 | Void TAppEncTop::xSetBaseLUT( Int iViewIdxSource, Int iViewIdxTarget, TComMVDRefData* pcRefInfo, InterViewReference eView ) |
---|
995 | { |
---|
996 | if ( ( iViewIdxSource < 0) || ( iViewIdxSource >= m_iNumberOfViews )||( iViewIdxTarget < 0) || ( iViewIdxTarget >= m_iNumberOfViews ) ) |
---|
997 | return; |
---|
998 | assert( abs( iViewIdxTarget - iViewIdxSource ) <= 1 ); //GT; Not supported yet |
---|
999 | pcRefInfo->setShiftLUTsBaseView(eView, m_cCameraData.getBaseViewShiftLUTD()[iViewIdxSource][iViewIdxTarget],m_cCameraData.getBaseViewShiftLUTI()[iViewIdxSource][iViewIdxTarget] ); |
---|
1000 | }; |
---|
1001 | //GT campara end |
---|
1002 | |
---|
1003 | |
---|
1004 | //GT VSO |
---|
1005 | Void TAppEncTop::xSetERPicYuvs( Int iViewIdx, Int iPoc, TComMVDRefData* pcReferenceInfo ) |
---|
1006 | { |
---|
1007 | std::vector<TComPicYuv*> apcExtRefViews; |
---|
1008 | |
---|
1009 | std::map< Int, vector<TComPicYuv*> >::iterator cMapIt; |
---|
1010 | cMapIt = m_cMapPicExtRefView.find(iPoc); |
---|
1011 | |
---|
1012 | assert( cMapIt != m_cMapPicExtRefView.end() ); |
---|
1013 | |
---|
1014 | pcReferenceInfo->setPicYuvERViews( cMapIt->second ); |
---|
1015 | } |
---|
1016 | |
---|
1017 | |
---|
1018 | |
---|
1019 | Void TAppEncTop::xStoreVSORefPicsInBuffer() |
---|
1020 | { |
---|
1021 | // X-Check if all Encoders have received the same number of pics |
---|
1022 | Int iNumRcvd = m_iFrameRcvdVector[0]; |
---|
1023 | for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber ++ ) |
---|
1024 | { |
---|
1025 | assert( ( m_iFrameRcvdVector[uiViewNumber] == iNumRcvd ) && ( m_iDepthFrameRcvdVector[uiViewNumber] == iNumRcvd ) ); //GT; if assert here, the encoder instances are not synchronized any more, re-think this function and the ERView Buffer!! |
---|
1026 | }; |
---|
1027 | |
---|
1028 | Int iCurPoc = iNumRcvd - 1; |
---|
1029 | |
---|
1030 | if ( iCurPoc <= m_iLastFramePutInERViewBuffer ) |
---|
1031 | { |
---|
1032 | return; |
---|
1033 | } |
---|
1034 | |
---|
1035 | std::vector<TComPicYuv*> apcExtRefViewVec; |
---|
1036 | |
---|
1037 | Int iNumberOfReferenceViews = 0; |
---|
1038 | if (m_iNumberOfExternalRefs != 0) |
---|
1039 | { |
---|
1040 | m_aaiERViewRefLutInd = m_aaiERViewRefInd; |
---|
1041 | // Insert Rendered Views form File |
---|
1042 | |
---|
1043 | iNumberOfReferenceViews = m_iNumberOfExternalRefs; |
---|
1044 | |
---|
1045 | for ( UInt uiViewNumber = 0; uiViewNumber < iNumberOfReferenceViews; uiViewNumber++ ) |
---|
1046 | { |
---|
1047 | TComPicYuv* pcPicYuvERView = new TComPicYuv; |
---|
1048 | pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1049 | |
---|
1050 | m_acTVideoIOYuvERFileList[uiViewNumber]->read( pcPicYuvERView, m_aiPad ) ; |
---|
1051 | |
---|
1052 | apcExtRefViewVec.push_back( pcPicYuvERView ); |
---|
1053 | } |
---|
1054 | } |
---|
1055 | else |
---|
1056 | { //Render Views |
---|
1057 | |
---|
1058 | for ( UInt uiViewNumber = 0; uiViewNumber < m_iNumberOfViews; uiViewNumber++ ) |
---|
1059 | { |
---|
1060 | m_aaiERViewRefInd [uiViewNumber].clear(); |
---|
1061 | m_aaiERViewRefLutInd[uiViewNumber].clear(); |
---|
1062 | } |
---|
1063 | |
---|
1064 | iNumberOfReferenceViews = 0; |
---|
1065 | for ( UInt iSynthViewIdx = 0; iSynthViewIdx < m_cCameraData.getSynthViewNumbers().size(); iSynthViewIdx++ ) |
---|
1066 | { |
---|
1067 | // Get Left and right view |
---|
1068 | Int iLeftViewIdx = -1; |
---|
1069 | Int iRightViewIdx = -1; |
---|
1070 | Bool bIsBaseView; |
---|
1071 | |
---|
1072 | Int iRelDistToLeft; |
---|
1073 | m_cCameraData.getLeftRightBaseView( iSynthViewIdx, iLeftViewIdx, iRightViewIdx, iRelDistToLeft, bIsBaseView ); |
---|
1074 | |
---|
1075 | if ((iLeftViewIdx == -1) || (iRightViewIdx == -1)) |
---|
1076 | { |
---|
1077 | std::cerr << "Left or right View not given." << endl; |
---|
1078 | exit(EXIT_FAILURE); |
---|
1079 | } |
---|
1080 | |
---|
1081 | m_cRendererTop.setShiftLUTs( |
---|
1082 | m_cCameraData.getSynthViewShiftLUTD()[iLeftViewIdx] [iSynthViewIdx], |
---|
1083 | m_cCameraData.getSynthViewShiftLUTI()[iLeftViewIdx] [iSynthViewIdx], |
---|
1084 | m_cCameraData.getBaseViewShiftLUTI ()[iLeftViewIdx] [iRightViewIdx], |
---|
1085 | m_cCameraData.getSynthViewShiftLUTD()[iRightViewIdx][iSynthViewIdx], |
---|
1086 | m_cCameraData.getSynthViewShiftLUTI()[iRightViewIdx][iSynthViewIdx], |
---|
1087 | m_cCameraData.getBaseViewShiftLUTI ()[iRightViewIdx][iLeftViewIdx], |
---|
1088 | iRelDistToLeft |
---|
1089 | ); |
---|
1090 | if ( bIsBaseView ) continue; |
---|
1091 | |
---|
1092 | // Render from left |
---|
1093 | TComPicYuv* pcPicYuvERView = new TComPicYuv; |
---|
1094 | pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1095 | m_cRendererTop.extrapolateView( xGetPicFromView( iLeftViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iLeftViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, true ); |
---|
1096 | |
---|
1097 | apcExtRefViewVec.push_back( pcPicYuvERView ); |
---|
1098 | |
---|
1099 | m_aaiERViewRefInd [ iLeftViewIdx].push_back( iNumberOfReferenceViews ); |
---|
1100 | m_aaiERViewRefLutInd[ iLeftViewIdx].push_back( iSynthViewIdx ); |
---|
1101 | iNumberOfReferenceViews++; |
---|
1102 | |
---|
1103 | //Render from right |
---|
1104 | pcPicYuvERView = new TComPicYuv; |
---|
1105 | pcPicYuvERView->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1106 | |
---|
1107 | m_cRendererTop.extrapolateView( xGetPicFromView( iRightViewIdx, iCurPoc, false )->getPicYuvOrg(), xGetPicFromView( iRightViewIdx, iCurPoc, true )->getPicYuvOrg(), pcPicYuvERView, false ); |
---|
1108 | apcExtRefViewVec.push_back( pcPicYuvERView ); |
---|
1109 | |
---|
1110 | m_aaiERViewRefInd [ iRightViewIdx].push_back( iNumberOfReferenceViews ); |
---|
1111 | m_aaiERViewRefLutInd[ iRightViewIdx].push_back( iSynthViewIdx ); |
---|
1112 | iNumberOfReferenceViews++; |
---|
1113 | } |
---|
1114 | } |
---|
1115 | |
---|
1116 | m_iLastFramePutInERViewBuffer++; |
---|
1117 | m_cMapPicExtRefView.insert( std::make_pair( m_iLastFramePutInERViewBuffer, apcExtRefViewVec ) ); |
---|
1118 | |
---|
1119 | if ( m_cMapPicExtRefView.size() > (UInt)m_iGOPSize + 1 ) |
---|
1120 | { |
---|
1121 | for ( UInt uiViewNumber = 0; uiViewNumber < (UInt) m_cMapPicExtRefView.begin()->second.size(); uiViewNumber++ ) |
---|
1122 | { |
---|
1123 | if ( m_cMapPicExtRefView.begin()->second[uiViewNumber] ) |
---|
1124 | { |
---|
1125 | m_cMapPicExtRefView.begin()->second[uiViewNumber]->destroy(); |
---|
1126 | delete m_cMapPicExtRefView.begin()->second[uiViewNumber]; |
---|
1127 | } |
---|
1128 | } |
---|
1129 | m_cMapPicExtRefView.erase ( m_cMapPicExtRefView.begin() ); |
---|
1130 | } |
---|
1131 | } |
---|
1132 | // GT VSO end |
---|
1133 | |
---|
1134 | Void TAppEncTop::getUsedPelsMap( Int iViewIdx, Int iPoc, TComPicYuv* pcPicYuvUsedSplsMap ) |
---|
1135 | { |
---|
1136 | AOT( iViewIdx <= 0); |
---|
1137 | AOT( iViewIdx >= m_iNumberOfViews ); |
---|
1138 | AOF( m_bOmitUnusedBlocks ); |
---|
1139 | AOF( m_cCameraData.getCurFrameId() == iPoc ); |
---|
1140 | |
---|
1141 | Int iViewSIdx = m_cCameraData.getBaseId2SortedId()[iViewIdx]; |
---|
1142 | Int iFirstViewSIdx = m_cCameraData.getBaseId2SortedId()[0]; |
---|
1143 | |
---|
1144 | AOT( iViewSIdx == iFirstViewSIdx ); |
---|
1145 | |
---|
1146 | Bool bFirstIsLeft = (iFirstViewSIdx < iViewSIdx); |
---|
1147 | |
---|
1148 | m_cUsedPelsRenderer.setShiftLUTs( |
---|
1149 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1150 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1151 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1152 | m_cCameraData.getBaseViewShiftLUTD()[0][iViewIdx], |
---|
1153 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1154 | m_cCameraData.getBaseViewShiftLUTI()[0][iViewIdx], |
---|
1155 | -1 |
---|
1156 | ); |
---|
1157 | |
---|
1158 | |
---|
1159 | TComPicYuv* pcPicYuvDepth = xGetPicYuvFromView(0, iPoc, true, true ); |
---|
1160 | AOF( pcPicYuvDepth); |
---|
1161 | |
---|
1162 | m_cUsedPelsRenderer.getUsedSamplesMap( pcPicYuvDepth, pcPicYuvUsedSplsMap, bFirstIsLeft ); |
---|
1163 | |
---|
1164 | } |
---|
1165 | |
---|
1166 | Void TAppEncTop::setupRenModel( Int iPoc, Int iEncViewIdx, Int iEncContent ) |
---|
1167 | { |
---|
1168 | Int iEncViewSIdx = m_cCameraData.getBaseId2SortedId()[ iEncViewIdx ]; |
---|
1169 | |
---|
1170 | // setup base views |
---|
1171 | Int iNumOfBV = m_cRenModStrParser.getNumOfBaseViewsForView( iEncViewSIdx, iEncContent ); |
---|
1172 | |
---|
1173 | for (Int iCurView = 0; iCurView < iNumOfBV; iCurView++ ) |
---|
1174 | { |
---|
1175 | Int iBaseViewSIdx; |
---|
1176 | Int iVideoDistMode; |
---|
1177 | Int iDepthDistMode; |
---|
1178 | |
---|
1179 | m_cRenModStrParser.getBaseViewData( iEncViewSIdx, iEncContent, iCurView, iBaseViewSIdx, iVideoDistMode, iDepthDistMode ); |
---|
1180 | |
---|
1181 | AOT( iVideoDistMode < 0 || iVideoDistMode > 2 ); |
---|
1182 | |
---|
1183 | Int iBaseViewIdx = m_cCameraData.getBaseSortedId2Id()[ iBaseViewSIdx ]; |
---|
1184 | |
---|
1185 | TComPicYuv* pcPicYuvVideoRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, true ); |
---|
1186 | TComPicYuv* pcPicYuvDepthRec = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , true ); |
---|
1187 | TComPicYuv* pcPicYuvVideoOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, false, false ); |
---|
1188 | TComPicYuv* pcPicYuvDepthOrg = xGetPicYuvFromView( iBaseViewIdx, iPoc, true , false ); |
---|
1189 | |
---|
1190 | TComPicYuv* pcPicYuvVideoRef = ( iVideoDistMode == 2 ) ? pcPicYuvVideoOrg : NULL; |
---|
1191 | TComPicYuv* pcPicYuvDepthRef = ( iDepthDistMode == 2 ) ? pcPicYuvDepthOrg : NULL; |
---|
1192 | |
---|
1193 | TComPicYuv* pcPicYuvVideoTest = ( iVideoDistMode == 0 ) ? pcPicYuvVideoOrg : pcPicYuvVideoRec; |
---|
1194 | TComPicYuv* pcPicYuvDepthTest = ( iDepthDistMode == 0 ) ? pcPicYuvDepthOrg : pcPicYuvDepthRec; |
---|
1195 | |
---|
1196 | AOT( (iVideoDistMode == 2) != (pcPicYuvVideoRef != NULL) ); |
---|
1197 | AOT( (iDepthDistMode == 2) != (pcPicYuvDepthRef != NULL) ); |
---|
1198 | AOT( pcPicYuvDepthTest == NULL ); |
---|
1199 | AOT( pcPicYuvVideoTest == NULL ); |
---|
1200 | |
---|
1201 | m_cRendererModel.setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1202 | #if GERHARD_RM_DEBUG_MM |
---|
1203 | m_cMMCheckModel .setBaseView( iBaseViewSIdx, pcPicYuvVideoTest, pcPicYuvDepthTest, pcPicYuvVideoRef, pcPicYuvDepthRef ); |
---|
1204 | #endif |
---|
1205 | } |
---|
1206 | |
---|
1207 | m_cRendererModel.setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1208 | #if GERHARD_RM_DEBUG_MM |
---|
1209 | m_cMMCheckModel .setErrorMode( iEncViewSIdx, iEncContent, 0 ); |
---|
1210 | #endif |
---|
1211 | |
---|
1212 | // setup virtual views |
---|
1213 | Int iNumOfSV = m_cRenModStrParser.getNumOfModelsForView( iEncViewSIdx, iEncContent ); |
---|
1214 | for (Int iCurView = 0; iCurView < iNumOfSV; iCurView++ ) |
---|
1215 | { |
---|
1216 | Int iOrgRefBaseViewSIdx; |
---|
1217 | Int iLeftBaseViewSIdx; |
---|
1218 | Int iRightBaseViewSIdx; |
---|
1219 | Int iSynthViewRelNum; |
---|
1220 | Int iModelNum; |
---|
1221 | Int iBlendMode; |
---|
1222 | m_cRenModStrParser.getSingleModelData(iEncViewSIdx, iEncContent, iCurView, iModelNum, iBlendMode,iLeftBaseViewSIdx, iRightBaseViewSIdx, iOrgRefBaseViewSIdx, iSynthViewRelNum ); |
---|
1223 | |
---|
1224 | Int iLeftBaseViewIdx = -1; |
---|
1225 | Int iRightBaseViewIdx = -1; |
---|
1226 | |
---|
1227 | TComPicYuv* pcPicYuvOrgRef = NULL; |
---|
1228 | Int** ppiShiftLUTLeft = NULL; |
---|
1229 | Int** ppiShiftLUTRight = NULL; |
---|
1230 | Int** ppiBaseShiftLUTLeft = NULL; |
---|
1231 | Int** ppiBaseShiftLUTRight = NULL; |
---|
1232 | |
---|
1233 | |
---|
1234 | Int iDistToLeft = -1; |
---|
1235 | |
---|
1236 | Int iSynthViewIdx = m_cCameraData.synthRelNum2Idx( iSynthViewRelNum ); |
---|
1237 | |
---|
1238 | if ( iLeftBaseViewSIdx != -1 ) |
---|
1239 | { |
---|
1240 | iLeftBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [ iLeftBaseViewSIdx ]; |
---|
1241 | ppiShiftLUTLeft = m_cCameraData.getSynthViewShiftLUTI()[ iLeftBaseViewIdx ][ iSynthViewIdx ]; |
---|
1242 | } |
---|
1243 | |
---|
1244 | if ( iRightBaseViewSIdx != -1 ) |
---|
1245 | { |
---|
1246 | iRightBaseViewIdx = m_cCameraData.getBaseSortedId2Id() [iRightBaseViewSIdx ]; |
---|
1247 | ppiShiftLUTRight = m_cCameraData.getSynthViewShiftLUTI()[ iRightBaseViewIdx ][ iSynthViewIdx ]; |
---|
1248 | } |
---|
1249 | |
---|
1250 | if ( iRightBaseViewSIdx != -1 && iLeftBaseViewSIdx != -1 ) |
---|
1251 | { |
---|
1252 | iDistToLeft = m_cCameraData.getRelDistLeft( iSynthViewIdx , iLeftBaseViewIdx, iRightBaseViewIdx); |
---|
1253 | ppiBaseShiftLUTLeft = m_cCameraData.getBaseViewShiftLUTI() [ iLeftBaseViewIdx ][ iRightBaseViewIdx ]; |
---|
1254 | ppiBaseShiftLUTRight = m_cCameraData.getBaseViewShiftLUTI() [ iRightBaseViewIdx ][ iLeftBaseViewIdx ]; |
---|
1255 | |
---|
1256 | } |
---|
1257 | |
---|
1258 | if ( iOrgRefBaseViewSIdx != -1 ) |
---|
1259 | { |
---|
1260 | pcPicYuvOrgRef = xGetPicYuvFromView( m_cCameraData.getBaseSortedId2Id()[ iOrgRefBaseViewSIdx ] , iPoc, false, false ); |
---|
1261 | AOF ( pcPicYuvOrgRef ); |
---|
1262 | } |
---|
1263 | |
---|
1264 | m_cRendererModel.setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
1265 | #if GERHARD_RM_DEBUG_MM |
---|
1266 | m_cMMCheckModel .setSingleModel( iModelNum, ppiShiftLUTLeft, ppiBaseShiftLUTLeft, ppiShiftLUTRight, ppiBaseShiftLUTRight, iDistToLeft, pcPicYuvOrgRef ); |
---|
1267 | #endif |
---|
1268 | } |
---|
1269 | } |
---|
1270 | |
---|
1271 | // GT VSO end |
---|