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 ? false : 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 | Bool bFirstFrame = true; |
---|
1672 | while ( !bEos ) |
---|
1673 | { |
---|
1674 | // Read enough frames |
---|
1675 | Bool bFramesReadyToCode = false; |
---|
1676 | while(!bFramesReadyToCode) |
---|
1677 | { |
---|
1678 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1679 | { |
---|
1680 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1681 | //6 |
---|
1682 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1683 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1684 | |
---|
1685 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1686 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1687 | #endif |
---|
1688 | #if LAYER_CTB |
---|
1689 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
1690 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
1691 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
1692 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
1693 | #endif |
---|
1694 | |
---|
1695 | // get buffers |
---|
1696 | xGetBuffer(pcPicYuvRec, layer); |
---|
1697 | |
---|
1698 | // read input YUV file |
---|
1699 | m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() ); |
---|
1700 | |
---|
1701 | #if AUXILIARY_PICTURES |
---|
1702 | if (m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400) |
---|
1703 | { |
---|
1704 | pcPicYuvOrg[layer]->convertToMonochrome(); |
---|
1705 | } |
---|
1706 | #endif |
---|
1707 | |
---|
1708 | if(layer == m_numLayers-1) |
---|
1709 | { |
---|
1710 | // increase number of received frames |
---|
1711 | m_iFrameRcvd++; |
---|
1712 | // check end of file |
---|
1713 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1714 | } |
---|
1715 | |
---|
1716 | if ( m_isField ) |
---|
1717 | { |
---|
1718 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer], m_isTopFieldFirst ); |
---|
1719 | } |
---|
1720 | else |
---|
1721 | { |
---|
1722 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); |
---|
1723 | } |
---|
1724 | } |
---|
1725 | |
---|
1726 | bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
1727 | } |
---|
1728 | Bool flush = 0; |
---|
1729 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1730 | if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof()) |
---|
1731 | { |
---|
1732 | flush = true; |
---|
1733 | bEos = true; |
---|
1734 | m_iFrameRcvd--; |
---|
1735 | m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd); |
---|
1736 | } |
---|
1737 | |
---|
1738 | #if RC_SHVC_HARMONIZATION |
---|
1739 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1740 | { |
---|
1741 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
1742 | { |
---|
1743 | (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd()); |
---|
1744 | } |
---|
1745 | } |
---|
1746 | #endif |
---|
1747 | |
---|
1748 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1749 | if (m_adaptiveResolutionChange) |
---|
1750 | { |
---|
1751 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
1752 | { |
---|
1753 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
1754 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
1755 | { |
---|
1756 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
1757 | recPic->setReconstructed(false); |
---|
1758 | } |
---|
1759 | } |
---|
1760 | } |
---|
1761 | #endif |
---|
1762 | |
---|
1763 | // loop through frames in one GOP |
---|
1764 | for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
1765 | { |
---|
1766 | // layer by layer for each frame |
---|
1767 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1768 | { |
---|
1769 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1770 | //7 |
---|
1771 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1772 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1773 | |
---|
1774 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1775 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1776 | #endif |
---|
1777 | #if LAYER_CTB |
---|
1778 | g_uiMaxCUWidth = g_auiLayerMaxCUWidth[layer]; |
---|
1779 | g_uiMaxCUHeight = g_auiLayerMaxCUHeight[layer]; |
---|
1780 | g_uiMaxCUDepth = g_auiLayerMaxCUDepth[layer]; |
---|
1781 | g_uiAddCUDepth = g_auiLayerAddCUDepth[layer]; |
---|
1782 | |
---|
1783 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
1784 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
1785 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
1786 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
1787 | #endif |
---|
1788 | // call encoding function for one frame |
---|
1789 | if ( m_isField ) |
---|
1790 | { |
---|
1791 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
1792 | } |
---|
1793 | else |
---|
1794 | { |
---|
1795 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
1796 | } |
---|
1797 | } |
---|
1798 | } |
---|
1799 | |
---|
1800 | #if RC_SHVC_HARMONIZATION |
---|
1801 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1802 | { |
---|
1803 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
1804 | { |
---|
1805 | (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP(); |
---|
1806 | } |
---|
1807 | } |
---|
1808 | #endif |
---|
1809 | |
---|
1810 | iTotalNumEncoded = 0; |
---|
1811 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1812 | { |
---|
1813 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1814 | //8 |
---|
1815 | g_bitDepthY = m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1816 | g_bitDepthC = m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1817 | |
---|
1818 | g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthY : m_acLayerCfg[layer].m_internalBitDepthY; |
---|
1819 | g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_inputBitDepthC : m_acLayerCfg[layer].m_internalBitDepthC; |
---|
1820 | #endif |
---|
1821 | // write bistream to file if necessary |
---|
1822 | iNumEncoded = m_acTEncTop[layer].getNumPicRcvd(); |
---|
1823 | if ( iNumEncoded > 0 ) |
---|
1824 | { |
---|
1825 | xWriteRecon(layer, iNumEncoded); |
---|
1826 | iTotalNumEncoded += iNumEncoded; |
---|
1827 | } |
---|
1828 | m_acTEncTop[layer].setNumPicRcvd( 0 ); |
---|
1829 | } |
---|
1830 | |
---|
1831 | // write bitstream out |
---|
1832 | if(iTotalNumEncoded) |
---|
1833 | { |
---|
1834 | #if P0130_EOB |
---|
1835 | if( bEos ) |
---|
1836 | { |
---|
1837 | OutputNALUnit nalu(NAL_UNIT_EOB); |
---|
1838 | nalu.m_layerId = 0; |
---|
1839 | |
---|
1840 | AccessUnit& accessUnit = outputAccessUnits.back(); |
---|
1841 | nalu.m_temporalId = accessUnit.front()->m_temporalId; |
---|
1842 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1843 | } |
---|
1844 | #endif |
---|
1845 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
1846 | outputAccessUnits.clear(); |
---|
1847 | } |
---|
1848 | |
---|
1849 | // print out summary |
---|
1850 | if (bEos) |
---|
1851 | { |
---|
1852 | printOutSummary(m_isTopFieldFirst); |
---|
1853 | } |
---|
1854 | |
---|
1855 | bFirstFrame = false; |
---|
1856 | } |
---|
1857 | // delete original YUV buffer |
---|
1858 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1859 | { |
---|
1860 | pcPicYuvOrg[layer]->destroy(); |
---|
1861 | delete pcPicYuvOrg[layer]; |
---|
1862 | pcPicYuvOrg[layer] = NULL; |
---|
1863 | |
---|
1864 | // delete used buffers in encoder class |
---|
1865 | m_acTEncTop[layer].deletePicBuffer(); |
---|
1866 | } |
---|
1867 | |
---|
1868 | // delete buffers & classes |
---|
1869 | xDeleteBuffer(); |
---|
1870 | xDestroyLib(); |
---|
1871 | |
---|
1872 | printRateSummary(); |
---|
1873 | |
---|
1874 | return; |
---|
1875 | } |
---|
1876 | |
---|
1877 | Void TAppEncTop::printOutSummary(Bool isField) |
---|
1878 | { |
---|
1879 | UInt layer; |
---|
1880 | |
---|
1881 | // set frame rate |
---|
1882 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1883 | { |
---|
1884 | if(isField) |
---|
1885 | { |
---|
1886 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2); |
---|
1887 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
1888 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
1889 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() * 2 ); |
---|
1890 | } |
---|
1891 | else |
---|
1892 | { |
---|
1893 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
1894 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1895 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1896 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1897 | } |
---|
1898 | } |
---|
1899 | |
---|
1900 | //-- all |
---|
1901 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
1902 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1903 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1904 | { |
---|
1905 | m_gcAnalyzeAll[layer].printOut('a', layer); |
---|
1906 | } |
---|
1907 | |
---|
1908 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
1909 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1910 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1911 | { |
---|
1912 | m_gcAnalyzeI[layer].printOut('i', layer); |
---|
1913 | } |
---|
1914 | |
---|
1915 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
1916 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1917 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1918 | { |
---|
1919 | m_gcAnalyzeP[layer].printOut('p', layer); |
---|
1920 | } |
---|
1921 | |
---|
1922 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
1923 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1924 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1925 | { |
---|
1926 | m_gcAnalyzeB[layer].printOut('b', layer); |
---|
1927 | } |
---|
1928 | |
---|
1929 | if(isField) |
---|
1930 | { |
---|
1931 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1932 | { |
---|
1933 | //-- interlaced summary |
---|
1934 | m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
1935 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
1936 | m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll[layer].getBits()); |
---|
1937 | |
---|
1938 | #if _SUMMARY_OUT_ |
---|
1939 | m_gcAnalyzeAll_in.printSummaryOutInterlaced(); |
---|
1940 | #endif |
---|
1941 | } |
---|
1942 | } |
---|
1943 | } |
---|
1944 | |
---|
1945 | #else |
---|
1946 | Void TAppEncTop::encode() |
---|
1947 | { |
---|
1948 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1949 | if (!bitstreamFile) |
---|
1950 | { |
---|
1951 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1952 | exit(EXIT_FAILURE); |
---|
1953 | } |
---|
1954 | |
---|
1955 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
1956 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1957 | |
---|
1958 | // initialize internal class & member variables |
---|
1959 | xInitLibCfg(); |
---|
1960 | xCreateLib(); |
---|
1961 | xInitLib(m_isField); |
---|
1962 | |
---|
1963 | // main encoder loop |
---|
1964 | Int iNumEncoded = 0; |
---|
1965 | Bool bEos = false; |
---|
1966 | |
---|
1967 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1968 | |
---|
1969 | // allocate original YUV buffer |
---|
1970 | if( m_isField ) |
---|
1971 | { |
---|
1972 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeightOrg, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1973 | } |
---|
1974 | else |
---|
1975 | { |
---|
1976 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1977 | } |
---|
1978 | |
---|
1979 | while ( !bEos ) |
---|
1980 | { |
---|
1981 | // get buffers |
---|
1982 | xGetBuffer(pcPicYuvRec); |
---|
1983 | |
---|
1984 | // read input YUV file |
---|
1985 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
1986 | |
---|
1987 | // increase number of received frames |
---|
1988 | m_iFrameRcvd++; |
---|
1989 | |
---|
1990 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1991 | Bool flush = 0; |
---|
1992 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1993 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
1994 | { |
---|
1995 | flush = true; |
---|
1996 | bEos = true; |
---|
1997 | m_iFrameRcvd--; |
---|
1998 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
1999 | } |
---|
2000 | |
---|
2001 | // call encoding function for one frame |
---|
2002 | if ( m_isField ) |
---|
2003 | { |
---|
2004 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst); |
---|
2005 | } |
---|
2006 | else |
---|
2007 | { |
---|
2008 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
2009 | } |
---|
2010 | |
---|
2011 | // write bistream to file if necessary |
---|
2012 | if ( iNumEncoded > 0 ) |
---|
2013 | { |
---|
2014 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
2015 | outputAccessUnits.clear(); |
---|
2016 | } |
---|
2017 | } |
---|
2018 | |
---|
2019 | m_cTEncTop.printSummary(m_isField); |
---|
2020 | |
---|
2021 | // delete original YUV buffer |
---|
2022 | pcPicYuvOrg->destroy(); |
---|
2023 | delete pcPicYuvOrg; |
---|
2024 | pcPicYuvOrg = NULL; |
---|
2025 | |
---|
2026 | // delete used buffers in encoder class |
---|
2027 | m_cTEncTop.deletePicBuffer(); |
---|
2028 | |
---|
2029 | // delete buffers & classes |
---|
2030 | xDeleteBuffer(); |
---|
2031 | xDestroyLib(); |
---|
2032 | |
---|
2033 | printRateSummary(); |
---|
2034 | |
---|
2035 | return; |
---|
2036 | } |
---|
2037 | #endif |
---|
2038 | |
---|
2039 | // ==================================================================================================================== |
---|
2040 | // Protected member functions |
---|
2041 | // ==================================================================================================================== |
---|
2042 | |
---|
2043 | /** |
---|
2044 | - application has picture buffer list with size of GOP |
---|
2045 | - picture buffer list acts as ring buffer |
---|
2046 | - end of the list has the latest picture |
---|
2047 | . |
---|
2048 | */ |
---|
2049 | #if SVC_EXTENSION |
---|
2050 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
2051 | { |
---|
2052 | assert( m_iGOPSize > 0 ); |
---|
2053 | |
---|
2054 | // org. buffer |
---|
2055 | if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize ) |
---|
2056 | { |
---|
2057 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
2058 | |
---|
2059 | } |
---|
2060 | else |
---|
2061 | { |
---|
2062 | rpcPicYuvRec = new TComPicYuv; |
---|
2063 | |
---|
2064 | #if LAYER_CTB |
---|
2065 | #if AUXILIARY_PICTURES |
---|
2066 | 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 ); |
---|
2067 | #else |
---|
2068 | 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 ); |
---|
2069 | #endif |
---|
2070 | #else |
---|
2071 | #if AUXILIARY_PICTURES |
---|
2072 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_acLayerCfg[layer].getChromaFormatIDC(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2073 | #else |
---|
2074 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
2075 | #endif |
---|
2076 | #endif |
---|
2077 | |
---|
2078 | } |
---|
2079 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
2080 | } |
---|
2081 | |
---|
2082 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2083 | { |
---|
2084 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
2085 | { |
---|
2086 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
2087 | |
---|
2088 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
2089 | |
---|
2090 | for ( Int i = 0; i < iSize; i++ ) |
---|
2091 | { |
---|
2092 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2093 | pcPicYuvRec->destroy(); |
---|
2094 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2095 | } |
---|
2096 | } |
---|
2097 | } |
---|
2098 | |
---|
2099 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
2100 | { |
---|
2101 | #if REPN_FORMAT_IN_VPS |
---|
2102 | ChromaFormat chromaFormatIdc = m_acLayerCfg[layer].getChromaFormatIDC(); |
---|
2103 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
2104 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
2105 | #endif |
---|
2106 | |
---|
2107 | if (m_isField) |
---|
2108 | { |
---|
2109 | //Reinterlace fields |
---|
2110 | Int i; |
---|
2111 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
2112 | |
---|
2113 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2114 | { |
---|
2115 | --iterPicYuvRec; |
---|
2116 | } |
---|
2117 | |
---|
2118 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2119 | { |
---|
2120 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2121 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2122 | |
---|
2123 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2124 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed()) |
---|
2125 | #else |
---|
2126 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
2127 | #endif |
---|
2128 | { |
---|
2129 | #if REPN_FORMAT_IN_VPS |
---|
2130 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal, |
---|
2131 | m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal, m_isTopFieldFirst ); |
---|
2132 | #else |
---|
2133 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst ); |
---|
2134 | #endif |
---|
2135 | } |
---|
2136 | } |
---|
2137 | } |
---|
2138 | else |
---|
2139 | { |
---|
2140 | Int i; |
---|
2141 | |
---|
2142 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
2143 | |
---|
2144 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2145 | { |
---|
2146 | --iterPicYuvRec; |
---|
2147 | } |
---|
2148 | |
---|
2149 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2150 | { |
---|
2151 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2152 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2153 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) |
---|
2154 | #else |
---|
2155 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
2156 | #endif |
---|
2157 | { |
---|
2158 | #if REPN_FORMAT_IN_VPS |
---|
2159 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal, |
---|
2160 | m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal ); |
---|
2161 | #else |
---|
2162 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), |
---|
2163 | m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() ); |
---|
2164 | #endif |
---|
2165 | } |
---|
2166 | } |
---|
2167 | } |
---|
2168 | } |
---|
2169 | |
---|
2170 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2171 | { |
---|
2172 | if (m_isField) |
---|
2173 | { |
---|
2174 | //Reinterlace fields |
---|
2175 | Int i; |
---|
2176 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2177 | |
---|
2178 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2179 | for ( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
2180 | #else |
---|
2181 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2182 | #endif |
---|
2183 | { |
---|
2184 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2185 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2186 | rateStatsAccum(auTop, statsTop); |
---|
2187 | |
---|
2188 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2189 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2190 | rateStatsAccum(auBottom, statsBottom); |
---|
2191 | } |
---|
2192 | } |
---|
2193 | else |
---|
2194 | { |
---|
2195 | Int i; |
---|
2196 | |
---|
2197 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2198 | |
---|
2199 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
2200 | for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
2201 | #else |
---|
2202 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2203 | #endif |
---|
2204 | { |
---|
2205 | const AccessUnit& au = *(iterBitstream++); |
---|
2206 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2207 | rateStatsAccum(au, stats); |
---|
2208 | } |
---|
2209 | } |
---|
2210 | } |
---|
2211 | |
---|
2212 | #else // SVC_EXTENSION |
---|
2213 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
2214 | { |
---|
2215 | assert( m_iGOPSize > 0 ); |
---|
2216 | |
---|
2217 | // org. buffer |
---|
2218 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
2219 | { |
---|
2220 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
2221 | |
---|
2222 | } |
---|
2223 | else |
---|
2224 | { |
---|
2225 | rpcPicYuvRec = new TComPicYuv; |
---|
2226 | |
---|
2227 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
2228 | |
---|
2229 | } |
---|
2230 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
2231 | } |
---|
2232 | |
---|
2233 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2234 | { |
---|
2235 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
2236 | |
---|
2237 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
2238 | |
---|
2239 | for ( Int i = 0; i < iSize; i++ ) |
---|
2240 | { |
---|
2241 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2242 | pcPicYuvRec->destroy(); |
---|
2243 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2244 | } |
---|
2245 | |
---|
2246 | } |
---|
2247 | |
---|
2248 | /** \param iNumEncoded number of encoded frames |
---|
2249 | */ |
---|
2250 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2251 | { |
---|
2252 | if (m_isField) |
---|
2253 | { |
---|
2254 | //Reinterlace fields |
---|
2255 | Int i; |
---|
2256 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2257 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2258 | |
---|
2259 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2260 | { |
---|
2261 | --iterPicYuvRec; |
---|
2262 | } |
---|
2263 | |
---|
2264 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2265 | { |
---|
2266 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2267 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2268 | |
---|
2269 | if (m_pchReconFile) |
---|
2270 | { |
---|
2271 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst ); |
---|
2272 | } |
---|
2273 | |
---|
2274 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2275 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2276 | rateStatsAccum(auTop, statsTop); |
---|
2277 | |
---|
2278 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2279 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2280 | rateStatsAccum(auBottom, statsBottom); |
---|
2281 | } |
---|
2282 | } |
---|
2283 | else |
---|
2284 | { |
---|
2285 | Int i; |
---|
2286 | |
---|
2287 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2288 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2289 | |
---|
2290 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2291 | { |
---|
2292 | --iterPicYuvRec; |
---|
2293 | } |
---|
2294 | |
---|
2295 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2296 | { |
---|
2297 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2298 | if (m_pchReconFile) |
---|
2299 | { |
---|
2300 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
2301 | } |
---|
2302 | |
---|
2303 | const AccessUnit& au = *(iterBitstream++); |
---|
2304 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2305 | rateStatsAccum(au, stats); |
---|
2306 | } |
---|
2307 | } |
---|
2308 | } |
---|
2309 | #endif |
---|
2310 | |
---|
2311 | /** |
---|
2312 | * |
---|
2313 | */ |
---|
2314 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
2315 | { |
---|
2316 | AccessUnit::const_iterator it_au = au.begin(); |
---|
2317 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
2318 | |
---|
2319 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
2320 | { |
---|
2321 | switch ((*it_au)->m_nalUnitType) |
---|
2322 | { |
---|
2323 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2324 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2325 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2326 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2327 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2328 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2329 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2330 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2331 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2332 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2333 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2334 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2335 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2336 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2337 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2338 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2339 | case NAL_UNIT_VPS: |
---|
2340 | case NAL_UNIT_SPS: |
---|
2341 | case NAL_UNIT_PPS: |
---|
2342 | m_essentialBytes += *it_stats; |
---|
2343 | break; |
---|
2344 | default: |
---|
2345 | break; |
---|
2346 | } |
---|
2347 | |
---|
2348 | m_totalBytes += *it_stats; |
---|
2349 | } |
---|
2350 | } |
---|
2351 | |
---|
2352 | void TAppEncTop::printRateSummary() |
---|
2353 | { |
---|
2354 | #if SVC_EXTENSION |
---|
2355 | Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate(); |
---|
2356 | #else |
---|
2357 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
2358 | #endif |
---|
2359 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
2360 | #if VERBOSE_RATE |
---|
2361 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
2362 | #endif |
---|
2363 | } |
---|
2364 | |
---|
2365 | //! \} |
---|