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