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