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