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, 0, sizeof(m_apcTVideoIOYuvInputFile) ); |
---|
67 | memset( m_apcTVideoIOYuvReconFile, 0, sizeof(m_apcTVideoIOYuvReconFile) ); |
---|
68 | memset( m_apcTEncTop, 0, 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 | m_cTEncTop.setAccessUnitDelimiter ( m_AccessUnitDelimiter ); |
---|
547 | |
---|
548 | #if SVC_EXTENSION |
---|
549 | m_cTEncTop.setMaxTempLayer ( layer ? m_EhMaxTempLayer[layer] : m_maxTempLayer ); |
---|
550 | #else |
---|
551 | m_cTEncTop.setMaxTempLayer ( m_maxTempLayer ); |
---|
552 | #endif |
---|
553 | m_cTEncTop.setUseAMP( m_enableAMP ); |
---|
554 | |
---|
555 | //===== Slice ======== |
---|
556 | |
---|
557 | //====== Loop/Deblock Filter ======== |
---|
558 | m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable ); |
---|
559 | m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); |
---|
560 | m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); |
---|
561 | m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); |
---|
562 | m_cTEncTop.setDeblockingFilterMetric ( m_DeblockingFilterMetric ); |
---|
563 | |
---|
564 | //====== Motion search ======== |
---|
565 | m_cTEncTop.setDisableIntraPUsInInterSlices ( m_bDisableIntraPUsInInterSlices ); |
---|
566 | m_cTEncTop.setMotionEstimationSearchMethod ( m_motionEstimationSearchMethod ); |
---|
567 | m_cTEncTop.setSearchRange ( m_iSearchRange ); |
---|
568 | m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange ); |
---|
569 | m_cTEncTop.setClipForBiPredMeEnabled ( m_bClipForBiPredMeEnabled ); |
---|
570 | m_cTEncTop.setFastMEAssumingSmootherMVEnabled ( m_bFastMEAssumingSmootherMVEnabled ); |
---|
571 | m_cTEncTop.setMinSearchWindow ( m_minSearchWindow ); |
---|
572 | m_cTEncTop.setRestrictMESampling ( m_bRestrictMESampling ); |
---|
573 | |
---|
574 | //====== Quality control ======== |
---|
575 | m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP ); |
---|
576 | m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth ); |
---|
577 | m_cTEncTop.setDiffCuChromaQpOffsetDepth ( m_diffCuChromaQpOffsetDepth ); |
---|
578 | m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset ); |
---|
579 | m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset ); |
---|
580 | |
---|
581 | m_cTEncTop.setChromaFormatIdc ( m_chromaFormatIDC ); |
---|
582 | |
---|
583 | #if ADAPTIVE_QP_SELECTION |
---|
584 | m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect ); |
---|
585 | #endif |
---|
586 | |
---|
587 | m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP ); |
---|
588 | m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange ); |
---|
589 | m_cTEncTop.setExtendedPrecisionProcessingFlag ( m_extendedPrecisionProcessingFlag ); |
---|
590 | m_cTEncTop.setHighPrecisionOffsetsEnabledFlag ( m_highPrecisionOffsetsEnabledFlag ); |
---|
591 | |
---|
592 | m_cTEncTop.setWeightedPredictionMethod( m_weightedPredictionMethod ); |
---|
593 | |
---|
594 | //====== Tool list ======== |
---|
595 | m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD ); |
---|
596 | m_cTEncTop.setFastDeltaQp ( m_bFastDeltaQP ); |
---|
597 | m_cTEncTop.setUseASR ( m_bUseASR ); |
---|
598 | m_cTEncTop.setUseHADME ( m_bUseHADME ); |
---|
599 | m_cTEncTop.setdQPs ( m_aidQP ); |
---|
600 | m_cTEncTop.setUseRDOQ ( m_useRDOQ ); |
---|
601 | m_cTEncTop.setUseRDOQTS ( m_useRDOQTS ); |
---|
602 | #if T0196_SELECTIVE_RDOQ |
---|
603 | m_cTEncTop.setUseSelectiveRDOQ ( m_useSelectiveRDOQ ); |
---|
604 | #endif |
---|
605 | m_cTEncTop.setRDpenalty ( m_rdPenalty ); |
---|
606 | m_cTEncTop.setMaxCUWidth ( m_uiMaxCUWidth ); |
---|
607 | m_cTEncTop.setMaxCUHeight ( m_uiMaxCUHeight ); |
---|
608 | m_cTEncTop.setMaxTotalCUDepth ( m_uiMaxTotalCUDepth ); |
---|
609 | m_cTEncTop.setLog2DiffMaxMinCodingBlockSize ( m_uiLog2DiffMaxMinCodingBlockSize ); |
---|
610 | m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize ); |
---|
611 | m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize ); |
---|
612 | m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter ); |
---|
613 | m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra ); |
---|
614 | m_cTEncTop.setFastInterSearchMode ( m_fastInterSearchMode ); |
---|
615 | m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU ); |
---|
616 | m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge ); |
---|
617 | m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode ); |
---|
618 | m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection ); |
---|
619 | m_cTEncTop.setCrossComponentPredictionEnabledFlag ( m_crossComponentPredictionEnabledFlag ); |
---|
620 | m_cTEncTop.setUseReconBasedCrossCPredictionEstimate ( m_reconBasedCrossCPredictionEstimate ); |
---|
621 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_LUMA , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] ); |
---|
622 | m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); |
---|
623 | m_cTEncTop.setUseTransformSkip ( m_useTransformSkip ); |
---|
624 | m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast ); |
---|
625 | m_cTEncTop.setTransformSkipRotationEnabledFlag ( m_transformSkipRotationEnabledFlag ); |
---|
626 | m_cTEncTop.setTransformSkipContextEnabledFlag ( m_transformSkipContextEnabledFlag ); |
---|
627 | m_cTEncTop.setPersistentRiceAdaptationEnabledFlag ( m_persistentRiceAdaptationEnabledFlag ); |
---|
628 | m_cTEncTop.setCabacBypassAlignmentEnabledFlag ( m_cabacBypassAlignmentEnabledFlag ); |
---|
629 | m_cTEncTop.setLog2MaxTransformSkipBlockSize ( m_log2MaxTransformSkipBlockSize ); |
---|
630 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
631 | { |
---|
632 | m_cTEncTop.setRdpcmEnabledFlag ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]); |
---|
633 | } |
---|
634 | m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred ); |
---|
635 | m_cTEncTop.setFastUDIUseMPMEnabled ( m_bFastUDIUseMPMEnabled ); |
---|
636 | m_cTEncTop.setFastMEForGenBLowDelayEnabled ( m_bFastMEForGenBLowDelayEnabled ); |
---|
637 | m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures ( m_bUseBLambdaForNonKeyLowDelayPictures ); |
---|
638 | m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize); |
---|
639 | m_cTEncTop.setUsePCM ( m_usePCM ); |
---|
640 | |
---|
641 | // set internal bit-depth and constants |
---|
642 | for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++) |
---|
643 | { |
---|
644 | #if SVC_EXTENSION |
---|
645 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
---|
646 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_apcLayerCfg[layer]->m_MSBExtendedBitDepth[channelType] : m_apcLayerCfg[layer]->m_internalBitDepth[channelType]); |
---|
647 | #else |
---|
648 | m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]); |
---|
649 | m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]); |
---|
650 | #endif |
---|
651 | } |
---|
652 | |
---|
653 | m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize); |
---|
654 | m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand ); |
---|
655 | |
---|
656 | |
---|
657 | //====== Weighted Prediction ======== |
---|
658 | m_cTEncTop.setUseWP ( m_useWeightedPred ); |
---|
659 | m_cTEncTop.setWPBiPred ( m_useWeightedBiPred ); |
---|
660 | |
---|
661 | //====== Parallel Merge Estimation ======== |
---|
662 | m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 ); |
---|
663 | |
---|
664 | //====== Slice ======== |
---|
665 | m_cTEncTop.setSliceMode ( (SliceConstraint) m_sliceMode ); |
---|
666 | m_cTEncTop.setSliceArgument ( m_sliceArgument ); |
---|
667 | |
---|
668 | //====== Dependent Slice ======== |
---|
669 | m_cTEncTop.setSliceSegmentMode ( (SliceConstraint) m_sliceSegmentMode ); |
---|
670 | m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument ); |
---|
671 | |
---|
672 | if(m_sliceMode == NO_SLICES ) |
---|
673 | { |
---|
674 | m_bLFCrossSliceBoundaryFlag = true; |
---|
675 | } |
---|
676 | m_cTEncTop.setLFCrossSliceBoundaryFlag ( m_bLFCrossSliceBoundaryFlag ); |
---|
677 | m_cTEncTop.setUseSAO ( m_bUseSAO ); |
---|
678 | m_cTEncTop.setTestSAODisableAtPictureLevel ( m_bTestSAODisableAtPictureLevel ); |
---|
679 | m_cTEncTop.setSaoEncodingRate ( m_saoEncodingRate ); |
---|
680 | m_cTEncTop.setSaoEncodingRateChroma ( m_saoEncodingRateChroma ); |
---|
681 | m_cTEncTop.setMaxNumOffsetsPerPic ( m_maxNumOffsetsPerPic); |
---|
682 | |
---|
683 | m_cTEncTop.setSaoCtuBoundary ( m_saoCtuBoundary); |
---|
684 | m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag); |
---|
685 | m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag); |
---|
686 | |
---|
687 | m_cTEncTop.setIntraSmoothingDisabledFlag (!m_enableIntraReferenceSmoothing ); |
---|
688 | m_cTEncTop.setDecodedPictureHashSEIEnabled ( m_decodedPictureHashSEIEnabled ); |
---|
689 | m_cTEncTop.setRecoveryPointSEIEnabled ( m_recoveryPointSEIEnabled ); |
---|
690 | m_cTEncTop.setBufferingPeriodSEIEnabled ( m_bufferingPeriodSEIEnabled ); |
---|
691 | m_cTEncTop.setPictureTimingSEIEnabled ( m_pictureTimingSEIEnabled ); |
---|
692 | m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled ); |
---|
693 | m_cTEncTop.setTMISEIToneMapId ( m_toneMapId ); |
---|
694 | m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag ); |
---|
695 | m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag ); |
---|
696 | m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth ); |
---|
697 | m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth ); |
---|
698 | m_cTEncTop.setTMISEIModelID ( m_toneMapModelId ); |
---|
699 | m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue ); |
---|
700 | m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue ); |
---|
701 | m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint ); |
---|
702 | m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth ); |
---|
703 | m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval ); |
---|
704 | m_cTEncTop.setTMISEINumPivots ( m_numPivots ); |
---|
705 | m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue ); |
---|
706 | m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue ); |
---|
707 | m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc ); |
---|
708 | m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue ); |
---|
709 | m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc ); |
---|
710 | m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue ); |
---|
711 | m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag ); |
---|
712 | m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator ); |
---|
713 | m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc ); |
---|
714 | m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite ); |
---|
715 | m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel ); |
---|
716 | m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue ); |
---|
717 | m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue ); |
---|
718 | m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue ); |
---|
719 | m_cTEncTop.setChromaSamplingFilterHintEnabled ( m_chromaSamplingFilterSEIenabled ); |
---|
720 | m_cTEncTop.setChromaSamplingHorFilterIdc ( m_chromaSamplingHorFilterIdc ); |
---|
721 | m_cTEncTop.setChromaSamplingVerFilterIdc ( m_chromaSamplingVerFilterIdc ); |
---|
722 | m_cTEncTop.setFramePackingArrangementSEIEnabled ( m_framePackingSEIEnabled ); |
---|
723 | m_cTEncTop.setFramePackingArrangementSEIType ( m_framePackingSEIType ); |
---|
724 | m_cTEncTop.setFramePackingArrangementSEIId ( m_framePackingSEIId ); |
---|
725 | m_cTEncTop.setFramePackingArrangementSEIQuincunx ( m_framePackingSEIQuincunx ); |
---|
726 | m_cTEncTop.setFramePackingArrangementSEIInterpretation ( m_framePackingSEIInterpretation ); |
---|
727 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled ( m_segmentedRectFramePackingSEIEnabled ); |
---|
728 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel ( m_segmentedRectFramePackingSEICancel ); |
---|
729 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType ( m_segmentedRectFramePackingSEIType ); |
---|
730 | m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence ); |
---|
731 | m_cTEncTop.setDisplayOrientationSEIAngle ( m_displayOrientationSEIAngle ); |
---|
732 | m_cTEncTop.setTemporalLevel0IndexSEIEnabled ( m_temporalLevel0IndexSEIEnabled ); |
---|
733 | m_cTEncTop.setGradualDecodingRefreshInfoEnabled ( m_gradualDecodingRefreshInfoEnabled ); |
---|
734 | m_cTEncTop.setNoDisplaySEITLayer ( m_noDisplaySEITLayer ); |
---|
735 | m_cTEncTop.setDecodingUnitInfoSEIEnabled ( m_decodingUnitInfoSEIEnabled ); |
---|
736 | m_cTEncTop.setSOPDescriptionSEIEnabled ( m_SOPDescriptionSEIEnabled ); |
---|
737 | m_cTEncTop.setScalableNestingSEIEnabled ( m_scalableNestingSEIEnabled ); |
---|
738 | m_cTEncTop.setTMCTSSEIEnabled ( m_tmctsSEIEnabled ); |
---|
739 | m_cTEncTop.setTimeCodeSEIEnabled ( m_timeCodeSEIEnabled ); |
---|
740 | m_cTEncTop.setNumberOfTimeSets ( m_timeCodeSEINumTs ); |
---|
741 | for(Int i = 0; i < m_timeCodeSEINumTs; i++) |
---|
742 | { |
---|
743 | m_cTEncTop.setTimeSet(m_timeSetArray[i], i); |
---|
744 | } |
---|
745 | m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled ); |
---|
746 | m_cTEncTop.setKneeSEIId ( m_kneeSEIId ); |
---|
747 | m_cTEncTop.setKneeSEICancelFlag ( m_kneeSEICancelFlag ); |
---|
748 | m_cTEncTop.setKneeSEIPersistenceFlag ( m_kneeSEIPersistenceFlag ); |
---|
749 | m_cTEncTop.setKneeSEIInputDrange ( m_kneeSEIInputDrange ); |
---|
750 | m_cTEncTop.setKneeSEIInputDispLuminance ( m_kneeSEIInputDispLuminance ); |
---|
751 | m_cTEncTop.setKneeSEIOutputDrange ( m_kneeSEIOutputDrange ); |
---|
752 | m_cTEncTop.setKneeSEIOutputDispLuminance ( m_kneeSEIOutputDispLuminance ); |
---|
753 | m_cTEncTop.setKneeSEINumKneePointsMinus1 ( m_kneeSEINumKneePointsMinus1 ); |
---|
754 | m_cTEncTop.setKneeSEIInputKneePoint ( m_kneeSEIInputKneePoint ); |
---|
755 | m_cTEncTop.setKneeSEIOutputKneePoint ( m_kneeSEIOutputKneePoint ); |
---|
756 | m_cTEncTop.setMasteringDisplaySEI ( m_masteringDisplay ); |
---|
757 | |
---|
758 | m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag ); |
---|
759 | m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 ); |
---|
760 | m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 ); |
---|
761 | if(!m_tileUniformSpacingFlag) |
---|
762 | { |
---|
763 | m_cTEncTop.setColumnWidth ( m_tileColumnWidth ); |
---|
764 | m_cTEncTop.setRowHeight ( m_tileRowHeight ); |
---|
765 | } |
---|
766 | m_cTEncTop.xCheckGSParameters(); |
---|
767 | Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1); |
---|
768 | if(uiTilesCount == 1) |
---|
769 | { |
---|
770 | m_bLFCrossTileBoundaryFlag = true; |
---|
771 | } |
---|
772 | m_cTEncTop.setLFCrossTileBoundaryFlag ( m_bLFCrossTileBoundaryFlag ); |
---|
773 | m_cTEncTop.setWaveFrontSynchro ( m_iWaveFrontSynchro ); |
---|
774 | m_cTEncTop.setTMVPModeId ( m_TMVPModeId ); |
---|
775 | m_cTEncTop.setUseScalingListId ( m_useScalingListId ); |
---|
776 | m_cTEncTop.setScalingListFile ( m_scalingListFile ); |
---|
777 | m_cTEncTop.setSignHideFlag ( m_signHideFlag); |
---|
778 | m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl ); |
---|
779 | m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate ); |
---|
780 | m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit ); |
---|
781 | m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC ); |
---|
782 | m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel ); |
---|
783 | m_cTEncTop.setInitialQP ( m_RCInitialQP ); |
---|
784 | m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP ); |
---|
785 | m_cTEncTop.setTransquantBypassEnableFlag ( m_TransquantBypassEnableFlag ); |
---|
786 | m_cTEncTop.setCUTransquantBypassFlagForceValue ( m_CUTransquantBypassFlagForce ); |
---|
787 | m_cTEncTop.setCostMode ( m_costMode ); |
---|
788 | m_cTEncTop.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); |
---|
789 | m_cTEncTop.setUseStrongIntraSmoothing ( m_useStrongIntraSmoothing ); |
---|
790 | m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); |
---|
791 | m_cTEncTop.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag ); |
---|
792 | m_cTEncTop.setAspectRatioInfoPresentFlag ( m_aspectRatioInfoPresentFlag); |
---|
793 | m_cTEncTop.setAspectRatioIdc ( m_aspectRatioIdc ); |
---|
794 | m_cTEncTop.setSarWidth ( m_sarWidth ); |
---|
795 | m_cTEncTop.setSarHeight ( m_sarHeight ); |
---|
796 | m_cTEncTop.setOverscanInfoPresentFlag ( m_overscanInfoPresentFlag ); |
---|
797 | m_cTEncTop.setOverscanAppropriateFlag ( m_overscanAppropriateFlag ); |
---|
798 | m_cTEncTop.setVideoSignalTypePresentFlag ( m_videoSignalTypePresentFlag ); |
---|
799 | m_cTEncTop.setVideoFormat ( m_videoFormat ); |
---|
800 | m_cTEncTop.setVideoFullRangeFlag ( m_videoFullRangeFlag ); |
---|
801 | m_cTEncTop.setColourDescriptionPresentFlag ( m_colourDescriptionPresentFlag ); |
---|
802 | m_cTEncTop.setColourPrimaries ( m_colourPrimaries ); |
---|
803 | m_cTEncTop.setTransferCharacteristics ( m_transferCharacteristics ); |
---|
804 | m_cTEncTop.setMatrixCoefficients ( m_matrixCoefficients ); |
---|
805 | m_cTEncTop.setChromaLocInfoPresentFlag ( m_chromaLocInfoPresentFlag ); |
---|
806 | m_cTEncTop.setChromaSampleLocTypeTopField ( m_chromaSampleLocTypeTopField ); |
---|
807 | m_cTEncTop.setChromaSampleLocTypeBottomField ( m_chromaSampleLocTypeBottomField ); |
---|
808 | m_cTEncTop.setNeutralChromaIndicationFlag ( m_neutralChromaIndicationFlag ); |
---|
809 | m_cTEncTop.setDefaultDisplayWindow ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset ); |
---|
810 | m_cTEncTop.setFrameFieldInfoPresentFlag ( m_frameFieldInfoPresentFlag ); |
---|
811 | m_cTEncTop.setPocProportionalToTimingFlag ( m_pocProportionalToTimingFlag ); |
---|
812 | m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 ); |
---|
813 | m_cTEncTop.setBitstreamRestrictionFlag ( m_bitstreamRestrictionFlag ); |
---|
814 | m_cTEncTop.setTilesFixedStructureFlag ( m_tilesFixedStructureFlag ); |
---|
815 | m_cTEncTop.setMotionVectorsOverPicBoundariesFlag ( m_motionVectorsOverPicBoundariesFlag ); |
---|
816 | m_cTEncTop.setMinSpatialSegmentationIdc ( m_minSpatialSegmentationIdc ); |
---|
817 | m_cTEncTop.setMaxBytesPerPicDenom ( m_maxBytesPerPicDenom ); |
---|
818 | m_cTEncTop.setMaxBitsPerMinCuDenom ( m_maxBitsPerMinCuDenom ); |
---|
819 | m_cTEncTop.setLog2MaxMvLengthHorizontal ( m_log2MaxMvLengthHorizontal ); |
---|
820 | m_cTEncTop.setLog2MaxMvLengthVertical ( m_log2MaxMvLengthVertical ); |
---|
821 | m_cTEncTop.setEfficientFieldIRAPEnabled ( m_bEfficientFieldIRAPEnabled ); |
---|
822 | m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled ( m_bHarmonizeGopFirstFieldCoupleEnabled ); |
---|
823 | |
---|
824 | m_cTEncTop.setSummaryOutFilename ( m_summaryOutFilename ); |
---|
825 | m_cTEncTop.setSummaryPicFilenameBase ( m_summaryPicFilenameBase ); |
---|
826 | m_cTEncTop.setSummaryVerboseness ( m_summaryVerboseness ); |
---|
827 | |
---|
828 | #if FAST_INTRA_SHVC |
---|
829 | m_cTEncTop.setUseFastIntraScalable ( m_useFastIntraScalable ); |
---|
830 | #endif |
---|
831 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
832 | #if SVC_EXTENSION |
---|
833 | m_cTEncTop.setCRISEIFileRoot ( const_cast<Char*>(m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot.c_str()) ); |
---|
834 | #else |
---|
835 | m_cTEncTop.setCRISEIFileRoot ( const_cast<Char*>(m_colourRemapSEIFileRoot.c_str()) ); |
---|
836 | #endif |
---|
837 | #endif |
---|
838 | #if LAYERS_NOT_PRESENT_SEI |
---|
839 | m_cTEncTop.setLayersNotPresentSEIEnabled ( m_layersNotPresentSEIEnabled ); |
---|
840 | #endif |
---|
841 | |
---|
842 | |
---|
843 | #if SVC_EXTENSION |
---|
844 | if( layer != 0 && m_useInterLayerWeightedPred ) |
---|
845 | { |
---|
846 | // Enable weighted prediction for enhancement layer |
---|
847 | m_cTEncTop.setUseWP ( true ); |
---|
848 | m_cTEncTop.setWPBiPred ( true ); |
---|
849 | } |
---|
850 | |
---|
851 | } |
---|
852 | #endif |
---|
853 | } |
---|
854 | |
---|
855 | Void TAppEncTop::xCreateLib() |
---|
856 | { |
---|
857 | // Video I/O |
---|
858 | #if SVC_EXTENSION |
---|
859 | // initialize global variables |
---|
860 | initROM(); |
---|
861 | |
---|
862 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
863 | { |
---|
864 | //2 |
---|
865 | // Video I/O |
---|
866 | 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 |
---|
867 | 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); |
---|
868 | |
---|
869 | if( !m_apcLayerCfg[layer]->getReconFile().empty() ) |
---|
870 | { |
---|
871 | 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 |
---|
872 | } |
---|
873 | |
---|
874 | // Neo Decoder |
---|
875 | m_apcTEncTop[layer]->create(); |
---|
876 | } |
---|
877 | #else //SVC_EXTENSION |
---|
878 | // Video I/O |
---|
879 | m_cTVideoIOYuvInputFile.open( m_pchInputFile, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth ); // read mode |
---|
880 | m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC); |
---|
881 | |
---|
882 | if (m_pchReconFile) |
---|
883 | { |
---|
884 | m_cTVideoIOYuvReconFile.open(m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth); // write mode |
---|
885 | } |
---|
886 | |
---|
887 | // Neo Decoder |
---|
888 | m_cTEncTop.create(); |
---|
889 | #endif //SVC_EXTENSION |
---|
890 | } |
---|
891 | |
---|
892 | Void TAppEncTop::xDestroyLib() |
---|
893 | { |
---|
894 | // Video I/O |
---|
895 | #if SVC_EXTENSION |
---|
896 | // destroy ROM |
---|
897 | destroyROM(); |
---|
898 | |
---|
899 | for( UInt layer=0; layer < m_numLayers; layer++ ) |
---|
900 | { |
---|
901 | if( m_apcTVideoIOYuvInputFile[layer] ) |
---|
902 | { |
---|
903 | m_apcTVideoIOYuvInputFile[layer]->close(); |
---|
904 | delete m_apcTVideoIOYuvInputFile[layer]; |
---|
905 | m_apcTVideoIOYuvInputFile[layer] = NULL; |
---|
906 | } |
---|
907 | |
---|
908 | if( m_apcTVideoIOYuvReconFile[layer] ) |
---|
909 | { |
---|
910 | m_apcTVideoIOYuvReconFile[layer]->close(); |
---|
911 | delete m_apcTVideoIOYuvReconFile[layer]; |
---|
912 | m_apcTVideoIOYuvReconFile[layer] = NULL; |
---|
913 | } |
---|
914 | |
---|
915 | if( m_apcTEncTop[layer] ) |
---|
916 | { |
---|
917 | m_apcTEncTop[layer]->destroy(); |
---|
918 | delete m_apcTEncTop[layer]; |
---|
919 | m_apcTEncTop[layer] = NULL; |
---|
920 | } |
---|
921 | } |
---|
922 | #else //SVC_EXTENSION |
---|
923 | m_cTVideoIOYuvInputFile.close(); |
---|
924 | m_cTVideoIOYuvReconFile.close(); |
---|
925 | |
---|
926 | // Neo Decoder |
---|
927 | m_cTEncTop.destroy(); |
---|
928 | #endif //SVC_EXTENSION |
---|
929 | } |
---|
930 | |
---|
931 | Void TAppEncTop::xInitLib(Bool isFieldCoding) |
---|
932 | { |
---|
933 | #if SVC_EXTENSION |
---|
934 | TComVPS* vps = m_apcTEncTop[0]->getVPS(); |
---|
935 | m_apcTEncTop[0]->getVPS()->setMaxLayers( m_numLayers ); |
---|
936 | |
---|
937 | UInt i = 0, dimIdLen = 0; |
---|
938 | |
---|
939 | while((1 << dimIdLen) < m_numLayers) |
---|
940 | { |
---|
941 | dimIdLen++; |
---|
942 | } |
---|
943 | vps->setDimensionIdLen(0, dimIdLen); |
---|
944 | vps->setNuhLayerIdPresentFlag(false); |
---|
945 | vps->setLayerIdInNuh(0, 0); |
---|
946 | vps->setLayerIdxInVps(0, 0); |
---|
947 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
948 | { |
---|
949 | vps->setLayerIdInNuh(i, m_apcLayerCfg[i]->m_layerId); |
---|
950 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
---|
951 | vps->setDimensionId(i, 0, i); |
---|
952 | |
---|
953 | if( m_apcLayerCfg[i]->m_layerId != i ) |
---|
954 | { |
---|
955 | vps->setNuhLayerIdPresentFlag(true); |
---|
956 | } |
---|
957 | } |
---|
958 | |
---|
959 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
960 | { |
---|
961 | //3 |
---|
962 | #if LAYER_CTB |
---|
963 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
964 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
965 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
966 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
967 | #endif |
---|
968 | m_apcTEncTop[layer]->init(isFieldCoding); |
---|
969 | } |
---|
970 | |
---|
971 | // Set max-layer ID |
---|
972 | vps->setMaxLayerId( m_apcLayerCfg[m_numLayers - 1]->m_layerId ); |
---|
973 | vps->setVpsExtensionFlag( m_numLayers > 1 ? true : false ); |
---|
974 | |
---|
975 | if( m_numLayerSets > 1 ) |
---|
976 | { |
---|
977 | vps->setNumLayerSets(m_numLayerSets); |
---|
978 | |
---|
979 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
980 | { |
---|
981 | for (Int layerId = 0; layerId <= vps->getMaxLayerId(); layerId++) |
---|
982 | { |
---|
983 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
984 | } |
---|
985 | } |
---|
986 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
987 | { |
---|
988 | for( i = 0; i < m_numLayerInIdList[setId]; i++ ) |
---|
989 | { |
---|
990 | //4 |
---|
991 | vps->setLayerIdIncludedFlag(true, setId, m_layerSetLayerIdList[setId][i]); |
---|
992 | } |
---|
993 | } |
---|
994 | } |
---|
995 | else |
---|
996 | { |
---|
997 | // Default layer sets |
---|
998 | vps->setNumLayerSets(m_numLayers); |
---|
999 | for (Int setId = 1; setId < vps->getNumLayerSets(); setId++) |
---|
1000 | { |
---|
1001 | for (Int layerIdx = 0; layerIdx <= vps->getMaxLayers(); layerIdx++) |
---|
1002 | { |
---|
1003 | //4 |
---|
1004 | UInt layerId = vps->getLayerIdInNuh(layerIdx); |
---|
1005 | |
---|
1006 | if (layerId <= setId) |
---|
1007 | { |
---|
1008 | vps->setLayerIdIncludedFlag(true, setId, layerId); |
---|
1009 | } |
---|
1010 | else |
---|
1011 | { |
---|
1012 | vps->setLayerIdIncludedFlag(false, setId, layerId); |
---|
1013 | } |
---|
1014 | } |
---|
1015 | } |
---|
1016 | } |
---|
1017 | |
---|
1018 | vps->setVpsNumLayerSetsMinus1(vps->getNumLayerSets() - 1); |
---|
1019 | vps->setNumAddLayerSets(m_numAddLayerSets); |
---|
1020 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
1021 | |
---|
1022 | if( m_numAddLayerSets > 0 ) |
---|
1023 | { |
---|
1024 | for (Int setId = 0; setId < m_numAddLayerSets; setId++) |
---|
1025 | { |
---|
1026 | for (Int j = 0; j < m_numHighestLayerIdx[setId]; j++) |
---|
1027 | { |
---|
1028 | vps->setHighestLayerIdxPlus1(setId, j + 1, m_highestLayerIdx[setId][j] + 1); |
---|
1029 | } |
---|
1030 | } |
---|
1031 | } |
---|
1032 | |
---|
1033 | #if AVC_BASE |
---|
1034 | vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag ); |
---|
1035 | if ( m_nonHEVCBaseLayerFlag ) |
---|
1036 | { |
---|
1037 | vps->setBaseLayerInternalFlag (false); |
---|
1038 | } |
---|
1039 | #else |
---|
1040 | vps->setAvcBaseLayerFlag(false); |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | for( Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx < vps->getNumProfileTierLevel(); idx++ ) |
---|
1044 | { |
---|
1045 | vps->setProfilePresentFlag(idx, true); |
---|
1046 | } |
---|
1047 | |
---|
1048 | vps->setSplittingFlag(false); |
---|
1049 | |
---|
1050 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1051 | { |
---|
1052 | vps->setScalabilityMask(i, false); |
---|
1053 | } |
---|
1054 | if(m_numLayers > 1) |
---|
1055 | { |
---|
1056 | Int scalabilityTypes = 0; |
---|
1057 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1058 | { |
---|
1059 | vps->setScalabilityMask(i, m_scalabilityMask[i]); |
---|
1060 | scalabilityTypes += m_scalabilityMask[i]; |
---|
1061 | } |
---|
1062 | #if AUXILIARY_PICTURES |
---|
1063 | assert( scalabilityTypes <= 2 ); |
---|
1064 | #else |
---|
1065 | assert( scalabilityTypes == 1 ); |
---|
1066 | #endif |
---|
1067 | vps->setNumScalabilityTypes(scalabilityTypes); |
---|
1068 | } |
---|
1069 | else |
---|
1070 | { |
---|
1071 | vps->setNumScalabilityTypes(0); |
---|
1072 | } |
---|
1073 | |
---|
1074 | #if AUXILIARY_PICTURES |
---|
1075 | if (m_scalabilityMask[AUX_ID]) |
---|
1076 | { |
---|
1077 | UInt maxAuxId = 0; |
---|
1078 | UInt auxDimIdLen = 1; |
---|
1079 | Int auxId = vps->getNumScalabilityTypes() - 1; |
---|
1080 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1081 | { |
---|
1082 | if (m_apcLayerCfg[i]->getAuxId() > maxAuxId) |
---|
1083 | { |
---|
1084 | maxAuxId = m_apcLayerCfg[i]->getAuxId(); |
---|
1085 | } |
---|
1086 | } |
---|
1087 | while((1 << auxDimIdLen) < (maxAuxId + 1)) |
---|
1088 | { |
---|
1089 | auxDimIdLen++; |
---|
1090 | } |
---|
1091 | vps->setDimensionIdLen(auxId, auxDimIdLen); |
---|
1092 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1093 | { |
---|
1094 | vps->setDimensionId(i, auxId, m_apcLayerCfg[i]->getAuxId()); |
---|
1095 | } |
---|
1096 | } |
---|
1097 | #endif |
---|
1098 | |
---|
1099 | vps->setMaxTSLayersPresentFlag(true); |
---|
1100 | |
---|
1101 | for( i = 0; i < vps->getMaxLayers(); i++ ) |
---|
1102 | { |
---|
1103 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
1104 | } |
---|
1105 | |
---|
1106 | vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag); |
---|
1107 | if (vps->getMaxTidRefPresentFlag()) |
---|
1108 | { |
---|
1109 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1110 | { |
---|
1111 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1112 | { |
---|
1113 | vps->setMaxTidIlRefPicsPlus1(i, j, m_apcTEncTop[i]->getMaxTidIlRefPicsPlus1()); |
---|
1114 | } |
---|
1115 | } |
---|
1116 | } |
---|
1117 | else |
---|
1118 | { |
---|
1119 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
1120 | { |
---|
1121 | for( Int j = i+1; j < vps->getMaxLayers(); j++) |
---|
1122 | { |
---|
1123 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
1124 | } |
---|
1125 | } |
---|
1126 | } |
---|
1127 | |
---|
1128 | vps->setIlpSshSignalingEnabledFlag(false); |
---|
1129 | |
---|
1130 | // Direct reference layers |
---|
1131 | UInt maxDirectRefLayers = 0; |
---|
1132 | Bool isDefaultDirectDependencyTypeSet = false; |
---|
1133 | for (UInt layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
---|
1134 | { |
---|
1135 | UInt layerId = vps->getLayerIdInNuh(layerCtr); |
---|
1136 | Int numDirectRefLayers = 0; |
---|
1137 | |
---|
1138 | vps->setNumDirectRefLayers(layerId, m_apcTEncTop[layerCtr]->getNumDirectRefLayers()); |
---|
1139 | maxDirectRefLayers = max<UInt>(maxDirectRefLayers, vps->getNumDirectRefLayers(layerId)); |
---|
1140 | |
---|
1141 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
---|
1142 | { |
---|
1143 | vps->setRefLayerId(layerId, i, m_apcTEncTop[layerCtr]->getRefLayerId(i)); |
---|
1144 | } |
---|
1145 | // Set direct dependency flag |
---|
1146 | // Initialize flag to 0 |
---|
1147 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1148 | { |
---|
1149 | vps->setDirectDependencyFlag(layerCtr, refLayerCtr, false); |
---|
1150 | } |
---|
1151 | for (i = 0; i < vps->getNumDirectRefLayers(layerId); i++) |
---|
1152 | { |
---|
1153 | vps->setDirectDependencyFlag(layerCtr, vps->getLayerIdxInVps(m_apcTEncTop[layerCtr]->getRefLayerId(i)), true); |
---|
1154 | } |
---|
1155 | // prediction indications |
---|
1156 | vps->setDirectDepTypeLen(2); // sample and motion types are encoded |
---|
1157 | for (Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1158 | { |
---|
1159 | if (vps->getDirectDependencyFlag(layerCtr, refLayerCtr)) |
---|
1160 | { |
---|
1161 | assert(m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) || m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers)); |
---|
1162 | vps->setDirectDependencyType(layerCtr, refLayerCtr, ((m_apcTEncTop[layerCtr]->getSamplePredEnabledFlag(numDirectRefLayers) ? 1 : 0) | |
---|
1163 | (m_apcTEncTop[layerCtr]->getMotionPredEnabledFlag(numDirectRefLayers) ? 2 : 0)) - 1); |
---|
1164 | |
---|
1165 | if (!isDefaultDirectDependencyTypeSet) |
---|
1166 | { |
---|
1167 | vps->setDefaultDirectDependecyTypeFlag(1); |
---|
1168 | vps->setDefaultDirectDependecyType(vps->getDirectDependencyType(layerCtr, refLayerCtr)); |
---|
1169 | isDefaultDirectDependencyTypeSet = true; |
---|
1170 | } |
---|
1171 | else if (vps->getDirectDependencyType(layerCtr, refLayerCtr) != vps->getDefaultDirectDependencyType()) |
---|
1172 | { |
---|
1173 | vps->setDefaultDirectDependecyTypeFlag(0); |
---|
1174 | } |
---|
1175 | |
---|
1176 | numDirectRefLayers ++; |
---|
1177 | } |
---|
1178 | else |
---|
1179 | { |
---|
1180 | vps->setDirectDependencyType(layerCtr, refLayerCtr, 0); |
---|
1181 | } |
---|
1182 | } |
---|
1183 | } |
---|
1184 | |
---|
1185 | // dependency constraint |
---|
1186 | vps->setNumRefLayers(); |
---|
1187 | |
---|
1188 | if( vps->getMaxLayers() > MAX_REF_LAYERS ) |
---|
1189 | { |
---|
1190 | for( UInt layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++ ) |
---|
1191 | { |
---|
1192 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(layerCtr)) <= MAX_REF_LAYERS); |
---|
1193 | } |
---|
1194 | } |
---|
1195 | |
---|
1196 | // The Layer ID List variables should be derived here. |
---|
1197 | vps->deriveLayerIdListVariables(); |
---|
1198 | vps->setPredictedLayerIds(); |
---|
1199 | vps->setTreePartitionLayerIdList(); |
---|
1200 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
1201 | |
---|
1202 | vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file |
---|
1203 | |
---|
1204 | if( m_numOutputLayerSets == -1 ) // # of output layer sets not specified in the configuration file |
---|
1205 | { |
---|
1206 | vps->setNumOutputLayerSets(vps->getNumLayerSets()); |
---|
1207 | |
---|
1208 | for(i = 1; i < vps->getNumLayerSets(); i++) |
---|
1209 | { |
---|
1210 | vps->setOutputLayerSetIdx(i, i); |
---|
1211 | } |
---|
1212 | } |
---|
1213 | else |
---|
1214 | { |
---|
1215 | vps->setNumOutputLayerSets( m_numOutputLayerSets ); |
---|
1216 | for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets |
---|
1217 | { |
---|
1218 | vps->setOutputLayerSetIdx(olsCtr, olsCtr); |
---|
1219 | } |
---|
1220 | for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ ) // Non-default output layer sets |
---|
1221 | { |
---|
1222 | vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]); |
---|
1223 | } |
---|
1224 | } |
---|
1225 | |
---|
1226 | // Target output layer |
---|
1227 | vps->deriveNumberOfSubDpbs(); |
---|
1228 | vps->setOutputLayerFlag( 0, 0, 1 ); |
---|
1229 | |
---|
1230 | // derive OutputLayerFlag[i][j] |
---|
1231 | // 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 |
---|
1232 | // 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. |
---|
1233 | |
---|
1234 | // Include the highest layer as output layer for each layer set |
---|
1235 | for(Int lsIdx = 1; lsIdx <= vps->getVpsNumLayerSetsMinus1(); lsIdx++) |
---|
1236 | { |
---|
1237 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(lsIdx); layer++ ) |
---|
1238 | { |
---|
1239 | switch( vps->getDefaultTargetOutputLayerIdc() ) |
---|
1240 | { |
---|
1241 | case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 ); |
---|
1242 | break; |
---|
1243 | case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 ); |
---|
1244 | break; |
---|
1245 | case 2: |
---|
1246 | 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() |
---|
1247 | : m_listOfOutputLayers[lsIdx][m_listOfOutputLayers[lsIdx].size()-1] == m_layerSetLayerIdList[lsIdx][layer] ); |
---|
1248 | break; |
---|
1249 | } |
---|
1250 | } |
---|
1251 | } |
---|
1252 | |
---|
1253 | for( Int olsIdx = vps->getVpsNumLayerSetsMinus1() + 1; olsIdx < vps->getNumOutputLayerSets(); olsIdx++ ) |
---|
1254 | { |
---|
1255 | for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ ) |
---|
1256 | { |
---|
1257 | 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() |
---|
1258 | : m_listOfOutputLayers[olsIdx][m_listOfOutputLayers[olsIdx].size()-1] == vps->getLayerSetLayerIdList(vps->getOutputLayerSetIdx(olsIdx), layer) ); |
---|
1259 | } |
---|
1260 | } |
---|
1261 | |
---|
1262 | vps->deriveNecessaryLayerFlag(); |
---|
1263 | vps->checkNecessaryLayerFlagCondition(); |
---|
1264 | vps->calculateMaxSLInLayerSets(); |
---|
1265 | |
---|
1266 | // Initialize dpb_size_table() for all ouput layer sets in the VPS extension |
---|
1267 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
1268 | { |
---|
1269 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
1270 | Int layerSetId = vps->getOutputLayerSetIdx(i); |
---|
1271 | |
---|
1272 | for(Int j = 0; j < vps->getMaxTLayers(); j++) |
---|
1273 | { |
---|
1274 | |
---|
1275 | Int maxNumReorderPics = -1; |
---|
1276 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
1277 | { |
---|
1278 | Int layerId = vps->getLayerSetLayerIdList(layerSetId, k); // k-th layer in the output layer set |
---|
1279 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getMaxDecPicBuffering(j) - 1 ); |
---|
1280 | maxNumReorderPics = std::max( maxNumReorderPics, m_apcTEncTop[vps->getLayerIdxInVps(layerId)]->getNumReorderPics(j)); |
---|
1281 | } |
---|
1282 | vps->setMaxVpsNumReorderPics(i, j, maxNumReorderPics); |
---|
1283 | vps->determineSubDpbInfoFlags(); |
---|
1284 | } |
---|
1285 | } |
---|
1286 | |
---|
1287 | vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); |
---|
1288 | |
---|
1289 | // POC LSB not present flag |
---|
1290 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
---|
1291 | { |
---|
1292 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
1293 | { |
---|
1294 | // make independedent layers base-layer compliant |
---|
1295 | vps->setPocLsbNotPresentFlag(i, true); |
---|
1296 | } |
---|
1297 | } |
---|
1298 | |
---|
1299 | vps->setCrossLayerPictureTypeAlignFlag( m_crossLayerPictureTypeAlignFlag ); |
---|
1300 | vps->setCrossLayerAlignedIdrOnlyFlag( m_crossLayerAlignedIdrOnlyFlag ); |
---|
1301 | vps->setCrossLayerIrapAlignFlag( m_crossLayerIrapAlignFlag ); |
---|
1302 | |
---|
1303 | if( vps->getCrossLayerPictureTypeAlignFlag() ) |
---|
1304 | { |
---|
1305 | // When not present, the value of cross_layer_irap_aligned_flag is inferred to be equal to vps_vui_present_flag, |
---|
1306 | assert( m_crossLayerIrapAlignFlag == true ); |
---|
1307 | vps->setCrossLayerIrapAlignFlag( true ); |
---|
1308 | } |
---|
1309 | |
---|
1310 | for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1311 | { |
---|
1312 | for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1313 | { |
---|
1314 | if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr)) |
---|
1315 | { |
---|
1316 | if(m_apcTEncTop[layerCtr]->getIntraPeriod() != m_apcTEncTop[refLayerCtr]->getIntraPeriod()) |
---|
1317 | { |
---|
1318 | vps->setCrossLayerIrapAlignFlag(false); |
---|
1319 | break; |
---|
1320 | } |
---|
1321 | } |
---|
1322 | } |
---|
1323 | } |
---|
1324 | vps->setSingleLayerForNonIrapFlag(m_adaptiveResolutionChange > 0 ? true : false); |
---|
1325 | vps->setHigherLayerIrapSkipFlag(m_skipPictureAtArcSwitch); |
---|
1326 | |
---|
1327 | for( Int k = 0; k < MAX_VPS_LAYER_SETS_PLUS1; k++ ) |
---|
1328 | { |
---|
1329 | vps->setAltOuputLayerFlag( k, m_altOutputLayerFlag ); |
---|
1330 | } |
---|
1331 | |
---|
1332 | // VPS VUI BSP HRD parameters |
---|
1333 | vps->setVpsVuiBspHrdPresentFlag(false); |
---|
1334 | TEncTop *pcCfg = m_apcTEncTop[0]; |
---|
1335 | if( pcCfg->getBufferingPeriodSEIEnabled() ) |
---|
1336 | { |
---|
1337 | Int j; |
---|
1338 | vps->setVpsVuiBspHrdPresentFlag(true); |
---|
1339 | vps->setVpsNumAddHrdParams( vps->getMaxLayers() ); |
---|
1340 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1); |
---|
1341 | for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) |
---|
1342 | { |
---|
1343 | vps->setCprmsAddPresentFlag( j, true ); |
---|
1344 | vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 ); |
---|
1345 | |
---|
1346 | UInt layerIdx = j; |
---|
1347 | TEncTop *pcCfgLayer = m_apcTEncTop[layerIdx]; |
---|
1348 | |
---|
1349 | Int iPicWidth = pcCfgLayer->getSourceWidth(); |
---|
1350 | Int iPicHeight = pcCfgLayer->getSourceHeight(); |
---|
1351 | |
---|
1352 | UInt uiWidthInCU = ( iPicWidth % m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth ) ? iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth + 1 : iPicWidth / m_apcLayerCfg[layerIdx]->m_uiMaxCUWidth; |
---|
1353 | UInt uiHeightInCU = ( iPicHeight % m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight ) ? iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight + 1 : iPicHeight / m_apcLayerCfg[layerIdx]->m_uiMaxCUHeight; |
---|
1354 | UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_apcLayerCfg[layerIdx]->m_uiMaxCUDepth << 1); |
---|
1355 | |
---|
1356 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
1357 | |
---|
1358 | UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 ); |
---|
1359 | if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 ) |
---|
1360 | { |
---|
1361 | numDU ++; |
---|
1362 | } |
---|
1363 | //vps->getBspHrd(i)->setNumDU( numDU ); |
---|
1364 | vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) ); |
---|
1365 | } |
---|
1366 | |
---|
1367 | // Signalling of additional partitioning schemes |
---|
1368 | for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ ) |
---|
1369 | { |
---|
1370 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
---|
1371 | vps->setNumSignalledPartitioningSchemes(h, 1); // Only the default per-layer partitioning scheme |
---|
1372 | for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
---|
1373 | { |
---|
1374 | // ToDo: Add code for additional partitioning schemes here |
---|
1375 | // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag |
---|
1376 | } |
---|
1377 | |
---|
1378 | for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ ) |
---|
1379 | { |
---|
1380 | if( i == 0 ) |
---|
1381 | { |
---|
1382 | for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++) |
---|
1383 | { |
---|
1384 | vps->setNumBspSchedulesMinus1( h, i, t, 0 ); |
---|
1385 | for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
---|
1386 | { |
---|
1387 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
1388 | { |
---|
1389 | // Only for the default partition |
---|
1390 | Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k); |
---|
1391 | Int layerIdxInVps = vps->getLayerIdxInVps( nuhlayerId ); |
---|
1392 | vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters()); |
---|
1393 | |
---|
1394 | vps->setBspSchedIdx(h, i, t, j, k, 0); |
---|
1395 | } |
---|
1396 | } |
---|
1397 | } |
---|
1398 | } |
---|
1399 | else |
---|
1400 | { |
---|
1401 | assert(0); // Need to add support for additional partitioning schemes. |
---|
1402 | } |
---|
1403 | } |
---|
1404 | } |
---|
1405 | } |
---|
1406 | #else //SVC_EXTENSION |
---|
1407 | m_cTEncTop.init(isFieldCoding); |
---|
1408 | #endif //SVC_EXTENSION |
---|
1409 | } |
---|
1410 | |
---|
1411 | // ==================================================================================================================== |
---|
1412 | // Public member functions |
---|
1413 | // ==================================================================================================================== |
---|
1414 | |
---|
1415 | /** |
---|
1416 | - create internal class |
---|
1417 | - initialize internal variable |
---|
1418 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1419 | - delete allocated buffers |
---|
1420 | - destroy internal class |
---|
1421 | . |
---|
1422 | */ |
---|
1423 | #if SVC_EXTENSION |
---|
1424 | Void TAppEncTop::encode() |
---|
1425 | { |
---|
1426 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1427 | if (!bitstreamFile) |
---|
1428 | { |
---|
1429 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1430 | exit(EXIT_FAILURE); |
---|
1431 | } |
---|
1432 | |
---|
1433 | // allocated memory |
---|
1434 | for( Int layer = 0; layer < m_numLayers; layer++ ) |
---|
1435 | { |
---|
1436 | m_apcTVideoIOYuvInputFile[layer] = new TVideoIOYuv; |
---|
1437 | m_apcTVideoIOYuvReconFile[layer] = new TVideoIOYuv; |
---|
1438 | m_apcTEncTop[layer] = new TEncTop; |
---|
1439 | } |
---|
1440 | |
---|
1441 | TComPicYuv* pcPicYuvOrg [MAX_LAYERS]; |
---|
1442 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1443 | |
---|
1444 | // initialize internal class & member variables |
---|
1445 | xInitLibCfg(); |
---|
1446 | xCreateLib(); |
---|
1447 | xInitLib(m_isField); |
---|
1448 | |
---|
1449 | // main encoder loop |
---|
1450 | Int iNumEncoded = 0, iTotalNumEncoded = 0; |
---|
1451 | Bool bEos = false; |
---|
1452 | |
---|
1453 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
---|
1454 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1455 | |
---|
1456 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1457 | |
---|
1458 | TComPicYuv acPicYuvTrueOrg[MAX_LAYERS]; |
---|
1459 | |
---|
1460 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1461 | { |
---|
1462 | //5 |
---|
1463 | // allocate original YUV buffer |
---|
1464 | pcPicYuvOrg[layer] = new TComPicYuv; |
---|
1465 | if( m_isField ) |
---|
1466 | { |
---|
1467 | 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 ); |
---|
1468 | 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 ); |
---|
1469 | } |
---|
1470 | else |
---|
1471 | { |
---|
1472 | 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 ); |
---|
1473 | 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 ); |
---|
1474 | } |
---|
1475 | } |
---|
1476 | |
---|
1477 | Bool bFirstFrame = true; |
---|
1478 | while ( !bEos ) |
---|
1479 | { |
---|
1480 | // Read enough frames |
---|
1481 | Bool bFramesReadyToCode = false; |
---|
1482 | while(!bFramesReadyToCode) |
---|
1483 | { |
---|
1484 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1485 | { |
---|
1486 | //6 |
---|
1487 | // get buffers |
---|
1488 | xGetBuffer(pcPicYuvRec, layer); |
---|
1489 | |
---|
1490 | // read input YUV file |
---|
1491 | m_apcTVideoIOYuvInputFile[layer]->read( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], ipCSC, m_apcLayerCfg[layer]->getPad(), m_apcLayerCfg[layer]->getInputChromaFormat(), m_bClipInputVideoToRec709Range ); |
---|
1492 | |
---|
1493 | #if AUXILIARY_PICTURES |
---|
1494 | 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)) ) |
---|
1495 | { |
---|
1496 | pcPicYuvOrg[layer]->convertToMonochrome(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1497 | } |
---|
1498 | #endif |
---|
1499 | |
---|
1500 | if(layer == m_numLayers-1) |
---|
1501 | { |
---|
1502 | // increase number of received frames |
---|
1503 | m_iFrameRcvd++; |
---|
1504 | // check end of file |
---|
1505 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1506 | } |
---|
1507 | |
---|
1508 | if ( m_isField ) |
---|
1509 | { |
---|
1510 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer], m_isTopFieldFirst ); |
---|
1511 | } |
---|
1512 | else |
---|
1513 | { |
---|
1514 | m_apcTEncTop[layer]->encodePrep( pcPicYuvOrg[layer], &acPicYuvTrueOrg[layer] ); |
---|
1515 | } |
---|
1516 | } |
---|
1517 | |
---|
1518 | bFramesReadyToCode = !(!bFirstFrame && ( m_apcTEncTop[m_numLayers-1]->getNumPicRcvd() != m_iGOPSize && m_iGOPSize ) && !bEos ); |
---|
1519 | } |
---|
1520 | Bool flush = 0; |
---|
1521 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1522 | if (m_apcTVideoIOYuvInputFile[m_numLayers-1]->isEof()) |
---|
1523 | { |
---|
1524 | flush = true; |
---|
1525 | bEos = true; |
---|
1526 | m_iFrameRcvd--; |
---|
1527 | m_apcTEncTop[m_numLayers-1]->setFramesToBeEncoded(m_iFrameRcvd); |
---|
1528 | } |
---|
1529 | |
---|
1530 | #if RC_SHVC_HARMONIZATION |
---|
1531 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1532 | { |
---|
1533 | if( m_apcTEncTop[layer]->getUseRateCtrl() ) |
---|
1534 | { |
---|
1535 | m_apcTEncTop[layer]->getRateCtrl()->initRCGOP(m_apcTEncTop[layer]->getNumPicRcvd()); |
---|
1536 | } |
---|
1537 | } |
---|
1538 | #endif |
---|
1539 | |
---|
1540 | if( m_adaptiveResolutionChange ) |
---|
1541 | { |
---|
1542 | for(UInt layer = 0; layer < m_numLayers; layer++) |
---|
1543 | { |
---|
1544 | TComList<TComPicYuv*>::iterator iterPicYuvRec; |
---|
1545 | for (iterPicYuvRec = m_acListPicYuvRec[layer].begin(); iterPicYuvRec != m_acListPicYuvRec[layer].end(); iterPicYuvRec++) |
---|
1546 | { |
---|
1547 | TComPicYuv* recPic = *(iterPicYuvRec); |
---|
1548 | recPic->setReconstructed(false); |
---|
1549 | } |
---|
1550 | } |
---|
1551 | } |
---|
1552 | |
---|
1553 | // loop through frames in one GOP |
---|
1554 | for( UInt iPicIdInGOP=0; iPicIdInGOP < (bFirstFrame? 1:m_iGOPSize); iPicIdInGOP++ ) |
---|
1555 | { |
---|
1556 | // layer by layer for each frame |
---|
1557 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1558 | { |
---|
1559 | //7 |
---|
1560 | #if LAYER_CTB |
---|
1561 | memcpy( g_auiZscanToRaster, g_auiLayerZscanToRaster[layer], sizeof( g_auiZscanToRaster ) ); |
---|
1562 | memcpy( g_auiRasterToZscan, g_auiLayerRasterToZscan[layer], sizeof( g_auiRasterToZscan ) ); |
---|
1563 | memcpy( g_auiRasterToPelX, g_auiLayerRasterToPelX[layer], sizeof( g_auiRasterToPelX ) ); |
---|
1564 | memcpy( g_auiRasterToPelY, g_auiLayerRasterToPelY[layer], sizeof( g_auiRasterToPelY ) ); |
---|
1565 | #endif |
---|
1566 | // call encoding function for one frame |
---|
1567 | if ( m_isField ) |
---|
1568 | { |
---|
1569 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP, m_isTopFieldFirst ); |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | m_apcTEncTop[layer]->encode( flush ? 0 : pcPicYuvOrg[layer], snrCSC, m_acListPicYuvRec[layer], outputAccessUnits, iPicIdInGOP ); |
---|
1574 | } |
---|
1575 | } |
---|
1576 | } |
---|
1577 | #if R0247_SEI_ACTIVE |
---|
1578 | if(bFirstFrame) |
---|
1579 | { |
---|
1580 | list<AccessUnit>::iterator first_au = outputAccessUnits.begin(); |
---|
1581 | if( m_nonHEVCBaseLayerFlag ) |
---|
1582 | { |
---|
1583 | first_au++; |
---|
1584 | } |
---|
1585 | AccessUnit::iterator it_sps; |
---|
1586 | for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++) |
---|
1587 | { |
---|
1588 | if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
1589 | { |
---|
1590 | break; |
---|
1591 | } |
---|
1592 | } |
---|
1593 | |
---|
1594 | for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++) |
---|
1595 | { |
---|
1596 | for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++) |
---|
1597 | { |
---|
1598 | if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS ) |
---|
1599 | { |
---|
1600 | first_au->insert(++it_sps, *it_nalu); |
---|
1601 | it_nalu = it_au->erase(it_nalu); |
---|
1602 | } |
---|
1603 | } |
---|
1604 | } |
---|
1605 | } |
---|
1606 | |
---|
1607 | #endif |
---|
1608 | |
---|
1609 | #if RC_SHVC_HARMONIZATION |
---|
1610 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1611 | { |
---|
1612 | if ( m_apcTEncTop[layer]->getUseRateCtrl() ) |
---|
1613 | { |
---|
1614 | (m_apcTEncTop[layer]->getRateCtrl())->destroyRCGOP(); |
---|
1615 | } |
---|
1616 | } |
---|
1617 | #endif |
---|
1618 | |
---|
1619 | iTotalNumEncoded = 0; |
---|
1620 | for( UInt layer=0; layer<m_numLayers; layer++ ) |
---|
1621 | { |
---|
1622 | //8 |
---|
1623 | // write bistream to file if necessary |
---|
1624 | iNumEncoded = m_apcTEncTop[layer]->getNumPicRcvd(); |
---|
1625 | if ( iNumEncoded > 0 ) |
---|
1626 | { |
---|
1627 | xWriteRecon(layer, iNumEncoded); |
---|
1628 | iTotalNumEncoded += iNumEncoded; |
---|
1629 | } |
---|
1630 | m_apcTEncTop[layer]->setNumPicRcvd( 0 ); |
---|
1631 | } |
---|
1632 | |
---|
1633 | // write bitstream out |
---|
1634 | if( iTotalNumEncoded ) |
---|
1635 | { |
---|
1636 | if( bEos ) |
---|
1637 | { |
---|
1638 | OutputNALUnit nalu(NAL_UNIT_EOB); |
---|
1639 | nalu.m_nuhLayerId = 0; |
---|
1640 | |
---|
1641 | AccessUnit& accessUnit = outputAccessUnits.back(); |
---|
1642 | nalu.m_temporalId = 0; |
---|
1643 | accessUnit.push_back(new NALUnitEBSP(nalu)); |
---|
1644 | } |
---|
1645 | |
---|
1646 | xWriteStream(bitstreamFile, iTotalNumEncoded, outputAccessUnits); |
---|
1647 | outputAccessUnits.clear(); |
---|
1648 | } |
---|
1649 | |
---|
1650 | // print out summary |
---|
1651 | if (bEos) |
---|
1652 | { |
---|
1653 | printOutSummary(m_isTopFieldFirst, m_printMSEBasedSequencePSNR, m_printSequenceMSE); |
---|
1654 | } |
---|
1655 | |
---|
1656 | bFirstFrame = false; |
---|
1657 | } |
---|
1658 | // delete original YUV buffer |
---|
1659 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1660 | { |
---|
1661 | pcPicYuvOrg[layer]->destroy(); |
---|
1662 | delete pcPicYuvOrg[layer]; |
---|
1663 | pcPicYuvOrg[layer] = NULL; |
---|
1664 | |
---|
1665 | // delete used buffers in encoder class |
---|
1666 | m_apcTEncTop[layer]->deletePicBuffer(); |
---|
1667 | acPicYuvTrueOrg[layer].destroy(); |
---|
1668 | } |
---|
1669 | |
---|
1670 | // delete buffers & classes |
---|
1671 | xDeleteBuffer(); |
---|
1672 | xDestroyLib(); |
---|
1673 | |
---|
1674 | printRateSummary(); |
---|
1675 | |
---|
1676 | return; |
---|
1677 | } |
---|
1678 | |
---|
1679 | Void TAppEncTop::printOutSummary(Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE) |
---|
1680 | { |
---|
1681 | UInt layer; |
---|
1682 | const Int rateMultiplier = isField ? 2 : 1; |
---|
1683 | |
---|
1684 | // set frame rate |
---|
1685 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1686 | { |
---|
1687 | m_apcTEncTop[layer]->getAnalyzeAll()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1688 | m_apcTEncTop[layer]->getAnalyzeI()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1689 | m_apcTEncTop[layer]->getAnalyzeP()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1690 | m_apcTEncTop[layer]->getAnalyzeB()->setFrmRate( m_apcLayerCfg[layer]->getFrameRate() * rateMultiplier ); |
---|
1691 | } |
---|
1692 | |
---|
1693 | //-- all |
---|
1694 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
1695 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1696 | { |
---|
1697 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1698 | m_apcTEncTop[layer]->getAnalyzeAll()->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1699 | } |
---|
1700 | |
---|
1701 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
1702 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1703 | { |
---|
1704 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1705 | m_apcTEncTop[layer]->getAnalyzeI()->printOut('i', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1706 | } |
---|
1707 | |
---|
1708 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
1709 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1710 | { |
---|
1711 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1712 | m_apcTEncTop[layer]->getAnalyzeP()->printOut('p', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1713 | } |
---|
1714 | |
---|
1715 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
1716 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1717 | { |
---|
1718 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1719 | m_apcTEncTop[layer]->getAnalyzeB()->printOut('b', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1720 | } |
---|
1721 | |
---|
1722 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1723 | { |
---|
1724 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
---|
1725 | { |
---|
1726 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1727 | |
---|
1728 | m_apcTEncTop[layer]->getAnalyzeAll()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
---|
1729 | } |
---|
1730 | } |
---|
1731 | |
---|
1732 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1733 | { |
---|
1734 | if (!m_apcTEncTop[layer]->getSummaryPicFilenameBase().empty()) |
---|
1735 | { |
---|
1736 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1737 | |
---|
1738 | m_apcTEncTop[layer]->getAnalyzeI()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"I.txt"); |
---|
1739 | m_apcTEncTop[layer]->getAnalyzeP()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"P.txt"); |
---|
1740 | m_apcTEncTop[layer]->getAnalyzeB()->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryPicFilenameBase()+"B.txt"); |
---|
1741 | } |
---|
1742 | } |
---|
1743 | |
---|
1744 | if(isField) |
---|
1745 | { |
---|
1746 | for(layer = 0; layer < m_numLayers; layer++) |
---|
1747 | { |
---|
1748 | const BitDepths bitDepths(m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_LUMA], m_apcLayerCfg[layer]->m_internalBitDepth[CHANNEL_TYPE_CHROMA]); |
---|
1749 | TEncAnalyze *analyze = m_apcTEncTop[layer]->getAnalyzeAllin(); |
---|
1750 | |
---|
1751 | //-- interlaced summary |
---|
1752 | analyze->setFrmRate( m_apcLayerCfg[layer]->getFrameRate()); |
---|
1753 | analyze->setBits(m_apcTEncTop[layer]->getAnalyzeB()->getBits()); |
---|
1754 | // prior to the above statement, the interlace analyser does not contain the correct total number of bits. |
---|
1755 | |
---|
1756 | printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); |
---|
1757 | analyze->printOut('a', m_apcLayerCfg[layer]->getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer); |
---|
1758 | |
---|
1759 | if (!m_apcTEncTop[layer]->getSummaryOutFilename().empty()) |
---|
1760 | { |
---|
1761 | analyze->printSummary(m_apcLayerCfg[layer]->getChromaFormatIDC(), printSequenceMSE, bitDepths, m_apcTEncTop[layer]->getSummaryOutFilename()); |
---|
1762 | } |
---|
1763 | } |
---|
1764 | } |
---|
1765 | |
---|
1766 | printf("\n"); |
---|
1767 | for( layer = 0; layer < m_numLayers; layer++ ) |
---|
1768 | { |
---|
1769 | printf("RVM[L%d]: %.3lf\n", layer, m_apcTEncTop[layer]->calculateRVM()); |
---|
1770 | } |
---|
1771 | printf("\n"); |
---|
1772 | } |
---|
1773 | #else |
---|
1774 | // ==================================================================================================================== |
---|
1775 | // Public member functions |
---|
1776 | // ==================================================================================================================== |
---|
1777 | |
---|
1778 | /** |
---|
1779 | - create internal class |
---|
1780 | - initialize internal variable |
---|
1781 | - until the end of input YUV file, call encoding function in TEncTop class |
---|
1782 | - delete allocated buffers |
---|
1783 | - destroy internal class |
---|
1784 | . |
---|
1785 | */ |
---|
1786 | Void TAppEncTop::encode() |
---|
1787 | { |
---|
1788 | fstream bitstreamFile(m_pchBitstreamFile, fstream::binary | fstream::out); |
---|
1789 | if (!bitstreamFile) |
---|
1790 | { |
---|
1791 | fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_pchBitstreamFile); |
---|
1792 | exit(EXIT_FAILURE); |
---|
1793 | } |
---|
1794 | |
---|
1795 | TComPicYuv* pcPicYuvOrg = new TComPicYuv; |
---|
1796 | TComPicYuv* pcPicYuvRec = NULL; |
---|
1797 | |
---|
1798 | // initialize internal class & member variables |
---|
1799 | xInitLibCfg(); |
---|
1800 | xCreateLib(); |
---|
1801 | xInitLib(m_isField); |
---|
1802 | |
---|
1803 | printChromaFormat(); |
---|
1804 | |
---|
1805 | // main encoder loop |
---|
1806 | Int iNumEncoded = 0; |
---|
1807 | Bool bEos = false; |
---|
1808 | |
---|
1809 | const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert; |
---|
1810 | const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1811 | |
---|
1812 | list<AccessUnit> outputAccessUnits; ///< list of access units to write out. is populated by the encoding process |
---|
1813 | |
---|
1814 | TComPicYuv cPicYuvTrueOrg; |
---|
1815 | |
---|
1816 | // allocate original YUV buffer |
---|
1817 | if( m_isField ) |
---|
1818 | { |
---|
1819 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1820 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true); |
---|
1821 | } |
---|
1822 | else |
---|
1823 | { |
---|
1824 | pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1825 | cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
1826 | } |
---|
1827 | |
---|
1828 | while ( !bEos ) |
---|
1829 | { |
---|
1830 | // get buffers |
---|
1831 | xGetBuffer(pcPicYuvRec); |
---|
1832 | |
---|
1833 | // read input YUV file |
---|
1834 | m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); |
---|
1835 | |
---|
1836 | // increase number of received frames |
---|
1837 | m_iFrameRcvd++; |
---|
1838 | |
---|
1839 | bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) ); |
---|
1840 | |
---|
1841 | Bool flush = 0; |
---|
1842 | // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures |
---|
1843 | if (m_cTVideoIOYuvInputFile.isEof()) |
---|
1844 | { |
---|
1845 | flush = true; |
---|
1846 | bEos = true; |
---|
1847 | m_iFrameRcvd--; |
---|
1848 | m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd); |
---|
1849 | } |
---|
1850 | |
---|
1851 | // call encoding function for one frame |
---|
1852 | if ( m_isField ) |
---|
1853 | { |
---|
1854 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst ); |
---|
1855 | } |
---|
1856 | else |
---|
1857 | { |
---|
1858 | m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded ); |
---|
1859 | } |
---|
1860 | |
---|
1861 | // write bistream to file if necessary |
---|
1862 | if ( iNumEncoded > 0 ) |
---|
1863 | { |
---|
1864 | xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits); |
---|
1865 | outputAccessUnits.clear(); |
---|
1866 | } |
---|
1867 | } |
---|
1868 | |
---|
1869 | m_cTEncTop.printSummary(m_isField); |
---|
1870 | |
---|
1871 | // delete original YUV buffer |
---|
1872 | pcPicYuvOrg->destroy(); |
---|
1873 | delete pcPicYuvOrg; |
---|
1874 | pcPicYuvOrg = NULL; |
---|
1875 | |
---|
1876 | // delete used buffers in encoder class |
---|
1877 | m_cTEncTop.deletePicBuffer(); |
---|
1878 | cPicYuvTrueOrg.destroy(); |
---|
1879 | |
---|
1880 | // delete buffers & classes |
---|
1881 | xDeleteBuffer(); |
---|
1882 | xDestroyLib(); |
---|
1883 | |
---|
1884 | printRateSummary(); |
---|
1885 | |
---|
1886 | return; |
---|
1887 | } |
---|
1888 | #endif //SVC_EXTENSION |
---|
1889 | |
---|
1890 | // ==================================================================================================================== |
---|
1891 | // Protected member functions |
---|
1892 | // ==================================================================================================================== |
---|
1893 | |
---|
1894 | /** |
---|
1895 | - application has picture buffer list with size of GOP |
---|
1896 | - picture buffer list acts as ring buffer |
---|
1897 | - end of the list has the latest picture |
---|
1898 | . |
---|
1899 | */ |
---|
1900 | #if SVC_EXTENSION |
---|
1901 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec, UInt layer) |
---|
1902 | { |
---|
1903 | assert( m_iGOPSize > 0 ); |
---|
1904 | |
---|
1905 | // org. buffer |
---|
1906 | 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. |
---|
1907 | { |
---|
1908 | rpcPicYuvRec = m_acListPicYuvRec[layer].popFront(); |
---|
1909 | } |
---|
1910 | else |
---|
1911 | { |
---|
1912 | rpcPicYuvRec = new TComPicYuv; |
---|
1913 | |
---|
1914 | 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 ); |
---|
1915 | } |
---|
1916 | m_acListPicYuvRec[layer].pushBack( rpcPicYuvRec ); |
---|
1917 | } |
---|
1918 | |
---|
1919 | Void TAppEncTop::xDeleteBuffer( ) |
---|
1920 | { |
---|
1921 | for(UInt layer=0; layer<m_numLayers; layer++) |
---|
1922 | { |
---|
1923 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].begin(); |
---|
1924 | |
---|
1925 | Int iSize = Int( m_acListPicYuvRec[layer].size() ); |
---|
1926 | |
---|
1927 | for ( Int i = 0; i < iSize; i++ ) |
---|
1928 | { |
---|
1929 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1930 | pcPicYuvRec->destroy(); |
---|
1931 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
1932 | } |
---|
1933 | } |
---|
1934 | } |
---|
1935 | |
---|
1936 | Void TAppEncTop::xWriteRecon(UInt layer, Int iNumEncoded) |
---|
1937 | { |
---|
1938 | ChromaFormat chromaFormatIdc = m_apcLayerCfg[layer]->getChromaFormatIDC(); |
---|
1939 | Int xScal = TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
1940 | Int yScal = TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
1941 | |
---|
1942 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
1943 | |
---|
1944 | if (m_isField) |
---|
1945 | { |
---|
1946 | //Reinterlace fields |
---|
1947 | Int i; |
---|
1948 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
1949 | |
---|
1950 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1951 | { |
---|
1952 | --iterPicYuvRec; |
---|
1953 | } |
---|
1954 | |
---|
1955 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
1956 | { |
---|
1957 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
1958 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
1959 | |
---|
1960 | if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRecTop->isReconstructed() && pcPicYuvRecBottom->isReconstructed() ) |
---|
1961 | { |
---|
1962 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
---|
1963 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
---|
1964 | } |
---|
1965 | } |
---|
1966 | } |
---|
1967 | else |
---|
1968 | { |
---|
1969 | Int i; |
---|
1970 | |
---|
1971 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_acListPicYuvRec[layer].end(); |
---|
1972 | |
---|
1973 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1974 | { |
---|
1975 | --iterPicYuvRec; |
---|
1976 | } |
---|
1977 | |
---|
1978 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
1979 | { |
---|
1980 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
1981 | if( !m_apcLayerCfg[layer]->getReconFile().empty() && pcPicYuvRec->isReconstructed() ) |
---|
1982 | { |
---|
1983 | m_apcTVideoIOYuvReconFile[layer]->write( pcPicYuvRec, ipCSC, m_apcLayerCfg[layer]->getConfWinLeft() * xScal, m_apcLayerCfg[layer]->getConfWinRight() * xScal, |
---|
1984 | m_apcLayerCfg[layer]->getConfWinTop() * yScal, m_apcLayerCfg[layer]->getConfWinBottom() * yScal, |
---|
1985 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
---|
1986 | } |
---|
1987 | } |
---|
1988 | } |
---|
1989 | } |
---|
1990 | |
---|
1991 | Void TAppEncTop::xWriteStream(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
1992 | { |
---|
1993 | if (m_isField) |
---|
1994 | { |
---|
1995 | //Reinterlace fields |
---|
1996 | Int i; |
---|
1997 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
1998 | |
---|
1999 | for( i = 0; i < iNumEncoded/2 && iterBitstream != accessUnits.end(); i++ ) |
---|
2000 | { |
---|
2001 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2002 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2003 | rateStatsAccum(auTop, statsTop); |
---|
2004 | |
---|
2005 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2006 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2007 | rateStatsAccum(auBottom, statsBottom); |
---|
2008 | } |
---|
2009 | } |
---|
2010 | else |
---|
2011 | { |
---|
2012 | Int i; |
---|
2013 | |
---|
2014 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2015 | |
---|
2016 | for( i = 0; i < iNumEncoded && iterBitstream != accessUnits.end(); i++ ) |
---|
2017 | { |
---|
2018 | const AccessUnit& au = *(iterBitstream++); |
---|
2019 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2020 | rateStatsAccum(au, stats); |
---|
2021 | } |
---|
2022 | } |
---|
2023 | } |
---|
2024 | |
---|
2025 | #else // SVC_EXTENSION |
---|
2026 | Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec) |
---|
2027 | { |
---|
2028 | assert( m_iGOPSize > 0 ); |
---|
2029 | |
---|
2030 | // org. buffer |
---|
2031 | if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second. |
---|
2032 | { |
---|
2033 | rpcPicYuvRec = m_cListPicYuvRec.popFront(); |
---|
2034 | |
---|
2035 | } |
---|
2036 | else |
---|
2037 | { |
---|
2038 | rpcPicYuvRec = new TComPicYuv; |
---|
2039 | |
---|
2040 | rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true ); |
---|
2041 | |
---|
2042 | } |
---|
2043 | m_cListPicYuvRec.pushBack( rpcPicYuvRec ); |
---|
2044 | } |
---|
2045 | |
---|
2046 | Void TAppEncTop::xDeleteBuffer( ) |
---|
2047 | { |
---|
2048 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin(); |
---|
2049 | |
---|
2050 | Int iSize = Int( m_cListPicYuvRec.size() ); |
---|
2051 | |
---|
2052 | for ( Int i = 0; i < iSize; i++ ) |
---|
2053 | { |
---|
2054 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2055 | pcPicYuvRec->destroy(); |
---|
2056 | delete pcPicYuvRec; pcPicYuvRec = NULL; |
---|
2057 | } |
---|
2058 | |
---|
2059 | } |
---|
2060 | |
---|
2061 | /** |
---|
2062 | Write access units to output file. |
---|
2063 | \param bitstreamFile target bitstream file |
---|
2064 | \param iNumEncoded number of encoded frames |
---|
2065 | \param accessUnits list of access units to be written |
---|
2066 | */ |
---|
2067 | Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits) |
---|
2068 | { |
---|
2069 | const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED; |
---|
2070 | |
---|
2071 | if (m_isField) |
---|
2072 | { |
---|
2073 | //Reinterlace fields |
---|
2074 | Int i; |
---|
2075 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2076 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2077 | |
---|
2078 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2079 | { |
---|
2080 | --iterPicYuvRec; |
---|
2081 | } |
---|
2082 | |
---|
2083 | for ( i = 0; i < iNumEncoded/2; i++ ) |
---|
2084 | { |
---|
2085 | TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++); |
---|
2086 | TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++); |
---|
2087 | |
---|
2088 | if (m_pchReconFile) |
---|
2089 | { |
---|
2090 | m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst ); |
---|
2091 | } |
---|
2092 | |
---|
2093 | const AccessUnit& auTop = *(iterBitstream++); |
---|
2094 | const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop); |
---|
2095 | rateStatsAccum(auTop, statsTop); |
---|
2096 | |
---|
2097 | const AccessUnit& auBottom = *(iterBitstream++); |
---|
2098 | const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom); |
---|
2099 | rateStatsAccum(auBottom, statsBottom); |
---|
2100 | } |
---|
2101 | } |
---|
2102 | else |
---|
2103 | { |
---|
2104 | Int i; |
---|
2105 | |
---|
2106 | TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end(); |
---|
2107 | list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin(); |
---|
2108 | |
---|
2109 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2110 | { |
---|
2111 | --iterPicYuvRec; |
---|
2112 | } |
---|
2113 | |
---|
2114 | for ( i = 0; i < iNumEncoded; i++ ) |
---|
2115 | { |
---|
2116 | TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++); |
---|
2117 | if (m_pchReconFile) |
---|
2118 | { |
---|
2119 | m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, |
---|
2120 | NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); |
---|
2121 | } |
---|
2122 | |
---|
2123 | const AccessUnit& au = *(iterBitstream++); |
---|
2124 | const vector<UInt>& stats = writeAnnexB(bitstreamFile, au); |
---|
2125 | rateStatsAccum(au, stats); |
---|
2126 | } |
---|
2127 | } |
---|
2128 | } |
---|
2129 | #endif |
---|
2130 | |
---|
2131 | /** |
---|
2132 | * |
---|
2133 | */ |
---|
2134 | Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes) |
---|
2135 | { |
---|
2136 | AccessUnit::const_iterator it_au = au.begin(); |
---|
2137 | vector<UInt>::const_iterator it_stats = annexBsizes.begin(); |
---|
2138 | |
---|
2139 | for (; it_au != au.end(); it_au++, it_stats++) |
---|
2140 | { |
---|
2141 | switch ((*it_au)->m_nalUnitType) |
---|
2142 | { |
---|
2143 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2144 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2145 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2146 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2147 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2148 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2149 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2150 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2151 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2152 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2153 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2154 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2155 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2156 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2157 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2158 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2159 | case NAL_UNIT_VPS: |
---|
2160 | case NAL_UNIT_SPS: |
---|
2161 | case NAL_UNIT_PPS: |
---|
2162 | m_essentialBytes += *it_stats; |
---|
2163 | break; |
---|
2164 | default: |
---|
2165 | break; |
---|
2166 | } |
---|
2167 | |
---|
2168 | m_totalBytes += *it_stats; |
---|
2169 | } |
---|
2170 | } |
---|
2171 | |
---|
2172 | Void TAppEncTop::printRateSummary() |
---|
2173 | { |
---|
2174 | #if SVC_EXTENSION |
---|
2175 | Double time = (Double) m_iFrameRcvd / m_apcLayerCfg[m_numLayers-1]->getFrameRate(); |
---|
2176 | #else |
---|
2177 | Double time = (Double) m_iFrameRcvd / m_iFrameRate; |
---|
2178 | #endif |
---|
2179 | printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time); |
---|
2180 | if (m_summaryVerboseness > 0) |
---|
2181 | { |
---|
2182 | printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time); |
---|
2183 | } |
---|
2184 | } |
---|
2185 | |
---|
2186 | #if !SVC_EXTENSION |
---|
2187 | Void TAppEncTop::printChromaFormat() |
---|
2188 | { |
---|
2189 | std::cout << std::setw(43) << "Input ChromaFormatIDC = "; |
---|
2190 | switch (m_InputChromaFormatIDC) |
---|
2191 | { |
---|
2192 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
2193 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
2194 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
2195 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
2196 | default: |
---|
2197 | std::cerr << "Invalid"; |
---|
2198 | exit(1); |
---|
2199 | } |
---|
2200 | std::cout << std::endl; |
---|
2201 | |
---|
2202 | std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = "; |
---|
2203 | switch (m_cTEncTop.getChromaFormatIdc()) |
---|
2204 | { |
---|
2205 | case CHROMA_400: std::cout << " 4:0:0"; break; |
---|
2206 | case CHROMA_420: std::cout << " 4:2:0"; break; |
---|
2207 | case CHROMA_422: std::cout << " 4:2:2"; break; |
---|
2208 | case CHROMA_444: std::cout << " 4:4:4"; break; |
---|
2209 | default: |
---|
2210 | std::cerr << "Invalid"; |
---|
2211 | exit(1); |
---|
2212 | } |
---|
2213 | std::cout << "\n" << std::endl; |
---|
2214 | } |
---|
2215 | #endif |
---|
2216 | |
---|
2217 | //! \} |
---|