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