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