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