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-2015, 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 | #if !SVC_EXTENSION |
---|
45 | #include <iomanip> |
---|
46 | #endif |
---|
47 | |
---|
48 | #include "TAppEncTop.h" |
---|
49 | #include "TLibEncoder/AnnexBwrite.h" |
---|
50 | |
---|
51 | using namespace std; |
---|
52 | |
---|
53 | //! \ingroup TAppEncoder |
---|
54 | //! \{ |
---|
55 | |
---|
56 | // ==================================================================================================================== |
---|
57 | // Constructor / destructor / initialization / destroy |
---|
58 | // ==================================================================================================================== |
---|
59 | |
---|
60 | TAppEncTop::TAppEncTop() |
---|
61 | { |
---|
62 | m_iFrameRcvd = 0; |
---|
63 | m_totalBytes = 0; |
---|
64 | m_essentialBytes = 0; |
---|
65 | #if SVC_EXTENSION |
---|
66 | memset( m_apcTVideoIOYuvInputFile, NULL, sizeof(m_apcTVideoIOYuvInputFile) ); |
---|
67 | memset( m_apcTVideoIOYuvReconFile, NULL, sizeof(m_apcTVideoIOYuvReconFile) ); |
---|
68 | memset( m_apcTEncTop, NULL, sizeof(m_apcTEncTop) ); |
---|
69 | #endif |
---|
70 | } |
---|
71 | |
---|
72 | TAppEncTop::~TAppEncTop() |
---|
73 | { |
---|
74 | } |
---|
75 | |
---|
76 | Void TAppEncTop::xInitLibCfg() |
---|
77 | { |
---|
78 | #if SVC_EXTENSION |
---|
79 | TComVPS& vps = *m_apcTEncTop[0]->getVPS(); |
---|
80 | #else |
---|
81 | TComVPS vps; |
---|
82 | #endif |
---|
83 | |
---|
84 | vps.setMaxTLayers ( m_maxTempLayer ); |
---|
85 | if (m_maxTempLayer == 1) |
---|
86 | { |
---|
87 | vps.setTemporalNestingFlag(true); |
---|
88 | } |
---|
89 | vps.setMaxLayers ( 1 ); |
---|
90 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
91 | { |
---|
92 | vps.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
93 | vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
94 | } |
---|
95 | |
---|
96 | #if !SVC_EXTENSION |
---|
97 | m_cTEncTop.setVPS(&vps); |
---|
98 | #endif |
---|
99 | |
---|
100 | #if SVC_EXTENSION |
---|
101 | vps.setVpsPocLsbAlignedFlag(false); |
---|
102 | |
---|
103 | Int maxRepFormatIdx = -1; |
---|
104 | Int formatIdx = -1; |
---|
105 | for(UInt layer=0; layer < m_numLayers; layer++) |
---|
106 | { |
---|
107 | // Auto generation of the format index |
---|
108 | if( m_apcLayerCfg[layer]->getRepFormatIdx() == -1 ) |
---|
109 | { |
---|
110 | Bool found = false; |
---|
111 | for( UInt idx = 0; idx < layer; idx++ ) |
---|
112 | { |
---|
113 | if( m_apcLayerCfg[layer]->getSourceWidth() == m_apcLayerCfg[idx]->getSourceWidth() && m_apcLayerCfg[layer]->getSourceHeight() == m_apcLayerCfg[idx]->getSourceHeight() |
---|
114 | #if AUXILIARY_PICTURES |
---|
115 | && m_apcLayerCfg[layer]->getChromaFormatIDC() == m_apcLayerCfg[idx]->getChromaFormatIDC() |
---|
116 | #endif |
---|
117 | && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_LUMA] && m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA] == m_apcLayerCfg[idx]->m_internalBitDepth[CHANNEL_TYPE_CHROMA] |
---|
118 | ) |
---|
119 | { |
---|
120 | found = true; |
---|
121 | break; |
---|
122 | } |
---|
123 | } |
---|
124 | if( !found ) |
---|
125 | { |
---|
126 | formatIdx++; |
---|
127 | } |
---|
128 | |
---|
129 | m_apcLayerCfg[layer]->setRepFormatIdx( formatIdx ); |
---|
130 | } |
---|
131 | |
---|
132 | assert( m_apcLayerCfg[layer]->getRepFormatIdx() != -1 && "RepFormatIdx not assigned for a layer" ); |
---|
133 | |
---|
134 | vps.setVpsRepFormatIdx( layer, m_apcLayerCfg[layer]->getRepFormatIdx() ); |
---|
135 | |
---|
136 | maxRepFormatIdx = std::max( m_apcLayerCfg[layer]->getRepFormatIdx(), maxRepFormatIdx ); |
---|
137 | } |
---|
138 | |
---|
139 | assert( vps.getVpsRepFormatIdx( 0 ) == 0 ); // Base layer should point to the first one. |
---|
140 | |
---|
141 | Int* mapIdxToLayer = new Int[maxRepFormatIdx + 1]; |
---|
142 | |
---|
143 | // Check that all the indices from 0 to maxRepFormatIdx are used in the VPS |
---|
144 | for(Int i = 0; i <= maxRepFormatIdx; i++) |
---|
145 | { |
---|
146 | mapIdxToLayer[i] = -1; |
---|
147 | UInt layer; |
---|
148 | for(layer=0; layer < m_numLayers; layer++) |
---|
149 | { |
---|
150 | if( vps.getVpsRepFormatIdx(layer) == i ) |
---|
151 | { |
---|
152 | mapIdxToLayer[i] = layer; |
---|
153 | break; |
---|
154 | } |
---|
155 | } |
---|
156 | assert( layer != m_numLayers ); // One of the VPS Rep format indices not set |
---|
157 | } |
---|
158 | |
---|
159 | vps.setVpsNumRepFormats ( maxRepFormatIdx + 1 ); |
---|
160 | |
---|
161 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
162 | vps.setRepFormatIdxPresentFlag ( vps.getVpsNumRepFormats() > 1 ? true : false ); |
---|
163 | |
---|
164 | for(UInt idx=0; idx < vps.getVpsNumRepFormats(); idx++) |
---|
165 | { |
---|
166 | RepFormat *repFormat = vps.getVpsRepFormat( idx ); |
---|
167 | repFormat->setChromaAndBitDepthVpsPresentFlag ( true ); |
---|
168 | if (idx==0) |
---|
169 | { |
---|
170 | assert(repFormat->getChromaAndBitDepthVpsPresentFlag() == true); |
---|
171 | } |
---|
172 | |
---|
173 | repFormat->setPicWidthVpsInLumaSamples ( m_apcLayerCfg[mapIdxToLayer[idx]]->getSourceWidth() ); |
---|
174 | repFormat->setPicHeightVpsInLumaSamples ( m_apcLayerCfg[mapIdxToLayer[idx]]->getSourceHeight() ); |
---|
175 | #if AUXILIARY_PICTURES |
---|
176 | repFormat->setChromaFormatVpsIdc ( m_apcLayerCfg[mapIdxToLayer[idx]]->getChromaFormatIDC() ); |
---|
177 | #else |
---|
178 | repFormat->setChromaFormatVpsIdc ( 1 ); // Need modification to change for each layer - corresponds to 420 |
---|
179 | #endif |
---|
180 | repFormat->setSeparateColourPlaneVpsFlag ( 0 ); // Need modification to change for each layer |
---|
181 | |
---|
182 | repFormat->setBitDepthVpsLuma ( getInternalBitDepth(mapIdxToLayer[idx], CHANNEL_TYPE_LUMA) ); // Need modification to change for each layer |
---|
183 | repFormat->setBitDepthVpsChroma ( getInternalBitDepth(mapIdxToLayer[idx], CHANNEL_TYPE_CHROMA) ); // Need modification to change for each layer |
---|
184 | |
---|
185 | repFormat->getConformanceWindowVps().setWindow ( m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinLeft, |
---|
186 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinRight, |
---|
187 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinTop, |
---|
188 | m_apcLayerCfg[mapIdxToLayer[idx]]->m_confWinBottom ); |
---|
189 | |
---|
190 | m_apcTEncTop[mapIdxToLayer[idx]]->setSkipPictureAtArcSwitch ( m_skipPictureAtArcSwitch ); |
---|
191 | } |
---|
192 | |
---|
193 | delete [] mapIdxToLayer; |
---|
194 | |
---|
195 | //Populate PTL in VPS |
---|
196 | for( Int ii = 0; ii < m_numPTLInfo; ii++ ) |
---|
197 | { |
---|
198 | vps.getPTL(ii)->getGeneralPTL()->setLevelIdc(m_levelList[ii]); |
---|
199 | vps.getPTL(ii)->getGeneralPTL()->setTierFlag(m_levelTierList[ii]); |
---|
200 | vps.getPTL(ii)->getGeneralPTL()->setProfileIdc(m_profileList[ii]); |
---|
201 | vps.getPTL(ii)->getGeneralPTL()->setProfileCompatibilityFlag(m_profileCompatibility[ii], 1); |
---|
202 | vps.getPTL(ii)->getGeneralPTL()->setProgressiveSourceFlag(m_progressiveSourceFlagList[ii]); |
---|
203 | vps.getPTL(ii)->getGeneralPTL()->setInterlacedSourceFlag(m_interlacedSourceFlagList[ii]); |
---|
204 | vps.getPTL(ii)->getGeneralPTL()->setNonPackedConstraintFlag(m_nonPackedConstraintFlagList[ii]); |
---|
205 | vps.getPTL(ii)->getGeneralPTL()->setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlagList[ii]); |
---|
206 | } |
---|
207 | vps.setNumProfileTierLevel(m_numPTLInfo); |
---|
208 | |
---|
209 | std::vector<Int> myvector; |
---|
210 | vps.getProfileLevelTierIdx()->resize(m_numOutputLayerSets); |
---|
211 | for( Int ii = 0; ii < m_numOutputLayerSets; ii++ ) |
---|
212 | { |
---|
213 | myvector = m_listOfLayerPTLofOlss[ii]; |
---|
214 | |
---|
215 | for( std::vector<Int>::iterator it = myvector.begin() ; it != myvector.end(); ++it ) |
---|
216 | { |
---|
217 | vps.addProfileLevelTierIdx(ii, it[0]); |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | assert( m_numLayers <= MAX_LAYERS ); |
---|
222 | |
---|
223 | for( UInt layer=0; layer < m_numLayers; layer++ ) |
---|
224 | { |
---|
225 | TEncTop& m_cTEncTop = *m_apcTEncTop[layer]; |
---|
226 | //1 |
---|
227 | m_cTEncTop.setInterLayerWeightedPredFlag ( m_useInterLayerWeightedPred ); |
---|
228 | m_cTEncTop.setMFMEnabledFlag ( layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_apcLayerCfg[layer]->getNumMotionPredRefLayers()); |
---|
229 | |
---|
230 | // set layer ID |
---|
231 | m_cTEncTop.setLayerId ( m_apcLayerCfg[layer]->m_layerId ); |
---|
232 | m_cTEncTop.setNumLayer ( m_numLayers ); |
---|
233 | m_cTEncTop.setLayerEnc ( m_apcTEncTop ); |
---|
234 | |
---|
235 | if( layer < m_numLayers - 1 ) |
---|
236 | { |
---|
237 | m_cTEncTop.setMaxTidIlRefPicsPlus1 ( m_apcLayerCfg[layer]->getMaxTidIlRefPicsPlus1()); |
---|
238 | } |
---|
239 | |
---|
240 | if( layer ) |
---|
241 | { |
---|
242 | UInt prevLayerIdx = 0; |
---|
243 | UInt prevLayerId = 0; |
---|
244 | if (m_apcLayerCfg[layer]->getNumActiveRefLayers() > 0) |
---|
245 | { |
---|
246 | prevLayerIdx = m_apcLayerCfg[layer]->getPredLayerIdx(m_apcLayerCfg[layer]->getNumActiveRefLayers() - 1); |
---|
247 | prevLayerId = m_cTEncTop.getRefLayerId(prevLayerIdx); |
---|
248 | } |
---|
249 | for(Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1; i++) |
---|
250 | { |
---|
251 | m_cTEncTop.setSamplePredEnabledFlag (i, false); |
---|
252 | m_cTEncTop.setMotionPredEnabledFlag (i, false); |
---|
253 | } |
---|
254 | if(m_apcLayerCfg[layer]->getNumSamplePredRefLayers() == -1) |
---|
255 | { |
---|
256 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
257 | m_cTEncTop.setNumSamplePredRefLayers (1); // One sample pred ref. layer |
---|
258 | m_cTEncTop.setSamplePredRefLayerId (prevLayerIdx, prevLayerId); // Previous layer |
---|
259 | m_cTEncTop.setSamplePredEnabledFlag (prevLayerIdx, true); |
---|
260 | } |
---|
261 | else |
---|
262 | { |
---|
263 | m_cTEncTop.setNumSamplePredRefLayers ( m_apcLayerCfg[layer]->getNumSamplePredRefLayers() ); |
---|
264 | for( Int i = 0; i < m_cTEncTop.getNumSamplePredRefLayers(); i++ ) |
---|
265 | { |
---|
266 | m_cTEncTop.setSamplePredRefLayerId ( i, m_apcLayerCfg[layer]->getSamplePredRefLayerId(i)); |
---|
267 | } |
---|
268 | } |
---|
269 | if( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() == -1) |
---|
270 | { |
---|
271 | // Not included in the configuration file; assume that each layer depends on previous layer |
---|
272 | m_cTEncTop.setNumMotionPredRefLayers (1); // One motion pred ref. layer |
---|
273 | m_cTEncTop.setMotionPredRefLayerId (prevLayerIdx, prevLayerId); // Previous layer |
---|
274 | m_cTEncTop.setMotionPredEnabledFlag (prevLayerIdx, true); |
---|
275 | } |
---|
276 | else |
---|
277 | { |
---|
278 | m_cTEncTop.setNumMotionPredRefLayers ( m_apcLayerCfg[layer]->getNumMotionPredRefLayers() ); |
---|
279 | for( Int i = 0; i < m_cTEncTop.getNumMotionPredRefLayers(); i++ ) |
---|
280 | { |
---|
281 | m_cTEncTop.setMotionPredRefLayerId ( i, m_apcLayerCfg[layer]->getMotionPredRefLayerId(i)); |
---|
282 | } |
---|
283 | } |
---|
284 | Int numDirectRefLayers = 0; |
---|
285 | |
---|
286 | assert( layer < MAX_LAYERS ); |
---|
287 | |
---|
288 | for (Int i = 0; i < m_apcLayerCfg[layer]->m_layerId; i++) |
---|
289 | { |
---|
290 | Int refLayerId = -1; |
---|
291 | |
---|
292 | for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumSamplePredRefLayers(); layerIdc++ ) |
---|
293 | { |
---|
294 | if( m_apcLayerCfg[layer]->getSamplePredRefLayerId(layerIdc) == i ) |
---|
295 | { |
---|
296 | refLayerId = i; |
---|
297 | m_cTEncTop.setSamplePredEnabledFlag( numDirectRefLayers, true ); |
---|
298 | break; |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | for( Int layerIdc = 0; layerIdc < m_cTEncTop.getNumMotionPredRefLayers(); layerIdc++ ) |
---|
303 | { |
---|
304 | if( m_apcLayerCfg[layer]->getMotionPredRefLayerId(layerIdc) == i ) |
---|
305 | { |
---|
306 | refLayerId = i; |
---|
307 | m_cTEncTop.setMotionPredEnabledFlag( numDirectRefLayers, true ); |
---|
308 | break; |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | if( refLayerId >= 0 ) |
---|
313 | { |
---|
314 | m_cTEncTop.setRefLayerId ( numDirectRefLayers, refLayerId ); |
---|
315 | numDirectRefLayers++; |
---|
316 | } |
---|
317 | } |
---|
318 | |
---|
319 | m_cTEncTop.setNumDirectRefLayers ( numDirectRefLayers ); |
---|
320 | |
---|
321 | if(m_apcLayerCfg[layer]->getNumActiveRefLayers() == -1) |
---|
322 | { |
---|
323 | m_cTEncTop.setNumActiveRefLayers ( m_cTEncTop.getNumDirectRefLayers() ); |
---|
324 | for( Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++ ) |
---|
325 | { |
---|
326 | m_cTEncTop.setPredLayerIdx(i, i); |
---|
327 | } |
---|
328 | } |
---|
329 | else |
---|
330 | { |
---|
331 | m_cTEncTop.setNumActiveRefLayers ( m_apcLayerCfg[layer]->getNumActiveRefLayers() ); |
---|
332 | for(Int i = 0; i < m_cTEncTop.getNumActiveRefLayers(); i++) |
---|
333 | { |
---|
334 | m_cTEncTop.setPredLayerIdx ( i, m_apcLayerCfg[layer]->getPredLayerIdx(i)); |
---|
335 | } |
---|
336 | } |
---|
337 | } |
---|
338 | else |
---|
339 | { |
---|
340 | assert( layer == 0 ); |
---|
341 | m_cTEncTop.setNumDirectRefLayers(0); |
---|
342 | } |
---|
343 | |
---|
344 | if( layer > 0 ) |
---|
345 | { |
---|
346 | #if AUXILIARY_PICTURES |
---|
347 | Int subWidthC = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1; |
---|
348 | Int subHeightC = ( m_apcLayerCfg[layer]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1; |
---|
349 | #else |
---|
350 | Int subWidthC = 2; |
---|
351 | Int subHeightC = 2; |
---|
352 | #endif |
---|
353 | m_cTEncTop.setNumRefLayerLocationOffsets ( m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets ); |
---|
354 | for(Int i = 0; i < m_apcLayerCfg[layer]->m_numRefLayerLocationOffsets; i++) |
---|
355 | { |
---|
356 | m_cTEncTop.setRefLocationOffsetLayerId ( i, m_apcLayerCfg[layer]->m_refLocationOffsetLayerId[i]); |
---|
357 | m_cTEncTop.setScaledRefLayerOffsetPresentFlag ( i, m_apcLayerCfg[layer]->m_scaledRefLayerOffsetPresentFlag[i] ); |
---|
358 | m_cTEncTop.getScaledRefLayerWindow(i).setWindow ( subWidthC * m_apcLayerCfg[layer]->m_scaledRefLayerLeftOffset[i], subWidthC * m_apcLayerCfg[layer]->m_scaledRefLayerRightOffset[i], |
---|
359 | subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerTopOffset[i], subHeightC * m_apcLayerCfg[layer]->m_scaledRefLayerBottomOffset[i]); |
---|
360 | |
---|
361 | Int rlSubWidthC = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 || m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_422 ) ? 2 : 1; |
---|
362 | Int rlSubHeightC = ( m_apcLayerCfg[i]->m_chromaFormatIDC == CHROMA_420 ) ? 2 : 1; |
---|
363 | |
---|
364 | m_cTEncTop.setRefRegionOffsetPresentFlag ( i, m_apcLayerCfg[layer]->m_refRegionOffsetPresentFlag[i] ); |
---|
365 | m_cTEncTop.getRefLayerWindow(i).setWindow ( rlSubWidthC * m_apcLayerCfg[layer]->m_refRegionLeftOffset[i], rlSubWidthC * m_apcLayerCfg[layer]->m_refRegionRightOffset[i], |
---|
366 | rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionTopOffset[i], rlSubHeightC * m_apcLayerCfg[layer]->m_refRegionBottomOffset[i]); |
---|
367 | m_cTEncTop.setResamplePhaseSetPresentFlag ( i, m_apcLayerCfg[layer]->m_resamplePhaseSetPresentFlag[i] ); |
---|
368 | m_cTEncTop.setPhaseHorLuma ( i, m_apcLayerCfg[layer]->m_phaseHorLuma[i] ); |
---|
369 | m_cTEncTop.setPhaseVerLuma ( i, m_apcLayerCfg[layer]->m_phaseVerLuma[i] ); |
---|
370 | m_cTEncTop.setPhaseHorChroma ( i, m_apcLayerCfg[layer]->m_phaseHorChroma[i] ); |
---|
371 | m_cTEncTop.setPhaseVerChroma ( i, m_apcLayerCfg[layer]->m_phaseVerChroma[i] ); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | m_cTEncTop.setAdaptiveResolutionChange ( m_adaptiveResolutionChange ); |
---|
376 | m_cTEncTop.setLayerSwitchOffBegin ( m_apcLayerCfg[layer]->m_layerSwitchOffBegin ); |
---|
377 | m_cTEncTop.setLayerSwitchOffEnd ( m_apcLayerCfg[layer]->m_layerSwitchOffEnd ); |
---|
378 | m_cTEncTop.setChromaFormatIDC ( m_apcLayerCfg[layer]->m_chromaFormatIDC ); |
---|
379 | m_cTEncTop.setAltOuputLayerFlag ( m_altOutputLayerFlag ); |
---|
380 | m_cTEncTop.setCrossLayerBLAFlag ( m_crossLayerBLAFlag ); |
---|
381 | #if CGS_3D_ASYMLUT |
---|
382 | m_cTEncTop.setCGSFlag ( layer == 0 ? 0 : m_nCGSFlag ); |
---|
383 | m_cTEncTop.setCGSMaxOctantDepth ( m_nCGSMaxOctantDepth ); |
---|
384 | m_cTEncTop.setCGSMaxYPartNumLog2 ( m_nCGSMaxYPartNumLog2 ); |
---|
385 | m_cTEncTop.setCGSLUTBit ( m_nCGSLUTBit ); |
---|
386 | m_cTEncTop.setCGSAdaptChroma ( m_nCGSAdaptiveChroma ); |
---|
387 | #if R0179_ENC_OPT_3DLUT_SIZE |
---|
388 | m_cTEncTop.setCGSLutSizeRDO ( m_nCGSLutSizeRDO ); |
---|
389 | #endif |
---|
390 | #endif |
---|
391 | m_cTEncTop.setNumAddLayerSets ( m_numAddLayerSets ); |
---|
392 | |
---|
393 | #if P0123_ALPHA_CHANNEL_SEI |
---|
394 | m_cTEncTop.setAlphaSEIEnabled ( m_alphaSEIEnabled ); |
---|
395 | m_cTEncTop.setAlphaCancelFlag ( m_alphaCancelFlag ); |
---|
396 | m_cTEncTop.setAlphaUseIdc ( m_alphaUseIdc ); |
---|
397 | m_cTEncTop.setAlphaBitDepthMinus8 ( m_alphaBitDepthMinus8 ); |
---|
398 | m_cTEncTop.setAlphaTransparentValue ( m_alphaTransparentValue ); |
---|
399 | m_cTEncTop.setAlphaOpaqueValue ( m_alphaOpaqueValue ); |
---|
400 | m_cTEncTop.setAlphaIncrementFlag ( m_alphaIncrementFlag ); |
---|
401 | m_cTEncTop.setAlphaClipFlag ( m_alphaClipFlag ); |
---|
402 | m_cTEncTop.setAlphaClipTypeFlag ( m_alphaClipTypeFlag ); |
---|
403 | #endif |
---|
404 | #if Q0096_OVERLAY_SEI |
---|
405 | m_cTEncTop.setOverlaySEIEnabled ( m_overlaySEIEnabled ); |
---|
406 | m_cTEncTop.setOverlaySEICancelFlag ( m_overlayInfoCancelFlag ); |
---|
407 | m_cTEncTop.setOverlaySEIContentAuxIdMinus128 ( m_overlayContentAuxIdMinus128 ); |
---|
408 | m_cTEncTop.setOverlaySEILabelAuxIdMinus128 ( m_overlayLabelAuxIdMinus128 ); |
---|
409 | m_cTEncTop.setOverlaySEIAlphaAuxIdMinus128 ( m_overlayAlphaAuxIdMinus128 ); |
---|
410 | m_cTEncTop.setOverlaySEIElementLabelValueLengthMinus8 ( m_overlayElementLabelValueLengthMinus8 ); |
---|
411 | m_cTEncTop.setOverlaySEINumOverlaysMinus1 ( m_numOverlaysMinus1 ); |
---|
412 | m_cTEncTop.setOverlaySEIIdx ( m_overlayIdx ); |
---|
413 | m_cTEncTop.setOverlaySEILanguagePresentFlag ( m_overlayLanguagePresentFlag ); |
---|
414 | m_cTEncTop.setOverlaySEIContentLayerId ( m_overlayContentLayerId ); |
---|
415 | m_cTEncTop.setOverlaySEILabelPresentFlag ( m_overlayLabelPresentFlag ); |
---|
416 | m_cTEncTop.setOverlaySEILabelLayerId ( m_overlayLabelLayerId ); |
---|
417 | m_cTEncTop.setOverlaySEIAlphaPresentFlag ( m_overlayAlphaPresentFlag ); |
---|
418 | m_cTEncTop.setOverlaySEIAlphaLayerId ( m_overlayAlphaLayerId ); |
---|
419 | m_cTEncTop.setOverlaySEINumElementsMinus1 ( m_numOverlayElementsMinus1 ); |
---|
420 | m_cTEncTop.setOverlaySEIElementLabelMin ( m_overlayElementLabelMin ); |
---|
421 | m_cTEncTop.setOverlaySEIElementLabelMax ( m_overlayElementLabelMax ); |
---|
422 | m_cTEncTop.setOverlaySEILanguage ( m_overlayLanguage ); |
---|
423 | m_cTEncTop.setOverlaySEIName ( m_overlayName ); |
---|
424 | m_cTEncTop.setOverlaySEIElementName ( m_overlayElementName ); |
---|
425 | m_cTEncTop.setOverlaySEIPersistenceFlag ( m_overlayInfoPersistenceFlag ); |
---|
426 | #endif |
---|
427 | #if Q0189_TMVP_CONSTRAINTS |
---|
428 | m_cTEncTop.setTMVPConstraintsSEIEnabled ( m_TMVPConstraintsSEIEnabled); |
---|
429 | #endif |
---|
430 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
431 | m_cTEncTop.setInterLayerConstrainedTileSetsSEIEnabled ( m_interLayerConstrainedTileSetsSEIEnabled ); |
---|
432 | m_cTEncTop.setIlNumSetsInMessage ( m_ilNumSetsInMessage ); |
---|
433 | m_cTEncTop.setSkippedTileSetPresentFlag ( m_skippedTileSetPresentFlag ); |
---|
434 | m_cTEncTop.setTopLeftTileIndex ( m_topLeftTileIndex ); |
---|
435 | m_cTEncTop.setBottomRightTileIndex ( m_bottomRightTileIndex ); |
---|
436 | m_cTEncTop.setIlcIdc ( m_ilcIdc ); |
---|
437 | #endif |
---|
438 | |
---|
439 | Int layerPTLIdx = m_apcLayerCfg[layer]->m_layerPTLIdx; |
---|
440 | |
---|
441 | Profile::Name m_profile = m_profileList[layerPTLIdx]; |
---|
442 | Level::Tier m_levelTier = m_levelTierList[layerPTLIdx]; |
---|
443 | Level::Name m_level = m_levelList[layerPTLIdx]; |
---|
444 | UInt m_bitDepthConstraint = m_apcLayerCfg[layer]->m_bitDepthConstraint; |
---|
445 | ChromaFormat m_chromaFormatConstraint = m_apcLayerCfg[layer]->m_chromaFormatConstraint; |
---|
446 | Bool m_intraConstraintFlag = m_apcLayerCfg[layer]->m_intraConstraintFlag; |
---|
447 | Bool m_onePictureOnlyConstraintFlag = m_apcLayerCfg[layer]->m_onePictureOnlyConstraintFlag; |
---|
448 | Bool m_lowerBitRateConstraintFlag = m_apcLayerCfg[layer]->m_lowerBitRateConstraintFlag; |
---|
449 | Bool m_progressiveSourceFlag = m_progressiveSourceFlagList[layerPTLIdx]; |
---|
450 | Bool m_interlacedSourceFlag = m_interlacedSourceFlagList[layerPTLIdx]; |
---|
451 | Bool m_nonPackedConstraintFlag = m_nonPackedConstraintFlagList[layerPTLIdx]; |
---|
452 | Bool m_frameOnlyConstraintFlag = m_frameOnlyConstraintFlagList[layerPTLIdx]; |
---|
453 | |
---|
454 | Int m_iFrameRate = m_apcLayerCfg[layer]->getFrameRate(); |
---|
455 | Int m_iSourceWidth = m_apcLayerCfg[layer]->getSourceWidth(); |
---|
456 | Int m_iSourceHeight = m_apcLayerCfg[layer]->getSourceHeight(); |
---|
457 | Int m_confWinLeft = m_apcLayerCfg[layer]->m_confWinLeft; |
---|
458 | Int m_confWinRight = m_apcLayerCfg[layer]->m_confWinRight; |
---|
459 | Int m_confWinTop = m_apcLayerCfg[layer]->m_confWinTop; |
---|
460 | Int m_confWinBottom = m_apcLayerCfg[layer]->m_confWinBottom; |
---|
461 | |
---|
462 | Int m_iIntraPeriod = m_apcLayerCfg[layer]->m_iIntraPeriod; |
---|
463 | Int m_iQP = m_apcLayerCfg[layer]->getIntQP(); |
---|
464 | Int *m_aiPad = m_apcLayerCfg[layer]->getPad(); |
---|
465 | |
---|
466 | Int m_iMaxCuDQPDepth = m_apcLayerCfg[layer]->m_iMaxCuDQPDepth; |
---|
467 | ChromaFormat m_chromaFormatIDC = m_apcLayerCfg[layer]->m_chromaFormatIDC; |
---|
468 | Bool m_extendedPrecisionProcessingFlag = m_apcLayerCfg[layer]->m_extendedPrecisionProcessingFlag; |
---|
469 | Bool m_highPrecisionOffsetsEnabledFlag = m_apcLayerCfg[layer]->m_highPrecisionOffsetsEnabledFlag; |
---|
470 | Int *m_aidQP = m_apcLayerCfg[layer]->getdQPs(); |
---|
471 | |
---|
472 | UInt m_uiMaxCUWidth = m_apcLayerCfg[layer]->m_uiMaxCUWidth; |
---|
473 | UInt m_uiMaxCUHeight = m_apcLayerCfg[layer]->m_uiMaxCUHeight; |
---|
474 | UInt m_uiMaxTotalCUDepth = m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth; |
---|
475 | UInt m_uiLog2DiffMaxMinCodingBlockSize = m_apcLayerCfg[layer]->m_uiLog2DiffMaxMinCodingBlockSize; |
---|
476 | UInt m_uiQuadtreeTULog2MaxSize = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MaxSize; |
---|
477 | UInt m_uiQuadtreeTULog2MinSize = m_apcLayerCfg[layer]->m_uiQuadtreeTULog2MinSize; |
---|
478 | UInt m_uiQuadtreeTUMaxDepthInter = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthInter; |
---|
479 | UInt m_uiQuadtreeTUMaxDepthIntra = m_apcLayerCfg[layer]->m_uiQuadtreeTUMaxDepthIntra; |
---|
480 | |
---|
481 | Int m_iWaveFrontSynchro = m_apcLayerCfg[layer]->m_waveFrontSynchro; |
---|
482 | Bool m_RCEnableRateControl = m_apcLayerCfg[layer]->getRCEnableRateControl(); |
---|
483 | Int m_RCTargetBitrate = m_apcLayerCfg[layer]->getRCTargetBitrate(); |
---|
484 | Bool m_RCKeepHierarchicalBit = m_apcLayerCfg[layer]->getRCKeepHierarchicalBit(); |
---|
485 | Bool m_RCLCULevelRC = m_apcLayerCfg[layer]->getRCLCULevelRC(); |
---|
486 | Bool m_RCUseLCUSeparateModel = m_apcLayerCfg[layer]->getRCUseLCUSeparateModel(); |
---|
487 | Int m_RCInitialQP = m_apcLayerCfg[layer]->getRCInitialQP(); |
---|
488 | Bool m_RCForceIntraQP = m_apcLayerCfg[layer]->getRCForceIntraQP(); |
---|
489 | |
---|
490 | ScalingListMode m_useScalingListId = m_apcLayerCfg[layer]->m_useScalingListId; |
---|
491 | Char* m_scalingListFile = m_apcLayerCfg[layer]->m_scalingListFile; |
---|
492 | #endif |
---|
493 | |
---|
494 | m_cTEncTop.setProfile ( m_profile); |
---|
495 | m_cTEncTop.setLevel ( m_levelTier, m_level); |
---|
496 | m_cTEncTop.setProgressiveSourceFlag ( m_progressiveSourceFlag); |
---|
497 | m_cTEncTop.setInterlacedSourceFlag ( m_interlacedSourceFlag); |
---|
498 | m_cTEncTop.setNonPackedConstraintFlag ( m_nonPackedConstraintFlag); |
---|
499 | m_cTEncTop.setFrameOnlyConstraintFlag ( m_frameOnlyConstraintFlag); |
---|
500 | m_cTEncTop.setBitDepthConstraintValue ( m_bitDepthConstraint ); |
---|
501 | m_cTEncTop.setChromaFormatConstraintValue ( m_chromaFormatConstraint ); |
---|
502 | m_cTEncTop.setIntraConstraintFlag ( m_intraConstraintFlag ); |
---|
503 | m_cTEncTop.setOnePictureOnlyConstraintFlag ( m_onePictureOnlyConstraintFlag ); |
---|
504 | m_cTEncTop.setLowerBitRateConstraintFlag ( m_lowerBitRateConstraintFlag ); |
---|
505 | |
---|
506 | m_cTEncTop.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR); |
---|
507 | m_cTEncTop.setPrintFrameMSE ( m_printFrameMSE); |
---|
508 | m_cTEncTop.setPrintSequenceMSE ( m_printSequenceMSE); |
---|
509 | m_cTEncTop.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled ); |
---|
510 | |
---|
511 | m_cTEncTop.setFrameRate ( m_iFrameRate ); |
---|
512 | m_cTEncTop.setFrameSkip ( m_FrameSkip ); |
---|
513 | m_cTEncTop.setSourceWidth ( m_iSourceWidth ); |
---|
514 | m_cTEncTop.setSourceHeight ( m_iSourceHeight ); |
---|
515 | m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom ); |
---|
516 | m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded ); |
---|
517 | |
---|
518 | //====== Coding Structure ======== |
---|
519 | m_cTEncTop.setIntraPeriod ( m_iIntraPeriod ); |
---|
520 | m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType ); |
---|
521 | m_cTEncTop.setGOPSize ( m_iGOPSize ); |
---|
522 | #if SVC_EXTENSION |
---|
523 | m_cTEncTop.setGopList ( layer ? m_EhGOPList[layer] : m_GOPList ); |
---|
524 | m_cTEncTop.setExtraRPSs ( m_extraRPSs[layer] ); |
---|
525 | #else |
---|
526 | m_cTEncTop.setGopList ( m_GOPList ); |
---|
527 | m_cTEncTop.setExtraRPSs ( m_extraRPSs ); |
---|
528 | #endif |
---|
529 | |
---|
530 | for(Int i = 0; i < MAX_TLAYER; i++) |
---|
531 | { |
---|
532 | m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i ); |
---|
533 | m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i ); |
---|
534 | } |
---|
535 | for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop ) |
---|
536 | { |
---|
537 | m_cTEncTop.setLambdaModifier ( uiLoop, m_adLambdaModifier[ uiLoop ] ); |
---|
538 | } |
---|
539 | m_cTEncTop.setIntraLambdaModifier ( m_adIntraLambdaModifier ); |
---|
540 | m_cTEncTop.setIntraQpFactor ( m_dIntraQpFactor ); |
---|
541 | |
---|
542 | m_cTEncTop.setQP ( m_iQP ); |
---|
543 | |
---|
544 | m_cTEncTop.setPad ( m_aiPad ); |
---|
545 | |
---|
546 | #if SVC_EXTENSION |
---|
547 | m_cTEncTop.setMaxTempLayer ( layer ? m_EhMaxTempLayer[layer] : m_maxTempLayer ); |
---|
548 | #else |
---|
549 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
550 | #endif |
---|
551 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
552 | |
---|
553 | //===== Slice ======== |
---|
554 | |
---|
555 | //====== Loop/Deblock Filter ======== |
---|
556 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
557 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
558 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
559 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
560 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
561 | |
---|
562 | //====== Motion search ======== |
---|
563 | m_cTEncTop.setDisableIntraPUsInInterSlices ( m_bDisableIntraPUsInInterSlices ); |
---|
564 | m_cTEncTop.setFastSearch ( m_iFastSearch ); |
---|
565 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
566 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
567 | m_cTEncTop.setClipForBiPredMeEnabled ( m_bClipForBiPredMeEnabled ); |
---|
568 | m_cTEncTop.setFastMEAssumingSmootherMVEnabled ( m_bFastMEAssumingSmootherMVEnabled ); |
---|
569 | m_cTEncTop.setMinSearchWindow ( m_minSearchWindow ); |
---|
570 | |
---|
571 | //====== Quality control ======== |
---|
572 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
573 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
574 | m_cTEncTop.setDiffCuChromaQpOffsetDepth ( m_diffCuChromaQpOffsetDepth ); |
---|
575 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
576 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
577 | |
---|
578 | m_cTEncTop.setChromaFormatIdc ( m_chromaFormatIDC ); |
---|
579 | |
---|
580 | #if ADAPTIVE_QP_SELECTION |
---|
581 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
582 | #endif |
---|
583 | |
---|
584 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
585 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
586 | m_cTEncTop.setExtendedPrecisionProcessingFlag ( m_extendedPrecisionProcessingFlag ); |
---|
587 | m_cTEncTop.setHighPrecisionOffsetsEnabledFlag ( m_highPrecisionOffsetsEnabledFlag ); |
---|
588 | |
---|
589 | m_cTEncTop.setWeightedPredictionMethod( m_weightedPredictionMethod ); |
---|
590 | |
---|
591 | //====== Tool list ======== |
---|
592 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
593 | m_cTEncTop.setFastDeltaQp ( m_bFastDeltaQP ); |
---|
594 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
595 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
596 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
597 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
598 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
599 | #if T0196_SELECTIVE_RDOQ |
---|
600 | m_cTEncTop.setUseSelectiveRDOQ ( m_useSelectiveRDOQ ); |
---|
601 | #endif |
---|
602 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
603 | m_cTEncTop.setMaxCUWidth ( m_uiMaxCUWidth ); |
---|
604 | m_cTEncTop.setMaxCUHeight ( m_uiMaxCUHeight ); |
---|
605 | m_cTEncTop.setMaxTotalCUDepth ( m_uiMaxTotalCUDepth ); |
---|
606 | m_cTEncTop.setLog2DiffMaxMinCodingBlockSize ( m_uiLog2DiffMaxMinCodingBlockSize ); |
---|
607 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
608 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
609 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
610 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
611 | m_cTEncTop.setFastInterSearchMode ( m_fastInterSearchMode ); |
---|
612 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
613 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
614 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
615 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
616 | m_cTEncTop.setCrossComponentPredictionEnabledFlag ( m_crossComponentPredictionEnabledFlag ); |
---|
617 | m_cTEncTop.setUseReconBasedCrossCPredictionEstimate ( m_reconBasedCrossCPredictionEstimate ); |
---|
618 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_LUMA , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] ); |
---|
619 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
---|
620 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
621 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
622 | m_cTEncTop.setTransformSkipRotationEnabledFlag ( m_transformSkipRotationEnabledFlag ); |
---|
623 | m_cTEncTop.setTransformSkipContextEnabledFlag ( m_transformSkipContextEnabledFlag ); |
---|
624 | m_cTEncTop.setPersistentRiceAdaptationEnabledFlag ( m_persistentRiceAdaptationEnabledFlag ); |
---|
625 | m_cTEncTop.setCabacBypassAlignmentEnabledFlag ( m_cabacBypassAlignmentEnabledFlag ); |
---|
626 | m_cTEncTop.setLog2MaxTransformSkipBlockSize ( m_log2MaxTransformSkipBlockSize ); |
---|
627 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
628 | { |
---|
629 | m_cTEncTop.setRdpcmEnabledFlag ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
---|
630 | } |
---|
631 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
632 | m_cTEncTop.setFastUDIUseMPMEnabled ( m_bFastUDIUseMPMEnabled ); |
---|
633 | m_cTEncTop.setFastMEForGenBLowDelayEnabled ( m_bFastMEForGenBLowDelayEnabled ); |
---|
634 | m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures ( m_bUseBLambdaForNonKeyLowDelayPictures ); |
---|
635 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
636 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
637 | |
---|
638 | // set internal bit-depth and constants |
---|
639 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
---|
640 | { |
---|
641 | #if SVC_EXTENSION |
---|
642 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
---|
643 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[channelType] : m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
---|
644 | #else |
---|
645 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]); |
---|
646 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]); |
---|
647 | #endif |
---|
648 | } |
---|
649 | |
---|
650 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
651 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
652 | |
---|
653 | |
---|
654 | //====== Weighted Prediction ======== |
---|
655 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
656 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
657 | //====== Parallel Merge Estimation ======== |
---|
658 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
659 | |
---|
660 | //====== Slice ======== |
---|
661 | m_cTEncTop.setSliceMode ( (SliceConstraint) m_sliceMode ); |
---|
662 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
663 | |
---|
664 | //====== Dependent Slice ======== |
---|
665 | m_cTEncTop.setSliceSegmentMode ( (SliceConstraint) m_sliceSegmentMode ); |
---|
666 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
667 | |
---|
668 | if(m_sliceMode == NO_SLICES ) |
---|
669 | { |
---|
670 | m_bLFCrossSliceBoundaryFlag = true; |
---|
671 | } |
---|
672 | m_cTEncTop.setLFCrossSliceBoundaryFlag ( m_bLFCrossSliceBoundaryFlag ); |
---|
673 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
674 | m_cTEncTop.setTestSAODisableAtPictureLevel ( m_bTestSAODisableAtPictureLevel ); |
---|
675 | m_cTEncTop.setSaoEncodingRate ( m_saoEncodingRate ); |
---|
676 | m_cTEncTop.setSaoEncodingRateChroma ( m_saoEncodingRateChroma ); |
---|
677 | m_cTEncTop.setMaxNumOffsetsPerPic ( m_maxNumOffsetsPerPic); |
---|
678 | |
---|
679 | m_cTEncTop.setSaoCtuBoundary ( m_saoCtuBoundary); |
---|
680 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
681 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
682 | |
---|
683 | m_cTEncTop.setIntraSmoothingDisabledFlag (!m_enableIntraReferenceSmoothing ); |
---|
684 | m_cTEncTop.setDecodedPictureHashSEIEnabled ( m_decodedPictureHashSEIEnabled ); |
---|
685 | m_cTEncTop.setRecoveryPointSEIEnabled ( m_recoveryPointSEIEnabled ); |
---|
686 | m_cTEncTop.setBufferingPeriodSEIEnabled ( m_bufferingPeriodSEIEnabled ); |
---|
687 | m_cTEncTop.setPictureTimingSEIEnabled ( m_pictureTimingSEIEnabled ); |
---|
688 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
689 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
690 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
691 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
692 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
693 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
694 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
695 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
696 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
697 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
698 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
699 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
700 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
701 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
702 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
703 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
704 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
705 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
706 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
707 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
708 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
709 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
710 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
711 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
712 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
713 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
714 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
715 | m_cTEncTop.setChromaSamplingFilterHintEnabled ( m_chromaSamplingFilterSEIenabled ); |
---|
716 | m_cTEncTop.setChromaSamplingHorFilterIdc ( m_chromaSamplingHorFilterIdc ); |
---|
717 | m_cTEncTop.setChromaSamplingVerFilterIdc ( m_chromaSamplingVerFilterIdc ); |
---|
718 | m_cTEncTop.setFramePackingArrangementSEIEnabled ( m_framePackingSEIEnabled ); |
---|
719 | m_cTEncTop.setFramePackingArrangementSEIType ( m_framePackingSEIType ); |
---|
720 | m_cTEncTop.setFramePackingArrangementSEIId ( m_framePackingSEIId ); |
---|
721 | m_cTEncTop.setFramePackingArrangementSEIQuincunx ( m_framePackingSEIQuincunx ); |
---|
722 | m_cTEncTop.setFramePackingArrangementSEIInterpretation ( m_framePackingSEIInterpretation ); |
---|
723 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled ( m_segmentedRectFramePackingSEIEnabled ); |
---|
724 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel ( m_segmentedRectFramePackingSEICancel ); |
---|
725 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType ( m_segmentedRectFramePackingSEIType ); |
---|
726 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence ); |
---|
727 | m_cTEncTop.setDisplayOrientationSEIAngle ( m_displayOrientationSEIAngle ); |
---|
728 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled ( m_temporalLevel0IndexSEIEnabled ); |
---|
729 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled ( m_gradualDecodingRefreshInfoEnabled ); |
---|
730 | m_cTEncTop.setNoDisplaySEITLayer ( m_noDisplaySEITLayer ); |
---|
731 | m_cTEncTop.setDecodingUnitInfoSEIEnabled ( m_decodingUnitInfoSEIEnabled ); |
---|
732 | m_cTEncTop.setSOPDescriptionSEIEnabled ( m_SOPDescriptionSEIEnabled ); |
---|
733 | m_cTEncTop.setScalableNestingSEIEnabled ( m_scalableNestingSEIEnabled ); |
---|
734 | m_cTEncTop.setTMCTSSEIEnabled ( m_tmctsSEIEnabled ); |
---|
735 | m_cTEncTop.setTimeCodeSEIEnabled ( m_timeCodeSEIEnabled ); |
---|
736 | m_cTEncTop.setNumberOfTimeSets ( m_timeCodeSEINumTs ); |
---|
737 | for(Int i = 0; i < m_timeCodeSEINumTs; i++) |
---|
738 | { |
---|
739 | m_cTEncTop.setTimeSet(m_timeSetArray[i], i); |
---|
740 | } |
---|
741 | m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
742 | m_cTEncTop.setKneeSEIId ( m_kneeSEIId ); |
---|
743 | m_cTEncTop.setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
744 | m_cTEncTop.setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
745 | m_cTEncTop.setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
746 | m_cTEncTop.setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
747 | m_cTEncTop.setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
748 | m_cTEncTop.setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
749 | m_cTEncTop.setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
750 | m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
751 | m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
752 | m_cTEncTop.setMasteringDisplaySEI ( m_masteringDisplay ); |
---|
753 | |
---|
754 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
755 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
756 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
757 | if(!m_tileUniformSpacingFlag) |
---|
758 | { |
---|
759 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
760 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
761 | } |
---|
762 | m_cTEncTop.xCheckGSParameters(); |
---|
763 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
764 | if(uiTilesCount == 1) |
---|
765 | { |
---|
766 | m_bLFCrossTileBoundaryFlag = true; |
---|
767 | } |
---|
768 | m_cTEncTop.setLFCrossTileBoundaryFlag ( m_bLFCrossTileBoundaryFlag ); |
---|
769 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
770 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
771 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
772 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
773 | m_cTEncTop.setSignHideFlag ( m_signHideFlag); |
---|
774 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
775 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
776 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
777 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
778 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
779 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
780 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
781 | m_cTEncTop.setTransquantBypassEnableFlag ( m_TransquantBypassEnableFlag ); |
---|
782 | m_cTEncTop.setCUTransquantBypassFlagForceValue ( m_CUTransquantBypassFlagForce ); |
---|
783 | m_cTEncTop.setCostMode ( m_costMode ); |
---|
784 | m_cTEncTop.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); |
---|
785 | m_cTEncTop.setUseStrongIntraSmoothing ( m_useStrongIntraSmoothing ); |
---|
786 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
787 | m_cTEncTop.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag ); |
---|
788 | m_cTEncTop.setAspectRatioInfoPresentFlag ( m_aspectRatioInfoPresentFlag); |
---|
789 | m_cTEncTop.setAspectRatioIdc ( m_aspectRatioIdc ); |
---|
790 | m_cTEncTop.setSarWidth ( m_sarWidth ); |
---|
791 | m_cTEncTop.setSarHeight ( m_sarHeight ); |
---|
792 | m_cTEncTop.setOverscanInfoPresentFlag ( m_overscanInfoPresentFlag ); |
---|
793 | m_cTEncTop.setOverscanAppropriateFlag ( m_overscanAppropriateFlag ); |
---|
794 | m_cTEncTop.setVideoSignalTypePresentFlag ( m_videoSignalTypePresentFlag ); |
---|
795 | m_cTEncTop.setVideoFormat ( m_videoFormat ); |
---|
796 | m_cTEncTop.setVideoFullRangeFlag ( m_videoFullRangeFlag ); |
---|
797 | m_cTEncTop.setColourDescriptionPresentFlag ( m_colourDescriptionPresentFlag ); |
---|
798 | m_cTEncTop.setColourPrimaries ( m_colourPrimaries ); |
---|
799 | m_cTEncTop.setTransferCharacteristics ( m_transferCharacteristics ); |
---|
800 | m_cTEncTop.setMatrixCoefficients ( m_matrixCoefficients ); |
---|
801 | m_cTEncTop.setChromaLocInfoPresentFlag ( m_chromaLocInfoPresentFlag ); |
---|
802 | m_cTEncTop.setChromaSampleLocTypeTopField ( m_chromaSampleLocTypeTopField ); |
---|
803 | m_cTEncTop.setChromaSampleLocTypeBottomField ( m_chromaSampleLocTypeBottomField ); |
---|
804 | m_cTEncTop.setNeutralChromaIndicationFlag ( m_neutralChromaIndicationFlag ); |
---|
805 | m_cTEncTop.setDefaultDisplayWindow ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
806 | m_cTEncTop.setFrameFieldInfoPresentFlag ( m_frameFieldInfoPresentFlag ); |
---|
807 | m_cTEncTop.setPocProportionalToTimingFlag ( m_pocProportionalToTimingFlag ); |
---|
808 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
809 | m_cTEncTop.setBitstreamRestrictionFlag ( m_bitstreamRestrictionFlag ); |
---|
810 | m_cTEncTop.setTilesFixedStructureFlag ( m_tilesFixedStructureFlag ); |
---|
811 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag ( m_motionVectorsOverPicBoundariesFlag ); |
---|
812 | m_cTEncTop.setMinSpatialSegmentationIdc ( m_minSpatialSegmentationIdc ); |
---|
813 | m_cTEncTop.setMaxBytesPerPicDenom ( m_maxBytesPerPicDenom ); |
---|
814 | m_cTEncTop.setMaxBitsPerMinCuDenom ( m_maxBitsPerMinCuDenom ); |
---|
815 | m_cTEncTop.setLog2MaxMvLengthHorizontal ( m_log2MaxMvLengthHorizontal ); |
---|
816 | m_cTEncTop.setLog2MaxMvLengthVertical ( m_log2MaxMvLengthVertical ); |
---|
817 | m_cTEncTop.setEfficientFieldIRAPEnabled ( m_bEfficientFieldIRAPEnabled ); |
---|
818 | m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled ( m_bHarmonizeGopFirstFieldCoupleEnabled ); |
---|
819 | |
---|
820 | m_cTEncTop.setSummaryOutFilename ( m_summaryOutFilename ); |
---|
821 | m_cTEncTop.setSummaryPicFilenameBase ( m_summaryPicFilenameBase ); |
---|
822 | m_cTEncTop.setSummaryVerboseness ( m_summaryVerboseness ); |
---|
823 | |
---|
824 | #if FAST_INTRA_SHVC |
---|
825 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
826 | #endif |
---|
827 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
828 | #if SVC_EXTENSION |
---|
829 | m_cTEncTop.setCRISEIFileRoot ( const_cast<Char*>(m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot.c_str()) ); |
---|
830 | #else |
---|
831 | m_cTEncTop.setCRISEIFileRoot ( const_cast<Char*>(m_colourRemapSEIFileRoot.c_str()) ); |
---|
832 | #endif |
---|
833 | #endif |
---|
834 | #if LAYERS_NOT_PRESENT_SEI |
---|
835 | m_cTEncTop.setLayersNotPresentSEIEnabled ( m_layersNotPresentSEIEnabled ); |
---|
836 | #endif |
---|
837 | |
---|
838 | |
---|
839 | #if SVC_EXTENSION |
---|
840 | if( layer != 0 && m_useInterLayerWeightedPred ) |
---|
841 | { |
---|
842 | // Enable weighted prediction for enhancement layer |
---|
843 | m_cTEncTop.setUseWP ( true ); |
---|
844 | m_cTEncTop.setWPBiPred ( true ); |
---|
845 | } |
---|
846 | |
---|
847 | } |
---|
848 | #endif |
---|
849 | } |
---|
850 | |
---|
851 | Void TAppEncTop::xCreateLib() |
---|
852 | { |
---|
853 | // Video I/O |
---|
854 | #if SVC_EXTENSION |
---|
855 | // initialize global variables |
---|
856 | initROM(); |
---|
857 | |
---|
858 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
859 | { |
---|
860 | //2 |
---|
861 | // Video I/O |
---|
862 | m_apcTVideoIOYuvInputFile[layer]->open( (Char *)m_apcLayerCfg[layer]->getInputFile().c_str(), false, m_apcLayerCfg[layer]->m_inputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth ); // read mode |
---|
863 | m_apcTVideoIOYuvInputFile[layer]->skipFrames(m_FrameSkip, m_apcLayerCfg[layer]->getSourceWidth() - m_apcLayerCfg[layer]->getPad()[0], m_apcLayerCfg[layer]->getSourceHeight() - m_apcLayerCfg[layer]->getPad()[1], m_apcLayerCfg[layer]->m_InputChromaFormatIDC); |
---|
864 | |
---|
865 | if( !m_apcLayerCfg[layer]->getReconFile().empty() ) |
---|
866 | { |
---|
867 | m_apcTVideoIOYuvReconFile[layer]->open((Char *)m_apcLayerCfg[layer]->getReconFile().c_str(), true, m_apcLayerCfg[layer]->m_outputBitDepth, m_apcLayerCfg[layer]->m_MSBExtendedBitDepth, m_apcLayerCfg[layer]->m_internalBitDepth ); // write mode |
---|
868 | } |
---|
869 | |
---|
870 | // Neo Decoder |
---|
871 | m_apcTEncTop[layer]->create(); |
---|
872 | } |
---|
873 | #else //SVC_EXTENSION |
---|
874 | // Video I/O |
---|
875 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth ); // read mode |
---|
876 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC); |
---|
877 | |
---|
878 | if (m_pchReconFile) |
---|
879 | { |
---|
880 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth); // write mode |
---|
881 | } |
---|
882 | |
---|
883 | // Neo Decoder |
---|
884 | m_cTEncTop.create(); |
---|
885 | #endif //SVC_EXTENSION |
---|
886 | } |
---|
887 | |
---|
888 | Void TAppEncTop::xDestroyLib() |
---|
889 | { |
---|
890 | // Video I/O |
---|
891 | #if SVC_EXTENSION |
---|
892 | // destroy ROM |
---|
893 | destroyROM(); |
---|
894 | |
---|
895 | for( UInt layer=0; layer < m_numLayers; layer++ ) |
---|
896 | { |
---|
897 | if( m_apcTVideoIOYuvInputFile[layer] ) |
---|
898 | { |
---|
899 | m_apcTVideoIOYuvInputFile[layer]->close(); |
---|
900 | delete m_apcTVideoIOYuvInputFile[layer]; |
---|
901 | m_apcTVideoIOYuvInputFile[layer] = NULL; |
---|
902 | } |
---|
903 | |
---|
904 | if( m_apcTVideoIOYuvReconFile[layer] ) |
---|
905 | { |
---|
906 | m_apcTVideoIOYuvReconFile[layer]->close(); |
---|
907 | delete m_apcTVideoIOYuvReconFile[layer]; |
---|
908 | m_apcTVideoIOYuvReconFile[layer] = NULL; |
---|
909 | } |
---|
910 | |
---|
911 | if( m_apcTEncTop[layer] ) |
---|
912 | { |
---|
913 | m_apcTEncTop[layer]->destroy(); |
---|
914 | delete m_apcTEncTop[layer]; |
---|
915 | m_apcTEncTop[layer] = NULL; |
---|
916 | } |
---|
917 | } |
---|
918 | #else //SVC_EXTENSION |
---|
919 | m_cTVideoIOYuvInputFile.close(); |
---|
920 | m_cTVideoIOYuvReconFile.close(); |
---|
921 | |
---|
922 | // Neo Decoder |
---|
923 | m_cTEncTop.destroy(); |
---|
924 | #endif //SVC_EXTENSION |
---|
925 | } |
---|
926 | |
---|
927 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
928 | { |
---|
929 | #if SVC_EXTENSION |
---|
930 | TComVPS* vps = m_apcTEncTop[0]->getVPS(); |
---|
931 | m_apcTEncTop[0]->getVPS()->setMaxLayers( m_numLayers ); |
---|
932 | |
---|
933 | UInt i = 0, dimIdLen = 0; |
---|
934 | |
---|
935 | while((1 << dimIdLen) < m_numLayers) |
---|
936 | { |
---|
937 | dimIdLen++; |
---|
938 | } |
---|
939 | vps->setDimensionIdLen(0, dimIdLen); |
---|
940 | vps->setNuhLayerIdPresentFlag(false); |
---|
941 | vps->setLayerIdInNuh(0, 0); |
---|
942 | vps->setLayerIdxInVps(0, 0); |
---|
943 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
944 | { |
---|
945 | vps->setLayerIdInNuh(i, m_apcLayerCfg[i]->m_layerId); |
---|
946 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
---|
947 | vps->setDimensionId(i, 0, i); |
---|
948 | |
---|
949 | if( m_apcLayerCfg[i]->m_layerId != i ) |
---|
950 | { |
---|
951 | vps->setNuhLayerIdPresentFlag(true); |
---|
952 | } |
---|
953 | } |
---|
954 | |
---|
955 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
956 | { |
---|
957 | //3 |
---|
958 | #if LAYER_CTB |
---|
959 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
960 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
961 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
962 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
963 | #endif |
---|
964 | m_apcTEncTop[layer]->init(isFieldCoding); |
---|
965 | } |
---|
966 | |
---|
967 | // Set max-layer ID |
---|
968 | vps->setMaxLayerId( m_apcLayerCfg[m_numLayers - 1]->m_layerId ); |
---|
969 | vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false ); |
---|
970 | |
---|
971 | if( m_numLayerSets > 1 ) |
---|
972 | { |
---|
973 | vps->setNumLayerSets(m_numLayerSets); |
---|
974 | |
---|
975 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
976 | { |
---|
977 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
978 | { |
---|
979 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
980 | } |
---|
981 | } |
---|
982 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
983 | { |
---|
984 | for( i = 0; i < m_numLayerInIdList[setId]; i++ ) |
---|
985 | { |
---|
986 | //4 |
---|
987 | vps->setLayerIdIncludedFlag(true, setId, m_layerSetLayerIdList[setId][i]); |
---|
988 | } |
---|
989 | } |
---|
990 | } |
---|
991 | else |
---|
992 | { |
---|
993 | // Default layer sets |
---|
994 | vps->setNumLayerSets(m_numLayers); |
---|
995 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
996 | { |
---|
997 | for (Int layerIdx = 0; layerIdx <= vps->getMaxLayers(); layerIdx++) |
---|
998 | { |
---|
999 | //4 |
---|
1000 | UInt layerId = vps->getLayerIdInNuh(layerIdx); |
---|
1001 | |
---|
1002 | if (layerId <= setId) |
---|
1003 | { |
---|
1004 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
1005 | } |
---|
1006 | else |
---|
1007 | { |
---|
1008 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
1009 | } |
---|
1010 | } |
---|
1011 | } |
---|
1012 | } |
---|
1013 | |
---|
1014 | vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1); |
---|
1015 | vps->setNumAddLayerSets(m_numAddLayerSets); |
---|
1016 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
1017 | |
---|
1018 | if( m_numAddLayerSets > 0 ) |
---|
1019 | { |
---|
1020 | for (Int setId = 0; setId < m_numAddLayerSets; setId++) |
---|
1021 | { |
---|
1022 | for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++) |
---|
1023 | { |
---|
1024 | vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1); |
---|
1025 | } |
---|
1026 | } |
---|
1027 | } |
---|
1028 | |
---|
1029 | #if AVC_BASE |
---|
1030 | vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag ); |
---|
1031 | if ( m_nonHEVCBaseLayerFlag ) |
---|
1032 | { |
---|
1033 | vps->setBaseLayerInternalFlag (false); |
---|
1034 | } |
---|
1035 | #else |
---|
1036 | vps->setAvcBaseLayerFlag(false); |
---|
1037 | #endif |
---|
1038 | |
---|
1039 | for( Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx < vps->getNumProfileTierLevel(); idx++ ) |
---|
1040 | { |
---|
1041 | vps->setProfilePresentFlag(idx, true); |
---|
1042 | } |
---|
1043 | |
---|
1044 | vps->setSplittingFlag(false); |
---|
1045 | |
---|
1046 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1047 | { |
---|
1048 | vps->setScalabilityMask(i, false); |
---|
1049 | } |
---|
1050 | if(m_numLayers > 1) |
---|
1051 | { |
---|
1052 | Int scalabilityTypes = 0; |
---|
1053 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1054 | { |
---|
1055 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
1056 | scalabilityTypes += m_scalabilityMask[i]; |
---|
1057 | } |
---|
1058 | #if AUXILIARY_PICTURES |
---|
1059 | assert( scalabilityTypes <= 2 ); |
---|
1060 | #else |
---|
1061 | assert( scalabilityTypes == 1 ); |
---|
1062 | #endif |
---|
1063 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | vps->setNumScalabilityTypes(0); |
---|
1068 | } |
---|
1069 | |
---|
1070 | #if AUXILIARY_PICTURES |
---|
1071 | if (m_scalabilityMask[AUX_ID]) |
---|
1072 | { |
---|
1073 | UInt maxAuxId = 0; |
---|
1074 | UInt auxDimIdLen = 1; |
---|
1075 | Int auxId = vps->getNumScalabilityTypes() - 1; |
---|
1076 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1077 | { |
---|
1078 | if (m_apcLayerCfg[i]->getAuxId() > maxAuxId) |
---|
1079 | { |
---|
1080 | maxAuxId = m_apcLayerCfg[i]->getAuxId(); |
---|
1081 | } |
---|
1082 | } |
---|
1083 | while((1 << auxDimIdLen) < (maxAuxId + 1)) |
---|
1084 | { |
---|
1085 | auxDimIdLen++; |
---|
1086 | } |
---|
1087 | vps->setDimensionIdLen(auxId, auxDimIdLen); |
---|
1088 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1089 | { |
---|
1090 | vps->setDimensionId(i, auxId, m_apcLayerCfg[i]->getAuxId()); |
---|
1091 | } |
---|
1092 | } |
---|
1093 | #endif |
---|
1094 | |
---|
1095 | vps->setMaxTSLayersPresentFlag(true); |
---|
1096 | |
---|
1097 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
---|
1098 | { |
---|
1099 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
1100 | } |
---|
1101 | |
---|
1102 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
1103 | if (vps->getMaxTidRefPresentFlag()) |
---|
1104 | { |
---|
1105 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1106 | { |
---|
1107 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1108 | { |
---|
1109 | vps->setMaxTidIlRefPicsPlus1(i, j, m_apcTEncTop[i]->getMaxTidIlRefPicsPlus1()); |
---|
1110 | } |
---|
1111 | } |
---|
1112 | } |
---|
1113 | else |
---|
1114 | { |
---|
1115 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1116 | { |
---|
1117 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1118 | { |
---|
1119 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | |
---|
1124 | vps->setIlpSshSignalingEnabledFlag(false); |
---|
1125 | |
---|
1126 | // Direct reference layers |
---|
1127 | UInt maxDirectRefLayers = 0; |
---|
1128 | Bool isDefaultDirectDependencyTypeSet = false; |
---|
1129 | for (UInt layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
---|
1130 | { |
---|
1131 | UInt layerId = vps->getLayerIdInNuh(layerCtr); |
---|
1132 | Int numDirectRefLayers = 0; |
---|
1133 | |
---|
1134 | vps->setNumDirectRefLayers(layerId, m_apcTEncTop[layerCtr]->getNumDirectRefLayers()); |
---|
1135 | maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerId)); |
---|
1136 | |
---|
1137 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
---|
1138 | { |
---|
1139 | vps->setRefLayerId(layerId, i, m_apcTEncTop[layerCtr]->getRefLayerId(i)); |
---|
1140 | } |
---|
1141 | // Set direct dependency flag |
---|
1142 | // Initialize flag to 0 |
---|
1143 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1144 | { |
---|
1145 | vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false); |
---|
1146 | } |
---|
1147 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
---|
1148 | { |
---|
1149 | vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdxInVps(m_apcTEncTop[layerCtr]->getRefLayerId(i)), true); |
---|
1150 | } |
---|
1151 | // prediction indications |
---|
1152 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
1153 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1154 | { |
---|
1155 | if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr)) |
---|
1156 | { |
---|
1157 | assert(m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) || m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers)); |
---|
1158 | vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) ? 1 : 0) | |
---|
1159 | (m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers) ? 2 : 0)) - 1); |
---|
1160 | |
---|
1161 | if (!isDefaultDirectDependencyTypeSet) |
---|
1162 | { |
---|
1163 | vps->setDefaultDirectDependecyTypeFlag(1); |
---|
1164 | vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr)); |
---|
1165 | isDefaultDirectDependencyTypeSet = true; |
---|
1166 | } |
---|
1167 | else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType()) |
---|
1168 | { |
---|
1169 | vps->setDefaultDirectDependecyTypeFlag(0); |
---|
1170 | } |
---|
1171 | |
---|
1172 | numDirectRefLayers ++; |
---|
1173 | } |
---|
1174 | else |
---|
1175 | { |
---|
1176 | vps->setDirectDependencyType(layerCtr, refLayerCtr, 0); |
---|
1177 | } |
---|
1178 | } |
---|
1179 | } |
---|
1180 | |
---|
1181 | // dependency constraint |
---|
1182 | vps->setNumRefLayers(); |
---|
1183 | |
---|
1184 | if( vps->getMaxLayers() > MAX_REF_LAYERS ) |
---|
1185 | { |
---|
1186 | for( UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++ ) |
---|
1187 | { |
---|
1188 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS); |
---|
1189 | } |
---|
1190 | } |
---|
1191 | |
---|
1192 | // The Layer ID List variables should be derived here. |
---|
1193 | vps->deriveLayerIdListVariables(); |
---|
1194 | vps->setPredictedLayerIds(); |
---|
1195 | vps->setTreePartitionLayerIdList(); |
---|
1196 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
1197 | |
---|
1198 | vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file |
---|
1199 | |
---|
1200 | if( m_numOutputLayerSets == -1 ) // # of output layer sets not specified in the configuration file |
---|
1201 | { |
---|
1202 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
1203 | |
---|
1204 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
1205 | { |
---|
1206 | vps->setOutputLayerSetIdx(i, i); |
---|
1207 | } |
---|
1208 | } |
---|
1209 | else |
---|
1210 | { |
---|
1211 | vps->setNumOutputLayerSets( m_numOutputLayerSets ); |
---|
1212 | for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets |
---|
1213 | { |
---|
1214 | vps->setOutputLayerSetIdx(olsCtr, olsCtr); |
---|
1215 | } |
---|
1216 | for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ ) // Non-default output layer sets |
---|
1217 | { |
---|
1218 | vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]); |
---|
1219 | } |
---|
1220 | } |
---|
1221 | |
---|
1222 | // Target output layer |
---|
1223 | vps->deriveNumberOfSubDpbs(); |
---|
1224 | vps->setOutputLayerFlag( 0, 0, 1 ); |
---|
1225 | |
---|
1226 | // derive OutputLayerFlag[i][j] |
---|
1227 | // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and |
---|
1228 | // AuxId[ nuhLayerIdA ] equal to 0 in each of the output layer sets with index in the range of 1 to vps_num_layer_sets_minus1, inclusive, is an output layer of its output layer set. |
---|
1229 | |
---|
1230 | // Include the highest layer as output layer for each layer set |
---|
1231 | for(Int lsIdx = 1; lsIdx <= vps->getVpsNumLayerSetsMinus1(); lsIdx++) |
---|
1232 | { |
---|
1233 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ ) |
---|
1234 | { |
---|
1235 | switch( vps->getDefaultTargetOutputLayerIdc() ) |
---|
1236 | { |
---|
1237 | case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 ); |
---|
1238 | break; |
---|
1239 | case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
1240 | break; |
---|
1241 | case 2: |
---|
1242 | case 3: vps->setOutputLayerFlag( lsIdx, layer, (layer != vps->getNumLayersInIdList(lsIdx) - 1) ? std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), m_layerSetLayerIdList[lsIdx][layer]) != m_listOfOutputLayers[lsIdx].end() |
---|
1243 | : m_listOfOutputLayers[lsIdx][m_listOfOutputLayers[lsIdx].size()-1] == m_layerSetLayerIdList[lsIdx][layer] ); |
---|
1244 | break; |
---|
1245 | } |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | for( Int olsIdx = vps->getVpsNumLayerSetsMinus1() + 1; olsIdx < vps->getNumOutputLayerSets(); olsIdx++ ) |
---|
1250 | { |
---|
1251 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ ) |
---|
1252 | { |
---|
1253 | vps->setOutputLayerFlag( olsIdx, layer, (layer != vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)) - 1) ? std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), vps->getLayerSetLayerIdList(vps->getOutputLayerSetIdx(olsIdx), layer)) != m_listOfOutputLayers[olsIdx].end() |
---|
1254 | : m_listOfOutputLayers[olsIdx][m_listOfOutputLayers[olsIdx].size()-1] == vps->getLayerSetLayerIdList(vps->getOutputLayerSetIdx(olsIdx), layer) ); |
---|
1255 | } |
---|
1256 | } |
---|
1257 | |
---|
1258 | vps->deriveNecessaryLayerFlag(); |
---|
1259 | vps->checkNecessaryLayerFlagCondition(); |
---|
1260 | vps->calculateMaxSLInLayerSets(); |
---|
1261 | |
---|
1262 | // Initialize dpb_size_table() for all ouput layer sets in the VPS extension |
---|
1263 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
1264 | { |
---|
1265 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
1266 | Int layerSetId = vps->getOutputLayerSetIdx(i); |
---|
1267 | |
---|
1268 | for(Int j = 0; j < vps->getMaxTLayers(); j++) |
---|
1269 | { |
---|
1270 | |
---|
1271 | Int maxNumReorderPics = -1; |
---|
1272 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
1273 | { |
---|
1274 | Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set |
---|
1275 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getMaxDecPicBuffering(j) - 1 ); |
---|
1276 | maxNumReorderPics = std::max( maxNumReorderPics, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getNumReorderPics(j)); |
---|
1277 | } |
---|
1278 | vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); |
---|
1279 | vps->determineSubDpbInfoFlags(); |
---|
1280 | } |
---|
1281 | } |
---|
1282 | |
---|
1283 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
1284 | |
---|
1285 | // POC LSB not present flag |
---|
1286 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
---|
1287 | { |
---|
1288 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
1289 | { |
---|
1290 | // make independedent layers base-layer compliant |
---|
1291 | vps->setPocLsbNotPresentFlag(i, true); |
---|
1292 | } |
---|
1293 | } |
---|
1294 | |
---|
1295 | vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); |
---|
1296 | vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); |
---|
1297 | vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); |
---|
1298 | |
---|
1299 | if( vps->getCrossLayerPictureTypeAlignFlag() ) |
---|
1300 | { |
---|
1301 | // When not present, the value of cross_layer_irap_aligned_flag is inferred to be equal to vps_vui_present_flag, |
---|
1302 | assert( m_crossLayerIrapAlignFlag == true ); |
---|
1303 | vps->setCrossLayerIrapAlignFlag( true ); |
---|
1304 | } |
---|
1305 | |
---|
1306 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1307 | { |
---|
1308 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1309 | { |
---|
1310 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
1311 | { |
---|
1312 | if(m_apcTEncTop[layerCtr]->getIntraPeriod() != m_apcTEncTop[refLayerCtr]->getIntraPeriod()) |
---|
1313 | { |
---|
1314 | vps->setCrossLayerIrapAlignFlag(false); |
---|
1315 | break; |
---|
1316 | } |
---|
1317 | } |
---|
1318 | } |
---|
1319 | } |
---|
1320 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
1321 | vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch); |
---|
1322 | |
---|
1323 | for( Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++ ) |
---|
1324 | { |
---|
1325 | vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); |
---|
1326 | } |
---|
1327 | |
---|
1328 | // VPS VUI BSP HRD parameters |
---|
1329 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
1330 | TEncTop *pcCfg = m_apcTEncTop[0]; |
---|
1331 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
1332 | { |
---|
1333 | Int j; |
---|
1334 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
1335 | vps->setVpsNumAddHrdParams( vps->getMaxLayers() ); |
---|
1336 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1); |
---|
1337 | for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) |
---|
1338 | { |
---|
1339 | vps->setCprmsAddPresentFlag( j, true ); |
---|
1340 | vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 ); |
---|
1341 | |
---|
1342 | UInt layerIdx = j; |
---|
1343 | TEncTop *pcCfgLayer = m_apcTEncTop[layerIdx]; |
---|
1344 | |
---|
1345 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
1346 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
1347 | |
---|
1348 | UInt uiWidthInCU = ( iPicWidth % m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth ) ? iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth + 1 : iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth; |
---|
1349 | UInt uiHeightInCU = ( iPicHeight % m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight ) ? iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight + 1 : iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight; |
---|
1350 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth << 1); |
---|
1351 | |
---|
1352 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
1353 | |
---|
1354 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
1355 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
1356 | { |
---|
1357 | numDU ++; |
---|
1358 | } |
---|
1359 | //vps->getBspHrd(i)->setNumDU( numDU ); |
---|
1360 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
1361 | } |
---|
1362 | |
---|
1363 | // Signalling of additional partitioning schemes |
---|
1364 | for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ ) |
---|
1365 | { |
---|
1366 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
---|
1367 | vps->setNumSignalledPartitioningSchemes(h, 1); // Only the default per-layer partitioning scheme |
---|
1368 | for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
---|
1369 | { |
---|
1370 | // ToDo: Add code for additional partitioning schemes here |
---|
1371 | // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag |
---|
1372 | } |
---|
1373 | |
---|
1374 | for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ ) |
---|
1375 | { |
---|
1376 | if( i == 0 ) |
---|
1377 | { |
---|
1378 | for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++) |
---|
1379 | { |
---|
1380 | vps->setNumBspSchedulesMinus1( h, i, t, 0 ); |
---|
1381 | for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
---|
1382 | { |
---|
1383 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
1384 | { |
---|
1385 | // Only for the default partition |
---|
1386 | Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k); |
---|
1387 | Int layerIdxInVps = vps->getLayerIdxInVps( nuhlayerId ); |
---|
1388 | vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters()); |
---|
1389 | |
---|
1390 | vps->setBspSchedIdx(h, i, t, j, k, 0); |
---|
1391 | } |
---|
1392 | } |
---|
1393 | } |
---|
1394 | } |
---|
1395 | else |
---|
1396 | { |
---|
1397 | assert(0); // Need to add support for additional partitioning schemes. |
---|
1398 | } |
---|
1399 | } |
---|
1400 | } |
---|
1401 | } |
---|
1402 | #else //SVC_EXTENSION |
---|
1403 | m_cTEncTop.init(isFieldCoding); |
---|
1404 | #endif //SVC_EXTENSION |
---|
1405 | } |
---|
1406 | |
---|
1407 | // ==================================================================================================================== |
---|
1408 | // Public member functions |
---|
1409 | // ==================================================================================================================== |
---|
1410 | |
---|
1411 | /** |
---|
1412 | - create internal class |
---|
1413 | - initialize internal variable |
---|
1414 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1415 | - delete allocated buffers |
---|
1416 | - destroy internal class |
---|
1417 | . |
---|
1418 | */ |
---|
1419 | #if SVC_EXTENSION |
---|
1420 | Void TAppEncTop::encode() |
---|
1421 | { |
---|
1422 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1423 | if (!bitstreamFile) |
---|
1424 | { |
---|
1425 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1426 | exit(EXIT_FAILURE); |
---|
1427 | } |
---|
1428 | |
---|
1429 | // allocated memory |
---|
1430 | for( Int layer = 0; layer < m_numLayers; layer++ ) |
---|
1431 | { |
---|
1432 | m_apcTVideoIOYuvInputFile[layer] = new TVideoIOYuv; |
---|
1433 | m_apcTVideoIOYuvReconFile[layer] = new TVideoIOYuv; |
---|
1434 | m_apcTEncTop[layer] = new TEncTop; |
---|
1435 | } |
---|
1436 | |
---|
1437 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
1438 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1439 | |
---|
1440 | // initialize internal class & member variables |
---|
1441 | xInitLibCfg(); |
---|
1442 | xCreateLib(); |
---|
1443 | xInitLib(m_isField); |
---|
1444 | |
---|
1445 | // main encoder loop |
---|
1446 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
1447 | Bool bEos = false; |
---|
1448 | |
---|
1449 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
---|
1450 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1451 | |
---|
1452 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1453 | |
---|
1454 | TComPicYuv acPicYuvTrueOrg[MAX_LAYERS]; |
---|
1455 | |
---|
1456 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1457 | { |
---|
1458 | //5 |
---|
1459 | // allocate original YUV buffer |
---|
1460 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
1461 | if( m_isField ) |
---|
1462 | { |
---|
1463 | pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeightOrg(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
---|
1464 | acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeightOrg(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
---|
1465 | } |
---|
1466 | else |
---|
1467 | { |
---|
1468 | pcPicYuvOrg[layer]->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
---|
1469 | acPicYuvTrueOrg[layer].create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
---|
1470 | } |
---|
1471 | } |
---|
1472 | |
---|
1473 | Bool bFirstFrame = true; |
---|
1474 | while ( !bEos ) |
---|
1475 | { |
---|
1476 | // Read enough frames |
---|
1477 | Bool bFramesReadyToCode = false; |
---|
1478 | while(!bFramesReadyToCode) |
---|
1479 | { |
---|
1480 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1481 | { |
---|
1482 | //6 |
---|
1483 | // get buffers |
---|
1484 | xGetBuffer(pcPicYuvRec, layer); |
---|
1485 | |
---|
1486 | // read input YUV file |
---|
1487 | m_apcTVideoIOYuvInputFile[layer]->read( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], ipCSC, m_apcLayerCfg[layer]->getPad(), m_apcLayerCfg[layer]->getInputChromaFormat(), m_bClipInputVideoToRec709Range ); |
---|
1488 | |
---|
1489 | #if AUXILIARY_PICTURES |
---|
1490 | if( m_apcLayerCfg[layer]->getChromaFormatIDC() == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_apcLayerCfg[layer]->getAuxId() == AUX_ALPHA || m_apcLayerCfg[layer]->getAuxId() == AUX_DEPTH)) ) |
---|
1491 | { |
---|
1492 | pcPicYuvOrg[layer]->convertToMonochrome(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1493 | } |
---|
1494 | #endif |
---|
1495 | |
---|
1496 | if(layer == m_numLayers-1) |
---|
1497 | { |
---|
1498 | // increase number of received frames |
---|
1499 | m_iFrameRcvd++; |
---|
1500 | // check end of file |
---|
1501 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1502 | } |
---|
1503 | |
---|
1504 | if ( m_isField ) |
---|
1505 | { |
---|
1506 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], m_isTopFieldFirst ); |
---|
1507 | } |
---|
1508 | else |
---|
1509 | { |
---|
1510 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer] ); |
---|
1511 | } |
---|
1512 | } |
---|
1513 | |
---|
1514 | bFramesReadyToCode = !(!bFirstFrame && ( m_apcTEncTop[m_numLayers-1]->getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
1515 | } |
---|
1516 | Bool flush = 0; |
---|
1517 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1518 | if (m_apcTVideoIOYuvInputFile[m_numLayers-1]->isEof()) |
---|
1519 | { |
---|
1520 | flush = true; |
---|
1521 | bEos = true; |
---|
1522 | m_iFrameRcvd--; |
---|
1523 | m_apcTEncTop[m_numLayers-1]->setFramesToBeEncoded(m_iFrameRcvd); |
---|
1524 | } |
---|
1525 | |
---|
1526 | #if RC_SHVC_HARMONIZATION |
---|
1527 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1528 | { |
---|
1529 | if( m_apcTEncTop[layer]->getUseRateCtrl() ) |
---|
1530 | { |
---|
1531 | m_apcTEncTop[layer]->getRateCtrl()->initRCGOP(m_apcTEncTop[layer]->getNumPicRcvd()); |
---|
1532 | } |
---|
1533 | } |
---|
1534 | #endif |
---|
1535 | |
---|
1536 | if( m_adaptiveResolutionChange ) |
---|
1537 | { |
---|
1538 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
1539 | { |
---|
1540 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
1541 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
1542 | { |
---|
1543 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
1544 | recPic->setReconstructed(false); |
---|
1545 | } |
---|
1546 | } |
---|
1547 | } |
---|
1548 | |
---|
1549 | // loop through frames in one GOP |
---|
1550 | for( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
1551 | { |
---|
1552 | // layer by layer for each frame |
---|
1553 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1554 | { |
---|
1555 | //7 |
---|
1556 | #if LAYER_CTB |
---|
1557 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
1558 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
1559 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
1560 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
1561 | #endif |
---|
1562 | // call encoding function for one frame |
---|
1563 | if ( m_isField ) |
---|
1564 | { |
---|
1565 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
1566 | } |
---|
1567 | else |
---|
1568 | { |
---|
1569 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
1570 | } |
---|
1571 | } |
---|
1572 | } |
---|
1573 | #if R0247_SEI_ACTIVE |
---|
1574 | if(bFirstFrame) |
---|
1575 | { |
---|
1576 | list<AccessUnit>::iterator first_au = outputAccessUnits.begin(); |
---|
1577 | if( m_nonHEVCBaseLayerFlag ) |
---|
1578 | { |
---|
1579 | first_au++; |
---|
1580 | } |
---|
1581 | AccessUnit::iterator it_sps; |
---|
1582 | for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++) |
---|
1583 | { |
---|
1584 | if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
1585 | { |
---|
1586 | break; |
---|
1587 | } |
---|
1588 | } |
---|
1589 | |
---|
1590 | for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++) |
---|
1591 | { |
---|
1592 | for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++) |
---|
1593 | { |
---|
1594 | if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
1595 | { |
---|
1596 | first_au->insert(++it_sps, *it_nalu); |
---|
1597 | it_nalu = it_au->erase(it_nalu); |
---|
1598 | } |
---|
1599 | } |
---|
1600 | } |
---|
1601 | } |
---|
1602 | |
---|
1603 | #endif |
---|
1604 | |
---|
1605 | #if RC_SHVC_HARMONIZATION |
---|
1606 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1607 | { |
---|
1608 | if ( m_apcTEncTop[layer]->getUseRateCtrl() ) |
---|
1609 | { |
---|
1610 | (m_apcTEncTop[layer]->getRateCtrl())->destroyRCGOP(); |
---|
1611 | } |
---|
1612 | } |
---|
1613 | #endif |
---|
1614 | |
---|
1615 | iTotalNumEncoded = 0; |
---|
1616 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1617 | { |
---|
1618 | //8 |
---|
1619 | // write bistream to file if necessary |
---|
1620 | iNumEncoded = m_apcTEncTop[layer]->getNumPicRcvd(); |
---|
1621 | if ( iNumEncoded > 0 ) |
---|
1622 | { |
---|
1623 | xWriteRecon(layer, iNumEncoded); |
---|
1624 | iTotalNumEncoded += iNumEncoded; |
---|
1625 | } |
---|
1626 | m_apcTEncTop[layer]->setNumPicRcvd( 0 ); |
---|
1627 | } |
---|
1628 | |
---|
1629 | // write bitstream out |
---|
1630 | if( iTotalNumEncoded ) |
---|
1631 | { |
---|
1632 | if( bEos ) |
---|
1633 | { |
---|
1634 | OutputNALUnit nalu(NAL_UNIT_EOB); |
---|
1635 | nalu.m_nuhLayerId = 0; |
---|
1636 | |
---|
1637 | AccessUnit& accessUnit = outputAccessUnits.back(); |
---|
1638 | nalu.m_temporalId = 0; |
---|
1639 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1640 | } |
---|
1641 | |
---|
1642 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
1643 | outputAccessUnits.clear(); |
---|
1644 | } |
---|
1645 | |
---|
1646 | // print out summary |
---|
1647 | if (bEos) |
---|
1648 | { |
---|
1649 | printOutSummary(m_isTopFieldFirst, m_printMSEBasedSequencePSNR, m_printSequenceMSE); |
---|
1650 | } |
---|
1651 | |
---|
1652 | bFirstFrame = false; |
---|
1653 | } |
---|
1654 | // delete original YUV buffer |
---|
1655 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1656 | { |
---|
1657 | pcPicYuvOrg[layer]->destroy(); |
---|
1658 | delete pcPicYuvOrg[layer]; |
---|
1659 | pcPicYuvOrg[layer] = NULL; |
---|
1660 | |
---|
1661 | // delete used buffers in encoder class |
---|
1662 | m_apcTEncTop[layer]->deletePicBuffer(); |
---|
1663 | acPicYuvTrueOrg[layer].destroy(); |
---|
1664 | } |
---|
1665 | |
---|
1666 | // delete buffers & classes |
---|
1667 | xDeleteBuffer(); |
---|
1668 | xDestroyLib(); |
---|
1669 | |
---|
1670 | printRateSummary(); |
---|
1671 | |
---|
1672 | return; |
---|
1673 | } |
---|
1674 | |
---|
1675 | Void TAppEncTop::printOutSummary(Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE) |
---|
1676 | { |
---|
1677 | UInt layer; |
---|
1678 | const Int rateMultiplier = isField ? 2 : 1; |
---|
1679 | |
---|
1680 | // set frame rate |
---|
1681 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1682 | { |
---|
1683 | m_apcTEncTop[layer]->getAnalyzeAll()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1684 | m_apcTEncTop[layer]->getAnalyzeI()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1685 | m_apcTEncTop[layer]->getAnalyzeP()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1686 | m_apcTEncTop[layer]->getAnalyzeB()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1687 | } |
---|
1688 | |
---|
1689 | //-- all |
---|
1690 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
1691 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1692 | { |
---|
1693 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1694 | m_apcTEncTop[layer]->getAnalyzeAll()->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1695 | } |
---|
1696 | |
---|
1697 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
1698 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1699 | { |
---|
1700 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1701 | m_apcTEncTop[layer]->getAnalyzeI()->printOut('i', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1702 | } |
---|
1703 | |
---|
1704 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
1705 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1706 | { |
---|
1707 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1708 | m_apcTEncTop[layer]->getAnalyzeP()->printOut('p', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1709 | } |
---|
1710 | |
---|
1711 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
1712 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1713 | { |
---|
1714 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1715 | m_apcTEncTop[layer]->getAnalyzeB()->printOut('b', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1716 | } |
---|
1717 | |
---|
1718 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1719 | { |
---|
1720 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
---|
1721 | { |
---|
1722 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1723 | |
---|
1724 | m_apcTEncTop[layer]->getAnalyzeAll()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
---|
1725 | } |
---|
1726 | } |
---|
1727 | |
---|
1728 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1729 | { |
---|
1730 | if (!m_apcTEncTop[layer]->getSummaryPicFilenameBase().empty()) |
---|
1731 | { |
---|
1732 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1733 | |
---|
1734 | m_apcTEncTop[layer]->getAnalyzeI()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"I.txt"); |
---|
1735 | m_apcTEncTop[layer]->getAnalyzeP()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"P.txt"); |
---|
1736 | m_apcTEncTop[layer]->getAnalyzeB()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"B.txt"); |
---|
1737 | } |
---|
1738 | } |
---|
1739 | |
---|
1740 | if(isField) |
---|
1741 | { |
---|
1742 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1743 | { |
---|
1744 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1745 | TEncAnalyze *analyze = m_apcTEncTop[layer]->getAnalyzeAllin(); |
---|
1746 | |
---|
1747 | //-- interlaced summary |
---|
1748 | analyze->setFrmRate( m_apcLayerCfg[layer]->getFrameRate()); |
---|
1749 | analyze->setBits(m_apcTEncTop[layer]->getAnalyzeB()->getBits()); |
---|
1750 | // prior to the above statement, the interlace analyser does not contain the correct total number of bits. |
---|
1751 | |
---|
1752 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
1753 | analyze->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1754 | |
---|
1755 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
---|
1756 | { |
---|
1757 | analyze->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
---|
1758 | } |
---|
1759 | } |
---|
1760 | } |
---|
1761 | |
---|
1762 | printf("\n"); |
---|
1763 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1764 | { |
---|
1765 | printf("RVM[L%d]: %.3lf\n", layer, m_apcTEncTop[layer]->calculateRVM()); |
---|
1766 | } |
---|
1767 | printf("\n"); |
---|
1768 | } |
---|
1769 | #else |
---|
1770 | // ==================================================================================================================== |
---|
1771 | // Public member functions |
---|
1772 | // ==================================================================================================================== |
---|
1773 | |
---|
1774 | /** |
---|
1775 | - create internal class |
---|
1776 | - initialize internal variable |
---|
1777 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1778 | - delete allocated buffers |
---|
1779 | - destroy internal class |
---|
1780 | . |
---|
1781 | */ |
---|
1782 | Void TAppEncTop::encode() |
---|
1783 | { |
---|
1784 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1785 | if (!bitstreamFile) |
---|
1786 | { |
---|
1787 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1788 | exit(EXIT_FAILURE); |
---|
1789 | } |
---|
1790 | |
---|
1791 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
1792 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1793 | |
---|
1794 | // initialize internal class & member variables |
---|
1795 | xInitLibCfg(); |
---|
1796 | xCreateLib(); |
---|
1797 | xInitLib(m_isField); |
---|
1798 | |
---|
1799 | printChromaFormat(); |
---|
1800 | |
---|
1801 | // main encoder loop |
---|
1802 | Int iNumEncoded = 0; |
---|
1803 | Bool bEos = false; |
---|
1804 | |
---|
1805 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
---|
1806 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1807 | |
---|
1808 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1809 | |
---|
1810 | TComPicYuv cPicYuvTrueOrg; |
---|
1811 | |
---|
1812 | // allocate original YUV buffer |
---|
1813 | if( m_isField ) |
---|
1814 | { |
---|
1815 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1816 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true); |
---|
1817 | } |
---|
1818 | else |
---|
1819 | { |
---|
1820 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1821 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1822 | } |
---|
1823 | |
---|
1824 | while ( !bEos ) |
---|
1825 | { |
---|
1826 | // get buffers |
---|
1827 | xGetBuffer(pcPicYuvRec); |
---|
1828 | |
---|
1829 | // read input YUV file |
---|
1830 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); |
---|
1831 | |
---|
1832 | // increase number of received frames |
---|
1833 | m_iFrameRcvd++; |
---|
1834 | |
---|
1835 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1836 | |
---|
1837 | Bool flush = 0; |
---|
1838 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1839 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
1840 | { |
---|
1841 | flush = true; |
---|
1842 | bEos = true; |
---|
1843 | m_iFrameRcvd--; |
---|
1844 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
1845 | } |
---|
1846 | |
---|
1847 | // call encoding function for one frame |
---|
1848 | if ( m_isField ) |
---|
1849 | { |
---|
1850 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst ); |
---|
1851 | } |
---|
1852 | else |
---|
1853 | { |
---|
1854 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
1855 | } |
---|
1856 | |
---|
1857 | // write bistream to file if necessary |
---|
1858 | if ( iNumEncoded > 0 ) |
---|
1859 | { |
---|
1860 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
1861 | outputAccessUnits.clear(); |
---|
1862 | } |
---|
1863 | } |
---|
1864 | |
---|
1865 | m_cTEncTop.printSummary(m_isField); |
---|
1866 | |
---|
1867 | // delete original YUV buffer |
---|
1868 | pcPicYuvOrg->destroy(); |
---|
1869 | delete pcPicYuvOrg; |
---|
1870 | pcPicYuvOrg = NULL; |
---|
1871 | |
---|
1872 | // delete used buffers in encoder class |
---|
1873 | m_cTEncTop.deletePicBuffer(); |
---|
1874 | cPicYuvTrueOrg.destroy(); |
---|
1875 | |
---|
1876 | // delete buffers & classes |
---|
1877 | xDeleteBuffer(); |
---|
1878 | xDestroyLib(); |
---|
1879 | |
---|
1880 | printRateSummary(); |
---|
1881 | |
---|
1882 | return; |
---|
1883 | } |
---|
1884 | #endif //SVC_EXTENSION |
---|
1885 | |
---|
1886 | // ==================================================================================================================== |
---|
1887 | // Protected member functions |
---|
1888 | // ==================================================================================================================== |
---|
1889 | |
---|
1890 | /** |
---|
1891 | - application has picture buffer list with size of GOP |
---|
1892 | - picture buffer list acts as ring buffer |
---|
1893 | - end of the list has the latest picture |
---|
1894 | . |
---|
1895 | */ |
---|
1896 | #if SVC_EXTENSION |
---|
1897 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
1898 | { |
---|
1899 | assert( m_iGOPSize > 0 ); |
---|
1900 | |
---|
1901 | // org. buffer |
---|
1902 | if ( m_acListPicYuvRec[layer].size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second. |
---|
1903 | { |
---|
1904 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
1905 | } |
---|
1906 | else |
---|
1907 | { |
---|
1908 | rpcPicYuvRec = new TComPicYuv; |
---|
1909 | |
---|
1910 | rpcPicYuvRec->create( m_apcLayerCfg[layer]->getSourceWidth(), m_apcLayerCfg[layer]->getSourceHeight(), m_apcLayerCfg[layer]->getChromaFormatIDC(), m_apcLayerCfg[layer]->m_uiMaxCUWidth, m_apcLayerCfg[layer]->m_uiMaxCUHeight, m_apcLayerCfg[layer]->m_uiMaxTotalCUDepth, true, NULL ); |
---|
1911 | } |
---|
1912 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
1913 | } |
---|
1914 | |
---|
1915 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1916 | { |
---|
1917 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1918 | { |
---|
1919 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
1920 | |
---|
1921 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
1922 | |
---|
1923 | for ( Int i = 0; i < iSize; i++ ) |
---|
1924 | { |
---|
1925 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1926 | pcPicYuvRec->destroy(); |
---|
1927 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
1928 | } |
---|
1929 | } |
---|
1930 | } |
---|
1931 | |
---|
1932 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
1933 | { |
---|
1934 | ChromaFormat chromaFormatIdc = m_apcLayerCfg[layer]->getChromaFormatIDC(); |
---|
1935 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
1936 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
1937 | |
---|
1938 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1939 | |
---|
1940 | if (m_isField) |
---|
1941 | { |
---|
1942 | //Reinterlace fields |
---|
1943 | Int i; |
---|
1944 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
1945 | |
---|
1946 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1947 | { |
---|
1948 | --iterPicYuvRec; |
---|
1949 | } |
---|
1950 | |
---|
1951 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
1952 | { |
---|
1953 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
1954 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
1955 | |
---|
1956 | if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() ) |
---|
1957 | { |
---|
1958 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
---|
1959 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
---|
1960 | } |
---|
1961 | } |
---|
1962 | } |
---|
1963 | else |
---|
1964 | { |
---|
1965 | Int i; |
---|
1966 | |
---|
1967 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
1968 | |
---|
1969 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1970 | { |
---|
1971 | --iterPicYuvRec; |
---|
1972 | } |
---|
1973 | |
---|
1974 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1975 | { |
---|
1976 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1977 | if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRec->isReconstructed() ) |
---|
1978 | { |
---|
1979 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRec, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
---|
1980 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, |
---|
1981 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
---|
1982 | } |
---|
1983 | } |
---|
1984 | } |
---|
1985 | } |
---|
1986 | |
---|
1987 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
1988 | { |
---|
1989 | if (m_isField) |
---|
1990 | { |
---|
1991 | //Reinterlace fields |
---|
1992 | Int i; |
---|
1993 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1994 | |
---|
1995 | for( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
1996 | { |
---|
1997 | const AccessUnit& auTop = *(iterBitstream++); |
---|
1998 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
1999 | rateStatsAccum(auTop, statsTop); |
---|
2000 | |
---|
2001 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2002 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2003 | rateStatsAccum(auBottom, statsBottom); |
---|
2004 | } |
---|
2005 | } |
---|
2006 | else |
---|
2007 | { |
---|
2008 | Int i; |
---|
2009 | |
---|
2010 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2011 | |
---|
2012 | for( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
2013 | { |
---|
2014 | const AccessUnit& au = *(iterBitstream++); |
---|
2015 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2016 | rateStatsAccum(au, stats); |
---|
2017 | } |
---|
2018 | } |
---|
2019 | } |
---|
2020 | |
---|
2021 | #else // SVC_EXTENSION |
---|
2022 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
2023 | { |
---|
2024 | assert( m_iGOPSize > 0 ); |
---|
2025 | |
---|
2026 | // org. buffer |
---|
2027 | if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second. |
---|
2028 | { |
---|
2029 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
2030 | |
---|
2031 | } |
---|
2032 | else |
---|
2033 | { |
---|
2034 | rpcPicYuvRec = new TComPicYuv; |
---|
2035 | |
---|
2036 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
2037 | |
---|
2038 | } |
---|
2039 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
2040 | } |
---|
2041 | |
---|
2042 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2043 | { |
---|
2044 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
2045 | |
---|
2046 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
2047 | |
---|
2048 | for ( Int i = 0; i < iSize; i++ ) |
---|
2049 | { |
---|
2050 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2051 | pcPicYuvRec->destroy(); |
---|
2052 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2053 | } |
---|
2054 | |
---|
2055 | } |
---|
2056 | |
---|
2057 | /** |
---|
2058 | Write access units to output file. |
---|
2059 | \param bitstreamFile target bitstream file |
---|
2060 | \param iNumEncoded number of encoded frames |
---|
2061 | \param accessUnits list of access units to be written |
---|
2062 | */ |
---|
2063 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2064 | { |
---|
2065 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
2066 | |
---|
2067 | if (m_isField) |
---|
2068 | { |
---|
2069 | //Reinterlace fields |
---|
2070 | Int i; |
---|
2071 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2072 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2073 | |
---|
2074 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2075 | { |
---|
2076 | --iterPicYuvRec; |
---|
2077 | } |
---|
2078 | |
---|
2079 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2080 | { |
---|
2081 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2082 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2083 | |
---|
2084 | if (m_pchReconFile) |
---|
2085 | { |
---|
2086 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
---|
2087 | } |
---|
2088 | |
---|
2089 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2090 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2091 | rateStatsAccum(auTop, statsTop); |
---|
2092 | |
---|
2093 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2094 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2095 | rateStatsAccum(auBottom, statsBottom); |
---|
2096 | } |
---|
2097 | } |
---|
2098 | else |
---|
2099 | { |
---|
2100 | Int i; |
---|
2101 | |
---|
2102 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2103 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2104 | |
---|
2105 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2106 | { |
---|
2107 | --iterPicYuvRec; |
---|
2108 | } |
---|
2109 | |
---|
2110 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2111 | { |
---|
2112 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2113 | if (m_pchReconFile) |
---|
2114 | { |
---|
2115 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, |
---|
2116 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
---|
2117 | } |
---|
2118 | |
---|
2119 | const AccessUnit& au = *(iterBitstream++); |
---|
2120 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2121 | rateStatsAccum(au, stats); |
---|
2122 | } |
---|
2123 | } |
---|
2124 | } |
---|
2125 | #endif |
---|
2126 | |
---|
2127 | /** |
---|
2128 | * |
---|
2129 | */ |
---|
2130 | Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
2131 | { |
---|
2132 | AccessUnit::const_iterator it_au = au.begin(); |
---|
2133 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
2134 | |
---|
2135 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
2136 | { |
---|
2137 | switch ((*it_au)->m_nalUnitType) |
---|
2138 | { |
---|
2139 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2140 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2141 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2142 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2143 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2144 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2145 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2146 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2147 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2148 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2149 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2150 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2151 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2152 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2153 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2154 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2155 | case NAL_UNIT_VPS: |
---|
2156 | case NAL_UNIT_SPS: |
---|
2157 | case NAL_UNIT_PPS: |
---|
2158 | m_essentialBytes += *it_stats; |
---|
2159 | break; |
---|
2160 | default: |
---|
2161 | break; |
---|
2162 | } |
---|
2163 | |
---|
2164 | m_totalBytes += *it_stats; |
---|
2165 | } |
---|
2166 | } |
---|
2167 | |
---|
2168 | Void TAppEncTop::printRateSummary() |
---|
2169 | { |
---|
2170 | #if SVC_EXTENSION |
---|
2171 | Double time = (Double) m_iFrameRcvd / m_apcLayerCfg[m_numLayers-1]->getFrameRate(); |
---|
2172 | #else |
---|
2173 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
2174 | #endif |
---|
2175 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
2176 | if (m_summaryVerboseness > 0) |
---|
2177 | { |
---|
2178 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
2179 | } |
---|
2180 | } |
---|
2181 | |
---|
2182 | #if !SVC_EXTENSION |
---|
2183 | Void TAppEncTop::printChromaFormat() |
---|
2184 | { |
---|
2185 | std::cout << std::setw(43) << "Input ChromaFormatIDC = "; |
---|
2186 | switch (m_InputChromaFormatIDC) |
---|
2187 | { |
---|
2188 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
2189 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
2190 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
2191 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
2192 | default: |
---|
2193 | std::cerr << "Invalid"; |
---|
2194 | exit(1); |
---|
2195 | } |
---|
2196 | std::cout << std::endl; |
---|
2197 | |
---|
2198 | std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = "; |
---|
2199 | switch (m_cTEncTop.getChromaFormatIdc()) |
---|
2200 | { |
---|
2201 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
2202 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
2203 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
2204 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
2205 | default: |
---|
2206 | std::cerr << "Invalid"; |
---|
2207 | exit(1); |
---|
2208 | } |
---|
2209 | std::cout << "\n" << std::endl; |
---|
2210 | } |
---|
2211 | #endif |
---|
2212 | |
---|
2213 | //! \} |
---|