1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TAppEncTop.cpp |
---|
35 | \brief Encoder application class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <list> |
---|
39 | #include <fstream> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <stdio.h> |
---|
42 | #include <fcntl.h> |
---|
43 | #include <assert.h> |
---|
44 | |
---|
45 | #include "TAppEncTop.h" |
---|
46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
47 | |
---|
48 | using namespace std; |
---|
49 | |
---|
50 | //! \ingroup TAppEncoder |
---|
51 | //! \{ |
---|
52 | |
---|
53 | // ==================================================================================================================== |
---|
54 | // Constructor / destructor / initialization / destroy |
---|
55 | // ==================================================================================================================== |
---|
56 | |
---|
57 | TAppEncTop::TAppEncTop() |
---|
58 | { |
---|
59 | m_iFrameRcvd = 0; |
---|
60 | m_totalBytes = 0; |
---|
61 | m_essentialBytes = 0; |
---|
62 | #if SVC_EXTENSION |
---|
63 | for(UInt layer=0; layer < MAX_LAYERS; layer++) |
---|
64 | { |
---|
65 | m_apcTEncTop[layer] = &m_acTEncTop[layer]; |
---|
66 | } |
---|
67 | #endif |
---|
68 | } |
---|
69 | |
---|
70 | TAppEncTop::~TAppEncTop() |
---|
71 | { |
---|
72 | } |
---|
73 | |
---|
74 | #if SVC_EXTENSION |
---|
75 | Void TAppEncTop::xInitLibCfg() |
---|
76 | { |
---|
77 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
78 | |
---|
79 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
80 | vps->setVpsPocLsbAlignedFlag(false); |
---|
81 | #endif |
---|
82 | vps->setMaxTLayers ( m_maxTempLayer ); |
---|
83 | if (m_maxTempLayer == 1) |
---|
84 | { |
---|
85 | vps->setTemporalNestingFlag(true); |
---|
86 | } |
---|
87 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
88 | { |
---|
89 | vps->setNumReorderPics ( m_numReorderPics[i], i ); |
---|
90 | vps->setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
91 | } |
---|
92 | |
---|
93 | #if REPN_FORMAT_IN_VPS |
---|
94 | Int maxRepFormatIdx = -1; |
---|
95 | Int formatIdx = -1; |
---|
96 | for(UInt layer=0; layer < m_numLayers; layer++) |
---|
97 | { |
---|
98 | // Auto generation of the format index |
---|
99 | if( m_acLayerCfg[layer].getRepFormatIdx() == -1 ) |
---|
100 | { |
---|
101 | Bool found = false; |
---|
102 | for( UInt idx = 0; idx < layer; idx++ ) |
---|
103 | { |
---|
104 | if( m_acLayerCfg[layer].getSourceWidth() == m_acLayerCfg[idx].getSourceWidth() && m_acLayerCfg[layer].getSourceHeight() == m_acLayerCfg[idx].getSourceHeight() |
---|
105 | #if AUXILIARY_PICTURES |
---|
106 | && m_acLayerCfg[layer].getChromaFormatIDC() == m_acLayerCfg[idx].getChromaFormatIDC() |
---|
107 | #endif |
---|
108 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
109 | && m_acLayerCfg[layer].m_internalBitDepthY == m_acLayerCfg[idx].m_internalBitDepthY && m_acLayerCfg[layer].m_internalBitDepthC == m_acLayerCfg[idx].m_internalBitDepthC |
---|
110 | #endif |
---|
111 | ) |
---|
112 | { |
---|
113 | found = true; |
---|
114 | break; |
---|
115 | } |
---|
116 | } |
---|
117 | if( !found ) |
---|
118 | { |
---|
119 | formatIdx++; |
---|
120 | } |
---|
121 | |
---|
122 | m_acLayerCfg[layer].setRepFormatIdx( formatIdx ); |
---|
123 | } |
---|
124 | |
---|
125 | assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
---|
126 | |
---|
127 | vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() ); |
---|
128 | |
---|
129 | maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx ); |
---|
130 | } |
---|
131 | |
---|
132 | assert( vps->getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
---|
133 | |
---|
134 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
---|
135 | |
---|
136 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
---|
137 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
---|
138 | { |
---|
139 | mapIdxToLayer[i] = -1; |
---|
140 | UInt layer; |
---|
141 | for(layer=0; layer < m_numLayers; layer++) |
---|
142 | { |
---|
143 | if( vps->getVpsRepFormatIdx(layer) == i ) |
---|
144 | { |
---|
145 | mapIdxToLayer[i] = layer; |
---|
146 | break; |
---|
147 | } |
---|
148 | } |
---|
149 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
---|
150 | } |
---|
151 | |
---|
152 | vps->setVpsNumRepFormats( maxRepFormatIdx + 1 ); |
---|
153 | |
---|
154 | #if Q0195_REP_FORMAT_CLEANUP |
---|
155 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
156 | vps->setRepFormatIdxPresentFlag( vps->getVpsNumRepFormats() > 1 ? true : false ); |
---|
157 | #else |
---|
158 | vps->setRepFormatIdxPresentFlag( true ); |
---|
159 | #endif |
---|
160 | |
---|
161 | for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++) |
---|
162 | { |
---|
163 | RepFormat *repFormat = vps->getVpsRepFormat( idx ); |
---|
164 | #if REPN_FORMAT_CONTROL_FLAG |
---|
165 | repFormat->setChromaAndBitDepthVpsPresentFlag( true ); |
---|
166 | if (idx==0) |
---|
167 | { |
---|
168 | assert(repFormat->getChromaAndBitDepthVpsPresentFlag() == true); |
---|
169 | } |
---|
170 | #endif |
---|
171 | repFormat->setPicWidthVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth() ); |
---|
172 | repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight() ); |
---|
173 | #if AUXILIARY_PICTURES |
---|
174 | repFormat->setChromaFormatVpsIdc ( m_acLayerCfg[mapIdxToLayer[idx]].getChromaFormatIDC() ); |
---|
175 | #else |
---|
176 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
---|
177 | #endif |
---|
178 | repFormat->setSeparateColourPlaneVpsFlag( 0 ); // Need modification to change for each layer |
---|
179 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
180 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
181 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC(mapIdxToLayer[idx]) ); // Need modification to change for each layer |
---|
182 | #else |
---|
183 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY() ); // Need modification to change for each layer |
---|
184 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC() ); // Need modification to change for each layer |
---|
185 | #endif |
---|
186 | |
---|
187 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
188 | repFormat->getConformanceWindowVps().setWindow( |
---|
189 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft, |
---|
190 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight, |
---|
191 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop, |
---|
192 | m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom ); |
---|
193 | #endif |
---|
194 | |
---|
195 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
196 | m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch ); |
---|
197 | #endif |
---|
198 | } |
---|
199 | delete [] mapIdxToLayer; |
---|
200 | #endif |
---|
201 | |
---|
202 | #if MULTIPLE_PTL_SUPPORT |
---|
203 | //Populate PTL in VPS |
---|
204 | TComVPS *pVPS = m_acTEncTop[0].getVPS(); |
---|
205 | ProfileTierLevel& profileTierLevel = *(pVPS->getPTL(0)->getGeneralPTL()); |
---|
206 | for (int ii = 0; ii < m_numPTLInfo; ii++) |
---|
207 | { |
---|
208 | profileTierLevel = *(pVPS->getPTL(ii)->getGeneralPTL()); |
---|
209 | |
---|
210 | profileTierLevel.setLevelIdc(m_levelList[ii]); |
---|
211 | profileTierLevel.setTierFlag(m_levelTierList[ii]); |
---|
212 | profileTierLevel.setProfileIdc(m_profileList[ii]); |
---|
213 | profileTierLevel.setProfileCompatibilityFlag(m_profileList[ii], 1); |
---|
214 | profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]); |
---|
215 | profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]); |
---|
216 | profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]); |
---|
217 | profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]); |
---|
218 | } |
---|
219 | pVPS->setNumProfileTierLevel(m_numPTLInfo); |
---|
220 | |
---|
221 | std::vector<int> myvector; |
---|
222 | vps->getProfileLevelTierIdx()->resize(m_numOutputLayerSets); |
---|
223 | for (int ii = 0; ii < m_numOutputLayerSets; ii++) |
---|
224 | { |
---|
225 | myvector = m_listOfLayerPTLofOlss[ii]; |
---|
226 | vps->getProfileLevelTierIdx()->resize(myvector.size()); |
---|
227 | for (std::vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it) |
---|
228 | { |
---|
229 | pVPS->addProfileLevelTierIdx(ii, it[0]); |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | //pVPS->setProfileLevelTierIdx( |
---|
234 | #endif |
---|
235 | |
---|
236 | assert( m_numLayers <= MAX_LAYERS ); |
---|
237 | |
---|
238 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
239 | { |
---|
240 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
241 | //1 |
---|
242 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
243 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
244 | |
---|
245 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
246 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
247 | |
---|
248 | // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic" |
---|
249 | g_bitDepthYLayer[layer] = g_bitDepthY; |
---|
250 | g_bitDepthCLayer[layer] = g_bitDepthC; |
---|
251 | |
---|
252 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
253 | m_acTEncTop[layer].setInterLayerWeightedPredFlag( m_useInterLayerWeightedPred ); |
---|
254 | #endif |
---|
255 | #endif |
---|
256 | //m_acTEncTop[layer].setVPS(&vps); |
---|
257 | m_acTEncTop[layer].setFrameRate ( m_acLayerCfg[layer].getFrameRate() ); |
---|
258 | m_acTEncTop[layer].setFrameSkip ( m_FrameSkip ); |
---|
259 | m_acTEncTop[layer].setSourceWidth ( m_acLayerCfg[layer].getSourceWidth() ); |
---|
260 | m_acTEncTop[layer].setSourceHeight ( m_acLayerCfg[layer].getSourceHeight() ); |
---|
261 | m_acTEncTop[layer].setConformanceWindow ( m_acLayerCfg[layer].m_confWinLeft, m_acLayerCfg[layer].m_confWinRight, m_acLayerCfg[layer].m_confWinTop, m_acLayerCfg[layer].m_confWinBottom ); |
---|
262 | m_acTEncTop[layer].setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
263 | |
---|
264 | #if !MULTIPLE_PTL_SUPPORT |
---|
265 | m_acTEncTop[layer].setProfile(m_profile); |
---|
266 | m_acTEncTop[layer].setLevel(m_levelTier, m_level); |
---|
267 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
268 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
269 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
270 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
271 | #else |
---|
272 | m_acTEncTop[layer].setProfile(m_profileList[m_layerPTLIdx[layer]]); |
---|
273 | m_acTEncTop[layer].setLevel(m_levelTierList[m_layerPTLIdx[layer]], m_levelList[m_layerPTLIdx[layer]]); |
---|
274 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlagList[m_layerPTLIdx[layer]]); |
---|
275 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlagList[m_layerPTLIdx[layer]]); |
---|
276 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[m_layerPTLIdx[layer]]); |
---|
277 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[m_layerPTLIdx[layer]]); |
---|
278 | #endif |
---|
279 | |
---|
280 | #if REF_IDX_MFM |
---|
281 | #if AVC_BASE |
---|
282 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
283 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
284 | #else |
---|
285 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
286 | #endif |
---|
287 | #else |
---|
288 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) ); |
---|
289 | #endif |
---|
290 | #endif |
---|
291 | // set layer ID |
---|
292 | m_acTEncTop[layer].setLayerId ( layer ); |
---|
293 | m_acTEncTop[layer].setNumLayer ( m_numLayers ); |
---|
294 | m_acTEncTop[layer].setLayerEnc(m_apcTEncTop); |
---|
295 | |
---|
296 | //====== Coding Structure ======== |
---|
297 | m_acTEncTop[layer].setIntraPeriod ( m_acLayerCfg[layer].m_iIntraPeriod ); |
---|
298 | m_acTEncTop[layer].setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
299 | m_acTEncTop[layer].setGOPSize ( m_iGOPSize ); |
---|
300 | #if Q0108_TSA_STSA |
---|
301 | m_acTEncTop[layer].setGopList ( layer ? m_EhGOPList[layer] : m_GOPList ); |
---|
302 | #else |
---|
303 | m_acTEncTop[layer].setGopList ( m_GOPList ); |
---|
304 | #endif |
---|
305 | |
---|
306 | #if !Q0108_TSA_STSA |
---|
307 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs ); |
---|
308 | #else |
---|
309 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs[layer] ); |
---|
310 | #endif |
---|
311 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
312 | { |
---|
313 | m_acTEncTop[layer].setNumReorderPics ( m_numReorderPics[i], i ); |
---|
314 | m_acTEncTop[layer].setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
315 | } |
---|
316 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
317 | { |
---|
318 | m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
319 | } |
---|
320 | m_acTEncTop[layer].setQP ( m_acLayerCfg[layer].getIntQP() ); |
---|
321 | |
---|
322 | m_acTEncTop[layer].setPad ( m_acLayerCfg[layer].getPad() ); |
---|
323 | #if !Q0108_TSA_STSA |
---|
324 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
325 | #else |
---|
326 | if (layer== 0) |
---|
327 | { |
---|
328 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
329 | } |
---|
330 | else |
---|
331 | { |
---|
332 | m_acTEncTop[layer].setMaxTempLayer ( m_EhMaxTempLayer[layer] ); |
---|
333 | } |
---|
334 | #endif |
---|
335 | m_acTEncTop[layer].setUseAMP( m_enableAMP ); |
---|
336 | |
---|
337 | if( layer < m_numLayers - 1 ) |
---|
338 | { |
---|
339 | m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); |
---|
340 | } |
---|
341 | |
---|
342 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
343 | if(layer) |
---|
344 | { |
---|
345 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
346 | { |
---|
347 | m_acTEncTop[layer].setSamplePredEnabledFlag(i, false); |
---|
348 | m_acTEncTop[layer].setMotionPredEnabledFlag(i, false); |
---|
349 | } |
---|
350 | if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1) |
---|
351 | { |
---|
352 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
353 | m_acTEncTop[layer].setNumSamplePredRefLayers (1); // One sample pred ref. layer |
---|
354 | m_acTEncTop[layer].setSamplePredRefLayerId (0, layer - 1); // Previous layer |
---|
355 | m_acTEncTop[layer].setSamplePredEnabledFlag (layer - 1, true); |
---|
356 | } |
---|
357 | else |
---|
358 | { |
---|
359 | m_acTEncTop[layer].setNumSamplePredRefLayers ( m_acLayerCfg[layer].getNumSamplePredRefLayers() ); |
---|
360 | for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++) |
---|
361 | { |
---|
362 | m_acTEncTop[layer].setSamplePredRefLayerId ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i)); |
---|
363 | m_acTEncTop[layer].setSamplePredEnabledFlag (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true); |
---|
364 | } |
---|
365 | } |
---|
366 | if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1) |
---|
367 | { |
---|
368 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
369 | m_acTEncTop[layer].setNumMotionPredRefLayers (1); // One motion pred ref. layer |
---|
370 | m_acTEncTop[layer].setMotionPredRefLayerId (0, layer - 1); // Previous layer |
---|
371 | m_acTEncTop[layer].setMotionPredEnabledFlag (layer - 1, true); |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | m_acTEncTop[layer].setNumMotionPredRefLayers ( m_acLayerCfg[layer].getNumMotionPredRefLayers() ); |
---|
376 | for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++) |
---|
377 | { |
---|
378 | m_acTEncTop[layer].setMotionPredRefLayerId ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i)); |
---|
379 | m_acTEncTop[layer].setMotionPredEnabledFlag (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true); |
---|
380 | } |
---|
381 | } |
---|
382 | Int numDirectRefLayers = 0; |
---|
383 | |
---|
384 | assert( layer < MAX_LAYERS ); |
---|
385 | |
---|
386 | for (Int i = 0; i < layer; i++) |
---|
387 | { |
---|
388 | if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i)) |
---|
389 | { |
---|
390 | m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i); |
---|
391 | numDirectRefLayers++; |
---|
392 | } |
---|
393 | } |
---|
394 | m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers); |
---|
395 | |
---|
396 | if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1) |
---|
397 | { |
---|
398 | m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() ); |
---|
399 | for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ ) |
---|
400 | { |
---|
401 | m_acTEncTop[layer].setPredLayerId(i, i); |
---|
402 | } |
---|
403 | } |
---|
404 | else |
---|
405 | { |
---|
406 | m_acTEncTop[layer].setNumActiveRefLayers ( m_acLayerCfg[layer].getNumActiveRefLayers() ); |
---|
407 | for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++) |
---|
408 | { |
---|
409 | m_acTEncTop[layer].setPredLayerId ( i, m_acLayerCfg[layer].getPredLayerId(i)); |
---|
410 | } |
---|
411 | } |
---|
412 | #if REF_REGION_OFFSET |
---|
413 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
414 | { |
---|
415 | #if AUXILIARY_PICTURES |
---|
416 | Int cf = m_acLayerCfg[i].m_chromaFormatIDC; |
---|
417 | Int rlSubWidthC = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1; |
---|
418 | Int rlSubHeightC = ( cf == CHROMA_420 ) ? 2 : 1; |
---|
419 | #else |
---|
420 | Int rlSubWidthC = 2; |
---|
421 | Int rlSubHeightC = 2; |
---|
422 | #endif |
---|
423 | m_acTEncTop[layer].setRefRegionOffsetPresentFlag( i, m_acLayerCfg[layer].m_refRegionOffsetPresentFlag ); |
---|
424 | m_acTEncTop[layer].getRefLayerWindow(i).setWindow( rlSubWidthC * m_acLayerCfg[layer].m_refRegionLeftOffset[i], rlSubWidthC * m_acLayerCfg[layer].m_refRegionRightOffset[i], |
---|
425 | rlSubHeightC * m_acLayerCfg[layer].m_refRegionTopOffset[i], rlSubHeightC * m_acLayerCfg[layer].m_refRegionBottomOffset[i]); |
---|
426 | } |
---|
427 | #endif |
---|
428 | } |
---|
429 | else |
---|
430 | { |
---|
431 | assert( layer == 0 ); |
---|
432 | m_acTEncTop[layer].setNumDirectRefLayers(0); |
---|
433 | } |
---|
434 | #endif //VPS_EXTN_DIRECT_REF_LAYERS |
---|
435 | //===== Slice ======== |
---|
436 | |
---|
437 | //====== Loop/Deblock Filter ======== |
---|
438 | m_acTEncTop[layer].setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
439 | m_acTEncTop[layer].setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
440 | m_acTEncTop[layer].setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
441 | m_acTEncTop[layer].setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
442 | m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
443 | m_acTEncTop[layer].setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
444 | |
---|
445 | //====== Motion search ======== |
---|
446 | m_acTEncTop[layer].setFastSearch ( m_iFastSearch ); |
---|
447 | m_acTEncTop[layer].setSearchRange ( m_iSearchRange ); |
---|
448 | m_acTEncTop[layer].setBipredSearchRange ( m_bipredSearchRange ); |
---|
449 | |
---|
450 | //====== Quality control ======== |
---|
451 | m_acTEncTop[layer].setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
452 | m_acTEncTop[layer].setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
453 | |
---|
454 | m_acTEncTop[layer].setChromaCbQpOffset ( m_cbQpOffset ); |
---|
455 | m_acTEncTop[layer].setChromaCrQpOffset ( m_crQpOffset ); |
---|
456 | |
---|
457 | #if ADAPTIVE_QP_SELECTION |
---|
458 | m_acTEncTop[layer].setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
459 | #endif |
---|
460 | |
---|
461 | m_acTEncTop[layer].setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
462 | m_acTEncTop[layer].setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
463 | |
---|
464 | //====== Tool list ======== |
---|
465 | m_acTEncTop[layer].setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
466 | m_acTEncTop[layer].setUseASR ( m_bUseASR ); |
---|
467 | m_acTEncTop[layer].setUseHADME ( m_bUseHADME ); |
---|
468 | m_acTEncTop[layer].setdQPs ( m_acLayerCfg[layer].getdQPs() ); |
---|
469 | m_acTEncTop[layer].setUseRDOQ ( m_useRDOQ ); |
---|
470 | m_acTEncTop[layer].setUseRDOQTS ( m_useRDOQTS ); |
---|
471 | m_acTEncTop[layer].setRDpenalty ( m_rdPenalty ); |
---|
472 | #if LAYER_CTB |
---|
473 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MaxSize ); |
---|
474 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_acLayerCfg[layer].m_uiQuadtreeTULog2MinSize ); |
---|
475 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthInter ); |
---|
476 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_acLayerCfg[layer].m_uiQuadtreeTUMaxDepthIntra ); |
---|
477 | #else |
---|
478 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
479 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
480 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
481 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
482 | #endif |
---|
483 | m_acTEncTop[layer].setUseFastEnc ( m_bUseFastEnc ); |
---|
484 | m_acTEncTop[layer].setUseEarlyCU ( m_bUseEarlyCU ); |
---|
485 | m_acTEncTop[layer].setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
486 | m_acTEncTop[layer].setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
487 | m_acTEncTop[layer].setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
488 | #if FAST_INTRA_SHVC |
---|
489 | m_acTEncTop[layer].setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
490 | #endif |
---|
491 | |
---|
492 | m_acTEncTop[layer].setUseTransformSkip ( m_useTransformSkip ); |
---|
493 | m_acTEncTop[layer].setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
494 | m_acTEncTop[layer].setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
495 | m_acTEncTop[layer].setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
496 | m_acTEncTop[layer].setUsePCM ( m_usePCM ); |
---|
497 | m_acTEncTop[layer].setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
498 | m_acTEncTop[layer].setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
499 | |
---|
500 | |
---|
501 | //====== Weighted Prediction ======== |
---|
502 | m_acTEncTop[layer].setUseWP ( m_useWeightedPred ); |
---|
503 | m_acTEncTop[layer].setWPBiPred ( m_useWeightedBiPred ); |
---|
504 | #if O0194_WEIGHTED_PREDICTION_CGS |
---|
505 | if( layer != 0 && m_useInterLayerWeightedPred ) |
---|
506 | { |
---|
507 | // Enable weighted prediction for enhancement layer |
---|
508 | m_acTEncTop[layer].setUseWP ( true ); |
---|
509 | m_acTEncTop[layer].setWPBiPred ( true ); |
---|
510 | } |
---|
511 | #endif |
---|
512 | //====== Parallel Merge Estimation ======== |
---|
513 | m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
514 | |
---|
515 | //====== Slice ======== |
---|
516 | m_acTEncTop[layer].setSliceMode ( m_sliceMode ); |
---|
517 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
518 | |
---|
519 | //====== Dependent Slice ======== |
---|
520 | m_acTEncTop[layer].setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
521 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
522 | #if LAYER_CTB |
---|
523 | Int iNumPartInCU = 1<<(m_acLayerCfg[layer].m_uiMaxCUDepth<<1); |
---|
524 | #else |
---|
525 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
526 | #endif |
---|
527 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
528 | { |
---|
529 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
530 | } |
---|
531 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
532 | { |
---|
533 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
534 | } |
---|
535 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
536 | { |
---|
537 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
538 | } |
---|
539 | |
---|
540 | if(m_sliceMode == 0 ) |
---|
541 | { |
---|
542 | m_bLFCrossSliceBoundaryFlag = true; |
---|
543 | } |
---|
544 | m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
545 | m_acTEncTop[layer].setUseSAO ( m_bUseSAO ); |
---|
546 | m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
547 | |
---|
548 | m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary); |
---|
549 | m_acTEncTop[layer].setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
550 | m_acTEncTop[layer].setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
551 | |
---|
552 | m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
553 | m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
554 | m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
555 | m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
556 | m_acTEncTop[layer].setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
557 | m_acTEncTop[layer].setTMISEIToneMapId ( m_toneMapId ); |
---|
558 | m_acTEncTop[layer].setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
559 | m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
560 | m_acTEncTop[layer].setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
561 | m_acTEncTop[layer].setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
562 | m_acTEncTop[layer].setTMISEIModelID ( m_toneMapModelId ); |
---|
563 | m_acTEncTop[layer].setTMISEIMinValue ( m_toneMapMinValue ); |
---|
564 | m_acTEncTop[layer].setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
565 | m_acTEncTop[layer].setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
566 | m_acTEncTop[layer].setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
567 | m_acTEncTop[layer].setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
568 | m_acTEncTop[layer].setTMISEINumPivots ( m_numPivots ); |
---|
569 | m_acTEncTop[layer].setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
570 | m_acTEncTop[layer].setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
571 | m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
572 | m_acTEncTop[layer].setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
573 | m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
574 | m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
575 | m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
576 | m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
577 | m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
578 | m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
579 | m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
580 | m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
581 | #if P0050_KNEE_FUNCTION_SEI |
---|
582 | m_acTEncTop[layer].setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
583 | m_acTEncTop[layer].setKneeSEIId ( m_kneeSEIId ); |
---|
584 | m_acTEncTop[layer].setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
585 | m_acTEncTop[layer].setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
586 | m_acTEncTop[layer].setKneeSEIMappingFlag ( m_kneeSEIMappingFlag ); |
---|
587 | m_acTEncTop[layer].setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
588 | m_acTEncTop[layer].setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
589 | m_acTEncTop[layer].setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
590 | m_acTEncTop[layer].setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
591 | m_acTEncTop[layer].setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
592 | m_acTEncTop[layer].setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
593 | m_acTEncTop[layer].setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
594 | #endif |
---|
595 | #if Q0096_OVERLAY_SEI |
---|
596 | m_acTEncTop[layer].setOverlaySEIEnabled ( m_overlaySEIEnabled ); |
---|
597 | m_acTEncTop[layer].setOverlaySEICancelFlag ( m_overlayInfoCancelFlag ); |
---|
598 | m_acTEncTop[layer].setOverlaySEIContentAuxIdMinus128 ( m_overlayContentAuxIdMinus128 ); |
---|
599 | m_acTEncTop[layer].setOverlaySEILabelAuxIdMinus128 ( m_overlayLabelAuxIdMinus128 ); |
---|
600 | m_acTEncTop[layer].setOverlaySEIAlphaAuxIdMinus128 ( m_overlayAlphaAuxIdMinus128 ); |
---|
601 | m_acTEncTop[layer].setOverlaySEIElementLabelValueLengthMinus8 ( m_overlayElementLabelValueLengthMinus8 ); |
---|
602 | m_acTEncTop[layer].setOverlaySEINumOverlaysMinus1 ( m_numOverlaysMinus1 ); |
---|
603 | m_acTEncTop[layer].setOverlaySEIIdx ( m_overlayIdx ); |
---|
604 | m_acTEncTop[layer].setOverlaySEILanguagePresentFlag ( m_overlayLanguagePresentFlag ); |
---|
605 | m_acTEncTop[layer].setOverlaySEIContentLayerId ( m_overlayContentLayerId ); |
---|
606 | m_acTEncTop[layer].setOverlaySEILabelPresentFlag ( m_overlayLabelPresentFlag ); |
---|
607 | m_acTEncTop[layer].setOverlaySEILabelLayerId ( m_overlayLabelLayerId ); |
---|
608 | m_acTEncTop[layer].setOverlaySEIAlphaPresentFlag ( m_overlayAlphaPresentFlag ); |
---|
609 | m_acTEncTop[layer].setOverlaySEIAlphaLayerId ( m_overlayAlphaLayerId ); |
---|
610 | m_acTEncTop[layer].setOverlaySEINumElementsMinus1 ( m_numOverlayElementsMinus1 ); |
---|
611 | m_acTEncTop[layer].setOverlaySEIElementLabelMin ( m_overlayElementLabelMin ); |
---|
612 | m_acTEncTop[layer].setOverlaySEIElementLabelMax ( m_overlayElementLabelMax ); |
---|
613 | m_acTEncTop[layer].setOverlaySEILanguage ( m_overlayLanguage ); |
---|
614 | m_acTEncTop[layer].setOverlaySEIName ( m_overlayName ); |
---|
615 | m_acTEncTop[layer].setOverlaySEIElementName ( m_overlayElementName ); |
---|
616 | m_acTEncTop[layer].setOverlaySEIPersistenceFlag ( m_overlayInfoPersistenceFlag ); |
---|
617 | #endif |
---|
618 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
619 | m_acTEncTop[layer].setCRISEIFile ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFile.c_str()) ); |
---|
620 | m_acTEncTop[layer].setCRISEIId ( m_acLayerCfg[layer].m_colourRemapSEIId ); |
---|
621 | m_acTEncTop[layer].setCRISEICancelFlag ( m_acLayerCfg[layer].m_colourRemapSEICancelFlag ); |
---|
622 | m_acTEncTop[layer].setCRISEIPersistenceFlag ( m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag ); |
---|
623 | m_acTEncTop[layer].setCRISEIVideoSignalInfoPresentFlag ( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag ); |
---|
624 | m_acTEncTop[layer].setCRISEIFullRangeFlag ( m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag ); |
---|
625 | m_acTEncTop[layer].setCRISEIPrimaries ( m_acLayerCfg[layer].m_colourRemapSEIPrimaries ); |
---|
626 | m_acTEncTop[layer].setCRISEITransferFunction ( m_acLayerCfg[layer].m_colourRemapSEITransferFunction ); |
---|
627 | m_acTEncTop[layer].setCRISEIMatrixCoefficients ( m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients ); |
---|
628 | m_acTEncTop[layer].setCRISEIInputBitDepth ( m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth ); |
---|
629 | m_acTEncTop[layer].setCRISEIBitDepth ( m_acLayerCfg[layer].m_colourRemapSEIBitDepth ); |
---|
630 | m_acTEncTop[layer].setCRISEIPreLutNumValMinus1 ( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1 ); |
---|
631 | m_acTEncTop[layer].setCRISEIPreLutCodedValue ( m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue ); |
---|
632 | m_acTEncTop[layer].setCRISEIPreLutTargetValue ( m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue ); |
---|
633 | m_acTEncTop[layer].setCRISEIMatrixPresentFlag ( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag ); |
---|
634 | m_acTEncTop[layer].setCRISEILog2MatrixDenom ( m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom ); |
---|
635 | m_acTEncTop[layer].setCRISEICoeffs ( m_acLayerCfg[layer].m_colourRemapSEICoeffs ); |
---|
636 | m_acTEncTop[layer].setCRISEIPostLutNumValMinus1 ( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1 ); |
---|
637 | m_acTEncTop[layer].setCRISEIPostLutCodedValue ( m_acLayerCfg[layer]. m_colourRemapSEIPostLutCodedValue ); |
---|
638 | m_acTEncTop[layer].setCRISEIPostLutTargetValue ( m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue ); |
---|
639 | #endif |
---|
640 | m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
641 | m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
642 | m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
643 | m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
644 | m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
645 | m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
646 | m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
647 | m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
648 | m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
649 | #if LAYERS_NOT_PRESENT_SEI |
---|
650 | m_acTEncTop[layer].setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled ); |
---|
651 | #endif |
---|
652 | m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
653 | m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
654 | #if Q0189_TMVP_CONSTRAINTS |
---|
655 | m_acTEncTop[layer].setTMVPConstraintsSEIEnabled( m_TMVPConstraintsSEIEnabled); |
---|
656 | #endif |
---|
657 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
658 | m_acTEncTop[layer].setInterLayerConstrainedTileSetsSEIEnabled( m_interLayerConstrainedTileSetsSEIEnabled ); |
---|
659 | m_acTEncTop[layer].setIlNumSetsInMessage( m_ilNumSetsInMessage ); |
---|
660 | m_acTEncTop[layer].setSkippedTileSetPresentFlag( m_skippedTileSetPresentFlag ); |
---|
661 | m_acTEncTop[layer].setTopLeftTileIndex( m_topLeftTileIndex ); |
---|
662 | m_acTEncTop[layer].setBottomRightTileIndex( m_bottomRightTileIndex ); |
---|
663 | m_acTEncTop[layer].setIlcIdc( m_ilcIdc ); |
---|
664 | #endif |
---|
665 | m_acTEncTop[layer].setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
666 | m_acTEncTop[layer].setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
667 | m_acTEncTop[layer].setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
668 | if(!m_tileUniformSpacingFlag) |
---|
669 | { |
---|
670 | m_acTEncTop[layer].setColumnWidth ( m_tileColumnWidth ); |
---|
671 | m_acTEncTop[layer].setRowHeight ( m_tileRowHeight ); |
---|
672 | } |
---|
673 | m_acTEncTop[layer].xCheckGSParameters(); |
---|
674 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
675 | if(uiTilesCount == 1) |
---|
676 | { |
---|
677 | m_bLFCrossTileBoundaryFlag = true; |
---|
678 | } |
---|
679 | m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
680 | m_acTEncTop[layer].setWaveFrontSynchro ( m_acLayerCfg[layer].m_waveFrontSynchro ); |
---|
681 | m_acTEncTop[layer].setWaveFrontSubstreams ( m_acLayerCfg[layer].m_iWaveFrontSubstreams ); |
---|
682 | m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId ); |
---|
683 | m_acTEncTop[layer].setUseScalingListId ( m_useScalingListId ); |
---|
684 | m_acTEncTop[layer].setScalingListFile ( m_scalingListFile ); |
---|
685 | m_acTEncTop[layer].setSignHideFlag(m_signHideFlag); |
---|
686 | #if RC_SHVC_HARMONIZATION |
---|
687 | m_acTEncTop[layer].setUseRateCtrl (m_acLayerCfg[layer].getRCEnableRateControl()); |
---|
688 | m_acTEncTop[layer].setTargetBitrate (m_acLayerCfg[layer].getRCTargetBitrate()); |
---|
689 | m_acTEncTop[layer].setKeepHierBit (m_acLayerCfg[layer].getRCKeepHierarchicalBit()); |
---|
690 | m_acTEncTop[layer].setLCULevelRC (m_acLayerCfg[layer].getRCLCULevelRC()); |
---|
691 | m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel()); |
---|
692 | m_acTEncTop[layer].setInitialQP (m_acLayerCfg[layer].getRCInitialQP()); |
---|
693 | m_acTEncTop[layer].setForceIntraQP (m_acLayerCfg[layer].getRCForceIntraQP()); |
---|
694 | #else |
---|
695 | m_acTEncTop[layer].setUseRateCtrl ( m_RCEnableRateControl ); |
---|
696 | m_acTEncTop[layer].setTargetBitrate ( m_RCTargetBitrate ); |
---|
697 | m_acTEncTop[layer].setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
698 | m_acTEncTop[layer].setLCULevelRC ( m_RCLCULevelRC ); |
---|
699 | m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
700 | m_acTEncTop[layer].setInitialQP ( m_RCInitialQP ); |
---|
701 | m_acTEncTop[layer].setForceIntraQP ( m_RCForceIntraQP ); |
---|
702 | #endif |
---|
703 | m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
704 | m_acTEncTop[layer].setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
705 | m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
706 | m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
707 | m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
708 | m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
709 | m_acTEncTop[layer].setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
710 | m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc ); |
---|
711 | m_acTEncTop[layer].setSarWidth( m_sarWidth ); |
---|
712 | m_acTEncTop[layer].setSarHeight( m_sarHeight ); |
---|
713 | m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
714 | m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
715 | m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
716 | m_acTEncTop[layer].setVideoFormat( m_videoFormat ); |
---|
717 | m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
718 | m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
719 | m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries ); |
---|
720 | m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics ); |
---|
721 | m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients ); |
---|
722 | m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
723 | m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
724 | m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
725 | m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
726 | m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
727 | m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
728 | m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
729 | m_acTEncTop[layer].setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
730 | m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
731 | m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
732 | m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
733 | m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
734 | m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
735 | m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
736 | m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
737 | m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
738 | m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled); |
---|
739 | if( layer > 0 ) |
---|
740 | { |
---|
741 | #if REF_REGION_OFFSET |
---|
742 | #if AUXILIARY_PICTURES |
---|
743 | Int cf = m_acLayerCfg[layer].m_chromaFormatIDC; |
---|
744 | Int subWidthC = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1; |
---|
745 | Int subHeightC = ( cf == CHROMA_420 ) ? 2 : 1; |
---|
746 | #else |
---|
747 | Int subWidthC = 2; |
---|
748 | Int subHeightC = 2; |
---|
749 | #endif |
---|
750 | #endif |
---|
751 | m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets ); |
---|
752 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
753 | { |
---|
754 | #if O0098_SCALED_REF_LAYER_ID |
---|
755 | m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]); |
---|
756 | #endif |
---|
757 | #if REF_REGION_OFFSET |
---|
758 | m_acTEncTop[layer].setScaledRefLayerOffsetPresentFlag( i, m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] ); |
---|
759 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( subWidthC * m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], subWidthC * m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
760 | subHeightC * m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], subHeightC * m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
761 | #else |
---|
762 | #if P0312_VERT_PHASE_ADJ |
---|
763 | m_acTEncTop[layer].setVertPhasePositionEnableFlag( i, m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); |
---|
764 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
765 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i], m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] ); |
---|
766 | #else |
---|
767 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
768 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
769 | #endif |
---|
770 | #endif |
---|
771 | #if R0209_GENERIC_PHASE |
---|
772 | m_acTEncTop[layer].setResamplePhaseSetPresentFlag( i, m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] ); |
---|
773 | m_acTEncTop[layer].setPhaseHorLuma( i, m_acLayerCfg[layer].m_phaseHorLuma[i] ); |
---|
774 | m_acTEncTop[layer].setPhaseVerLuma( i, m_acLayerCfg[layer].m_phaseVerLuma[i] ); |
---|
775 | m_acTEncTop[layer].setPhaseHorChroma( i, m_acLayerCfg[layer].m_phaseHorChroma[i] ); |
---|
776 | m_acTEncTop[layer].setPhaseVerChroma( i, m_acLayerCfg[layer].m_phaseVerChroma[i] ); |
---|
777 | #endif |
---|
778 | } |
---|
779 | } |
---|
780 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
781 | m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange ); |
---|
782 | #endif |
---|
783 | #if AUXILIARY_PICTURES |
---|
784 | m_acTEncTop[layer].setChromaFormatIDC( m_acLayerCfg[layer].m_chromaFormatIDC ); |
---|
785 | #endif |
---|
786 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
787 | m_acTEncTop[layer].setAltOuputLayerFlag( m_altOutputLayerFlag ); |
---|
788 | #endif |
---|
789 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
790 | m_acTEncTop[layer].setCrossLayerBLAFlag( m_crossLayerBLAFlag ); |
---|
791 | #endif |
---|
792 | #if Q0048_CGS_3D_ASYMLUT |
---|
793 | m_acTEncTop[layer].setCGSFlag( layer == 0 ? 0 : m_nCGSFlag ); |
---|
794 | m_acTEncTop[layer].setCGSMaxOctantDepth( m_nCGSMaxOctantDepth ); |
---|
795 | m_acTEncTop[layer].setCGSMaxYPartNumLog2( m_nCGSMaxYPartNumLog2 ); |
---|
796 | m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit ); |
---|
797 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
798 | m_acTEncTop[layer].setCGSAdaptChroma( m_nCGSAdaptiveChroma ); |
---|
799 | #endif |
---|
800 | #if R0179_ENC_OPT_3DLUT_SIZE |
---|
801 | m_acTEncTop[layer].setCGSLutSizeRDO( m_nCGSLutSizeRDO ); |
---|
802 | #endif |
---|
803 | #endif |
---|
804 | #if Q0078_ADD_LAYER_SETS |
---|
805 | m_acTEncTop[layer].setNumAddLayerSets( m_numAddLayerSets ); |
---|
806 | #endif |
---|
807 | } |
---|
808 | } |
---|
809 | #else //SVC_EXTENSION |
---|
810 | Void TAppEncTop::xInitLibCfg() |
---|
811 | { |
---|
812 | TComVPS vps; |
---|
813 | |
---|
814 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
815 | if (m_maxTempLayer == 1) |
---|
816 | { |
---|
817 | vps.setTemporalNestingFlag(true); |
---|
818 | } |
---|
819 | vps.setMaxLayers ( 1 ); |
---|
820 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
821 | { |
---|
822 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
823 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
824 | } |
---|
825 | m_cTEncTop.setVPS(&vps); |
---|
826 | |
---|
827 | m_cTEncTop.setProfile(m_profile); |
---|
828 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
829 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
830 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
831 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
832 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
833 | |
---|
834 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
835 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
836 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
837 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
838 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
839 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
840 | |
---|
841 | //====== Coding Structure ======== |
---|
842 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
843 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
844 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
845 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
846 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
847 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
848 | { |
---|
849 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
850 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
851 | } |
---|
852 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
853 | { |
---|
854 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
855 | } |
---|
856 | m_cTEncTop.setQP ( m_iQP ); |
---|
857 | |
---|
858 | m_cTEncTop.setPad ( m_aiPad ); |
---|
859 | |
---|
860 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
861 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
862 | |
---|
863 | //===== Slice ======== |
---|
864 | |
---|
865 | //====== Loop/Deblock Filter ======== |
---|
866 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
867 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
868 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
869 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
870 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
871 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
872 | |
---|
873 | //====== Motion search ======== |
---|
874 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
875 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
876 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
877 | |
---|
878 | //====== Quality control ======== |
---|
879 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
880 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
881 | |
---|
882 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
883 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
884 | |
---|
885 | #if ADAPTIVE_QP_SELECTION |
---|
886 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
887 | #endif |
---|
888 | |
---|
889 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
890 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
891 | |
---|
892 | //====== Tool list ======== |
---|
893 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
894 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
895 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
896 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
897 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
898 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
899 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
900 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
901 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
902 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
903 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
904 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
905 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
906 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
907 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
908 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
909 | #if FAST_INTRA_SHVC |
---|
910 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
911 | #endif |
---|
912 | |
---|
913 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
914 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
915 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
916 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
917 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
918 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
919 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
920 | |
---|
921 | |
---|
922 | //====== Weighted Prediction ======== |
---|
923 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
924 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
925 | //====== Parallel Merge Estimation ======== |
---|
926 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
927 | |
---|
928 | //====== Slice ======== |
---|
929 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
930 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
931 | |
---|
932 | //====== Dependent Slice ======== |
---|
933 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
934 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
935 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
936 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
937 | { |
---|
938 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
939 | } |
---|
940 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
941 | { |
---|
942 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
943 | } |
---|
944 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
945 | { |
---|
946 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
947 | } |
---|
948 | |
---|
949 | if(m_sliceMode == 0 ) |
---|
950 | { |
---|
951 | m_bLFCrossSliceBoundaryFlag = true; |
---|
952 | } |
---|
953 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
954 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
955 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
956 | |
---|
957 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
958 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
959 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
960 | |
---|
961 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
962 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
963 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
964 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
965 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
966 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
967 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
968 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
969 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
970 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
971 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
972 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
973 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
974 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
975 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
976 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
977 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
978 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
979 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
980 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
981 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
982 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
983 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
984 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
985 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
986 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
987 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
988 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
989 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
990 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
991 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
992 | #if P0050_KNEE_FUNCTION_SEI |
---|
993 | m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
994 | m_cTEncTop.setKneeSEIId ( m_kneeSEIId ); |
---|
995 | m_cTEncTop.setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
996 | m_cTEncTop.setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
997 | m_cTEncTop.setKneeSEIMappingFlag ( m_kneeSEIMappingFlag ); |
---|
998 | m_cTEncTop.setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
999 | m_cTEncTop.setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
1000 | m_cTEncTop.setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
1001 | m_cTEncTop.setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
1002 | m_cTEncTop.setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
1003 | m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
1004 | m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
1005 | #endif |
---|
1006 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
1007 | m_cTEncTop.setCRISEIFile ( const_cast<Char*>(m_colourRemapSEIFile.c_str()) ); |
---|
1008 | m_cTEncTop.setCRISEIId ( m_colourRemapSEIId ); |
---|
1009 | m_cTEncTop.setCRISEICancelFlag ( m_colourRemapSEICancelFlag ); |
---|
1010 | m_cTEncTop.setCRISEIPersistenceFlag ( m_colourRemapSEIPersistenceFlag ); |
---|
1011 | m_cTEncTop.setCRISEIVideoSignalInfoPresentFlag ( m_colourRemapSEIVideoSignalInfoPresentFlag ); |
---|
1012 | m_cTEncTop.setCRISEIFullRangeFlag ( m_colourRemapSEIFullRangeFlag ); |
---|
1013 | m_cTEncTop.setCRISEIPrimaries ( m_colourRemapSEIPrimaries ); |
---|
1014 | m_cTEncTop.setCRISEITransferFunction ( m_colourRemapSEITransferFunction ); |
---|
1015 | m_cTEncTop.setCRISEIMatrixCoefficients ( m_colourRemapSEIMatrixCoefficients ); |
---|
1016 | m_cTEncTop.setCRISEIInputBitDepth ( m_colourRemapSEIInputBitDepth ); |
---|
1017 | m_cTEncTop.setCRISEIBitDepth ( m_colourRemapSEIBitDepth ); |
---|
1018 | m_cTEncTop.setCRISEIPreLutNumValMinus1 ( m_colourRemapSEIPreLutNumValMinus1 ); |
---|
1019 | m_cTEncTop.setCRISEIPreLutCodedValue ( m_colourRemapSEIPreLutCodedValue ); |
---|
1020 | m_cTEncTop.setCRISEIPreLutTargetValue ( m_colourRemapSEIPreLutTargetValue ); |
---|
1021 | m_cTEncTop.setCRISEIMatrixPresentFlag ( m_colourRemapSEIMatrixPresentFlag ); |
---|
1022 | m_cTEncTop.setCRISEILog2MatrixDenom ( m_colourRemapSEILog2MatrixDenom ); |
---|
1023 | m_cTEncTop.setCRISEICoeffs ( m_colourRemapSEICoeffs ); |
---|
1024 | m_cTEncTop.setCRISEIPostLutNumValMinus1 ( m_colourRemapSEIPostLutNumValMinus1 ); |
---|
1025 | m_cTEncTop.setCRISEIPostLutCodedValue ( m_colourRemapSEIPostLutCodedValue ); |
---|
1026 | m_cTEncTop.setCRISEIPostLutTargetValue ( m_colourRemapSEIPostLutTargetValue ); |
---|
1027 | #endif |
---|
1028 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
1029 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
1030 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
1031 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
1032 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
1033 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
1034 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
1035 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
1036 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
1037 | #if LAYERS_NOT_PRESENT_SEI |
---|
1038 | m_cTEncTop.setLayersNotPresentSEIEnabled( m_layersNotPresentSEIEnabled ); |
---|
1039 | #endif |
---|
1040 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
1041 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
1042 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
1043 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
1044 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
1045 | if(!m_tileUniformSpacingFlag) |
---|
1046 | { |
---|
1047 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
1048 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
1049 | } |
---|
1050 | m_cTEncTop.xCheckGSParameters(); |
---|
1051 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
1052 | if(uiTilesCount == 1) |
---|
1053 | { |
---|
1054 | m_bLFCrossTileBoundaryFlag = true; |
---|
1055 | } |
---|
1056 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
1057 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
1058 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
1059 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
1060 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
1061 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
1062 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
1063 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
1064 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
1065 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
1066 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
1067 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
1068 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
1069 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
1070 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
1071 | m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce); |
---|
1072 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
1073 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
1074 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
1075 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
1076 | m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag); |
---|
1077 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
1078 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
1079 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
1080 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
1081 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
1082 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
1083 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
1084 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
1085 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
1086 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
1087 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
1088 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
1089 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
1090 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
1091 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
1092 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
1093 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
1094 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
1095 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
1096 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
1097 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
1098 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
1099 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
1100 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
1101 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
1102 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
1103 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
1104 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
1105 | } |
---|
1106 | #endif //SVC_EXTENSION |
---|
1107 | |
---|
1108 | Void TAppEncTop::xCreateLib() |
---|
1109 | { |
---|
1110 | // Video I/O |
---|
1111 | #if SVC_EXTENSION |
---|
1112 | // initialize global variables |
---|
1113 | initROM(); |
---|
1114 | |
---|
1115 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1116 | { |
---|
1117 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1118 | //2 |
---|
1119 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1120 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1121 | |
---|
1122 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1123 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1124 | #endif |
---|
1125 | #if LAYER_CTB |
---|
1126 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
1127 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
1128 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
1129 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
1130 | #endif |
---|
1131 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1132 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_acLayerCfg[layer].m_inputBitDepthY, m_acLayerCfg[layer].m_inputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC ); // read mode |
---|
1133 | #else |
---|
1134 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
1135 | #endif |
---|
1136 | m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]); |
---|
1137 | |
---|
1138 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
1139 | { |
---|
1140 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1141 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_acLayerCfg[layer].m_outputBitDepthY, m_acLayerCfg[layer].m_outputBitDepthC, m_acLayerCfg[layer].m_internalBitDepthY, m_acLayerCfg[layer].m_internalBitDepthC ); // write mode |
---|
1142 | #else |
---|
1143 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // write mode |
---|
1144 | #endif |
---|
1145 | } |
---|
1146 | |
---|
1147 | m_acTEncTop[layer].create(); |
---|
1148 | } |
---|
1149 | #else //SVC_EXTENSION |
---|
1150 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
1151 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
1152 | |
---|
1153 | if (m_pchReconFile) |
---|
1154 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
1155 | |
---|
1156 | // Neo Decoder |
---|
1157 | m_cTEncTop.create(); |
---|
1158 | #endif //SVC_EXTENSION |
---|
1159 | } |
---|
1160 | |
---|
1161 | Void TAppEncTop::xDestroyLib() |
---|
1162 | { |
---|
1163 | // Video I/O |
---|
1164 | #if SVC_EXTENSION |
---|
1165 | // destroy ROM |
---|
1166 | destroyROM(); |
---|
1167 | |
---|
1168 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1169 | { |
---|
1170 | #if LAYER_CTB |
---|
1171 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
1172 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
1173 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
1174 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
1175 | #endif |
---|
1176 | |
---|
1177 | m_acTVideoIOYuvInputFile[layer].close(); |
---|
1178 | m_acTVideoIOYuvReconFile[layer].close(); |
---|
1179 | |
---|
1180 | m_acTEncTop[layer].destroy(); |
---|
1181 | } |
---|
1182 | #else //SVC_EXTENSION |
---|
1183 | m_cTVideoIOYuvInputFile.close(); |
---|
1184 | m_cTVideoIOYuvReconFile.close(); |
---|
1185 | |
---|
1186 | // Neo Decoder |
---|
1187 | m_cTEncTop.destroy(); |
---|
1188 | #endif //SVC_EXTENSION |
---|
1189 | } |
---|
1190 | |
---|
1191 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
1192 | { |
---|
1193 | #if SVC_EXTENSION |
---|
1194 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1195 | { |
---|
1196 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1197 | //3 |
---|
1198 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1199 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1200 | |
---|
1201 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1202 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1203 | #endif |
---|
1204 | #if LAYER_CTB |
---|
1205 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
1206 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
1207 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
1208 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
1209 | |
---|
1210 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
1211 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
1212 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
1213 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
1214 | #endif |
---|
1215 | m_acTEncTop[layer].init(isFieldCoding); |
---|
1216 | #if P0182_VPS_VUI_PS_FLAG |
---|
1217 | m_acTEncTop[layer].getVPS()->setSPSId(layer, m_acTEncTop[layer].getSPS()->getSPSId()); |
---|
1218 | m_acTEncTop[layer].getVPS()->setPPSId(layer, m_acTEncTop[layer].getPPS()->getPPSId()); |
---|
1219 | #endif |
---|
1220 | } |
---|
1221 | m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers ); |
---|
1222 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1223 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
1224 | vps->setMaxLayerId(m_numLayers - 1); // Set max-layer ID |
---|
1225 | |
---|
1226 | vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false ); |
---|
1227 | |
---|
1228 | #if Q0078_ADD_LAYER_SETS |
---|
1229 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
1230 | if (m_numLayerSets > 1) |
---|
1231 | { |
---|
1232 | vps->setNumLayerSets(m_numLayerSets); |
---|
1233 | #else |
---|
1234 | if (m_numLayerSets > 0) |
---|
1235 | { |
---|
1236 | vps->setNumLayerSets(m_numLayerSets+1); |
---|
1237 | #endif |
---|
1238 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
1239 | { |
---|
1240 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
1241 | { |
---|
1242 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
1243 | } |
---|
1244 | } |
---|
1245 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
1246 | { |
---|
1247 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
1248 | for (Int i = 0; i < m_numLayerInIdList[setId]; i++) |
---|
1249 | { |
---|
1250 | Int layerId = m_layerSetLayerIdList[setId][i]; |
---|
1251 | #else |
---|
1252 | for (Int i = 0; i < m_numLayerInIdList[setId-1]; i++) |
---|
1253 | { |
---|
1254 | Int layerId = m_layerSetLayerIdList[setId-1][i]; |
---|
1255 | #endif |
---|
1256 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1257 | //4 |
---|
1258 | g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
1259 | g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
1260 | |
---|
1261 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
1262 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
1263 | #endif |
---|
1264 | |
---|
1265 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
1266 | } |
---|
1267 | } |
---|
1268 | } |
---|
1269 | else |
---|
1270 | { |
---|
1271 | // Default layer sets |
---|
1272 | #endif |
---|
1273 | vps->setNumLayerSets(m_numLayers); |
---|
1274 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
1275 | { |
---|
1276 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
1277 | { |
---|
1278 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1279 | //4 |
---|
1280 | g_bitDepthY = m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
1281 | g_bitDepthC = m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
1282 | |
---|
1283 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthY : m_acLayerCfg[layerId].m_internalBitDepthY; |
---|
1284 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layerId].m_inputBitDepthC : m_acLayerCfg[layerId].m_internalBitDepthC; |
---|
1285 | #endif |
---|
1286 | if (layerId <= setId) |
---|
1287 | { |
---|
1288 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
1289 | } |
---|
1290 | else |
---|
1291 | { |
---|
1292 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
1293 | } |
---|
1294 | } |
---|
1295 | } |
---|
1296 | #if Q0078_ADD_LAYER_SETS |
---|
1297 | } |
---|
1298 | #endif |
---|
1299 | #if Q0078_ADD_LAYER_SETS |
---|
1300 | vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1); |
---|
1301 | vps->setNumAddLayerSets(m_numAddLayerSets); |
---|
1302 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
1303 | if (m_numAddLayerSets > 0) |
---|
1304 | { |
---|
1305 | for (Int setId = 0; setId < m_numAddLayerSets; setId++) |
---|
1306 | { |
---|
1307 | for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++) |
---|
1308 | { |
---|
1309 | vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1); |
---|
1310 | } |
---|
1311 | } |
---|
1312 | } |
---|
1313 | #endif |
---|
1314 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
1315 | UInt i = 0, dimIdLen = 0; |
---|
1316 | #if AVC_BASE |
---|
1317 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
1318 | vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag ); |
---|
1319 | if ( m_nonHEVCBaseLayerFlag ) |
---|
1320 | { |
---|
1321 | vps->setBaseLayerInternalFlag (false); |
---|
1322 | } |
---|
1323 | #else |
---|
1324 | vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag); |
---|
1325 | #endif |
---|
1326 | #else |
---|
1327 | vps->setAvcBaseLayerFlag(false); |
---|
1328 | #endif |
---|
1329 | vps->setSplittingFlag(false); |
---|
1330 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1331 | { |
---|
1332 | vps->setScalabilityMask(i, false); |
---|
1333 | } |
---|
1334 | if(m_numLayers > 1) |
---|
1335 | { |
---|
1336 | Int scalabilityTypes = 0; |
---|
1337 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1338 | { |
---|
1339 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
1340 | scalabilityTypes += m_scalabilityMask[i]; |
---|
1341 | } |
---|
1342 | #if AUXILIARY_PICTURES |
---|
1343 | assert( scalabilityTypes <= 2 ); |
---|
1344 | #else |
---|
1345 | assert( scalabilityTypes == 1 ); |
---|
1346 | #endif |
---|
1347 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
1348 | } |
---|
1349 | else |
---|
1350 | { |
---|
1351 | vps->setNumScalabilityTypes(0); |
---|
1352 | } |
---|
1353 | while((1 << dimIdLen) < m_numLayers) |
---|
1354 | { |
---|
1355 | dimIdLen++; |
---|
1356 | } |
---|
1357 | vps->setDimensionIdLen(0, dimIdLen); |
---|
1358 | vps->setNuhLayerIdPresentFlag(false); |
---|
1359 | vps->setLayerIdInNuh(0, 0); |
---|
1360 | vps->setLayerIdInVps(0, 0); |
---|
1361 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1362 | { |
---|
1363 | vps->setLayerIdInNuh(i, i); |
---|
1364 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
1365 | vps->setDimensionId(i, 0, i); |
---|
1366 | } |
---|
1367 | #if AUXILIARY_PICTURES |
---|
1368 | if (m_scalabilityMask[3]) |
---|
1369 | { |
---|
1370 | UInt maxAuxId = 0; |
---|
1371 | UInt auxDimIdLen = 1; |
---|
1372 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1373 | { |
---|
1374 | if (m_acLayerCfg[i].getAuxId() > maxAuxId) |
---|
1375 | { |
---|
1376 | maxAuxId = m_acLayerCfg[i].getAuxId(); |
---|
1377 | } |
---|
1378 | } |
---|
1379 | while((1 << auxDimIdLen) < (maxAuxId + 1)) |
---|
1380 | { |
---|
1381 | auxDimIdLen++; |
---|
1382 | } |
---|
1383 | vps->setDimensionIdLen(1, auxDimIdLen); |
---|
1384 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1385 | { |
---|
1386 | vps->setDimensionId(i, 1, m_acLayerCfg[i].getAuxId()); |
---|
1387 | } |
---|
1388 | } |
---|
1389 | #endif |
---|
1390 | #endif |
---|
1391 | #if VPS_TSLAYERS |
---|
1392 | vps->setMaxTSLayersPresentFlag(true); |
---|
1393 | |
---|
1394 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
---|
1395 | { |
---|
1396 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
1397 | } |
---|
1398 | #endif |
---|
1399 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
1400 | if (vps->getMaxTidRefPresentFlag()) |
---|
1401 | { |
---|
1402 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1403 | { |
---|
1404 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
1405 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1406 | { |
---|
1407 | vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
1408 | } |
---|
1409 | #else |
---|
1410 | vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
1411 | #endif |
---|
1412 | } |
---|
1413 | } |
---|
1414 | else |
---|
1415 | { |
---|
1416 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1417 | { |
---|
1418 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
1419 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1420 | { |
---|
1421 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
1422 | } |
---|
1423 | #else |
---|
1424 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
1425 | #endif |
---|
1426 | } |
---|
1427 | } |
---|
1428 | vps->setIlpSshSignalingEnabledFlag(false); |
---|
1429 | #if VPS_EXTN_PROFILE_INFO |
---|
1430 | #if !MULTIPLE_PTL_SUPPORT |
---|
1431 | #if LIST_OF_PTL |
---|
1432 | vps->getPTLForExtnPtr()->resize(1); // Dummy object - unused. |
---|
1433 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
1434 | { |
---|
1435 | // TODO: The profile tier level have to be given support to be included in the configuration files |
---|
1436 | if(i == 0) |
---|
1437 | { |
---|
1438 | if( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ) |
---|
1439 | { |
---|
1440 | vps->setProfilePresentFlag(1, false); |
---|
1441 | vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) ); |
---|
1442 | } |
---|
1443 | } |
---|
1444 | else // i > 0 |
---|
1445 | { |
---|
1446 | vps->setProfilePresentFlag(i, true); |
---|
1447 | // Note - may need to be changed for other layer structures. |
---|
1448 | vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) ); |
---|
1449 | } |
---|
1450 | } |
---|
1451 | #else |
---|
1452 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
1453 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
1454 | { |
---|
1455 | vps->setProfilePresentFlag(setId, true); |
---|
1456 | // Note - may need to be changed for other layer structures. |
---|
1457 | *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL()); |
---|
1458 | } |
---|
1459 | #endif |
---|
1460 | #endif |
---|
1461 | #endif |
---|
1462 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1463 | // Direct reference layers |
---|
1464 | UInt maxDirectRefLayers = 0; |
---|
1465 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
1466 | Bool isDefaultDirectDependencyTypeSet = false; |
---|
1467 | #endif |
---|
1468 | for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1469 | { |
---|
1470 | vps->setNumDirectRefLayers(layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers()); |
---|
1471 | maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerCtr)); |
---|
1472 | |
---|
1473 | for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
1474 | { |
---|
1475 | vps->setRefLayerId(layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i)); |
---|
1476 | } |
---|
1477 | // Set direct dependency flag |
---|
1478 | // Initialize flag to 0 |
---|
1479 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1480 | { |
---|
1481 | vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false); |
---|
1482 | } |
---|
1483 | for (i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
1484 | { |
---|
1485 | vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true); |
---|
1486 | } |
---|
1487 | // prediction indications |
---|
1488 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
1489 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1490 | { |
---|
1491 | if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr)) |
---|
1492 | { |
---|
1493 | assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr)); |
---|
1494 | vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) | |
---|
1495 | (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1); |
---|
1496 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
1497 | if (!isDefaultDirectDependencyTypeSet) |
---|
1498 | { |
---|
1499 | vps->setDefaultDirectDependecyTypeFlag(1); |
---|
1500 | vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr)); |
---|
1501 | isDefaultDirectDependencyTypeSet = true; |
---|
1502 | } |
---|
1503 | else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType()) |
---|
1504 | { |
---|
1505 | vps->setDefaultDirectDependecyTypeFlag(0); |
---|
1506 | } |
---|
1507 | #endif |
---|
1508 | } |
---|
1509 | else |
---|
1510 | { |
---|
1511 | vps->setDirectDependencyType(layerCtr, refLayerCtr, 0); |
---|
1512 | } |
---|
1513 | } |
---|
1514 | } |
---|
1515 | |
---|
1516 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
1517 | vps->setNumRefLayers(); |
---|
1518 | |
---|
1519 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
1520 | { |
---|
1521 | for (UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1522 | { |
---|
1523 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS); |
---|
1524 | } |
---|
1525 | } |
---|
1526 | #endif |
---|
1527 | #if FIX_LAYER_ID_INIT |
---|
1528 | // The Layer ID List variables should be derived here. |
---|
1529 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
1530 | vps->deriveLayerIdListVariables(); |
---|
1531 | #endif |
---|
1532 | #endif |
---|
1533 | #if Q0078_ADD_LAYER_SETS |
---|
1534 | vps->setPredictedLayerIds(); |
---|
1535 | vps->setTreePartitionLayerIdList(); |
---|
1536 | #if FIX_LAYER_ID_INIT |
---|
1537 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
1538 | #else |
---|
1539 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
1540 | #endif |
---|
1541 | #endif |
---|
1542 | #endif |
---|
1543 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
1544 | |
---|
1545 | vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file |
---|
1546 | |
---|
1547 | if( m_numOutputLayerSets == -1 ) // # of output layer sets not specified in the configuration file |
---|
1548 | { |
---|
1549 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
1550 | |
---|
1551 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
1552 | { |
---|
1553 | vps->setOutputLayerSetIdx(i, i); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | vps->setNumOutputLayerSets( m_numOutputLayerSets ); |
---|
1559 | for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets |
---|
1560 | { |
---|
1561 | vps->setOutputLayerSetIdx(olsCtr, olsCtr); |
---|
1562 | } |
---|
1563 | for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ ) // Non-default output layer sets |
---|
1564 | { |
---|
1565 | vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]); |
---|
1566 | } |
---|
1567 | } |
---|
1568 | #endif |
---|
1569 | // Target output layer |
---|
1570 | #if !MULTIPLE_PTL_SUPPORT |
---|
1571 | #if LIST_OF_PTL |
---|
1572 | vps->setNumProfileTierLevel( vps->getPTLForExtnPtr()->size() ); // +1 for the base VPS PTL() |
---|
1573 | #else |
---|
1574 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
1575 | vps->setNumProfileTierLevel(vps->getNumLayerSets()); |
---|
1576 | #endif |
---|
1577 | #endif |
---|
1578 | #if !OUTPUT_LAYER_SETS_CONFIG // Taken care by configuration file parameter |
---|
1579 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
1580 | vps->setDefaultTargetOutputLayerIdc(1); |
---|
1581 | #else |
---|
1582 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
1583 | vps->setDefaultOneTargetOutputLayerIdc(1); |
---|
1584 | #else |
---|
1585 | vps->setDefaultOneTargetOutputLayerFlag(true); |
---|
1586 | #endif |
---|
1587 | #endif |
---|
1588 | #endif |
---|
1589 | #if !PER_LAYER_PTL |
---|
1590 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
1591 | { |
---|
1592 | vps->setProfileLevelTierIdx(i, i); |
---|
1593 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
1594 | vps->setOutputLayerSetIdx(i, i); |
---|
1595 | #endif |
---|
1596 | } |
---|
1597 | #endif |
---|
1598 | #endif |
---|
1599 | #if VPS_DPB_SIZE_TABLE |
---|
1600 | #if !FIX_LAYER_ID_INIT // must be derived earlier to not delete additional layer sets |
---|
1601 | // The Layer ID List variables can be derived here. |
---|
1602 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
1603 | vps->deriveLayerIdListVariables(); |
---|
1604 | #endif |
---|
1605 | #endif |
---|
1606 | #if RESOLUTION_BASED_DPB |
---|
1607 | vps->assignSubDpbIndices(); |
---|
1608 | #else |
---|
1609 | vps->deriveNumberOfSubDpbs(); |
---|
1610 | #endif |
---|
1611 | vps->setOutputLayerFlag( 0, 0, 1 ); |
---|
1612 | // derive OutputLayerFlag[i][j] |
---|
1613 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
1614 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
1615 | #endif |
---|
1616 | { |
---|
1617 | // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and |
---|
1618 | // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set. |
---|
1619 | |
---|
1620 | // Include the highest layer as output layer for each layer set |
---|
1621 | for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++) |
---|
1622 | { |
---|
1623 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ ) |
---|
1624 | { |
---|
1625 | #if !Q0078_ADD_LAYER_SETS // the following condition is incorrect and is not needed anyway |
---|
1626 | if( vps->getLayerIdIncludedFlag(lsIdx, layer) ) |
---|
1627 | #endif |
---|
1628 | { |
---|
1629 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
1630 | switch(vps->getDefaultTargetOutputLayerIdc()) |
---|
1631 | { |
---|
1632 | case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 ); |
---|
1633 | break; |
---|
1634 | case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
1635 | break; |
---|
1636 | case 2: |
---|
1637 | case 3: vps->setOutputLayerFlag( lsIdx, layer, std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), layer) != m_listOfOutputLayers[lsIdx].end() ); |
---|
1638 | break; |
---|
1639 | } |
---|
1640 | #else |
---|
1641 | vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
1642 | #endif |
---|
1643 | } |
---|
1644 | } |
---|
1645 | } |
---|
1646 | #if OUTPUT_LAYER_SETS_CONFIG |
---|
1647 | for( Int olsIdx = vps->getNumLayerSets(); olsIdx < vps->getNumOutputLayerSets(); olsIdx++ ) |
---|
1648 | { |
---|
1649 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ ) |
---|
1650 | { |
---|
1651 | vps->setOutputLayerFlag( olsIdx, layer, std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), layer) != m_listOfOutputLayers[olsIdx].end()); |
---|
1652 | } |
---|
1653 | } |
---|
1654 | #endif |
---|
1655 | } |
---|
1656 | #if !OUTPUT_LAYER_SETS_CONFIG |
---|
1657 | else |
---|
1658 | { |
---|
1659 | // cases when default_output_layer_idc is not equal to 1 |
---|
1660 | assert(!"default_output_layer_idc not equal to 1 is not yet supported"); |
---|
1661 | } |
---|
1662 | #endif |
---|
1663 | #if NECESSARY_LAYER_FLAG |
---|
1664 | vps->deriveNecessaryLayerFlag(); |
---|
1665 | vps->checkNecessaryLayerFlagCondition(); |
---|
1666 | #endif |
---|
1667 | #if !MULTIPLE_PTL_SUPPORT |
---|
1668 | #if PER_LAYER_PTL |
---|
1669 | vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets()); |
---|
1670 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0 ); // Default 0-th output layer set |
---|
1671 | for(i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
1672 | { |
---|
1673 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
1674 | Int numLayerInLayerSet = vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); |
---|
1675 | for(Int j = 0; j < numLayerInLayerSet; j++) |
---|
1676 | { |
---|
1677 | Int layerIdxInVps = vps->getLayerIdInVps( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) ); |
---|
1678 | if( vps->getNecessaryLayerFlag(i, j) ) |
---|
1679 | { |
---|
1680 | vps->getProfileLevelTierIdx(i)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? layerIdxInVps + 1 : layerIdxInVps); |
---|
1681 | } |
---|
1682 | else |
---|
1683 | { |
---|
1684 | vps->getProfileLevelTierIdx(i)->push_back( -1 ); |
---|
1685 | } |
---|
1686 | } |
---|
1687 | } |
---|
1688 | #endif |
---|
1689 | #endif |
---|
1690 | #if SUB_LAYERS_IN_LAYER_SET |
---|
1691 | vps->calculateMaxSLInLayerSets(); |
---|
1692 | #endif |
---|
1693 | // Initialize dpb_size_table() for all ouput layer sets in the VPS extension |
---|
1694 | for(i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
1695 | { |
---|
1696 | #if CHANGE_NUMSUBDPB_IDX |
---|
1697 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
1698 | #endif |
---|
1699 | Int layerSetId = vps->getOutputLayerSetIdx(i); |
---|
1700 | |
---|
1701 | for(Int j = 0; j < vps->getMaxTLayers(); j++) |
---|
1702 | { |
---|
1703 | |
---|
1704 | Int maxNumReorderPics = -1; |
---|
1705 | #if CHANGE_NUMSUBDPB_IDX |
---|
1706 | #if RESOLUTION_BASED_DPB |
---|
1707 | for(Int k = 0; k < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); k++) |
---|
1708 | #else |
---|
1709 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
1710 | #endif |
---|
1711 | #else |
---|
1712 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
1713 | #endif |
---|
1714 | { |
---|
1715 | Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set |
---|
1716 | #if RESOLUTION_BASED_DPB |
---|
1717 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 ); |
---|
1718 | // Add sub-DPB sizes of layers belonging to a sub-DPB. If a different sub-DPB size is calculated |
---|
1719 | // at the encoder, modify below |
---|
1720 | Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); |
---|
1721 | oldValue += vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j ) + 1; |
---|
1722 | vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue ); |
---|
1723 | #else |
---|
1724 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, m_acTEncTop[layerId].getMaxDecPicBuffering(j) - 1 ); |
---|
1725 | #endif |
---|
1726 | maxNumReorderPics = std::max( maxNumReorderPics, m_acTEncTop[layerId].getNumReorderPics(j)); |
---|
1727 | } |
---|
1728 | #if RESOLUTION_BASED_DPB |
---|
1729 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
1730 | { |
---|
1731 | // Decrement m_maxVpsDecPicBufferingMinus1 |
---|
1732 | Int oldValue = vps->getMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j ); |
---|
1733 | vps->setMaxVpsDecPicBufferingMinus1( i, vps->getSubDpbAssigned( layerSetIdxForOutputLayerSet, k ), j, oldValue - 1 ); |
---|
1734 | } |
---|
1735 | #endif |
---|
1736 | vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); |
---|
1737 | vps->determineSubDpbInfoFlags(); |
---|
1738 | } |
---|
1739 | } |
---|
1740 | #endif |
---|
1741 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
1742 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
1743 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
1744 | { |
---|
1745 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
1746 | { |
---|
1747 | #if Q0078_ADD_LAYER_SETS |
---|
1748 | vps->setPocLsbNotPresentFlag(i, true); // make independedent layers base-layer compliant |
---|
1749 | #else |
---|
1750 | vps->setPocLsbNotPresentFlag(i, false); |
---|
1751 | #endif |
---|
1752 | } |
---|
1753 | } |
---|
1754 | #endif |
---|
1755 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
1756 | vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); |
---|
1757 | #endif |
---|
1758 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
1759 | vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); |
---|
1760 | #endif |
---|
1761 | vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); |
---|
1762 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1763 | { |
---|
1764 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1765 | { |
---|
1766 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
1767 | { |
---|
1768 | if(m_acTEncTop[layerCtr].getIntraPeriod() != m_acTEncTop[refLayerCtr].getIntraPeriod()) |
---|
1769 | { |
---|
1770 | vps->setCrossLayerIrapAlignFlag(false); |
---|
1771 | break; |
---|
1772 | } |
---|
1773 | } |
---|
1774 | } |
---|
1775 | } |
---|
1776 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1777 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
1778 | #endif |
---|
1779 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
1780 | vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch); |
---|
1781 | #endif |
---|
1782 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
---|
1783 | #if !VPS_EXTN_OFFSET_CALC |
---|
1784 | #if VPS_EXTN_OFFSET |
---|
1785 | // to be updated according to the current semantics |
---|
1786 | vps->setExtensionOffset( 0xffff ); |
---|
1787 | #endif |
---|
1788 | #endif |
---|
1789 | #endif |
---|
1790 | |
---|
1791 | #if O0215_PHASE_ALIGNMENT |
---|
1792 | vps->setPhaseAlignFlag( m_phaseAlignFlag ); |
---|
1793 | #endif |
---|
1794 | |
---|
1795 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
1796 | for (Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++) |
---|
1797 | { |
---|
1798 | vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); |
---|
1799 | } |
---|
1800 | #else |
---|
1801 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
1802 | vps->setAltOuputLayerFlag( m_altOutputLayerFlag ); |
---|
1803 | #endif |
---|
1804 | #endif |
---|
1805 | |
---|
1806 | #if P0312_VERT_PHASE_ADJ |
---|
1807 | Bool vpsVuiVertPhaseInUseFlag = false; |
---|
1808 | for( UInt layerId = 1; layerId < m_numLayers; layerId++ ) |
---|
1809 | { |
---|
1810 | for( i = 0; i < m_acLayerCfg[layerId].m_numScaledRefLayerOffsets; i++ ) |
---|
1811 | { |
---|
1812 | if( m_acTEncTop[layerId].getVertPhasePositionEnableFlag(i) ) |
---|
1813 | { |
---|
1814 | vpsVuiVertPhaseInUseFlag = true; |
---|
1815 | break; |
---|
1816 | } |
---|
1817 | } |
---|
1818 | } |
---|
1819 | vps->setVpsVuiVertPhaseInUseFlag( vpsVuiVertPhaseInUseFlag ); |
---|
1820 | #endif |
---|
1821 | |
---|
1822 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
1823 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
1824 | TEncTop *pcCfg = &m_acTEncTop[0]; |
---|
1825 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
1826 | { |
---|
1827 | Int j; |
---|
1828 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
1829 | vps->setVpsNumAddHrdParams( vps->getMaxLayers() ); |
---|
1830 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1); |
---|
1831 | for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) |
---|
1832 | { |
---|
1833 | vps->setCprmsAddPresentFlag( j, true ); |
---|
1834 | vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 ); |
---|
1835 | |
---|
1836 | UInt layerId = j; |
---|
1837 | TEncTop *pcCfgLayer = &m_acTEncTop[layerId]; |
---|
1838 | |
---|
1839 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
1840 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
1841 | #if LAYER_CTB |
---|
1842 | UInt uiWidthInCU = ( iPicWidth % m_acLayerCfg[layerId].m_uiMaxCUWidth ) ? iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth + 1 : iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth; |
---|
1843 | UInt uiHeightInCU = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight; |
---|
1844 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1); |
---|
1845 | #else |
---|
1846 | UInt uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
1847 | UInt uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
1848 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1); |
---|
1849 | #endif |
---|
1850 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
1851 | |
---|
1852 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
1853 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
1854 | { |
---|
1855 | numDU ++; |
---|
1856 | } |
---|
1857 | vps->getBspHrd(i)->setNumDU( numDU ); |
---|
1858 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
1859 | } |
---|
1860 | |
---|
1861 | // Signalling of additional partitioning schemes |
---|
1862 | for(Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
---|
1863 | { |
---|
1864 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
---|
1865 | vps->setNumSignalledPartitioningSchemes(h, 1); // Only the default per-layer partitioning scheme |
---|
1866 | for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
---|
1867 | { |
---|
1868 | // ToDo: Add code for additional partitioning schemes here |
---|
1869 | // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag |
---|
1870 | } |
---|
1871 | |
---|
1872 | for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ ) |
---|
1873 | { |
---|
1874 | if( i == 0 ) |
---|
1875 | { |
---|
1876 | for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++) |
---|
1877 | { |
---|
1878 | vps->setNumBspSchedulesMinus1( h, i, t, 0 ); |
---|
1879 | for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
---|
1880 | { |
---|
1881 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
1882 | { |
---|
1883 | // Only for the default partition |
---|
1884 | Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k); |
---|
1885 | Int layerIdxInVps = vps->getLayerIdInVps( nuhlayerId ); |
---|
1886 | vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters()); |
---|
1887 | |
---|
1888 | vps->setBspSchedIdx(h, i, t, j, k, 0); |
---|
1889 | } |
---|
1890 | } |
---|
1891 | } |
---|
1892 | } |
---|
1893 | else |
---|
1894 | { |
---|
1895 | assert(0); // Need to add support for additional partitioning schemes. |
---|
1896 | } |
---|
1897 | } |
---|
1898 | } |
---|
1899 | } |
---|
1900 | #else |
---|
1901 | |
---|
1902 | #if O0164_MULTI_LAYER_HRD |
---|
1903 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
1904 | TEncTop *pcCfg = &m_acTEncTop[0]; |
---|
1905 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
1906 | { |
---|
1907 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
1908 | #if Q0078_ADD_LAYER_SETS |
---|
1909 | vps->setVpsNumBspHrdParametersMinus1(vps->getVpsNumLayerSetsMinus1() - 1); |
---|
1910 | #else |
---|
1911 | vps->setVpsNumBspHrdParametersMinus1(vps->getNumLayerSets() - 2); |
---|
1912 | #endif |
---|
1913 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
1914 | for ( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
1915 | { |
---|
1916 | vps->setBspCprmsPresentFlag(i, true); |
---|
1917 | |
---|
1918 | UInt layerId = i + 1; |
---|
1919 | TEncTop *pcCfgLayer = &m_acTEncTop[layerId]; |
---|
1920 | |
---|
1921 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
1922 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
1923 | #if LAYER_CTB |
---|
1924 | UInt uiWidthInCU = ( iPicWidth % m_acLayerCfg[layerId].m_uiMaxCUWidth ) ? iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth + 1 : iPicWidth / m_acLayerCfg[layerId].m_uiMaxCUWidth; |
---|
1925 | UInt uiHeightInCU = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight; |
---|
1926 | #else |
---|
1927 | UInt uiWidthInCU = ( iPicWidth %m_uiMaxCUWidth ) ? iPicWidth /m_uiMaxCUWidth + 1 : iPicWidth /m_uiMaxCUWidth; |
---|
1928 | UInt uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; |
---|
1929 | #endif |
---|
1930 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
1931 | |
---|
1932 | #if LAYER_CTB |
---|
1933 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1); |
---|
1934 | #else |
---|
1935 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1); |
---|
1936 | #endif |
---|
1937 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
1938 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
1939 | { |
---|
1940 | numDU ++; |
---|
1941 | } |
---|
1942 | vps->getBspHrd(i)->setNumDU( numDU ); |
---|
1943 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
1944 | } |
---|
1945 | #if Q0078_ADD_LAYER_SETS |
---|
1946 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
---|
1947 | #else |
---|
1948 | for(UInt h = 1; h <= (vps->getNumLayerSets()-1); h++) |
---|
1949 | #endif |
---|
1950 | { |
---|
1951 | vps->setNumBitstreamPartitions(h, 1); |
---|
1952 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
1953 | { |
---|
1954 | for( UInt j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
1955 | { |
---|
1956 | if (vps->getLayerIdIncludedFlag(h, j) && h == j) |
---|
1957 | { |
---|
1958 | vps->setLayerInBspFlag(h, i, j, true); |
---|
1959 | } |
---|
1960 | } |
---|
1961 | } |
---|
1962 | vps->setNumBspSchedCombinations(h, 1); |
---|
1963 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
1964 | { |
---|
1965 | for( UInt j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
1966 | { |
---|
1967 | vps->setBspCombHrdIdx(h, i, j, 0); |
---|
1968 | vps->setBspCombSchedIdx(h, i, j, 0); |
---|
1969 | } |
---|
1970 | } |
---|
1971 | } |
---|
1972 | } |
---|
1973 | #endif |
---|
1974 | #endif |
---|
1975 | |
---|
1976 | #else //SVC_EXTENSION |
---|
1977 | m_cTEncTop.init(isFieldCoding); |
---|
1978 | #endif //SVC_EXTENSION |
---|
1979 | } |
---|
1980 | |
---|
1981 | // ==================================================================================================================== |
---|
1982 | // Public member functions |
---|
1983 | // ==================================================================================================================== |
---|
1984 | |
---|
1985 | /** |
---|
1986 | - create internal class |
---|
1987 | - initialize internal variable |
---|
1988 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1989 | - delete allocated buffers |
---|
1990 | - destroy internal class |
---|
1991 | . |
---|
1992 | */ |
---|
1993 | #if SVC_EXTENSION |
---|
1994 | Void TAppEncTop::encode() |
---|
1995 | { |
---|
1996 | fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out); |
---|
1997 | if (!bitstreamFile) |
---|
1998 | { |
---|
1999 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile); |
---|
2000 | exit(EXIT_FAILURE); |
---|
2001 | } |
---|
2002 | |
---|
2003 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
2004 | TComPicYuv* pcPicYuvRec = NULL; |
---|
2005 | |
---|
2006 | // initialize internal class & member variables |
---|
2007 | xInitLibCfg(); |
---|
2008 | xCreateLib(); |
---|
2009 | xInitLib(m_isField); |
---|
2010 | |
---|
2011 | // main encoder loop |
---|
2012 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
2013 | Bool bEos = false; |
---|
2014 | |
---|
2015 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
2016 | |
---|
2017 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2018 | { |
---|
2019 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
2020 | //5 |
---|
2021 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2022 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2023 | |
---|
2024 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2025 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2026 | #endif |
---|
2027 | // allocate original YUV buffer |
---|
2028 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
2029 | if( m_isField ) |
---|
2030 | { |
---|
2031 | #if SVC_EXTENSION |
---|
2032 | #if LAYER_CTB |
---|
2033 | #if AUXILIARY_PICTURES |
---|
2034 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2035 | #else |
---|
2036 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2037 | #endif |
---|
2038 | #else |
---|
2039 | #if AUXILIARY_PICTURES |
---|
2040 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2041 | #else |
---|
2042 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2043 | #endif |
---|
2044 | #endif |
---|
2045 | #else |
---|
2046 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeightOrg(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2047 | #endif |
---|
2048 | } |
---|
2049 | else |
---|
2050 | { |
---|
2051 | #if SVC_EXTENSION |
---|
2052 | #if LAYER_CTB |
---|
2053 | #if AUXILIARY_PICTURES |
---|
2054 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2055 | #else |
---|
2056 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2057 | #endif |
---|
2058 | #else |
---|
2059 | #if AUXILIARY_PICTURES |
---|
2060 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2061 | #else |
---|
2062 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2063 | #endif |
---|
2064 | #endif |
---|
2065 | #else |
---|
2066 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2067 | #endif |
---|
2068 | } |
---|
2069 | } |
---|
2070 | |
---|
2071 | Bool bFirstFrame = true; |
---|
2072 | while ( !bEos ) |
---|
2073 | { |
---|
2074 | // Read enough frames |
---|
2075 | Bool bFramesReadyToCode = false; |
---|
2076 | while(!bFramesReadyToCode) |
---|
2077 | { |
---|
2078 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2079 | { |
---|
2080 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
2081 | //6 |
---|
2082 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2083 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2084 | |
---|
2085 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2086 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2087 | #endif |
---|
2088 | #if LAYER_CTB |
---|
2089 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
2090 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
2091 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
2092 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
2093 | #endif |
---|
2094 | |
---|
2095 | // get buffers |
---|
2096 | xGetBuffer(pcPicYuvRec, layer); |
---|
2097 | |
---|
2098 | // read input YUV file |
---|
2099 | m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() ); |
---|
2100 | |
---|
2101 | #if AUXILIARY_PICTURES |
---|
2102 | #if R0062_AUX_PSEUDO_MONOCHROME |
---|
2103 | if ( m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400 || |
---|
2104 | (m_apcTEncTop[0]->getVPS()->getScalabilityMask(3) && (m_acLayerCfg[layer].getAuxId() == 1 || m_acLayerCfg[layer].getAuxId() == 2)) ) |
---|
2105 | #else |
---|
2106 | if (m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400) |
---|
2107 | #endif |
---|
2108 | { |
---|
2109 | pcPicYuvOrg[layer]->convertToMonochrome(); |
---|
2110 | } |
---|
2111 | #endif |
---|
2112 | |
---|
2113 | if(layer == m_numLayers-1) |
---|
2114 | { |
---|
2115 | // increase number of received frames |
---|
2116 | m_iFrameRcvd++; |
---|
2117 | // check end of file |
---|
2118 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
2119 | } |
---|
2120 | |
---|
2121 | if ( m_isField ) |
---|
2122 | { |
---|
2123 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst ); |
---|
2124 | } |
---|
2125 | else |
---|
2126 | { |
---|
2127 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); |
---|
2128 | } |
---|
2129 | } |
---|
2130 | |
---|
2131 | bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
2132 | } |
---|
2133 | Bool flush = 0; |
---|
2134 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
2135 | if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof()) |
---|
2136 | { |
---|
2137 | flush = true; |
---|
2138 | bEos = true; |
---|
2139 | m_iFrameRcvd--; |
---|
2140 | m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd); |
---|
2141 | } |
---|
2142 | |
---|
2143 | #if RC_SHVC_HARMONIZATION |
---|
2144 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2145 | { |
---|
2146 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
2147 | { |
---|
2148 | (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd()); |
---|
2149 | } |
---|
2150 | } |
---|
2151 | #endif |
---|
2152 | |
---|
2153 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2154 | if (m_adaptiveResolutionChange) |
---|
2155 | { |
---|
2156 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
2157 | { |
---|
2158 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
2159 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
2160 | { |
---|
2161 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
2162 | recPic->setReconstructed(false); |
---|
2163 | } |
---|
2164 | } |
---|
2165 | } |
---|
2166 | #endif |
---|
2167 | |
---|
2168 | // loop through frames in one GOP |
---|
2169 | for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
2170 | { |
---|
2171 | // layer by layer for each frame |
---|
2172 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2173 | { |
---|
2174 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
2175 | //7 |
---|
2176 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2177 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2178 | |
---|
2179 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2180 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2181 | #endif |
---|
2182 | #if LAYER_CTB |
---|
2183 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
2184 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
2185 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
2186 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
2187 | |
---|
2188 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
2189 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
2190 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
2191 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
2192 | #endif |
---|
2193 | // call encoding function for one frame |
---|
2194 | if ( m_isField ) |
---|
2195 | { |
---|
2196 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
2197 | } |
---|
2198 | else |
---|
2199 | { |
---|
2200 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
2201 | } |
---|
2202 | } |
---|
2203 | } |
---|
2204 | #if R0247_SEI_ACTIVE |
---|
2205 | if(bFirstFrame) |
---|
2206 | { |
---|
2207 | list<AccessUnit>::iterator first_au = outputAccessUnits.begin(); |
---|
2208 | AccessUnit::iterator it_sps; |
---|
2209 | for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++) |
---|
2210 | { |
---|
2211 | if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
2212 | { |
---|
2213 | break; |
---|
2214 | } |
---|
2215 | } |
---|
2216 | |
---|
2217 | for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++) |
---|
2218 | { |
---|
2219 | for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++) |
---|
2220 | { |
---|
2221 | if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
2222 | { |
---|
2223 | first_au->insert(++it_sps, *it_nalu); |
---|
2224 | it_nalu = it_au->erase(it_nalu); |
---|
2225 | } |
---|
2226 | } |
---|
2227 | } |
---|
2228 | } |
---|
2229 | |
---|
2230 | #endif |
---|
2231 | |
---|
2232 | #if RC_SHVC_HARMONIZATION |
---|
2233 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2234 | { |
---|
2235 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
2236 | { |
---|
2237 | (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP(); |
---|
2238 | } |
---|
2239 | } |
---|
2240 | #endif |
---|
2241 | |
---|
2242 | iTotalNumEncoded = 0; |
---|
2243 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2244 | { |
---|
2245 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
2246 | //8 |
---|
2247 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2248 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2249 | |
---|
2250 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
2251 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
2252 | #endif |
---|
2253 | // write bistream to file if necessary |
---|
2254 | iNumEncoded = m_acTEncTop[layer].getNumPicRcvd(); |
---|
2255 | if ( iNumEncoded > 0 ) |
---|
2256 | { |
---|
2257 | xWriteRecon(layer, iNumEncoded); |
---|
2258 | iTotalNumEncoded += iNumEncoded; |
---|
2259 | } |
---|
2260 | m_acTEncTop[layer].setNumPicRcvd( 0 ); |
---|
2261 | } |
---|
2262 | |
---|
2263 | // write bitstream out |
---|
2264 | if(iTotalNumEncoded) |
---|
2265 | { |
---|
2266 | #if P0130_EOB |
---|
2267 | if( bEos ) |
---|
2268 | { |
---|
2269 | OutputNALUnit nalu(NAL_UNIT_EOB); |
---|
2270 | nalu.m_layerId = 0; |
---|
2271 | |
---|
2272 | AccessUnit& accessUnit = outputAccessUnits.back(); |
---|
2273 | #if T_ID_EOB_BUG_FIX |
---|
2274 | nalu.m_temporalId = 0; |
---|
2275 | #else |
---|
2276 | nalu.m_temporalId = accessUnit.front()->m_temporalId; |
---|
2277 | #endif |
---|
2278 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
2279 | } |
---|
2280 | #endif |
---|
2281 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
2282 | outputAccessUnits.clear(); |
---|
2283 | } |
---|
2284 | |
---|
2285 | // print out summary |
---|
2286 | if (bEos) |
---|
2287 | { |
---|
2288 | printOutSummary(m_isTopFieldFirst); |
---|
2289 | } |
---|
2290 | |
---|
2291 | bFirstFrame = false; |
---|
2292 | } |
---|
2293 | // delete original YUV buffer |
---|
2294 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2295 | { |
---|
2296 | pcPicYuvOrg[layer]->destroy(); |
---|
2297 | delete pcPicYuvOrg[layer]; |
---|
2298 | pcPicYuvOrg[layer] = NULL; |
---|
2299 | |
---|
2300 | // delete used buffers in encoder class |
---|
2301 | m_acTEncTop[layer].deletePicBuffer(); |
---|
2302 | } |
---|
2303 | |
---|
2304 | // delete buffers & classes |
---|
2305 | xDeleteBuffer(); |
---|
2306 | xDestroyLib(); |
---|
2307 | |
---|
2308 | printRateSummary(); |
---|
2309 | |
---|
2310 | return; |
---|
2311 | } |
---|
2312 | |
---|
2313 | Void TAppEncTop::printOutSummary(Bool isField) |
---|
2314 | { |
---|
2315 | UInt layer; |
---|
2316 | |
---|
2317 | // set frame rate |
---|
2318 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2319 | { |
---|
2320 | if(isField) |
---|
2321 | { |
---|
2322 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2); |
---|
2323 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
2324 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
2325 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
2326 | } |
---|
2327 | else |
---|
2328 | { |
---|
2329 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
2330 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
2331 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
2332 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
2333 | } |
---|
2334 | } |
---|
2335 | |
---|
2336 | //-- all |
---|
2337 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
2338 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
2339 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2340 | { |
---|
2341 | m_gcAnalyzeAll[layer].printOut('a', layer); |
---|
2342 | } |
---|
2343 | |
---|
2344 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
2345 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
2346 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2347 | { |
---|
2348 | m_gcAnalyzeI[layer].printOut('i', layer); |
---|
2349 | } |
---|
2350 | |
---|
2351 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
2352 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
2353 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2354 | { |
---|
2355 | m_gcAnalyzeP[layer].printOut('p', layer); |
---|
2356 | } |
---|
2357 | |
---|
2358 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
2359 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
2360 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2361 | { |
---|
2362 | m_gcAnalyzeB[layer].printOut('b', layer); |
---|
2363 | } |
---|
2364 | |
---|
2365 | if(isField) |
---|
2366 | { |
---|
2367 | for(layer = 0; layer < m_numLayers; layer++) |
---|
2368 | { |
---|
2369 | //-- interlaced summary |
---|
2370 | m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
2371 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
2372 | m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll[layer].getBits()); |
---|
2373 | |
---|
2374 | #if _SUMMARY_OUT_ |
---|
2375 | m_gcAnalyzeAll_in.printSummaryOutInterlaced(); |
---|
2376 | #endif |
---|
2377 | } |
---|
2378 | } |
---|
2379 | } |
---|
2380 | |
---|
2381 | #else |
---|
2382 | Void TAppEncTop::encode() |
---|
2383 | { |
---|
2384 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
2385 | if (!bitstreamFile) |
---|
2386 | { |
---|
2387 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
2388 | exit(EXIT_FAILURE); |
---|
2389 | } |
---|
2390 | |
---|
2391 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
2392 | TComPicYuv* pcPicYuvRec = NULL; |
---|
2393 | |
---|
2394 | // initialize internal class & member variables |
---|
2395 | xInitLibCfg(); |
---|
2396 | xCreateLib(); |
---|
2397 | xInitLib(m_isField); |
---|
2398 | |
---|
2399 | // main encoder loop |
---|
2400 | Int iNumEncoded = 0; |
---|
2401 | Bool bEos = false; |
---|
2402 | |
---|
2403 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
2404 | |
---|
2405 | // allocate original YUV buffer |
---|
2406 | if( m_isField ) |
---|
2407 | { |
---|
2408 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2409 | } |
---|
2410 | else |
---|
2411 | { |
---|
2412 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2413 | } |
---|
2414 | |
---|
2415 | while ( !bEos ) |
---|
2416 | { |
---|
2417 | // get buffers |
---|
2418 | xGetBuffer(pcPicYuvRec); |
---|
2419 | |
---|
2420 | // read input YUV file |
---|
2421 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
2422 | |
---|
2423 | // increase number of received frames |
---|
2424 | m_iFrameRcvd++; |
---|
2425 | |
---|
2426 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
2427 | Bool flush = 0; |
---|
2428 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
2429 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
2430 | { |
---|
2431 | flush = true; |
---|
2432 | bEos = true; |
---|
2433 | m_iFrameRcvd--; |
---|
2434 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
2435 | } |
---|
2436 | |
---|
2437 | // call encoding function for one frame |
---|
2438 | if ( m_isField ) |
---|
2439 | { |
---|
2440 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
2441 | } |
---|
2442 | else |
---|
2443 | { |
---|
2444 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
2445 | } |
---|
2446 | |
---|
2447 | // write bistream to file if necessary |
---|
2448 | if ( iNumEncoded > 0 ) |
---|
2449 | { |
---|
2450 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
2451 | outputAccessUnits.clear(); |
---|
2452 | } |
---|
2453 | } |
---|
2454 | |
---|
2455 | m_cTEncTop.printSummary(m_isField); |
---|
2456 | |
---|
2457 | // delete original YUV buffer |
---|
2458 | pcPicYuvOrg->destroy(); |
---|
2459 | delete pcPicYuvOrg; |
---|
2460 | pcPicYuvOrg = NULL; |
---|
2461 | |
---|
2462 | // delete used buffers in encoder class |
---|
2463 | m_cTEncTop.deletePicBuffer(); |
---|
2464 | |
---|
2465 | // delete buffers & classes |
---|
2466 | xDeleteBuffer(); |
---|
2467 | xDestroyLib(); |
---|
2468 | |
---|
2469 | printRateSummary(); |
---|
2470 | |
---|
2471 | return; |
---|
2472 | } |
---|
2473 | #endif |
---|
2474 | |
---|
2475 | // ==================================================================================================================== |
---|
2476 | // Protected member functions |
---|
2477 | // ==================================================================================================================== |
---|
2478 | |
---|
2479 | /** |
---|
2480 | - application has picture buffer list with size of GOP |
---|
2481 | - picture buffer list acts as ring buffer |
---|
2482 | - end of the list has the latest picture |
---|
2483 | . |
---|
2484 | */ |
---|
2485 | #if SVC_EXTENSION |
---|
2486 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
2487 | { |
---|
2488 | assert( m_iGOPSize > 0 ); |
---|
2489 | |
---|
2490 | // org. buffer |
---|
2491 | if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize ) |
---|
2492 | { |
---|
2493 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
2494 | |
---|
2495 | } |
---|
2496 | else |
---|
2497 | { |
---|
2498 | rpcPicYuvRec = new TComPicYuv; |
---|
2499 | |
---|
2500 | #if LAYER_CTB |
---|
2501 | #if AUXILIARY_PICTURES |
---|
2502 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2503 | #else |
---|
2504 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].m_uiMaxCUWidth, m_acLayerCfg[layer].m_uiMaxCUHeight, m_acLayerCfg[layer].m_uiMaxCUDepth, NULL ); |
---|
2505 | #endif |
---|
2506 | #else |
---|
2507 | #if AUXILIARY_PICTURES |
---|
2508 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2509 | #else |
---|
2510 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2511 | #endif |
---|
2512 | #endif |
---|
2513 | |
---|
2514 | } |
---|
2515 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
2516 | } |
---|
2517 | |
---|
2518 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2519 | { |
---|
2520 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2521 | { |
---|
2522 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
2523 | |
---|
2524 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
2525 | |
---|
2526 | for ( Int i = 0; i < iSize; i++ ) |
---|
2527 | { |
---|
2528 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2529 | pcPicYuvRec->destroy(); |
---|
2530 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2531 | } |
---|
2532 | } |
---|
2533 | } |
---|
2534 | |
---|
2535 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
2536 | { |
---|
2537 | #if REPN_FORMAT_IN_VPS |
---|
2538 | ChromaFormat chromaFormatIdc = m_acLayerCfg[layer].getChromaFormatIDC(); |
---|
2539 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
2540 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
2541 | #endif |
---|
2542 | |
---|
2543 | if (m_isField) |
---|
2544 | { |
---|
2545 | //Reinterlace fields |
---|
2546 | Int i; |
---|
2547 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
2548 | |
---|
2549 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2550 | { |
---|
2551 | --iterPicYuvRec; |
---|
2552 | } |
---|
2553 | |
---|
2554 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2555 | { |
---|
2556 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2557 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2558 | |
---|
2559 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2560 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed()) |
---|
2561 | #else |
---|
2562 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
2563 | #endif |
---|
2564 | { |
---|
2565 | #if REPN_FORMAT_IN_VPS |
---|
2566 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal, |
---|
2567 | m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal, m_isTopFieldFirst ); |
---|
2568 | #else |
---|
2569 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom(), m_isTopFieldFirst ); |
---|
2570 | #endif |
---|
2571 | } |
---|
2572 | } |
---|
2573 | } |
---|
2574 | else |
---|
2575 | { |
---|
2576 | Int i; |
---|
2577 | |
---|
2578 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
2579 | |
---|
2580 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2581 | { |
---|
2582 | --iterPicYuvRec; |
---|
2583 | } |
---|
2584 | |
---|
2585 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2586 | { |
---|
2587 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2588 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2589 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) |
---|
2590 | #else |
---|
2591 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
2592 | #endif |
---|
2593 | { |
---|
2594 | #if REPN_FORMAT_IN_VPS |
---|
2595 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal, |
---|
2596 | m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal ); |
---|
2597 | #else |
---|
2598 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), |
---|
2599 | m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom() ); |
---|
2600 | #endif |
---|
2601 | } |
---|
2602 | } |
---|
2603 | } |
---|
2604 | } |
---|
2605 | |
---|
2606 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2607 | { |
---|
2608 | if (m_isField) |
---|
2609 | { |
---|
2610 | //Reinterlace fields |
---|
2611 | Int i; |
---|
2612 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2613 | |
---|
2614 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2615 | for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
2616 | #else |
---|
2617 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2618 | #endif |
---|
2619 | { |
---|
2620 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2621 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2622 | rateStatsAccum(auTop, statsTop); |
---|
2623 | |
---|
2624 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2625 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2626 | rateStatsAccum(auBottom, statsBottom); |
---|
2627 | } |
---|
2628 | } |
---|
2629 | else |
---|
2630 | { |
---|
2631 | Int i; |
---|
2632 | |
---|
2633 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2634 | |
---|
2635 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2636 | for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
2637 | #else |
---|
2638 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2639 | #endif |
---|
2640 | { |
---|
2641 | const AccessUnit& au = *(iterBitstream++); |
---|
2642 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2643 | rateStatsAccum(au, stats); |
---|
2644 | } |
---|
2645 | } |
---|
2646 | } |
---|
2647 | |
---|
2648 | #else // SVC_EXTENSION |
---|
2649 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
2650 | { |
---|
2651 | assert( m_iGOPSize > 0 ); |
---|
2652 | |
---|
2653 | // org. buffer |
---|
2654 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
2655 | { |
---|
2656 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
2657 | |
---|
2658 | } |
---|
2659 | else |
---|
2660 | { |
---|
2661 | rpcPicYuvRec = new TComPicYuv; |
---|
2662 | |
---|
2663 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2664 | |
---|
2665 | } |
---|
2666 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
2667 | } |
---|
2668 | |
---|
2669 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2670 | { |
---|
2671 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
2672 | |
---|
2673 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
2674 | |
---|
2675 | for ( Int i = 0; i < iSize; i++ ) |
---|
2676 | { |
---|
2677 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2678 | pcPicYuvRec->destroy(); |
---|
2679 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2680 | } |
---|
2681 | |
---|
2682 | } |
---|
2683 | |
---|
2684 | /** \param iNumEncoded number of encoded frames |
---|
2685 | */ |
---|
2686 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2687 | { |
---|
2688 | if (m_isField) |
---|
2689 | { |
---|
2690 | //Reinterlace fields |
---|
2691 | Int i; |
---|
2692 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2693 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2694 | |
---|
2695 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2696 | { |
---|
2697 | --iterPicYuvRec; |
---|
2698 | } |
---|
2699 | |
---|
2700 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2701 | { |
---|
2702 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2703 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2704 | |
---|
2705 | if (m_pchReconFile) |
---|
2706 | { |
---|
2707 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst ); |
---|
2708 | } |
---|
2709 | |
---|
2710 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2711 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2712 | rateStatsAccum(auTop, statsTop); |
---|
2713 | |
---|
2714 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2715 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2716 | rateStatsAccum(auBottom, statsBottom); |
---|
2717 | } |
---|
2718 | } |
---|
2719 | else |
---|
2720 | { |
---|
2721 | Int i; |
---|
2722 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2723 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2724 | |
---|
2725 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2726 | { |
---|
2727 | --iterPicYuvRec; |
---|
2728 | } |
---|
2729 | |
---|
2730 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2731 | { |
---|
2732 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2733 | if (m_pchReconFile) |
---|
2734 | { |
---|
2735 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
2736 | } |
---|
2737 | |
---|
2738 | const AccessUnit& au = *(iterBitstream++); |
---|
2739 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2740 | rateStatsAccum(au, stats); |
---|
2741 | } |
---|
2742 | } |
---|
2743 | } |
---|
2744 | #endif |
---|
2745 | |
---|
2746 | /** |
---|
2747 | * |
---|
2748 | */ |
---|
2749 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
2750 | { |
---|
2751 | AccessUnit::const_iterator it_au = au.begin(); |
---|
2752 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
2753 | |
---|
2754 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
2755 | { |
---|
2756 | switch ((*it_au)->m_nalUnitType) |
---|
2757 | { |
---|
2758 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2759 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2760 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2761 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2762 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2763 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2764 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2765 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2766 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2767 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2768 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2769 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2770 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2771 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2772 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2773 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2774 | case NAL_UNIT_VPS: |
---|
2775 | case NAL_UNIT_SPS: |
---|
2776 | case NAL_UNIT_PPS: |
---|
2777 | m_essentialBytes += *it_stats; |
---|
2778 | break; |
---|
2779 | default: |
---|
2780 | break; |
---|
2781 | } |
---|
2782 | |
---|
2783 | m_totalBytes += *it_stats; |
---|
2784 | } |
---|
2785 | } |
---|
2786 | |
---|
2787 | void TAppEncTop::printRateSummary() |
---|
2788 | { |
---|
2789 | #if SVC_EXTENSION |
---|
2790 | Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate(); |
---|
2791 | #else |
---|
2792 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
2793 | #endif |
---|
2794 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
2795 | #if VERBOSE_RATE |
---|
2796 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
2797 | #endif |
---|
2798 | } |
---|
2799 | |
---|
2800 | //! \} |
---|