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