HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TAppEncTop.cpp
Go to the documentation of this file.
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-2017, 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 
38 #include <list>
39 #include <fstream>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <fcntl.h>
43 #include <assert.h>
44 #include <iomanip>
45 
46 #include "TAppEncTop.h"
48 
49 #if EXTENSION_360_VIDEO
50 #include "TAppEncHelper360/TExt360AppEncTop.h"
51 #endif
52 
53 using namespace std;
54 
57 
58 // ====================================================================================================================
59 // Constructor / destructor / initialization / destroy
60 // ====================================================================================================================
61 
63 {
64  m_iFrameRcvd = 0;
65  m_totalBytes = 0;
66  m_essentialBytes = 0;
67 }
68 
70 {
71 }
72 
74 {
75  TComVPS vps;
76 
77  vps.setMaxTLayers ( m_maxTempLayer );
78  if (m_maxTempLayer == 1)
79  {
80  vps.setTemporalNestingFlag(true);
81  }
82  vps.setMaxLayers ( 1 );
83  for(Int i = 0; i < MAX_TLAYER; i++)
84  {
85  vps.setNumReorderPics ( m_numReorderPics[i], i );
86  vps.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i );
87  }
88  m_cTEncTop.setVPS(&vps);
89 
90  m_cTEncTop.setProfile ( m_profile);
91  m_cTEncTop.setLevel ( m_levelTier, m_level);
92  m_cTEncTop.setProgressiveSourceFlag ( m_progressiveSourceFlag);
93  m_cTEncTop.setInterlacedSourceFlag ( m_interlacedSourceFlag);
94  m_cTEncTop.setNonPackedConstraintFlag ( m_nonPackedConstraintFlag);
95  m_cTEncTop.setFrameOnlyConstraintFlag ( m_frameOnlyConstraintFlag);
96  m_cTEncTop.setBitDepthConstraintValue ( m_bitDepthConstraint );
97  m_cTEncTop.setChromaFormatConstraintValue ( m_chromaFormatConstraint );
98  m_cTEncTop.setIntraConstraintFlag ( m_intraConstraintFlag );
99  m_cTEncTop.setOnePictureOnlyConstraintFlag ( m_onePictureOnlyConstraintFlag );
100  m_cTEncTop.setLowerBitRateConstraintFlag ( m_lowerBitRateConstraintFlag );
101 
102  m_cTEncTop.setPrintMSEBasedSequencePSNR ( m_printMSEBasedSequencePSNR);
103  m_cTEncTop.setPrintFrameMSE ( m_printFrameMSE);
104  m_cTEncTop.setPrintSequenceMSE ( m_printSequenceMSE);
105 #if JVET_F0064_MSSSIM
106  m_cTEncTop.setPrintMSSSIM ( m_printMSSSIM );
107 #endif
108  m_cTEncTop.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled );
109 
110  m_cTEncTop.setFrameRate ( m_iFrameRate );
111  m_cTEncTop.setFrameSkip ( m_FrameSkip );
112  m_cTEncTop.setTemporalSubsampleRatio ( m_temporalSubsampleRatio );
113  m_cTEncTop.setSourceWidth ( m_iSourceWidth );
114  m_cTEncTop.setSourceHeight ( m_iSourceHeight );
115  m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
116  m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded );
117 
118  //====== Coding Structure ========
119  m_cTEncTop.setIntraPeriod ( m_iIntraPeriod );
120  m_cTEncTop.setDecodingRefreshType ( m_iDecodingRefreshType );
121  m_cTEncTop.setGOPSize ( m_iGOPSize );
122 #if JCTVC_Y0038_PARAMS
123  m_cTEncTop.setReWriteParamSetsFlag ( m_bReWriteParamSetsFlag );
124 #endif
125  m_cTEncTop.setGopList ( m_GOPList );
126  m_cTEncTop.setExtraRPSs ( m_extraRPSs );
127  for(Int i = 0; i < MAX_TLAYER; i++)
128  {
129  m_cTEncTop.setNumReorderPics ( m_numReorderPics[i], i );
130  m_cTEncTop.setMaxDecPicBuffering ( m_maxDecPicBuffering[i], i );
131  }
132  for( UInt uiLoop = 0; uiLoop < MAX_TLAYER; ++uiLoop )
133  {
134  m_cTEncTop.setLambdaModifier ( uiLoop, m_adLambdaModifier[ uiLoop ] );
135  }
136  m_cTEncTop.setIntraLambdaModifier ( m_adIntraLambdaModifier );
137  m_cTEncTop.setIntraQpFactor ( m_dIntraQpFactor );
138 
139  m_cTEncTop.setQP ( m_iQP );
140 
141 #if X0038_LAMBDA_FROM_QP_CAPABILITY
142  m_cTEncTop.setIntraQPOffset ( m_intraQPOffset );
143  m_cTEncTop.setLambdaFromQPEnable ( m_lambdaFromQPEnable );
144 #endif
145  m_cTEncTop.setPad ( m_aiPad );
146 
147  m_cTEncTop.setAccessUnitDelimiter ( m_AccessUnitDelimiter );
148 
149  m_cTEncTop.setMaxTempLayer ( m_maxTempLayer );
150  m_cTEncTop.setUseAMP( m_enableAMP );
151 
152  //===== Slice ========
153 
154  //====== Loop/Deblock Filter ========
155  m_cTEncTop.setLoopFilterDisable ( m_bLoopFilterDisable );
156  m_cTEncTop.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS );
157  m_cTEncTop.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 );
158  m_cTEncTop.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 );
159  m_cTEncTop.setDeblockingFilterMetric ( m_deblockingFilterMetric );
160 
161  //====== Motion search ========
162  m_cTEncTop.setDisableIntraPUsInInterSlices ( m_bDisableIntraPUsInInterSlices );
163  m_cTEncTop.setMotionEstimationSearchMethod ( m_motionEstimationSearchMethod );
164  m_cTEncTop.setSearchRange ( m_iSearchRange );
165  m_cTEncTop.setBipredSearchRange ( m_bipredSearchRange );
166  m_cTEncTop.setClipForBiPredMeEnabled ( m_bClipForBiPredMeEnabled );
167  m_cTEncTop.setFastMEAssumingSmootherMVEnabled ( m_bFastMEAssumingSmootherMVEnabled );
168  m_cTEncTop.setMinSearchWindow ( m_minSearchWindow );
169  m_cTEncTop.setRestrictMESampling ( m_bRestrictMESampling );
170 
171  //====== Quality control ========
172  m_cTEncTop.setMaxDeltaQP ( m_iMaxDeltaQP );
173  m_cTEncTop.setMaxCuDQPDepth ( m_iMaxCuDQPDepth );
174  m_cTEncTop.setDiffCuChromaQpOffsetDepth ( m_diffCuChromaQpOffsetDepth );
175  m_cTEncTop.setChromaCbQpOffset ( m_cbQpOffset );
176  m_cTEncTop.setChromaCrQpOffset ( m_crQpOffset );
177  m_cTEncTop.setWCGChromaQpControl ( m_wcgChromaQpControl );
178  m_cTEncTop.setSliceChromaOffsetQpIntraOrPeriodic ( m_sliceChromaQpOffsetPeriodicity, m_sliceChromaQpOffsetIntraOrPeriodic );
179  m_cTEncTop.setChromaFormatIdc ( m_chromaFormatIDC );
180 
181 #if ADAPTIVE_QP_SELECTION
182  m_cTEncTop.setUseAdaptQpSelect ( m_bUseAdaptQpSelect );
183 #endif
184 
185  m_cTEncTop.setUseAdaptiveQP ( m_bUseAdaptiveQP );
186  m_cTEncTop.setQPAdaptationRange ( m_iQPAdaptationRange );
187  m_cTEncTop.setExtendedPrecisionProcessingFlag ( m_extendedPrecisionProcessingFlag );
188  m_cTEncTop.setHighPrecisionOffsetsEnabledFlag ( m_highPrecisionOffsetsEnabledFlag );
189 
190  m_cTEncTop.setWeightedPredictionMethod( m_weightedPredictionMethod );
191 
192  //====== Tool list ========
193  m_cTEncTop.setLumaLevelToDeltaQPControls ( m_lumaLevelToDeltaQPMapping );
194 #if X0038_LAMBDA_FROM_QP_CAPABILITY
195  m_cTEncTop.setDeltaQpRD( (m_costMode==COST_LOSSLESS_CODING) ? 0 : m_uiDeltaQpRD );
196 #else
197  m_cTEncTop.setDeltaQpRD ( m_uiDeltaQpRD );
198 #endif
199  m_cTEncTop.setFastDeltaQp ( m_bFastDeltaQP );
200  m_cTEncTop.setUseASR ( m_bUseASR );
201  m_cTEncTop.setUseHADME ( m_bUseHADME );
202  m_cTEncTop.setdQPs ( m_aidQP );
203  m_cTEncTop.setUseRDOQ ( m_useRDOQ );
204  m_cTEncTop.setUseRDOQTS ( m_useRDOQTS );
205  m_cTEncTop.setUseSelectiveRDOQ ( m_useSelectiveRDOQ );
206  m_cTEncTop.setRDpenalty ( m_rdPenalty );
207  m_cTEncTop.setMaxCUWidth ( m_uiMaxCUWidth );
208  m_cTEncTop.setMaxCUHeight ( m_uiMaxCUHeight );
209  m_cTEncTop.setMaxTotalCUDepth ( m_uiMaxTotalCUDepth );
210  m_cTEncTop.setLog2DiffMaxMinCodingBlockSize ( m_uiLog2DiffMaxMinCodingBlockSize );
211  m_cTEncTop.setQuadtreeTULog2MaxSize ( m_uiQuadtreeTULog2MaxSize );
212  m_cTEncTop.setQuadtreeTULog2MinSize ( m_uiQuadtreeTULog2MinSize );
213  m_cTEncTop.setQuadtreeTUMaxDepthInter ( m_uiQuadtreeTUMaxDepthInter );
214  m_cTEncTop.setQuadtreeTUMaxDepthIntra ( m_uiQuadtreeTUMaxDepthIntra );
215  m_cTEncTop.setFastInterSearchMode ( m_fastInterSearchMode );
216  m_cTEncTop.setUseEarlyCU ( m_bUseEarlyCU );
217  m_cTEncTop.setUseFastDecisionForMerge ( m_useFastDecisionForMerge );
218  m_cTEncTop.setUseCbfFastMode ( m_bUseCbfFastMode );
219  m_cTEncTop.setUseEarlySkipDetection ( m_useEarlySkipDetection );
220  m_cTEncTop.setCrossComponentPredictionEnabledFlag ( m_crossComponentPredictionEnabledFlag );
221  m_cTEncTop.setUseReconBasedCrossCPredictionEstimate ( m_reconBasedCrossCPredictionEstimate );
222  m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_LUMA , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] );
223  m_cTEncTop.setLog2SaoOffsetScale ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] );
224  m_cTEncTop.setUseTransformSkip ( m_useTransformSkip );
225  m_cTEncTop.setUseTransformSkipFast ( m_useTransformSkipFast );
226  m_cTEncTop.setTransformSkipRotationEnabledFlag ( m_transformSkipRotationEnabledFlag );
227  m_cTEncTop.setTransformSkipContextEnabledFlag ( m_transformSkipContextEnabledFlag );
228  m_cTEncTop.setPersistentRiceAdaptationEnabledFlag ( m_persistentRiceAdaptationEnabledFlag );
229  m_cTEncTop.setCabacBypassAlignmentEnabledFlag ( m_cabacBypassAlignmentEnabledFlag );
230  m_cTEncTop.setLog2MaxTransformSkipBlockSize ( m_log2MaxTransformSkipBlockSize );
231  for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++)
232  {
233  m_cTEncTop.setRdpcmEnabledFlag ( RDPCMSignallingMode(signallingModeIndex), m_rdpcmEnabledFlag[signallingModeIndex]);
234  }
235  m_cTEncTop.setUseConstrainedIntraPred ( m_bUseConstrainedIntraPred );
236  m_cTEncTop.setFastUDIUseMPMEnabled ( m_bFastUDIUseMPMEnabled );
237  m_cTEncTop.setFastMEForGenBLowDelayEnabled ( m_bFastMEForGenBLowDelayEnabled );
238  m_cTEncTop.setUseBLambdaForNonKeyLowDelayPictures ( m_bUseBLambdaForNonKeyLowDelayPictures );
239  m_cTEncTop.setPCMLog2MinSize ( m_uiPCMLog2MinSize);
240  m_cTEncTop.setUsePCM ( m_usePCM );
241 
242  // set internal bit-depth and constants
243  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
244  {
245  m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
246  m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
247  }
248 
249  m_cTEncTop.setPCMLog2MaxSize ( m_pcmLog2MaxSize);
250  m_cTEncTop.setMaxNumMergeCand ( m_maxNumMergeCand );
251 
252 
253  //====== Weighted Prediction ========
254  m_cTEncTop.setUseWP ( m_useWeightedPred );
255  m_cTEncTop.setWPBiPred ( m_useWeightedBiPred );
256 
257  //====== Parallel Merge Estimation ========
258  m_cTEncTop.setLog2ParallelMergeLevelMinus2 ( m_log2ParallelMergeLevel - 2 );
259 
260  //====== Slice ========
261  m_cTEncTop.setSliceMode ( m_sliceMode );
262  m_cTEncTop.setSliceArgument ( m_sliceArgument );
263 
264  //====== Dependent Slice ========
265  m_cTEncTop.setSliceSegmentMode ( m_sliceSegmentMode );
266  m_cTEncTop.setSliceSegmentArgument ( m_sliceSegmentArgument );
267 
268  if(m_sliceMode == NO_SLICES )
269  {
270  m_bLFCrossSliceBoundaryFlag = true;
271  }
272  m_cTEncTop.setLFCrossSliceBoundaryFlag ( m_bLFCrossSliceBoundaryFlag );
273  m_cTEncTop.setUseSAO ( m_bUseSAO );
274  m_cTEncTop.setTestSAODisableAtPictureLevel ( m_bTestSAODisableAtPictureLevel );
275  m_cTEncTop.setSaoEncodingRate ( m_saoEncodingRate );
276  m_cTEncTop.setSaoEncodingRateChroma ( m_saoEncodingRateChroma );
277  m_cTEncTop.setMaxNumOffsetsPerPic ( m_maxNumOffsetsPerPic);
278 
279  m_cTEncTop.setSaoCtuBoundary ( m_saoCtuBoundary);
280  m_cTEncTop.setSaoResetEncoderStateAfterIRAP ( m_saoResetEncoderStateAfterIRAP);
281  m_cTEncTop.setPCMInputBitDepthFlag ( m_bPCMInputBitDepthFlag);
282  m_cTEncTop.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag);
283 
284  m_cTEncTop.setIntraSmoothingDisabledFlag (!m_enableIntraReferenceSmoothing );
285  m_cTEncTop.setDecodedPictureHashSEIType ( m_decodedPictureHashSEIType );
286  m_cTEncTop.setRecoveryPointSEIEnabled ( m_recoveryPointSEIEnabled );
287  m_cTEncTop.setBufferingPeriodSEIEnabled ( m_bufferingPeriodSEIEnabled );
288  m_cTEncTop.setPictureTimingSEIEnabled ( m_pictureTimingSEIEnabled );
289  m_cTEncTop.setToneMappingInfoSEIEnabled ( m_toneMappingInfoSEIEnabled );
290  m_cTEncTop.setTMISEIToneMapId ( m_toneMapId );
291  m_cTEncTop.setTMISEIToneMapCancelFlag ( m_toneMapCancelFlag );
292  m_cTEncTop.setTMISEIToneMapPersistenceFlag ( m_toneMapPersistenceFlag );
293  m_cTEncTop.setTMISEICodedDataBitDepth ( m_toneMapCodedDataBitDepth );
294  m_cTEncTop.setTMISEITargetBitDepth ( m_toneMapTargetBitDepth );
295  m_cTEncTop.setTMISEIModelID ( m_toneMapModelId );
296  m_cTEncTop.setTMISEIMinValue ( m_toneMapMinValue );
297  m_cTEncTop.setTMISEIMaxValue ( m_toneMapMaxValue );
298  m_cTEncTop.setTMISEISigmoidMidpoint ( m_sigmoidMidpoint );
299  m_cTEncTop.setTMISEISigmoidWidth ( m_sigmoidWidth );
300  m_cTEncTop.setTMISEIStartOfCodedInterva ( m_startOfCodedInterval );
301  m_cTEncTop.setTMISEINumPivots ( m_numPivots );
302  m_cTEncTop.setTMISEICodedPivotValue ( m_codedPivotValue );
303  m_cTEncTop.setTMISEITargetPivotValue ( m_targetPivotValue );
304  m_cTEncTop.setTMISEICameraIsoSpeedIdc ( m_cameraIsoSpeedIdc );
305  m_cTEncTop.setTMISEICameraIsoSpeedValue ( m_cameraIsoSpeedValue );
306  m_cTEncTop.setTMISEIExposureIndexIdc ( m_exposureIndexIdc );
307  m_cTEncTop.setTMISEIExposureIndexValue ( m_exposureIndexValue );
308  m_cTEncTop.setTMISEIExposureCompensationValueSignFlag ( m_exposureCompensationValueSignFlag );
309  m_cTEncTop.setTMISEIExposureCompensationValueNumerator ( m_exposureCompensationValueNumerator );
310  m_cTEncTop.setTMISEIExposureCompensationValueDenomIdc ( m_exposureCompensationValueDenomIdc );
311  m_cTEncTop.setTMISEIRefScreenLuminanceWhite ( m_refScreenLuminanceWhite );
312  m_cTEncTop.setTMISEIExtendedRangeWhiteLevel ( m_extendedRangeWhiteLevel );
313  m_cTEncTop.setTMISEINominalBlackLevelLumaCodeValue ( m_nominalBlackLevelLumaCodeValue );
314  m_cTEncTop.setTMISEINominalWhiteLevelLumaCodeValue ( m_nominalWhiteLevelLumaCodeValue );
315  m_cTEncTop.setTMISEIExtendedWhiteLevelLumaCodeValue ( m_extendedWhiteLevelLumaCodeValue );
316  m_cTEncTop.setChromaResamplingFilterHintEnabled ( m_chromaResamplingFilterSEIenabled );
317  m_cTEncTop.setChromaResamplingHorFilterIdc ( m_chromaResamplingHorFilterIdc );
318  m_cTEncTop.setChromaResamplingVerFilterIdc ( m_chromaResamplingVerFilterIdc );
319  m_cTEncTop.setFramePackingArrangementSEIEnabled ( m_framePackingSEIEnabled );
320  m_cTEncTop.setFramePackingArrangementSEIType ( m_framePackingSEIType );
321  m_cTEncTop.setFramePackingArrangementSEIId ( m_framePackingSEIId );
322  m_cTEncTop.setFramePackingArrangementSEIQuincunx ( m_framePackingSEIQuincunx );
323  m_cTEncTop.setFramePackingArrangementSEIInterpretation ( m_framePackingSEIInterpretation );
324  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIEnabled ( m_segmentedRectFramePackingSEIEnabled );
325  m_cTEncTop.setSegmentedRectFramePackingArrangementSEICancel ( m_segmentedRectFramePackingSEICancel );
326  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIType ( m_segmentedRectFramePackingSEIType );
327  m_cTEncTop.setSegmentedRectFramePackingArrangementSEIPersistence( m_segmentedRectFramePackingSEIPersistence );
328  m_cTEncTop.setDisplayOrientationSEIAngle ( m_displayOrientationSEIAngle );
329  m_cTEncTop.setTemporalLevel0IndexSEIEnabled ( m_temporalLevel0IndexSEIEnabled );
330  m_cTEncTop.setGradualDecodingRefreshInfoEnabled ( m_gradualDecodingRefreshInfoEnabled );
331  m_cTEncTop.setNoDisplaySEITLayer ( m_noDisplaySEITLayer );
332  m_cTEncTop.setDecodingUnitInfoSEIEnabled ( m_decodingUnitInfoSEIEnabled );
333  m_cTEncTop.setSOPDescriptionSEIEnabled ( m_SOPDescriptionSEIEnabled );
334  m_cTEncTop.setScalableNestingSEIEnabled ( m_scalableNestingSEIEnabled );
335  m_cTEncTop.setTMCTSSEIEnabled ( m_tmctsSEIEnabled );
336 #if MCTS_ENC_CHECK
337  m_cTEncTop.setTMCTSSEITileConstraint ( m_tmctsSEITileConstraint );
338 #endif
339  m_cTEncTop.setTimeCodeSEIEnabled ( m_timeCodeSEIEnabled );
340  m_cTEncTop.setNumberOfTimeSets ( m_timeCodeSEINumTs );
341  for(Int i = 0; i < m_timeCodeSEINumTs; i++)
342  {
343  m_cTEncTop.setTimeSet(m_timeSetArray[i], i);
344  }
345  m_cTEncTop.setKneeSEIEnabled ( m_kneeSEIEnabled );
346  m_cTEncTop.setKneeFunctionInformationSEI ( m_kneeFunctionInformationSEI );
347 #if CCV_SEI_MESSAGE
348  m_cTEncTop.setCcvSEIEnabled (m_ccvSEIEnabled);
349  m_cTEncTop.setCcvSEICancelFlag (m_ccvSEICancelFlag);
350  m_cTEncTop.setCcvSEIPersistenceFlag (m_ccvSEIPersistenceFlag);
351 
352  m_cTEncTop.setCcvSEIEnabled (m_ccvSEIEnabled);
353  m_cTEncTop.setCcvSEICancelFlag (m_ccvSEICancelFlag);
354  m_cTEncTop.setCcvSEIPersistenceFlag (m_ccvSEIPersistenceFlag);
355  m_cTEncTop.setCcvSEIPrimariesPresentFlag (m_ccvSEIPrimariesPresentFlag);
356  m_cTEncTop.setCcvSEIMinLuminanceValuePresentFlag (m_ccvSEIMinLuminanceValuePresentFlag);
357  m_cTEncTop.setCcvSEIMaxLuminanceValuePresentFlag (m_ccvSEIMaxLuminanceValuePresentFlag);
358  m_cTEncTop.setCcvSEIAvgLuminanceValuePresentFlag (m_ccvSEIAvgLuminanceValuePresentFlag);
359  for(Int i = 0; i < MAX_NUM_COMPONENT; i++) {
360  m_cTEncTop.setCcvSEIPrimariesX (m_ccvSEIPrimariesX[i], i);
361  m_cTEncTop.setCcvSEIPrimariesY (m_ccvSEIPrimariesY[i], i);
362  }
363  m_cTEncTop.setCcvSEIMinLuminanceValue (m_ccvSEIMinLuminanceValue);
364  m_cTEncTop.setCcvSEIMaxLuminanceValue (m_ccvSEIMaxLuminanceValue);
365  m_cTEncTop.setCcvSEIAvgLuminanceValue (m_ccvSEIAvgLuminanceValue);
366 #endif
367 #if ERP_SR_OV_SEI_MESSAGE
368  m_cTEncTop.setErpSEIEnabled ( m_erpSEIEnabled );
369  m_cTEncTop.setErpSEICancelFlag ( m_erpSEICancelFlag );
370  m_cTEncTop.setErpSEIPersistenceFlag ( m_erpSEIPersistenceFlag );
371  m_cTEncTop.setErpSEIGuardBandFlag ( m_erpSEIGuardBandFlag );
372  m_cTEncTop.setErpSEIGuardBandType ( m_erpSEIGuardBandType );
373  m_cTEncTop.setErpSEILeftGuardBandWidth ( m_erpSEILeftGuardBandWidth );
374  m_cTEncTop.setErpSEIRightGuardBandWidth ( m_erpSEIRightGuardBandWidth );
375  m_cTEncTop.setSphereRotationSEIEnabled ( m_sphereRotationSEIEnabled );
376  m_cTEncTop.setSphereRotationSEICancelFlag ( m_sphereRotationSEICancelFlag );
377  m_cTEncTop.setSphereRotationSEIPersistenceFlag ( m_sphereRotationSEIPersistenceFlag );
378  m_cTEncTop.setSphereRotationSEIYaw ( m_sphereRotationSEIYaw );
379  m_cTEncTop.setSphereRotationSEIPitch ( m_sphereRotationSEIPitch );
380  m_cTEncTop.setSphereRotationSEIRoll ( m_sphereRotationSEIRoll );
381  m_cTEncTop.setOmniViewportSEIEnabled ( m_omniViewportSEIEnabled );
382  m_cTEncTop.setOmniViewportSEIId ( m_omniViewportSEIId );
383  m_cTEncTop.setOmniViewportSEICancelFlag ( m_omniViewportSEICancelFlag );
384  m_cTEncTop.setOmniViewportSEIPersistenceFlag ( m_omniViewportSEIPersistenceFlag );
385  m_cTEncTop.setOmniViewportSEICntMinus1 ( m_omniViewportSEICntMinus1 );
386  m_cTEncTop.setOmniViewportSEIAzimuthCentre ( m_omniViewportSEIAzimuthCentre );
387  m_cTEncTop.setOmniViewportSEIElevationCentre ( m_omniViewportSEIElevationCentre );
388  m_cTEncTop.setOmniViewportSEITiltCentre ( m_omniViewportSEITiltCentre );
389  m_cTEncTop.setOmniViewportSEIHorRange ( m_omniViewportSEIHorRange );
390  m_cTEncTop.setOmniViewportSEIVerRange ( m_omniViewportSEIVerRange );
391 #endif
392 #if CMP_SEI_MESSAGE
393  m_cTEncTop.setCmpSEIEnabled (m_cmpSEIEnabled);
394  m_cTEncTop.setCmpSEICmpCancelFlag (m_cmpSEICmpCancelFlag);
395  m_cTEncTop.setCmpSEICmpPersistenceFlag (m_cmpSEICmpPersistenceFlag);
396 #endif
397 #if RWP_SEI_MESSAGE
398  m_cTEncTop.setRwpSEIEnabled (m_rwpSEIEnabled);
399  m_cTEncTop.setRwpSEIRwpCancelFlag (m_rwpSEIRwpCancelFlag);
400  m_cTEncTop.setRwpSEIRwpPersistenceFlag (m_rwpSEIRwpPersistenceFlag);
401  m_cTEncTop.setRwpSEIConstituentPictureMatchingFlag (m_rwpSEIConstituentPictureMatchingFlag);
402  m_cTEncTop.setRwpSEINumPackedRegions (m_rwpSEINumPackedRegions);
403  m_cTEncTop.setRwpSEIProjPictureWidth (m_rwpSEIProjPictureWidth);
404  m_cTEncTop.setRwpSEIProjPictureHeight (m_rwpSEIProjPictureHeight);
405  m_cTEncTop.setRwpSEIPackedPictureWidth (m_rwpSEIPackedPictureWidth);
406  m_cTEncTop.setRwpSEIPackedPictureHeight (m_rwpSEIPackedPictureHeight);
407  m_cTEncTop.setRwpSEIRwpTransformType (m_rwpSEIRwpTransformType);
408  m_cTEncTop.setRwpSEIRwpGuardBandFlag (m_rwpSEIRwpGuardBandFlag);
409  m_cTEncTop.setRwpSEIProjRegionWidth (m_rwpSEIProjRegionWidth);
410  m_cTEncTop.setRwpSEIProjRegionHeight (m_rwpSEIProjRegionHeight);
411  m_cTEncTop.setRwpSEIRwpSEIProjRegionTop (m_rwpSEIRwpSEIProjRegionTop);
412  m_cTEncTop.setRwpSEIProjRegionLeft (m_rwpSEIProjRegionLeft);
413  m_cTEncTop.setRwpSEIPackedRegionWidth (m_rwpSEIPackedRegionWidth);
414  m_cTEncTop.setRwpSEIPackedRegionHeight (m_rwpSEIPackedRegionHeight);
415  m_cTEncTop.setRwpSEIPackedRegionTop (m_rwpSEIPackedRegionTop);
416  m_cTEncTop.setRwpSEIPackedRegionLeft (m_rwpSEIPackedRegionLeft);
417  m_cTEncTop.setRwpSEIRwpLeftGuardBandWidth (m_rwpSEIRwpLeftGuardBandWidth);
418  m_cTEncTop.setRwpSEIRwpRightGuardBandWidth (m_rwpSEIRwpRightGuardBandWidth);
419  m_cTEncTop.setRwpSEIRwpTopGuardBandHeight (m_rwpSEIRwpTopGuardBandHeight);
420  m_cTEncTop.setRwpSEIRwpBottomGuardBandHeight (m_rwpSEIRwpBottomGuardBandHeight);
421  m_cTEncTop.setRwpSEIRwpGuardBandNotUsedForPredFlag (m_rwpSEIRwpGuardBandNotUsedForPredFlag);
422  m_cTEncTop.setRwpSEIRwpGuardBandType (m_rwpSEIRwpGuardBandType);
423 #endif
424  m_cTEncTop.setColourRemapInfoSEIFileRoot ( m_colourRemapSEIFileRoot );
425  m_cTEncTop.setMasteringDisplaySEI ( m_masteringDisplay );
426  m_cTEncTop.setSEIAlternativeTransferCharacteristicsSEIEnable ( m_preferredTransferCharacteristics>=0 );
427  m_cTEncTop.setSEIPreferredTransferCharacteristics ( UChar(m_preferredTransferCharacteristics) );
428  m_cTEncTop.setSEIGreenMetadataInfoSEIEnable ( m_greenMetadataType > 0 );
429  m_cTEncTop.setSEIGreenMetadataType ( UChar(m_greenMetadataType) );
430  m_cTEncTop.setSEIXSDMetricType ( UChar(m_xsdMetricType) );
431 #if RNSEI
432  m_cTEncTop.setRegionalNestingSEIFileRoot ( m_regionalNestingSEIFileRoot );
433 #endif
434  m_cTEncTop.setTileUniformSpacingFlag ( m_tileUniformSpacingFlag );
435  m_cTEncTop.setNumColumnsMinus1 ( m_numTileColumnsMinus1 );
436  m_cTEncTop.setNumRowsMinus1 ( m_numTileRowsMinus1 );
437  if(!m_tileUniformSpacingFlag)
438  {
439  m_cTEncTop.setColumnWidth ( m_tileColumnWidth );
440  m_cTEncTop.setRowHeight ( m_tileRowHeight );
441  }
442  m_cTEncTop.xCheckGSParameters();
443  Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
444  if(uiTilesCount == 1)
445  {
446  m_bLFCrossTileBoundaryFlag = true;
447  }
448  m_cTEncTop.setLFCrossTileBoundaryFlag ( m_bLFCrossTileBoundaryFlag );
449  m_cTEncTop.setEntropyCodingSyncEnabledFlag ( m_entropyCodingSyncEnabledFlag );
450  m_cTEncTop.setTMVPModeId ( m_TMVPModeId );
451  m_cTEncTop.setUseScalingListId ( m_useScalingListId );
452  m_cTEncTop.setScalingListFileName ( m_scalingListFileName );
453  m_cTEncTop.setSignDataHidingEnabledFlag ( m_signDataHidingEnabledFlag);
454  m_cTEncTop.setUseRateCtrl ( m_RCEnableRateControl );
455  m_cTEncTop.setTargetBitrate ( m_RCTargetBitrate );
456  m_cTEncTop.setKeepHierBit ( m_RCKeepHierarchicalBit );
457  m_cTEncTop.setLCULevelRC ( m_RCLCULevelRC );
458  m_cTEncTop.setUseLCUSeparateModel ( m_RCUseLCUSeparateModel );
459  m_cTEncTop.setInitialQP ( m_RCInitialQP );
460  m_cTEncTop.setForceIntraQP ( m_RCForceIntraQP );
461  m_cTEncTop.setCpbSaturationEnabled ( m_RCCpbSaturationEnabled );
462  m_cTEncTop.setCpbSize ( m_RCCpbSize );
463  m_cTEncTop.setInitialCpbFullness ( m_RCInitialCpbFullness );
464  m_cTEncTop.setTransquantBypassEnabledFlag ( m_TransquantBypassEnabledFlag );
465  m_cTEncTop.setCUTransquantBypassFlagForceValue ( m_CUTransquantBypassFlagForce );
466  m_cTEncTop.setCostMode ( m_costMode );
467  m_cTEncTop.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda );
468  m_cTEncTop.setUseStrongIntraSmoothing ( m_useStrongIntraSmoothing );
469  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
470  m_cTEncTop.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag );
471  m_cTEncTop.setAspectRatioInfoPresentFlag ( m_aspectRatioInfoPresentFlag);
472  m_cTEncTop.setAspectRatioIdc ( m_aspectRatioIdc );
473  m_cTEncTop.setSarWidth ( m_sarWidth );
474  m_cTEncTop.setSarHeight ( m_sarHeight );
475  m_cTEncTop.setOverscanInfoPresentFlag ( m_overscanInfoPresentFlag );
476  m_cTEncTop.setOverscanAppropriateFlag ( m_overscanAppropriateFlag );
477  m_cTEncTop.setVideoSignalTypePresentFlag ( m_videoSignalTypePresentFlag );
478  m_cTEncTop.setVideoFormat ( m_videoFormat );
479  m_cTEncTop.setVideoFullRangeFlag ( m_videoFullRangeFlag );
480  m_cTEncTop.setColourDescriptionPresentFlag ( m_colourDescriptionPresentFlag );
481  m_cTEncTop.setColourPrimaries ( m_colourPrimaries );
482  m_cTEncTop.setTransferCharacteristics ( m_transferCharacteristics );
483  m_cTEncTop.setMatrixCoefficients ( m_matrixCoefficients );
484  m_cTEncTop.setChromaLocInfoPresentFlag ( m_chromaLocInfoPresentFlag );
485  m_cTEncTop.setChromaSampleLocTypeTopField ( m_chromaSampleLocTypeTopField );
486  m_cTEncTop.setChromaSampleLocTypeBottomField ( m_chromaSampleLocTypeBottomField );
487  m_cTEncTop.setNeutralChromaIndicationFlag ( m_neutralChromaIndicationFlag );
488  m_cTEncTop.setDefaultDisplayWindow ( m_defDispWinLeftOffset, m_defDispWinRightOffset, m_defDispWinTopOffset, m_defDispWinBottomOffset );
489  m_cTEncTop.setFrameFieldInfoPresentFlag ( m_frameFieldInfoPresentFlag );
490  m_cTEncTop.setPocProportionalToTimingFlag ( m_pocProportionalToTimingFlag );
491  m_cTEncTop.setNumTicksPocDiffOneMinus1 ( m_numTicksPocDiffOneMinus1 );
492  m_cTEncTop.setBitstreamRestrictionFlag ( m_bitstreamRestrictionFlag );
493  m_cTEncTop.setTilesFixedStructureFlag ( m_tilesFixedStructureFlag );
494  m_cTEncTop.setMotionVectorsOverPicBoundariesFlag ( m_motionVectorsOverPicBoundariesFlag );
495  m_cTEncTop.setMinSpatialSegmentationIdc ( m_minSpatialSegmentationIdc );
496  m_cTEncTop.setMaxBytesPerPicDenom ( m_maxBytesPerPicDenom );
497  m_cTEncTop.setMaxBitsPerMinCuDenom ( m_maxBitsPerMinCuDenom );
498  m_cTEncTop.setLog2MaxMvLengthHorizontal ( m_log2MaxMvLengthHorizontal );
499  m_cTEncTop.setLog2MaxMvLengthVertical ( m_log2MaxMvLengthVertical );
500  m_cTEncTop.setEfficientFieldIRAPEnabled ( m_bEfficientFieldIRAPEnabled );
501  m_cTEncTop.setHarmonizeGopFirstFieldCoupleEnabled ( m_bHarmonizeGopFirstFieldCoupleEnabled );
502 
503  m_cTEncTop.setSummaryOutFilename ( m_summaryOutFilename );
504  m_cTEncTop.setSummaryPicFilenameBase ( m_summaryPicFilenameBase );
505  m_cTEncTop.setSummaryVerboseness ( m_summaryVerboseness );
506 }
507 
509 {
510  // Video I/O
511  m_cTVideoIOYuvInputFile.open( m_inputFileName, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth ); // read mode
512  m_cTVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
513 
514  if (!m_reconFileName.empty())
515  {
516  m_cTVideoIOYuvReconFile.open(m_reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth); // write mode
517  }
518 
519  // Neo Decoder
520  m_cTEncTop.create();
521 }
522 
524 {
525  // Video I/O
526  m_cTVideoIOYuvInputFile.close();
527  m_cTVideoIOYuvReconFile.close();
528 
529  // Neo Decoder
530  m_cTEncTop.destroy();
531 }
532 
534 {
535  m_cTEncTop.init(isFieldCoding);
536 }
537 
538 // ====================================================================================================================
539 // Public member functions
540 // ====================================================================================================================
541 
551 {
552  fstream bitstreamFile(m_bitstreamFileName.c_str(), fstream::binary | fstream::out);
553  if (!bitstreamFile)
554  {
555  fprintf(stderr, "\nfailed to open bitstream file `%s' for writing\n", m_bitstreamFileName.c_str());
556  exit(EXIT_FAILURE);
557  }
558 
559  TComPicYuv* pcPicYuvOrg = new TComPicYuv;
560  TComPicYuv* pcPicYuvRec = NULL;
561 
562  // initialize internal class & member variables
563  xInitLibCfg();
564  xCreateLib();
565  xInitLib(m_isField);
566 
567  printChromaFormat();
568 
569  // main encoder loop
570  Int iNumEncoded = 0;
571  Bool bEos = false;
572 
573  const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert;
574  const InputColourSpaceConversion snrCSC = (!m_snrInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
575 
576  list<AccessUnit> outputAccessUnits;
577 
578  TComPicYuv cPicYuvTrueOrg;
579 
580  // allocate original YUV buffer
581  if( m_isField )
582  {
583  pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
584  cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true);
585  }
586  else
587  {
588  pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
589  cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
590  }
591 
592 #if EXTENSION_360_VIDEO
593  TExt360AppEncTop ext360(*this, m_cTEncTop.getGOPEncoder()->getExt360Data(), *(m_cTEncTop.getGOPEncoder()), *pcPicYuvOrg);
594 #endif
595 
596  while ( !bEos )
597  {
598  // get buffers
599  xGetBuffer(pcPicYuvRec);
600 
601  // read input YUV file
602 #if EXTENSION_360_VIDEO
603  if (ext360.isEnabled())
604  {
605  ext360.read(m_cTVideoIOYuvInputFile, *pcPicYuvOrg, cPicYuvTrueOrg, ipCSC);
606  }
607  else
608  {
609  m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
610  }
611 #else
612  m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
613 #endif
614 
615  // increase number of received frames
616  m_iFrameRcvd++;
617 
618  bEos = (m_isField && (m_iFrameRcvd == (m_framesToBeEncoded >> 1) )) || ( !m_isField && (m_iFrameRcvd == m_framesToBeEncoded) );
619 
620  Bool flush = 0;
621  // if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
622  if (m_cTVideoIOYuvInputFile.isEof())
623  {
624  flush = true;
625  bEos = true;
626  m_iFrameRcvd--;
627  m_cTEncTop.setFramesToBeEncoded(m_iFrameRcvd);
628  }
629 
630  // call encoding function for one frame
631  if ( m_isField )
632  {
633  m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
634  }
635  else
636  {
637  m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
638  }
639 
640  // write bistream to file if necessary
641  if ( iNumEncoded > 0 )
642  {
643  xWriteOutput(bitstreamFile, iNumEncoded, outputAccessUnits);
644  outputAccessUnits.clear();
645  }
646  // temporally skip frames
647  if( m_temporalSubsampleRatio > 1 )
648  {
649  m_cTVideoIOYuvInputFile.skipFrames(m_temporalSubsampleRatio-1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC);
650  }
651  }
652 
653  m_cTEncTop.printSummary(m_isField);
654 
655  // delete original YUV buffer
656  pcPicYuvOrg->destroy();
657  delete pcPicYuvOrg;
658  pcPicYuvOrg = NULL;
659 
660  // delete used buffers in encoder class
661  m_cTEncTop.deletePicBuffer();
662  cPicYuvTrueOrg.destroy();
663 
664  // delete buffers & classes
665  xDeleteBuffer();
666  xDestroyLib();
667 
668  printRateSummary();
669 
670  return;
671 }
672 
673 // ====================================================================================================================
674 // Protected member functions
675 // ====================================================================================================================
676 
684 {
685  assert( m_iGOPSize > 0 );
686 
687  // org. buffer
688  if ( m_cListPicYuvRec.size() >= (UInt)m_iGOPSize ) // buffer will be 1 element longer when using field coding, to maintain first field whilst processing second.
689  {
690  rpcPicYuvRec = m_cListPicYuvRec.popFront();
691 
692  }
693  else
694  {
695  rpcPicYuvRec = new TComPicYuv;
696 
697  rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
698 
699  }
700  m_cListPicYuvRec.pushBack( rpcPicYuvRec );
701 }
702 
704 {
705  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.begin();
706 
707  Int iSize = Int( m_cListPicYuvRec.size() );
708 
709  for ( Int i = 0; i < iSize; i++ )
710  {
711  TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++);
712  pcPicYuvRec->destroy();
713  delete pcPicYuvRec; pcPicYuvRec = NULL;
714  }
715 
716 }
717 
724 Void TAppEncTop::xWriteOutput(std::ostream& bitstreamFile, Int iNumEncoded, const std::list<AccessUnit>& accessUnits)
725 {
726  const InputColourSpaceConversion ipCSC = (!m_outputInternalColourSpace) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
727 
728  if (m_isField)
729  {
730  //Reinterlace fields
731  Int i;
732  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
733  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
734 
735  for ( i = 0; i < iNumEncoded; i++ )
736  {
737  --iterPicYuvRec;
738  }
739 
740  for ( i = 0; i < iNumEncoded/2; i++ )
741  {
742  TComPicYuv* pcPicYuvRecTop = *(iterPicYuvRec++);
743  TComPicYuv* pcPicYuvRecBottom = *(iterPicYuvRec++);
744 
745  if (!m_reconFileName.empty())
746  {
747  m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, NUM_CHROMA_FORMAT, m_isTopFieldFirst );
748  }
749 
750  const AccessUnit& auTop = *(iterBitstream++);
751  const vector<UInt>& statsTop = writeAnnexB(bitstreamFile, auTop);
752  rateStatsAccum(auTop, statsTop);
753 
754  const AccessUnit& auBottom = *(iterBitstream++);
755  const vector<UInt>& statsBottom = writeAnnexB(bitstreamFile, auBottom);
756  rateStatsAccum(auBottom, statsBottom);
757  }
758  }
759  else
760  {
761  Int i;
762 
763  TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
764  list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
765 
766  for ( i = 0; i < iNumEncoded; i++ )
767  {
768  --iterPicYuvRec;
769  }
770 
771  for ( i = 0; i < iNumEncoded; i++ )
772  {
773  TComPicYuv* pcPicYuvRec = *(iterPicYuvRec++);
774  if (!m_reconFileName.empty())
775  {
776  m_cTVideoIOYuvReconFile.write( pcPicYuvRec, ipCSC, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom,
777  NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range );
778  }
779 
780  const AccessUnit& au = *(iterBitstream++);
781  const vector<UInt>& stats = writeAnnexB(bitstreamFile, au);
782  rateStatsAccum(au, stats);
783  }
784  }
785 }
786 
790 Void TAppEncTop::rateStatsAccum(const AccessUnit& au, const std::vector<UInt>& annexBsizes)
791 {
792  AccessUnit::const_iterator it_au = au.begin();
793  vector<UInt>::const_iterator it_stats = annexBsizes.begin();
794 
795  for (; it_au != au.end(); it_au++, it_stats++)
796  {
797  switch ((*it_au)->m_nalUnitType)
798  {
815  case NAL_UNIT_VPS:
816  case NAL_UNIT_SPS:
817  case NAL_UNIT_PPS:
818  m_essentialBytes += *it_stats;
819  break;
820  default:
821  break;
822  }
823 
824  m_totalBytes += *it_stats;
825  }
826 }
827 
829 {
830  Double time = (Double) m_iFrameRcvd / m_iFrameRate * m_temporalSubsampleRatio;
831  printf("Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time);
832  if (m_summaryVerboseness > 0)
833  {
834  printf("Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
835  }
836 }
837 
839 {
840  std::cout << std::setw(43) << "Input ChromaFormatIDC = ";
841  switch (m_InputChromaFormatIDC)
842  {
843  case CHROMA_400: std::cout << " 4:0:0"; break;
844  case CHROMA_420: std::cout << " 4:2:0"; break;
845  case CHROMA_422: std::cout << " 4:2:2"; break;
846  case CHROMA_444: std::cout << " 4:4:4"; break;
847  default:
848  std::cerr << "Invalid";
849  exit(1);
850  }
851  std::cout << std::endl;
852 
853  std::cout << std::setw(43) << "Output (internal) ChromaFormatIDC = ";
854  switch (m_cTEncTop.getChromaFormatIdc())
855  {
856  case CHROMA_400: std::cout << " 4:0:0"; break;
857  case CHROMA_420: std::cout << " 4:2:0"; break;
858  case CHROMA_422: std::cout << " 4:2:2"; break;
859  case CHROMA_444: std::cout << " 4:4:4"; break;
860  default:
861  std::cerr << "Invalid";
862  exit(1);
863  }
864  std::cout << "\n" << std::endl;
865 }
866 
Void rateStatsAccum(const AccessUnit &au, const std::vector< UInt > &stats)
Definition: TAppEncTop.cpp:790
Void printChromaFormat()
Definition: TAppEncTop.cpp:838
picture YUV buffer class
Definition: TComPicYuv.h:55
Encoder application class (header)
ChannelType
Definition: TypeDef.h:301
void Void
Definition: TypeDef.h:203
#define NULL
Definition: CommonDef.h:107
don&#39;t use slices / slice segments
Definition: TypeDef.h:516
virtual ~TAppEncTop()
Definition: TAppEncTop.cpp:69
Void xDeleteBuffer()
delete allocated buffers
Definition: TAppEncTop.cpp:703
unsigned int UInt
Definition: TypeDef.h:212
Void xInitLib(Bool isFieldCoding)
initialize encoder class
Definition: TAppEncTop.cpp:533
Void setNumReorderPics(UInt v, UInt tLayer)
Definition: TComSlice.h:489
Void setMaxLayers(UInt l)
Definition: TComSlice.h:484
Void xWriteOutput(std::ostream &bitstreamFile, Int iNumEncoded, const std::list< AccessUnit > &accessUnits)
write bitstream to file
Definition: TAppEncTop.cpp:724
Void setMaxDecPicBuffering(UInt v, UInt tLayer)
Definition: TComSlice.h:492
bool Bool
Definition: TypeDef.h:204
Void xCreateLib()
create files &amp; encoder class
Definition: TAppEncTop.cpp:508
Void printRateSummary()
Definition: TAppEncTop.cpp:828
Void setMaxTLayers(UInt t)
Definition: TComSlice.h:481
Void xInitLibCfg()
initialize internal variables
Definition: TAppEncTop.cpp:73
unsigned char UChar
Definition: TypeDef.h:208
RDPCMSignallingMode
Definition: TypeDef.h:275
Void xGetBuffer(TComPicYuv *&rpcPicYuvRec)
obtain required buffers
Definition: TAppEncTop.cpp:683
static const Int MAX_TLAYER
Explicit temporal layer QP offset - max number of temporal layer.
Definition: CommonDef.h:134
InputColourSpaceConversion
Definition: TypeDef.h:316
Void encode()
main encoding function
Definition: TAppEncTop.cpp:550
Void xDestroyLib()
destroy encoder class
Definition: TAppEncTop.cpp:523
list template
Definition: TComList.h:61
Void create(const Int picWidth, const Int picHeight, const ChromaFormat chromaFormatIDC, const UInt maxCUWidth, const UInt maxCUHeight, const UInt maxCUDepth, const Bool bUseMargin)
if true, then a margin of uiMaxCUWidth+16 and uiMaxCUHeight+16 is created around the image...
Definition: TComPicYuv.cpp:121
int Int
Definition: TypeDef.h:211
double Double
Definition: TypeDef.h:213
Void setTemporalNestingFlag(Bool t)
Definition: TComSlice.h:487
Void destroy()
Definition: TComPicYuv.cpp:168
static std::vector< UInt > writeAnnexB(std::ostream &out, const AccessUnit &au)
Definition: AnnexBwrite.h:53