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-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TAppEncTop.cpp |
---|
35 | \brief Encoder application class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <list> |
---|
39 | #include <fstream> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <stdio.h> |
---|
42 | #include <fcntl.h> |
---|
43 | #include <assert.h> |
---|
44 | |
---|
45 | #include "TAppEncTop.h" |
---|
46 | #include "TLibEncoder/AnnexBwrite.h" |
---|
47 | |
---|
48 | using namespace std; |
---|
49 | |
---|
50 | //! \ingroup TAppEncoder |
---|
51 | //! \{ |
---|
52 | |
---|
53 | // ==================================================================================================================== |
---|
54 | // Constructor / destructor / initialization / destroy |
---|
55 | // ==================================================================================================================== |
---|
56 | |
---|
57 | TAppEncTop::TAppEncTop() |
---|
58 | { |
---|
59 | m_iFrameRcvd = 0; |
---|
60 | m_totalBytes = 0; |
---|
61 | m_essentialBytes = 0; |
---|
62 | #if SVC_EXTENSION |
---|
63 | for(UInt layer=0; layer < MAX_LAYERS; layer++) |
---|
64 | { |
---|
65 | m_apcTEncTop[layer] = &m_acTEncTop[layer]; |
---|
66 | } |
---|
67 | #endif |
---|
68 | } |
---|
69 | |
---|
70 | TAppEncTop::~TAppEncTop() |
---|
71 | { |
---|
72 | } |
---|
73 | |
---|
74 | #if SVC_EXTENSION |
---|
75 | Void TAppEncTop::xInitLibCfg() |
---|
76 | { |
---|
77 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
78 | |
---|
79 | vps->setMaxTLayers ( m_maxTempLayer ); |
---|
80 | if (m_maxTempLayer == 1) |
---|
81 | { |
---|
82 | vps->setTemporalNestingFlag(true); |
---|
83 | } |
---|
84 | #if !VPS_RENAME |
---|
85 | vps.setMaxLayers ( 1 ); |
---|
86 | #endif |
---|
87 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
88 | { |
---|
89 | vps->setNumReorderPics ( m_numReorderPics[i], i ); |
---|
90 | vps->setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
91 | } |
---|
92 | #if REPN_FORMAT_IN_VPS |
---|
93 | vps->setRepFormatIdxPresentFlag( true ); // Could be disabled to optimize in some cases. |
---|
94 | Int maxRepFormatIdx = -1; |
---|
95 | for(UInt layer=0; layer < m_numLayers; layer++) |
---|
96 | { |
---|
97 | assert( m_acLayerCfg[layer].getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
---|
98 | vps->setVpsRepFormatIdx( layer, m_acLayerCfg[layer].getRepFormatIdx() ); |
---|
99 | maxRepFormatIdx = std::max( m_acLayerCfg[layer].getRepFormatIdx(), maxRepFormatIdx ); |
---|
100 | } |
---|
101 | assert( vps->getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
---|
102 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
---|
103 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
---|
104 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
---|
105 | { |
---|
106 | mapIdxToLayer[i] = -1; |
---|
107 | UInt layer; |
---|
108 | for(layer=0; layer < m_numLayers; layer++) |
---|
109 | { |
---|
110 | if( vps->getVpsRepFormatIdx(layer) == i ) |
---|
111 | { |
---|
112 | mapIdxToLayer[i] = layer; |
---|
113 | break; |
---|
114 | } |
---|
115 | } |
---|
116 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
---|
117 | } |
---|
118 | vps->setVpsNumRepFormats( maxRepFormatIdx + 1 ); |
---|
119 | for(UInt idx=0; idx < vps->getVpsNumRepFormats(); idx++) |
---|
120 | { |
---|
121 | RepFormat *repFormat = vps->getVpsRepFormat( idx ); |
---|
122 | repFormat->setPicWidthVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceWidth() ); |
---|
123 | repFormat->setPicHeightVpsInLumaSamples ( m_acLayerCfg[mapIdxToLayer[idx]].getSourceHeight() ); |
---|
124 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
---|
125 | repFormat->setSeparateColourPlaneVpsFlag( 0 ); // Need modification to change for each layer |
---|
126 | repFormat->setBitDepthVpsLuma ( getInternalBitDepthY() ); // Need modification to change for each layer |
---|
127 | repFormat->setBitDepthVpsChroma ( getInternalBitDepthC() ); // Need modification to change for each layer |
---|
128 | } |
---|
129 | delete [] mapIdxToLayer; |
---|
130 | #endif |
---|
131 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
132 | { |
---|
133 | //m_acTEncTop[layer].setVPS(&vps); |
---|
134 | m_acTEncTop[layer].setFrameRate ( m_acLayerCfg[layer].getFrameRate() ); |
---|
135 | m_acTEncTop[layer].setFrameSkip ( m_FrameSkip ); |
---|
136 | m_acTEncTop[layer].setSourceWidth ( m_acLayerCfg[layer].getSourceWidth() ); |
---|
137 | m_acTEncTop[layer].setSourceHeight ( m_acLayerCfg[layer].getSourceHeight() ); |
---|
138 | m_acTEncTop[layer].setConformanceMode ( m_acLayerCfg[layer].getConformanceMode() ); |
---|
139 | m_acTEncTop[layer].setConformanceWindow ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom ); |
---|
140 | m_acTEncTop[layer].setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
141 | |
---|
142 | m_acTEncTop[layer].setProfile(m_profile); |
---|
143 | m_acTEncTop[layer].setLevel(m_levelTier, m_level); |
---|
144 | m_acTEncTop[layer].setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
145 | m_acTEncTop[layer].setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
146 | m_acTEncTop[layer].setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
147 | m_acTEncTop[layer].setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
148 | |
---|
149 | #if REF_IDX_MFM |
---|
150 | #if AVC_BASE |
---|
151 | #if M0457_PREDICTION_INDICATIONS |
---|
152 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers()); |
---|
153 | #else |
---|
154 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true )); |
---|
155 | #endif |
---|
156 | #else |
---|
157 | #if M0457_PREDICTION_INDICATIONS |
---|
158 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) ); |
---|
159 | #else |
---|
160 | m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : true); |
---|
161 | #endif |
---|
162 | #endif |
---|
163 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
164 | m_acTEncTop[layer].setIlSampleOnlyPred( layer == 0 ? 0 : m_ilSampleOnlyPred[layer] ); |
---|
165 | #endif |
---|
166 | #endif |
---|
167 | // set layer ID |
---|
168 | m_acTEncTop[layer].setLayerId ( layer ); |
---|
169 | m_acTEncTop[layer].setNumLayer ( m_numLayers ); |
---|
170 | m_acTEncTop[layer].setLayerEnc(m_apcTEncTop); |
---|
171 | |
---|
172 | //====== Coding Structure ======== |
---|
173 | m_acTEncTop[layer].setIntraPeriod ( m_acLayerCfg[layer].m_iIntraPeriod ); |
---|
174 | m_acTEncTop[layer].setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
175 | m_acTEncTop[layer].setGOPSize ( m_iGOPSize ); |
---|
176 | #if FINAL_RPL_CHANGE_N0082 |
---|
177 | m_acTEncTop[layer].setGopList ( m_acLayerCfg[layer].m_GOPListLayer ); |
---|
178 | #else |
---|
179 | m_acTEncTop[layer].setGopList ( m_GOPList ); |
---|
180 | #endif |
---|
181 | m_acTEncTop[layer].setExtraRPSs ( m_extraRPSs ); |
---|
182 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
183 | { |
---|
184 | m_acTEncTop[layer].setNumReorderPics ( m_numReorderPics[i], i ); |
---|
185 | m_acTEncTop[layer].setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
186 | } |
---|
187 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
188 | { |
---|
189 | m_acTEncTop[layer].setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
190 | } |
---|
191 | m_acTEncTop[layer].setQP ( m_acLayerCfg[layer].getIntQP() ); |
---|
192 | |
---|
193 | m_acTEncTop[layer].setPad ( m_acLayerCfg[layer].getPad() ); |
---|
194 | |
---|
195 | m_acTEncTop[layer].setMaxTempLayer ( m_maxTempLayer ); |
---|
196 | m_acTEncTop[layer].setUseAMP( m_enableAMP ); |
---|
197 | #if N0120_MAX_TID_REF_CFG |
---|
198 | if (layer<m_numLayers-1) |
---|
199 | { |
---|
200 | m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); |
---|
201 | } |
---|
202 | #endif |
---|
203 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
204 | if(layer) |
---|
205 | { |
---|
206 | #if M0457_PREDICTION_INDICATIONS |
---|
207 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
208 | { |
---|
209 | m_acTEncTop[layer].setSamplePredEnabledFlag(i, false); |
---|
210 | m_acTEncTop[layer].setMotionPredEnabledFlag(i, false); |
---|
211 | } |
---|
212 | if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1) |
---|
213 | { |
---|
214 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
215 | m_acTEncTop[layer].setNumSamplePredRefLayers (1); // One sample pred ref. layer |
---|
216 | m_acTEncTop[layer].setSamplePredRefLayerId (0, layer - 1); // Previous layer |
---|
217 | m_acTEncTop[layer].setSamplePredEnabledFlag (layer - 1, true); |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | m_acTEncTop[layer].setNumSamplePredRefLayers ( m_acLayerCfg[layer].getNumSamplePredRefLayers() ); |
---|
222 | for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++) |
---|
223 | { |
---|
224 | m_acTEncTop[layer].setSamplePredRefLayerId ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i)); |
---|
225 | m_acTEncTop[layer].setSamplePredEnabledFlag (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true); |
---|
226 | } |
---|
227 | } |
---|
228 | if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1) |
---|
229 | { |
---|
230 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
231 | m_acTEncTop[layer].setNumMotionPredRefLayers (1); // One motion pred ref. layer |
---|
232 | m_acTEncTop[layer].setMotionPredRefLayerId (0, layer - 1); // Previous layer |
---|
233 | m_acTEncTop[layer].setMotionPredEnabledFlag (layer - 1, true); |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | m_acTEncTop[layer].setNumMotionPredRefLayers ( m_acLayerCfg[layer].getNumMotionPredRefLayers() ); |
---|
238 | for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++) |
---|
239 | { |
---|
240 | m_acTEncTop[layer].setMotionPredRefLayerId ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i)); |
---|
241 | m_acTEncTop[layer].setMotionPredEnabledFlag (m_acLayerCfg[layer].getMotionPredRefLayerId(i), true); |
---|
242 | } |
---|
243 | } |
---|
244 | Int numDirectRefLayers = 0; |
---|
245 | for (Int i = 0; i < layer; i++) |
---|
246 | { |
---|
247 | if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i)) |
---|
248 | { |
---|
249 | m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i); |
---|
250 | numDirectRefLayers++; |
---|
251 | } |
---|
252 | } |
---|
253 | m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers); |
---|
254 | #else |
---|
255 | if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1) |
---|
256 | { |
---|
257 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
258 | m_acTEncTop[layer].setNumDirectRefLayers (1); // One ref. layer |
---|
259 | m_acTEncTop[layer].setRefLayerId (0, layer - 1); // Previous layer |
---|
260 | } |
---|
261 | else |
---|
262 | { |
---|
263 | m_acTEncTop[layer].setNumDirectRefLayers ( m_acLayerCfg[layer].getNumDirectRefLayers() ); |
---|
264 | for(Int i = 0; i < m_acTEncTop[layer].getNumDirectRefLayers(); i++) |
---|
265 | { |
---|
266 | m_acTEncTop[layer].setRefLayerId ( i, m_acLayerCfg[layer].getRefLayerId(i)); |
---|
267 | } |
---|
268 | } |
---|
269 | #endif |
---|
270 | if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1) |
---|
271 | { |
---|
272 | #if M0457_PREDICTION_INDICATIONS |
---|
273 | m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() ); |
---|
274 | #else |
---|
275 | m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() ); |
---|
276 | #endif |
---|
277 | for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ ) |
---|
278 | { |
---|
279 | m_acTEncTop[layer].setPredLayerId(i, i); |
---|
280 | } |
---|
281 | } |
---|
282 | else |
---|
283 | { |
---|
284 | m_acTEncTop[layer].setNumActiveRefLayers ( m_acLayerCfg[layer].getNumActiveRefLayers() ); |
---|
285 | for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++) |
---|
286 | { |
---|
287 | m_acTEncTop[layer].setPredLayerId ( i, m_acLayerCfg[layer].getPredLayerId(i)); |
---|
288 | } |
---|
289 | } |
---|
290 | } |
---|
291 | #endif |
---|
292 | //===== Slice ======== |
---|
293 | |
---|
294 | //====== Loop/Deblock Filter ======== |
---|
295 | m_acTEncTop[layer].setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
296 | m_acTEncTop[layer].setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
297 | m_acTEncTop[layer].setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
298 | m_acTEncTop[layer].setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
299 | m_acTEncTop[layer].setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
300 | m_acTEncTop[layer].setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
301 | |
---|
302 | //====== Motion search ======== |
---|
303 | m_acTEncTop[layer].setFastSearch ( m_iFastSearch ); |
---|
304 | m_acTEncTop[layer].setSearchRange ( m_iSearchRange ); |
---|
305 | m_acTEncTop[layer].setBipredSearchRange ( m_bipredSearchRange ); |
---|
306 | |
---|
307 | //====== Quality control ======== |
---|
308 | m_acTEncTop[layer].setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
309 | m_acTEncTop[layer].setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
310 | |
---|
311 | m_acTEncTop[layer].setChromaCbQpOffset ( m_cbQpOffset ); |
---|
312 | m_acTEncTop[layer].setChromaCrQpOffset ( m_crQpOffset ); |
---|
313 | |
---|
314 | #if ADAPTIVE_QP_SELECTION |
---|
315 | m_acTEncTop[layer].setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
316 | #endif |
---|
317 | |
---|
318 | Int lowestQP; |
---|
319 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
320 | |
---|
321 | if ((m_iMaxDeltaQP == 0 ) && (m_acLayerCfg[layer].getIntQP() == lowestQP) && (m_useLossless == true)) |
---|
322 | { |
---|
323 | m_bUseAdaptiveQP = false; |
---|
324 | } |
---|
325 | m_acTEncTop[layer].setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
326 | m_acTEncTop[layer].setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
327 | |
---|
328 | //====== Tool list ======== |
---|
329 | m_acTEncTop[layer].setUseSBACRD ( m_bUseSBACRD ); |
---|
330 | m_acTEncTop[layer].setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
331 | m_acTEncTop[layer].setUseASR ( m_bUseASR ); |
---|
332 | m_acTEncTop[layer].setUseHADME ( m_bUseHADME ); |
---|
333 | m_acTEncTop[layer].setUseLossless ( m_useLossless ); |
---|
334 | m_acTEncTop[layer].setdQPs ( m_acLayerCfg[layer].getdQPs() ); |
---|
335 | m_acTEncTop[layer].setUseRDOQ ( m_useRDOQ ); |
---|
336 | m_acTEncTop[layer].setUseRDOQTS ( m_useRDOQTS ); |
---|
337 | m_acTEncTop[layer].setRDpenalty ( m_rdPenalty ); |
---|
338 | m_acTEncTop[layer].setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
339 | m_acTEncTop[layer].setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
340 | m_acTEncTop[layer].setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
341 | m_acTEncTop[layer].setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
342 | m_acTEncTop[layer].setUseFastEnc ( m_bUseFastEnc ); |
---|
343 | m_acTEncTop[layer].setUseEarlyCU ( m_bUseEarlyCU ); |
---|
344 | m_acTEncTop[layer].setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
345 | m_acTEncTop[layer].setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
346 | m_acTEncTop[layer].setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
347 | #if FAST_INTRA_SHVC |
---|
348 | m_acTEncTop[layer].setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
349 | #endif |
---|
350 | |
---|
351 | m_acTEncTop[layer].setUseTransformSkip ( m_useTransformSkip ); |
---|
352 | m_acTEncTop[layer].setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
353 | m_acTEncTop[layer].setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
354 | m_acTEncTop[layer].setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
355 | m_acTEncTop[layer].setUsePCM ( m_usePCM ); |
---|
356 | m_acTEncTop[layer].setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
357 | m_acTEncTop[layer].setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
358 | |
---|
359 | |
---|
360 | //====== Weighted Prediction ======== |
---|
361 | m_acTEncTop[layer].setUseWP ( m_useWeightedPred ); |
---|
362 | m_acTEncTop[layer].setWPBiPred ( m_useWeightedBiPred ); |
---|
363 | //====== Parallel Merge Estimation ======== |
---|
364 | m_acTEncTop[layer].setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
365 | |
---|
366 | //====== Slice ======== |
---|
367 | m_acTEncTop[layer].setSliceMode ( m_sliceMode ); |
---|
368 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
369 | |
---|
370 | //====== Dependent Slice ======== |
---|
371 | m_acTEncTop[layer].setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
372 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
373 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
374 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
375 | { |
---|
376 | m_acTEncTop[layer].setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
377 | } |
---|
378 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
379 | { |
---|
380 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
381 | } |
---|
382 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
383 | { |
---|
384 | m_acTEncTop[layer].setSliceArgument ( m_sliceArgument ); |
---|
385 | } |
---|
386 | |
---|
387 | if(m_sliceMode == 0 ) |
---|
388 | { |
---|
389 | m_bLFCrossSliceBoundaryFlag = true; |
---|
390 | } |
---|
391 | m_acTEncTop[layer].setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
392 | m_acTEncTop[layer].setUseSAO ( m_bUseSAO ); |
---|
393 | m_acTEncTop[layer].setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
394 | |
---|
395 | m_acTEncTop[layer].setSaoLcuBoundary (m_saoLcuBoundary); |
---|
396 | m_acTEncTop[layer].setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
397 | m_acTEncTop[layer].setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
398 | m_acTEncTop[layer].setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
399 | |
---|
400 | m_acTEncTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
401 | m_acTEncTop[layer].setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
402 | m_acTEncTop[layer].setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
403 | m_acTEncTop[layer].setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
404 | m_acTEncTop[layer].setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
405 | m_acTEncTop[layer].setTMISEIToneMapId ( m_toneMapId ); |
---|
406 | m_acTEncTop[layer].setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
407 | m_acTEncTop[layer].setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
408 | m_acTEncTop[layer].setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
409 | m_acTEncTop[layer].setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
410 | m_acTEncTop[layer].setTMISEIModelID ( m_toneMapModelId ); |
---|
411 | m_acTEncTop[layer].setTMISEIMinValue ( m_toneMapMinValue ); |
---|
412 | m_acTEncTop[layer].setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
413 | m_acTEncTop[layer].setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
414 | m_acTEncTop[layer].setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
415 | m_acTEncTop[layer].setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
416 | m_acTEncTop[layer].setTMISEINumPivots ( m_numPivots ); |
---|
417 | m_acTEncTop[layer].setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
418 | m_acTEncTop[layer].setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
419 | m_acTEncTop[layer].setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
420 | m_acTEncTop[layer].setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
421 | m_acTEncTop[layer].setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
422 | m_acTEncTop[layer].setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
423 | m_acTEncTop[layer].setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
424 | m_acTEncTop[layer].setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
425 | m_acTEncTop[layer].setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
426 | m_acTEncTop[layer].setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
427 | m_acTEncTop[layer].setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
428 | m_acTEncTop[layer].setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
429 | m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
430 | m_acTEncTop[layer].setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
431 | m_acTEncTop[layer].setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
432 | m_acTEncTop[layer].setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
433 | m_acTEncTop[layer].setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
434 | m_acTEncTop[layer].setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
435 | m_acTEncTop[layer].setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
436 | m_acTEncTop[layer].setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
437 | m_acTEncTop[layer].setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
438 | #if M0043_LAYERS_PRESENT_SEI |
---|
439 | m_acTEncTop[layer].setLayersPresentSEIEnabled( m_layersPresentSEIEnabled ); |
---|
440 | #endif |
---|
441 | m_acTEncTop[layer].setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
442 | m_acTEncTop[layer].setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
443 | m_acTEncTop[layer].setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
444 | m_acTEncTop[layer].setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
445 | m_acTEncTop[layer].setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
446 | if(m_iUniformSpacingIdr==0) |
---|
447 | { |
---|
448 | m_acTEncTop[layer].setColumnWidth ( m_pColumnWidth ); |
---|
449 | m_acTEncTop[layer].setRowHeight ( m_pRowHeight ); |
---|
450 | } |
---|
451 | m_acTEncTop[layer].xCheckGSParameters(); |
---|
452 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
453 | if(uiTilesCount == 1) |
---|
454 | { |
---|
455 | m_bLFCrossTileBoundaryFlag = true; |
---|
456 | } |
---|
457 | m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
458 | m_acTEncTop[layer].setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
459 | m_acTEncTop[layer].setWaveFrontSubstreams ( m_acLayerCfg[layer].m_iWaveFrontSubstreams ); |
---|
460 | m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId ); |
---|
461 | m_acTEncTop[layer].setUseScalingListId ( m_useScalingListId ); |
---|
462 | m_acTEncTop[layer].setScalingListFile ( m_scalingListFile ); |
---|
463 | m_acTEncTop[layer].setSignHideFlag(m_signHideFlag); |
---|
464 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
465 | #if RC_SHVC_HARMONIZATION |
---|
466 | m_acTEncTop[layer].setUseRateCtrl (m_acLayerCfg[layer].getRCEnableRateControl()); |
---|
467 | m_acTEncTop[layer].setTargetBitrate (m_acLayerCfg[layer].getRCTargetBitrate()); |
---|
468 | m_acTEncTop[layer].setKeepHierBit (m_acLayerCfg[layer].getRCKeepHierarchicalBit()); |
---|
469 | m_acTEncTop[layer].setLCULevelRC (m_acLayerCfg[layer].getRCLCULevelRC()); |
---|
470 | m_acTEncTop[layer].setUseLCUSeparateModel (m_acLayerCfg[layer].getRCUseLCUSeparateModel()); |
---|
471 | m_acTEncTop[layer].setInitialQP (m_acLayerCfg[layer].getRCInitialQP()); |
---|
472 | m_acTEncTop[layer].setForceIntraQP (m_acLayerCfg[layer].getRCForceIntraQP()); |
---|
473 | #else |
---|
474 | m_acTEncTop[layer].setUseRateCtrl ( m_RCEnableRateControl ); |
---|
475 | m_acTEncTop[layer].setTargetBitrate ( m_RCTargetBitrate ); |
---|
476 | m_acTEncTop[layer].setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
477 | m_acTEncTop[layer].setLCULevelRC ( m_RCLCULevelRC ); |
---|
478 | m_acTEncTop[layer].setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
479 | m_acTEncTop[layer].setInitialQP ( m_RCInitialQP ); |
---|
480 | m_acTEncTop[layer].setForceIntraQP ( m_RCForceIntraQP ); |
---|
481 | #endif |
---|
482 | #else |
---|
483 | m_acTEncTop[layer].setUseRateCtrl ( m_enableRateCtrl); |
---|
484 | m_acTEncTop[layer].setTargetBitrate ( m_targetBitrate); |
---|
485 | m_acTEncTop[layer].setNumLCUInUnit ( m_numLCUInUnit); |
---|
486 | #endif |
---|
487 | m_acTEncTop[layer].setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
488 | m_acTEncTop[layer].setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
489 | m_acTEncTop[layer].setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
490 | m_acTEncTop[layer].setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
491 | m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
492 | m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
493 | m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc ); |
---|
494 | m_acTEncTop[layer].setSarWidth( m_sarWidth ); |
---|
495 | m_acTEncTop[layer].setSarHeight( m_sarHeight ); |
---|
496 | m_acTEncTop[layer].setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
497 | m_acTEncTop[layer].setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
498 | m_acTEncTop[layer].setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
499 | m_acTEncTop[layer].setVideoFormat( m_videoFormat ); |
---|
500 | m_acTEncTop[layer].setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
501 | m_acTEncTop[layer].setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
502 | m_acTEncTop[layer].setColourPrimaries( m_colourPrimaries ); |
---|
503 | m_acTEncTop[layer].setTransferCharacteristics( m_transferCharacteristics ); |
---|
504 | m_acTEncTop[layer].setMatrixCoefficients( m_matrixCoefficients ); |
---|
505 | m_acTEncTop[layer].setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
506 | m_acTEncTop[layer].setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
507 | m_acTEncTop[layer].setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
508 | m_acTEncTop[layer].setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
509 | m_acTEncTop[layer].setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
510 | m_acTEncTop[layer].setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
511 | m_acTEncTop[layer].setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
512 | m_acTEncTop[layer].setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
513 | m_acTEncTop[layer].setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
514 | m_acTEncTop[layer].setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
515 | m_acTEncTop[layer].setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
516 | m_acTEncTop[layer].setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
517 | m_acTEncTop[layer].setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
518 | m_acTEncTop[layer].setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
519 | m_acTEncTop[layer].setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
520 | m_acTEncTop[layer].setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
521 | m_acTEncTop[layer].setElRapSliceTypeB(layer == 0? 0 : m_elRapSliceBEnabled); |
---|
522 | #if SCALED_REF_LAYER_OFFSETS |
---|
523 | if( layer > 0 ) |
---|
524 | { |
---|
525 | m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets ); |
---|
526 | for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++) |
---|
527 | { |
---|
528 | m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i], |
---|
529 | 2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]); |
---|
530 | } |
---|
531 | } |
---|
532 | #endif |
---|
533 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
534 | m_acTEncTop[layer].setAdaptiveResolutionChange( m_adaptiveResolutionChange ); |
---|
535 | #endif |
---|
536 | } |
---|
537 | } |
---|
538 | #else |
---|
539 | Void TAppEncTop::xInitLibCfg() |
---|
540 | { |
---|
541 | TComVPS vps; |
---|
542 | |
---|
543 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
544 | if (m_maxTempLayer == 1) |
---|
545 | { |
---|
546 | vps.setTemporalNestingFlag(true); |
---|
547 | } |
---|
548 | vps.setMaxLayers ( 1 ); |
---|
549 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
550 | { |
---|
551 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
552 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
553 | } |
---|
554 | m_cTEncTop.setVPS(&vps); |
---|
555 | |
---|
556 | m_cTEncTop.setProfile(m_profile); |
---|
557 | m_cTEncTop.setLevel(m_levelTier, m_level); |
---|
558 | m_cTEncTop.setProgressiveSourceFlag(m_progressiveSourceFlag); |
---|
559 | m_cTEncTop.setInterlacedSourceFlag(m_interlacedSourceFlag); |
---|
560 | m_cTEncTop.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); |
---|
561 | m_cTEncTop.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); |
---|
562 | |
---|
563 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
564 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
565 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
566 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
567 | m_cTEncTop.setConformanceWindow ( m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
568 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
569 | |
---|
570 | //====== Coding Structure ======== |
---|
571 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
572 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
573 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
574 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
575 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
576 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
577 | { |
---|
578 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
579 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
580 | } |
---|
581 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
582 | { |
---|
583 | m_cTEncTop.setLambdaModifier( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
584 | } |
---|
585 | m_cTEncTop.setQP ( m_iQP ); |
---|
586 | |
---|
587 | m_cTEncTop.setPad ( m_aiPad ); |
---|
588 | |
---|
589 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
590 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
591 | |
---|
592 | //===== Slice ======== |
---|
593 | |
---|
594 | //====== Loop/Deblock Filter ======== |
---|
595 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
596 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
597 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
598 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
599 | m_cTEncTop.setDeblockingFilterControlPresent( m_DeblockingFilterControlPresent); |
---|
600 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
601 | |
---|
602 | //====== Motion search ======== |
---|
603 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
604 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
605 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
606 | |
---|
607 | //====== Quality control ======== |
---|
608 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
609 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
610 | |
---|
611 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
612 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
613 | |
---|
614 | #if ADAPTIVE_QP_SELECTION |
---|
615 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
616 | #endif |
---|
617 | |
---|
618 | Int lowestQP; |
---|
619 | lowestQP = - 6*(g_bitDepthY - 8); // XXX: check |
---|
620 | |
---|
621 | if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true)) |
---|
622 | { |
---|
623 | m_bUseAdaptiveQP = false; |
---|
624 | } |
---|
625 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
626 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
627 | |
---|
628 | //====== Tool list ======== |
---|
629 | m_cTEncTop.setUseSBACRD ( m_bUseSBACRD ); |
---|
630 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
631 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
632 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
633 | m_cTEncTop.setUseLossless ( m_useLossless ); |
---|
634 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
635 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
636 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
637 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
638 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
639 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
640 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
641 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
642 | m_cTEncTop.setUseFastEnc ( m_bUseFastEnc ); |
---|
643 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
644 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
645 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
646 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
647 | #if FAST_INTRA_SHVC |
---|
648 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
649 | #endif |
---|
650 | |
---|
651 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
652 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
653 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
654 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
655 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
656 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
657 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
658 | |
---|
659 | |
---|
660 | //====== Weighted Prediction ======== |
---|
661 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
662 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
663 | //====== Parallel Merge Estimation ======== |
---|
664 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
665 | |
---|
666 | //====== Slice ======== |
---|
667 | m_cTEncTop.setSliceMode ( m_sliceMode ); |
---|
668 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
669 | |
---|
670 | //====== Dependent Slice ======== |
---|
671 | m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode ); |
---|
672 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
673 | Int iNumPartInCU = 1<<(m_uiMaxCUDepth<<1); |
---|
674 | if(m_sliceSegmentMode==FIXED_NUMBER_OF_LCU) |
---|
675 | { |
---|
676 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument * iNumPartInCU ); |
---|
677 | } |
---|
678 | if(m_sliceMode==FIXED_NUMBER_OF_LCU) |
---|
679 | { |
---|
680 | m_cTEncTop.setSliceArgument ( m_sliceArgument * iNumPartInCU ); |
---|
681 | } |
---|
682 | if(m_sliceMode==FIXED_NUMBER_OF_TILES) |
---|
683 | { |
---|
684 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
685 | } |
---|
686 | |
---|
687 | if(m_sliceMode == 0 ) |
---|
688 | { |
---|
689 | m_bLFCrossSliceBoundaryFlag = true; |
---|
690 | } |
---|
691 | m_cTEncTop.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
692 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
693 | m_cTEncTop.setMaxNumOffsetsPerPic (m_maxNumOffsetsPerPic); |
---|
694 | |
---|
695 | m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary); |
---|
696 | m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization); |
---|
697 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
698 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
699 | |
---|
700 | m_cTEncTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled); |
---|
701 | m_cTEncTop.setRecoveryPointSEIEnabled( m_recoveryPointSEIEnabled ); |
---|
702 | m_cTEncTop.setBufferingPeriodSEIEnabled( m_bufferingPeriodSEIEnabled ); |
---|
703 | m_cTEncTop.setPictureTimingSEIEnabled( m_pictureTimingSEIEnabled ); |
---|
704 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
705 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
706 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
707 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
708 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
709 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
710 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
711 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
712 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
713 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
714 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
715 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
716 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
717 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
718 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
719 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
720 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
721 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
722 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
723 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
724 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
725 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
726 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
727 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
728 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
729 | m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled ); |
---|
730 | m_cTEncTop.setFramePackingArrangementSEIType( m_framePackingSEIType ); |
---|
731 | m_cTEncTop.setFramePackingArrangementSEIId( m_framePackingSEIId ); |
---|
732 | m_cTEncTop.setFramePackingArrangementSEIQuincunx( m_framePackingSEIQuincunx ); |
---|
733 | m_cTEncTop.setFramePackingArrangementSEIInterpretation( m_framePackingSEIInterpretation ); |
---|
734 | m_cTEncTop.setDisplayOrientationSEIAngle( m_displayOrientationSEIAngle ); |
---|
735 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled( m_temporalLevel0IndexSEIEnabled ); |
---|
736 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled( m_gradualDecodingRefreshInfoEnabled ); |
---|
737 | m_cTEncTop.setDecodingUnitInfoSEIEnabled( m_decodingUnitInfoSEIEnabled ); |
---|
738 | #if M0043_LAYERS_PRESENT_SEI |
---|
739 | m_cTEncTop.setLayersPresentSEIEnabled( m_layersPresentSEIEnabled ); |
---|
740 | #endif |
---|
741 | m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled ); |
---|
742 | m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled ); |
---|
743 | m_cTEncTop.setUniformSpacingIdr ( m_iUniformSpacingIdr ); |
---|
744 | m_cTEncTop.setNumColumnsMinus1 ( m_iNumColumnsMinus1 ); |
---|
745 | m_cTEncTop.setNumRowsMinus1 ( m_iNumRowsMinus1 ); |
---|
746 | if(m_iUniformSpacingIdr==0) |
---|
747 | { |
---|
748 | m_cTEncTop.setColumnWidth ( m_pColumnWidth ); |
---|
749 | m_cTEncTop.setRowHeight ( m_pRowHeight ); |
---|
750 | } |
---|
751 | m_cTEncTop.xCheckGSParameters(); |
---|
752 | Int uiTilesCount = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1); |
---|
753 | if(uiTilesCount == 1) |
---|
754 | { |
---|
755 | m_bLFCrossTileBoundaryFlag = true; |
---|
756 | } |
---|
757 | m_cTEncTop.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
758 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
759 | m_cTEncTop.setWaveFrontSubstreams ( m_iWaveFrontSubstreams ); |
---|
760 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
761 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
762 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
763 | m_cTEncTop.setSignHideFlag(m_signHideFlag); |
---|
764 | #if RATE_CONTROL_LAMBDA_DOMAIN |
---|
765 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
766 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
767 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
768 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
769 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
770 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
771 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
772 | #else |
---|
773 | m_cTEncTop.setUseRateCtrl ( m_enableRateCtrl); |
---|
774 | m_cTEncTop.setTargetBitrate ( m_targetBitrate); |
---|
775 | m_cTEncTop.setNumLCUInUnit ( m_numLCUInUnit); |
---|
776 | #endif |
---|
777 | m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag); |
---|
778 | m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue); |
---|
779 | m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda ); |
---|
780 | m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing ); |
---|
781 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
782 | m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag ); |
---|
783 | m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc ); |
---|
784 | m_cTEncTop.setSarWidth( m_sarWidth ); |
---|
785 | m_cTEncTop.setSarHeight( m_sarHeight ); |
---|
786 | m_cTEncTop.setOverscanInfoPresentFlag( m_overscanInfoPresentFlag ); |
---|
787 | m_cTEncTop.setOverscanAppropriateFlag( m_overscanAppropriateFlag ); |
---|
788 | m_cTEncTop.setVideoSignalTypePresentFlag( m_videoSignalTypePresentFlag ); |
---|
789 | m_cTEncTop.setVideoFormat( m_videoFormat ); |
---|
790 | m_cTEncTop.setVideoFullRangeFlag( m_videoFullRangeFlag ); |
---|
791 | m_cTEncTop.setColourDescriptionPresentFlag( m_colourDescriptionPresentFlag ); |
---|
792 | m_cTEncTop.setColourPrimaries( m_colourPrimaries ); |
---|
793 | m_cTEncTop.setTransferCharacteristics( m_transferCharacteristics ); |
---|
794 | m_cTEncTop.setMatrixCoefficients( m_matrixCoefficients ); |
---|
795 | m_cTEncTop.setChromaLocInfoPresentFlag( m_chromaLocInfoPresentFlag ); |
---|
796 | m_cTEncTop.setChromaSampleLocTypeTopField( m_chromaSampleLocTypeTopField ); |
---|
797 | m_cTEncTop.setChromaSampleLocTypeBottomField( m_chromaSampleLocTypeBottomField ); |
---|
798 | m_cTEncTop.setNeutralChromaIndicationFlag( m_neutralChromaIndicationFlag ); |
---|
799 | m_cTEncTop.setDefaultDisplayWindow( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
800 | m_cTEncTop.setFrameFieldInfoPresentFlag( m_frameFieldInfoPresentFlag ); |
---|
801 | m_cTEncTop.setPocProportionalToTimingFlag( m_pocProportionalToTimingFlag ); |
---|
802 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
803 | m_cTEncTop.setBitstreamRestrictionFlag( m_bitstreamRestrictionFlag ); |
---|
804 | m_cTEncTop.setTilesFixedStructureFlag( m_tilesFixedStructureFlag ); |
---|
805 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag( m_motionVectorsOverPicBoundariesFlag ); |
---|
806 | m_cTEncTop.setMinSpatialSegmentationIdc( m_minSpatialSegmentationIdc ); |
---|
807 | m_cTEncTop.setMaxBytesPerPicDenom( m_maxBytesPerPicDenom ); |
---|
808 | m_cTEncTop.setMaxBitsPerMinCuDenom( m_maxBitsPerMinCuDenom ); |
---|
809 | m_cTEncTop.setLog2MaxMvLengthHorizontal( m_log2MaxMvLengthHorizontal ); |
---|
810 | m_cTEncTop.setLog2MaxMvLengthVertical( m_log2MaxMvLengthVertical ); |
---|
811 | } |
---|
812 | #endif |
---|
813 | |
---|
814 | Void TAppEncTop::xCreateLib() |
---|
815 | { |
---|
816 | // Video I/O |
---|
817 | #if SVC_EXTENSION |
---|
818 | // initialize global variables |
---|
819 | initROM(); |
---|
820 | |
---|
821 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
822 | { |
---|
823 | m_acTVideoIOYuvInputFile[layer].open( (Char *)m_acLayerCfg[layer].getInputFile().c_str(), false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
824 | m_acTVideoIOYuvInputFile[layer].skipFrames(m_FrameSkip, m_acLayerCfg[layer].getSourceWidth() - m_acLayerCfg[layer].getPad()[0], m_acLayerCfg[layer].getSourceHeight() - m_acLayerCfg[layer].getPad()[1]); |
---|
825 | |
---|
826 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
827 | { |
---|
828 | m_acTVideoIOYuvReconFile[layer].open((Char *)m_acLayerCfg[layer].getReconFile().c_str(), true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // write mode |
---|
829 | } |
---|
830 | |
---|
831 | m_acTEncTop[layer].create(); |
---|
832 | } |
---|
833 | #else |
---|
834 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepthY, m_inputBitDepthC, m_internalBitDepthY, m_internalBitDepthC ); // read mode |
---|
835 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1]); |
---|
836 | |
---|
837 | if (m_pchReconFile) |
---|
838 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepthY, m_outputBitDepthC, m_internalBitDepthY, m_internalBitDepthC); // write mode |
---|
839 | |
---|
840 | // Neo Decoder |
---|
841 | m_cTEncTop.create(); |
---|
842 | #endif |
---|
843 | } |
---|
844 | |
---|
845 | Void TAppEncTop::xDestroyLib() |
---|
846 | { |
---|
847 | // Video I/O |
---|
848 | #if SVC_EXTENSION |
---|
849 | // destroy ROM |
---|
850 | destroyROM(); |
---|
851 | |
---|
852 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
853 | { |
---|
854 | m_acTVideoIOYuvInputFile[layer].close(); |
---|
855 | m_acTVideoIOYuvReconFile[layer].close(); |
---|
856 | |
---|
857 | m_acTEncTop[layer].destroy(); |
---|
858 | } |
---|
859 | #else |
---|
860 | m_cTVideoIOYuvInputFile.close(); |
---|
861 | m_cTVideoIOYuvReconFile.close(); |
---|
862 | |
---|
863 | // Neo Decoder |
---|
864 | m_cTEncTop.destroy(); |
---|
865 | #endif |
---|
866 | } |
---|
867 | |
---|
868 | Void TAppEncTop::xInitLib() |
---|
869 | { |
---|
870 | #if SVC_EXTENSION |
---|
871 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
872 | { |
---|
873 | m_acTEncTop[layer].init(); |
---|
874 | } |
---|
875 | #if VPS_RENAME |
---|
876 | m_acTEncTop[0].getVPS()->setMaxLayers( m_numLayers ); |
---|
877 | #endif |
---|
878 | #if VPS_EXTN_OP_LAYER_SETS |
---|
879 | TComVPS* vps = m_acTEncTop[0].getVPS(); |
---|
880 | vps->setMaxLayerId(m_numLayers - 1); // Set max-layer ID |
---|
881 | |
---|
882 | vps->setNumLayerSets(m_numLayers); |
---|
883 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
884 | { |
---|
885 | for(Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
886 | { |
---|
887 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
888 | } |
---|
889 | } |
---|
890 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
891 | UInt i = 0, dimIdLen = 0; |
---|
892 | #if AVC_BASE |
---|
893 | vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag); |
---|
894 | #else |
---|
895 | vps->setAvcBaseLayerFlag(false); |
---|
896 | #endif |
---|
897 | vps->setSplittingFlag(false); |
---|
898 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
899 | { |
---|
900 | vps->setScalabilityMask(i, false); |
---|
901 | } |
---|
902 | if(m_numLayers > 1) |
---|
903 | { |
---|
904 | Int scalabilityTypes = 0; |
---|
905 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
906 | { |
---|
907 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
908 | scalabilityTypes += m_scalabilityMask[i]; |
---|
909 | } |
---|
910 | assert( scalabilityTypes == 1 ); |
---|
911 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
912 | } |
---|
913 | else |
---|
914 | { |
---|
915 | vps->setNumScalabilityTypes(0); |
---|
916 | } |
---|
917 | while((1 << dimIdLen) < m_numLayers) |
---|
918 | { |
---|
919 | dimIdLen++; |
---|
920 | } |
---|
921 | vps->setDimensionIdLen(0, dimIdLen); |
---|
922 | vps->setNuhLayerIdPresentFlag(false); |
---|
923 | vps->setLayerIdInNuh(0, 0); |
---|
924 | vps->setLayerIdInVps(0, 0); |
---|
925 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
926 | { |
---|
927 | vps->setLayerIdInNuh(i, i); |
---|
928 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
929 | vps->setDimensionId(i, 0, i); |
---|
930 | } |
---|
931 | #endif |
---|
932 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
933 | #if N0120_MAX_TID_REF_CFG |
---|
934 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
935 | #else |
---|
936 | vps->setMaxTidIlRefPicsPlus1PresentFlag(true); |
---|
937 | #endif |
---|
938 | if (vps->getMaxTidRefPresentFlag()) |
---|
939 | { |
---|
940 | for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ ) |
---|
941 | { |
---|
942 | #if N0120_MAX_TID_REF_CFG |
---|
943 | vps->setMaxSublayerForIlpPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); |
---|
944 | #else |
---|
945 | vps->setMaxSublayerForIlpPlus1(i, vps->getMaxTLayers()+1); |
---|
946 | #endif |
---|
947 | } |
---|
948 | } |
---|
949 | else |
---|
950 | { |
---|
951 | for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ ) |
---|
952 | { |
---|
953 | vps->setMaxSublayerForIlpPlus1(i, 7); |
---|
954 | } |
---|
955 | } |
---|
956 | #endif |
---|
957 | #if ILP_SSH_SIG |
---|
958 | vps->setIlpSshSignalingEnabledFlag(true); |
---|
959 | #endif |
---|
960 | #if VPS_EXTN_PROFILE_INFO |
---|
961 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
962 | for(Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
963 | { |
---|
964 | vps->setProfilePresentFlag(setId, true); |
---|
965 | // Note - may need to be changed for other layer structures. |
---|
966 | *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL()); |
---|
967 | } |
---|
968 | #endif |
---|
969 | // Target output layer |
---|
970 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
971 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
972 | vps->setNumProfileTierLevel(vps->getNumLayerSets()); |
---|
973 | vps->setDefaultOneTargetOutputLayerFlag(true); |
---|
974 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
975 | { |
---|
976 | vps->setProfileLevelTierIdx(i, i); |
---|
977 | vps->setOutputLayerSetIdx(i, i); |
---|
978 | } |
---|
979 | #else |
---|
980 | vps->setNumOutputLayerSets(1); |
---|
981 | Int lsIdx = 1; |
---|
982 | vps->setOutputLayerSetIdx(0, lsIdx); // Because only one layer set |
---|
983 | #endif |
---|
984 | for(Int lsIdx = 1; lsIdx < vps->getNumLayerSets(); lsIdx++) |
---|
985 | { |
---|
986 | // Include the highest layer as output layer |
---|
987 | for(UInt layer=0; layer <= vps->getMaxLayerId() ; layer++) |
---|
988 | { |
---|
989 | if(vps->getLayerIdIncludedFlag(lsIdx, layer)) |
---|
990 | { |
---|
991 | vps->setOutputLayerFlag(lsIdx, layer, layer == (vps->getMaxLayerId())); |
---|
992 | } |
---|
993 | } |
---|
994 | } |
---|
995 | #endif |
---|
996 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
997 | // Direct reference layers |
---|
998 | UInt maxDirectRefLayers = 0; |
---|
999 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1000 | { |
---|
1001 | vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() ); |
---|
1002 | maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) ); |
---|
1003 | |
---|
1004 | for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
1005 | { |
---|
1006 | vps->setRefLayerId( layerCtr, i, m_acTEncTop[layerCtr].getRefLayerId(i) ); |
---|
1007 | } |
---|
1008 | // Set direct dependency flag |
---|
1009 | // Initialize flag to 0 |
---|
1010 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1011 | { |
---|
1012 | vps->setDirectDependencyFlag( layerCtr, refLayerCtr, false ); |
---|
1013 | } |
---|
1014 | for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++) |
---|
1015 | { |
---|
1016 | vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true); |
---|
1017 | } |
---|
1018 | #if M0457_PREDICTION_INDICATIONS |
---|
1019 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
1020 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1021 | { |
---|
1022 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
1023 | { |
---|
1024 | assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr)); |
---|
1025 | vps->setDirectDependencyType( layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) | |
---|
1026 | (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1); |
---|
1027 | } |
---|
1028 | else |
---|
1029 | { |
---|
1030 | vps->setDirectDependencyType( layerCtr, refLayerCtr, 0 ); |
---|
1031 | } |
---|
1032 | } |
---|
1033 | #endif |
---|
1034 | } |
---|
1035 | #endif |
---|
1036 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1037 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
1038 | #endif |
---|
1039 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1040 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
1041 | #endif |
---|
1042 | #else |
---|
1043 | m_cTEncTop.init(); |
---|
1044 | #endif |
---|
1045 | } |
---|
1046 | |
---|
1047 | // ==================================================================================================================== |
---|
1048 | // Public member functions |
---|
1049 | // ==================================================================================================================== |
---|
1050 | |
---|
1051 | /** |
---|
1052 | - create internal class |
---|
1053 | - initialize internal variable |
---|
1054 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1055 | - delete allocated buffers |
---|
1056 | - destroy internal class |
---|
1057 | . |
---|
1058 | */ |
---|
1059 | #if SVC_EXTENSION |
---|
1060 | Void TAppEncTop::encode() |
---|
1061 | { |
---|
1062 | fstream bitstreamFile(m_pBitstreamFile, fstream::binary | fstream::out); |
---|
1063 | if (!bitstreamFile) |
---|
1064 | { |
---|
1065 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pBitstreamFile); |
---|
1066 | exit(EXIT_FAILURE); |
---|
1067 | } |
---|
1068 | |
---|
1069 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
1070 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1071 | |
---|
1072 | // initialize internal class & member variables |
---|
1073 | xInitLibCfg(); |
---|
1074 | xCreateLib(); |
---|
1075 | xInitLib(); |
---|
1076 | |
---|
1077 | // main encoder loop |
---|
1078 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
1079 | Bool bEos = false; |
---|
1080 | |
---|
1081 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1082 | |
---|
1083 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1084 | { |
---|
1085 | // allocate original YUV buffer |
---|
1086 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
1087 | #if SVC_UPSAMPLING |
---|
1088 | pcPicYuvOrg[layer]->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
1089 | #else |
---|
1090 | pcPicYuvOrg->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1091 | #endif |
---|
1092 | } |
---|
1093 | |
---|
1094 | #if AVC_SYNTAX |
---|
1095 | fstream streamSyntaxFile; |
---|
1096 | if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() ) |
---|
1097 | { |
---|
1098 | if( !m_BLSyntaxFile ) |
---|
1099 | { |
---|
1100 | printf( "Wrong base layer syntax input file\n" ); |
---|
1101 | exit(EXIT_FAILURE); |
---|
1102 | } |
---|
1103 | streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary ); |
---|
1104 | if( !streamSyntaxFile.good() ) |
---|
1105 | { |
---|
1106 | printf( "Base layer syntax input reading error\n" ); |
---|
1107 | exit(EXIT_FAILURE); |
---|
1108 | } |
---|
1109 | m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile ); |
---|
1110 | } |
---|
1111 | #endif |
---|
1112 | |
---|
1113 | Bool bFirstFrame = true; |
---|
1114 | while ( !bEos ) |
---|
1115 | { |
---|
1116 | // Read enough frames |
---|
1117 | Bool bFramesReadyToCode = false; |
---|
1118 | while(!bFramesReadyToCode) |
---|
1119 | { |
---|
1120 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1121 | { |
---|
1122 | // get buffers |
---|
1123 | xGetBuffer(pcPicYuvRec, layer); |
---|
1124 | |
---|
1125 | // read input YUV file |
---|
1126 | m_acTVideoIOYuvInputFile[layer].read( pcPicYuvOrg[layer], m_acLayerCfg[layer].getPad() ); |
---|
1127 | |
---|
1128 | if(layer == m_numLayers-1) |
---|
1129 | { |
---|
1130 | // increase number of received frames |
---|
1131 | m_iFrameRcvd++; |
---|
1132 | // check end of file |
---|
1133 | bEos = (m_iFrameRcvd == m_framesToBeEncoded); |
---|
1134 | } |
---|
1135 | |
---|
1136 | m_acTEncTop[layer].encodePrep( pcPicYuvOrg[layer] ); |
---|
1137 | } |
---|
1138 | |
---|
1139 | bFramesReadyToCode = !(!bFirstFrame && ( m_acTEncTop[m_numLayers-1].getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
1140 | } |
---|
1141 | Bool flush = 0; |
---|
1142 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1143 | if (m_acTVideoIOYuvInputFile[m_numLayers-1].isEof()) |
---|
1144 | { |
---|
1145 | flush = true; |
---|
1146 | bEos = true; |
---|
1147 | m_iFrameRcvd--; |
---|
1148 | m_acTEncTop[m_numLayers-1].setFramesToBeEncoded(m_iFrameRcvd); |
---|
1149 | } |
---|
1150 | |
---|
1151 | #if RC_SHVC_HARMONIZATION |
---|
1152 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1153 | { |
---|
1154 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
1155 | { |
---|
1156 | (m_acTEncTop[layer].getRateCtrl())->initRCGOP(m_acTEncTop[layer].getNumPicRcvd()); |
---|
1157 | } |
---|
1158 | } |
---|
1159 | #endif |
---|
1160 | |
---|
1161 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1162 | if (m_adaptiveResolutionChange) |
---|
1163 | { |
---|
1164 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
1165 | { |
---|
1166 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
1167 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
1168 | { |
---|
1169 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
1170 | recPic->setReconstructed(false); |
---|
1171 | } |
---|
1172 | } |
---|
1173 | } |
---|
1174 | #endif |
---|
1175 | |
---|
1176 | // loop through frames in one GOP |
---|
1177 | for ( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
1178 | { |
---|
1179 | // layer by layer for each frame |
---|
1180 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1181 | { |
---|
1182 | // call encoding function for one frame |
---|
1183 | m_acTEncTop[layer].encode( flush ? 0 : pcPicYuvOrg[layer], m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
1184 | } |
---|
1185 | } |
---|
1186 | |
---|
1187 | #if RC_SHVC_HARMONIZATION |
---|
1188 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1189 | { |
---|
1190 | if ( m_acTEncTop[layer].getUseRateCtrl() ) |
---|
1191 | { |
---|
1192 | (m_acTEncTop[layer].getRateCtrl())->destroyRCGOP(); |
---|
1193 | } |
---|
1194 | } |
---|
1195 | #endif |
---|
1196 | |
---|
1197 | iTotalNumEncoded = 0; |
---|
1198 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1199 | { |
---|
1200 | // write bistream to file if necessary |
---|
1201 | iNumEncoded = m_acTEncTop[layer].getNumPicRcvd(); |
---|
1202 | if ( iNumEncoded > 0 ) |
---|
1203 | { |
---|
1204 | xWriteRecon(layer, iNumEncoded); |
---|
1205 | iTotalNumEncoded += iNumEncoded; |
---|
1206 | } |
---|
1207 | m_acTEncTop[layer].setNumPicRcvd( 0 ); |
---|
1208 | } |
---|
1209 | |
---|
1210 | // write bitstream out |
---|
1211 | if(iTotalNumEncoded) |
---|
1212 | { |
---|
1213 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
1214 | outputAccessUnits.clear(); |
---|
1215 | } |
---|
1216 | |
---|
1217 | // print out summary |
---|
1218 | if (bEos) |
---|
1219 | { |
---|
1220 | printOutSummary(); |
---|
1221 | } |
---|
1222 | |
---|
1223 | bFirstFrame = false; |
---|
1224 | } |
---|
1225 | // delete original YUV buffer |
---|
1226 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1227 | { |
---|
1228 | pcPicYuvOrg[layer]->destroy(); |
---|
1229 | delete pcPicYuvOrg[layer]; |
---|
1230 | pcPicYuvOrg[layer] = NULL; |
---|
1231 | |
---|
1232 | // delete used buffers in encoder class |
---|
1233 | m_acTEncTop[layer].deletePicBuffer(); |
---|
1234 | } |
---|
1235 | |
---|
1236 | #if AVC_SYNTAX |
---|
1237 | if( streamSyntaxFile.is_open() ) |
---|
1238 | { |
---|
1239 | streamSyntaxFile.close(); |
---|
1240 | } |
---|
1241 | #endif |
---|
1242 | |
---|
1243 | // delete buffers & classes |
---|
1244 | xDeleteBuffer(); |
---|
1245 | xDestroyLib(); |
---|
1246 | |
---|
1247 | printRateSummary(); |
---|
1248 | |
---|
1249 | return; |
---|
1250 | } |
---|
1251 | |
---|
1252 | Void TAppEncTop::printOutSummary() |
---|
1253 | { |
---|
1254 | UInt layer; |
---|
1255 | |
---|
1256 | // set frame rate |
---|
1257 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1258 | { |
---|
1259 | m_gcAnalyzeAll[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate()); |
---|
1260 | m_gcAnalyzeI[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1261 | m_gcAnalyzeP[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1262 | m_gcAnalyzeB[layer].setFrmRate( m_acLayerCfg[layer].getFrameRate() ); |
---|
1263 | } |
---|
1264 | |
---|
1265 | //-- all |
---|
1266 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
1267 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1268 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1269 | { |
---|
1270 | m_gcAnalyzeAll[layer].printOut('a', layer); |
---|
1271 | } |
---|
1272 | |
---|
1273 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
1274 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1275 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1276 | { |
---|
1277 | m_gcAnalyzeI[layer].printOut('i', layer); |
---|
1278 | } |
---|
1279 | |
---|
1280 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
1281 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1282 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1283 | { |
---|
1284 | m_gcAnalyzeP[layer].printOut('p', layer); |
---|
1285 | } |
---|
1286 | |
---|
1287 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
1288 | printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); |
---|
1289 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1290 | { |
---|
1291 | m_gcAnalyzeB[layer].printOut('b', layer); |
---|
1292 | } |
---|
1293 | } |
---|
1294 | |
---|
1295 | #else |
---|
1296 | Void TAppEncTop::encode() |
---|
1297 | { |
---|
1298 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1299 | if (!bitstreamFile) |
---|
1300 | { |
---|
1301 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1302 | exit(EXIT_FAILURE); |
---|
1303 | } |
---|
1304 | |
---|
1305 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
1306 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1307 | |
---|
1308 | // initialize internal class & member variables |
---|
1309 | xInitLibCfg(); |
---|
1310 | xCreateLib(); |
---|
1311 | xInitLib(); |
---|
1312 | |
---|
1313 | // main encoder loop |
---|
1314 | Int iNumEncoded = 0; |
---|
1315 | Bool bEos = false; |
---|
1316 | |
---|
1317 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1318 | |
---|
1319 | // allocate original YUV buffer |
---|
1320 | pcPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1321 | |
---|
1322 | while ( !bEos ) |
---|
1323 | { |
---|
1324 | // get buffers |
---|
1325 | xGetBuffer(pcPicYuvRec); |
---|
1326 | |
---|
1327 | // read input YUV file |
---|
1328 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, m_aiPad ); |
---|
1329 | |
---|
1330 | // increase number of received frames |
---|
1331 | m_iFrameRcvd++; |
---|
1332 | |
---|
1333 | bEos = (m_iFrameRcvd == m_framesToBeEncoded); |
---|
1334 | |
---|
1335 | Bool flush = 0; |
---|
1336 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1337 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
1338 | { |
---|
1339 | flush = true; |
---|
1340 | bEos = true; |
---|
1341 | m_iFrameRcvd--; |
---|
1342 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
1343 | } |
---|
1344 | |
---|
1345 | // call encoding function for one frame |
---|
1346 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
1347 | |
---|
1348 | // write bistream to file if necessary |
---|
1349 | if ( iNumEncoded > 0 ) |
---|
1350 | { |
---|
1351 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
1352 | outputAccessUnits.clear(); |
---|
1353 | } |
---|
1354 | } |
---|
1355 | |
---|
1356 | m_cTEncTop.printSummary(); |
---|
1357 | |
---|
1358 | // delete original YUV buffer |
---|
1359 | pcPicYuvOrg->destroy(); |
---|
1360 | delete pcPicYuvOrg; |
---|
1361 | pcPicYuvOrg = NULL; |
---|
1362 | |
---|
1363 | // delete used buffers in encoder class |
---|
1364 | m_cTEncTop.deletePicBuffer(); |
---|
1365 | |
---|
1366 | // delete buffers & classes |
---|
1367 | xDeleteBuffer(); |
---|
1368 | xDestroyLib(); |
---|
1369 | |
---|
1370 | printRateSummary(); |
---|
1371 | |
---|
1372 | return; |
---|
1373 | } |
---|
1374 | #endif |
---|
1375 | |
---|
1376 | // ==================================================================================================================== |
---|
1377 | // Protected member functions |
---|
1378 | // ==================================================================================================================== |
---|
1379 | |
---|
1380 | /** |
---|
1381 | - application has picture buffer list with size of GOP |
---|
1382 | - picture buffer list acts as ring buffer |
---|
1383 | - end of the list has the latest picture |
---|
1384 | . |
---|
1385 | */ |
---|
1386 | #if SVC_EXTENSION |
---|
1387 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
1388 | { |
---|
1389 | assert( m_iGOPSize > 0 ); |
---|
1390 | |
---|
1391 | // org. buffer |
---|
1392 | if ( m_acListPicYuvRec[layer].size() == (UInt)m_iGOPSize ) |
---|
1393 | { |
---|
1394 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
1395 | |
---|
1396 | } |
---|
1397 | else |
---|
1398 | { |
---|
1399 | rpcPicYuvRec = new TComPicYuv; |
---|
1400 | |
---|
1401 | #if SVC_UPSAMPLING |
---|
1402 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth, NULL ); |
---|
1403 | #else |
---|
1404 | rpcPicYuvRec->create( m_acLayerCfg[layer].getSourceWidth(), m_acLayerCfg[layer].getSourceHeight(), m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1405 | #endif |
---|
1406 | |
---|
1407 | } |
---|
1408 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
1409 | } |
---|
1410 | |
---|
1411 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1412 | { |
---|
1413 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1414 | { |
---|
1415 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
1416 | |
---|
1417 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
1418 | |
---|
1419 | for ( Int i = 0; i < iSize; i++ ) |
---|
1420 | { |
---|
1421 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1422 | pcPicYuvRec->destroy(); |
---|
1423 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
1424 | } |
---|
1425 | } |
---|
1426 | } |
---|
1427 | |
---|
1428 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
1429 | { |
---|
1430 | Int i; |
---|
1431 | |
---|
1432 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
1433 | |
---|
1434 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1435 | { |
---|
1436 | --iterPicYuvRec; |
---|
1437 | } |
---|
1438 | |
---|
1439 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1440 | { |
---|
1441 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1442 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1443 | if (!m_acLayerCfg[layer].getReconFile().empty() && pcPicYuvRec->isReconstructed()) |
---|
1444 | #else |
---|
1445 | if (!m_acLayerCfg[layer].getReconFile().empty()) |
---|
1446 | #endif |
---|
1447 | { |
---|
1448 | m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), |
---|
1449 | m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() ); |
---|
1450 | } |
---|
1451 | } |
---|
1452 | } |
---|
1453 | |
---|
1454 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
1455 | { |
---|
1456 | Int i; |
---|
1457 | |
---|
1458 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1459 | |
---|
1460 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1461 | for ( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
1462 | #else |
---|
1463 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1464 | #endif |
---|
1465 | { |
---|
1466 | const AccessUnit& au = *(iterBitstream++); |
---|
1467 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
1468 | rateStatsAccum(au, stats); |
---|
1469 | } |
---|
1470 | } |
---|
1471 | |
---|
1472 | #else // SVC_EXTENSION |
---|
1473 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
1474 | { |
---|
1475 | assert( m_iGOPSize > 0 ); |
---|
1476 | |
---|
1477 | // org. buffer |
---|
1478 | if ( m_cListPicYuvRec.size() == (UInt)m_iGOPSize ) |
---|
1479 | { |
---|
1480 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
1481 | |
---|
1482 | } |
---|
1483 | else |
---|
1484 | { |
---|
1485 | rpcPicYuvRec = new TComPicYuv; |
---|
1486 | |
---|
1487 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); |
---|
1488 | |
---|
1489 | } |
---|
1490 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
1491 | } |
---|
1492 | |
---|
1493 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1494 | { |
---|
1495 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
1496 | |
---|
1497 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
1498 | |
---|
1499 | for ( Int i = 0; i < iSize; i++ ) |
---|
1500 | { |
---|
1501 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1502 | pcPicYuvRec->destroy(); |
---|
1503 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
1504 | } |
---|
1505 | |
---|
1506 | } |
---|
1507 | |
---|
1508 | /** \param iNumEncoded number of encoded frames |
---|
1509 | */ |
---|
1510 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
1511 | { |
---|
1512 | Int i; |
---|
1513 | |
---|
1514 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
1515 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1516 | |
---|
1517 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1518 | { |
---|
1519 | --iterPicYuvRec; |
---|
1520 | } |
---|
1521 | |
---|
1522 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1523 | { |
---|
1524 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1525 | if (m_pchReconFile) |
---|
1526 | { |
---|
1527 | #if SYNTAX_OUTPUT |
---|
1528 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom ); |
---|
1529 | #endif |
---|
1530 | } |
---|
1531 | |
---|
1532 | const AccessUnit& au = *(iterBitstream++); |
---|
1533 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
1534 | rateStatsAccum(au, stats); |
---|
1535 | } |
---|
1536 | } |
---|
1537 | #endif |
---|
1538 | |
---|
1539 | /** |
---|
1540 | * |
---|
1541 | */ |
---|
1542 | void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
1543 | { |
---|
1544 | AccessUnit::const_iterator it_au = au.begin(); |
---|
1545 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
1546 | |
---|
1547 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
1548 | { |
---|
1549 | switch ((*it_au)->m_nalUnitType) |
---|
1550 | { |
---|
1551 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1552 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1553 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
1554 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1555 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1556 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1557 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1558 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1559 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1560 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1561 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1562 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1563 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1564 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1565 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1566 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1567 | case NAL_UNIT_VPS: |
---|
1568 | case NAL_UNIT_SPS: |
---|
1569 | case NAL_UNIT_PPS: |
---|
1570 | m_essentialBytes += *it_stats; |
---|
1571 | break; |
---|
1572 | default: |
---|
1573 | break; |
---|
1574 | } |
---|
1575 | |
---|
1576 | m_totalBytes += *it_stats; |
---|
1577 | } |
---|
1578 | } |
---|
1579 | |
---|
1580 | void TAppEncTop::printRateSummary() |
---|
1581 | { |
---|
1582 | #if SVC_EXTENSION |
---|
1583 | Double time = (Double) m_iFrameRcvd / m_acLayerCfg[m_numLayers-1].getFrameRate(); |
---|
1584 | #else |
---|
1585 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
1586 | #endif |
---|
1587 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
1588 | #if VERBOSE_RATE |
---|
1589 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
1590 | #endif |
---|
1591 | } |
---|
1592 | |
---|
1593 | //! \} |
---|