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