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