[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TEncTop.cpp |
---|
| 35 | \brief encoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "TLibCommon/CommonDef.h" |
---|
[2] | 39 | #include "TEncTop.h" |
---|
[56] | 40 | #include "TEncPic.h" |
---|
[2] | 41 | #include "../../App/TAppEncoder/TAppEncTop.h" |
---|
[56] | 42 | #if FAST_BIT_EST |
---|
| 43 | #include "TLibCommon/ContextModel.h" |
---|
| 44 | #endif |
---|
[2] | 45 | |
---|
[56] | 46 | //! \ingroup TLibEncoder |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[2] | 49 | // ==================================================================================================================== |
---|
| 50 | // Constructor / destructor / create / destroy |
---|
| 51 | // ==================================================================================================================== |
---|
| 52 | |
---|
| 53 | TEncTop::TEncTop() |
---|
| 54 | { |
---|
| 55 | m_iPOCLast = -1; |
---|
| 56 | m_iNumPicRcvd = 0; |
---|
| 57 | m_uiNumAllPicCoded = 0; |
---|
| 58 | m_pppcRDSbacCoder = NULL; |
---|
| 59 | m_pppcBinCoderCABAC = NULL; |
---|
| 60 | m_cRDGoOnSbacCoder.init( &m_cRDGoOnBinCoderCABAC ); |
---|
| 61 | #if ENC_DEC_TRACE |
---|
| 62 | g_hTrace = fopen( "TraceEnc.txt", "wb" ); |
---|
| 63 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 64 | g_nSymbolCounter = 0; |
---|
| 65 | #endif |
---|
[56] | 66 | |
---|
| 67 | m_iMaxRefPicNum = 0; |
---|
| 68 | |
---|
| 69 | #if FAST_BIT_EST |
---|
| 70 | ContextModel::buildNextStateTable(); |
---|
| 71 | #endif |
---|
| 72 | |
---|
| 73 | m_pcSbacCoders = NULL; |
---|
| 74 | m_pcBinCoderCABACs = NULL; |
---|
| 75 | m_ppppcRDSbacCoders = NULL; |
---|
| 76 | m_ppppcBinCodersCABAC = NULL; |
---|
| 77 | m_pcRDGoOnSbacCoders = NULL; |
---|
| 78 | m_pcRDGoOnBinCodersCABAC = NULL; |
---|
| 79 | m_pcBitCounters = NULL; |
---|
| 80 | m_pcRdCosts = NULL; |
---|
[166] | 81 | |
---|
| 82 | #if VSP_N |
---|
| 83 | m_pcPicVSP = NULL; |
---|
| 84 | m_pcPicAvail = NULL; |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | #if VSP_SLICE_HEADER |
---|
| 88 | m_bUseVSP = false; |
---|
[193] | 89 | m_bVSPDepthDisable = false; |
---|
[166] | 90 | #endif |
---|
[2] | 91 | } |
---|
| 92 | |
---|
| 93 | TEncTop::~TEncTop() |
---|
| 94 | { |
---|
| 95 | #if ENC_DEC_TRACE |
---|
| 96 | fclose( g_hTrace ); |
---|
| 97 | #endif |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | Void TEncTop::create () |
---|
| 101 | { |
---|
| 102 | // initialize global variables |
---|
[105] | 103 | #if FIX_INIT_ROM |
---|
| 104 | if( m_viewId == 0 && m_isDepth == false ) |
---|
| 105 | { |
---|
| 106 | #endif |
---|
| 107 | initROM(); |
---|
| 108 | #if FIX_INIT_ROM |
---|
| 109 | } |
---|
| 110 | #endif |
---|
| 111 | |
---|
| 112 | |
---|
[2] | 113 | // create processing unit classes |
---|
[56] | 114 | m_cGOPEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
[2] | 115 | m_cSliceEncoder. create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 116 | m_cCuEncoder. create( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 117 | if (m_bUseSAO) |
---|
| 118 | { |
---|
[56] | 119 | #if SAO_UNIT_INTERLEAVING |
---|
| 120 | m_cEncSAO.setSaoInterleavingFlag(getSaoInterleavingFlag()); |
---|
| 121 | m_cEncSAO.setMaxNumOffsetsPerPic(getMaxNumOffsetsPerPic()); |
---|
| 122 | #endif |
---|
[2] | 123 | m_cEncSAO.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 124 | m_cEncSAO.createEncBuffer(); |
---|
| 125 | } |
---|
[56] | 126 | #if ADAPTIVE_QP_SELECTION |
---|
| 127 | if (m_bUseAdaptQpSelect) |
---|
| 128 | { |
---|
| 129 | m_cTrQuant.initSliceQpDelta(); |
---|
| 130 | } |
---|
[2] | 131 | #endif |
---|
| 132 | m_cAdaptiveLoopFilter.create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 133 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
[56] | 134 | |
---|
[5] | 135 | #if DEPTH_MAP_GENERATION |
---|
[21] | 136 | m_cDepthMapGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
[5] | 137 | #endif |
---|
| 138 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 139 | m_cResidualGenerator. create( false, getSourceWidth(), getSourceHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
[5] | 140 | #endif |
---|
[2] | 141 | |
---|
| 142 | if(m_bUseALF) |
---|
| 143 | { |
---|
[56] | 144 | #if LCU_SYNTAX_ALF |
---|
| 145 | m_cAdaptiveLoopFilter.setAlfCoefInSlice(m_bALFParamInSlice); |
---|
| 146 | m_cAdaptiveLoopFilter.createAlfGlobalBuffers(); |
---|
| 147 | #else |
---|
| 148 | m_cAdaptiveLoopFilter.setGOPSize( getGOPSize() ); |
---|
[2] | 149 | m_cAdaptiveLoopFilter.createAlfGlobalBuffers(m_iALFEncodePassReduction); |
---|
[56] | 150 | #endif |
---|
[2] | 151 | } |
---|
| 152 | |
---|
[56] | 153 | if(m_bUseSAO || m_bUseALF) |
---|
| 154 | { |
---|
| 155 | m_vAPS.reserve(MAX_NUM_SUPPORTED_APS); |
---|
| 156 | } |
---|
| 157 | |
---|
[2] | 158 | // if SBAC-based RD optimization is used |
---|
| 159 | if( m_bUseSBACRD ) |
---|
| 160 | { |
---|
[56] | 161 | m_pppcRDSbacCoder = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 162 | #if FAST_BIT_EST |
---|
| 163 | m_pppcBinCoderCABAC = new TEncBinCABACCounter** [g_uiMaxCUDepth+1]; |
---|
| 164 | #else |
---|
| 165 | m_pppcBinCoderCABAC = new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 166 | #endif |
---|
| 167 | |
---|
| 168 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
[2] | 169 | { |
---|
| 170 | m_pppcRDSbacCoder[iDepth] = new TEncSbac* [CI_NUM]; |
---|
[56] | 171 | #if FAST_BIT_EST |
---|
| 172 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABACCounter* [CI_NUM]; |
---|
| 173 | #else |
---|
[2] | 174 | m_pppcBinCoderCABAC[iDepth] = new TEncBinCABAC* [CI_NUM]; |
---|
[56] | 175 | #endif |
---|
| 176 | |
---|
[2] | 177 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 178 | { |
---|
| 179 | m_pppcRDSbacCoder[iDepth][iCIIdx] = new TEncSbac; |
---|
[56] | 180 | #if FAST_BIT_EST |
---|
| 181 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABACCounter; |
---|
| 182 | #else |
---|
[2] | 183 | m_pppcBinCoderCABAC [iDepth][iCIIdx] = new TEncBinCABAC; |
---|
[56] | 184 | #endif |
---|
[2] | 185 | m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); |
---|
| 186 | } |
---|
| 187 | } |
---|
| 188 | } |
---|
[56] | 189 | m_pcTAppEncTop = NULL; |
---|
[5] | 190 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 191 | if( g_aacWedgeLists.empty() && m_bUseDMM ) |
---|
[2] | 192 | { |
---|
| 193 | initWedgeLists(); |
---|
| 194 | } |
---|
| 195 | #endif |
---|
[166] | 196 | |
---|
| 197 | #if VSP_N |
---|
| 198 | m_pcPicVSP = new TComPic; |
---|
| 199 | m_pcPicVSP->create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 200 | m_pcPicVSP->getCurrSlice()->setViewOrderIdx( m_iViewOrderIdx ); |
---|
| 201 | |
---|
| 202 | m_pcPicAvail = new TComPic; |
---|
| 203 | m_pcPicAvail->create( getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 204 | m_pcPicAvail->getCurrSlice()->setViewOrderIdx( m_iViewOrderIdx ); |
---|
| 205 | #endif |
---|
[2] | 206 | } |
---|
| 207 | |
---|
[56] | 208 | /** |
---|
| 209 | - Allocate coders required for wavefront for the nominated number of substreams. |
---|
| 210 | . |
---|
| 211 | \param iNumSubstreams Determines how much information to allocate. |
---|
| 212 | */ |
---|
| 213 | Void TEncTop::createWPPCoders(Int iNumSubstreams) |
---|
| 214 | { |
---|
| 215 | if (m_pcSbacCoders != NULL) |
---|
| 216 | return; // already generated. |
---|
| 217 | |
---|
| 218 | m_iNumSubstreams = iNumSubstreams; |
---|
| 219 | m_pcSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 220 | m_pcBinCoderCABACs = new TEncBinCABAC [iNumSubstreams]; |
---|
| 221 | m_pcRDGoOnSbacCoders = new TEncSbac [iNumSubstreams]; |
---|
| 222 | m_pcRDGoOnBinCodersCABAC = new TEncBinCABAC [iNumSubstreams]; |
---|
| 223 | m_pcBitCounters = new TComBitCounter [iNumSubstreams]; |
---|
| 224 | m_pcRdCosts = new TComRdCost [iNumSubstreams]; |
---|
| 225 | |
---|
| 226 | for ( UInt ui = 0 ; ui < iNumSubstreams; ui++ ) |
---|
| 227 | { |
---|
| 228 | m_pcRDGoOnSbacCoders[ui].init( &m_pcRDGoOnBinCodersCABAC[ui] ); |
---|
| 229 | m_pcSbacCoders[ui].init( &m_pcBinCoderCABACs[ui] ); |
---|
| 230 | } |
---|
| 231 | if( m_bUseSBACRD ) |
---|
| 232 | { |
---|
| 233 | m_ppppcRDSbacCoders = new TEncSbac*** [iNumSubstreams]; |
---|
| 234 | m_ppppcBinCodersCABAC = new TEncBinCABAC***[iNumSubstreams]; |
---|
| 235 | for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) |
---|
| 236 | { |
---|
| 237 | m_ppppcRDSbacCoders[ui] = new TEncSbac** [g_uiMaxCUDepth+1]; |
---|
| 238 | m_ppppcBinCodersCABAC[ui]= new TEncBinCABAC** [g_uiMaxCUDepth+1]; |
---|
| 239 | |
---|
| 240 | for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 241 | { |
---|
| 242 | m_ppppcRDSbacCoders[ui][iDepth] = new TEncSbac* [CI_NUM]; |
---|
| 243 | m_ppppcBinCodersCABAC[ui][iDepth]= new TEncBinCABAC* [CI_NUM]; |
---|
| 244 | |
---|
| 245 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 246 | { |
---|
| 247 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx] = new TEncSbac; |
---|
| 248 | m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] = new TEncBinCABAC; |
---|
| 249 | m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]->init( m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx] ); |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | |
---|
[2] | 256 | Void TEncTop::destroy () |
---|
| 257 | { |
---|
| 258 | if(m_bUseALF) |
---|
| 259 | { |
---|
| 260 | m_cAdaptiveLoopFilter.destroyAlfGlobalBuffers(); |
---|
| 261 | } |
---|
| 262 | |
---|
[56] | 263 | for(Int i=0; i< m_vAPS.size(); i++) |
---|
| 264 | { |
---|
| 265 | TComAPS& cAPS = m_vAPS[i]; |
---|
| 266 | m_cGOPEncoder.freeAPS(&cAPS, &m_cSPS); |
---|
| 267 | } |
---|
| 268 | |
---|
[2] | 269 | // destroy processing unit classes |
---|
[56] | 270 | m_cGOPEncoder. destroy(); |
---|
[2] | 271 | m_cSliceEncoder. destroy(); |
---|
| 272 | m_cCuEncoder. destroy(); |
---|
| 273 | if (m_cSPS.getUseSAO()) |
---|
| 274 | { |
---|
| 275 | m_cEncSAO.destroy(); |
---|
[56] | 276 | m_cEncSAO.destroyEncBuffer(); |
---|
[2] | 277 | } |
---|
| 278 | m_cAdaptiveLoopFilter.destroy(); |
---|
| 279 | m_cLoopFilter. destroy(); |
---|
[56] | 280 | |
---|
[5] | 281 | #if DEPTH_MAP_GENERATION |
---|
[2] | 282 | m_cDepthMapGenerator. destroy(); |
---|
[5] | 283 | #endif |
---|
| 284 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 285 | m_cResidualGenerator. destroy(); |
---|
[5] | 286 | #endif |
---|
[2] | 287 | |
---|
[56] | 288 | m_RPSList. destroy(); |
---|
| 289 | |
---|
[2] | 290 | // SBAC RD |
---|
| 291 | if( m_bUseSBACRD ) |
---|
| 292 | { |
---|
| 293 | Int iDepth; |
---|
| 294 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 295 | { |
---|
| 296 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 297 | { |
---|
| 298 | delete m_pppcRDSbacCoder[iDepth][iCIIdx]; |
---|
| 299 | delete m_pppcBinCoderCABAC[iDepth][iCIIdx]; |
---|
| 300 | } |
---|
| 301 | } |
---|
[56] | 302 | |
---|
[2] | 303 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 304 | { |
---|
| 305 | delete [] m_pppcRDSbacCoder[iDepth]; |
---|
| 306 | delete [] m_pppcBinCoderCABAC[iDepth]; |
---|
| 307 | } |
---|
[56] | 308 | |
---|
[2] | 309 | delete [] m_pppcRDSbacCoder; |
---|
| 310 | delete [] m_pppcBinCoderCABAC; |
---|
[56] | 311 | |
---|
| 312 | for ( UInt ui = 0; ui < m_iNumSubstreams; ui++ ) |
---|
| 313 | { |
---|
| 314 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 315 | { |
---|
| 316 | for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) |
---|
| 317 | { |
---|
| 318 | delete m_ppppcRDSbacCoders [ui][iDepth][iCIIdx]; |
---|
| 319 | delete m_ppppcBinCodersCABAC[ui][iDepth][iCIIdx]; |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) |
---|
| 324 | { |
---|
| 325 | delete [] m_ppppcRDSbacCoders [ui][iDepth]; |
---|
| 326 | delete [] m_ppppcBinCodersCABAC[ui][iDepth]; |
---|
| 327 | } |
---|
| 328 | delete[] m_ppppcRDSbacCoders [ui]; |
---|
| 329 | delete[] m_ppppcBinCodersCABAC[ui]; |
---|
| 330 | } |
---|
| 331 | delete[] m_ppppcRDSbacCoders; |
---|
| 332 | delete[] m_ppppcBinCodersCABAC; |
---|
[2] | 333 | } |
---|
[56] | 334 | delete[] m_pcSbacCoders; |
---|
| 335 | delete[] m_pcBinCoderCABACs; |
---|
| 336 | delete[] m_pcRDGoOnSbacCoders; |
---|
| 337 | delete[] m_pcRDGoOnBinCodersCABAC; |
---|
| 338 | delete[] m_pcBitCounters; |
---|
| 339 | delete[] m_pcRdCosts; |
---|
| 340 | |
---|
[2] | 341 | // destroy ROM |
---|
[56] | 342 | if(m_viewId == 0 && m_isDepth == false) |
---|
| 343 | { |
---|
| 344 | destroyROM(); |
---|
| 345 | } |
---|
| 346 | |
---|
[166] | 347 | #if VSP_N |
---|
| 348 | if( m_pcPicVSP ) |
---|
| 349 | { |
---|
| 350 | m_pcPicVSP->destroy(); |
---|
| 351 | delete m_pcPicVSP; |
---|
| 352 | m_pcPicVSP = NULL; |
---|
| 353 | } |
---|
| 354 | if( m_pcPicAvail ) |
---|
| 355 | { |
---|
| 356 | m_pcPicAvail->destroy(); |
---|
| 357 | delete m_pcPicAvail; |
---|
| 358 | m_pcPicAvail = NULL; |
---|
| 359 | } |
---|
| 360 | #endif |
---|
| 361 | |
---|
[2] | 362 | return; |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | Void TEncTop::init( TAppEncTop* pcTAppEncTop ) |
---|
| 366 | { |
---|
| 367 | UInt *aTable4=NULL, *aTable8=NULL; |
---|
[56] | 368 | UInt* aTableLastPosVlcIndex=NULL; |
---|
[2] | 369 | // initialize SPS |
---|
| 370 | xInitSPS(); |
---|
[56] | 371 | |
---|
[2] | 372 | // initialize PPS |
---|
[56] | 373 | m_cPPS.setSPS(&m_cSPS); |
---|
| 374 | #if RPS_IN_SPS |
---|
| 375 | m_cSPS.setRPSList(&m_RPSList); |
---|
| 376 | #else |
---|
| 377 | m_cPPS.setRPSList(&m_RPSList); |
---|
| 378 | #endif |
---|
[2] | 379 | xInitPPS(); |
---|
[56] | 380 | xInitRPS(); |
---|
[2] | 381 | |
---|
[56] | 382 | xInitSPSforInterViewRefs(); |
---|
| 383 | xInitPPSforTiles(); |
---|
| 384 | |
---|
[2] | 385 | // initialize processing unit classes |
---|
[56] | 386 | m_cGOPEncoder. init( this ); |
---|
[2] | 387 | m_cSliceEncoder.init( this ); |
---|
| 388 | m_cCuEncoder. init( this ); |
---|
[56] | 389 | |
---|
| 390 | m_pcTAppEncTop = pcTAppEncTop; |
---|
[2] | 391 | |
---|
[5] | 392 | #if DEPTH_MAP_GENERATION |
---|
[77] | 393 | #if VIDYO_VPS_INTEGRATION |
---|
| 394 | m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getVPSAccess(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() ); |
---|
| 395 | #else |
---|
[2] | 396 | m_cDepthMapGenerator.init( (TComPrediction*)this->getPredSearch(), m_pcTAppEncTop->getSPSAccess(), m_pcTAppEncTop->getAUPicAccess() ); |
---|
[5] | 397 | #endif |
---|
[77] | 398 | #endif |
---|
[5] | 399 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 400 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
[5] | 401 | #endif |
---|
[2] | 402 | |
---|
| 403 | // initialize transform & quantization class |
---|
| 404 | m_pcCavlcCoder = getCavlcCoder(); |
---|
[56] | 405 | |
---|
| 406 | m_cTrQuant.init( g_uiMaxCUWidth, g_uiMaxCUHeight, 1 << m_uiQuadtreeTULog2MaxSize, |
---|
| 407 | 0, |
---|
| 408 | aTable4, aTable8, |
---|
| 409 | aTableLastPosVlcIndex, m_bUseRDOQ, true |
---|
| 410 | #if ADAPTIVE_QP_SELECTION |
---|
| 411 | , m_bUseAdaptQpSelect |
---|
[2] | 412 | #endif |
---|
[56] | 413 | ); |
---|
| 414 | |
---|
[2] | 415 | // initialize encoder search class |
---|
| 416 | m_cSearch.init( this, &m_cTrQuant, m_iSearchRange, m_bipredSearchRange, m_iFastSearch, 0, &m_cEntropyCoder, &m_cRdCost, getRDSbacCoder(), getRDGoOnSbacCoder() ); |
---|
| 417 | |
---|
| 418 | if(m_bUseALF) |
---|
| 419 | { |
---|
| 420 | m_cAdaptiveLoopFilter.setALFEncodePassReduction( m_iALFEncodePassReduction ); |
---|
[56] | 421 | m_cAdaptiveLoopFilter.setALFMaxNumberFilters( m_iALFMaxNumberFilters ); |
---|
| 422 | #if LCU_SYNTAX_ALF |
---|
| 423 | m_cAdaptiveLoopFilter.initPicQuadTreePartition(m_bALFPicBasedEncode ); |
---|
| 424 | #endif |
---|
[2] | 425 | } |
---|
[56] | 426 | |
---|
| 427 | m_iMaxRefPicNum = 0; |
---|
[166] | 428 | |
---|
| 429 | #if VSP_N |
---|
| 430 | m_pcPicVSP->setCurrSliceIdx( 0 ); |
---|
| 431 | m_pcPicVSP->getCurrSlice()->setSPS( this->getSPS() ); |
---|
| 432 | m_pcPicVSP->getCurrSlice()->setPPS( this->getPPS() ); |
---|
| 433 | m_pcPicVSP->getCurrSlice()->setPPSId( this->getPPS()->getPPSId() ); |
---|
| 434 | //initialize the motion vector field with zeros - How about the RefIdx ???? |
---|
| 435 | //IS THIS REALLY NECESSARY ???? |
---|
| 436 | for ( int i=0; i<m_pcPicVSP->getPicSym()->getNumberOfCUsInFrame(); i++ ) |
---|
| 437 | { |
---|
| 438 | m_pcPicVSP->getPicSym()->getCU(i)->getCUMvField(RefPicList(0))->clearMvField(); |
---|
| 439 | m_pcPicVSP->getPicSym()->getCU(i)->getCUMvField(RefPicList(1))->clearMvField(); |
---|
| 440 | } |
---|
| 441 | #if DEPTH_MAP_GENERATION |
---|
| 442 | #if !QC_MULTI_DIS_CAN |
---|
| 443 | // add extra pic buffers |
---|
| 444 | Bool bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); |
---|
| 445 | if( bNeedPrdDepthMapBuf && !m_pcPicVSP->getPredDepthMap() ) |
---|
| 446 | { |
---|
| 447 | m_pcPicVSP->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
| 448 | m_cDepthMapGenerator.clearDepthMap( m_pcPicVSP ); |
---|
| 449 | } |
---|
| 450 | #endif |
---|
| 451 | #endif |
---|
| 452 | m_pcPicAvail->setCurrSliceIdx( 0 ); |
---|
| 453 | m_pcPicAvail->getCurrSlice()->setSPS( this->getSPS() ); |
---|
| 454 | m_pcPicAvail->getCurrSlice()->setPPS( this->getPPS() ); |
---|
| 455 | m_pcPicAvail->getCurrSlice()->setPPSId( this->getPPS()->getPPSId() ); |
---|
| 456 | //initialize the motion vector field with zeros - How about the RefIdx ???? |
---|
| 457 | //IS THIS REALLY NECESSARY ???? |
---|
| 458 | for ( int i=0; i<m_pcPicAvail->getPicSym()->getNumberOfCUsInFrame(); i++ ) |
---|
| 459 | { |
---|
| 460 | m_pcPicAvail->getPicSym()->getCU(i)->getCUMvField(RefPicList(0))->clearMvField(); |
---|
| 461 | m_pcPicAvail->getPicSym()->getCU(i)->getCUMvField(RefPicList(1))->clearMvField(); |
---|
| 462 | } |
---|
| 463 | #if DEPTH_MAP_GENERATION |
---|
| 464 | #if !QC_MULTI_DIS_CAN |
---|
| 465 | // add extra pic buffers |
---|
| 466 | bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); |
---|
| 467 | if( bNeedPrdDepthMapBuf && !m_pcPicVSP->getPredDepthMap() ) |
---|
| 468 | { |
---|
| 469 | m_pcPicAvail->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
| 470 | m_cDepthMapGenerator.clearDepthMap( m_pcPicAvail ); |
---|
| 471 | } |
---|
| 472 | #endif |
---|
| 473 | #endif |
---|
| 474 | #endif |
---|
[2] | 475 | } |
---|
| 476 | |
---|
| 477 | // ==================================================================================================================== |
---|
| 478 | // Public member functions |
---|
| 479 | // ==================================================================================================================== |
---|
| 480 | |
---|
[56] | 481 | Void TEncTop::initNewPic( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcOrgPdmDepth ) |
---|
| 482 | { |
---|
| 483 | TComPic* pcPicCurr = NULL; |
---|
| 484 | |
---|
| 485 | // get original YUV |
---|
| 486 | xGetNewPicBuffer( pcPicCurr ); |
---|
| 487 | pcPicYuvOrg->copyToPic( pcPicCurr->getPicYuvOrg() ); |
---|
| 488 | |
---|
| 489 | #if SONY_COLPIC_AVAILABILITY |
---|
| 490 | pcPicCurr->setViewOrderIdx(m_iViewOrderIdx); |
---|
| 491 | #endif |
---|
| 492 | pcPicCurr->setScaleOffset( m_aaiCodedScale, m_aaiCodedOffset ); |
---|
| 493 | |
---|
| 494 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 495 | if( m_uiMultiviewMvRegMode ) |
---|
| 496 | { |
---|
| 497 | AOF( pcOrgPdmDepth ); |
---|
| 498 | AOF( pcPicCurr->getOrgDepthMap() ); |
---|
| 499 | pcOrgPdmDepth->copyToPic( pcPicCurr->getOrgDepthMap() ); |
---|
| 500 | } |
---|
| 501 | else |
---|
| 502 | { |
---|
| 503 | AOT( pcOrgPdmDepth ); |
---|
| 504 | AOT( pcPicCurr->getOrgDepthMap() ); |
---|
| 505 | } |
---|
| 506 | #endif |
---|
| 507 | |
---|
| 508 | #if DEPTH_MAP_GENERATION |
---|
| 509 | // add extra pic buffers |
---|
| 510 | Bool bNeedPrdDepthMapBuf = ( m_uiPredDepthMapGeneration > 0 ); |
---|
| 511 | if( bNeedPrdDepthMapBuf && !pcPicCurr->getPredDepthMap() ) |
---|
| 512 | { |
---|
| 513 | pcPicCurr->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(m_uiPredDepthMapGeneration), PDM_SUB_SAMP_EXP_Y(m_uiPredDepthMapGeneration) ); |
---|
| 514 | } |
---|
| 515 | #endif |
---|
| 516 | |
---|
| 517 | // compute image characteristics |
---|
| 518 | if ( getUseAdaptiveQP() ) |
---|
| 519 | { |
---|
| 520 | m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcPicCurr ) ); |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | |
---|
[2] | 524 | Void TEncTop::deletePicBuffer() |
---|
| 525 | { |
---|
| 526 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 527 | Int iSize = Int( m_cListPic.size() ); |
---|
[56] | 528 | |
---|
[2] | 529 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 530 | { |
---|
| 531 | TComPic* pcPic = *(iterPic++); |
---|
[56] | 532 | |
---|
[2] | 533 | pcPic->destroy(); |
---|
| 534 | delete pcPic; |
---|
| 535 | pcPic = NULL; |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | /** |
---|
| 540 | - Application has picture buffer list with size of GOP + 1 |
---|
| 541 | - Picture buffer list acts like as ring buffer |
---|
| 542 | - End of the list has the latest picture |
---|
| 543 | . |
---|
| 544 | \param bEos true if end-of-sequence is reached |
---|
| 545 | \param pcPicYuvOrg original YUV picture |
---|
| 546 | \retval rcListPicYuvRecOut list of reconstruction YUV pictures |
---|
| 547 | \retval rcListBitstreamOut list of output bitstreams |
---|
| 548 | \retval iNumEncoded number of encoded pictures |
---|
| 549 | */ |
---|
[56] | 550 | Void TEncTop::encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Int gopId ) |
---|
| 551 | { |
---|
[2] | 552 | |
---|
[56] | 553 | if( gopId == 0) |
---|
[2] | 554 | { |
---|
[56] | 555 | m_cGOPEncoder.initGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); |
---|
[2] | 556 | } |
---|
| 557 | |
---|
| 558 | { |
---|
[56] | 559 | m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId ); |
---|
[2] | 560 | } |
---|
[56] | 561 | |
---|
| 562 | if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) |
---|
[2] | 563 | { |
---|
[56] | 564 | iNumEncoded = m_iNumPicRcvd; |
---|
| 565 | m_iNumPicRcvd = 0; |
---|
| 566 | m_uiNumAllPicCoded += iNumEncoded; |
---|
[2] | 567 | } |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | |
---|
[56] | 571 | #if HHI_INTERVIEW_SKIP || HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 572 | Void |
---|
| 573 | TEncTop::deleteExtraPicBuffers( Int iPoc ) |
---|
| 574 | { |
---|
| 575 | TComPic* pcPic = 0; |
---|
| 576 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 577 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 578 | for( ; cIter != cEnd; cIter++ ) |
---|
| 579 | { |
---|
| 580 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 581 | { |
---|
| 582 | pcPic = *cIter; |
---|
| 583 | break; |
---|
| 584 | } |
---|
| 585 | } |
---|
| 586 | AOF( pcPic ); |
---|
| 587 | if ( pcPic ) |
---|
| 588 | { |
---|
[5] | 589 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
[2] | 590 | pcPic->removeOrgDepthMapBuffer(); |
---|
[5] | 591 | #endif |
---|
| 592 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 593 | pcPic->removeResidualBuffer (); |
---|
[5] | 594 | #endif |
---|
| 595 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 596 | pcPic->removeUsedPelsMapBuffer(); |
---|
[5] | 597 | #endif |
---|
[2] | 598 | } |
---|
| 599 | } |
---|
[56] | 600 | #endif |
---|
[2] | 601 | |
---|
| 602 | Void |
---|
| 603 | TEncTop::compressMotion( Int iPoc ) |
---|
| 604 | { |
---|
| 605 | TComPic* pcPic = 0; |
---|
| 606 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 607 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 608 | for( ; cIter != cEnd; cIter++ ) |
---|
| 609 | { |
---|
| 610 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 611 | { |
---|
| 612 | pcPic = *cIter; |
---|
| 613 | break; |
---|
| 614 | } |
---|
| 615 | } |
---|
| 616 | AOF( pcPic ); |
---|
| 617 | if ( pcPic ) |
---|
| 618 | { |
---|
| 619 | pcPic->compressMotion(); |
---|
| 620 | } |
---|
| 621 | } |
---|
| 622 | |
---|
| 623 | // ==================================================================================================================== |
---|
| 624 | // Protected member functions |
---|
| 625 | // ==================================================================================================================== |
---|
| 626 | |
---|
| 627 | /** |
---|
| 628 | - Application has picture buffer list with size of GOP + 1 |
---|
| 629 | - Picture buffer list acts like as ring buffer |
---|
| 630 | - End of the list has the latest picture |
---|
| 631 | . |
---|
| 632 | \retval rpcPic obtained picture buffer |
---|
| 633 | */ |
---|
| 634 | Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic ) |
---|
| 635 | { |
---|
| 636 | TComSlice::sortPicList(m_cListPic); |
---|
[56] | 637 | |
---|
| 638 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 639 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxDecPicBuffering(MAX_TLAYER-1) + 2) ) |
---|
| 640 | #else |
---|
| 641 | if (m_cListPic.size() >= (UInt)(m_iGOPSize + getMaxNumberOfReferencePictures() + 2) ) |
---|
| 642 | #endif |
---|
[2] | 643 | { |
---|
[56] | 644 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 645 | Int iSize = Int( m_cListPic.size() ); |
---|
| 646 | for ( Int i = 0; i < iSize; i++ ) |
---|
| 647 | { |
---|
| 648 | rpcPic = *(++iterPic); |
---|
| 649 | if(rpcPic->getSlice(0)->isReferenced() == false) |
---|
| 650 | break; |
---|
| 651 | } |
---|
[2] | 652 | } |
---|
| 653 | else |
---|
| 654 | { |
---|
[56] | 655 | if ( getUseAdaptiveQP() ) |
---|
| 656 | { |
---|
| 657 | TEncPic* pcEPic = new TEncPic; |
---|
| 658 | pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ); |
---|
| 659 | rpcPic = pcEPic; |
---|
| 660 | } |
---|
| 661 | else |
---|
| 662 | { |
---|
| 663 | rpcPic = new TComPic; |
---|
| 664 | rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 665 | } |
---|
| 666 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 667 | } |
---|
[56] | 668 | #if HHI_INTERVIEW_SKIP |
---|
| 669 | if( m_bInterViewSkip ) |
---|
| 670 | { |
---|
| 671 | rpcPic->addUsedPelsMapBuffer(); |
---|
| 672 | } |
---|
| 673 | #endif |
---|
[2] | 674 | rpcPic->setReconMark (false); |
---|
[56] | 675 | |
---|
[2] | 676 | m_iPOCLast++; |
---|
| 677 | m_iNumPicRcvd++; |
---|
[56] | 678 | |
---|
[5] | 679 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
[2] | 680 | if( m_uiMultiviewMvRegMode ) |
---|
| 681 | { |
---|
| 682 | rpcPic->addOrgDepthMapBuffer(); |
---|
| 683 | } |
---|
[5] | 684 | #endif |
---|
[56] | 685 | |
---|
[2] | 686 | rpcPic->getSlice(0)->setPOC( m_iPOCLast ); |
---|
| 687 | // mark it should be extended |
---|
| 688 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
[100] | 689 | #if FIXES |
---|
| 690 | rpcPic->getPicYuvOrg()->setBorderExtension(false); |
---|
| 691 | #endif |
---|
[2] | 692 | } |
---|
| 693 | |
---|
| 694 | Void TEncTop::xInitSPS() |
---|
| 695 | { |
---|
[56] | 696 | m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); |
---|
| 697 | m_cSPS.setPicHeightInLumaSamples ( m_iSourceHeight ); |
---|
| 698 | #if PIC_CROPPING |
---|
| 699 | m_cSPS.setPicCroppingFlag( m_croppingMode!= 0 ); |
---|
| 700 | if (m_croppingMode != 0) |
---|
| 701 | { |
---|
| 702 | m_cSPS.setPicCropLeftOffset( m_cropLeft ); |
---|
| 703 | m_cSPS.setPicCropRightOffset( m_cropRight ); |
---|
| 704 | m_cSPS.setPicCropTopOffset( m_cropTop ); |
---|
| 705 | m_cSPS.setPicCropBottomOffset( m_cropBottom ); |
---|
| 706 | } |
---|
| 707 | #else |
---|
[2] | 708 | m_cSPS.setPad ( m_aiPad ); |
---|
[56] | 709 | #endif |
---|
[2] | 710 | m_cSPS.setMaxCUWidth ( g_uiMaxCUWidth ); |
---|
| 711 | m_cSPS.setMaxCUHeight ( g_uiMaxCUHeight ); |
---|
| 712 | m_cSPS.setMaxCUDepth ( g_uiMaxCUDepth ); |
---|
| 713 | m_cSPS.setMinTrDepth ( 0 ); |
---|
| 714 | m_cSPS.setMaxTrDepth ( 1 ); |
---|
[56] | 715 | |
---|
| 716 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 717 | m_cSPS.setMaxNumberOfReferencePictures(m_maxNumberOfReferencePictures); |
---|
| 718 | m_cSPS.setNumReorderFrames(m_numReorderFrames); |
---|
| 719 | #endif |
---|
| 720 | m_cSPS.setPCMLog2MinSize (m_uiPCMLog2MinSize); |
---|
| 721 | m_cSPS.setUsePCM ( m_usePCM ); |
---|
| 722 | m_cSPS.setPCMLog2MaxSize( m_pcmLog2MaxSize ); |
---|
[2] | 723 | |
---|
| 724 | m_cSPS.setUseALF ( m_bUseALF ); |
---|
[56] | 725 | #if LCU_SYNTAX_ALF |
---|
| 726 | if(m_bUseALF) |
---|
| 727 | { |
---|
| 728 | m_cSPS.setUseALFCoefInSlice(m_bALFParamInSlice); |
---|
| 729 | } |
---|
| 730 | #endif |
---|
| 731 | |
---|
[2] | 732 | m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize ); |
---|
| 733 | m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize ); |
---|
| 734 | m_cSPS.setQuadtreeTUMaxDepthInter( m_uiQuadtreeTUMaxDepthInter ); |
---|
| 735 | m_cSPS.setQuadtreeTUMaxDepthIntra( m_uiQuadtreeTUMaxDepthIntra ); |
---|
[56] | 736 | |
---|
| 737 | #if LOSSLESS_CODING |
---|
| 738 | m_cSPS.setUseLossless ( m_useLossless ); |
---|
[2] | 739 | #endif |
---|
[56] | 740 | #if !PIC_CROPPING |
---|
[2] | 741 | m_cSPS.setUsePAD ( m_bUsePAD ); |
---|
[56] | 742 | #endif |
---|
| 743 | m_cSPS.setUseLMChroma ( m_bUseLMChroma ); |
---|
| 744 | |
---|
| 745 | m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); |
---|
| 746 | |
---|
| 747 | m_cSPS.setUseLComb ( m_bUseLComb ); |
---|
| 748 | m_cSPS.setLCMod ( m_bLCMod ); |
---|
| 749 | m_cSPS.setUseNSQT( m_useNSQT ); |
---|
| 750 | |
---|
| 751 | Int i; |
---|
| 752 | #if HHI_AMVP_OFF |
---|
| 753 | for ( i = 0; i < g_uiMaxCUDepth; i++ ) |
---|
| 754 | { |
---|
| 755 | m_cSPS.setAMVPMode( i, AM_NONE ); |
---|
| 756 | } |
---|
| 757 | #else |
---|
| 758 | for ( i = 0; i < g_uiMaxCUDepth; i++ ) |
---|
| 759 | { |
---|
| 760 | m_cSPS.setAMVPMode( i, AM_EXPL ); |
---|
| 761 | } |
---|
| 762 | #endif |
---|
| 763 | |
---|
| 764 | for (i = 0; i < g_uiMaxCUDepth-1; i++ ) |
---|
| 765 | { |
---|
| 766 | m_cSPS.setAMPAcc( i, m_useAMP ); |
---|
| 767 | //m_cSPS.setAMPAcc( i, 1 ); |
---|
| 768 | } |
---|
[2] | 769 | |
---|
[56] | 770 | m_cSPS.setUseAMP ( m_useAMP ); |
---|
[2] | 771 | |
---|
[56] | 772 | for (i = g_uiMaxCUDepth-1; i < g_uiMaxCUDepth; i++ ) |
---|
| 773 | { |
---|
| 774 | m_cSPS.setAMPAcc(i, 0); |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | m_cSPS.setBitDepth ( g_uiBitDepth ); |
---|
| 778 | m_cSPS.setBitIncrement( g_uiBitIncrement ); |
---|
| 779 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 780 | m_cSPS.setQpBDOffsetY ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
| 781 | m_cSPS.setQpBDOffsetC ( (Int)(6*(g_uiBitDepth + g_uiBitIncrement - 8)) ); |
---|
[2] | 782 | #endif |
---|
| 783 | |
---|
[56] | 784 | m_cSPS.setLFCrossSliceBoundaryFlag( m_bLFCrossSliceBoundaryFlag ); |
---|
| 785 | m_cSPS.setUseSAO( m_bUseSAO ); |
---|
[2] | 786 | |
---|
[56] | 787 | #if !H0566_TLA |
---|
| 788 | if ( m_bTLayering ) |
---|
| 789 | { |
---|
| 790 | Int iMaxTLayers = 1; |
---|
| 791 | for ( i = 1; ; i++) |
---|
| 792 | { |
---|
| 793 | iMaxTLayers = i; |
---|
| 794 | if ( (m_iGOPSize >> i) == 0 ) |
---|
| 795 | { |
---|
| 796 | break; |
---|
| 797 | } |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | m_cSPS.setMaxTLayers( (UInt)iMaxTLayers ); |
---|
| 801 | |
---|
| 802 | Bool bTemporalIdNestingFlag = true; |
---|
| 803 | for ( i = 0; i < m_cSPS.getMaxTLayers()-1; i++ ) |
---|
| 804 | { |
---|
| 805 | if ( !m_abTLayerSwitchingFlag[i] ) |
---|
| 806 | { |
---|
| 807 | bTemporalIdNestingFlag = false; |
---|
| 808 | break; |
---|
| 809 | } |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | m_cSPS.setTemporalIdNestingFlag( bTemporalIdNestingFlag ); |
---|
| 813 | } |
---|
| 814 | else |
---|
| 815 | { |
---|
| 816 | m_cSPS.setMaxTLayers( 1 ); |
---|
| 817 | m_cSPS.setTemporalIdNestingFlag( false ); |
---|
| 818 | } |
---|
| 819 | #else |
---|
| 820 | m_cSPS.setMaxTLayers( m_maxTempLayer ); |
---|
| 821 | m_cSPS.setTemporalIdNestingFlag( false ); |
---|
[42] | 822 | #endif |
---|
[56] | 823 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 824 | for ( i = 0; i < m_cSPS.getMaxTLayers(); i++ ) |
---|
| 825 | { |
---|
| 826 | m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i); |
---|
| 827 | m_cSPS.setNumReorderPics(m_numReorderPics[i], i); |
---|
| 828 | } |
---|
| 829 | #endif |
---|
| 830 | m_cSPS.setPCMBitDepthLuma (g_uiPCMBitDepthLuma); |
---|
| 831 | m_cSPS.setPCMBitDepthChroma (g_uiPCMBitDepthChroma); |
---|
| 832 | m_cSPS.setPCMFilterDisableFlag ( m_bPCMFilterDisableFlag ); |
---|
[42] | 833 | |
---|
[56] | 834 | m_cSPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 835 | m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); |
---|
| 836 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 837 | m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); |
---|
| 838 | #endif |
---|
| 839 | m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
| 840 | m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
| 841 | if( m_iUniformSpacingIdr == 0 ) |
---|
[2] | 842 | { |
---|
[56] | 843 | m_cSPS.setColumnWidth( m_puiColumnWidth ); |
---|
| 844 | m_cSPS.setRowHeight( m_puiRowHeight ); |
---|
| 845 | } |
---|
| 846 | m_cSPS.setScalingListFlag ( (m_useScalingListId == 0) ? 0 : 1 ); |
---|
| 847 | m_cSPS.setUseDF( m_loopFilterOffsetInAPS ); |
---|
| 848 | |
---|
| 849 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 850 | m_cSPS.setUseDMM( m_bUseDMM ); |
---|
| 851 | #endif |
---|
[193] | 852 | #if OL_DEPTHLIMIT_A0044 |
---|
| 853 | m_cSPS.setUseDPL( m_bDepthPartitionLimiting ); |
---|
| 854 | #endif |
---|
[56] | 855 | #if HHI_MPI |
---|
| 856 | m_cSPS.setUseMVI( m_bUseMVI ); |
---|
| 857 | #endif |
---|
| 858 | |
---|
| 859 | if( m_isDepth ) |
---|
| 860 | { |
---|
| 861 | m_cSPS.initMultiviewSPSDepth ( m_viewId, m_iViewOrderIdx ); |
---|
[5] | 862 | #if DEPTH_MAP_GENERATION |
---|
[56] | 863 | m_cSPS.setPredDepthMapGeneration( m_viewId, true ); |
---|
[5] | 864 | #endif |
---|
| 865 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 866 | m_cSPS.setMultiviewResPredMode ( 0 ); |
---|
[5] | 867 | #endif |
---|
[2] | 868 | } |
---|
| 869 | else |
---|
| 870 | { |
---|
[56] | 871 | m_cSPS.initMultiviewSPS ( m_viewId, m_iViewOrderIdx, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset ); |
---|
| 872 | if( m_viewId ) |
---|
[2] | 873 | { |
---|
[5] | 874 | #if DEPTH_MAP_GENERATION |
---|
| 875 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
[56] | 876 | m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, m_uiMultiviewMvPredMode, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); |
---|
[5] | 877 | #else |
---|
[56] | 878 | m_cSPS.setPredDepthMapGeneration( m_viewId, false, m_uiPredDepthMapGeneration, 0, m_uiPdmPrecision, m_aaiPdmScaleNomDelta, m_aaiPdmOffset ); |
---|
[5] | 879 | #endif |
---|
| 880 | #endif |
---|
| 881 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 882 | m_cSPS.setMultiviewResPredMode ( m_uiMultiviewResPredMode ); |
---|
[5] | 883 | #endif |
---|
[2] | 884 | } |
---|
| 885 | else |
---|
| 886 | { |
---|
[5] | 887 | #if DEPTH_MAP_GENERATION |
---|
[56] | 888 | m_cSPS.setPredDepthMapGeneration( m_viewId, false ); |
---|
[5] | 889 | #endif |
---|
| 890 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 891 | m_cSPS.setMultiviewResPredMode ( 0 ); |
---|
[5] | 892 | #endif |
---|
[2] | 893 | } |
---|
| 894 | } |
---|
[193] | 895 | #if VSP_N |
---|
| 896 | m_cSPS.setVspPresentFlag( m_bUseVSP ); |
---|
| 897 | #if VSP_CFG |
---|
| 898 | m_cSPS.setVspDepthPresentFlag( m_bVSPDepthDisable ? false : true ); |
---|
| 899 | #endif |
---|
| 900 | #endif |
---|
[56] | 901 | } |
---|
[2] | 902 | |
---|
[56] | 903 | Void TEncTop::xInitPPS() |
---|
| 904 | { |
---|
| 905 | m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); |
---|
| 906 | m_cPPS.setSliceGranularity(m_iSliceGranularity); |
---|
| 907 | #if !H0566_TLA |
---|
| 908 | if ( m_cSPS.getTemporalIdNestingFlag() ) |
---|
| 909 | { |
---|
| 910 | m_cPPS.setNumTLayerSwitchingFlags( 0 ); |
---|
| 911 | for ( UInt i = 0; i < m_cSPS.getMaxTLayers() - 1; i++ ) |
---|
| 912 | { |
---|
| 913 | m_cPPS.setTLayerSwitchingFlag( i, true ); |
---|
| 914 | } |
---|
| 915 | } |
---|
| 916 | else |
---|
| 917 | { |
---|
| 918 | m_cPPS.setNumTLayerSwitchingFlags( m_cSPS.getMaxTLayers() - 1 ); |
---|
| 919 | for ( UInt i = 0; i < m_cPPS.getNumTLayerSwitchingFlags(); i++ ) |
---|
| 920 | { |
---|
| 921 | m_cPPS.setTLayerSwitchingFlag( i, m_abTLayerSwitchingFlag[i] ); |
---|
| 922 | } |
---|
| 923 | } |
---|
[2] | 924 | #endif |
---|
[56] | 925 | Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; |
---|
[2] | 926 | |
---|
[56] | 927 | #if LOSSLESS_CODING |
---|
| 928 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 929 | Int lowestQP = - m_cSPS.getQpBDOffsetY(); |
---|
| 930 | #else |
---|
| 931 | Int lowestQP = 0; |
---|
| 932 | #endif |
---|
| 933 | |
---|
| 934 | if(getUseLossless()) |
---|
[2] | 935 | { |
---|
[56] | 936 | if ((getMaxCuDQPDepth() == 0) && (getMaxDeltaQP() == 0 ) && (getQP() == lowestQP) ) |
---|
| 937 | { |
---|
| 938 | bUseDQP = false; |
---|
| 939 | } |
---|
| 940 | else |
---|
| 941 | { |
---|
| 942 | bUseDQP = true; |
---|
| 943 | } |
---|
[2] | 944 | } |
---|
[56] | 945 | else |
---|
| 946 | { |
---|
| 947 | if(bUseDQP == false) |
---|
| 948 | { |
---|
| 949 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
| 950 | { |
---|
| 951 | bUseDQP = true; |
---|
| 952 | } |
---|
| 953 | } |
---|
| 954 | } |
---|
| 955 | |
---|
[2] | 956 | #else |
---|
[56] | 957 | if(bUseDQP == false) |
---|
[2] | 958 | { |
---|
[56] | 959 | if((getMaxDeltaQP() != 0 )|| getUseAdaptiveQP()) |
---|
| 960 | { |
---|
| 961 | bUseDQP = true; |
---|
| 962 | } |
---|
[2] | 963 | } |
---|
| 964 | #endif |
---|
| 965 | |
---|
[56] | 966 | if(bUseDQP) |
---|
| 967 | { |
---|
| 968 | m_cPPS.setUseDQP(true); |
---|
| 969 | m_cPPS.setMaxCuDQPDepth( m_iMaxCuDQPDepth ); |
---|
| 970 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 971 | } |
---|
| 972 | else |
---|
| 973 | { |
---|
| 974 | m_cPPS.setUseDQP(false); |
---|
| 975 | m_cPPS.setMaxCuDQPDepth( 0 ); |
---|
| 976 | m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); |
---|
| 977 | } |
---|
[2] | 978 | |
---|
[56] | 979 | m_cPPS.setChromaQpOffset ( m_iChromaQpOffset ); |
---|
| 980 | m_cPPS.setChromaQpOffset2nd( m_iChromaQpOffset2nd ); |
---|
[2] | 981 | |
---|
[56] | 982 | m_cPPS.setEntropyCodingMode( 1 ); // In the PPS now, but also remains in slice header! |
---|
| 983 | #if !WPP_SIMPLIFICATION |
---|
| 984 | m_cPPS.setEntropyCodingSynchro(m_iWaveFrontSynchro); |
---|
| 985 | m_cPPS.setCabacIstateReset(m_iWaveFrontFlush != 0); |
---|
[2] | 986 | #endif |
---|
[56] | 987 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams); |
---|
| 988 | m_cPPS.setUseWP( m_bUseWeightPred ); |
---|
| 989 | m_cPPS.setWPBiPredIdc( m_uiBiPredIdc ); |
---|
| 990 | m_cPPS.setEnableTMVPFlag( m_bEnableTMVP ); |
---|
| 991 | #if H0388 |
---|
| 992 | m_cPPS.setOutputFlagPresentFlag( false ); |
---|
[2] | 993 | #endif |
---|
[56] | 994 | #if MULTIBITS_DATA_HIDING |
---|
| 995 | m_cPPS.setSignHideFlag(getSignHideFlag()); |
---|
| 996 | m_cPPS.setTSIG(getTSIG()); |
---|
[2] | 997 | #endif |
---|
[56] | 998 | #if DBL_CONTROL |
---|
| 999 | m_cPPS.setDeblockingFilterControlPresent (m_DeblockingFilterControlPresent ); |
---|
[42] | 1000 | #endif |
---|
[56] | 1001 | #if PARALLEL_MERGE |
---|
| 1002 | m_cPPS.setLog2ParallelMergeLevelMinus2 (LOG2_PARALLEL_MERGE_LEVEL_MINUS2); |
---|
[5] | 1003 | #endif |
---|
[56] | 1004 | #if CABAC_INIT_FLAG |
---|
| 1005 | m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); |
---|
[42] | 1006 | #endif |
---|
[2] | 1007 | } |
---|
| 1008 | |
---|
[56] | 1009 | //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. |
---|
| 1010 | Void TEncTop::xInitRPS() |
---|
[2] | 1011 | { |
---|
[56] | 1012 | TComReferencePictureSet* rps; |
---|
| 1013 | |
---|
| 1014 | m_RPSList.create(getGOPSize()+m_extraRPSs); |
---|
| 1015 | for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) |
---|
| 1016 | { |
---|
| 1017 | GOPEntryMvc ge = getGOPEntry(i); |
---|
| 1018 | rps = m_RPSList.getReferencePictureSet(i); |
---|
| 1019 | rps->setNumberOfPictures(ge.m_numRefPics); |
---|
| 1020 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1021 | Int numNeg = 0; |
---|
| 1022 | Int numPos = 0; |
---|
| 1023 | for( Int j = 0; j < ge.m_numRefPics; j++) |
---|
[2] | 1024 | { |
---|
[56] | 1025 | rps->setDeltaPOC(j,ge.m_referencePics[j]); |
---|
| 1026 | rps->setUsed(j,ge.m_usedByCurrPic[j]); |
---|
| 1027 | if(ge.m_referencePics[j]>0) |
---|
| 1028 | { |
---|
| 1029 | numPos++; |
---|
| 1030 | } |
---|
| 1031 | else |
---|
| 1032 | { |
---|
| 1033 | numNeg++; |
---|
| 1034 | } |
---|
[2] | 1035 | } |
---|
[56] | 1036 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1037 | rps->setNumberOfPositivePictures(numPos); |
---|
| 1038 | rps->setInterRPSPrediction(ge.m_interRPSPrediction); |
---|
| 1039 | if (ge.m_interRPSPrediction) |
---|
[2] | 1040 | { |
---|
[56] | 1041 | rps->setDeltaRIdxMinus1(ge.m_deltaRIdxMinus1); |
---|
| 1042 | rps->setDeltaRPS(ge.m_deltaRPS); |
---|
| 1043 | rps->setNumRefIdc(ge.m_numRefIdc); |
---|
| 1044 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1045 | { |
---|
| 1046 | rps->setRefIdc(j, ge.m_refIdc[j]); |
---|
| 1047 | } |
---|
| 1048 | #if WRITE_BACK |
---|
| 1049 | // the folowing code overwrite the deltaPOC and Used by current values read from the config file with the ones |
---|
| 1050 | // computed from the RefIdc. This is not necessary if both are identical. Currently there is no check to see if they are identical. |
---|
| 1051 | numNeg = 0; |
---|
| 1052 | numPos = 0; |
---|
| 1053 | TComReferencePictureSet* RPSRef = m_RPSList.getReferencePictureSet(i-(ge.m_deltaRIdxMinus1+1)); |
---|
| 1054 | for (Int j = 0; j < ge.m_numRefIdc; j++ ) |
---|
| 1055 | { |
---|
| 1056 | if (ge.m_refIdc[j]) |
---|
| 1057 | { |
---|
| 1058 | Int deltaPOC = ge.m_deltaRPS + ((j < RPSRef->getNumberOfPictures())? RPSRef->getDeltaPOC(j) : 0); |
---|
| 1059 | rps->setDeltaPOC((numNeg+numPos),deltaPOC); |
---|
| 1060 | rps->setUsed((numNeg+numPos),ge.m_refIdc[j]==1?1:0); |
---|
| 1061 | if (deltaPOC<0) |
---|
| 1062 | { |
---|
| 1063 | numNeg++; |
---|
| 1064 | } |
---|
| 1065 | else |
---|
| 1066 | { |
---|
| 1067 | numPos++; |
---|
| 1068 | } |
---|
| 1069 | } |
---|
| 1070 | } |
---|
| 1071 | rps->setNumberOfNegativePictures(numNeg); |
---|
| 1072 | rps->setNumberOfPositivePictures(numPos); |
---|
| 1073 | rps->sortDeltaPOC(); |
---|
| 1074 | #endif |
---|
[2] | 1075 | } |
---|
[56] | 1076 | } |
---|
| 1077 | |
---|
| 1078 | } |
---|
[2] | 1079 | |
---|
[56] | 1080 | // This is a function that |
---|
| 1081 | // determines what Reference Picture Set to use |
---|
| 1082 | // for a specific slice (with POC = POCCurr) |
---|
| 1083 | Void TEncTop::selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid,TComList<TComPic*>& listPic ) |
---|
| 1084 | { |
---|
[77] | 1085 | if( slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && POCCurr == 0 ) |
---|
[56] | 1086 | { |
---|
| 1087 | TComReferencePictureSet* rps = slice->getLocalRPS(); |
---|
| 1088 | rps->setNumberOfNegativePictures(0); |
---|
| 1089 | rps->setNumberOfPositivePictures(0); |
---|
| 1090 | rps->setNumberOfLongtermPictures(0); |
---|
| 1091 | rps->setNumberOfPictures(0); |
---|
| 1092 | slice->setRPS(rps); |
---|
| 1093 | } |
---|
| 1094 | else |
---|
| 1095 | { |
---|
| 1096 | slice->setRPSidx(GOPid); |
---|
[2] | 1097 | |
---|
[56] | 1098 | for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) |
---|
| 1099 | { |
---|
| 1100 | if(m_uiIntraPeriod > 0) |
---|
| 1101 | { |
---|
| 1102 | if(POCCurr%m_uiIntraPeriod==m_GOPList[extraNum].m_POC) |
---|
| 1103 | { |
---|
| 1104 | slice->setRPSidx(extraNum); |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | else |
---|
| 1108 | { |
---|
| 1109 | if(POCCurr==m_GOPList[extraNum].m_POC) |
---|
| 1110 | { |
---|
| 1111 | slice->setRPSidx(extraNum); |
---|
| 1112 | } |
---|
| 1113 | } |
---|
| 1114 | } |
---|
[2] | 1115 | |
---|
[56] | 1116 | slice->setRPS(getRPSList()->getReferencePictureSet(slice->getRPSidx())); |
---|
| 1117 | slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); |
---|
| 1118 | } |
---|
[2] | 1119 | } |
---|
| 1120 | |
---|
[56] | 1121 | Void TEncTop::xInitSPSforInterViewRefs() |
---|
[2] | 1122 | { |
---|
[56] | 1123 | // base view |
---|
| 1124 | if( getGOPEntry( MAX_GOP ).m_POC == -1 ) |
---|
| 1125 | { |
---|
| 1126 | m_cSPS.setNumberOfUsableInterViewRefs( 0 ); |
---|
| 1127 | m_cSPS.setListsModificationPresentFlag( false ); |
---|
| 1128 | return; |
---|
| 1129 | } |
---|
[2] | 1130 | |
---|
[56] | 1131 | Int numberUsableInterViewRefs = 0; |
---|
| 1132 | for( Int i = 0; i < getGOPSize()+1 && numberUsableInterViewRefs < MAX_VIEW_NUM; i++ ) |
---|
[2] | 1133 | { |
---|
[56] | 1134 | GOPEntryMvc ge = ( i < getGOPSize() ) ? getGOPEntry( i ) : getGOPEntry( MAX_GOP ); |
---|
| 1135 | for( Int j = 0; j < ge.m_numInterViewRefPics; j++ ) |
---|
[2] | 1136 | { |
---|
[56] | 1137 | // add ref view to list |
---|
| 1138 | Bool onList = false; |
---|
| 1139 | for( Int k = 0; k < numberUsableInterViewRefs; k++ ) |
---|
[2] | 1140 | { |
---|
[56] | 1141 | if( ge.m_interViewRefs[j] == m_cSPS.getUsableInterViewRef( k ) ) |
---|
[2] | 1142 | { |
---|
[56] | 1143 | onList = true; |
---|
[2] | 1144 | break; |
---|
| 1145 | } |
---|
| 1146 | } |
---|
[56] | 1147 | if( !onList ) |
---|
[2] | 1148 | { |
---|
[56] | 1149 | m_cSPS.setUsableInterViewRef( (UInt)numberUsableInterViewRefs, ge.m_interViewRefs[j] ); |
---|
| 1150 | numberUsableInterViewRefs++; |
---|
[2] | 1151 | } |
---|
| 1152 | } |
---|
| 1153 | } |
---|
[56] | 1154 | m_cSPS.setNumberOfUsableInterViewRefs( numberUsableInterViewRefs ); |
---|
| 1155 | |
---|
| 1156 | // sort inter view refs |
---|
| 1157 | for( Int j = 1; j < m_cSPS.getNumberOfUsableInterViewRefs(); j++ ) |
---|
| 1158 | { |
---|
| 1159 | Int deltaViewId = m_cSPS.getUsableInterViewRef( j ); |
---|
| 1160 | for( Int k = j-1; k >= 0; k-- ) |
---|
| 1161 | { |
---|
| 1162 | Int temp = m_cSPS.getUsableInterViewRef( k ); |
---|
| 1163 | if( deltaViewId > temp ) |
---|
| 1164 | { |
---|
| 1165 | m_cSPS.setUsableInterViewRef( k+1, temp ); |
---|
| 1166 | m_cSPS.setUsableInterViewRef( k, deltaViewId ); |
---|
| 1167 | } |
---|
| 1168 | } |
---|
[2] | 1169 | } |
---|
[56] | 1170 | |
---|
| 1171 | m_cSPS.setListsModificationPresentFlag( true ); |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | Void TEncTop::xInitPPSforTiles() |
---|
| 1175 | { |
---|
| 1176 | m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent ); |
---|
| 1177 | m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr ); |
---|
| 1178 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 1179 | m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr ); |
---|
| 1180 | #endif |
---|
| 1181 | m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 ); |
---|
| 1182 | m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 ); |
---|
| 1183 | if( m_iUniformSpacingIdr == 0 ) |
---|
[2] | 1184 | { |
---|
[56] | 1185 | m_cPPS.setColumnWidth( m_puiColumnWidth ); |
---|
| 1186 | m_cPPS.setRowHeight( m_puiRowHeight ); |
---|
[2] | 1187 | } |
---|
[56] | 1188 | m_cPPS.setTileBehaviorControlPresentFlag( m_iTileBehaviorControlPresentFlag ); |
---|
| 1189 | m_cPPS.setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag ); |
---|
| 1190 | |
---|
| 1191 | // # substreams is "per tile" when tiles are independent. |
---|
[193] | 1192 | #if FIX_REMOVE_TILE_DEPENDENCE |
---|
| 1193 | if ( m_iWaveFrontSynchro ) |
---|
| 1194 | #else |
---|
[56] | 1195 | if (m_iTileBoundaryIndependenceIdr && m_iWaveFrontSynchro) |
---|
[193] | 1196 | #endif |
---|
[2] | 1197 | { |
---|
[56] | 1198 | m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)); |
---|
[2] | 1199 | } |
---|
| 1200 | } |
---|
| 1201 | |
---|
[56] | 1202 | Void TEncCfg::xCheckGSParameters() |
---|
[2] | 1203 | { |
---|
[56] | 1204 | Int iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; |
---|
| 1205 | Int iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; |
---|
| 1206 | UInt uiCummulativeColumnWidth = 0; |
---|
| 1207 | UInt uiCummulativeRowHeight = 0; |
---|
| 1208 | |
---|
| 1209 | //check the column relative parameters |
---|
| 1210 | if( m_iNumColumnsMinus1 >= (1<<(LOG2_MAX_NUM_COLUMNS_MINUS1+1)) ) |
---|
[2] | 1211 | { |
---|
[56] | 1212 | printf( "The number of columns is larger than the maximum allowed number of columns.\n" ); |
---|
| 1213 | exit( EXIT_FAILURE ); |
---|
[2] | 1214 | } |
---|
[56] | 1215 | |
---|
| 1216 | if( m_iNumColumnsMinus1 >= iWidthInCU ) |
---|
[2] | 1217 | { |
---|
[56] | 1218 | printf( "The current picture can not have so many columns.\n" ); |
---|
| 1219 | exit( EXIT_FAILURE ); |
---|
[2] | 1220 | } |
---|
[56] | 1221 | |
---|
| 1222 | if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
[2] | 1223 | { |
---|
[56] | 1224 | for(Int i=0; i<m_iNumColumnsMinus1; i++) |
---|
| 1225 | uiCummulativeColumnWidth += m_puiColumnWidth[i]; |
---|
| 1226 | |
---|
| 1227 | if( uiCummulativeColumnWidth >= iWidthInCU ) |
---|
| 1228 | { |
---|
| 1229 | printf( "The width of the column is too large.\n" ); |
---|
| 1230 | exit( EXIT_FAILURE ); |
---|
| 1231 | } |
---|
[2] | 1232 | } |
---|
[56] | 1233 | |
---|
| 1234 | //check the row relative parameters |
---|
| 1235 | if( m_iNumRowsMinus1 >= (1<<(LOG2_MAX_NUM_ROWS_MINUS1+1)) ) |
---|
[2] | 1236 | { |
---|
[56] | 1237 | printf( "The number of rows is larger than the maximum allowed number of rows.\n" ); |
---|
| 1238 | exit( EXIT_FAILURE ); |
---|
[2] | 1239 | } |
---|
[56] | 1240 | |
---|
| 1241 | if( m_iNumRowsMinus1 >= iHeightInCU ) |
---|
[2] | 1242 | { |
---|
[56] | 1243 | printf( "The current picture can not have so many rows.\n" ); |
---|
| 1244 | exit( EXIT_FAILURE ); |
---|
[2] | 1245 | } |
---|
| 1246 | |
---|
[56] | 1247 | if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 ) |
---|
| 1248 | { |
---|
| 1249 | for(Int i=0; i<m_iNumRowsMinus1; i++) |
---|
| 1250 | uiCummulativeRowHeight += m_puiRowHeight[i]; |
---|
| 1251 | |
---|
| 1252 | if( uiCummulativeRowHeight >= iHeightInCU ) |
---|
| 1253 | { |
---|
| 1254 | printf( "The height of the row is too large.\n" ); |
---|
| 1255 | exit( EXIT_FAILURE ); |
---|
| 1256 | } |
---|
| 1257 | } |
---|
[2] | 1258 | } |
---|
| 1259 | |
---|
[56] | 1260 | Void TEncTop::setTEncTopList(std::vector<TEncTop*>* pacTEncTopList ) |
---|
| 1261 | { |
---|
| 1262 | assert(m_viewId!=-1); // not to be set for single view coding |
---|
[2] | 1263 | |
---|
[56] | 1264 | m_pacTEncTopList=pacTEncTopList; |
---|
| 1265 | |
---|
| 1266 | } |
---|
| 1267 | |
---|
| 1268 | Void TEncTop::printOutSummary(UInt uiNumAllPicCoded) |
---|
[2] | 1269 | { |
---|
[56] | 1270 | assert (uiNumAllPicCoded == m_cAnalyzeAll.getNumPic()); |
---|
[2] | 1271 | |
---|
[56] | 1272 | //--CFG_KDY |
---|
| 1273 | m_cAnalyzeAll.setFrmRate( getFrameRate() ); |
---|
| 1274 | m_cAnalyzeI.setFrmRate( getFrameRate() ); |
---|
| 1275 | m_cAnalyzeP.setFrmRate( getFrameRate() ); |
---|
| 1276 | m_cAnalyzeB.setFrmRate( getFrameRate() ); |
---|
[2] | 1277 | |
---|
[56] | 1278 | //-- all |
---|
| 1279 | if(m_viewId==-1) |
---|
| 1280 | printf( "\n\nSUMMARY --------------------------------------------------------\n" ); |
---|
| 1281 | else { |
---|
| 1282 | if ( m_isDepth ) |
---|
| 1283 | { |
---|
| 1284 | printf( "\n\nSUMMARY ---------------------------------------------- DEPTH %2d\n", m_viewId ); |
---|
| 1285 | } |
---|
| 1286 | else |
---|
| 1287 | { |
---|
| 1288 | printf( "\n\nSUMMARY ---------------------------------------------- VIDEO %2d\n", m_viewId ); |
---|
| 1289 | } |
---|
| 1290 | }; |
---|
| 1291 | m_cAnalyzeAll.printOut('a'); |
---|
[2] | 1292 | |
---|
[56] | 1293 | printf( "\n\nI Slices--------------------------------------------------------\n" ); |
---|
| 1294 | m_cAnalyzeI.printOut('i'); |
---|
| 1295 | |
---|
| 1296 | printf( "\n\nP Slices--------------------------------------------------------\n" ); |
---|
| 1297 | m_cAnalyzeP.printOut('p'); |
---|
| 1298 | |
---|
| 1299 | printf( "\n\nB Slices--------------------------------------------------------\n" ); |
---|
| 1300 | m_cAnalyzeB.printOut('b'); |
---|
| 1301 | |
---|
| 1302 | // m_cAnalyzeAll.printSummaryOut(); |
---|
| 1303 | // m_cAnalyzeI.printSummary('I'); |
---|
| 1304 | // m_cAnalyzeP.printSummary('P'); |
---|
| 1305 | // m_cAnalyzeB.printSummary('B'); |
---|
[2] | 1306 | } |
---|
[56] | 1307 | |
---|
| 1308 | //! \} |
---|