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