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