1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file 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 | |
---|
60 | #if H_MV |
---|
61 | m_vps = new TComVPS; |
---|
62 | #else |
---|
63 | m_iFrameRcvd = 0; |
---|
64 | #endif |
---|
65 | m_totalBytes = 0; |
---|
66 | m_essentialBytes = 0; |
---|
67 | } |
---|
68 | |
---|
69 | TAppEncTop::~TAppEncTop() |
---|
70 | { |
---|
71 | #if H_MV |
---|
72 | if (m_vps) |
---|
73 | { |
---|
74 | delete m_vps; |
---|
75 | }; |
---|
76 | #endif |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | Void TAppEncTop::xInitLibCfg() |
---|
81 | { |
---|
82 | #if H_MV |
---|
83 | TComVPS& vps = (*m_vps); |
---|
84 | #else |
---|
85 | TComVPS vps; |
---|
86 | #endif |
---|
87 | |
---|
88 | #if H_3D |
---|
89 | vps.createCamPars(m_iNumberOfViews); |
---|
90 | TComDLT& dlt = m_dlt; |
---|
91 | #endif |
---|
92 | |
---|
93 | #if H_MV |
---|
94 | Int maxTempLayer = -1; |
---|
95 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
96 | { |
---|
97 | maxTempLayer = max( m_maxTempLayerMvc[ j ], maxTempLayer ); |
---|
98 | } |
---|
99 | |
---|
100 | vps.setMaxTLayers ( maxTempLayer ); |
---|
101 | if ( maxTempLayer ) |
---|
102 | { |
---|
103 | vps.setTemporalNestingFlag(true); |
---|
104 | } |
---|
105 | vps.setMaxLayersMinus1( m_numberOfLayers - 1); |
---|
106 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
107 | { |
---|
108 | Int maxNumReOrderPics = 0; |
---|
109 | Int maxDecPicBuffering = 0; |
---|
110 | for (Int j = 0; j < m_numberOfLayers; j++) |
---|
111 | { |
---|
112 | maxNumReOrderPics = max( maxNumReOrderPics, m_numReorderPicsMvc [ j ][ i ] ); |
---|
113 | maxDecPicBuffering = max( maxDecPicBuffering, m_maxDecPicBufferingMvc[ j ][ i ] ); |
---|
114 | } |
---|
115 | |
---|
116 | vps.setNumReorderPics ( maxNumReOrderPics ,i ); |
---|
117 | vps.setMaxDecPicBuffering ( maxDecPicBuffering ,i ); |
---|
118 | } |
---|
119 | #else |
---|
120 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
121 | if (m_maxTempLayer == 1) |
---|
122 | { |
---|
123 | vps.setTemporalNestingFlag(true); |
---|
124 | } |
---|
125 | vps.setMaxLayers ( 1 ); |
---|
126 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
127 | { |
---|
128 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
129 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
130 | } |
---|
131 | #endif |
---|
132 | #if H_MV |
---|
133 | xSetLayerIds ( vps ); |
---|
134 | xSetDimensionIdAndLength ( vps ); |
---|
135 | xSetDependencies ( vps ); |
---|
136 | xSetRepFormat ( vps ); |
---|
137 | xSetProfileTierLevel ( vps ); |
---|
138 | xSetLayerSets ( vps ); |
---|
139 | xSetDpbSize ( vps ); |
---|
140 | xSetVPSVUI ( vps ); |
---|
141 | #if H_3D |
---|
142 | m_ivPicLists.setVPS ( &vps ); |
---|
143 | xDeriveDltArray ( vps, dlt ); |
---|
144 | #endif |
---|
145 | if ( m_targetEncLayerIdList.size() == 0 ) |
---|
146 | { |
---|
147 | for (Int i = 0; i < m_numberOfLayers; i++ ) |
---|
148 | { |
---|
149 | m_targetEncLayerIdList.push_back( vps.getLayerIdInNuh( i ) ); |
---|
150 | } |
---|
151 | } |
---|
152 | for( Int i = (Int) m_targetEncLayerIdList.size()-1 ; i >= 0 ; i--) |
---|
153 | { |
---|
154 | Int iNuhLayerId = m_targetEncLayerIdList[i]; |
---|
155 | Bool allRefLayersPresent = true; |
---|
156 | for( Int j = 0; j < vps.getNumRefLayers( iNuhLayerId ); j++) |
---|
157 | { |
---|
158 | allRefLayersPresent = allRefLayersPresent && xLayerIdInTargetEncLayerIdList( vps.getIdRefLayer( iNuhLayerId, j) ); |
---|
159 | } |
---|
160 | if ( !allRefLayersPresent ) |
---|
161 | { |
---|
162 | printf("\nCannot encode layer with nuh_layer_id equal to %d since not all reference layers are in TargetEncLayerIdList\n", iNuhLayerId); |
---|
163 | m_targetEncLayerIdList.erase( m_targetEncLayerIdList.begin() + i ); |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | if ( m_outputVpsInfo ) |
---|
168 | { |
---|
169 | vps.printScalabilityId(); |
---|
170 | vps.printLayerDependencies(); |
---|
171 | vps.printLayerSets(); |
---|
172 | vps.printPTL(); |
---|
173 | } |
---|
174 | |
---|
175 | #if H_3D |
---|
176 | // Set 3d tool parameters |
---|
177 | |
---|
178 | for (Int d = 0; d < 2; d++) |
---|
179 | { |
---|
180 | m_sps3dExtension.setIvMvPredFlag ( d, m_ivMvPredFlag[d] ); |
---|
181 | m_sps3dExtension.setIvMvScalingFlag ( d, m_ivMvScalingFlag[d] ); |
---|
182 | if (d == 0 ) |
---|
183 | { |
---|
184 | m_sps3dExtension.setLog2SubPbSizeMinus3 ( d, m_log2SubPbSizeMinus3 ); |
---|
185 | m_sps3dExtension.setIvResPredFlag ( d, m_ivResPredFlag ); |
---|
186 | m_sps3dExtension.setDepthRefinementFlag ( d, m_depthRefinementFlag ); |
---|
187 | m_sps3dExtension.setViewSynthesisPredFlag ( d, m_viewSynthesisPredFlag ); |
---|
188 | m_sps3dExtension.setDepthBasedBlkPartFlag ( d, m_depthBasedBlkPartFlag ); |
---|
189 | } |
---|
190 | else |
---|
191 | { |
---|
192 | m_sps3dExtension.setMpiFlag ( d, m_mpiFlag ); |
---|
193 | m_sps3dExtension.setLog2MpiSubPbSizeMinus3( d, m_log2MpiSubPbSizeMinus3); |
---|
194 | m_sps3dExtension.setIntraContourFlag ( d, m_intraContourFlag ); |
---|
195 | m_sps3dExtension.setIntraSdcWedgeFlag ( d, m_intraSdcFlag || m_intraWedgeFlag ); |
---|
196 | m_sps3dExtension.setQtPredFlag ( d, m_qtPredFlag ); |
---|
197 | m_sps3dExtension.setInterSdcFlag ( d, m_interSdcFlag ); |
---|
198 | m_sps3dExtension.setIntraSingleFlag ( d, m_intraSingleFlag ); |
---|
199 | } |
---|
200 | } |
---|
201 | #endif |
---|
202 | |
---|
203 | for(Int layerIdInVps = 0; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
---|
204 | { |
---|
205 | m_frameRcvd .push_back(0); |
---|
206 | m_acTEncTopList .push_back(new TEncTop); |
---|
207 | m_acTVideoIOYuvInputFileList.push_back(new TVideoIOYuv); |
---|
208 | m_acTVideoIOYuvReconFileList.push_back(new TVideoIOYuv); |
---|
209 | m_picYuvRec .push_back(new TComList<TComPicYuv*>) ; |
---|
210 | m_ivPicLists.push_back( m_acTEncTopList[ layerIdInVps ]->getListPic() ); |
---|
211 | TEncTop& m_cTEncTop = *m_acTEncTopList[ layerIdInVps ]; // It is not a member, but this name helps avoiding code duplication !!! |
---|
212 | |
---|
213 | Int layerId = vps.getLayerIdInNuh( layerIdInVps ); |
---|
214 | m_cTEncTop.setLayerIdInVps ( layerIdInVps ); |
---|
215 | m_cTEncTop.setLayerId ( layerId ); |
---|
216 | m_cTEncTop.setViewId ( vps.getViewId ( layerId ) ); |
---|
217 | m_cTEncTop.setViewIndex ( vps.getViewIndex ( layerId ) ); |
---|
218 | #if H_3D |
---|
219 | Bool isDepth = ( vps.getDepthId ( layerId ) != 0 ) ; |
---|
220 | m_cTEncTop.setIsDepth ( isDepth ); |
---|
221 | //====== Camera Parameters ========= |
---|
222 | m_cTEncTop.setCameraParameters ( &m_cCameraData ); |
---|
223 | m_cTEncTop.setCamParPrecision ( m_cCameraData.getCamParsCodedPrecision () ); |
---|
224 | m_cTEncTop.setCamParInSliceHeader ( m_cCameraData.getVaryingCameraParameters() ); |
---|
225 | m_cTEncTop.setCodedScale ( m_cCameraData.getCodedScale () ); |
---|
226 | m_cTEncTop.setCodedOffset ( m_cCameraData.getCodedOffset () ); |
---|
227 | #if H_3D_VSO |
---|
228 | //====== VSO ========= |
---|
229 | m_cTEncTop.setRenderModelParameters ( &m_cRenModStrParser ); |
---|
230 | m_cTEncTop.setForceLambdaScaleVSO ( isDepth ? m_bForceLambdaScaleVSO : false ); |
---|
231 | m_cTEncTop.setLambdaScaleVSO ( isDepth ? m_dLambdaScaleVSO : 1 ); |
---|
232 | m_cTEncTop.setVSOMode ( isDepth ? m_uiVSOMode : 0 ); |
---|
233 | |
---|
234 | m_cTEncTop.setAllowNegDist ( isDepth ? m_bAllowNegDist : false ); |
---|
235 | |
---|
236 | // SAIT_VSO_EST_A0033 |
---|
237 | m_cTEncTop.setUseEstimatedVSD ( isDepth ? m_bUseEstimatedVSD : false ); |
---|
238 | |
---|
239 | // LGE_WVSO_A0119 |
---|
240 | m_cTEncTop.setUseWVSO ( isDepth ? m_bUseWVSO : false ); |
---|
241 | m_cTEncTop.setVSOWeight ( isDepth ? m_iVSOWeight : 0 ); |
---|
242 | m_cTEncTop.setVSDWeight ( isDepth ? m_iVSDWeight : 0 ); |
---|
243 | m_cTEncTop.setDWeight ( isDepth ? m_iDWeight : 0 ); |
---|
244 | #endif // H_3D_VSO |
---|
245 | #if H_3D_IC |
---|
246 | m_cTEncTop.setUseIC ( vps.getViewIndex( layerId ) == 0 || isDepth ? false : m_abUseIC ); |
---|
247 | m_cTEncTop.setUseICLowLatencyEnc ( m_bUseLowLatencyICEnc ); |
---|
248 | #endif |
---|
249 | |
---|
250 | |
---|
251 | m_cTEncTop.setUseDMM ( isDepth ? m_intraWedgeFlag : false ); |
---|
252 | m_cTEncTop.setUseSDC ( isDepth ? m_intraSdcFlag : false ); |
---|
253 | m_cTEncTop.setUseDLT ( isDepth ? m_useDLT : false ); |
---|
254 | m_cTEncTop.setUseQTL ( isDepth ? m_bUseQTL : false ); |
---|
255 | |
---|
256 | |
---|
257 | m_cTEncTop.setSps3dExtension ( m_sps3dExtension ); |
---|
258 | #endif // H_3D |
---|
259 | |
---|
260 | m_cTEncTop.setIvPicLists ( &m_ivPicLists ); |
---|
261 | #endif // H_MV |
---|
262 | m_cTEncTop.setVPS(&vps); |
---|
263 | |
---|
264 | #if H_3D |
---|
265 | m_cTEncTop.setDLT(&dlt); |
---|
266 | #endif |
---|
267 | |
---|
268 | #if H_MV |
---|
269 | m_cTEncTop.setProfile(m_profile[0]); |
---|
270 | m_cTEncTop.setLevel (m_levelTier[0], m_level[0]); |
---|
271 | #else |
---|
272 | m_cTEncTop.setProfile(m_profile); |
---|
273 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
274 | #endif |
---|
275 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
276 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
277 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
278 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
279 | |
---|
280 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
281 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
282 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
283 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
284 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
285 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
286 | |
---|
287 | //====== Coding Structure ======== |
---|
288 | #if H_MV |
---|
289 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod[ layerIdInVps ] ); |
---|
290 | #else |
---|
291 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
292 | #endif |
---|
293 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
294 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
295 | #if H_MV |
---|
296 | m_cTEncTop.setGopList ( m_GOPListMvc[layerIdInVps] ); |
---|
297 | m_cTEncTop.setExtraRPSs ( m_extraRPSsMvc[layerIdInVps] ); |
---|
298 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
299 | { |
---|
300 | m_cTEncTop.setNumReorderPics ( m_numReorderPicsMvc[layerIdInVps][i], i ); |
---|
301 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBufferingMvc[layerIdInVps][i], i ); |
---|
302 | } |
---|
303 | #else |
---|
304 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
305 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
306 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
307 | { |
---|
308 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
309 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
310 | } |
---|
311 | #endif |
---|
312 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
313 | { |
---|
314 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
315 | } |
---|
316 | #if H_MV |
---|
317 | m_cTEncTop.setQP ( m_iQP[layerIdInVps] ); |
---|
318 | #else |
---|
319 | m_cTEncTop.setQP ( m_iQP ); |
---|
320 | #endif |
---|
321 | |
---|
322 | m_cTEncTop.setPad ( m_aiPad ); |
---|
323 | |
---|
324 | #if H_MV |
---|
325 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayerMvc[layerIdInVps] ); |
---|
326 | #else |
---|
327 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
328 | #endif |
---|
329 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
330 | |
---|
331 | //===== Slice ======== |
---|
332 | |
---|
333 | //====== Loop/Deblock Filter ======== |
---|
334 | #if H_MV |
---|
335 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable[layerIdInVps]); |
---|
336 | #else |
---|
337 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
338 | #endif |
---|
339 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
340 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
341 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
342 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
343 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
344 | |
---|
345 | //====== Motion search ======== |
---|
346 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
347 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
348 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
349 | |
---|
350 | //====== Quality control ======== |
---|
351 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
352 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
353 | |
---|
354 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
355 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
356 | |
---|
357 | #if ADAPTIVE_QP_SELECTION |
---|
358 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
359 | #endif |
---|
360 | |
---|
361 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
362 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
363 | |
---|
364 | //====== Tool list ======== |
---|
365 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
366 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
367 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
368 | #if H_MV |
---|
369 | m_cTEncTop.setdQPs ( m_aidQP[layerIdInVps] ); |
---|
370 | #else |
---|
371 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
372 | #endif |
---|
373 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
374 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
375 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
376 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
377 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
378 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
379 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
380 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
381 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
382 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
383 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
384 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
385 | |
---|
386 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
387 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
388 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
389 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
390 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
391 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
392 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
393 | |
---|
394 | |
---|
395 | //====== Weighted Prediction ======== |
---|
396 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
397 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
398 | //====== Parallel Merge Estimation ======== |
---|
399 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
400 | |
---|
401 | //====== Slice ======== |
---|
402 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
403 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
404 | |
---|
405 | //====== Dependent Slice ======== |
---|
406 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
407 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
408 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
409 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
410 | { |
---|
411 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
412 | } |
---|
413 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
414 | { |
---|
415 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
416 | } |
---|
417 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
418 | { |
---|
419 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
420 | } |
---|
421 | |
---|
422 | if(m_sliceMode == 0 ) |
---|
423 | { |
---|
424 | m_bLFCrossSliceBoundaryFlag = true; |
---|
425 | } |
---|
426 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
427 | #if H_MV |
---|
428 | m_cTEncTop.setUseSAO ( m_bUseSAO[layerIdInVps] ); |
---|
429 | #else |
---|
430 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
431 | #endif |
---|
432 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
433 | |
---|
434 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
435 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
436 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
437 | |
---|
438 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
439 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
440 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
441 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
442 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
443 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
444 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
445 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
446 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
447 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
448 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
449 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
450 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
451 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
452 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
453 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
454 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
455 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
456 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
457 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
458 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
459 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
460 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
461 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
462 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
463 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
464 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
465 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
466 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
467 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
468 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
469 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
470 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
471 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
472 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
473 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
474 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
475 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
476 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
477 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
478 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
479 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
480 | #if H_MV |
---|
481 | m_cTEncTop.setSubBitstreamPropSEIEnabled( m_subBistreamPropSEIEnabled ); |
---|
482 | if( m_subBistreamPropSEIEnabled ) |
---|
483 | { |
---|
484 | m_cTEncTop.setNumAdditionalSubStreams ( m_sbPropNumAdditionalSubStreams ); |
---|
485 | m_cTEncTop.setSubBitstreamMode ( m_sbPropSubBitstreamMode ); |
---|
486 | m_cTEncTop.setOutputLayerSetIdxToVps ( m_sbPropOutputLayerSetIdxToVps ); |
---|
487 | m_cTEncTop.setHighestSublayerId ( m_sbPropHighestSublayerId ); |
---|
488 | m_cTEncTop.setAvgBitRate ( m_sbPropAvgBitRate ); |
---|
489 | m_cTEncTop.setMaxBitRate ( m_sbPropMaxBitRate ); |
---|
490 | } |
---|
491 | #endif |
---|
492 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
493 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
494 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
495 | if(!m_tileUniformSpacingFlag) |
---|
496 | { |
---|
497 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
498 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
499 | } |
---|
500 | m_cTEncTop.xCheckGSParameters(); |
---|
501 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
502 | if(uiTilesCount == 1) |
---|
503 | { |
---|
504 | m_bLFCrossTileBoundaryFlag = true; |
---|
505 | } |
---|
506 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
507 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
508 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
509 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
510 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
511 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
512 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
513 | #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227 |
---|
514 | if(!m_cTEncTop.getIsDepth()) //only for texture |
---|
515 | { |
---|
516 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | m_cTEncTop.setUseRateCtrl ( 0 ); |
---|
521 | } |
---|
522 | #else |
---|
523 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
524 | #endif |
---|
525 | #if !KWU_RC_VIEWRC_E0227 |
---|
526 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
527 | #endif |
---|
528 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
529 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
530 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
531 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
532 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
533 | #if KWU_RC_MADPRED_E0227 |
---|
534 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
---|
535 | { |
---|
536 | m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred : 0); |
---|
537 | if(m_cTEncTop.getUseDepthMADPred()) |
---|
538 | { |
---|
539 | m_cTEncTop.setCamParam(&m_cCameraData); |
---|
540 | } |
---|
541 | } |
---|
542 | #endif |
---|
543 | #if KWU_RC_VIEWRC_E0227 |
---|
544 | if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth()) |
---|
545 | { |
---|
546 | m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl); |
---|
547 | if(m_iNumberOfViews == 1) |
---|
548 | { |
---|
549 | if(m_viewWiseRateCtrl) |
---|
550 | { |
---|
551 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
---|
552 | } |
---|
553 | else |
---|
554 | { |
---|
555 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
556 | } |
---|
557 | } |
---|
558 | else |
---|
559 | { |
---|
560 | if(m_viewWiseRateCtrl) |
---|
561 | { |
---|
562 | m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]); |
---|
563 | } |
---|
564 | else |
---|
565 | { |
---|
566 | if(m_iNumberOfViews == 2) |
---|
567 | { |
---|
568 | if(m_cTEncTop.getViewId() == 0) |
---|
569 | { |
---|
570 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*80)/100 ); |
---|
571 | } |
---|
572 | else if(m_cTEncTop.getViewId() == 1) |
---|
573 | { |
---|
574 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*20)/100 ); |
---|
575 | } |
---|
576 | } |
---|
577 | else if(m_iNumberOfViews == 3) |
---|
578 | { |
---|
579 | if(m_cTEncTop.getViewId() == 0) |
---|
580 | { |
---|
581 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*66)/100 ); |
---|
582 | } |
---|
583 | else if(m_cTEncTop.getViewId() == 1) |
---|
584 | { |
---|
585 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
---|
586 | } |
---|
587 | else if(m_cTEncTop.getViewId() == 2) |
---|
588 | { |
---|
589 | m_cTEncTop.setTargetBitrate ( (m_RCTargetBitrate*17)/100 ); |
---|
590 | } |
---|
591 | } |
---|
592 | else |
---|
593 | { |
---|
594 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
595 | } |
---|
596 | } |
---|
597 | } |
---|
598 | } |
---|
599 | #endif |
---|
600 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
601 | m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
602 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
603 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
604 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
605 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
606 | m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
607 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
608 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
609 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
610 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
611 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
612 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
613 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
614 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
615 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
616 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
617 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
618 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
619 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
620 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
621 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
622 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
623 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
624 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
625 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
626 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
627 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
628 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
629 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
630 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
631 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
632 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
633 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
634 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
635 | #if H_MV |
---|
636 | } |
---|
637 | #endif |
---|
638 | #if H_3D_VSO |
---|
639 | if ( m_bUseVSO ) |
---|
640 | { |
---|
641 | if ( m_uiVSOMode == 4 ) |
---|
642 | { |
---|
643 | #if H_3D_VSO_EARLY_SKIP |
---|
644 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0, m_bVSOEarlySkip ); |
---|
645 | #else |
---|
646 | m_cRendererModel.create( m_cRenModStrParser.getNumOfBaseViews(), m_cRenModStrParser.getNumOfModels(), m_iSourceWidth, g_uiMaxCUHeight , LOG2_DISP_PREC_LUT, 0 ); |
---|
647 | #endif |
---|
648 | for ( Int layer = 0; layer < m_numberOfLayers ; layer++ ) |
---|
649 | { |
---|
650 | TEncTop* pcEncTop = m_acTEncTopList[ layer ]; |
---|
651 | Int iViewNum = pcEncTop->getViewIndex(); |
---|
652 | Int iContent = pcEncTop->getIsDepth() ? 1 : 0; |
---|
653 | Int iNumOfModels = m_cRenModStrParser.getNumOfModelsForView(iViewNum, iContent); |
---|
654 | |
---|
655 | Bool bUseVSO = (iNumOfModels != 0); |
---|
656 | |
---|
657 | pcEncTop->setUseVSO( bUseVSO ); |
---|
658 | pcEncTop->getRdCost()->setRenModel( bUseVSO ? &m_cRendererModel : NULL ); |
---|
659 | |
---|
660 | for (Int iCurModel = 0; iCurModel < iNumOfModels; iCurModel++ ) |
---|
661 | { |
---|
662 | Int iModelNum; Int iLeftViewNum; Int iRightViewNum; Int iDump; Int iOrgRefNum; Int iBlendMode; |
---|
663 | |
---|
664 | m_cRenModStrParser.getSingleModelData ( iViewNum, iContent, iCurModel, iModelNum, iBlendMode, iLeftViewNum, iRightViewNum, iOrgRefNum, iDump ) ; |
---|
665 | m_cRendererModel .createSingleModel ( iViewNum, iContent, iModelNum, iLeftViewNum, iRightViewNum, (iOrgRefNum != -1), iBlendMode ); |
---|
666 | } |
---|
667 | } |
---|
668 | } |
---|
669 | else |
---|
670 | { |
---|
671 | AOT(true); |
---|
672 | } |
---|
673 | } |
---|
674 | #endif |
---|
675 | } |
---|
676 | |
---|
677 | Void TAppEncTop::xCreateLib() |
---|
678 | { |
---|
679 | #if H_MV |
---|
680 | // initialize global variables |
---|
681 | initROM(); |
---|
682 | #if H_3D_DIM_DMM |
---|
683 | initWedgeLists( true ); |
---|
684 | #endif |
---|
685 | |
---|
686 | for( Int layer=0; layer < m_numberOfLayers; layer++) |
---|
687 | { |
---|
688 | m_acTVideoIOYuvInputFileList[layer]->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
689 | m_acTVideoIOYuvInputFileList[layer]->skipFrames( m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
690 | |
---|
691 | if (m_pchReconFileList[layer]) |
---|
692 | { |
---|
693 | m_acTVideoIOYuvReconFileList[layer]->open( m_pchReconFileList[layer], true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
694 | } |
---|
695 | m_acTEncTopList[layer]->create(); |
---|
696 | } |
---|
697 | #else |
---|
698 | // Video I/O |
---|
699 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
700 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
701 | |
---|
702 | if (m_pchReconFile) |
---|
703 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
704 | |
---|
705 | // Neo Decoder |
---|
706 | m_cTEncTop.create(); |
---|
707 | #endif |
---|
708 | } |
---|
709 | |
---|
710 | Void TAppEncTop::xDestroyLib() |
---|
711 | { |
---|
712 | #if H_MV |
---|
713 | // destroy ROM |
---|
714 | destroyROM(); |
---|
715 | |
---|
716 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
717 | { |
---|
718 | m_acTVideoIOYuvInputFileList[layer]->close(); |
---|
719 | m_acTVideoIOYuvReconFileList[layer]->close(); |
---|
720 | delete m_acTVideoIOYuvInputFileList[layer] ; |
---|
721 | m_acTVideoIOYuvInputFileList[layer] = NULL; |
---|
722 | delete m_acTVideoIOYuvReconFileList[layer] ; |
---|
723 | m_acTVideoIOYuvReconFileList[layer] = NULL; |
---|
724 | m_acTEncTopList[layer]->deletePicBuffer(); |
---|
725 | m_acTEncTopList[layer]->destroy(); |
---|
726 | delete m_acTEncTopList[layer] ; |
---|
727 | m_acTEncTopList[layer] = NULL; |
---|
728 | delete m_picYuvRec[layer] ; |
---|
729 | m_picYuvRec[layer] = NULL; |
---|
730 | } |
---|
731 | #else |
---|
732 | // Video I/O |
---|
733 | m_cTVideoIOYuvInputFile.close(); |
---|
734 | m_cTVideoIOYuvReconFile.close(); |
---|
735 | |
---|
736 | // Neo Decoder |
---|
737 | m_cTEncTop.destroy(); |
---|
738 | #endif |
---|
739 | } |
---|
740 | |
---|
741 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
742 | { |
---|
743 | #if H_3D |
---|
744 | for ( Int viewIndex = 0; viewIndex < m_vps->getNumViews(); viewIndex++ ) |
---|
745 | { |
---|
746 | m_vps->initCamParaVPS( viewIndex, true, m_cCameraData.getCamParsCodedPrecision(), |
---|
747 | m_cCameraData.getVaryingCameraParameters(), m_cCameraData.getCodedScale(), m_cCameraData.getCodedOffset() ); |
---|
748 | } |
---|
749 | #endif |
---|
750 | |
---|
751 | #if H_MV |
---|
752 | for(Int layer=0; layer<m_numberOfLayers; layer++) |
---|
753 | { |
---|
754 | #if KWU_RC_MADPRED_E0227 |
---|
755 | m_acTEncTopList[layer]->init( isFieldCoding, this ); |
---|
756 | #else |
---|
757 | m_acTEncTopList[layer]->init( isFieldCoding ); |
---|
758 | #endif |
---|
759 | } |
---|
760 | #else |
---|
761 | m_cTEncTop.init( isFieldCoding ); |
---|
762 | #endif |
---|
763 | } |
---|
764 | |
---|
765 | // ==================================================================================================================== |
---|
766 | // Public member functions |
---|
767 | // ==================================================================================================================== |
---|
768 | |
---|
769 | /** |
---|
770 | - create internal class |
---|
771 | - initialize internal variable |
---|
772 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
773 | - delete allocated buffers |
---|
774 | - destroy internal class |
---|
775 | . |
---|
776 | */ |
---|
777 | Void TAppEncTop::encode() |
---|
778 | { |
---|
779 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
780 | if (!bitstreamFile) |
---|
781 | { |
---|
782 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
783 | exit(EXIT_FAILURE); |
---|
784 | } |
---|
785 | |
---|
786 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
787 | TComPicYuv* pcPicYuvRec = NULL; |
---|
788 | |
---|
789 | // initialize internal class & member variables |
---|
790 | xInitLibCfg(); |
---|
791 | xCreateLib(); |
---|
792 | xInitLib(m_isField); |
---|
793 | |
---|
794 | // main encoder loop |
---|
795 | #if H_MV |
---|
796 | Bool allEos = false; |
---|
797 | std::vector<Bool> eos ; |
---|
798 | std::vector<Bool> flush ; |
---|
799 | |
---|
800 | Int gopSize = 1; |
---|
801 | Int maxGopSize = 0; |
---|
802 | maxGopSize = (std::max)(maxGopSize, m_acTEncTopList[0]->getGOPSize()); |
---|
803 | |
---|
804 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
805 | { |
---|
806 | eos .push_back( false ); |
---|
807 | flush.push_back( false ); |
---|
808 | } |
---|
809 | #else |
---|
810 | Int iNumEncoded = 0; |
---|
811 | Bool bEos = false; |
---|
812 | #endif |
---|
813 | |
---|
814 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
815 | |
---|
816 | // allocate original YUV buffer |
---|
817 | if( m_isField ) |
---|
818 | { |
---|
819 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
820 | } |
---|
821 | else |
---|
822 | { |
---|
823 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
824 | } |
---|
825 | |
---|
826 | #if H_MV |
---|
827 | while ( (m_targetEncLayerIdList.size() != 0 ) && !allEos ) |
---|
828 | { |
---|
829 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
830 | { |
---|
831 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
832 | { |
---|
833 | continue; |
---|
834 | } |
---|
835 | |
---|
836 | Int frmCnt = 0; |
---|
837 | while ( !eos[layer] && !(frmCnt == gopSize)) |
---|
838 | { |
---|
839 | // get buffers |
---|
840 | xGetBuffer(pcPicYuvRec, layer); |
---|
841 | |
---|
842 | // read input YUV file |
---|
843 | m_acTVideoIOYuvInputFileList[layer]->read ( pcPicYuvOrg, m_aiPad ); |
---|
844 | m_acTEncTopList [layer]->initNewPic( pcPicYuvOrg ); |
---|
845 | |
---|
846 | // increase number of received frames |
---|
847 | m_frameRcvd[layer]++; |
---|
848 | |
---|
849 | frmCnt++; |
---|
850 | |
---|
851 | eos[layer] = (m_frameRcvd[layer] == m_framesToBeEncoded); |
---|
852 | allEos = allEos||eos[layer]; |
---|
853 | |
---|
854 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
855 | if (m_acTVideoIOYuvInputFileList[layer]->isEof()) |
---|
856 | { |
---|
857 | flush [layer] = true; |
---|
858 | eos [layer] = true; |
---|
859 | m_frameRcvd [layer]--; |
---|
860 | m_acTEncTopList[layer]->setFramesToBeEncoded(m_frameRcvd[layer]); |
---|
861 | } |
---|
862 | } |
---|
863 | } |
---|
864 | for ( Int gopId=0; gopId < gopSize; gopId++ ) |
---|
865 | { |
---|
866 | #if H_3D |
---|
867 | UInt iNextPoc = m_acTEncTopList[0] -> getFrameId( gopId ); |
---|
868 | if ( iNextPoc < m_framesToBeEncoded ) |
---|
869 | { |
---|
870 | m_cCameraData.update( iNextPoc ); |
---|
871 | } |
---|
872 | #endif |
---|
873 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
874 | { |
---|
875 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
876 | { |
---|
877 | continue; |
---|
878 | } |
---|
879 | |
---|
880 | #if H_3D_VSO |
---|
881 | if( m_bUseVSO && m_bUseEstimatedVSD && iNextPoc < m_framesToBeEncoded ) |
---|
882 | { |
---|
883 | m_cCameraData.setDispCoeff( iNextPoc, m_acTEncTopList[layer]->getViewIndex() ); |
---|
884 | m_acTEncTopList[layer] ->setDispCoeff( m_cCameraData.getDispCoeff() ); |
---|
885 | } |
---|
886 | #endif |
---|
887 | |
---|
888 | Int iNumEncoded = 0; |
---|
889 | |
---|
890 | // call encoding function for one frame |
---|
891 | m_acTEncTopList[layer]->encode( eos[layer], flush[layer] ? 0 : pcPicYuvOrg, *m_picYuvRec[layer], outputAccessUnits, iNumEncoded, gopId ); |
---|
892 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits, layer); |
---|
893 | outputAccessUnits.clear(); |
---|
894 | } |
---|
895 | } |
---|
896 | |
---|
897 | gopSize = maxGopSize; |
---|
898 | } |
---|
899 | for(Int layer=0; layer < m_numberOfLayers; layer++ ) |
---|
900 | { |
---|
901 | if (!xLayerIdInTargetEncLayerIdList( m_vps->getLayerIdInNuh( layer ) )) |
---|
902 | { |
---|
903 | continue; |
---|
904 | } |
---|
905 | m_acTEncTopList[layer]->printSummary( m_acTEncTopList[layer]->getNumAllPicCoded(), m_isField ); |
---|
906 | } |
---|
907 | #else |
---|
908 | while ( !bEos ) |
---|
909 | { |
---|
910 | // get buffers |
---|
911 | xGetBuffer(pcPicYuvRec); |
---|
912 | |
---|
913 | // read input YUV file |
---|
914 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
915 | |
---|
916 | // increase number of received frames |
---|
917 | m_iFrameRcvd++; |
---|
918 | |
---|
919 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
920 | |
---|
921 | Bool flush = 0; |
---|
922 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
923 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
924 | { |
---|
925 | flush = true; |
---|
926 | bEos = true; |
---|
927 | m_iFrameRcvd--; |
---|
928 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
929 | } |
---|
930 | |
---|
931 | // call encoding function for one frame |
---|
932 | if ( m_isField ) |
---|
933 | { |
---|
934 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
935 | } |
---|
936 | else |
---|
937 | { |
---|
938 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
939 | } |
---|
940 | |
---|
941 | // write bistream to file if necessary |
---|
942 | if ( iNumEncoded > 0 ) |
---|
943 | { |
---|
944 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
945 | outputAccessUnits.clear(); |
---|
946 | } |
---|
947 | } |
---|
948 | |
---|
949 | m_cTEncTop.printSummary(m_isField); |
---|
950 | #endif |
---|
951 | |
---|
952 | // delete original YUV buffer |
---|
953 | pcPicYuvOrg->destroy(); |
---|
954 | delete pcPicYuvOrg; |
---|
955 | pcPicYuvOrg = NULL; |
---|
956 | |
---|
957 | #if !H_MV |
---|
958 | // delete used buffers in encoder class |
---|
959 | m_cTEncTop.deletePicBuffer(); |
---|
960 | #endif |
---|
961 | |
---|
962 | // delete buffers & classes |
---|
963 | xDeleteBuffer(); |
---|
964 | xDestroyLib(); |
---|
965 | |
---|
966 | printRateSummary(); |
---|
967 | |
---|
968 | #if H_3D_REN_MAX_DEV_OUT |
---|
969 | Double dMaxDispDiff = m_cCameraData.getMaxShiftDeviation(); |
---|
970 | |
---|
971 | if ( !(dMaxDispDiff < 0) ) |
---|
972 | { |
---|
973 | printf("\n Max. possible shift error: %12.3f samples.\n", dMaxDispDiff ); |
---|
974 | } |
---|
975 | #endif |
---|
976 | |
---|
977 | return; |
---|
978 | } |
---|
979 | |
---|
980 | // ==================================================================================================================== |
---|
981 | // Protected member functions |
---|
982 | // ==================================================================================================================== |
---|
983 | |
---|
984 | /** |
---|
985 | - application has picture buffer list with size of GOP |
---|
986 | - picture buffer list acts as ring buffer |
---|
987 | - end of the list has the latest picture |
---|
988 | . |
---|
989 | */ |
---|
990 | #if H_MV |
---|
991 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
992 | #else |
---|
993 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
994 | #endif |
---|
995 | { |
---|
996 | assert( m_iGOPSize > 0 ); |
---|
997 | |
---|
998 | // org. buffer |
---|
999 | #if H_MV |
---|
1000 | if ( m_picYuvRec[layer]->size() == (UInt)m_iGOPSize ) |
---|
1001 | { |
---|
1002 | rpcPicYuvRec = m_picYuvRec[layer]->popFront(); |
---|
1003 | #else |
---|
1004 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
1005 | { |
---|
1006 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
1007 | #endif |
---|
1008 | |
---|
1009 | } |
---|
1010 | else |
---|
1011 | { |
---|
1012 | rpcPicYuvRec = new TComPicYuv; |
---|
1013 | |
---|
1014 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1015 | |
---|
1016 | } |
---|
1017 | #if H_MV |
---|
1018 | m_picYuvRec[layer]->pushBack( rpcPicYuvRec ); |
---|
1019 | #else |
---|
1020 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
1021 | #endif |
---|
1022 | } |
---|
1023 | |
---|
1024 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1025 | { |
---|
1026 | #if H_MV |
---|
1027 | for(Int layer=0; layer<m_picYuvRec.size(); layer++) |
---|
1028 | { |
---|
1029 | if(m_picYuvRec[layer]) |
---|
1030 | { |
---|
1031 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layer]->begin(); |
---|
1032 | Int iSize = Int( m_picYuvRec[layer]->size() ); |
---|
1033 | #else |
---|
1034 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
1035 | |
---|
1036 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
1037 | #endif |
---|
1038 | |
---|
1039 | for ( Int i = 0; i < iSize; i++ ) |
---|
1040 | { |
---|
1041 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1042 | pcPicYuvRec->destroy(); |
---|
1043 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
1044 | } |
---|
1045 | |
---|
1046 | #if H_MV |
---|
1047 | } |
---|
1048 | } |
---|
1049 | #endif |
---|
1050 | } |
---|
1051 | |
---|
1052 | /** \param iNumEncoded number of encoded frames |
---|
1053 | */ |
---|
1054 | #if H_MV |
---|
1055 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, std::list<AccessUnit>& accessUnits, UInt layerId) |
---|
1056 | #else |
---|
1057 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
1058 | #endif |
---|
1059 | { |
---|
1060 | if (m_isField) |
---|
1061 | { |
---|
1062 | //Reinterlace fields |
---|
1063 | Int i; |
---|
1064 | #if H_MV |
---|
1065 | if( iNumEncoded > 0 ) |
---|
1066 | { |
---|
1067 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
1068 | #else |
---|
1069 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
1070 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1071 | #endif |
---|
1072 | |
---|
1073 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1074 | { |
---|
1075 | --iterPicYuvRec; |
---|
1076 | } |
---|
1077 | |
---|
1078 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
1079 | { |
---|
1080 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
1081 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
1082 | |
---|
1083 | #if H_MV |
---|
1084 | if (m_pchReconFileList[layerId]) |
---|
1085 | { |
---|
1086 | #if H_MV_ALIGN_HM_15 |
---|
1087 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
1088 | #else |
---|
1089 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); |
---|
1090 | #endif |
---|
1091 | } |
---|
1092 | } |
---|
1093 | } |
---|
1094 | |
---|
1095 | if( ! accessUnits.empty() ) |
---|
1096 | { |
---|
1097 | list<AccessUnit>::iterator aUIter; |
---|
1098 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
1099 | { |
---|
1100 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
1101 | rateStatsAccum(*aUIter, stats); |
---|
1102 | } |
---|
1103 | } |
---|
1104 | #else |
---|
1105 | if (m_pchReconFile) |
---|
1106 | { |
---|
1107 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
1108 | } |
---|
1109 | |
---|
1110 | const AccessUnit& auTop = *(iterBitstream++); |
---|
1111 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
1112 | rateStatsAccum(auTop, statsTop); |
---|
1113 | |
---|
1114 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
1115 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
1116 | rateStatsAccum(auBottom, statsBottom); |
---|
1117 | } |
---|
1118 | #endif |
---|
1119 | } |
---|
1120 | else |
---|
1121 | { |
---|
1122 | Int i; |
---|
1123 | #if H_MV |
---|
1124 | if( iNumEncoded > 0 ) |
---|
1125 | { |
---|
1126 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_picYuvRec[layerId]->end(); |
---|
1127 | #else |
---|
1128 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
1129 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1130 | #endif |
---|
1131 | |
---|
1132 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1133 | { |
---|
1134 | --iterPicYuvRec; |
---|
1135 | } |
---|
1136 | |
---|
1137 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1138 | { |
---|
1139 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1140 | #if H_MV |
---|
1141 | if (m_pchReconFileList[layerId]) |
---|
1142 | { |
---|
1143 | #if H_MV_ALIGN_HM_15 |
---|
1144 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
1145 | #else |
---|
1146 | m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
1147 | #endif |
---|
1148 | } |
---|
1149 | } |
---|
1150 | } |
---|
1151 | if( ! accessUnits.empty() ) |
---|
1152 | { |
---|
1153 | list<AccessUnit>::iterator aUIter; |
---|
1154 | for( aUIter = accessUnits.begin(); aUIter != accessUnits.end(); aUIter++ ) |
---|
1155 | { |
---|
1156 | const vector<unsigned>& stats = writeAnnexB(bitstreamFile, *aUIter); |
---|
1157 | rateStatsAccum(*aUIter, stats); |
---|
1158 | } |
---|
1159 | } |
---|
1160 | #else |
---|
1161 | if (m_pchReconFile) |
---|
1162 | { |
---|
1163 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
1164 | } |
---|
1165 | |
---|
1166 | const AccessUnit& au = *(iterBitstream++); |
---|
1167 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
1168 | rateStatsAccum(au, stats); |
---|
1169 | } |
---|
1170 | #endif |
---|
1171 | } |
---|
1172 | } |
---|
1173 | |
---|
1174 | /** |
---|
1175 | * |
---|
1176 | */ |
---|
1177 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
1178 | { |
---|
1179 | AccessUnit::const_iterator it_au = au.begin(); |
---|
1180 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
1181 | |
---|
1182 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
1183 | { |
---|
1184 | switch ((*it_au)->m_nalUnitType) |
---|
1185 | { |
---|
1186 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1187 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1188 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
1189 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1190 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1191 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1192 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1193 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1194 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1195 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1196 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1197 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1198 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1199 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1200 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1201 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1202 | case NAL_UNIT_VPS: |
---|
1203 | case NAL_UNIT_SPS: |
---|
1204 | case NAL_UNIT_PPS: |
---|
1205 | m_essentialBytes += *it_stats; |
---|
1206 | break; |
---|
1207 | default: |
---|
1208 | break; |
---|
1209 | } |
---|
1210 | |
---|
1211 | m_totalBytes += *it_stats; |
---|
1212 | } |
---|
1213 | } |
---|
1214 | |
---|
1215 | void TAppEncTop::printRateSummary() |
---|
1216 | { |
---|
1217 | #if H_MV |
---|
1218 | Double time = (Double) m_frameRcvd[0] / m_iFrameRate; |
---|
1219 | printf("\n"); |
---|
1220 | #else |
---|
1221 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
1222 | #endif |
---|
1223 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
1224 | #if VERBOSE_RATE |
---|
1225 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
1226 | #endif |
---|
1227 | } |
---|
1228 | |
---|
1229 | #if H_3D_DIM_DLT |
---|
1230 | Void TAppEncTop::xAnalyzeInputBaseDepth(UInt layer, UInt uiNumFrames, TComVPS* vps, TComDLT* dlt) |
---|
1231 | { |
---|
1232 | TComPicYuv* pcDepthPicYuvOrg = new TComPicYuv; |
---|
1233 | // allocate original YUV buffer |
---|
1234 | pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1235 | |
---|
1236 | TVideoIOYuv* depthVideoFile = new TVideoIOYuv; |
---|
1237 | |
---|
1238 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
1239 | |
---|
1240 | Bool abValidDepths[256]; |
---|
1241 | |
---|
1242 | depthVideoFile->open( m_pchInputFileList[layer], false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
1243 | |
---|
1244 | // initialize boolean array |
---|
1245 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1246 | abValidDepths[p] = false; |
---|
1247 | |
---|
1248 | Int iHeight = pcDepthPicYuvOrg->getHeight(); |
---|
1249 | Int iWidth = pcDepthPicYuvOrg->getWidth(); |
---|
1250 | Int iStride = pcDepthPicYuvOrg->getStride(); |
---|
1251 | |
---|
1252 | Pel* pInDM = pcDepthPicYuvOrg->getLumaAddr(); |
---|
1253 | |
---|
1254 | for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ ) |
---|
1255 | { |
---|
1256 | depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad ); |
---|
1257 | |
---|
1258 | // check all pixel values |
---|
1259 | for (Int i=0; i<iHeight; i++) |
---|
1260 | { |
---|
1261 | Int rowOffset = i*iStride; |
---|
1262 | |
---|
1263 | for (Int j=0; j<iWidth; j++) |
---|
1264 | { |
---|
1265 | Pel depthValue = pInDM[rowOffset+j]; |
---|
1266 | abValidDepths[depthValue] = true; |
---|
1267 | } |
---|
1268 | } |
---|
1269 | } |
---|
1270 | |
---|
1271 | depthVideoFile->close(); |
---|
1272 | delete depthVideoFile; |
---|
1273 | |
---|
1274 | pcDepthPicYuvOrg->destroy(); |
---|
1275 | delete pcDepthPicYuvOrg; |
---|
1276 | |
---|
1277 | // convert boolean array to idx2Depth LUT |
---|
1278 | Int* aiIdx2DepthValue = (Int*) calloc(uiMaxDepthValue, sizeof(Int)); |
---|
1279 | Int iNumDepthValues = 0; |
---|
1280 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1281 | { |
---|
1282 | if( abValidDepths[p] == true) |
---|
1283 | { |
---|
1284 | aiIdx2DepthValue[iNumDepthValues++] = p; |
---|
1285 | } |
---|
1286 | } |
---|
1287 | |
---|
1288 | if( uiNumFrames == 0 || numBitsForValue(iNumDepthValues) == g_bitDepthY ) |
---|
1289 | { |
---|
1290 | dlt->setUseDLTFlag(layer, false); |
---|
1291 | } |
---|
1292 | |
---|
1293 | // assign LUT |
---|
1294 | if( dlt->getUseDLTFlag(layer) ) |
---|
1295 | { |
---|
1296 | dlt->setDepthLUTs(layer, aiIdx2DepthValue, iNumDepthValues); |
---|
1297 | } |
---|
1298 | |
---|
1299 | // free temporary memory |
---|
1300 | free(aiIdx2DepthValue); |
---|
1301 | } |
---|
1302 | #endif |
---|
1303 | |
---|
1304 | #if H_MV |
---|
1305 | Void TAppEncTop::xSetDimensionIdAndLength( TComVPS& vps ) |
---|
1306 | { |
---|
1307 | vps.setScalabilityMaskFlag( m_scalabilityMask ); |
---|
1308 | for( Int dim = 0; dim < m_dimIds.size(); dim++ ) |
---|
1309 | { |
---|
1310 | vps.setDimensionIdLen( dim, m_dimensionIdLen[ dim ] ); |
---|
1311 | for( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
---|
1312 | |
---|
1313 | { |
---|
1314 | vps.setDimensionId( layer, dim, m_dimIds[ dim ][ layer ] ); |
---|
1315 | } |
---|
1316 | } |
---|
1317 | |
---|
1318 | vps.initNumViews(); |
---|
1319 | Int maxViewId = xGetMax( m_viewId ); |
---|
1320 | |
---|
1321 | Int viewIdLen = gCeilLog2( maxViewId + 1 ); |
---|
1322 | const Int maxViewIdLen = ( 1 << 4 ) - 1; |
---|
1323 | assert( viewIdLen <= maxViewIdLen ); |
---|
1324 | vps.setViewIdLen( viewIdLen ); |
---|
1325 | for (Int i = 0; i < m_iNumberOfViews; i++) |
---|
1326 | { |
---|
1327 | vps.setViewIdVal( i, m_viewId[ i] ); |
---|
1328 | } |
---|
1329 | |
---|
1330 | assert( m_iNumberOfViews == vps.getNumViews() ); |
---|
1331 | } |
---|
1332 | |
---|
1333 | Void TAppEncTop::xSetDependencies( TComVPS& vps ) |
---|
1334 | { |
---|
1335 | // Direct dependency flags + dependency types |
---|
1336 | for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ ) |
---|
1337 | { |
---|
1338 | for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ ) |
---|
1339 | { |
---|
1340 | vps.setDirectDependencyFlag( depLayer, refLayer, false); |
---|
1341 | vps.setDirectDependencyType( depLayer, refLayer, -1 ); |
---|
1342 | } |
---|
1343 | } |
---|
1344 | |
---|
1345 | Int defaultDirectDependencyType = -1; |
---|
1346 | Bool defaultDirectDependencyFlag = false; |
---|
1347 | |
---|
1348 | for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ ) |
---|
1349 | { |
---|
1350 | Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); |
---|
1351 | assert( numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); |
---|
1352 | for( Int i = 0; i < numRefLayers; i++ ) |
---|
1353 | { |
---|
1354 | Int refLayer = m_directRefLayers[depLayer][i]; |
---|
1355 | vps.setDirectDependencyFlag( depLayer, refLayer, true); |
---|
1356 | Int curDirectDependencyType = m_dependencyTypes[depLayer][i]; |
---|
1357 | |
---|
1358 | if ( defaultDirectDependencyType != -1 ) |
---|
1359 | { |
---|
1360 | defaultDirectDependencyFlag = defaultDirectDependencyFlag && (curDirectDependencyType == defaultDirectDependencyType ); |
---|
1361 | } |
---|
1362 | else |
---|
1363 | { |
---|
1364 | defaultDirectDependencyType = curDirectDependencyType; |
---|
1365 | defaultDirectDependencyFlag = true; |
---|
1366 | } |
---|
1367 | |
---|
1368 | vps.setDirectDependencyType( depLayer, refLayer, curDirectDependencyType); |
---|
1369 | } |
---|
1370 | } |
---|
1371 | |
---|
1372 | vps.setDefaultDirectDependencyFlag( defaultDirectDependencyFlag ); |
---|
1373 | vps.setDefaultDirectDependencyType( defaultDirectDependencyFlag ? defaultDirectDependencyType : -1 ); |
---|
1374 | |
---|
1375 | vps.setRefLayers(); |
---|
1376 | |
---|
1377 | // Max sub layers, + presence flag |
---|
1378 | Bool subLayersMaxMinus1PresentFlag = false; |
---|
1379 | for (Int curLayerIdInVps = 0; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++ ) |
---|
1380 | { |
---|
1381 | Int curSubLayersMaxMinus1 = 0; |
---|
1382 | for( Int i = 0; i < getGOPSize(); i++ ) |
---|
1383 | { |
---|
1384 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][i]; |
---|
1385 | curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); |
---|
1386 | } |
---|
1387 | |
---|
1388 | vps.setSubLayersVpsMaxMinus1( curLayerIdInVps, curSubLayersMaxMinus1 ); |
---|
1389 | subLayersMaxMinus1PresentFlag = subLayersMaxMinus1PresentFlag || ( curSubLayersMaxMinus1 != vps.getMaxSubLayersMinus1() ); |
---|
1390 | } |
---|
1391 | |
---|
1392 | vps.setVpsSubLayersMaxMinus1PresentFlag( subLayersMaxMinus1PresentFlag ); |
---|
1393 | |
---|
1394 | // Max temporal id for inter layer reference pictures |
---|
1395 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
1396 | { |
---|
1397 | Int refLayerIdInNuh = vps.getLayerIdInNuh( refLayerIdInVps ); |
---|
1398 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
1399 | { |
---|
1400 | Int curLayerIdInNuh = vps.getLayerIdInNuh( curLayerIdInVps ); |
---|
1401 | Int maxTid = -1; |
---|
1402 | #if H_3D |
---|
1403 | if ( vps.getDirectDependencyFlag( curLayerIdInVps, refLayerIdInVps ) ) |
---|
1404 | { |
---|
1405 | if ( m_depthFlag[ curLayerIdInVps] == m_depthFlag[ refLayerIdInVps ] ) |
---|
1406 | { |
---|
1407 | #endif |
---|
1408 | for( Int i = 0; i < ( getGOPSize() + 1); i++ ) |
---|
1409 | { |
---|
1410 | GOPEntry geCur = m_GOPListMvc[curLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
1411 | GOPEntry geRef = m_GOPListMvc[refLayerIdInVps][( i < getGOPSize() ? i : MAX_GOP )]; |
---|
1412 | for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++) |
---|
1413 | { |
---|
1414 | #if H_3D |
---|
1415 | if ( vps.getIdRefListLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh ) |
---|
1416 | #else |
---|
1417 | if ( vps.getIdDirectRefLayer( curLayerIdInNuh, geCur.m_interLayerPredLayerIdc[ j ] ) == refLayerIdInNuh ) |
---|
1418 | #endif |
---|
1419 | { |
---|
1420 | Bool refAlwaysIntra = ( i == getGOPSize() ) && ( m_iIntraPeriod[ curLayerIdInVps ] % m_iIntraPeriod[ refLayerIdInVps ] == 0 ); |
---|
1421 | Bool refLayerZero = ( i == getGOPSize() ) && ( refLayerIdInVps == 0 ); |
---|
1422 | maxTid = std::max( maxTid, ( refAlwaysIntra || refLayerZero ) ? 0 : geRef.m_temporalId ); |
---|
1423 | } |
---|
1424 | } |
---|
1425 | } |
---|
1426 | #if H_3D |
---|
1427 | } |
---|
1428 | else |
---|
1429 | { |
---|
1430 | if( m_depthFlag[ curLayerIdInVps ] && ( m_mpiFlag|| m_qtPredFlag || m_intraContourFlag ) ) |
---|
1431 | { |
---|
1432 | Int nuhLayerIdTex = vps.getLayerIdInNuh( vps.getViewIndex( curLayerIdInNuh ), false ); |
---|
1433 | if ( nuhLayerIdTex == refLayerIdInNuh ) |
---|
1434 | { |
---|
1435 | maxTid = std::max( maxTid, vps.getSubLayersVpsMaxMinus1( refLayerIdInVps) + 1 ); |
---|
1436 | } |
---|
1437 | } |
---|
1438 | if( !m_depthFlag[ curLayerIdInVps ] && vps.getNumRefListLayers( curLayerIdInNuh) > 0 && ( m_depthRefinementFlag || m_viewSynthesisPredFlag || m_depthBasedBlkPartFlag ) ) |
---|
1439 | { |
---|
1440 | Int maxPresentTid =-1; |
---|
1441 | Bool allPresent = true; |
---|
1442 | for (Int i = 0; i < vps.getNumRefListLayers( curLayerIdInNuh); i++ ) |
---|
1443 | { |
---|
1444 | Int nuhLayerIdDep = vps.getLayerIdInNuh( vps.getViewIndex( vps.getIdRefListLayer(curLayerIdInNuh, i ) ), true ); |
---|
1445 | if ( nuhLayerIdDep== refLayerIdInNuh ) |
---|
1446 | { |
---|
1447 | maxPresentTid= std::max( maxTid, vps.getSubLayersVpsMaxMinus1( refLayerIdInVps) + 1 ); |
---|
1448 | } |
---|
1449 | else |
---|
1450 | { |
---|
1451 | allPresent = false; |
---|
1452 | } |
---|
1453 | } |
---|
1454 | |
---|
1455 | if ( allPresent ) |
---|
1456 | { |
---|
1457 | maxTid= std::max( maxTid, maxPresentTid ); |
---|
1458 | } |
---|
1459 | } |
---|
1460 | } |
---|
1461 | } |
---|
1462 | vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 ); |
---|
1463 | #endif |
---|
1464 | } |
---|
1465 | } |
---|
1466 | |
---|
1467 | // Max temporal id for inter layer reference pictures presence flag |
---|
1468 | Bool maxTidRefPresentFlag = false; |
---|
1469 | for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++) |
---|
1470 | { |
---|
1471 | for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++) |
---|
1472 | { |
---|
1473 | maxTidRefPresentFlag = maxTidRefPresentFlag || ( vps.getMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps ) != 7 ); |
---|
1474 | } |
---|
1475 | } |
---|
1476 | vps.setMaxTidRefPresentFlag( maxTidRefPresentFlag ); |
---|
1477 | |
---|
1478 | |
---|
1479 | // Max one active ref layer flag |
---|
1480 | Bool maxOneActiveRefLayerFlag = true; |
---|
1481 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; layerIdInVps++) |
---|
1482 | { |
---|
1483 | for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) |
---|
1484 | { |
---|
1485 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
1486 | maxOneActiveRefLayerFlag = maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); |
---|
1487 | } |
---|
1488 | } |
---|
1489 | |
---|
1490 | vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag ); |
---|
1491 | |
---|
1492 | // Poc Lsb Not Present Flag |
---|
1493 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers; layerIdInVps++) |
---|
1494 | { |
---|
1495 | if ( m_directRefLayers[ layerIdInVps ].size() == 0 ) |
---|
1496 | { |
---|
1497 | vps.setPocLsbNotPresentFlag( layerIdInVps, true ); |
---|
1498 | } |
---|
1499 | } |
---|
1500 | |
---|
1501 | // All Ref layers active flag |
---|
1502 | Bool allRefLayersActiveFlag = true; |
---|
1503 | for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers && allRefLayersActiveFlag; layerIdInVps++) |
---|
1504 | { |
---|
1505 | Int layerIdInNuh = vps.getLayerIdInNuh( layerIdInVps ); |
---|
1506 | for( Int i = 0; i < ( getGOPSize() + 1) && allRefLayersActiveFlag; i++ ) |
---|
1507 | { |
---|
1508 | GOPEntry ge = m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]; |
---|
1509 | Int tId = ge.m_temporalId; // Should be equal for all layers. |
---|
1510 | |
---|
1511 | // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry |
---|
1512 | #if H_3D |
---|
1513 | for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ ) |
---|
1514 | { |
---|
1515 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh , k ) ); |
---|
1516 | #else |
---|
1517 | for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ) && allRefLayersActiveFlag; k++ ) |
---|
1518 | { |
---|
1519 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh , k ) ); |
---|
1520 | #endif |
---|
1521 | if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId ) ) |
---|
1522 | { |
---|
1523 | Bool gopEntryFoundFlag = false; |
---|
1524 | for( Int l = 0; l < ge.m_numActiveRefLayerPics && !gopEntryFoundFlag; l++ ) |
---|
1525 | { |
---|
1526 | gopEntryFoundFlag = gopEntryFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
---|
1527 | } |
---|
1528 | allRefLayersActiveFlag = allRefLayersActiveFlag && gopEntryFoundFlag; |
---|
1529 | } |
---|
1530 | } |
---|
1531 | |
---|
1532 | // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1 |
---|
1533 | // (Should actually always be true) |
---|
1534 | Bool maxTidIlRefAndSubLayerMaxVaildFlag = true; |
---|
1535 | for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ ) |
---|
1536 | { |
---|
1537 | Bool referenceLayerFoundFlag = false; |
---|
1538 | #if H_3D |
---|
1539 | for (Int k = 0; k < vps.getNumRefListLayers( layerIdInNuh ); k++ ) |
---|
1540 | { |
---|
1541 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdRefListLayer( layerIdInNuh, k) ); |
---|
1542 | #else |
---|
1543 | for (Int k = 0; k < vps.getNumDirectRefLayers( layerIdInNuh ); k++ ) |
---|
1544 | { |
---|
1545 | Int refLayerIdInVps = vps.getLayerIdInVps( vps.getIdDirectRefLayer( layerIdInNuh, k) ); |
---|
1546 | #endif |
---|
1547 | if ( vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId && ( tId == 0 || vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId ) ) |
---|
1548 | { |
---|
1549 | referenceLayerFoundFlag = referenceLayerFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); |
---|
1550 | } |
---|
1551 | } |
---|
1552 | maxTidIlRefAndSubLayerMaxVaildFlag = maxTidIlRefAndSubLayerMaxVaildFlag && referenceLayerFoundFlag; |
---|
1553 | } |
---|
1554 | assert ( maxTidIlRefAndSubLayerMaxVaildFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1 |
---|
1555 | } |
---|
1556 | } |
---|
1557 | |
---|
1558 | vps.setAllRefLayersActiveFlag( allRefLayersActiveFlag ); |
---|
1559 | }; |
---|
1560 | |
---|
1561 | |
---|
1562 | GOPEntry* TAppEncTop::xGetGopEntry( Int layerIdInVps, Int poc ) |
---|
1563 | { |
---|
1564 | GOPEntry* geFound = NULL; |
---|
1565 | for( Int i = 0; i < ( getGOPSize() + 1) && geFound == NULL ; i++ ) |
---|
1566 | { |
---|
1567 | GOPEntry* ge = &(m_GOPListMvc[layerIdInVps][ ( i < getGOPSize() ? i : MAX_GOP ) ]); |
---|
1568 | if ( ge->m_POC == poc ) |
---|
1569 | { |
---|
1570 | geFound = ge; |
---|
1571 | } |
---|
1572 | } |
---|
1573 | assert( geFound != NULL ); |
---|
1574 | return geFound; |
---|
1575 | } |
---|
1576 | |
---|
1577 | Void TAppEncTop::xSetLayerIds( TComVPS& vps ) |
---|
1578 | { |
---|
1579 | vps.setSplittingFlag ( m_splittingFlag ); |
---|
1580 | |
---|
1581 | Bool nuhLayerIdPresentFlag = !( m_layerIdInNuh.size() == 1 ); |
---|
1582 | Int maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; |
---|
1583 | |
---|
1584 | vps.setVpsMaxLayerId( maxNuhLayerId ); |
---|
1585 | vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); |
---|
1586 | |
---|
1587 | for (Int layer = 0; layer < m_numberOfLayers; layer++ ) |
---|
1588 | { |
---|
1589 | vps.setLayerIdInNuh( layer, nuhLayerIdPresentFlag ? m_layerIdInNuh[ layer ] : layer ); |
---|
1590 | vps.setLayerIdInVps( vps.getLayerIdInNuh( layer ), layer ); |
---|
1591 | } |
---|
1592 | } |
---|
1593 | |
---|
1594 | Int TAppEncTop::xGetMax( std::vector<Int>& vec ) |
---|
1595 | { |
---|
1596 | Int maxVec = 0; |
---|
1597 | for ( Int i = 0; i < vec.size(); i++) |
---|
1598 | { |
---|
1599 | maxVec = max( vec[i], maxVec ); |
---|
1600 | } |
---|
1601 | return maxVec; |
---|
1602 | } |
---|
1603 | |
---|
1604 | Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps ) |
---|
1605 | { |
---|
1606 | |
---|
1607 | // SET PTL |
---|
1608 | assert( m_profile.size() == m_level.size() && m_profile.size() == m_levelTier.size() ); |
---|
1609 | vps.setVpsNumProfileTierLevelMinus1( (Int) m_profile.size() - 1 ); |
---|
1610 | for ( Int ptlIdx = 0; ptlIdx <= vps.getVpsNumProfileTierLevelMinus1(); ptlIdx++ ) |
---|
1611 | { |
---|
1612 | if ( ptlIdx > 1 ) |
---|
1613 | { |
---|
1614 | Bool vpsProfilePresentFlag = ( m_profile[ptlIdx] != m_profile[ptlIdx - 1] ) |
---|
1615 | || ( m_inblFlag[ptlIdx ] != m_inblFlag[ptlIdx - 1] ); |
---|
1616 | vps.setVpsProfilePresentFlag( ptlIdx, vpsProfilePresentFlag ); |
---|
1617 | } |
---|
1618 | |
---|
1619 | xSetProfileTierLevel( vps, ptlIdx, -1, m_profile[ptlIdx], m_level[ptlIdx], |
---|
1620 | m_levelTier[ ptlIdx ], m_progressiveSourceFlag, m_interlacedSourceFlag, |
---|
1621 | m_nonPackedConstraintFlag, m_frameOnlyConstraintFlag, m_inblFlag[ptlIdx] ); |
---|
1622 | } |
---|
1623 | } |
---|
1624 | |
---|
1625 | Void TAppEncTop::xSetProfileTierLevel(TComVPS& vps, Int profileTierLevelIdx, Int subLayer, Profile::Name profile, Level::Name level, Level::Tier tier, Bool progressiveSourceFlag, Bool interlacedSourceFlag, Bool nonPackedConstraintFlag, Bool frameOnlyConstraintFlag, Bool inbldFlag) |
---|
1626 | { |
---|
1627 | TComPTL* ptlStruct = vps.getPTL( profileTierLevelIdx ); |
---|
1628 | assert( ptlStruct != NULL ); |
---|
1629 | |
---|
1630 | ProfileTierLevel* ptl; |
---|
1631 | if ( subLayer == -1 ) |
---|
1632 | { |
---|
1633 | ptl = ptlStruct->getGeneralPTL(); |
---|
1634 | } |
---|
1635 | else |
---|
1636 | { |
---|
1637 | ptl = ptlStruct->getSubLayerPTL( subLayer ); |
---|
1638 | } |
---|
1639 | |
---|
1640 | assert( ptl != NULL ); |
---|
1641 | |
---|
1642 | ptl->setProfileIdc( profile ); |
---|
1643 | ptl->setTierFlag ( tier ); |
---|
1644 | ptl->setLevelIdc ( level ); |
---|
1645 | ptl->setProfileCompatibilityFlag( profile, true ); |
---|
1646 | ptl->setInbldFlag( inbldFlag ); |
---|
1647 | |
---|
1648 | switch ( profile ) |
---|
1649 | { |
---|
1650 | case Profile::MAIN: |
---|
1651 | break; |
---|
1652 | case Profile::MULTIVIEWMAIN: |
---|
1653 | #if H_3D |
---|
1654 | case Profile::MAIN3D: |
---|
1655 | #endif |
---|
1656 | ptl->setMax12bitConstraintFlag ( true ); |
---|
1657 | ptl->setMax12bitConstraintFlag ( true ); |
---|
1658 | ptl->setMax10bitConstraintFlag ( true ); |
---|
1659 | ptl->setMax8bitConstraintFlag ( true ); |
---|
1660 | ptl->setMax422chromaConstraintFlag ( true ); |
---|
1661 | ptl->setMax420chromaConstraintFlag ( true ); |
---|
1662 | ptl->setMaxMonochromeConstraintFlag ( false ); |
---|
1663 | ptl->setIntraConstraintFlag ( false ); |
---|
1664 | ptl->setOnePictureOnlyConstraintFlag( false ); |
---|
1665 | ptl->setLowerBitRateConstraintFlag ( true ); |
---|
1666 | break; |
---|
1667 | default: |
---|
1668 | assert( 0 ); // other profiles currently not supported |
---|
1669 | break; |
---|
1670 | } |
---|
1671 | } |
---|
1672 | |
---|
1673 | Void TAppEncTop::xSetRepFormat( TComVPS& vps ) |
---|
1674 | { |
---|
1675 | vps.setRepFormatIdxPresentFlag( false ); |
---|
1676 | vps.setVpsNumRepFormatsMinus1 ( 0 ); |
---|
1677 | |
---|
1678 | TComRepFormat* repFormat = new TComRepFormat; |
---|
1679 | |
---|
1680 | repFormat->setBitDepthVpsChromaMinus8 ( g_bitDepthC - 8 ); |
---|
1681 | repFormat->setBitDepthVpsLumaMinus8 ( g_bitDepthY - 8 ); |
---|
1682 | repFormat->setChromaFormatVpsIdc ( CHROMA_420 ); |
---|
1683 | repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight ); |
---|
1684 | repFormat->setPicWidthVpsInLumaSamples ( m_iSourceWidth ); |
---|
1685 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
---|
1686 | // ToDo not supported yet. |
---|
1687 | //repFormat->setSeparateColourPlaneVpsFlag( ); |
---|
1688 | |
---|
1689 | repFormat->setConformanceWindowVpsFlag( true ); |
---|
1690 | #if H_MV_ALIGN_HM_15 |
---|
1691 | repFormat->setConfWinVpsLeftOffset ( m_confWinLeft / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1692 | repFormat->setConfWinVpsRightOffset ( m_confWinRight / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1693 | repFormat->setConfWinVpsTopOffset ( m_confWinTop / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1694 | repFormat->setConfWinVpsBottomOffset ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1695 | #else |
---|
1696 | repFormat->setConfWinVpsLeftOffset ( m_confLeft / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1697 | repFormat->setConfWinVpsRightOffset ( m_confRight / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1698 | repFormat->setConfWinVpsTopOffset ( m_confTop / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1699 | repFormat->setConfWinVpsBottomOffset ( m_confBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); |
---|
1700 | #endif |
---|
1701 | assert( vps.getRepFormat( 0 ) == NULL ); |
---|
1702 | vps.setRepFormat( 0 , repFormat ); |
---|
1703 | } |
---|
1704 | |
---|
1705 | Void TAppEncTop::xSetDpbSize ( TComVPS& vps ) |
---|
1706 | { |
---|
1707 | // These settings need to be verified |
---|
1708 | |
---|
1709 | TComDpbSize* dpbSize = vps.getDpbSize(); |
---|
1710 | |
---|
1711 | assert ( dpbSize != 0 ); |
---|
1712 | |
---|
1713 | for( Int i = 0; i < vps.getNumOutputLayerSets(); i++ ) |
---|
1714 | { |
---|
1715 | Int currLsIdx = vps.olsIdxToLsIdx( i ); |
---|
1716 | Bool subLayerFlagInfoPresentFlag = false; |
---|
1717 | |
---|
1718 | for( Int j = 0; j <= vps.getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
1719 | { |
---|
1720 | Bool subLayerDpbInfoPresentFlag = false; |
---|
1721 | for( Int k = 0; k < vps.getNumLayersInIdList( currLsIdx ); k++ ) |
---|
1722 | { |
---|
1723 | Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList( currLsIdx, k ) ); |
---|
1724 | if ( vps.getNecessaryLayerFlag( i,k ) && ( vps.getVpsBaseLayerInternalFlag() || vps.getLayerSetLayerIdList( currLsIdx, k ) != 0 ) ) |
---|
1725 | { |
---|
1726 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 ); |
---|
1727 | if ( j > 0 ) |
---|
1728 | { |
---|
1729 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) != dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
1730 | } |
---|
1731 | } |
---|
1732 | else |
---|
1733 | { |
---|
1734 | if (vps.getNecessaryLayerFlag(i,k) && j == 0 && k == 0 ) |
---|
1735 | { |
---|
1736 | dpbSize->setMaxVpsDecPicBufferingMinus1(i, k ,j, 0 ); |
---|
1737 | } |
---|
1738 | } |
---|
1739 | } |
---|
1740 | |
---|
1741 | Int maxNumReorderPics = MIN_INT; |
---|
1742 | for ( Int idx = 0; idx < vps.getNumLayersInIdList( currLsIdx ); idx++ ) |
---|
1743 | { |
---|
1744 | if (vps.getNecessaryLayerFlag(i, idx )) |
---|
1745 | { |
---|
1746 | Int layerIdInVps = vps.getLayerIdInVps( vps.getLayerSetLayerIdList(currLsIdx, idx) ); |
---|
1747 | maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); |
---|
1748 | } |
---|
1749 | } |
---|
1750 | assert( maxNumReorderPics != MIN_INT ); |
---|
1751 | |
---|
1752 | dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics ); |
---|
1753 | if ( j > 0 ) |
---|
1754 | { |
---|
1755 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsNumReorderPics( i, j ) != dpbSize->getMaxVpsNumReorderPics( i, j - 1 ) ); |
---|
1756 | } |
---|
1757 | |
---|
1758 | // To Be Done ! |
---|
1759 | // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, xx ); |
---|
1760 | if ( j > 0 ) |
---|
1761 | { |
---|
1762 | subLayerDpbInfoPresentFlag = subLayerDpbInfoPresentFlag || ( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) != dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
1763 | } |
---|
1764 | |
---|
1765 | if( j > 0 ) |
---|
1766 | { |
---|
1767 | dpbSize->setSubLayerDpbInfoPresentFlag( i, j, subLayerDpbInfoPresentFlag ); |
---|
1768 | subLayerFlagInfoPresentFlag = subLayerFlagInfoPresentFlag || subLayerDpbInfoPresentFlag; |
---|
1769 | } |
---|
1770 | } |
---|
1771 | dpbSize->setSubLayerFlagInfoPresentFlag( i, subLayerFlagInfoPresentFlag ); |
---|
1772 | } |
---|
1773 | } |
---|
1774 | |
---|
1775 | Void TAppEncTop::xSetLayerSets( TComVPS& vps ) |
---|
1776 | { |
---|
1777 | // Layer sets |
---|
1778 | vps.setVpsNumLayerSetsMinus1 ( m_vpsNumLayerSets - 1 ); |
---|
1779 | |
---|
1780 | for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ ) |
---|
1781 | { |
---|
1782 | for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ ) |
---|
1783 | { |
---|
1784 | vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); |
---|
1785 | } |
---|
1786 | for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++) |
---|
1787 | { |
---|
1788 | vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); |
---|
1789 | } |
---|
1790 | } |
---|
1791 | vps.deriveLayerSetLayerIdList(); |
---|
1792 | |
---|
1793 | Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); |
---|
1794 | // Additional output layer sets + profileLevelTierIdx |
---|
1795 | vps.setDefaultOutputLayerIdc ( m_defaultOutputLayerIdc ); |
---|
1796 | if( vps.getNumIndependentLayers() == 0 && m_numAddLayerSets > 0 ) |
---|
1797 | { |
---|
1798 | fprintf( stderr, "\nWarning: Ignoring additional layer sets since NumIndependentLayers is equal to 0.\n"); |
---|
1799 | } |
---|
1800 | else |
---|
1801 | { |
---|
1802 | vps.setNumAddLayerSets( m_numAddLayerSets ); |
---|
1803 | if ( m_highestLayerIdxPlus1.size() < vps.getNumAddLayerSets() ) |
---|
1804 | { |
---|
1805 | fprintf(stderr, "\nError: Number of highestLayerIdxPlus1 parameters must be greater than or equal to NumAddLayerSets\n"); |
---|
1806 | exit(EXIT_FAILURE); |
---|
1807 | } |
---|
1808 | |
---|
1809 | for (Int i = 0; i < vps.getNumAddLayerSets(); i++) |
---|
1810 | { |
---|
1811 | if ( m_highestLayerIdxPlus1[ i ].size() < vps.getNumIndependentLayers() ) |
---|
1812 | { |
---|
1813 | fprintf(stderr, "Error: Number of elements in highestLayerIdxPlus1[ %d ] parameters must be greater than or equal to NumIndependentLayers(= %d)\n", i, vps.getNumIndependentLayers()); |
---|
1814 | exit(EXIT_FAILURE); |
---|
1815 | } |
---|
1816 | |
---|
1817 | for (Int j = 1; j < vps.getNumIndependentLayers(); j++) |
---|
1818 | { |
---|
1819 | if ( m_highestLayerIdxPlus1[ i ][ j ] < 0 || m_highestLayerIdxPlus1[ i ][ j ] > vps.getNumLayersInTreePartition( j ) ) |
---|
1820 | { |
---|
1821 | fprintf(stderr, "Error: highestLayerIdxPlus1[ %d ][ %d ] shall be in the range of 0 to NumLayersInTreePartition[ %d ] (= %d ), inclusive. \n", i, j, j, vps.getNumLayersInTreePartition( j ) ); |
---|
1822 | exit(EXIT_FAILURE); |
---|
1823 | } |
---|
1824 | vps.setHighestLayerIdxPlus1( i, j, m_highestLayerIdxPlus1[ i ][ j ] ); |
---|
1825 | } |
---|
1826 | vps.deriveAddLayerSetLayerIdList( i ); |
---|
1827 | } |
---|
1828 | } |
---|
1829 | vps.setNumAddOlss ( numAddOuputLayerSets ); |
---|
1830 | vps.initTargetLayerIdLists(); |
---|
1831 | |
---|
1832 | for (Int olsIdx = 0; olsIdx < vps.getNumLayerSets() + numAddOuputLayerSets; olsIdx++) |
---|
1833 | { |
---|
1834 | Int addOutLsIdx = olsIdx - vps.getNumLayerSets(); |
---|
1835 | vps.setLayerSetIdxForOlsMinus1( olsIdx, ( ( addOutLsIdx < 0 ) ? olsIdx : m_outputLayerSetIdx[ addOutLsIdx ] ) - 1 ); |
---|
1836 | |
---|
1837 | Int lsIdx = vps.olsIdxToLsIdx( olsIdx ); |
---|
1838 | if (vps.getDefaultOutputLayerIdc() == 2 || addOutLsIdx >= 0 ) |
---|
1839 | { |
---|
1840 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
1841 | { |
---|
1842 | vps.setOutputLayerFlag( olsIdx, i, ( olsIdx == 0 && i == 0 ) ? vps.inferOutputLayerFlag(olsIdx, i ) : false ); // This is a software only fix for a bug in the spec. In spec outputLayerFlag neither present nor inferred for this case ! |
---|
1843 | } |
---|
1844 | |
---|
1845 | std::vector<Int>& outLayerIdList = ( addOutLsIdx >= 0 ) ? m_layerIdsInAddOutputLayerSet[addOutLsIdx] : m_layerIdsInDefOutputLayerSet[olsIdx]; |
---|
1846 | |
---|
1847 | Bool outputLayerInLayerSetFlag = false; |
---|
1848 | for (Int j = 0; j < outLayerIdList.size(); j++) |
---|
1849 | { |
---|
1850 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
1851 | { |
---|
1852 | if ( vps.getLayerSetLayerIdList( lsIdx, i ) == outLayerIdList[ j ] ) |
---|
1853 | { |
---|
1854 | vps.setOutputLayerFlag( olsIdx, i, true ); |
---|
1855 | outputLayerInLayerSetFlag = true; |
---|
1856 | break; |
---|
1857 | } |
---|
1858 | } |
---|
1859 | if ( !outputLayerInLayerSetFlag ) |
---|
1860 | { |
---|
1861 | fprintf(stderr, "Error: Output layer %d in output layer set %d not in corresponding layer set %d \n", outLayerIdList[ j ], olsIdx , lsIdx ); |
---|
1862 | exit(EXIT_FAILURE); |
---|
1863 | } |
---|
1864 | } |
---|
1865 | } |
---|
1866 | else |
---|
1867 | { |
---|
1868 | for ( Int i = 0; i < vps.getNumLayersInIdList( lsIdx ); i++) |
---|
1869 | { |
---|
1870 | vps.setOutputLayerFlag( olsIdx, i, vps.inferOutputLayerFlag( olsIdx, i ) ); |
---|
1871 | } |
---|
1872 | } |
---|
1873 | |
---|
1874 | vps.deriveNecessaryLayerFlags( olsIdx ); |
---|
1875 | vps.deriveTargetLayerIdList( olsIdx ); |
---|
1876 | |
---|
1877 | // SET profile_tier_level_index. |
---|
1878 | if ( olsIdx == 0 ) |
---|
1879 | { |
---|
1880 | vps.setProfileTierLevelIdx( 0, 0 , vps.getMaxLayersMinus1() > 0 ? 1 : 0 ); |
---|
1881 | } |
---|
1882 | else |
---|
1883 | { |
---|
1884 | if( (Int) m_profileTierLevelIdx[ olsIdx ].size() < vps.getNumLayersInIdList( lsIdx ) ) |
---|
1885 | { |
---|
1886 | fprintf( stderr, "Warning: Not enough profileTierLevelIdx values given for the %d-th OLS. Inferring default values.\n", olsIdx ); |
---|
1887 | } |
---|
1888 | for (Int j = 0; j < vps.getNumLayersInIdList( lsIdx ); j++) |
---|
1889 | { |
---|
1890 | if( j < (Int) m_profileTierLevelIdx[ olsIdx ].size() ) |
---|
1891 | { |
---|
1892 | vps.setProfileTierLevelIdx(olsIdx, j, m_profileTierLevelIdx[olsIdx][j] ); |
---|
1893 | if( !vps.getNecessaryLayerFlag(olsIdx,j) && m_profileTierLevelIdx[ olsIdx ][ j ] != -1 ) |
---|
1894 | { |
---|
1895 | fprintf( stderr, "Warning: The %d-th layer in the %d-th OLS is not necessary such that profileTierLevelIdx[%d][%d] will be ignored. Set value to -1 to suppress warning.\n", j,olsIdx,olsIdx,j ); |
---|
1896 | } |
---|
1897 | } |
---|
1898 | else if ( vps.getNecessaryLayerFlag(olsIdx,j) ) |
---|
1899 | { |
---|
1900 | // setting default values |
---|
1901 | if ( j == 0 || vps.getVpsNumProfileTierLevelMinus1() < 1 ) |
---|
1902 | { |
---|
1903 | // set base layer as default |
---|
1904 | vps.setProfileTierLevelIdx(olsIdx, j, 1 ); |
---|
1905 | } |
---|
1906 | else |
---|
1907 | { |
---|
1908 | // set VpsProfileTierLevel[2] as default |
---|
1909 | vps.setProfileTierLevelIdx(olsIdx, j, 2 ); |
---|
1910 | } |
---|
1911 | } |
---|
1912 | } |
---|
1913 | } |
---|
1914 | |
---|
1915 | if ( vps.getNumOutputLayersInOutputLayerSet( olsIdx ) == 1 && |
---|
1916 | vps.getNumDirectRefLayers( vps.getOlsHighestOutputLayerId( olsIdx ) ) ) |
---|
1917 | { |
---|
1918 | vps.setAltOutputLayerFlag( olsIdx , m_altOutputLayerFlag[ olsIdx ]); |
---|
1919 | } |
---|
1920 | else |
---|
1921 | { |
---|
1922 | vps.setAltOutputLayerFlag( olsIdx , false ); |
---|
1923 | if ( m_altOutputLayerFlag[ olsIdx ] ) |
---|
1924 | { |
---|
1925 | printf( "\nWarning: Ignoring AltOutputLayerFlag for output layer set %d, since more than one output layer or no dependent layers.\n", olsIdx ); |
---|
1926 | } |
---|
1927 | } |
---|
1928 | } |
---|
1929 | } |
---|
1930 | |
---|
1931 | Void TAppEncTop::xSetVPSVUI( TComVPS& vps ) |
---|
1932 | { |
---|
1933 | vps.setVpsVuiPresentFlag( m_vpsVuiPresentFlag ); |
---|
1934 | |
---|
1935 | TComVPSVUI* pcVPSVUI = vps.getVPSVUI( ); |
---|
1936 | assert( pcVPSVUI ); |
---|
1937 | |
---|
1938 | if ( m_vpsVuiPresentFlag ) |
---|
1939 | { |
---|
1940 | // All this stuff could actually be derived by the encoder, |
---|
1941 | // however preliminary setting it from input parameters |
---|
1942 | |
---|
1943 | pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag ); |
---|
1944 | pcVPSVUI->setCrossLayerIrapAlignedFlag ( m_crossLayerIrapAlignedFlag ); |
---|
1945 | pcVPSVUI->setAllLayersIdrAlignedFlag ( m_allLayersIdrAlignedFlag ); |
---|
1946 | pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag ); |
---|
1947 | pcVPSVUI->setPicRatePresentVpsFlag( m_picRatePresentVpsFlag ); |
---|
1948 | |
---|
1949 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1950 | { |
---|
1951 | for( Int i = 0; i < vps.getNumLayerSets(); i++ ) |
---|
1952 | { |
---|
1953 | for( Int j = 0; j <= vps.getMaxTLayers(); j++ ) |
---|
1954 | { |
---|
1955 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) && m_bitRatePresentFlag[i].size() > j ) |
---|
1956 | { |
---|
1957 | pcVPSVUI->setBitRatePresentFlag( i, j, m_bitRatePresentFlag[i][j] ); |
---|
1958 | } |
---|
1959 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) && m_picRatePresentFlag[i].size() > j ) |
---|
1960 | { |
---|
1961 | pcVPSVUI->setPicRatePresentFlag( i, j, m_picRatePresentFlag[i][j] ); |
---|
1962 | } |
---|
1963 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_avgBitRate[i].size() > j ) |
---|
1964 | { |
---|
1965 | pcVPSVUI->setAvgBitRate( i, j, m_avgBitRate[i][j] ); |
---|
1966 | } |
---|
1967 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) && m_maxBitRate[i].size() > j ) |
---|
1968 | { |
---|
1969 | pcVPSVUI->setMaxBitRate( i, j, m_maxBitRate[i][j] ); |
---|
1970 | } |
---|
1971 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_constantPicRateIdc[i].size() > j ) |
---|
1972 | { |
---|
1973 | pcVPSVUI->setConstantPicRateIdc( i, j, m_constantPicRateIdc[i][j] ); |
---|
1974 | } |
---|
1975 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) && m_avgPicRate[i].size() > j ) |
---|
1976 | { |
---|
1977 | pcVPSVUI->setAvgPicRate( i, j, m_avgPicRate[i][j] ); |
---|
1978 | } |
---|
1979 | } |
---|
1980 | } |
---|
1981 | } |
---|
1982 | |
---|
1983 | pcVPSVUI->setTilesNotInUseFlag( m_tilesNotInUseFlag ); |
---|
1984 | |
---|
1985 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
1986 | { |
---|
1987 | for( Int i = 0; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
1988 | { |
---|
1989 | pcVPSVUI->setTilesInUseFlag( i, m_tilesInUseFlag[ i ] ); |
---|
1990 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
1991 | { |
---|
1992 | pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] ); |
---|
1993 | } |
---|
1994 | } |
---|
1995 | |
---|
1996 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
1997 | { |
---|
1998 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ ) |
---|
1999 | { |
---|
2000 | Int layerIdx = vps.getLayerIdInVps( vps.getIdDirectRefLayer(vps.getLayerIdInNuh( i ) , j )); |
---|
2001 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
2002 | { |
---|
2003 | pcVPSVUI->setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] ); |
---|
2004 | } |
---|
2005 | } |
---|
2006 | } |
---|
2007 | } |
---|
2008 | |
---|
2009 | pcVPSVUI->setWppNotInUseFlag( m_wppNotInUseFlag ); |
---|
2010 | |
---|
2011 | if( !pcVPSVUI->getWppNotInUseFlag( ) ) |
---|
2012 | { |
---|
2013 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
2014 | { |
---|
2015 | pcVPSVUI->setWppInUseFlag( i, m_wppInUseFlag[ i ]); |
---|
2016 | } |
---|
2017 | } |
---|
2018 | |
---|
2019 | pcVPSVUI->setSingleLayerForNonIrapFlag( m_singleLayerForNonIrapFlag ); |
---|
2020 | pcVPSVUI->setHigherLayerIrapSkipFlag( m_higherLayerIrapSkipFlag ); |
---|
2021 | |
---|
2022 | pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag ); |
---|
2023 | |
---|
2024 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
2025 | { |
---|
2026 | for( Int i = 1; i <= vps.getMaxLayersMinus1(); i++ ) |
---|
2027 | { |
---|
2028 | for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ); j++ ) |
---|
2029 | { |
---|
2030 | if ( m_minSpatialSegmentOffsetPlus1[i].size() > j ) |
---|
2031 | { |
---|
2032 | pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, m_minSpatialSegmentOffsetPlus1[i][j] ); |
---|
2033 | } |
---|
2034 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
2035 | { |
---|
2036 | if ( m_ctuBasedOffsetEnabledFlag[i].size() > j ) |
---|
2037 | { |
---|
2038 | pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, m_ctuBasedOffsetEnabledFlag[i][j] ); |
---|
2039 | } |
---|
2040 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
2041 | { |
---|
2042 | if ( m_minHorizontalCtuOffsetPlus1[i].size() > j ) |
---|
2043 | { |
---|
2044 | pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, m_minHorizontalCtuOffsetPlus1[i][j] ); |
---|
2045 | } |
---|
2046 | } |
---|
2047 | } |
---|
2048 | } |
---|
2049 | } |
---|
2050 | } |
---|
2051 | pcVPSVUI->setVideoSignalInfoIdxPresentFlag( true ); |
---|
2052 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1 ( 0 ); |
---|
2053 | |
---|
2054 | assert ( pcVPSVUI->getVideoSignalInfo( 0 ) == NULL ); |
---|
2055 | |
---|
2056 | TComVideoSignalInfo* videoSignalInfo = new TComVideoSignalInfo; |
---|
2057 | |
---|
2058 | videoSignalInfo->setColourPrimariesVps ( m_colourPrimaries ); |
---|
2059 | videoSignalInfo->setMatrixCoeffsVps ( m_matrixCoefficients ); |
---|
2060 | videoSignalInfo->setTransferCharacteristicsVps( m_transferCharacteristics ); |
---|
2061 | videoSignalInfo->setVideoVpsFormat ( m_videoFormat ); |
---|
2062 | videoSignalInfo->setVideoFullRangeVpsFlag ( m_videoFullRangeFlag ); |
---|
2063 | |
---|
2064 | pcVPSVUI->setVideoSignalInfo( 0, videoSignalInfo ); |
---|
2065 | |
---|
2066 | for (Int i = 0; i < m_numberOfLayers; i++) |
---|
2067 | { |
---|
2068 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 ); |
---|
2069 | } |
---|
2070 | pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD |
---|
2071 | } |
---|
2072 | else |
---|
2073 | { |
---|
2074 | pcVPSVUI->setCrossLayerIrapAlignedFlag ( false ); |
---|
2075 | } |
---|
2076 | } |
---|
2077 | Bool TAppEncTop::xLayerIdInTargetEncLayerIdList(Int nuhLayerId) |
---|
2078 | { |
---|
2079 | return ( std::find(m_targetEncLayerIdList.begin(), m_targetEncLayerIdList.end(), nuhLayerId) != m_targetEncLayerIdList.end()) ; |
---|
2080 | } |
---|
2081 | |
---|
2082 | |
---|
2083 | #endif |
---|
2084 | |
---|
2085 | |
---|
2086 | #if H_3D |
---|
2087 | |
---|
2088 | Void TAppEncTop::xDeriveDltArray( TComVPS& vps, TComDLT& dlt ) |
---|
2089 | { |
---|
2090 | Int iNumDepthViews = 0; |
---|
2091 | Bool bDltPresentFlag = false; |
---|
2092 | |
---|
2093 | for ( Int layer = 0; layer <= vps.getMaxLayersMinus1(); layer++ ) |
---|
2094 | { |
---|
2095 | Bool isDepth = ( vps.getDepthId( layer ) == 1 ); |
---|
2096 | |
---|
2097 | if ( isDepth ) |
---|
2098 | { |
---|
2099 | iNumDepthViews++; |
---|
2100 | } |
---|
2101 | |
---|
2102 | dlt.setUseDLTFlag( layer , isDepth && m_useDLT ); |
---|
2103 | if( dlt.getUseDLTFlag( layer ) ) |
---|
2104 | { |
---|
2105 | xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod[layer], 24), &vps, &dlt); |
---|
2106 | bDltPresentFlag = bDltPresentFlag || dlt.getUseDLTFlag(layer); |
---|
2107 | dlt.setInterViewDltPredEnableFlag(layer, (dlt.getUseDLTFlag(layer) && (layer>1))); |
---|
2108 | } |
---|
2109 | } |
---|
2110 | |
---|
2111 | dlt.setDltPresentFlag( bDltPresentFlag ); |
---|
2112 | dlt.setNumDepthViews ( iNumDepthViews ); |
---|
2113 | } |
---|
2114 | #endif |
---|
2115 | //! \} |
---|