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