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