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