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