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