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