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-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TAppEncTop.cpp |
---|
35 | \brief Encoder application class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <list> |
---|
39 | #include <fstream> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <stdio.h> |
---|
42 | #include <fcntl.h> |
---|
43 | #include <assert.h> |
---|
44 | |
---|
45 | #include "TAppEncTop.h" |
---|
46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
47 | |
---|
48 | using namespace std; |
---|
49 | |
---|
50 | //! \ingroup TAppEncoder |
---|
51 | //! \{ |
---|
52 | |
---|
53 | // ==================================================================================================================== |
---|
54 | // Constructor / destructor / initialization / destroy |
---|
55 | // ==================================================================================================================== |
---|
56 | |
---|
57 | TAppEncTop::TAppEncTop() |
---|
58 | { |
---|
59 | #if !H_MV |
---|
60 | m_iFrameRcvd = 0; |
---|
61 | #endif |
---|
62 | m_totalBytes = 0; |
---|
63 | m_essentialBytes = 0; |
---|
64 | } |
---|
65 | |
---|
66 | TAppEncTop::~TAppEncTop() |
---|
67 | { |
---|
68 | } |
---|
69 | |
---|
70 | Void TAppEncTop::xInitLibCfg() |
---|
71 | { |
---|
72 | #if H_MV |
---|
73 | TComVPS& vps = m_vps; |
---|
74 | #else |
---|
75 | TComVPS vps; |
---|
76 | #endif |
---|
77 | |
---|
78 | #if H_MV |
---|
79 | Int maxTempLayer = -1; |
---|
80 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
81 | { |
---|
82 | maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); |
---|
83 | } |
---|
84 | |
---|
85 | vps.setMaxTLayers ( maxTempLayer ); |
---|
86 | if ( maxTempLayer ) |
---|
87 | { |
---|
88 | vps.setTemporalNestingFlag(true); |
---|
89 | } |
---|
90 | vps.setMaxLayers( m_numberOfLayers ); |
---|
91 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
92 | { |
---|
93 | Int maxNumReOrderPics = 0; |
---|
94 | Int maxDecPicBuffering = 0; |
---|
95 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
96 | { |
---|
97 | maxNumReOrderPics = max( maxNumReOrderPics, m_numReorderPicsMvc [ j ][ i ] ); |
---|
98 | maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] ); |
---|
99 | } |
---|
100 | |
---|
101 | vps.setNumReorderPics ( maxNumReOrderPics ,i ); |
---|
102 | vps.setMaxDecPicBuffering ( maxDecPicBuffering ,i ); |
---|
103 | } |
---|
104 | #else |
---|
105 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
106 | if (m_maxTempLayer == 1) |
---|
107 | { |
---|
108 | vps.setTemporalNestingFlag(true); |
---|
109 | } |
---|
110 | vps.setMaxLayers ( 1 ); |
---|
111 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
112 | { |
---|
113 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
114 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
115 | } |
---|
116 | #endif |
---|
117 | #if H_MV |
---|
118 | xSetLayerIds ( vps ); |
---|
119 | xSetDimensionIdAndLength ( vps ); |
---|
120 | xSetDependencies( vps ); |
---|
121 | xSetProfileTierLevel ( vps ); |
---|
122 | xSetLayerSets ( vps ); |
---|
123 | #if H_3D |
---|
124 | vps.initViewIndex(); |
---|
125 | xSetVPSExtension2 ( vps ); |
---|
126 | m_ivPicLists.setVPS ( &vps ); |
---|
127 | #endif |
---|
128 | |
---|
129 | for(Int layer = 0; layer < m_numberOfLayers; layer++) |
---|
130 | { |
---|
131 | m_frameRcvd .push_back(0); |
---|
132 | m_acTEncTopList .push_back(new TEncTop); |
---|
133 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
134 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
135 | m_picYuvRec .push_back(new TComList<TComPicYuv*>) ; |
---|
136 | |
---|
137 | m_ivPicLists.push_back( m_acTEncTopList[ layer ]->getListPic() ); |
---|
138 | TEncTop& m_cTEncTop = *m_acTEncTopList[ layer ]; // It is not a member, but this name helps avoiding code duplication !!! |
---|
139 | |
---|
140 | m_cTEncTop.setLayerIdInVps ( layer ); |
---|
141 | m_cTEncTop.setLayerId ( vps.getLayerIdInNuh( layer ) ); |
---|
142 | m_cTEncTop.setViewId ( vps.getViewId ( layer ) ); |
---|
143 | #if H_3D |
---|
144 | Bool isDepth = ( vps.getDepthId ( layer ) != 0 ) ; |
---|
145 | m_cTEncTop.setViewIndex ( vps.getViewIndex ( layer ) ); |
---|
146 | m_cTEncTop.setIsDepth ( isDepth ); |
---|
147 | //====== Camera Parameters ========= |
---|
148 | m_cTEncTop.setCameraParameters ( &m_cCameraData ); |
---|
149 | m_cTEncTop.setCamParPrecision ( isDepth ? false : m_cCameraData.getCamParsCodedPrecision () ); |
---|
150 | m_cTEncTop.setCamParInSliceHeader ( isDepth ? 0 : m_cCameraData.getVaryingCameraParameters() ); |
---|
151 | m_cTEncTop.setCodedScale ( isDepth ? 0 : m_cCameraData.getCodedScale () ); |
---|
152 | m_cTEncTop.setCodedOffset ( isDepth ? 0 : m_cCameraData.getCodedOffset () ); |
---|
153 | #if H_3D_VSO |
---|
154 | //====== VSO ========= |
---|
155 | m_cTEncTop.setRenderModelParameters ( &m_cRenModStrParser ); |
---|
156 | m_cTEncTop.setForceLambdaScaleVSO ( isDepth ? m_bForceLambdaScaleVSO : false ); |
---|
157 | m_cTEncTop.setLambdaScaleVSO ( isDepth ? m_dLambdaScaleVSO : 1 ); |
---|
158 | m_cTEncTop.setVSOMode ( isDepth ? m_uiVSOMode : 0 ); |
---|
159 | |
---|
160 | m_cTEncTop.setAllowNegDist ( isDepth ? m_bAllowNegDist : false ); |
---|
161 | |
---|
162 | // SAIT_VSO_EST_A0033 |
---|
163 | m_cTEncTop.setUseEstimatedVSD ( isDepth ? m_bUseEstimatedVSD : false ); |
---|
164 | |
---|
165 | // LGE_WVSO_A0119 |
---|
166 | m_cTEncTop.setUseWVSO ( isDepth ? m_bUseWVSO : false ); |
---|
167 | m_cTEncTop.setVSOWeight ( isDepth ? m_iVSOWeight : 0 ); |
---|
168 | m_cTEncTop.setVSDWeight ( isDepth ? m_iVSDWeight : 0 ); |
---|
169 | m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); |
---|
170 | #endif // H_3D_VSO |
---|
171 | #if H_3D_ARP |
---|
172 | //====== Advanced Inter-view Residual Prediction ========= |
---|
173 | m_cTEncTop.setUseAdvRP ( ( isDepth || 0==layer ) ? 0 : m_uiUseAdvResPred ); |
---|
174 | m_cTEncTop.setARPStepNum ( ( isDepth || 0==layer ) ? 1 : H_3D_ARP_WFNR ); |
---|
175 | #endif |
---|
176 | #if H_3D_IC |
---|
177 | m_cTEncTop.setUseIC ( vps.getViewIndex( layer ) == 0 ? false : m_abUseIC[isDepth ? 1 : 0] ); |
---|
178 | #endif |
---|
179 | //========== Depth intra modes ========== |
---|
180 | #if H_3D_DIM |
---|
181 | m_cTEncTop.setUseDMM ( isDepth ? m_useDMM : false ); |
---|
182 | m_cTEncTop.setUseRBC ( isDepth ? m_useRBC : false ); |
---|
183 | m_cTEncTop.setUseSDC ( isDepth ? m_useSDC : false ); |
---|
184 | m_cTEncTop.setUseDLT ( isDepth ? m_useDLT : false ); |
---|
185 | #endif |
---|
186 | #if H_3D_QTLPC |
---|
187 | m_cTEncTop.setUseQTL ( isDepth ? m_bUseQTL : false ); |
---|
188 | m_cTEncTop.setUsePC ( isDepth ? m_bUsePC : false ); |
---|
189 | #endif |
---|
190 | //====== Depth Inter SDC ========= |
---|
191 | #if LGE_INTER_SDC_E0156 |
---|
192 | m_cTEncTop.setInterSDCEnable ( isDepth ? m_bDepthInterSDCFlag : false ); |
---|
193 | #endif |
---|
194 | #endif // H_3D |
---|
195 | |
---|
196 | m_cTEncTop.setIvPicLists ( &m_ivPicLists ); |
---|
197 | #endif // H_MV |
---|
198 | m_cTEncTop.setVPS(&vps); |
---|
199 | |
---|
200 | m_cTEncTop.setProfile(m_profile); |
---|
201 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
202 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
203 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
204 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
205 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
206 | |
---|
207 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
208 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
209 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
210 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
211 | m_cTEncTop.setConformanceWindow ( m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
212 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
213 | |
---|
214 | //====== Coding Structure ======== |
---|
215 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
216 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
217 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
218 | #if H_MV |
---|
219 | m_cTEncTop.setGopList ( m_GOPListMvc[layer] ); |
---|
220 | m_cTEncTop.setExtraRPSs ( m_extraRPSsMvc[layer] ); |
---|
221 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
222 | { |
---|
223 | m_cTEncTop.setNumReorderPics ( m_numReorderPicsMvc[layer][i], i ); |
---|
224 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBufferingMvc[layer][i], i ); |
---|
225 | } |
---|
226 | #else |
---|
227 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
228 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
229 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
230 | { |
---|
231 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
232 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
233 | } |
---|
234 | #endif |
---|
235 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
236 | { |
---|
237 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
238 | } |
---|
239 | #if H_MV |
---|
240 | m_cTEncTop.setQP ( m_iQP[layer] ); |
---|
241 | #else |
---|
242 | m_cTEncTop.setQP ( m_iQP ); |
---|
243 | #endif |
---|
244 | |
---|
245 | m_cTEncTop.setPad ( m_aiPad ); |
---|
246 | |
---|
247 | #if H_MV |
---|
248 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayerMvc[layer] ); |
---|
249 | #else |
---|
250 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
251 | #endif |
---|
252 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
253 | |
---|
254 | //===== Slice ======== |
---|
255 | |
---|
256 | //====== Loop/Deblock Filter ======== |
---|
257 | #if H_MV |
---|
258 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable[layer]); |
---|
259 | #else |
---|
260 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
261 | #endif |
---|
262 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
263 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
264 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
265 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
266 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
267 | |
---|
268 | //====== Motion search ======== |
---|
269 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
270 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
271 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
272 | |
---|
273 | //====== Quality control ======== |
---|
274 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
275 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
276 | |
---|
277 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
278 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
279 | |
---|
280 | #if ADAPTIVE_QP_SELECTION |
---|
281 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
282 | #endif |
---|
283 | |
---|
284 | Int lowestQP; |
---|
285 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
286 | |
---|
287 | #if H_MV |
---|
288 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layer] == lowestQP) && (m_useLossless == true)) |
---|
289 | #else |
---|
290 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true)) |
---|
291 | #endif |
---|
292 | { |
---|
293 | m_bUseAdaptiveQP = false; |
---|
294 | } |
---|
295 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
296 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
297 | |
---|
298 | //====== Tool list ======== |
---|
299 | m_cTEncTop.setUseSBACRD ( m_bUseSBACRD ); |
---|
300 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
301 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
302 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
303 | m_cTEncTop.setUseLossless ( m_useLossless ); |
---|
304 | #if H_MV |
---|
305 | m_cTEncTop.setdQPs ( m_aidQP[layer] ); |
---|
306 | #else |
---|
307 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
308 | #endif |
---|
309 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
310 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
311 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
312 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
313 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
314 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
315 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
316 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
317 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
318 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
319 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
320 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
321 | |
---|
322 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
323 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
324 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
325 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
326 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
327 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
328 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
329 | |
---|
330 | |
---|
331 | //====== Weighted Prediction ======== |
---|
332 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
333 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
334 | //====== Parallel Merge Estimation ======== |
---|
335 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
336 | |
---|
337 | //====== Slice ======== |
---|
338 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
339 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
340 | |
---|
341 | //====== Dependent Slice ======== |
---|
342 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
343 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
344 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
345 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
346 | { |
---|
347 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
348 | } |
---|
349 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
350 | { |
---|
351 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
352 | } |
---|
353 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
354 | { |
---|
355 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
356 | } |
---|
357 | |
---|
358 | if(m_sliceMode == 0 ) |
---|
359 | { |
---|
360 | m_bLFCrossSliceBoundaryFlag = true; |
---|
361 | } |
---|
362 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
363 | #if H_MV |
---|
364 | m_cTEncTop.setUseSAO ( m_bUseSAO[layer] ); |
---|
365 | #else |
---|
366 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
367 | #endif |
---|
368 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
369 | |
---|
370 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
371 | m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
372 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
373 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
374 | |
---|
375 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
376 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
377 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
378 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
379 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
380 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
381 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
382 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
383 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
384 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
385 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
386 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
387 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
388 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
389 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
390 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
391 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
392 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
393 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
394 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
395 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
396 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
397 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
398 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
399 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
400 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
401 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
402 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
403 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
404 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
405 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
406 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
407 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
408 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
409 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
410 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
411 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
412 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
413 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
414 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
415 | m_cTEncTop.setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
416 | m_cTEncTop.setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
417 | m_cTEncTop.setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
418 | if(m_iUniformSpacingIdr==0) |
---|
419 | { |
---|
420 | m_cTEncTop.setColumnWidth ( m_pColumnWidth ); |
---|
421 | m_cTEncTop.setRowHeight ( m_pRowHeight ); |
---|
422 | } |
---|
423 | m_cTEncTop.xCheckGSParameters(); |
---|
424 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
425 | if(uiTilesCount == 1) |
---|
426 | { |
---|
427 | m_bLFCrossTileBoundaryFlag = true; |
---|
428 | } |
---|
429 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
430 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
431 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
432 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
433 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
434 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
435 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
436 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
437 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
438 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
439 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
440 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
441 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
442 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
443 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
444 | #else |
---|
445 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl); |
---|
446 | m_cTEncTop.setTargetBitrate ( m_targetBitrate); |
---|
447 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
---|
448 | #endif |
---|
449 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
450 | m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
451 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
452 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
453 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
454 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
455 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
456 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
457 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
458 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
459 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
460 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
461 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
462 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
463 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
464 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
465 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
466 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
467 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
468 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
469 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
470 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
471 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
472 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
473 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
474 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
475 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
476 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
477 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
478 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
479 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
480 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
481 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
482 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
483 | #if H_MV |
---|
484 | } |
---|
485 | #endif |
---|
486 | #if H_3D_VSO |
---|
487 | if ( m_bUseVSO ) |
---|
488 | { |
---|
489 | if ( m_uiVSOMode == 4 ) |
---|
490 | { |
---|
491 | #if H_3D_VSO_EARLY_SKIP |
---|
492 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
---|
493 | #else |
---|
494 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
---|
495 | #endif |
---|
496 | for ( Int layer = 0; layer < m_numberOfLayers ; layer++ ) |
---|
497 | { |
---|
498 | TEncTop* pcEncTop = m_acTEncTopList[ layer ]; |
---|
499 | Int iViewNum = pcEncTop->getViewIndex(); |
---|
500 | Int iContent = pcEncTop->getIsDepth() ? 1 : 0; |
---|
501 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
502 | |
---|
503 | Bool bUseVSO = (iNumOfModels != 0); |
---|
504 | |
---|
505 | pcEncTop->setUseVSO( bUseVSO ); |
---|
506 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
507 | |
---|
508 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
509 | { |
---|
510 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
511 | |
---|
512 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
513 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
514 | } |
---|
515 | } |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | AOT(true); |
---|
520 | } |
---|
521 | } |
---|
522 | #endif |
---|
523 | } |
---|
524 | |
---|
525 | Void TAppEncTop::xCreateLib() |
---|
526 | { |
---|
527 | #if H_MV |
---|
528 | // initialize global variables |
---|
529 | initROM(); |
---|
530 | #if H_3D_DIM_DMM |
---|
531 | initWedgeLists( true ); |
---|
532 | #endif |
---|
533 | |
---|
534 | for( Int layer=0; layer < m_numberOfLayers; layer++) |
---|
535 | { |
---|
536 | m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
537 | m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
538 | |
---|
539 | if (m_pchReconFileList[layer]) |
---|
540 | { |
---|
541 | m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
542 | } |
---|
543 | m_acTEncTopList[layer]->create(); |
---|
544 | } |
---|
545 | #else |
---|
546 | // Video I/O |
---|
547 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
548 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
549 | |
---|
550 | if (m_pchReconFile) |
---|
551 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
552 | |
---|
553 | // Neo Decoder |
---|
554 | m_cTEncTop.create(); |
---|
555 | #endif |
---|
556 | } |
---|
557 | |
---|
558 | Void TAppEncTop::xDestroyLib() |
---|
559 | { |
---|
560 | #if H_MV |
---|
561 | // destroy ROM |
---|
562 | destroyROM(); |
---|
563 | |
---|
564 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
565 | { |
---|
566 | m_acTVideoIOYuvInputFileList[layer]->close(); |
---|
567 | m_acTVideoIOYuvReconFileList[layer]->close(); |
---|
568 | delete m_acTVideoIOYuvInputFileList[layer] ; |
---|
569 | m_acTVideoIOYuvInputFileList[layer] = NULL; |
---|
570 | delete m_acTVideoIOYuvReconFileList[layer] ; |
---|
571 | m_acTVideoIOYuvReconFileList[layer] = NULL; |
---|
572 | m_acTEncTopList[layer]->deletePicBuffer(); |
---|
573 | m_acTEncTopList[layer]->destroy(); |
---|
574 | delete m_acTEncTopList[layer] ; |
---|
575 | m_acTEncTopList[layer] = NULL; |
---|
576 | delete m_picYuvRec[layer] ; |
---|
577 | m_picYuvRec[layer] = NULL; |
---|
578 | } |
---|
579 | #else |
---|
580 | // Video I/O |
---|
581 | m_cTVideoIOYuvInputFile.close(); |
---|
582 | m_cTVideoIOYuvReconFile.close(); |
---|
583 | |
---|
584 | // Neo Decoder |
---|
585 | m_cTEncTop.destroy(); |
---|
586 | #endif |
---|
587 | } |
---|
588 | |
---|
589 | Void TAppEncTop::xInitLib() |
---|
590 | { |
---|
591 | #if H_MV |
---|
592 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
593 | { |
---|
594 | m_acTEncTopList[layer]->init( ); |
---|
595 | } |
---|
596 | #else |
---|
597 | m_cTEncTop.init(); |
---|
598 | #endif |
---|
599 | } |
---|
600 | |
---|
601 | // ==================================================================================================================== |
---|
602 | // Public member functions |
---|
603 | // ==================================================================================================================== |
---|
604 | |
---|
605 | /** |
---|
606 | - create internal class |
---|
607 | - initialize internal variable |
---|
608 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
609 | - delete allocated buffers |
---|
610 | - destroy internal class |
---|
611 | . |
---|
612 | */ |
---|
613 | Void TAppEncTop::encode() |
---|
614 | { |
---|
615 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
616 | if (!bitstreamFile) |
---|
617 | { |
---|
618 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
619 | exit(EXIT_FAILURE); |
---|
620 | } |
---|
621 | |
---|
622 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
623 | TComPicYuv* pcPicYuvRec = NULL; |
---|
624 | |
---|
625 | // initialize internal class & member variables |
---|
626 | xInitLibCfg(); |
---|
627 | xCreateLib(); |
---|
628 | xInitLib(); |
---|
629 | |
---|
630 | // main encoder loop |
---|
631 | #if H_MV |
---|
632 | Bool allEos = false; |
---|
633 | std::vector<Bool> eos ; |
---|
634 | std::vector<Bool> flush ; |
---|
635 | |
---|
636 | Int gopSize = 1; |
---|
637 | Int maxGopSize = 0; |
---|
638 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
639 | |
---|
640 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
641 | { |
---|
642 | eos .push_back( false ); |
---|
643 | flush.push_back( false ); |
---|
644 | } |
---|
645 | #else |
---|
646 | Int iNumEncoded = 0; |
---|
647 | Bool bEos = false; |
---|
648 | #endif |
---|
649 | |
---|
650 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
651 | |
---|
652 | // allocate original YUV buffer |
---|
653 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
654 | |
---|
655 | #if H_MV |
---|
656 | while ( !allEos ) |
---|
657 | { |
---|
658 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
659 | { |
---|
660 | Int frmCnt = 0; |
---|
661 | while ( !eos[layer] && !(frmCnt == gopSize)) |
---|
662 | { |
---|
663 | // get buffers |
---|
664 | xGetBuffer(pcPicYuvRec, layer); |
---|
665 | |
---|
666 | // read input YUV file |
---|
667 | m_acTVideoIOYuvInputFileList[layer]->read ( pcPicYuvOrg, m_aiPad ); |
---|
668 | m_acTEncTopList [layer]->initNewPic( pcPicYuvOrg ); |
---|
669 | |
---|
670 | // increase number of received frames |
---|
671 | m_frameRcvd[layer]++; |
---|
672 | |
---|
673 | frmCnt++; |
---|
674 | |
---|
675 | eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded); |
---|
676 | allEos = allEos||eos[layer]; |
---|
677 | |
---|
678 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
679 | if (m_acTVideoIOYuvInputFileList[layer]->isEof()) |
---|
680 | { |
---|
681 | flush [layer] = true; |
---|
682 | eos [layer] = true; |
---|
683 | m_frameRcvd [layer]--; |
---|
684 | m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]); |
---|
685 | } |
---|
686 | } |
---|
687 | } |
---|
688 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
689 | { |
---|
690 | #if H_3D |
---|
691 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
692 | if ( iNextPoc < m_framesToBeEncoded ) |
---|
693 | { |
---|
694 | m_cCameraData.update( iNextPoc ); |
---|
695 | } |
---|
696 | #endif |
---|
697 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
698 | { |
---|
699 | #if H_3D_VSO |
---|
700 | if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded ) |
---|
701 | { |
---|
702 | m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() ); |
---|
703 | m_acTEncTopList[layer] ->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
704 | } |
---|
705 | #endif |
---|
706 | Int iNumEncoded = 0; |
---|
707 | |
---|
708 | // call encoding function for one frame |
---|
709 | m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId ); |
---|
710 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer); |
---|
711 | outputAccessUnits.clear(); |
---|
712 | } |
---|
713 | } |
---|
714 | gopSize = maxGopSize; |
---|
715 | } |
---|
716 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
717 | { |
---|
718 | m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded() ); |
---|
719 | } |
---|
720 | #else |
---|
721 | while ( !bEos ) |
---|
722 | { |
---|
723 | // get buffers |
---|
724 | xGetBuffer(pcPicYuvRec); |
---|
725 | |
---|
726 | // read input YUV file |
---|
727 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
728 | |
---|
729 | // increase number of received frames |
---|
730 | m_iFrameRcvd++; |
---|
731 | |
---|
732 | bEos = (m_iFrameRcvd == m_framesToBeEncoded); |
---|
733 | |
---|
734 | Bool flush = 0; |
---|
735 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
736 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
737 | { |
---|
738 | flush = true; |
---|
739 | bEos = true; |
---|
740 | m_iFrameRcvd--; |
---|
741 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
742 | } |
---|
743 | |
---|
744 | // call encoding function for one frame |
---|
745 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
746 | |
---|
747 | // write bistream to file if necessary |
---|
748 | if ( iNumEncoded > 0 ) |
---|
749 | { |
---|
750 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
751 | outputAccessUnits.clear(); |
---|
752 | } |
---|
753 | } |
---|
754 | |
---|
755 | m_cTEncTop.printSummary(); |
---|
756 | #endif |
---|
757 | |
---|
758 | // delete original YUV buffer |
---|
759 | pcPicYuvOrg->destroy(); |
---|
760 | delete pcPicYuvOrg; |
---|
761 | pcPicYuvOrg = NULL; |
---|
762 | |
---|
763 | #if !H_MV |
---|
764 | // delete used buffers in encoder class |
---|
765 | m_cTEncTop.deletePicBuffer(); |
---|
766 | #endif |
---|
767 | |
---|
768 | // delete buffers & classes |
---|
769 | xDeleteBuffer(); |
---|
770 | xDestroyLib(); |
---|
771 | |
---|
772 | printRateSummary(); |
---|
773 | |
---|
774 | #if H_3D_REN_MAX_DEV_OUT |
---|
775 | Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); |
---|
776 | |
---|
777 | if ( !(dMaxDispDiff < 0) ) |
---|
778 | { |
---|
779 | printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff ); |
---|
780 | } |
---|
781 | #endif |
---|
782 | |
---|
783 | return; |
---|
784 | } |
---|
785 | |
---|
786 | // ==================================================================================================================== |
---|
787 | // Protected member functions |
---|
788 | // ==================================================================================================================== |
---|
789 | |
---|
790 | /** |
---|
791 | - application has picture buffer list with size of GOP |
---|
792 | - picture buffer list acts as ring buffer |
---|
793 | - end of the list has the latest picture |
---|
794 | . |
---|
795 | */ |
---|
796 | #if H_MV |
---|
797 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
798 | #else |
---|
799 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
800 | #endif |
---|
801 | { |
---|
802 | assert( m_iGOPSize > 0 ); |
---|
803 | |
---|
804 | // org. buffer |
---|
805 | #if H_MV |
---|
806 | if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize ) |
---|
807 | { |
---|
808 | rpcPicYuvRec = m_picYuvRec[layer]->popFront(); |
---|
809 | #else |
---|
810 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
811 | { |
---|
812 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
813 | #endif |
---|
814 | |
---|
815 | } |
---|
816 | else |
---|
817 | { |
---|
818 | rpcPicYuvRec = new TComPicYuv; |
---|
819 | |
---|
820 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
821 | |
---|
822 | } |
---|
823 | #if H_MV |
---|
824 | m_picYuvRec[layer]->pushBack( rpcPicYuvRec ); |
---|
825 | #else |
---|
826 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
827 | #endif |
---|
828 | } |
---|
829 | |
---|
830 | Void TAppEncTop::xDeleteBuffer( ) |
---|
831 | { |
---|
832 | #if H_MV |
---|
833 | for(Int layer=0; layer<m_picYuvRec.size(); layer++) |
---|
834 | { |
---|
835 | if(m_picYuvRec[layer]) |
---|
836 | { |
---|
837 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layer]->begin(); |
---|
838 | Int iSize = Int( m_picYuvRec[layer]->size() ); |
---|
839 | #else |
---|
840 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
841 | |
---|
842 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
843 | #endif |
---|
844 | |
---|
845 | for ( Int i = 0; i < iSize; i++ ) |
---|
846 | { |
---|
847 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
848 | pcPicYuvRec->destroy(); |
---|
849 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
850 | } |
---|
851 | |
---|
852 | #if H_MV |
---|
853 | } |
---|
854 | } |
---|
855 | #endif |
---|
856 | } |
---|
857 | |
---|
858 | /** \param iNumEncoded number of encoded frames |
---|
859 | */ |
---|
860 | #if H_MV |
---|
861 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId) |
---|
862 | #else |
---|
863 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
864 | #endif |
---|
865 | { |
---|
866 | Int i; |
---|
867 | |
---|
868 | #if H_MV |
---|
869 | if( iNumEncoded > 0 ) |
---|
870 | { |
---|
871 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
872 | #else |
---|
873 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
874 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
875 | #endif |
---|
876 | |
---|
877 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
878 | { |
---|
879 | --iterPicYuvRec; |
---|
880 | } |
---|
881 | |
---|
882 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
883 | { |
---|
884 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
885 | #if H_MV |
---|
886 | if (m_pchReconFileList[layerId]) |
---|
887 | { |
---|
888 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
889 | } |
---|
890 | } |
---|
891 | } |
---|
892 | if( ! accessUnits.empty() ) |
---|
893 | { |
---|
894 | list<AccessUnit>::iterator aUIter; |
---|
895 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
896 | { |
---|
897 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
898 | rateStatsAccum(*aUIter, stats); |
---|
899 | } |
---|
900 | } |
---|
901 | #else |
---|
902 | if (m_pchReconFile) |
---|
903 | { |
---|
904 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
905 | } |
---|
906 | |
---|
907 | const AccessUnit& au = *(iterBitstream++); |
---|
908 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
909 | rateStatsAccum(au, stats); |
---|
910 | } |
---|
911 | #endif |
---|
912 | } |
---|
913 | |
---|
914 | /** |
---|
915 | * |
---|
916 | */ |
---|
917 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
918 | { |
---|
919 | AccessUnit::const_iterator it_au = au.begin(); |
---|
920 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
921 | |
---|
922 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
923 | { |
---|
924 | switch ((*it_au)->m_nalUnitType) |
---|
925 | { |
---|
926 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
927 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
928 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
929 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
930 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
931 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
932 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
933 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
934 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
935 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
936 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
937 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
938 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
939 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
940 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
941 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
942 | case NAL_UNIT_VPS: |
---|
943 | case NAL_UNIT_SPS: |
---|
944 | case NAL_UNIT_PPS: |
---|
945 | m_essentialBytes += *it_stats; |
---|
946 | break; |
---|
947 | default: |
---|
948 | break; |
---|
949 | } |
---|
950 | |
---|
951 | m_totalBytes += *it_stats; |
---|
952 | } |
---|
953 | } |
---|
954 | |
---|
955 | void TAppEncTop::printRateSummary() |
---|
956 | { |
---|
957 | #if H_MV |
---|
958 | Double time = (Double) m_frameRcvd[0] / m_iFrameRate; |
---|
959 | printf("\n"); |
---|
960 | #else |
---|
961 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
962 | #endif |
---|
963 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
964 | #if VERBOSE_RATE |
---|
965 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
966 | #endif |
---|
967 | } |
---|
968 | |
---|
969 | #if H_3D_DIM_DLT |
---|
970 | Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps) |
---|
971 | { |
---|
972 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
973 | // allocate original YUV buffer |
---|
974 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
975 | |
---|
976 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
---|
977 | |
---|
978 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
979 | |
---|
980 | Bool abValidDepths[256]; |
---|
981 | |
---|
982 | depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
983 | |
---|
984 | // initialize boolean array |
---|
985 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
986 | abValidDepths[p] = false; |
---|
987 | |
---|
988 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
---|
989 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
---|
990 | Int iStride = pcDepthPicYuvOrg->getStride(); |
---|
991 | |
---|
992 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
---|
993 | |
---|
994 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
---|
995 | { |
---|
996 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad ); |
---|
997 | |
---|
998 | // check all pixel values |
---|
999 | for (Int i=0; i<iHeight; i++) |
---|
1000 | { |
---|
1001 | Int rowOffset = i*iStride; |
---|
1002 | |
---|
1003 | for (Int j=0; j<iWidth; j++) |
---|
1004 | { |
---|
1005 | Pel depthValue = pInDM[rowOffset+j]; |
---|
1006 | abValidDepths[depthValue] = true; |
---|
1007 | } |
---|
1008 | } |
---|
1009 | } |
---|
1010 | |
---|
1011 | depthVideoFile->close(); |
---|
1012 | delete depthVideoFile; |
---|
1013 | |
---|
1014 | pcDepthPicYuvOrg->destroy(); |
---|
1015 | delete pcDepthPicYuvOrg; |
---|
1016 | |
---|
1017 | // convert boolean array to idx2Depth LUT |
---|
1018 | Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int)); |
---|
1019 | Int iNumDepthValues = 0; |
---|
1020 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1021 | { |
---|
1022 | if( abValidDepths[p] == true) |
---|
1023 | { |
---|
1024 | aiIdx2DepthValue[iNumDepthValues++] = p; |
---|
1025 | } |
---|
1026 | } |
---|
1027 | |
---|
1028 | if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY ) |
---|
1029 | { |
---|
1030 | // don't use DLT |
---|
1031 | vps->setUseDLTFlag(layer, false); |
---|
1032 | } |
---|
1033 | |
---|
1034 | // assign LUT |
---|
1035 | if( vps->getUseDLTFlag(layer) ) |
---|
1036 | vps->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues); |
---|
1037 | |
---|
1038 | // free temporary memory |
---|
1039 | free(aiIdx2DepthValue); |
---|
1040 | } |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | #if H_MV |
---|
1044 | Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps ) |
---|
1045 | { |
---|
1046 | vps.setScalabilityMask( m_scalabilityMask ); |
---|
1047 | for( Int dim = 0; dim < m_dimIds.size(); dim++ ) |
---|
1048 | { |
---|
1049 | vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] ); |
---|
1050 | for( Int layer = 0; layer < vps.getMaxLayers(); layer++ ) |
---|
1051 | { |
---|
1052 | vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] ); |
---|
1053 | } |
---|
1054 | } |
---|
1055 | } |
---|
1056 | |
---|
1057 | Void TAppEncTop::xSetDependencies( TComVPS& vps ) |
---|
1058 | { |
---|
1059 | // Direct dependency flags + dependency types |
---|
1060 | for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ ) |
---|
1061 | { |
---|
1062 | for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ ) |
---|
1063 | { |
---|
1064 | vps.setDirectDependencyFlag( depLayer, refLayer, false); |
---|
1065 | vps.setDirectDependencyType( depLayer, refLayer, -1 ); |
---|
1066 | } |
---|
1067 | } |
---|
1068 | for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ ) |
---|
1069 | { |
---|
1070 | Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); |
---|
1071 | assert( numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); |
---|
1072 | for( Int i = 0; i < numRefLayers; i++ ) |
---|
1073 | { |
---|
1074 | Int refLayer = m_directRefLayers[depLayer][i]; |
---|
1075 | vps.setDirectDependencyFlag( depLayer, refLayer, true); |
---|
1076 | vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); |
---|
1077 | } |
---|
1078 | } |
---|
1079 | |
---|
1080 | // Max temporal id for inter layer reference pictures |
---|
1081 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
1082 | { |
---|
1083 | Int maxTid = -1; |
---|
1084 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
1085 | { |
---|
1086 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
1087 | { |
---|
1088 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
---|
1089 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][i]; |
---|
1090 | |
---|
1091 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++) |
---|
1092 | { |
---|
1093 | if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps ) |
---|
1094 | { |
---|
1095 | maxTid = std::max( maxTid, geRef.m_temporalId ); |
---|
1096 | } |
---|
1097 | } |
---|
1098 | } |
---|
1099 | } |
---|
1100 | vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 ); |
---|
1101 | } |
---|
1102 | |
---|
1103 | // Max one active ref layer flag |
---|
1104 | Bool maxOneActiveRefLayerFlag = true; |
---|
1105 | for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++) |
---|
1106 | { |
---|
1107 | for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) |
---|
1108 | { |
---|
1109 | GOPEntry ge = m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
1110 | maxOneActiveRefLayerFlag = maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); |
---|
1111 | } |
---|
1112 | } |
---|
1113 | |
---|
1114 | vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag ); |
---|
1115 | vps.setRefLayers(); |
---|
1116 | }; |
---|
1117 | |
---|
1118 | Void TAppEncTop::xSetLayerIds( TComVPS& vps ) |
---|
1119 | { |
---|
1120 | vps.setSplittingFlag ( m_splittingFlag ); |
---|
1121 | |
---|
1122 | Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); |
---|
1123 | Int maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; |
---|
1124 | |
---|
1125 | vps.setVpsMaxLayerId( maxNuhLayerId ); |
---|
1126 | vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); |
---|
1127 | |
---|
1128 | for (Int layer = 0; layer < m_numberOfLayers; layer++ ) |
---|
1129 | { |
---|
1130 | vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); |
---|
1131 | vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); |
---|
1132 | } |
---|
1133 | } |
---|
1134 | |
---|
1135 | Int TAppEncTop::xGetMax( std::vector<Int>& vec ) |
---|
1136 | { |
---|
1137 | Int maxVec = 0; |
---|
1138 | for ( Int i = 0; i < vec.size(); i++) |
---|
1139 | maxVec = max( vec[i], maxVec ); |
---|
1140 | return maxVec; |
---|
1141 | } |
---|
1142 | |
---|
1143 | Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps ) |
---|
1144 | { |
---|
1145 | const Int vpsNumProfileTierLevelMinus1 = 0; //TBD |
---|
1146 | vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); |
---|
1147 | |
---|
1148 | for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
1149 | { |
---|
1150 | vps.setVpsProfilePresentFlag( i, true ); |
---|
1151 | } |
---|
1152 | } |
---|
1153 | |
---|
1154 | |
---|
1155 | Void TAppEncTop::xSetLayerSets( TComVPS& vps ) |
---|
1156 | { |
---|
1157 | // Layer sets |
---|
1158 | vps.setVpsNumLayerSetsMinus1 ( m_vpsNumLayerSets - 1 ); |
---|
1159 | vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); |
---|
1160 | |
---|
1161 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ ) |
---|
1162 | { |
---|
1163 | for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ ) |
---|
1164 | { |
---|
1165 | vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); |
---|
1166 | } |
---|
1167 | for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++) |
---|
1168 | { |
---|
1169 | vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); |
---|
1170 | } |
---|
1171 | } |
---|
1172 | |
---|
1173 | Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); |
---|
1174 | // Additional output layer sets + profileLevelTierIdx |
---|
1175 | vps.setDefaultOneTargetOutputLayerFlag ( m_defaultOneTargetOutputLayerFlag ); |
---|
1176 | vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets != 0 ); |
---|
1177 | vps.setNumAddOutputLayerSetsMinus1 ( numAddOuputLayerSets - 1 ); |
---|
1178 | |
---|
1179 | for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++) |
---|
1180 | { |
---|
1181 | vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); |
---|
1182 | } |
---|
1183 | |
---|
1184 | for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ ) |
---|
1185 | { |
---|
1186 | vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] ); |
---|
1187 | |
---|
1188 | Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ]; |
---|
1189 | vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 ); |
---|
1190 | |
---|
1191 | for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ ) |
---|
1192 | { |
---|
1193 | Bool outputLayerFlag = false; |
---|
1194 | for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ ) |
---|
1195 | { |
---|
1196 | if ( m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] ) |
---|
1197 | { |
---|
1198 | outputLayerFlag = true; |
---|
1199 | break; |
---|
1200 | } |
---|
1201 | } |
---|
1202 | vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag ); |
---|
1203 | } |
---|
1204 | } |
---|
1205 | } |
---|
1206 | #endif |
---|
1207 | #if H_3D |
---|
1208 | Void TAppEncTop::xSetVPSExtension2( TComVPS& vps ) |
---|
1209 | { |
---|
1210 | for ( Int layer = 0; layer < vps.getMaxLayers(); layer++ ) |
---|
1211 | { |
---|
1212 | Bool isDepth = ( vps.getDepthId( layer ) == 1 ) ; |
---|
1213 | Bool isLayerZero = ( layer == 0 ); |
---|
1214 | |
---|
1215 | #if H_3D_ARP |
---|
1216 | vps.setUseAdvRP ( layer, ( isDepth || isLayerZero ) ? 0 : m_uiUseAdvResPred ); |
---|
1217 | vps.setARPStepNum ( layer, ( isDepth || isLayerZero ) ? 1 : H_3D_ARP_WFNR ); |
---|
1218 | #endif |
---|
1219 | |
---|
1220 | #if H_3D_DIM |
---|
1221 | vps.setVpsDepthModesFlag( layer, isDepth && !isLayerZero && (m_useDMM || m_useRBC || m_useSDC || m_useDLT ) ); |
---|
1222 | #if H_3D_DIM_DLT |
---|
1223 | vps.setUseDLTFlag( layer , isDepth && m_useDLT ); |
---|
1224 | if( vps.getUseDLTFlag( layer ) ) |
---|
1225 | { |
---|
1226 | xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod, 24), &vps); |
---|
1227 | } |
---|
1228 | #endif |
---|
1229 | #endif |
---|
1230 | |
---|
1231 | #if H_3D_IV_MERGE |
---|
1232 | vps.setIvMvPredFlag ( layer, !isLayerZero && !isDepth && m_ivMvPredFlag ); |
---|
1233 | #endif |
---|
1234 | #if H_3D_NBDV_REF |
---|
1235 | vps.setDepthRefinementFlag ( layer, !isLayerZero && !isDepth && m_depthRefinementFlag ); |
---|
1236 | #endif |
---|
1237 | #if H_3D_VSP |
---|
1238 | vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag ); |
---|
1239 | #endif |
---|
1240 | #if LGE_INTER_SDC_E0156 |
---|
1241 | vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag ); |
---|
1242 | #endif |
---|
1243 | } |
---|
1244 | #if H_3D_TMVP |
---|
1245 | vps.setIvMvScalingFlag( m_ivMvScalingFlag ); |
---|
1246 | #endif |
---|
1247 | } |
---|
1248 | #endif |
---|
1249 | //! \} |
---|