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