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