[313] | 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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 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 TComSlice.cpp |
---|
| 35 | \brief slice header and SPS class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "CommonDef.h" |
---|
| 39 | #include "TComSlice.h" |
---|
| 40 | #include "TComPic.h" |
---|
| 41 | #include "TLibEncoder/TEncSbac.h" |
---|
| 42 | #include "TLibDecoder/TDecSbac.h" |
---|
| 43 | |
---|
[1029] | 44 | |
---|
[313] | 45 | //! \ingroup TLibCommon |
---|
| 46 | //! \{ |
---|
| 47 | |
---|
| 48 | #if SVC_EXTENSION |
---|
[1029] | 49 | #include <numeric> |
---|
[442] | 50 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
[834] | 51 | ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS); |
---|
| 52 | ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS); |
---|
[1319] | 53 | Int ParameterSetManager::m_activeVPSId = -1; |
---|
[313] | 54 | #endif |
---|
| 55 | |
---|
| 56 | TComSlice::TComSlice() |
---|
| 57 | : m_iPPSId ( -1 ) |
---|
[1029] | 58 | , m_PicOutputFlag ( true ) |
---|
[313] | 59 | , m_iPOC ( 0 ) |
---|
| 60 | , m_iLastIDR ( 0 ) |
---|
[1029] | 61 | , m_iAssociatedIRAP ( 0 ) |
---|
| 62 | , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) |
---|
[1367] | 63 | , m_pRPS ( 0 ) |
---|
| 64 | , m_localRPS ( ) |
---|
| 65 | , m_rpsIdx ( 0 ) |
---|
[1029] | 66 | , m_RefPicListModification ( ) |
---|
[313] | 67 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
| 68 | , m_eSliceType ( I_SLICE ) |
---|
| 69 | , m_iSliceQp ( 0 ) |
---|
[1029] | 70 | , m_dependentSliceSegmentFlag ( false ) |
---|
[313] | 71 | #if ADAPTIVE_QP_SELECTION |
---|
| 72 | , m_iSliceQpBase ( 0 ) |
---|
| 73 | #endif |
---|
[1029] | 74 | , m_ChromaQpAdjEnabled ( false ) |
---|
| 75 | , m_deblockingFilterDisable ( false ) |
---|
| 76 | , m_deblockingFilterOverrideFlag ( false ) |
---|
| 77 | , m_deblockingFilterBetaOffsetDiv2( 0 ) |
---|
| 78 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
[313] | 79 | , m_bCheckLDC ( false ) |
---|
| 80 | , m_iSliceQpDelta ( 0 ) |
---|
| 81 | , m_iDepth ( 0 ) |
---|
| 82 | , m_bRefenced ( false ) |
---|
[1029] | 83 | , m_pcVPS ( NULL ) |
---|
[313] | 84 | , m_pcSPS ( NULL ) |
---|
| 85 | , m_pcPPS ( NULL ) |
---|
| 86 | , m_pcPic ( NULL ) |
---|
[1230] | 87 | , m_colFromL0Flag ( true ) |
---|
[713] | 88 | , m_noOutputPriorPicsFlag ( false ) |
---|
| 89 | , m_noRaslOutputFlag ( false ) |
---|
| 90 | , m_handleCraAsBlaFlag ( false ) |
---|
[313] | 91 | , m_colRefIdx ( 0 ) |
---|
[1029] | 92 | , m_maxNumMergeCand ( 0 ) |
---|
[313] | 93 | , m_uiTLayer ( 0 ) |
---|
| 94 | , m_bTLayerSwitchingFlag ( false ) |
---|
[1029] | 95 | , m_sliceMode ( NO_SLICES ) |
---|
| 96 | , m_sliceArgument ( 0 ) |
---|
| 97 | , m_sliceCurStartCtuTsAddr ( 0 ) |
---|
| 98 | , m_sliceCurEndCtuTsAddr ( 0 ) |
---|
| 99 | , m_sliceIdx ( 0 ) |
---|
| 100 | , m_sliceSegmentMode ( NO_SLICES ) |
---|
| 101 | , m_sliceSegmentArgument ( 0 ) |
---|
| 102 | , m_sliceSegmentCurStartCtuTsAddr ( 0 ) |
---|
| 103 | , m_sliceSegmentCurEndCtuTsAddr ( 0 ) |
---|
| 104 | , m_nextSlice ( false ) |
---|
| 105 | , m_nextSliceSegment ( false ) |
---|
| 106 | , m_sliceBits ( 0 ) |
---|
| 107 | , m_sliceSegmentBits ( 0 ) |
---|
[313] | 108 | , m_bFinalized ( false ) |
---|
[1235] | 109 | , m_bTestWeightPred ( false ) |
---|
| 110 | , m_bTestWeightBiPred ( false ) |
---|
[1029] | 111 | , m_substreamSizes ( ) |
---|
[313] | 112 | , m_cabacInitFlag ( false ) |
---|
| 113 | , m_bLMvdL1Zero ( false ) |
---|
| 114 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
[1029] | 115 | , m_LFCrossSliceBoundaryFlag ( false ) |
---|
[313] | 116 | , m_enableTMVPFlag ( true ) |
---|
[1235] | 117 | , m_encCABACTableIdx (I_SLICE) |
---|
[1029] | 118 | #if SVC_EXTENSION |
---|
[1092] | 119 | , m_firstSliceInPic ( false ) |
---|
[850] | 120 | , m_availableForTMVPRefFlag ( true ) |
---|
[1226] | 121 | , m_layerId ( 0 ) |
---|
[494] | 122 | , m_bMFMEnabledFlag ( false ) |
---|
| 123 | , m_bDiscardableFlag ( false ) |
---|
[540] | 124 | , m_bCrossLayerBLAFlag ( false ) |
---|
[644] | 125 | , m_pocResetIdc ( 0 ) |
---|
| 126 | , m_pocResetPeriodId ( 0 ) |
---|
| 127 | , m_fullPocResetFlag ( false ) |
---|
| 128 | , m_pocLsbVal ( 0 ) |
---|
| 129 | , m_pocMsbVal ( 0 ) |
---|
| 130 | , m_pocMsbValRequiredFlag ( false ) |
---|
[904] | 131 | , m_pocMsbValPresentFlag ( false ) |
---|
[903] | 132 | , m_pocMsbValNeeded ( false ) |
---|
[815] | 133 | , m_picOrderCntLsb (0) |
---|
[494] | 134 | #endif //SVC_EXTENSION |
---|
[313] | 135 | { |
---|
[1029] | 136 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 137 | { |
---|
| 138 | m_aiNumRefIdx[i] = 0; |
---|
| 139 | } |
---|
[313] | 140 | |
---|
| 141 | #if SVC_EXTENSION |
---|
| 142 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
| 143 | m_activeNumILRRefIdx = 0; |
---|
| 144 | m_interLayerPredEnabledFlag = 0; |
---|
| 145 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
[494] | 146 | #endif //SVC_EXTENSION |
---|
[313] | 147 | |
---|
[1029] | 148 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
[540] | 149 | { |
---|
[1029] | 150 | m_lambdas [component] = 0.0; |
---|
| 151 | m_iSliceChromaQpDelta[component] = 0; |
---|
[540] | 152 | } |
---|
[1029] | 153 | |
---|
| 154 | initEqualRef(); |
---|
| 155 | |
---|
[313] | 156 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
| 157 | { |
---|
| 158 | m_list1IdxToList0Idx[idx] = -1; |
---|
| 159 | } |
---|
[1029] | 160 | |
---|
[313] | 161 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
| 162 | { |
---|
[1029] | 163 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 164 | { |
---|
| 165 | m_apcRefPicList [i][iNumCount] = NULL; |
---|
| 166 | m_aiRefPOCList [i][iNumCount] = 0; |
---|
| 167 | } |
---|
[313] | 168 | } |
---|
[1029] | 169 | |
---|
[313] | 170 | resetWpScaling(); |
---|
| 171 | initWpAcDcParam(); |
---|
[1029] | 172 | |
---|
| 173 | for(Int ch=0; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 174 | { |
---|
| 175 | m_saoEnabledFlag[ch] = false; |
---|
| 176 | } |
---|
[313] | 177 | } |
---|
| 178 | |
---|
| 179 | TComSlice::~TComSlice() |
---|
| 180 | { |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | #if SVC_EXTENSION |
---|
| 185 | Void TComSlice::initSlice( UInt layerId ) |
---|
| 186 | #else |
---|
| 187 | Void TComSlice::initSlice() |
---|
| 188 | #endif |
---|
| 189 | { |
---|
| 190 | #if SVC_EXTENSION |
---|
[1235] | 191 | m_layerId = layerId; |
---|
[313] | 192 | m_activeNumILRRefIdx = 0; |
---|
| 193 | m_interLayerPredEnabledFlag = 0; |
---|
[1235] | 194 | m_picOrderCntLsb = 0; |
---|
| 195 | m_pocResetIdc = 0; |
---|
| 196 | m_pocResetPeriodId = 0; |
---|
| 197 | m_fullPocResetFlag = false; |
---|
| 198 | m_pocLsbVal = 0; |
---|
| 199 | m_pocMsbVal = 0; |
---|
| 200 | m_pocMsbValRequiredFlag = false; |
---|
| 201 | m_pocMsbValPresentFlag = false; |
---|
| 202 | m_pocMsbValNeeded = false; |
---|
| 203 | m_pocResetDeltaPoc = 0; |
---|
[442] | 204 | #endif |
---|
[1029] | 205 | |
---|
| 206 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 207 | { |
---|
| 208 | m_aiNumRefIdx[i] = 0; |
---|
| 209 | } |
---|
[1230] | 210 | m_colFromL0Flag = true; |
---|
[1029] | 211 | |
---|
[313] | 212 | m_colRefIdx = 0; |
---|
| 213 | initEqualRef(); |
---|
[1029] | 214 | |
---|
[313] | 215 | m_bCheckLDC = false; |
---|
| 216 | |
---|
[1246] | 217 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
| 218 | { |
---|
| 219 | m_iSliceChromaQpDelta[component] = 0; |
---|
| 220 | } |
---|
[1029] | 221 | |
---|
[313] | 222 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
| 223 | |
---|
| 224 | m_bFinalized=false; |
---|
| 225 | |
---|
[1029] | 226 | m_substreamSizes.clear(); |
---|
[313] | 227 | m_cabacInitFlag = false; |
---|
| 228 | m_enableTMVPFlag = true; |
---|
| 229 | } |
---|
| 230 | |
---|
[1235] | 231 | Bool TComSlice::getRapPicFlag() const |
---|
[313] | 232 | { |
---|
| 233 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 234 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 235 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 236 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 237 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 238 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
| 239 | } |
---|
[890] | 240 | |
---|
[873] | 241 | |
---|
[1029] | 242 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
[313] | 243 | { |
---|
| 244 | TComPic* pcPicExtract; |
---|
| 245 | TComPic* pcPicInsert; |
---|
[1029] | 246 | |
---|
[313] | 247 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 248 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 249 | TComList<TComPic*>::iterator iterPicInsert; |
---|
[1029] | 250 | |
---|
[313] | 251 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 252 | { |
---|
| 253 | iterPicExtract = rcListPic.begin(); |
---|
[1246] | 254 | for (Int j = 0; j < i; j++) |
---|
| 255 | { |
---|
| 256 | iterPicExtract++; |
---|
| 257 | } |
---|
[313] | 258 | pcPicExtract = *(iterPicExtract); |
---|
| 259 | pcPicExtract->setCurrSliceIdx(0); |
---|
[1029] | 260 | |
---|
[313] | 261 | iterPicInsert = rcListPic.begin(); |
---|
| 262 | while (iterPicInsert != iterPicExtract) |
---|
| 263 | { |
---|
| 264 | pcPicInsert = *(iterPicInsert); |
---|
| 265 | pcPicInsert->setCurrSliceIdx(0); |
---|
| 266 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
| 267 | { |
---|
| 268 | break; |
---|
| 269 | } |
---|
[1029] | 270 | |
---|
[313] | 271 | iterPicInsert++; |
---|
| 272 | } |
---|
[1029] | 273 | |
---|
[313] | 274 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
[1029] | 275 | |
---|
[313] | 276 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 277 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 278 | rcListPic.erase (iterPicExtract); |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | |
---|
[1029] | 282 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, Int poc) |
---|
[313] | 283 | { |
---|
[1029] | 284 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
[313] | 285 | TComPic* pcPic = *(iterPic); |
---|
| 286 | while ( iterPic != rcListPic.end() ) |
---|
| 287 | { |
---|
[1209] | 288 | #if SVC_EXTENSION |
---|
| 289 | if( pcPic->getPOC() == poc && pcPic->getSlice(0)->isReferenced() ) |
---|
[815] | 290 | #else |
---|
[313] | 291 | if(pcPic->getPOC() == poc) |
---|
[815] | 292 | #endif |
---|
[313] | 293 | { |
---|
| 294 | break; |
---|
| 295 | } |
---|
| 296 | iterPic++; |
---|
[540] | 297 | #if SVC_EXTENSION |
---|
| 298 | // return NULL, if picture with requested POC is not in the list, otherwise iterator goes outside of the list |
---|
| 299 | if( iterPic == rcListPic.end() ) |
---|
| 300 | { |
---|
| 301 | return NULL; |
---|
| 302 | } |
---|
| 303 | #endif |
---|
[313] | 304 | pcPic = *(iterPic); |
---|
| 305 | } |
---|
[1210] | 306 | #if SVC_EXTENSION |
---|
[442] | 307 | assert( pcPic->getSlice(0)->isReferenced() ); |
---|
| 308 | #endif |
---|
[313] | 309 | return pcPic; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
| 314 | { |
---|
[1029] | 315 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
[313] | 316 | TComPic* pcPic = *(iterPic); |
---|
| 317 | TComPic* pcStPic = pcPic; |
---|
[1029] | 318 | |
---|
[313] | 319 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
| 320 | if (!pocHasMsb) |
---|
| 321 | { |
---|
[442] | 322 | poc = poc & (pocCycle - 1); |
---|
[313] | 323 | } |
---|
[1029] | 324 | |
---|
[313] | 325 | while ( iterPic != rcListPic.end() ) |
---|
| 326 | { |
---|
| 327 | pcPic = *(iterPic); |
---|
| 328 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
| 329 | { |
---|
| 330 | Int picPoc = pcPic->getPOC(); |
---|
| 331 | if (!pocHasMsb) |
---|
| 332 | { |
---|
[442] | 333 | picPoc = picPoc & (pocCycle - 1); |
---|
[313] | 334 | } |
---|
[1246] | 335 | |
---|
[313] | 336 | if (poc == picPoc) |
---|
| 337 | { |
---|
[1029] | 338 | if(pcPic->getIsLongTerm()) |
---|
| 339 | { |
---|
| 340 | return pcPic; |
---|
| 341 | } |
---|
| 342 | else |
---|
| 343 | { |
---|
| 344 | pcStPic = pcPic; |
---|
| 345 | } |
---|
| 346 | break; |
---|
[313] | 347 | } |
---|
| 348 | } |
---|
| 349 | |
---|
| 350 | iterPic++; |
---|
| 351 | } |
---|
[1029] | 352 | |
---|
[313] | 353 | return pcStPic; |
---|
| 354 | } |
---|
| 355 | |
---|
[1029] | 356 | Void TComSlice::setRefPOCList () |
---|
[313] | 357 | { |
---|
[1029] | 358 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
[313] | 359 | { |
---|
| 360 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
| 361 | { |
---|
| 362 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
| 363 | } |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | Void TComSlice::setList1IdxToList0Idx() |
---|
| 369 | { |
---|
| 370 | Int idxL0, idxL1; |
---|
| 371 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
| 372 | { |
---|
| 373 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
| 374 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
| 375 | { |
---|
| 376 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
| 377 | { |
---|
| 378 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
| 379 | break; |
---|
| 380 | } |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | #if SVC_EXTENSION |
---|
| 386 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
| 387 | #else |
---|
| 388 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
| 389 | #endif |
---|
| 390 | { |
---|
[1414] | 391 | if ( m_eSliceType == I_SLICE) |
---|
[313] | 392 | { |
---|
[1414] | 393 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 394 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 395 | |
---|
| 396 | if (!checkNumPocTotalCurr) |
---|
[313] | 397 | { |
---|
| 398 | return; |
---|
| 399 | } |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | TComPic* pcRefPic= NULL; |
---|
[1029] | 403 | static const UInt MAX_NUM_NEGATIVE_PICTURES=16; |
---|
| 404 | TComPic* RefPicSetStCurr0[MAX_NUM_NEGATIVE_PICTURES]; |
---|
| 405 | TComPic* RefPicSetStCurr1[MAX_NUM_NEGATIVE_PICTURES]; |
---|
| 406 | TComPic* RefPicSetLtCurr[MAX_NUM_NEGATIVE_PICTURES]; |
---|
[1256] | 407 | UInt NumPicStCurr0 = 0; |
---|
| 408 | UInt NumPicStCurr1 = 0; |
---|
| 409 | UInt NumPicLtCurr = 0; |
---|
[313] | 410 | Int i; |
---|
| 411 | |
---|
[442] | 412 | #if SVC_EXTENSION |
---|
[1525] | 413 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) ) |
---|
[313] | 414 | { |
---|
| 415 | #endif |
---|
[1367] | 416 | for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++) |
---|
[313] | 417 | { |
---|
[1367] | 418 | if(m_pRPS->getUsed(i)) |
---|
[313] | 419 | { |
---|
[1367] | 420 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[313] | 421 | pcRefPic->setIsLongTerm(0); |
---|
| 422 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1256] | 423 | RefPicSetStCurr0[NumPicStCurr0] = pcRefPic; |
---|
| 424 | NumPicStCurr0++; |
---|
[1029] | 425 | pcRefPic->setCheckLTMSBPresent(false); |
---|
[313] | 426 | } |
---|
| 427 | } |
---|
[1029] | 428 | |
---|
[1367] | 429 | for(; i < m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures(); i++) |
---|
[313] | 430 | { |
---|
[1367] | 431 | if(m_pRPS->getUsed(i)) |
---|
[313] | 432 | { |
---|
[1367] | 433 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[313] | 434 | pcRefPic->setIsLongTerm(0); |
---|
| 435 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1256] | 436 | RefPicSetStCurr1[NumPicStCurr1] = pcRefPic; |
---|
| 437 | NumPicStCurr1++; |
---|
[1029] | 438 | pcRefPic->setCheckLTMSBPresent(false); |
---|
[313] | 439 | } |
---|
| 440 | } |
---|
[1029] | 441 | |
---|
[1367] | 442 | for(i = m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()+m_pRPS->getNumberOfLongtermPictures()-1; i > m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
[313] | 443 | { |
---|
[1367] | 444 | if(m_pRPS->getUsed(i)) |
---|
[313] | 445 | { |
---|
[1367] | 446 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[313] | 447 | pcRefPic->setIsLongTerm(1); |
---|
| 448 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1256] | 449 | RefPicSetLtCurr[NumPicLtCurr] = pcRefPic; |
---|
| 450 | NumPicLtCurr++; |
---|
[313] | 451 | } |
---|
[1029] | 452 | if(pcRefPic==NULL) |
---|
[313] | 453 | { |
---|
[1367] | 454 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[313] | 455 | } |
---|
[1367] | 456 | pcRefPic->setCheckLTMSBPresent(m_pRPS->getCheckLTMSBPresent(i)); |
---|
[313] | 457 | } |
---|
[442] | 458 | #if SVC_EXTENSION |
---|
[313] | 459 | } |
---|
| 460 | #endif |
---|
| 461 | |
---|
| 462 | // ref_pic_list_init |
---|
| 463 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
| 464 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
[442] | 465 | #if SVC_EXTENSION |
---|
[313] | 466 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
| 467 | { |
---|
[1196] | 468 | // max one resampling direct layer |
---|
[815] | 469 | if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) |
---|
[313] | 470 | { |
---|
| 471 | Int numResampler = 0; |
---|
[1197] | 472 | |
---|
| 473 | // motion resampling constraint |
---|
[442] | 474 | Int numMotionResamplers = 0; |
---|
| 475 | Int refResamplingLayer[MAX_LAYERS]; |
---|
| 476 | memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); |
---|
[313] | 477 | |
---|
| 478 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 479 | { |
---|
| 480 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
[713] | 481 | UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ); |
---|
[1122] | 482 | |
---|
[849] | 483 | const Window &scalEL = getPPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
[1147] | 484 | |
---|
[540] | 485 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
| 486 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
| 487 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
| 488 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
| 489 | ); |
---|
[1122] | 490 | |
---|
[1502] | 491 | Bool sameBitDepths = ( m_pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) == ilpPic[refLayerIdc]->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) ) && ( m_pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) == ilpPic[refLayerIdc]->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) ); |
---|
[713] | 492 | |
---|
[1197] | 493 | // motion resampling constraint |
---|
| 494 | // Allow maximum of one motion resampling process for direct reference layers, and use motion inter-layer prediction from the same layer as texture inter-layer prediction |
---|
[1431] | 495 | if( !( m_pcPic->getPosScalingFactor(refLayerIdc, 0) == POS_SCALING_FACTOR_1X && m_pcPic->getPosScalingFactor(refLayerIdc, 1) == POS_SCALING_FACTOR_1X ) || !scalingOffset || !sameBitDepths |
---|
[1212] | 496 | #if CGS_3D_ASYMLUT |
---|
[713] | 497 | || getPPS()->getCGSFlag() |
---|
| 498 | #endif |
---|
| 499 | ) // ratio 1x |
---|
[313] | 500 | { |
---|
[713] | 501 | UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, refLayerId ) + 1; |
---|
[442] | 502 | |
---|
| 503 | if( predType & 0x1 ) |
---|
| 504 | { |
---|
| 505 | numResampler++; |
---|
| 506 | refResamplingLayer[i] = refLayerIdc + 1; |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | if( predType & 0x2 ) |
---|
| 510 | { |
---|
| 511 | numMotionResamplers++; |
---|
| 512 | refResamplingLayer[i] -= refLayerIdc + 1; |
---|
| 513 | } |
---|
[313] | 514 | } |
---|
| 515 | } |
---|
[442] | 516 | |
---|
| 517 | // When both picture sample values and picture motion field resampling processes are invoked for decoding of a particular picture, they shall be applied to the same reference layer picture. |
---|
| 518 | if( m_activeNumILRRefIdx > 1 && numResampler > 0 ) |
---|
| 519 | { |
---|
| 520 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 521 | { |
---|
| 522 | assert( refResamplingLayer[i] >= 0 && "Motion and sample inter-layer prediction shall be from the same layer" ); |
---|
| 523 | } |
---|
| 524 | } |
---|
[313] | 525 | |
---|
[442] | 526 | // Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture. |
---|
[313] | 527 | assert(numResampler <= 1); |
---|
[442] | 528 | assert( numMotionResamplers <= 1 && "Up to 1 motion resampling is allowed" ); |
---|
[313] | 529 | } |
---|
| 530 | } |
---|
[1256] | 531 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr + m_activeNumILRRefIdx; |
---|
[494] | 532 | #else //SVC_EXTENSION |
---|
[1256] | 533 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr; |
---|
[494] | 534 | #endif //SVC_EXTENSION |
---|
[540] | 535 | |
---|
[313] | 536 | if (checkNumPocTotalCurr) |
---|
| 537 | { |
---|
| 538 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
[588] | 539 | #if SVC_EXTENSION // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
[713] | 540 | // - If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 541 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
[313] | 542 | if (getRapPicFlag() && getLayerId()==0) |
---|
| 543 | #else |
---|
[713] | 544 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 545 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
[313] | 546 | if (getRapPicFlag()) |
---|
| 547 | #endif |
---|
| 548 | { |
---|
[1256] | 549 | assert(numPicTotalCurr == 0); |
---|
[313] | 550 | } |
---|
| 551 | |
---|
| 552 | if (m_eSliceType == I_SLICE) |
---|
[588] | 553 | { |
---|
[313] | 554 | return; |
---|
| 555 | } |
---|
[588] | 556 | |
---|
[1256] | 557 | assert(numPicTotalCurr > 0); |
---|
[1258] | 558 | // general tier and level limit: |
---|
[1256] | 559 | assert(numPicTotalCurr <= 8); |
---|
[313] | 560 | } |
---|
| 561 | |
---|
[1029] | 562 | Int cIdx = 0; |
---|
[1256] | 563 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
[1029] | 564 | { |
---|
| 565 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
| 566 | } |
---|
| 567 | |
---|
[442] | 568 | #if SVC_EXTENSION |
---|
[1534] | 569 | #if VIEW_SCALABILITY |
---|
| 570 | std::vector<TComPic*> refPicSetInterLayer0; |
---|
| 571 | std::vector<TComPic*> refPicSetInterLayer1; |
---|
| 572 | const TComVPS* cVPS=getVPS(); |
---|
| 573 | |
---|
| 574 | Int viewIdCurrLayerId = cVPS->getViewIdVal(cVPS->getViewIndex(m_layerId) ); |
---|
| 575 | Int viewId0 = cVPS->getViewIdVal( 0 ); |
---|
| 576 | for( i=0; i< m_activeNumILRRefIdx ;i++) |
---|
| 577 | { |
---|
| 578 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 579 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx()); |
---|
| 580 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
| 581 | { |
---|
| 582 | Int viewIdRefPicLayerIdi = cVPS->getViewIdVal( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx() ); |
---|
| 583 | Bool refPicSet0Flag = |
---|
| 584 | ( ( viewIdCurrLayerId <= viewId0 && viewIdCurrLayerId <= viewIdRefPicLayerIdi ) || |
---|
| 585 | ( viewIdCurrLayerId >= viewId0 && viewIdCurrLayerId >= viewIdRefPicLayerIdi ) ); |
---|
| 586 | |
---|
| 587 | if ( refPicSet0Flag ) |
---|
| 588 | { |
---|
| 589 | refPicSetInterLayer0.push_back( ilpPic[refLayerIdc] ); |
---|
| 590 | } |
---|
| 591 | else |
---|
| 592 | { |
---|
| 593 | refPicSetInterLayer1.push_back( ilpPic[refLayerIdc] ); |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | } |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | |
---|
| 600 | if( m_layerId > 0 ) |
---|
| 601 | { |
---|
| 602 | for( i = 0; i < refPicSetInterLayer0.size() && cIdx < numPicTotalCurr; cIdx ++, i ++) |
---|
| 603 | { |
---|
| 604 | rpsCurrList0[cIdx] = refPicSetInterLayer0[i]; |
---|
| 605 | } |
---|
| 606 | } |
---|
| 607 | #else |
---|
[1195] | 608 | // initial reference picture list construction |
---|
[345] | 609 | if( m_layerId > 0 ) |
---|
[494] | 610 | { |
---|
[1522] | 611 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPicTotalCurr; cIdx++, i++ ) |
---|
[345] | 612 | { |
---|
| 613 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
[1522] | 614 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx()); |
---|
| 615 | |
---|
| 616 | // SHM: ILP is not valid due to temporal layer restriction, bitstream is not conformant |
---|
| 617 | assert( Int(ilpPic[refLayerIdc]->getSlice(0)->getTLayer()) < maxTidIlRefPicsPlus1 || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ); |
---|
| 618 | |
---|
| 619 | // SHM: Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
| 620 | assert( ilpPic[refLayerIdc]->getSlice(0)->getDiscardableFlag() == 0 ); |
---|
| 621 | |
---|
| 622 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
[345] | 623 | } |
---|
| 624 | } |
---|
[1534] | 625 | #endif |
---|
[494] | 626 | #endif //SVC_EXTENSION |
---|
[1195] | 627 | |
---|
[1256] | 628 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
[1246] | 629 | { |
---|
| 630 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
| 631 | } |
---|
[1256] | 632 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
[1246] | 633 | { |
---|
| 634 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
| 635 | } |
---|
[1534] | 636 | #if VIEW_SCALABILITY |
---|
| 637 | if( m_layerId > 0 ) |
---|
| 638 | { |
---|
| 639 | for( i = 0; i < refPicSetInterLayer1.size(); cIdx++, i++ ) |
---|
| 640 | { |
---|
| 641 | rpsCurrList0[cIdx] = refPicSetInterLayer1[i]; |
---|
| 642 | } |
---|
| 643 | } |
---|
| 644 | #else |
---|
[1256] | 645 | assert(cIdx == numPicTotalCurr); |
---|
[1534] | 646 | #endif |
---|
[313] | 647 | |
---|
| 648 | if (m_eSliceType==B_SLICE) |
---|
| 649 | { |
---|
| 650 | cIdx = 0; |
---|
[1256] | 651 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
[313] | 652 | { |
---|
| 653 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
| 654 | } |
---|
[1534] | 655 | #if VIEW_SCALABILITY |
---|
| 656 | if( m_layerId > 0 ) |
---|
| 657 | { |
---|
| 658 | for( i = 0; i < refPicSetInterLayer1.size(); cIdx ++, i ++) |
---|
| 659 | { |
---|
| 660 | rpsCurrList1[cIdx] = refPicSetInterLayer1[i]; |
---|
| 661 | } |
---|
| 662 | } |
---|
| 663 | #endif |
---|
[1256] | 664 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
[313] | 665 | { |
---|
| 666 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
| 667 | } |
---|
[1256] | 668 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
[313] | 669 | { |
---|
| 670 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
| 671 | } |
---|
| 672 | |
---|
[1534] | 673 | #if VIEW_SCALABILITY |
---|
| 674 | if( m_layerId > 0 ) |
---|
| 675 | { |
---|
| 676 | for( i = 0; i < refPicSetInterLayer0.size(); cIdx ++, i ++) |
---|
| 677 | { |
---|
| 678 | rpsCurrList1[cIdx] = refPicSetInterLayer0[i]; |
---|
| 679 | } |
---|
| 680 | } |
---|
| 681 | #else |
---|
[442] | 682 | #if SVC_EXTENSION |
---|
[313] | 683 | if( m_layerId > 0 ) |
---|
| 684 | { |
---|
[1522] | 685 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPicTotalCurr; cIdx++, i++ ) |
---|
[313] | 686 | { |
---|
| 687 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
[1522] | 688 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() ); |
---|
| 689 | |
---|
| 690 | // SHM: ILP is not valid due to temporal layer restriction, bitstream is not conformant |
---|
| 691 | assert( Int(ilpPic[refLayerIdc]->getSlice(0)->getTLayer()) < maxTidIlRefPicsPlus1 || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ); |
---|
| 692 | |
---|
| 693 | // SHM: Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
| 694 | assert( ilpPic[refLayerIdc]->getSlice(0)->getDiscardableFlag() == 0 ); |
---|
| 695 | |
---|
| 696 | rpsCurrList1[cIdx] = ilpPic[refLayerIdc]; |
---|
[313] | 697 | } |
---|
| 698 | } |
---|
[494] | 699 | #endif //SVC_EXTENSION |
---|
[1256] | 700 | assert(cIdx == numPicTotalCurr); |
---|
[1534] | 701 | #endif |
---|
[313] | 702 | } |
---|
| 703 | |
---|
| 704 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 705 | |
---|
[1029] | 706 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_0]; rIdx ++) |
---|
[313] | 707 | { |
---|
[1256] | 708 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPicTotalCurr; |
---|
| 709 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
[1029] | 710 | m_apcRefPicList[REF_PIC_LIST_0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
[1195] | 711 | |
---|
| 712 | #if SVC_EXTENSION |
---|
[1534] | 713 | #if VIEW_SCALABILITY |
---|
| 714 | m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = (cIdx<NumPicStCurr0 || (cIdx>=NumPicStCurr0+refPicSetInterLayer0.size() && cIdx<NumPicStCurr0+refPicSetInterLayer0.size()+NumPicStCurr1)) ? false : true; |
---|
| 715 | #else |
---|
[1256] | 716 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPicStCurr0 && cIdx < NumPicStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPicStCurr0 + NumPicStCurr1 + m_activeNumILRRefIdx ); |
---|
[1534] | 717 | #endif |
---|
[349] | 718 | #else |
---|
[1256] | 719 | m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
[349] | 720 | #endif |
---|
[313] | 721 | } |
---|
| 722 | if ( m_eSliceType != B_SLICE ) |
---|
| 723 | { |
---|
[1029] | 724 | m_aiNumRefIdx[REF_PIC_LIST_1] = 0; |
---|
| 725 | ::memset( m_apcRefPicList[REF_PIC_LIST_1], 0, sizeof(m_apcRefPicList[REF_PIC_LIST_1])); |
---|
[313] | 726 | } |
---|
| 727 | else |
---|
| 728 | { |
---|
[1029] | 729 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_1]; rIdx ++) |
---|
[313] | 730 | { |
---|
[1256] | 731 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPicTotalCurr; |
---|
| 732 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
[1029] | 733 | m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
[1534] | 734 | #if VIEW_SCALABILITY |
---|
| 735 | m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = (cIdx<NumPicStCurr1 || (cIdx>=NumPicStCurr1+refPicSetInterLayer1.size() && cIdx<NumPicStCurr1+refPicSetInterLayer1.size()+NumPicStCurr0)) ? false : true; |
---|
| 736 | #else |
---|
[1256] | 737 | m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
[1534] | 738 | #endif |
---|
[313] | 739 | } |
---|
| 740 | } |
---|
| 741 | } |
---|
| 742 | |
---|
[1235] | 743 | Int TComSlice::getNumRpsCurrTempList() const |
---|
[313] | 744 | { |
---|
| 745 | Int numRpsCurrTempList = 0; |
---|
| 746 | |
---|
[442] | 747 | #if SVC_EXTENSION |
---|
[644] | 748 | if( m_eSliceType == I_SLICE || ( m_layerId && |
---|
[313] | 749 | (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
| 750 | (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
| 751 | #else |
---|
[1029] | 752 | if (m_eSliceType == I_SLICE) |
---|
[313] | 753 | #endif |
---|
| 754 | { |
---|
[442] | 755 | #if SVC_EXTENSION |
---|
[313] | 756 | return m_activeNumILRRefIdx; |
---|
| 757 | #else |
---|
| 758 | return 0; |
---|
| 759 | #endif |
---|
| 760 | } |
---|
[1367] | 761 | for(UInt i=0; i < m_pRPS->getNumberOfNegativePictures()+ m_pRPS->getNumberOfPositivePictures() + m_pRPS->getNumberOfLongtermPictures(); i++) |
---|
[313] | 762 | { |
---|
[1367] | 763 | if(m_pRPS->getUsed(i)) |
---|
[313] | 764 | { |
---|
| 765 | numRpsCurrTempList++; |
---|
| 766 | } |
---|
| 767 | } |
---|
[442] | 768 | #if SVC_EXTENSION |
---|
[313] | 769 | if( m_layerId > 0 ) |
---|
| 770 | { |
---|
| 771 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
[644] | 772 | } |
---|
[313] | 773 | #endif |
---|
| 774 | |
---|
| 775 | return numRpsCurrTempList; |
---|
| 776 | } |
---|
| 777 | |
---|
[1534] | 778 | #if VIEW_SCALABILITY |
---|
| 779 | Int TComSlice::getNumRpsInterLayerX(Int li, TComPic** ilpPic) |
---|
| 780 | { |
---|
| 781 | assert(li==0 || li==1); |
---|
| 782 | |
---|
| 783 | Int viewIdCurrLayerId = m_pcVPS->getViewIdVal(m_pcVPS->getViewIndex(m_layerId) ); |
---|
| 784 | Int viewId0 = m_pcVPS->getViewIdVal( 0 ); |
---|
| 785 | Int numInterLayer0 = 0; |
---|
| 786 | Int numInterLayer1 = 0; |
---|
| 787 | |
---|
| 788 | for( Int i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 789 | { |
---|
| 790 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 791 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx()); |
---|
| 792 | |
---|
| 793 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
| 794 | { |
---|
| 795 | Int viewIdRefPicLayerIdi = m_pcVPS->getViewIdVal( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx() ); |
---|
| 796 | Bool refPicSet0Flag = ( ( viewIdCurrLayerId <= viewId0 && viewIdCurrLayerId <= viewIdRefPicLayerIdi ) || ( viewIdCurrLayerId >= viewId0 && viewIdCurrLayerId >= viewIdRefPicLayerIdi ) ); |
---|
| 797 | |
---|
| 798 | if( refPicSet0Flag ) |
---|
| 799 | { |
---|
| 800 | numInterLayer0++; |
---|
| 801 | } |
---|
| 802 | else |
---|
| 803 | { |
---|
| 804 | numInterLayer1++; |
---|
| 805 | } |
---|
| 806 | } |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | if( li==0 ) |
---|
| 810 | { |
---|
| 811 | return numInterLayer0; |
---|
| 812 | } |
---|
| 813 | else |
---|
| 814 | { |
---|
| 815 | return numInterLayer1; |
---|
| 816 | } |
---|
| 817 | } |
---|
| 818 | #endif |
---|
| 819 | |
---|
[313] | 820 | Void TComSlice::initEqualRef() |
---|
| 821 | { |
---|
[1029] | 822 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
[313] | 823 | { |
---|
| 824 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 825 | { |
---|
| 826 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 827 | { |
---|
| 828 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 835 | { |
---|
| 836 | Int i; |
---|
| 837 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
[1029] | 838 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1 - curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
[313] | 839 | TComSlice* preSlice; |
---|
| 840 | Int preColRefPOC; |
---|
| 841 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 842 | { |
---|
| 843 | preSlice = pic->getSlice(i); |
---|
| 844 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 845 | { |
---|
[1029] | 846 | preColRefPOC = preSlice->getRefPOC( RefPicList(1 - preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
[313] | 847 | if(currColRefPOC != preColRefPOC) |
---|
| 848 | { |
---|
| 849 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 850 | exit(EXIT_FAILURE); |
---|
| 851 | } |
---|
| 852 | else |
---|
| 853 | { |
---|
| 854 | break; |
---|
| 855 | } |
---|
| 856 | } |
---|
| 857 | } |
---|
| 858 | } |
---|
| 859 | |
---|
[1235] | 860 | Void TComSlice::checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
[313] | 861 | { |
---|
| 862 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 863 | { |
---|
| 864 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 865 | { |
---|
| 866 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 867 | } |
---|
| 868 | } |
---|
| 869 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 870 | { |
---|
| 871 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 872 | { |
---|
| 873 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 874 | { |
---|
| 875 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
| 876 | } |
---|
| 877 | else |
---|
| 878 | { |
---|
[1029] | 879 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 880 | } |
---|
[313] | 881 | } |
---|
| 882 | } |
---|
| 883 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
| 884 | { |
---|
| 885 | pocCRA = getPOC(); |
---|
[442] | 886 | associatedIRAPType = getNalUnitType(); |
---|
[313] | 887 | } |
---|
| 888 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 889 | { |
---|
| 890 | pocCRA = getPOC(); |
---|
[442] | 891 | associatedIRAPType = getNalUnitType(); |
---|
[313] | 892 | } |
---|
| 893 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 894 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 895 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 896 | { |
---|
| 897 | pocCRA = getPOC(); |
---|
[442] | 898 | associatedIRAPType = getNalUnitType(); |
---|
[313] | 899 | } |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 903 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
| 904 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 905 | * \param rcListPic reference to the reference picture list |
---|
| 906 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
[1029] | 907 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
[313] | 908 | * are marked as "unused for reference" |
---|
| 909 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 910 | * Otherwise |
---|
[1029] | 911 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
| 912 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 913 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
[313] | 914 | * the bRefreshPending flag to false. |
---|
[1029] | 915 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
[313] | 916 | * reference of the current picture. |
---|
| 917 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 918 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 919 | */ |
---|
[540] | 920 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[1005] | 921 | Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, UInt smallestLayerId ) |
---|
[713] | 922 | { |
---|
| 923 | if( !isIRAP() ) |
---|
| 924 | { |
---|
| 925 | return; |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | Int pocCurr = getPOC(); |
---|
| 929 | TComPic* rpcPic = NULL; |
---|
| 930 | |
---|
[1029] | 931 | // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1, |
---|
[713] | 932 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference". |
---|
[1005] | 933 | if (m_layerId == smallestLayerId && noClrasOutputFlag) |
---|
[713] | 934 | { |
---|
| 935 | // mark all pictures for all layers as not used for reference |
---|
| 936 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 937 | while( iterPic != rcListPic.end() ) |
---|
| 938 | { |
---|
| 939 | rpcPic = *(iterPic); |
---|
| 940 | if( rpcPic->getPOC() != pocCurr ) |
---|
| 941 | { |
---|
| 942 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 943 | } |
---|
| 944 | iterPic++; |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | |
---|
| 948 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
| 949 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the DPB (if any) are marked as "unused for reference". |
---|
| 950 | if( m_noRaslOutputFlag ) |
---|
| 951 | { |
---|
| 952 | // mark all pictures of a current layer as not used for reference |
---|
| 953 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 954 | while( iterPic != rcListPic.end() ) |
---|
| 955 | { |
---|
| 956 | rpcPic = *(iterPic); |
---|
| 957 | if( rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId ) |
---|
| 958 | { |
---|
| 959 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 960 | } |
---|
| 961 | iterPic++; |
---|
| 962 | } |
---|
| 963 | } |
---|
| 964 | } |
---|
| 965 | |
---|
[1325] | 966 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, const bool bEfficientFieldIRAPEnabled) |
---|
[540] | 967 | #else |
---|
[1325] | 968 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled) |
---|
[540] | 969 | #endif |
---|
[313] | 970 | { |
---|
[1029] | 971 | TComPic* rpcPic; |
---|
| 972 | Int pocCurr = getPOC(); |
---|
[313] | 973 | |
---|
| 974 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 975 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 976 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 977 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 978 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
| 979 | { |
---|
| 980 | // mark all pictures as not used for reference |
---|
| 981 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 982 | while (iterPic != rcListPic.end()) |
---|
| 983 | { |
---|
| 984 | rpcPic = *(iterPic); |
---|
| 985 | rpcPic->setCurrSliceIdx(0); |
---|
[540] | 986 | #if NO_CLRAS_OUTPUT_FLAG |
---|
[1209] | 987 | if( noClrasOutputFlag ) |
---|
[540] | 988 | { |
---|
[815] | 989 | rpcPic->getSlice(0)->setReferenced(false); // all layers // TODO. This does not mark all layers |
---|
| 990 | } |
---|
| 991 | else |
---|
| 992 | { |
---|
[1209] | 993 | if( rpcPic->getLayerId() == m_layerId ) |
---|
| 994 | { |
---|
| 995 | rpcPic->getSlice(0)->setReferenced(false); // only current layer |
---|
| 996 | } |
---|
[815] | 997 | } |
---|
| 998 | #else |
---|
[1246] | 999 | if (rpcPic->getPOC() != pocCurr) |
---|
| 1000 | { |
---|
| 1001 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 1002 | } |
---|
[540] | 1003 | #endif |
---|
[313] | 1004 | iterPic++; |
---|
| 1005 | } |
---|
[1209] | 1006 | |
---|
| 1007 | #if SVC_EXTENSION |
---|
| 1008 | m_pcPic->getSlice(0)->setReferenced(true); // Mark the current picture back as refererced. |
---|
[815] | 1009 | #endif |
---|
[1209] | 1010 | |
---|
[313] | 1011 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1012 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1013 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1014 | { |
---|
| 1015 | pocCRA = pocCurr; |
---|
| 1016 | } |
---|
[1325] | 1017 | if (bEfficientFieldIRAPEnabled) |
---|
| 1018 | { |
---|
| 1019 | bRefreshPending = true; |
---|
| 1020 | } |
---|
[313] | 1021 | } |
---|
| 1022 | else // CRA or No DR |
---|
| 1023 | { |
---|
[1325] | 1024 | if(bEfficientFieldIRAPEnabled && (getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
[713] | 1025 | { |
---|
| 1026 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
| 1027 | { |
---|
| 1028 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1029 | while (iterPic != rcListPic.end()) |
---|
| 1030 | { |
---|
| 1031 | rpcPic = *(iterPic); |
---|
| 1032 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
| 1033 | { |
---|
| 1034 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 1035 | } |
---|
| 1036 | iterPic++; |
---|
| 1037 | } |
---|
| 1038 | bRefreshPending = false; |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | else |
---|
| 1042 | { |
---|
[1029] | 1043 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
[313] | 1044 | { |
---|
[1029] | 1045 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1046 | while (iterPic != rcListPic.end()) |
---|
[313] | 1047 | { |
---|
[1029] | 1048 | rpcPic = *(iterPic); |
---|
| 1049 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
| 1050 | { |
---|
| 1051 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 1052 | } |
---|
| 1053 | iterPic++; |
---|
[313] | 1054 | } |
---|
[1029] | 1055 | bRefreshPending = false; |
---|
[313] | 1056 | } |
---|
[713] | 1057 | } |
---|
[313] | 1058 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 1059 | { |
---|
[1029] | 1060 | bRefreshPending = true; |
---|
[313] | 1061 | pocCRA = pocCurr; |
---|
| 1062 | } |
---|
| 1063 | } |
---|
| 1064 | } |
---|
| 1065 | |
---|
| 1066 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 1067 | { |
---|
| 1068 | assert( pSrc != NULL ); |
---|
| 1069 | |
---|
| 1070 | Int i, j, k; |
---|
| 1071 | |
---|
| 1072 | m_iPOC = pSrc->m_iPOC; |
---|
| 1073 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
| 1074 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 1075 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
| 1076 | #if ADAPTIVE_QP_SELECTION |
---|
| 1077 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 1078 | #endif |
---|
[1029] | 1079 | m_ChromaQpAdjEnabled = pSrc->m_ChromaQpAdjEnabled; |
---|
[313] | 1080 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 1081 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 1082 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 1083 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
[1029] | 1084 | |
---|
| 1085 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
[313] | 1086 | { |
---|
| 1087 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 1088 | } |
---|
| 1089 | |
---|
| 1090 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
| 1091 | { |
---|
| 1092 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
[1029] | 1093 | } |
---|
| 1094 | |
---|
[313] | 1095 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 1096 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
[1246] | 1097 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
| 1098 | { |
---|
| 1099 | m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component]; |
---|
| 1100 | } |
---|
[1029] | 1101 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
[313] | 1102 | { |
---|
| 1103 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 1104 | { |
---|
| 1105 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 1106 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
| 1107 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
| 1108 | } |
---|
[1029] | 1109 | m_bIsUsedAsLongTerm[i][MAX_NUM_REF] = pSrc->m_bIsUsedAsLongTerm[i][MAX_NUM_REF]; |
---|
[313] | 1110 | } |
---|
| 1111 | m_iDepth = pSrc->m_iDepth; |
---|
| 1112 | |
---|
| 1113 | // referenced slice |
---|
| 1114 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 1115 | |
---|
| 1116 | // access channel |
---|
| 1117 | #if SVC_EXTENSION |
---|
[1235] | 1118 | m_pcVPS = pSrc->m_pcVPS; |
---|
| 1119 | m_layerId = pSrc->m_layerId; |
---|
[1525] | 1120 | |
---|
| 1121 | // SHM: copy inter-layer prediction settings and list modification information from the previous slice. Actually, it can vary on a slice basis, but it is not supported by the current encoder. |
---|
[313] | 1122 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
| 1123 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
| 1124 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
[1525] | 1125 | m_RefPicListModification = pSrc->m_RefPicListModification; |
---|
[313] | 1126 | #endif |
---|
[1367] | 1127 | m_pRPS = pSrc->m_pRPS; |
---|
[313] | 1128 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 1129 | |
---|
| 1130 | m_pcPic = pSrc->m_pcPic; |
---|
| 1131 | |
---|
| 1132 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
| 1133 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
[1029] | 1134 | |
---|
[540] | 1135 | setLambdas(pSrc->getLambdas()); |
---|
[1029] | 1136 | |
---|
| 1137 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
[313] | 1138 | { |
---|
| 1139 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 1140 | { |
---|
| 1141 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 1142 | { |
---|
| 1143 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 1144 | } |
---|
| 1145 | } |
---|
| 1146 | } |
---|
| 1147 | |
---|
| 1148 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 1149 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 1150 | |
---|
[1029] | 1151 | m_sliceMode = pSrc->m_sliceMode; |
---|
| 1152 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
| 1153 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
| 1154 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
| 1155 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
| 1156 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
| 1157 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
| 1158 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
| 1159 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
| 1160 | m_nextSlice = pSrc->m_nextSlice; |
---|
| 1161 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
| 1162 | |
---|
| 1163 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[313] | 1164 | { |
---|
[1029] | 1165 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
[313] | 1166 | { |
---|
[1029] | 1167 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
[313] | 1168 | } |
---|
| 1169 | } |
---|
[1029] | 1170 | |
---|
| 1171 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 1172 | { |
---|
| 1173 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
| 1174 | } |
---|
| 1175 | |
---|
[1235] | 1176 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
[313] | 1177 | |
---|
[1235] | 1178 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 1179 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
[313] | 1180 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 1181 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
[1235] | 1182 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
[313] | 1183 | } |
---|
| 1184 | |
---|
[1029] | 1185 | |
---|
[313] | 1186 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 1187 | * \param uiTLayer Temporal layer ID of the current slice |
---|
[1029] | 1188 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 1189 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
[313] | 1190 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 1191 | */ |
---|
| 1192 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
| 1193 | { |
---|
| 1194 | m_uiTLayer = uiTLayer; |
---|
| 1195 | } |
---|
| 1196 | |
---|
| 1197 | /** Function for checking if this is a switching-point |
---|
| 1198 | */ |
---|
[1029] | 1199 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
[313] | 1200 | { |
---|
| 1201 | TComPic* rpcPic; |
---|
| 1202 | // loop through all pictures in the reference picture buffer |
---|
| 1203 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1204 | while ( iterPic != rcListPic.end()) |
---|
| 1205 | { |
---|
| 1206 | rpcPic = *(iterPic++); |
---|
| 1207 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 1208 | { |
---|
| 1209 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1210 | { |
---|
| 1211 | return false; |
---|
| 1212 | } |
---|
| 1213 | } |
---|
| 1214 | } |
---|
| 1215 | return true; |
---|
| 1216 | } |
---|
| 1217 | |
---|
[1029] | 1218 | /** Function for checking if this is a STSA candidate |
---|
[313] | 1219 | */ |
---|
[1029] | 1220 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
[313] | 1221 | { |
---|
[1029] | 1222 | TComPic* rpcPic; |
---|
| 1223 | |
---|
| 1224 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1225 | while ( iterPic != rcListPic.end()) |
---|
| 1226 | { |
---|
| 1227 | rpcPic = *(iterPic++); |
---|
| 1228 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
[313] | 1229 | { |
---|
[1029] | 1230 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1231 | { |
---|
| 1232 | return false; |
---|
| 1233 | } |
---|
[313] | 1234 | } |
---|
[1029] | 1235 | } |
---|
| 1236 | return true; |
---|
[313] | 1237 | } |
---|
| 1238 | |
---|
[1209] | 1239 | #if SVC_POC |
---|
[815] | 1240 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset) |
---|
| 1241 | #else |
---|
[442] | 1242 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
[815] | 1243 | #endif |
---|
[442] | 1244 | { |
---|
| 1245 | TComPic* rpcPic; |
---|
| 1246 | |
---|
| 1247 | Int nalUnitType = this->getNalUnitType(); |
---|
| 1248 | |
---|
| 1249 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
| 1250 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
| 1251 | { |
---|
| 1252 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
| 1253 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1254 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
| 1255 | { |
---|
| 1256 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1257 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1258 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1259 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1260 | } |
---|
| 1261 | } |
---|
| 1262 | |
---|
| 1263 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
| 1264 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
| 1265 | { |
---|
| 1266 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
| 1267 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
| 1268 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
| 1269 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | // No RASL pictures shall be present in the bitstream that are associated |
---|
| 1273 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
| 1274 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1275 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1276 | { |
---|
| 1277 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
| 1278 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
| 1279 | } |
---|
| 1280 | |
---|
| 1281 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
| 1282 | // an IDR picture. |
---|
| 1283 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1284 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1285 | { |
---|
| 1286 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
| 1287 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
| 1288 | } |
---|
| 1289 | |
---|
| 1290 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
| 1291 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
| 1292 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
| 1293 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1294 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1295 | { |
---|
| 1296 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
| 1297 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
| 1298 | } |
---|
| 1299 | |
---|
| 1300 | // loop through all pictures in the reference picture buffer |
---|
| 1301 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1302 | while ( iterPic != rcListPic.end()) |
---|
| 1303 | { |
---|
| 1304 | rpcPic = *(iterPic++); |
---|
[595] | 1305 | if(!rpcPic->getReconMark()) |
---|
| 1306 | { |
---|
| 1307 | continue; |
---|
| 1308 | } |
---|
[442] | 1309 | if (rpcPic->getPOC() == this->getPOC()) |
---|
| 1310 | { |
---|
| 1311 | continue; |
---|
| 1312 | } |
---|
| 1313 | |
---|
| 1314 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1315 | // in decoding order shall precede the IRAP picture in output order. |
---|
| 1316 | // (Note that any picture following in output order would be present in the DPB) |
---|
[713] | 1317 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
[442] | 1318 | { |
---|
| 1319 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1320 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1321 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1322 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
| 1323 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1324 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
| 1325 | { |
---|
[1209] | 1326 | #if SVC_POC |
---|
[815] | 1327 | if( usePocBeforeReset ) |
---|
| 1328 | { |
---|
| 1329 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
| 1330 | } |
---|
| 1331 | else |
---|
| 1332 | { |
---|
| 1333 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1334 | } |
---|
| 1335 | #else |
---|
[442] | 1336 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
[815] | 1337 | #endif |
---|
[442] | 1338 | } |
---|
| 1339 | } |
---|
| 1340 | |
---|
| 1341 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1342 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
| 1343 | // picture in output order. |
---|
| 1344 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
| 1345 | { |
---|
| 1346 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1347 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
| 1348 | { |
---|
| 1349 | // rpcPic precedes the IRAP in decoding order |
---|
| 1350 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1351 | { |
---|
| 1352 | // rpcPic must not be the IRAP picture |
---|
| 1353 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
| 1354 | { |
---|
[1209] | 1355 | #if SVC_POC |
---|
[815] | 1356 | if( usePocBeforeReset ) |
---|
| 1357 | { |
---|
| 1358 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
| 1359 | } |
---|
| 1360 | else |
---|
| 1361 | { |
---|
| 1362 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1363 | } |
---|
| 1364 | #else |
---|
[442] | 1365 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
[815] | 1366 | #endif |
---|
[442] | 1367 | } |
---|
| 1368 | } |
---|
| 1369 | } |
---|
| 1370 | } |
---|
| 1371 | |
---|
| 1372 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
| 1373 | // all trailing pictures that are associated with the same IRAP picture. |
---|
[1029] | 1374 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1375 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1376 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1377 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
[442] | 1378 | { |
---|
[1029] | 1379 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
| 1380 | { |
---|
| 1381 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
| 1382 | // rpcPic would violate the constraint if it was a trailing picture |
---|
[1209] | 1383 | #if SVC_POC |
---|
[1029] | 1384 | if( usePocBeforeReset ) |
---|
| 1385 | { |
---|
| 1386 | assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset()); |
---|
| 1387 | } |
---|
| 1388 | else |
---|
| 1389 | { |
---|
| 1390 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
| 1391 | } |
---|
| 1392 | #else |
---|
[815] | 1393 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
[1029] | 1394 | #endif |
---|
[815] | 1395 | } |
---|
[442] | 1396 | } |
---|
| 1397 | |
---|
| 1398 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
| 1399 | // RADL picture associated with the CRA or BLA picture in output order |
---|
| 1400 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1401 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
[1029] | 1402 | { |
---|
[442] | 1403 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1404 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1405 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1406 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
| 1407 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1408 | { |
---|
| 1409 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1410 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1411 | { |
---|
| 1412 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
| 1413 | } |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | |
---|
| 1417 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
| 1418 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
| 1419 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1420 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1421 | { |
---|
| 1422 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 1423 | { |
---|
| 1424 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
| 1425 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1426 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1427 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1428 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1429 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
| 1430 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
| 1431 | { |
---|
| 1432 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
| 1433 | } |
---|
| 1434 | } |
---|
| 1435 | } |
---|
| 1436 | } |
---|
| 1437 | } |
---|
| 1438 | |
---|
[595] | 1439 | |
---|
| 1440 | |
---|
[313] | 1441 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1442 | */ |
---|
[1235] | 1443 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
[313] | 1444 | { |
---|
| 1445 | TComPic* rpcPic; |
---|
| 1446 | Int i, isReference; |
---|
| 1447 | |
---|
[644] | 1448 | #if !ALIGNED_BUMPING |
---|
[442] | 1449 | checkLeadingPictureRestrictions(rcListPic); |
---|
[644] | 1450 | #endif |
---|
[442] | 1451 | |
---|
[313] | 1452 | // loop through all pictures in the reference picture buffer |
---|
| 1453 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1454 | while ( iterPic != rcListPic.end()) |
---|
| 1455 | { |
---|
| 1456 | rpcPic = *(iterPic++); |
---|
| 1457 | |
---|
| 1458 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
| 1459 | { |
---|
| 1460 | continue; |
---|
| 1461 | } |
---|
| 1462 | |
---|
| 1463 | isReference = 0; |
---|
| 1464 | // loop through all pictures in the Reference Picture Set |
---|
| 1465 | // to see if the picture should be kept as reference picture |
---|
| 1466 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1467 | { |
---|
| 1468 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1469 | { |
---|
| 1470 | isReference = 1; |
---|
| 1471 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1472 | rpcPic->setIsLongTerm(0); |
---|
| 1473 | } |
---|
| 1474 | } |
---|
| 1475 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1476 | { |
---|
| 1477 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1478 | { |
---|
| 1479 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1480 | { |
---|
| 1481 | isReference = 1; |
---|
| 1482 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1483 | } |
---|
| 1484 | } |
---|
[1256] | 1485 | else |
---|
[313] | 1486 | { |
---|
[442] | 1487 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1488 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1489 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1490 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
[313] | 1491 | { |
---|
| 1492 | isReference = 1; |
---|
| 1493 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1494 | } |
---|
| 1495 | } |
---|
| 1496 | |
---|
| 1497 | } |
---|
[1222] | 1498 | |
---|
| 1499 | #if SVC_EXTENSION |
---|
[588] | 1500 | if( isReference ) // Current picture is in the temporal RPS |
---|
| 1501 | { |
---|
| 1502 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
| 1503 | } |
---|
| 1504 | #endif |
---|
[1222] | 1505 | |
---|
[313] | 1506 | // mark the picture as "unused for reference" if it is not in |
---|
| 1507 | // the Reference Picture Set |
---|
[1029] | 1508 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1509 | { |
---|
| 1510 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
[313] | 1511 | rpcPic->setUsedByCurr(0); |
---|
| 1512 | rpcPic->setIsLongTerm(0); |
---|
| 1513 | } |
---|
| 1514 | //check that pictures of higher temporal layers are not used |
---|
| 1515 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1516 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
[540] | 1517 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
[313] | 1518 | { |
---|
| 1519 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1520 | } |
---|
| 1521 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1522 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1523 | { |
---|
| 1524 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1525 | } |
---|
| 1526 | } |
---|
| 1527 | } |
---|
| 1528 | |
---|
| 1529 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1530 | */ |
---|
[1235] | 1531 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
[313] | 1532 | { |
---|
[713] | 1533 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
| 1534 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
[313] | 1535 | TComPic* rpcPic; |
---|
| 1536 | Int i, isAvailable; |
---|
| 1537 | Int atLeastOneLost = 0; |
---|
| 1538 | Int atLeastOneRemoved = 0; |
---|
| 1539 | Int iPocLost = 0; |
---|
| 1540 | |
---|
| 1541 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1542 | // to see if the picture should be kept as reference picture |
---|
| 1543 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1544 | { |
---|
| 1545 | isAvailable = 0; |
---|
| 1546 | // loop through all pictures in the reference picture buffer |
---|
| 1547 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1548 | while ( iterPic != rcListPic.end()) |
---|
| 1549 | { |
---|
| 1550 | rpcPic = *(iterPic++); |
---|
| 1551 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1552 | { |
---|
| 1553 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1554 | { |
---|
[713] | 1555 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1556 | { |
---|
| 1557 | isAvailable = 0; |
---|
| 1558 | } |
---|
| 1559 | else |
---|
| 1560 | { |
---|
[1029] | 1561 | isAvailable = 1; |
---|
| 1562 | } |
---|
[713] | 1563 | } |
---|
[313] | 1564 | } |
---|
[1029] | 1565 | else |
---|
[313] | 1566 | { |
---|
[442] | 1567 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1568 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1569 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1570 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
[313] | 1571 | { |
---|
[713] | 1572 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1573 | { |
---|
| 1574 | isAvailable = 0; |
---|
| 1575 | } |
---|
| 1576 | else |
---|
| 1577 | { |
---|
[1029] | 1578 | isAvailable = 1; |
---|
| 1579 | } |
---|
[713] | 1580 | } |
---|
[313] | 1581 | } |
---|
| 1582 | } |
---|
| 1583 | // if there was no such long-term check the short terms |
---|
| 1584 | if(!isAvailable) |
---|
| 1585 | { |
---|
| 1586 | iterPic = rcListPic.begin(); |
---|
| 1587 | while ( iterPic != rcListPic.end()) |
---|
| 1588 | { |
---|
| 1589 | rpcPic = *(iterPic++); |
---|
| 1590 | |
---|
| 1591 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1592 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
| 1593 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
| 1594 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 1595 | { |
---|
[442] | 1596 | curPoc = curPoc & (pocCycle - 1); |
---|
| 1597 | refPoc = refPoc & (pocCycle - 1); |
---|
[313] | 1598 | } |
---|
[1029] | 1599 | |
---|
[313] | 1600 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
| 1601 | { |
---|
[713] | 1602 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1603 | { |
---|
| 1604 | isAvailable = 0; |
---|
| 1605 | } |
---|
| 1606 | else |
---|
| 1607 | { |
---|
[1029] | 1608 | isAvailable = 1; |
---|
| 1609 | rpcPic->setIsLongTerm(1); |
---|
| 1610 | break; |
---|
| 1611 | } |
---|
[713] | 1612 | } |
---|
[313] | 1613 | } |
---|
| 1614 | } |
---|
| 1615 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1616 | // but not available as reference picture |
---|
[1029] | 1617 | if(isAvailable == 0) |
---|
| 1618 | { |
---|
[313] | 1619 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1620 | { |
---|
| 1621 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1622 | { |
---|
| 1623 | if(printErrors) |
---|
| 1624 | { |
---|
| 1625 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1626 | } |
---|
| 1627 | atLeastOneRemoved = 1; |
---|
| 1628 | } |
---|
| 1629 | else |
---|
| 1630 | { |
---|
| 1631 | if(printErrors) |
---|
| 1632 | { |
---|
| 1633 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1634 | } |
---|
| 1635 | atLeastOneLost = 1; |
---|
| 1636 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1637 | } |
---|
| 1638 | } |
---|
[713] | 1639 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
| 1640 | { |
---|
| 1641 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
| 1642 | } |
---|
| 1643 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
| 1644 | { |
---|
| 1645 | atLeastOneFlushedByPreviousIDR = 1; |
---|
| 1646 | } |
---|
[313] | 1647 | } |
---|
[1029] | 1648 | } |
---|
[313] | 1649 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1650 | // to see if the picture should be kept as reference picture |
---|
| 1651 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1652 | { |
---|
| 1653 | isAvailable = 0; |
---|
| 1654 | // loop through all pictures in the reference picture buffer |
---|
| 1655 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1656 | while ( iterPic != rcListPic.end()) |
---|
| 1657 | { |
---|
| 1658 | rpcPic = *(iterPic++); |
---|
| 1659 | |
---|
| 1660 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1661 | { |
---|
[713] | 1662 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1663 | { |
---|
| 1664 | isAvailable = 0; |
---|
| 1665 | } |
---|
| 1666 | else |
---|
| 1667 | { |
---|
[1029] | 1668 | isAvailable = 1; |
---|
| 1669 | } |
---|
[713] | 1670 | } |
---|
[313] | 1671 | } |
---|
| 1672 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1673 | // but not available as reference picture |
---|
[1029] | 1674 | if(isAvailable == 0) |
---|
| 1675 | { |
---|
[815] | 1676 | #if !UNAVAILABLE_PIC_BUGFIX |
---|
[313] | 1677 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
[815] | 1678 | #endif |
---|
[313] | 1679 | { |
---|
| 1680 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1681 | { |
---|
| 1682 | if(printErrors) |
---|
| 1683 | { |
---|
| 1684 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1685 | } |
---|
| 1686 | atLeastOneRemoved = 1; |
---|
| 1687 | } |
---|
| 1688 | else |
---|
| 1689 | { |
---|
| 1690 | if(printErrors) |
---|
| 1691 | { |
---|
| 1692 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1693 | } |
---|
| 1694 | atLeastOneLost = 1; |
---|
| 1695 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1696 | } |
---|
| 1697 | } |
---|
[815] | 1698 | #if UNAVAILABLE_PIC_BUGFIX |
---|
| 1699 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
| 1700 | #else |
---|
[713] | 1701 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
[815] | 1702 | #endif |
---|
[713] | 1703 | { |
---|
| 1704 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
| 1705 | } |
---|
| 1706 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
| 1707 | { |
---|
| 1708 | atLeastOneFlushedByPreviousIDR = 1; |
---|
| 1709 | } |
---|
[313] | 1710 | } |
---|
[1029] | 1711 | } |
---|
| 1712 | |
---|
[713] | 1713 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
| 1714 | { |
---|
| 1715 | return -1; |
---|
[313] | 1716 | } |
---|
| 1717 | if(atLeastOneLost) |
---|
| 1718 | { |
---|
| 1719 | return iPocLost+1; |
---|
| 1720 | } |
---|
| 1721 | if(atLeastOneRemoved) |
---|
| 1722 | { |
---|
| 1723 | return -2; |
---|
| 1724 | } |
---|
| 1725 | else |
---|
| 1726 | { |
---|
| 1727 | return 0; |
---|
| 1728 | } |
---|
| 1729 | } |
---|
| 1730 | |
---|
| 1731 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1732 | */ |
---|
[1325] | 1733 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled) |
---|
[313] | 1734 | { |
---|
| 1735 | TComPic* rpcPic; |
---|
| 1736 | Int i, j; |
---|
| 1737 | Int k = 0; |
---|
| 1738 | Int nrOfNegativePictures = 0; |
---|
| 1739 | Int nrOfPositivePictures = 0; |
---|
[1367] | 1740 | TComReferencePictureSet* pLocalRPS = this->getLocalRPS(); |
---|
| 1741 | (*pLocalRPS)=TComReferencePictureSet(); |
---|
[1365] | 1742 | |
---|
[1325] | 1743 | Bool irapIsInRPS = false; // Used when bEfficientFieldIRAPEnabled==true |
---|
[1199] | 1744 | #if SVC_POC |
---|
[903] | 1745 | Bool pocsAdjusted = false; |
---|
| 1746 | #endif |
---|
[313] | 1747 | |
---|
| 1748 | // loop through all pictures in the Reference Picture Set |
---|
| 1749 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1750 | { |
---|
| 1751 | j = 0; |
---|
| 1752 | // loop through all pictures in the reference picture buffer |
---|
| 1753 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1754 | while ( iterPic != rcListPic.end()) |
---|
| 1755 | { |
---|
| 1756 | j++; |
---|
| 1757 | rpcPic = *(iterPic++); |
---|
| 1758 | |
---|
[1199] | 1759 | #if SVC_POC |
---|
[903] | 1760 | // poc adjustement by poc reset needs to be taken into account here |
---|
| 1761 | Int deltaPOC = pReferencePictureSet->getDeltaPOC(i) - rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc(); |
---|
| 1762 | if (rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc() != 0) |
---|
| 1763 | { |
---|
| 1764 | pocsAdjusted = true; |
---|
| 1765 | } |
---|
| 1766 | |
---|
| 1767 | if (rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + deltaPOC && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1768 | #else |
---|
[313] | 1769 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
[903] | 1770 | #endif |
---|
[313] | 1771 | { |
---|
| 1772 | // This picture exists as a reference picture |
---|
| 1773 | // and should be added to the explicit Reference Picture Set |
---|
[1199] | 1774 | #if SVC_POC |
---|
[1367] | 1775 | pLocalRPS->setDeltaPOC(k, deltaPOC); |
---|
[903] | 1776 | #else |
---|
[1367] | 1777 | pLocalRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
[903] | 1778 | #endif |
---|
[1367] | 1779 | pLocalRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
[1325] | 1780 | if (bEfficientFieldIRAPEnabled) |
---|
| 1781 | { |
---|
[1199] | 1782 | #if SVC_POC |
---|
[1367] | 1783 | pLocalRPS->setUsed(k, pLocalRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + deltaPOC < pocRandomAccess) ); |
---|
[903] | 1784 | #else |
---|
[1367] | 1785 | pLocalRPS->setUsed(k, pLocalRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
[713] | 1786 | #endif |
---|
[1325] | 1787 | } |
---|
| 1788 | |
---|
[1367] | 1789 | if(pLocalRPS->getDeltaPOC(k) < 0) |
---|
[313] | 1790 | { |
---|
| 1791 | nrOfNegativePictures++; |
---|
| 1792 | } |
---|
| 1793 | else |
---|
| 1794 | { |
---|
[1325] | 1795 | if(bEfficientFieldIRAPEnabled && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
[1029] | 1796 | { |
---|
| 1797 | irapIsInRPS = true; |
---|
| 1798 | } |
---|
[313] | 1799 | nrOfPositivePictures++; |
---|
| 1800 | } |
---|
| 1801 | k++; |
---|
| 1802 | } |
---|
| 1803 | } |
---|
| 1804 | } |
---|
[1029] | 1805 | |
---|
[713] | 1806 | Bool useNewRPS = false; |
---|
| 1807 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
[1325] | 1808 | if(bEfficientFieldIRAPEnabled && m_pcPic->isField() && !irapIsInRPS) |
---|
[713] | 1809 | { |
---|
| 1810 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1811 | while ( iterPic != rcListPic.end()) |
---|
| 1812 | { |
---|
| 1813 | rpcPic = *(iterPic++); |
---|
| 1814 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
| 1815 | { |
---|
[1367] | 1816 | pLocalRPS->setDeltaPOC(k, 1); |
---|
| 1817 | pLocalRPS->setUsed(k, true); |
---|
[713] | 1818 | nrOfPositivePictures++; |
---|
| 1819 | k ++; |
---|
| 1820 | useNewRPS = true; |
---|
| 1821 | } |
---|
| 1822 | } |
---|
| 1823 | } |
---|
[1367] | 1824 | pLocalRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1825 | pLocalRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1826 | pLocalRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
[1029] | 1827 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
[313] | 1828 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1829 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
[1325] | 1830 | if (!pReferencePictureSet->getInterRPSPrediction() || useNewRPS |
---|
[1199] | 1831 | #if SVC_POC |
---|
[903] | 1832 | || pocsAdjusted // inter RPS prediction does not work if POCs have been adjusted |
---|
| 1833 | #endif |
---|
[713] | 1834 | ) |
---|
[313] | 1835 | { |
---|
[1367] | 1836 | pLocalRPS->setInterRPSPrediction(false); |
---|
| 1837 | pLocalRPS->setNumRefIdc(0); |
---|
[313] | 1838 | } |
---|
| 1839 | else |
---|
| 1840 | { |
---|
| 1841 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1842 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
[1235] | 1843 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
[313] | 1844 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1845 | Int iNewIdc=0; |
---|
[1029] | 1846 | for(i=0; i<= iRefPics; i++) |
---|
[313] | 1847 | { |
---|
| 1848 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1849 | Int iRefIdc = 0; |
---|
[1367] | 1850 | for (j=0; j < pLocalRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
[313] | 1851 | { |
---|
[1367] | 1852 | if ( (deltaPOC + deltaRPS) == pLocalRPS->getDeltaPOC(j)) |
---|
[313] | 1853 | { |
---|
[1367] | 1854 | if (pLocalRPS->getUsed(j)) |
---|
[313] | 1855 | { |
---|
| 1856 | iRefIdc = 1; |
---|
| 1857 | } |
---|
| 1858 | else |
---|
| 1859 | { |
---|
| 1860 | iRefIdc = 2; |
---|
| 1861 | } |
---|
| 1862 | } |
---|
| 1863 | } |
---|
[1367] | 1864 | pLocalRPS->setRefIdc(i, iRefIdc); |
---|
[313] | 1865 | iNewIdc++; |
---|
| 1866 | } |
---|
[1367] | 1867 | pLocalRPS->setInterRPSPrediction(true); |
---|
| 1868 | pLocalRPS->setNumRefIdc(iNewIdc); |
---|
| 1869 | pLocalRPS->setDeltaRPS(deltaRPS); |
---|
| 1870 | pLocalRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
[313] | 1871 | } |
---|
| 1872 | |
---|
[1367] | 1873 | this->setRPS(pLocalRPS); |
---|
[313] | 1874 | this->setRPSidx(-1); |
---|
| 1875 | } |
---|
| 1876 | |
---|
[1316] | 1877 | //! get AC and DC values for weighted pred |
---|
| 1878 | Void TComSlice::getWpAcDcParam(WPACDCParam *&wp) |
---|
| 1879 | { |
---|
| 1880 | wp = m_weightACDCParam; |
---|
| 1881 | } |
---|
| 1882 | |
---|
[1260] | 1883 | //! init AC and DC values for weighted pred |
---|
[313] | 1884 | Void TComSlice::initWpAcDcParam() |
---|
| 1885 | { |
---|
[1029] | 1886 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
[313] | 1887 | { |
---|
| 1888 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1889 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1890 | } |
---|
| 1891 | } |
---|
| 1892 | |
---|
[1260] | 1893 | //! get tables for weighted prediction |
---|
[1029] | 1894 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
[313] | 1895 | { |
---|
[1029] | 1896 | assert (e<NUM_REF_PIC_LIST_01); |
---|
[313] | 1897 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1898 | } |
---|
| 1899 | |
---|
[1260] | 1900 | //! reset Default WP tables settings : no weight. |
---|
[313] | 1901 | Void TComSlice::resetWpScaling() |
---|
| 1902 | { |
---|
[1029] | 1903 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[313] | 1904 | { |
---|
| 1905 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1906 | { |
---|
[1029] | 1907 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
[313] | 1908 | { |
---|
[1029] | 1909 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
[313] | 1910 | pwp->bPresentFlag = false; |
---|
| 1911 | pwp->uiLog2WeightDenom = 0; |
---|
| 1912 | pwp->uiLog2WeightDenom = 0; |
---|
| 1913 | pwp->iWeight = 1; |
---|
| 1914 | pwp->iOffset = 0; |
---|
| 1915 | } |
---|
| 1916 | } |
---|
| 1917 | } |
---|
| 1918 | } |
---|
| 1919 | |
---|
[1260] | 1920 | //! init WP table |
---|
[1235] | 1921 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
[313] | 1922 | { |
---|
[1316] | 1923 | const Bool bUseHighPrecisionPredictionWeighting = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); |
---|
[1029] | 1924 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[313] | 1925 | { |
---|
| 1926 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1927 | { |
---|
[1029] | 1928 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
[313] | 1929 | { |
---|
[1029] | 1930 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1931 | if ( !pwp->bPresentFlag ) |
---|
[313] | 1932 | { |
---|
| 1933 | // Inferring values not present : |
---|
| 1934 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1935 | pwp->iOffset = 0; |
---|
| 1936 | } |
---|
| 1937 | |
---|
[1287] | 1938 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
[1029] | 1939 | |
---|
[313] | 1940 | pwp->w = pwp->iWeight; |
---|
[1029] | 1941 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
[313] | 1942 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1943 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1944 | } |
---|
| 1945 | } |
---|
| 1946 | } |
---|
| 1947 | } |
---|
| 1948 | |
---|
| 1949 | // ------------------------------------------------------------------------------------------------ |
---|
| 1950 | // Video parameter set (VPS) |
---|
| 1951 | // ------------------------------------------------------------------------------------------------ |
---|
[494] | 1952 | #if SVC_EXTENSION |
---|
[313] | 1953 | TComVPS::TComVPS() |
---|
| 1954 | : m_VPSId ( 0) |
---|
| 1955 | , m_uiMaxTLayers ( 1) |
---|
| 1956 | , m_uiMaxLayers ( 1) |
---|
| 1957 | , m_bTemporalIdNestingFlag (false) |
---|
| 1958 | , m_numHrdParameters ( 0) |
---|
[1235] | 1959 | , m_hrdParameters () |
---|
| 1960 | , m_hrdOpSetIdx () |
---|
| 1961 | , m_cprmsPresentFlag () |
---|
[1180] | 1962 | , m_baseLayerInternalFlag (true) |
---|
| 1963 | , m_baseLayerAvailableFlag (true) |
---|
[313] | 1964 | , m_maxLayerId (0) |
---|
| 1965 | , m_numLayerSets (0) |
---|
| 1966 | , m_numOutputLayerSets (0) |
---|
| 1967 | , m_numProfileTierLevel (0) |
---|
| 1968 | , m_numAddOutputLayerSets (0) |
---|
[1157] | 1969 | , m_defaultTargetOutputLayerIdc(0) |
---|
[442] | 1970 | , m_bitRatePresentVpsFlag (false) |
---|
| 1971 | , m_picRatePresentVpsFlag (false) |
---|
[713] | 1972 | , m_repFormatIdxPresentFlag (false) |
---|
[442] | 1973 | , m_vpsNumRepFormats (1) |
---|
[547] | 1974 | , m_viewIdLen (0) |
---|
[588] | 1975 | , m_vpsNonVuiExtLength (0) |
---|
[903] | 1976 | , m_vpsPocLsbAlignedFlag(false) |
---|
[313] | 1977 | { |
---|
| 1978 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1979 | { |
---|
| 1980 | m_numReorderPics[i] = 0; |
---|
[1029] | 1981 | m_uiMaxDecPicBuffering[i] = 1; |
---|
[313] | 1982 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1983 | } |
---|
[1029] | 1984 | |
---|
[874] | 1985 | m_nonHEVCBaseLayerFlag = false; |
---|
[313] | 1986 | m_splittingFlag = false; |
---|
[1161] | 1987 | m_nuhLayerIdPresentFlag = false; |
---|
[313] | 1988 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
| 1989 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
| 1990 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
| 1991 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
| 1992 | |
---|
| 1993 | m_numScalabilityTypes = 0; |
---|
[1043] | 1994 | ::memset(m_layerIdxInVps, 0, sizeof(m_layerIdxInVps)); |
---|
[1171] | 1995 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
[1161] | 1996 | |
---|
[313] | 1997 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
| 1998 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
| 1999 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
| 2000 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
[1148] | 2001 | |
---|
[1524] | 2002 | ::memset(m_directDependencyFlag, false, sizeof(m_directDependencyFlag)); |
---|
[313] | 2003 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
| 2004 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
| 2005 | m_directDepTypeLen = 2; |
---|
| 2006 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
[1148] | 2007 | |
---|
[313] | 2008 | m_maxOneActiveRefLayerFlag = true; |
---|
[494] | 2009 | ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); |
---|
[540] | 2010 | m_crossLayerPictureTypeAlignFlag = true; |
---|
[442] | 2011 | m_crossLayerIrapAlignFlag = true; |
---|
[644] | 2012 | m_crossLayerAlignedIdrOnlyFlag = false; |
---|
[442] | 2013 | m_maxTidRefPresentFlag = true; |
---|
[1046] | 2014 | for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1 - 1; i++) |
---|
[313] | 2015 | { |
---|
[1046] | 2016 | for( Int j = 0; j < MAX_VPS_LAYER_IDX_PLUS1; j++) |
---|
[588] | 2017 | { |
---|
| 2018 | m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1; |
---|
| 2019 | } |
---|
[313] | 2020 | } |
---|
[1176] | 2021 | |
---|
[588] | 2022 | m_tilesNotInUseFlag = true; |
---|
[1176] | 2023 | m_wppNotInUseFlag = true; |
---|
[588] | 2024 | ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); |
---|
| 2025 | ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); |
---|
| 2026 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
| 2027 | ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); |
---|
[1168] | 2028 | |
---|
[588] | 2029 | m_ilpRestrictedRefLayersFlag = false; |
---|
| 2030 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
| 2031 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
| 2032 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
[1167] | 2033 | |
---|
[588] | 2034 | m_vidSigPresentVpsFlag=true; |
---|
| 2035 | m_vpsVidSigInfo=1; |
---|
| 2036 | ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); |
---|
| 2037 | m_vpsVidSigIdx[0]=0; |
---|
| 2038 | for (Int i=0; i < 16; i++) |
---|
| 2039 | { |
---|
| 2040 | m_vpsVidFormat[i] = 5; |
---|
| 2041 | m_vpsFullRangeFlag[i] = false; |
---|
| 2042 | m_vpsColorPrimaries[i] = 2; |
---|
| 2043 | m_vpsTransChar[i] = 2; |
---|
| 2044 | m_vpsMatCoeff[i] = 2; |
---|
| 2045 | } |
---|
[1167] | 2046 | |
---|
[1203] | 2047 | ::memset( m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag) ); |
---|
| 2048 | ::memset( m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag) ); |
---|
| 2049 | ::memset( m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
| 2050 | ::memset( m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
| 2051 | ::memset( m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
| 2052 | ::memset( m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
| 2053 | ::memset( m_vpsRepFormatIdx , 0, sizeof(m_vpsRepFormatIdx) ); |
---|
| 2054 | ::memset( m_viewIdVal , 0, sizeof(m_viewIdVal)) ; |
---|
[1173] | 2055 | |
---|
| 2056 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
[540] | 2057 | { |
---|
| 2058 | m_numberRefLayers[i] = 0; |
---|
[1173] | 2059 | for( Int j = 0; j < MAX_NUM_LAYER_IDS; j++ ) |
---|
[540] | 2060 | { |
---|
| 2061 | m_recursiveRefLayerFlag[i][j] = 0; |
---|
| 2062 | } |
---|
| 2063 | } |
---|
[1173] | 2064 | |
---|
[540] | 2065 | ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); |
---|
| 2066 | ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); |
---|
| 2067 | ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); |
---|
| 2068 | ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); |
---|
| 2069 | ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); |
---|
| 2070 | ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); |
---|
[1034] | 2071 | ::memset( m_baseLayerPSCompatibilityFlag, 0, sizeof(m_baseLayerPSCompatibilityFlag) ); |
---|
[313] | 2072 | } |
---|
[494] | 2073 | #else |
---|
| 2074 | TComVPS::TComVPS() |
---|
| 2075 | : m_VPSId ( 0) |
---|
| 2076 | , m_uiMaxTLayers ( 1) |
---|
| 2077 | , m_uiMaxLayers ( 1) |
---|
| 2078 | , m_bTemporalIdNestingFlag (false) |
---|
| 2079 | , m_numHrdParameters ( 0) |
---|
| 2080 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
[1235] | 2081 | , m_hrdParameters () |
---|
| 2082 | , m_hrdOpSetIdx () |
---|
| 2083 | , m_cprmsPresentFlag () |
---|
[494] | 2084 | { |
---|
[1029] | 2085 | |
---|
[494] | 2086 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 2087 | { |
---|
| 2088 | m_numReorderPics[i] = 0; |
---|
[1029] | 2089 | m_uiMaxDecPicBuffering[i] = 1; |
---|
[494] | 2090 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 2091 | } |
---|
| 2092 | } |
---|
| 2093 | #endif //SVC_EXTENSION |
---|
[313] | 2094 | |
---|
| 2095 | TComVPS::~TComVPS() |
---|
| 2096 | { |
---|
| 2097 | } |
---|
[815] | 2098 | |
---|
[313] | 2099 | // ------------------------------------------------------------------------------------------------ |
---|
| 2100 | // Sequence parameter set (SPS) |
---|
| 2101 | // ------------------------------------------------------------------------------------------------ |
---|
| 2102 | |
---|
[1316] | 2103 | TComSPSRExt::TComSPSRExt() |
---|
| 2104 | : m_transformSkipRotationEnabledFlag (false) |
---|
| 2105 | , m_transformSkipContextEnabledFlag (false) |
---|
| 2106 | // m_rdpcmEnabledFlag initialized below |
---|
| 2107 | , m_extendedPrecisionProcessingFlag (false) |
---|
| 2108 | , m_intraSmoothingDisabledFlag (false) |
---|
| 2109 | , m_highPrecisionOffsetsEnabledFlag (false) |
---|
| 2110 | , m_persistentRiceAdaptationEnabledFlag(false) |
---|
| 2111 | , m_cabacBypassAlignmentEnabledFlag (false) |
---|
| 2112 | { |
---|
| 2113 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
| 2114 | { |
---|
| 2115 | m_rdpcmEnabledFlag[signallingModeIndex] = false; |
---|
| 2116 | } |
---|
| 2117 | } |
---|
| 2118 | |
---|
[313] | 2119 | TComSPS::TComSPS() |
---|
| 2120 | : m_SPSId ( 0) |
---|
| 2121 | , m_VPSId ( 0) |
---|
| 2122 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 2123 | , m_uiMaxTLayers ( 1) |
---|
| 2124 | // Structure |
---|
| 2125 | , m_picWidthInLumaSamples (352) |
---|
| 2126 | , m_picHeightInLumaSamples (288) |
---|
| 2127 | , m_log2MinCodingBlockSize ( 0) |
---|
[1029] | 2128 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
[313] | 2129 | , m_uiMaxCUWidth ( 32) |
---|
| 2130 | , m_uiMaxCUHeight ( 32) |
---|
[1290] | 2131 | , m_uiMaxTotalCUDepth ( 3) |
---|
[313] | 2132 | , m_bLongTermRefsPresent (false) |
---|
| 2133 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 2134 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 2135 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 2136 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 2137 | // Tool list |
---|
[1029] | 2138 | , m_usePCM (false) |
---|
[313] | 2139 | , m_pcmLog2MaxSize ( 5) |
---|
| 2140 | , m_uiPCMLog2MinSize ( 7) |
---|
| 2141 | , m_bPCMFilterDisableFlag (false) |
---|
| 2142 | , m_uiBitsForPOC ( 8) |
---|
[1029] | 2143 | , m_numLongTermRefPicSPS ( 0) |
---|
[313] | 2144 | , m_uiMaxTrSize ( 32) |
---|
[1029] | 2145 | , m_bUseSAO (false) |
---|
[313] | 2146 | , m_bTemporalIdNestingFlag (false) |
---|
| 2147 | , m_scalingListEnabledFlag (false) |
---|
| 2148 | , m_useStrongIntraSmoothing (false) |
---|
| 2149 | , m_vuiParametersPresentFlag (false) |
---|
| 2150 | , m_vuiParameters () |
---|
[494] | 2151 | #if SVC_EXTENSION |
---|
| 2152 | , m_layerId ( 0 ) |
---|
[815] | 2153 | , m_extensionFlag ( false ) |
---|
[1120] | 2154 | , m_bV1CompatibleSPSFlag ( 0) |
---|
[442] | 2155 | , m_updateRepFormatFlag (false) |
---|
[540] | 2156 | , m_updateRepFormatIndex (0) |
---|
[1223] | 2157 | , m_inferScalingListFlag ( false ) |
---|
| 2158 | , m_scalingListRefLayerId ( 0 ) |
---|
[494] | 2159 | #endif //SVC_EXTENSION |
---|
[313] | 2160 | { |
---|
[1029] | 2161 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 2162 | { |
---|
[1287] | 2163 | m_bitDepths.recon[ch] = 8; |
---|
| 2164 | #if O0043_BEST_EFFORT_DECODING |
---|
| 2165 | m_bitDepths.stream[ch] = 8; |
---|
| 2166 | #endif |
---|
| 2167 | m_pcmBitDepths[ch] = 8; |
---|
[1029] | 2168 | m_qpBDOffset [ch] = 0; |
---|
| 2169 | } |
---|
| 2170 | |
---|
[313] | 2171 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 2172 | { |
---|
[1464] | 2173 | m_uiMaxLatencyIncreasePlus1[i] = 0; |
---|
[313] | 2174 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 2175 | m_numReorderPics[i] = 0; |
---|
| 2176 | } |
---|
[1029] | 2177 | |
---|
[313] | 2178 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 2179 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
| 2180 | } |
---|
| 2181 | |
---|
| 2182 | TComSPS::~TComSPS() |
---|
| 2183 | { |
---|
| 2184 | m_RPSList.destroy(); |
---|
| 2185 | } |
---|
| 2186 | |
---|
| 2187 | Void TComSPS::createRPSList( Int numRPS ) |
---|
[1029] | 2188 | { |
---|
[313] | 2189 | m_RPSList.destroy(); |
---|
| 2190 | m_RPSList.create(numRPS); |
---|
| 2191 | } |
---|
| 2192 | |
---|
| 2193 | |
---|
| 2194 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
| 2195 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
| 2196 | |
---|
[1316] | 2197 | TComPPSRExt::TComPPSRExt() |
---|
| 2198 | : m_log2MaxTransformSkipBlockSize (2) |
---|
| 2199 | , m_crossComponentPredictionEnabledFlag(false) |
---|
| 2200 | , m_diffCuChromaQpOffsetDepth (0) |
---|
| 2201 | , m_chromaQpOffsetListLen (0) |
---|
| 2202 | // m_ChromaQpAdjTableIncludingNullEntry initialized below |
---|
| 2203 | // m_log2SaoOffsetScale initialized below |
---|
| 2204 | { |
---|
| 2205 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed. |
---|
| 2206 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; |
---|
| 2207 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 2208 | { |
---|
| 2209 | m_log2SaoOffsetScale[ch] = 0; |
---|
| 2210 | } |
---|
| 2211 | } |
---|
| 2212 | |
---|
[313] | 2213 | TComPPS::TComPPS() |
---|
[1029] | 2214 | : m_PPSId (0) |
---|
| 2215 | , m_SPSId (0) |
---|
| 2216 | , m_picInitQPMinus26 (0) |
---|
| 2217 | , m_useDQP (false) |
---|
| 2218 | , m_bConstrainedIntraPred (false) |
---|
| 2219 | , m_bSliceChromaQpFlag (false) |
---|
| 2220 | , m_uiMaxCuDQPDepth (0) |
---|
| 2221 | , m_chromaCbQpOffset (0) |
---|
| 2222 | , m_chromaCrQpOffset (0) |
---|
| 2223 | , m_numRefIdxL0DefaultActive (1) |
---|
| 2224 | , m_numRefIdxL1DefaultActive (1) |
---|
| 2225 | , m_TransquantBypassEnableFlag (false) |
---|
| 2226 | , m_useTransformSkip (false) |
---|
| 2227 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
| 2228 | , m_tilesEnabledFlag (false) |
---|
| 2229 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 2230 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 2231 | , m_uniformSpacingFlag (false) |
---|
| 2232 | , m_numTileColumnsMinus1 (0) |
---|
| 2233 | , m_numTileRowsMinus1 (0) |
---|
[1230] | 2234 | , m_signHideFlag (false) |
---|
[1029] | 2235 | , m_cabacInitPresentFlag (false) |
---|
| 2236 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 2237 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
| 2238 | , m_listsModificationPresentFlag (0) |
---|
| 2239 | , m_numExtraSliceHeaderBits (0) |
---|
| 2240 | |
---|
[815] | 2241 | #if SVC_EXTENSION |
---|
| 2242 | , m_extensionFlag(false) |
---|
| 2243 | , m_layerId(0) |
---|
[540] | 2244 | , m_inferScalingListFlag ( false ) |
---|
| 2245 | , m_scalingListRefLayerId ( 0 ) |
---|
[644] | 2246 | , m_pocResetInfoPresentFlag (false) |
---|
[1030] | 2247 | , m_numRefLayerLocationOffsets ( 0 ) |
---|
[1212] | 2248 | #if CGS_3D_ASYMLUT |
---|
[815] | 2249 | , m_nCGSFlag(0) |
---|
| 2250 | , m_nCGSOutputBitDepthY(0) |
---|
| 2251 | , m_nCGSOutputBitDepthC(0) |
---|
| 2252 | #endif |
---|
| 2253 | #endif //SVC_EXTENSION |
---|
[313] | 2254 | { |
---|
[1029] | 2255 | #if SVC_EXTENSION |
---|
[849] | 2256 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
---|
| 2257 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
---|
[1029] | 2258 | #endif //SVC_EXTENSION |
---|
[313] | 2259 | } |
---|
| 2260 | |
---|
| 2261 | TComPPS::~TComPPS() |
---|
| 2262 | { |
---|
| 2263 | } |
---|
| 2264 | |
---|
| 2265 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 2266 | : m_numberOfPictures (0) |
---|
| 2267 | , m_numberOfNegativePictures (0) |
---|
| 2268 | , m_numberOfPositivePictures (0) |
---|
| 2269 | , m_numberOfLongtermPictures (0) |
---|
[1029] | 2270 | , m_interRPSPrediction (0) |
---|
| 2271 | , m_deltaRIdxMinus1 (0) |
---|
| 2272 | , m_deltaRPS (0) |
---|
| 2273 | , m_numRefIdc (0) |
---|
[313] | 2274 | { |
---|
| 2275 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 2276 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 2277 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 2278 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
[1231] | 2279 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
| 2280 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
| 2281 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
| 2282 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
[313] | 2283 | } |
---|
| 2284 | |
---|
| 2285 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 2286 | { |
---|
| 2287 | } |
---|
| 2288 | |
---|
| 2289 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 2290 | { |
---|
| 2291 | m_used[bufferNum] = used; |
---|
| 2292 | } |
---|
| 2293 | |
---|
| 2294 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 2295 | { |
---|
| 2296 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 2297 | } |
---|
| 2298 | |
---|
| 2299 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 2300 | { |
---|
| 2301 | m_numberOfPictures = numberOfPictures; |
---|
| 2302 | } |
---|
| 2303 | |
---|
[1235] | 2304 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
[313] | 2305 | { |
---|
| 2306 | return m_used[bufferNum]; |
---|
| 2307 | } |
---|
| 2308 | |
---|
[1235] | 2309 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
[313] | 2310 | { |
---|
| 2311 | return m_deltaPOC[bufferNum]; |
---|
| 2312 | } |
---|
| 2313 | |
---|
[1235] | 2314 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
[313] | 2315 | { |
---|
| 2316 | return m_numberOfPictures; |
---|
| 2317 | } |
---|
| 2318 | |
---|
[1235] | 2319 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
[313] | 2320 | { |
---|
| 2321 | return m_POC[bufferNum]; |
---|
| 2322 | } |
---|
| 2323 | |
---|
| 2324 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 2325 | { |
---|
| 2326 | m_POC[bufferNum] = POC; |
---|
| 2327 | } |
---|
| 2328 | |
---|
[1235] | 2329 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
[313] | 2330 | { |
---|
| 2331 | return m_bCheckLTMSB[bufferNum]; |
---|
| 2332 | } |
---|
| 2333 | |
---|
| 2334 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 2335 | { |
---|
| 2336 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 2337 | } |
---|
| 2338 | |
---|
[1260] | 2339 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
[313] | 2340 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 2341 | { |
---|
| 2342 | m_refIdc[bufferNum] = refIdc; |
---|
| 2343 | } |
---|
| 2344 | |
---|
[1260] | 2345 | //! get the reference idc value at uiBufferNum |
---|
[1235] | 2346 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
[313] | 2347 | { |
---|
| 2348 | return m_refIdc[bufferNum]; |
---|
| 2349 | } |
---|
| 2350 | |
---|
| 2351 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 2352 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 2353 | * +ve values are in increasing order. |
---|
| 2354 | * \returns Void |
---|
| 2355 | */ |
---|
| 2356 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 2357 | { |
---|
| 2358 | // sort in increasing order (smallest first) |
---|
| 2359 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
[1029] | 2360 | { |
---|
[313] | 2361 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2362 | Bool used = getUsed(j); |
---|
| 2363 | for (Int k=j-1; k >= 0; k--) |
---|
| 2364 | { |
---|
| 2365 | Int temp = getDeltaPOC(k); |
---|
| 2366 | if (deltaPOC < temp) |
---|
| 2367 | { |
---|
| 2368 | setDeltaPOC(k+1, temp); |
---|
| 2369 | setUsed(k+1, getUsed(k)); |
---|
| 2370 | setDeltaPOC(k, deltaPOC); |
---|
| 2371 | setUsed(k, used); |
---|
| 2372 | } |
---|
| 2373 | } |
---|
| 2374 | } |
---|
| 2375 | // flip the negative values to largest first |
---|
| 2376 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2377 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
[1029] | 2378 | { |
---|
[313] | 2379 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2380 | Bool used = getUsed(j); |
---|
| 2381 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2382 | setUsed(j, getUsed(k)); |
---|
| 2383 | setDeltaPOC(k, deltaPOC); |
---|
| 2384 | setUsed(k, used); |
---|
| 2385 | } |
---|
| 2386 | } |
---|
| 2387 | |
---|
| 2388 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2389 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2390 | * \returns Void |
---|
| 2391 | */ |
---|
[1235] | 2392 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
[313] | 2393 | { |
---|
| 2394 | printf("DeltaPOC = { "); |
---|
| 2395 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2396 | { |
---|
| 2397 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
[1029] | 2398 | } |
---|
| 2399 | if (getInterRPSPrediction()) |
---|
[313] | 2400 | { |
---|
| 2401 | printf("}, RefIdc = { "); |
---|
| 2402 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2403 | { |
---|
| 2404 | printf("%d ", getRefIdc(j)); |
---|
[1029] | 2405 | } |
---|
[313] | 2406 | } |
---|
| 2407 | printf("}\n"); |
---|
| 2408 | } |
---|
| 2409 | |
---|
| 2410 | TComRefPicListModification::TComRefPicListModification() |
---|
[1230] | 2411 | : m_refPicListModificationFlagL0 (false) |
---|
| 2412 | , m_refPicListModificationFlagL1 (false) |
---|
[313] | 2413 | { |
---|
| 2414 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2415 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2416 | } |
---|
| 2417 | |
---|
| 2418 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2419 | { |
---|
| 2420 | } |
---|
| 2421 | |
---|
| 2422 | TComScalingList::TComScalingList() |
---|
| 2423 | { |
---|
[1235] | 2424 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2425 | { |
---|
| 2426 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
| 2427 | { |
---|
| 2428 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2429 | } |
---|
| 2430 | } |
---|
[313] | 2431 | } |
---|
[442] | 2432 | |
---|
[313] | 2433 | /** set default quantization matrix to array |
---|
| 2434 | */ |
---|
[1235] | 2435 | Void TComScalingList::setDefaultScalingList() |
---|
[313] | 2436 | { |
---|
| 2437 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2438 | { |
---|
[1029] | 2439 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
[313] | 2440 | { |
---|
[1235] | 2441 | processDefaultMatrix(sizeId, listId); |
---|
[313] | 2442 | } |
---|
| 2443 | } |
---|
| 2444 | } |
---|
| 2445 | /** check if use default quantization matrix |
---|
| 2446 | * \returns true if use default quantization matrix in all size |
---|
| 2447 | */ |
---|
[1235] | 2448 | Bool TComScalingList::checkDefaultScalingList() |
---|
[313] | 2449 | { |
---|
| 2450 | UInt defaultCounter=0; |
---|
| 2451 | |
---|
| 2452 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2453 | { |
---|
[1029] | 2454 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
[313] | 2455 | { |
---|
[1235] | 2456 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2457 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
[313] | 2458 | { |
---|
| 2459 | defaultCounter++; |
---|
| 2460 | } |
---|
| 2461 | } |
---|
| 2462 | } |
---|
[1029] | 2463 | |
---|
| 2464 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
[313] | 2465 | } |
---|
| 2466 | |
---|
| 2467 | /** get scaling matrix from RefMatrixID |
---|
[1260] | 2468 | * \param sizeId size index |
---|
| 2469 | * \param listId index of input matrix |
---|
| 2470 | * \param refListId index of reference matrix |
---|
[313] | 2471 | */ |
---|
| 2472 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 2473 | { |
---|
| 2474 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2475 | } |
---|
| 2476 | |
---|
[1235] | 2477 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
| 2478 | { |
---|
| 2479 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
| 2480 | |
---|
| 2481 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
| 2482 | { |
---|
| 2483 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
| 2484 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2485 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 2486 | { |
---|
| 2487 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 2488 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
| 2489 | return; |
---|
| 2490 | } |
---|
| 2491 | } |
---|
| 2492 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
| 2493 | } |
---|
| 2494 | |
---|
[1029] | 2495 | static Void outputScalingListHelp(std::ostream &os) |
---|
| 2496 | { |
---|
| 2497 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
| 2498 | "but their order is arbitrary.\n\n" |
---|
| 2499 | "The matrices are specified by:\n" |
---|
| 2500 | "<matrix name><unchecked data>\n" |
---|
| 2501 | " <value>,<value>,<value>,....\n\n" |
---|
| 2502 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
| 2503 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
| 2504 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
| 2505 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
| 2506 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
| 2507 | " exchanged between the encoder and decoder\n\n" |
---|
| 2508 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
| 2509 | "<matrix name>_DC<unchecked data>\n" |
---|
| 2510 | " <value>\n"; |
---|
| 2511 | |
---|
| 2512 | os << "The permitted matrix names are:\n"; |
---|
| 2513 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2514 | { |
---|
| 2515 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
| 2516 | { |
---|
| 2517 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
| 2518 | { |
---|
| 2519 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
| 2520 | } |
---|
| 2521 | } |
---|
| 2522 | } |
---|
| 2523 | } |
---|
| 2524 | |
---|
| 2525 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
| 2526 | { |
---|
| 2527 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2528 | { |
---|
| 2529 | const UInt size = min(8,4<<(sizeIdc)); |
---|
| 2530 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
| 2531 | { |
---|
| 2532 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
| 2533 | { |
---|
| 2534 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 2535 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
| 2536 | for(UInt y=0; y<size; y++) |
---|
| 2537 | { |
---|
| 2538 | for(UInt x=0; x<size; x++, src++) |
---|
| 2539 | { |
---|
| 2540 | os << std::setw(3) << (*src) << ", "; |
---|
| 2541 | } |
---|
| 2542 | os << (y+1<size?"\n ":"\n"); |
---|
| 2543 | } |
---|
| 2544 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 2545 | { |
---|
| 2546 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
| 2547 | } |
---|
| 2548 | os << "\n"; |
---|
| 2549 | } |
---|
| 2550 | } |
---|
| 2551 | } |
---|
| 2552 | } |
---|
| 2553 | |
---|
[1442] | 2554 | Bool TComScalingList::xParseScalingList(const std::string &fileName) |
---|
[313] | 2555 | { |
---|
[1029] | 2556 | static const Int LINE_SIZE=1024; |
---|
| 2557 | FILE *fp = NULL; |
---|
[1442] | 2558 | TChar line[LINE_SIZE]; |
---|
[313] | 2559 | |
---|
[1442] | 2560 | if (fileName.empty()) |
---|
[313] | 2561 | { |
---|
[1029] | 2562 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
| 2563 | outputScalingListHelp(std::cout); |
---|
| 2564 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
| 2565 | outputScalingLists(std::cout); |
---|
| 2566 | exit (1); |
---|
[313] | 2567 | return true; |
---|
| 2568 | } |
---|
[1442] | 2569 | else if ((fp = fopen(fileName.c_str(),"r")) == (FILE*)NULL) |
---|
[1029] | 2570 | { |
---|
[1442] | 2571 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n", fileName.c_str()); |
---|
[1029] | 2572 | return true; |
---|
| 2573 | } |
---|
[313] | 2574 | |
---|
[1029] | 2575 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
[313] | 2576 | { |
---|
[1029] | 2577 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 2578 | |
---|
| 2579 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
[313] | 2580 | { |
---|
[1029] | 2581 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
[313] | 2582 | |
---|
[1029] | 2583 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
[313] | 2584 | { |
---|
[1029] | 2585 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
| 2586 | for(UInt i=0; i<size; i++) |
---|
[313] | 2587 | { |
---|
[1029] | 2588 | src[i] = srcNextSmallerSize[i]; |
---|
[313] | 2589 | } |
---|
[1029] | 2590 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
[313] | 2591 | } |
---|
[1029] | 2592 | else |
---|
[313] | 2593 | { |
---|
| 2594 | { |
---|
[1029] | 2595 | fseek(fp, 0, SEEK_SET); |
---|
| 2596 | Bool bFound=false; |
---|
| 2597 | while ((!feof(fp)) && (!bFound)) |
---|
| 2598 | { |
---|
[1442] | 2599 | TChar *ret = fgets(line, LINE_SIZE, fp); |
---|
| 2600 | TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
[1029] | 2601 | // This could be a match against the DC string as well, so verify it isn't |
---|
| 2602 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
| 2603 | { |
---|
| 2604 | bFound=true; |
---|
| 2605 | } |
---|
| 2606 | } |
---|
| 2607 | if (!bFound) |
---|
| 2608 | { |
---|
[1442] | 2609 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], fileName.c_str()); |
---|
[1029] | 2610 | return true; |
---|
| 2611 | } |
---|
[313] | 2612 | } |
---|
[1029] | 2613 | for (UInt i=0; i<size; i++) |
---|
[313] | 2614 | { |
---|
[1029] | 2615 | Int data; |
---|
| 2616 | if (fscanf(fp, "%d,", &data)!=1) |
---|
[313] | 2617 | { |
---|
[1442] | 2618 | fprintf(stderr, "Error: cannot read value #%d for Matrix %s from scaling list file %s at file position %ld\n", i, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp)); |
---|
[313] | 2619 | return true; |
---|
| 2620 | } |
---|
[1029] | 2621 | if (data<0 || data>255) |
---|
| 2622 | { |
---|
[1442] | 2623 | fprintf(stderr, "Error: QMatrix entry #%d of value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", i, data, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp)); |
---|
[1029] | 2624 | return true; |
---|
| 2625 | } |
---|
| 2626 | src[i] = data; |
---|
[313] | 2627 | } |
---|
[1029] | 2628 | |
---|
| 2629 | //set DC value for default matrix check |
---|
| 2630 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 2631 | |
---|
| 2632 | if(sizeIdc > SCALING_LIST_8x8) |
---|
[313] | 2633 | { |
---|
[1029] | 2634 | { |
---|
| 2635 | fseek(fp, 0, SEEK_SET); |
---|
| 2636 | Bool bFound=false; |
---|
| 2637 | while ((!feof(fp)) && (!bFound)) |
---|
| 2638 | { |
---|
[1442] | 2639 | TChar *ret = fgets(line, LINE_SIZE, fp); |
---|
| 2640 | TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
[1029] | 2641 | if (findNamePosition!= NULL) |
---|
| 2642 | { |
---|
| 2643 | // This won't be a match against the non-DC string. |
---|
| 2644 | bFound=true; |
---|
| 2645 | } |
---|
| 2646 | } |
---|
| 2647 | if (!bFound) |
---|
| 2648 | { |
---|
[1442] | 2649 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], fileName.c_str()); |
---|
[1029] | 2650 | return true; |
---|
| 2651 | } |
---|
| 2652 | } |
---|
| 2653 | Int data; |
---|
| 2654 | if (fscanf(fp, "%d,", &data)!=1) |
---|
| 2655 | { |
---|
[1442] | 2656 | fprintf(stderr, "Error: cannot read DC %s from scaling list file %s at file position %ld\n", MatrixType_DC[sizeIdc][listIdc], fileName.c_str(), ftell(fp)); |
---|
[1029] | 2657 | return true; |
---|
| 2658 | } |
---|
| 2659 | if (data<0 || data>255) |
---|
| 2660 | { |
---|
[1442] | 2661 | fprintf(stderr, "Error: DC value %d for Matrix %s from scaling list file %s at file position %ld is out of range (0 to 255)\n", data, MatrixType[sizeIdc][listIdc], fileName.c_str(), ftell(fp)); |
---|
[1029] | 2662 | return true; |
---|
| 2663 | } |
---|
| 2664 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 2665 | setScalingListDC(sizeIdc,listIdc,data); |
---|
[313] | 2666 | } |
---|
| 2667 | } |
---|
| 2668 | } |
---|
| 2669 | } |
---|
[1029] | 2670 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
| 2671 | // outputScalingLists(std::cout); |
---|
| 2672 | |
---|
[313] | 2673 | fclose(fp); |
---|
| 2674 | return false; |
---|
| 2675 | } |
---|
| 2676 | |
---|
[1246] | 2677 | |
---|
[1029] | 2678 | /** get default address of quantization matrix |
---|
[313] | 2679 | * \param sizeId size index |
---|
| 2680 | * \param listId list index |
---|
| 2681 | * \returns pointer of quantization matrix |
---|
| 2682 | */ |
---|
[1292] | 2683 | const Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
[313] | 2684 | { |
---|
[1292] | 2685 | const Int *src = 0; |
---|
[313] | 2686 | switch(sizeId) |
---|
| 2687 | { |
---|
| 2688 | case SCALING_LIST_4x4: |
---|
| 2689 | src = g_quantTSDefault4x4; |
---|
| 2690 | break; |
---|
| 2691 | case SCALING_LIST_8x8: |
---|
| 2692 | case SCALING_LIST_16x16: |
---|
| 2693 | case SCALING_LIST_32x32: |
---|
[1029] | 2694 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
[313] | 2695 | break; |
---|
| 2696 | default: |
---|
| 2697 | assert(0); |
---|
| 2698 | src = NULL; |
---|
| 2699 | break; |
---|
| 2700 | } |
---|
| 2701 | return src; |
---|
| 2702 | } |
---|
| 2703 | |
---|
| 2704 | /** process of default matrix |
---|
| 2705 | * \param sizeId size index |
---|
[1260] | 2706 | * \param listId index of input matrix |
---|
[313] | 2707 | */ |
---|
[540] | 2708 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
[313] | 2709 | { |
---|
| 2710 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2711 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 2712 | } |
---|
| 2713 | |
---|
| 2714 | /** check DC value of matrix for default matrix signaling |
---|
| 2715 | */ |
---|
| 2716 | Void TComScalingList::checkDcOfMatrix() |
---|
| 2717 | { |
---|
| 2718 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2719 | { |
---|
[1029] | 2720 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
[313] | 2721 | { |
---|
| 2722 | //check default matrix? |
---|
| 2723 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 2724 | { |
---|
[540] | 2725 | processDefaultMatrix(sizeId, listId); |
---|
[313] | 2726 | } |
---|
| 2727 | } |
---|
| 2728 | } |
---|
| 2729 | } |
---|
| 2730 | |
---|
| 2731 | ParameterSetManager::ParameterSetManager() |
---|
| 2732 | #if SVC_EXTENSION |
---|
[1319] | 2733 | : m_activePPSId(-1) |
---|
[313] | 2734 | #else |
---|
| 2735 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 2736 | , m_spsMap(MAX_NUM_SPS) |
---|
| 2737 | , m_ppsMap(MAX_NUM_PPS) |
---|
[1319] | 2738 | , m_activeVPSId(-1) |
---|
[313] | 2739 | #endif |
---|
[1319] | 2740 | , m_activeSPSId(-1) |
---|
[313] | 2741 | { |
---|
| 2742 | } |
---|
| 2743 | |
---|
| 2744 | |
---|
| 2745 | ParameterSetManager::~ParameterSetManager() |
---|
| 2746 | { |
---|
| 2747 | } |
---|
| 2748 | |
---|
| 2749 | //! activate a SPS from a active parameter sets SEI message |
---|
| 2750 | //! \returns true, if activation is successful |
---|
[1319] | 2751 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
| 2752 | //{ |
---|
| 2753 | // TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2754 | // if (sps) |
---|
| 2755 | // { |
---|
| 2756 | // Int vpsId = sps->getVPSId(); |
---|
| 2757 | // TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
| 2758 | // if (vps) |
---|
| 2759 | // { |
---|
| 2760 | // m_activeVPS = *(vps); |
---|
| 2761 | // m_activeSPS = *(sps); |
---|
| 2762 | // return true; |
---|
| 2763 | // } |
---|
| 2764 | // else |
---|
| 2765 | // { |
---|
| 2766 | // printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
| 2767 | // } |
---|
| 2768 | // } |
---|
| 2769 | // else |
---|
| 2770 | // { |
---|
| 2771 | // printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
| 2772 | // } |
---|
| 2773 | // return false; |
---|
| 2774 | //} |
---|
[313] | 2775 | |
---|
| 2776 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
| 2777 | //! \returns true, if activation is successful |
---|
| 2778 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
| 2779 | { |
---|
| 2780 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
| 2781 | if (pps) |
---|
| 2782 | { |
---|
[1319] | 2783 | #if SVC_EXTENSION |
---|
| 2784 | m_activePPSId = ppsId; |
---|
| 2785 | #endif |
---|
[313] | 2786 | Int spsId = pps->getSPSId(); |
---|
[1319] | 2787 | if (!isIRAP && (spsId != m_activeSPSId )) |
---|
[313] | 2788 | { |
---|
[1029] | 2789 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
[313] | 2790 | } |
---|
[1319] | 2791 | else |
---|
[313] | 2792 | { |
---|
[1319] | 2793 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2794 | if (sps) |
---|
[313] | 2795 | { |
---|
[1319] | 2796 | Int vpsId = sps->getVPSId(); |
---|
| 2797 | if (!isIRAP && (vpsId != m_activeVPSId )) |
---|
| 2798 | { |
---|
| 2799 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
| 2800 | } |
---|
| 2801 | else |
---|
| 2802 | { |
---|
| 2803 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
| 2804 | if (vps) |
---|
| 2805 | { |
---|
| 2806 | m_activeVPSId = vpsId; |
---|
| 2807 | m_activeSPSId = spsId; |
---|
| 2808 | return true; |
---|
| 2809 | } |
---|
| 2810 | else |
---|
| 2811 | { |
---|
| 2812 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
| 2813 | } |
---|
| 2814 | } |
---|
[313] | 2815 | } |
---|
| 2816 | else |
---|
| 2817 | { |
---|
[1319] | 2818 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
[313] | 2819 | } |
---|
| 2820 | } |
---|
| 2821 | } |
---|
| 2822 | else |
---|
| 2823 | { |
---|
| 2824 | printf("Warning: tried to activate non-existing PPS."); |
---|
| 2825 | } |
---|
[1319] | 2826 | |
---|
| 2827 | // Failed to activate if reach here. |
---|
| 2828 | m_activeSPSId=-1; |
---|
| 2829 | m_activeVPSId=-1; |
---|
[313] | 2830 | return false; |
---|
| 2831 | } |
---|
| 2832 | |
---|
| 2833 | ProfileTierLevel::ProfileTierLevel() |
---|
| 2834 | : m_profileSpace (0) |
---|
[1029] | 2835 | , m_tierFlag (Level::MAIN) |
---|
| 2836 | , m_profileIdc (Profile::NONE) |
---|
| 2837 | , m_levelIdc (Level::NONE) |
---|
| 2838 | , m_progressiveSourceFlag (false) |
---|
| 2839 | , m_interlacedSourceFlag (false) |
---|
| 2840 | , m_nonPackedConstraintFlag(false) |
---|
| 2841 | , m_frameOnlyConstraintFlag(false) |
---|
[313] | 2842 | { |
---|
| 2843 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 2844 | } |
---|
[1029] | 2845 | |
---|
| 2846 | TComPTL::TComPTL() |
---|
| 2847 | { |
---|
| 2848 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 2849 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 2850 | } |
---|
| 2851 | |
---|
[1319] | 2852 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData) |
---|
[1235] | 2853 | { |
---|
| 2854 | if (!bChanged) |
---|
| 2855 | { |
---|
| 2856 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
| 2857 | { |
---|
| 2858 | bChanged=true; |
---|
| 2859 | } |
---|
| 2860 | else if (pOldData!=0 && pOldData!=0) |
---|
| 2861 | { |
---|
| 2862 | // compare the two |
---|
| 2863 | if (pOldData->size() != pOldData->size()) |
---|
| 2864 | { |
---|
| 2865 | bChanged=true; |
---|
| 2866 | } |
---|
| 2867 | else |
---|
| 2868 | { |
---|
[1319] | 2869 | const UChar *pNewDataArray=&(newData)[0]; |
---|
[1235] | 2870 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
| 2871 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
| 2872 | { |
---|
| 2873 | bChanged=true; |
---|
| 2874 | } |
---|
| 2875 | } |
---|
| 2876 | } |
---|
| 2877 | } |
---|
| 2878 | } |
---|
| 2879 | |
---|
[1147] | 2880 | #if SVC_EXTENSION |
---|
[313] | 2881 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
| 2882 | { |
---|
| 2883 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
| 2884 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
| 2885 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
| 2886 | for(Int j = 0; j < 32; j++) |
---|
| 2887 | { |
---|
| 2888 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
| 2889 | } |
---|
| 2890 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
| 2891 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
| 2892 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
| 2893 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
| 2894 | } |
---|
| 2895 | |
---|
[1235] | 2896 | const Window& TComPPS::getScaledRefLayerWindowForLayer(Int layerId) const |
---|
[313] | 2897 | { |
---|
[1235] | 2898 | static const Window win; |
---|
[1029] | 2899 | |
---|
[1036] | 2900 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
[1029] | 2901 | { |
---|
[1035] | 2902 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
[1029] | 2903 | { |
---|
| 2904 | return m_scaledRefLayerWindow[i]; |
---|
| 2905 | } |
---|
| 2906 | } |
---|
[1235] | 2907 | |
---|
[1029] | 2908 | return win; |
---|
[313] | 2909 | } |
---|
[1090] | 2910 | |
---|
[1235] | 2911 | const Window& TComPPS::getRefLayerWindowForLayer(Int layerId) const |
---|
[1029] | 2912 | { |
---|
[1235] | 2913 | static const Window win; |
---|
[1029] | 2914 | |
---|
[1036] | 2915 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
[1029] | 2916 | { |
---|
[1035] | 2917 | if( layerId == m_refLocationOffsetLayerId[i] ) |
---|
[1029] | 2918 | { |
---|
| 2919 | return m_refLayerWindow[i]; |
---|
| 2920 | } |
---|
| 2921 | } |
---|
| 2922 | |
---|
| 2923 | return win; |
---|
| 2924 | } |
---|
| 2925 | |
---|
[1235] | 2926 | Bool TComPPS::hasZeroResamplingPhase(Int refLayerId) const |
---|
[1029] | 2927 | { |
---|
[1235] | 2928 | const ResamplingPhase &resamplingPhase = getResamplingPhase(refLayerId); |
---|
[1035] | 2929 | |
---|
[1235] | 2930 | return ( resamplingPhase.phaseHorLuma == 0 && resamplingPhase.phaseHorChroma == 0 && resamplingPhase.phaseVerLuma == 0 && resamplingPhase.phaseVerChroma == 0 ); |
---|
[1029] | 2931 | } |
---|
[1035] | 2932 | |
---|
[1235] | 2933 | const ResamplingPhase& TComPPS::getResamplingPhase(Int refLayerId) const |
---|
[1035] | 2934 | { |
---|
[1235] | 2935 | static const ResamplingPhase resamplingPhase; |
---|
[1035] | 2936 | |
---|
[1036] | 2937 | for( Int i = m_numRefLayerLocationOffsets-1; i >= 0; i-- ) |
---|
[1035] | 2938 | { |
---|
| 2939 | if( refLayerId == m_refLocationOffsetLayerId[i] ) |
---|
| 2940 | { |
---|
[1235] | 2941 | return m_resamplingPhase[i]; |
---|
[1035] | 2942 | } |
---|
| 2943 | } |
---|
[1235] | 2944 | |
---|
| 2945 | return resamplingPhase; |
---|
[1035] | 2946 | } |
---|
[1029] | 2947 | |
---|
| 2948 | Void TComVPS::deriveLayerIdListVariables() |
---|
| 2949 | { |
---|
| 2950 | // For layer 0 |
---|
| 2951 | m_numLayerInIdList.push_back(1); |
---|
| 2952 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1); |
---|
| 2953 | m_layerSetLayerIdList[0].push_back(0); |
---|
| 2954 | |
---|
| 2955 | // For other layers |
---|
| 2956 | for (Int i = 1; i <= m_vpsNumLayerSetsMinus1; i++) |
---|
| 2957 | { |
---|
| 2958 | for( Int m = 0; m <= m_maxLayerId; m++) |
---|
| 2959 | { |
---|
| 2960 | if( m_layerIdIncludedFlag[i][m] ) |
---|
| 2961 | { |
---|
| 2962 | m_layerSetLayerIdList[i].push_back(m); |
---|
| 2963 | } |
---|
| 2964 | } |
---|
[1077] | 2965 | m_numLayerInIdList.push_back((Int)m_layerSetLayerIdList[i].size()); |
---|
[1029] | 2966 | } |
---|
| 2967 | } |
---|
[1161] | 2968 | |
---|
[1029] | 2969 | Void TComVPS::deriveNumberOfSubDpbs() |
---|
| 2970 | { |
---|
| 2971 | // Derive number of sub-DPBs |
---|
| 2972 | // For layer set 0 |
---|
[1057] | 2973 | m_numSubDpbs[0] = 1; |
---|
[1029] | 2974 | // For other layer sets |
---|
[1057] | 2975 | for( Int i = 1; i < m_numLayerSets; i++) |
---|
[1029] | 2976 | { |
---|
[1057] | 2977 | m_numSubDpbs[i] = m_numLayerInIdList[i]; |
---|
[1029] | 2978 | } |
---|
| 2979 | } |
---|
[1176] | 2980 | |
---|
[1029] | 2981 | Void TComVPS::setTilesNotInUseFlag(Bool x) |
---|
| 2982 | { |
---|
| 2983 | m_tilesNotInUseFlag = x; |
---|
[1176] | 2984 | |
---|
| 2985 | if( m_tilesNotInUseFlag ) |
---|
[1029] | 2986 | { |
---|
[1176] | 2987 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
[1029] | 2988 | { |
---|
| 2989 | m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; |
---|
| 2990 | } |
---|
[1176] | 2991 | |
---|
| 2992 | for( Int i = 1; i < getMaxLayers(); i++ ) |
---|
[1029] | 2993 | { |
---|
[1176] | 2994 | for( Int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) |
---|
[1029] | 2995 | { |
---|
| 2996 | setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); |
---|
| 2997 | } |
---|
| 2998 | } |
---|
| 2999 | } |
---|
| 3000 | } |
---|
| 3001 | |
---|
| 3002 | Void TComVPS::setWppNotInUseFlag(Bool x) |
---|
| 3003 | { |
---|
| 3004 | m_wppNotInUseFlag = x; |
---|
[1176] | 3005 | |
---|
| 3006 | if( m_wppNotInUseFlag ) |
---|
[1029] | 3007 | { |
---|
[1176] | 3008 | for( Int i = 0; i < getMaxLayers(); i++ ) |
---|
[1029] | 3009 | { |
---|
| 3010 | m_wppInUseFlag[i] = m_wppNotInUseFlag; |
---|
| 3011 | } |
---|
| 3012 | } |
---|
| 3013 | } |
---|
[1173] | 3014 | |
---|
[1029] | 3015 | Void TComVPS::setRefLayersFlags(Int currLayerId) |
---|
| 3016 | { |
---|
| 3017 | for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++) |
---|
| 3018 | { |
---|
| 3019 | UInt refLayerId = getRefLayerId(currLayerId, i); |
---|
| 3020 | m_recursiveRefLayerFlag[currLayerId][refLayerId] = true; |
---|
| 3021 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) |
---|
| 3022 | { |
---|
| 3023 | m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k]; |
---|
| 3024 | } |
---|
| 3025 | } |
---|
| 3026 | } |
---|
| 3027 | |
---|
| 3028 | Void TComVPS::setNumRefLayers() |
---|
| 3029 | { |
---|
| 3030 | memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) ); |
---|
| 3031 | |
---|
| 3032 | for (Int i = 0; i < m_uiMaxLayers; i++) |
---|
| 3033 | { |
---|
| 3034 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
| 3035 | setRefLayersFlags(iNuhLId); |
---|
| 3036 | for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
| 3037 | { |
---|
| 3038 | m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0); |
---|
| 3039 | } |
---|
| 3040 | } |
---|
| 3041 | } |
---|
| 3042 | |
---|
| 3043 | Void TComVPS::setPredictedLayerIds() |
---|
| 3044 | { |
---|
| 3045 | for (UInt i = 0; i < m_uiMaxLayers - 1; i++) |
---|
| 3046 | { |
---|
| 3047 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
| 3048 | UInt predIdx = 0; |
---|
| 3049 | for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++) |
---|
| 3050 | { |
---|
| 3051 | if( m_recursiveRefLayerFlag[j][iNuhLId] ) |
---|
| 3052 | { |
---|
| 3053 | m_predictedLayerId[iNuhLId][predIdx] = j; |
---|
| 3054 | predIdx++; |
---|
| 3055 | } |
---|
| 3056 | } |
---|
| 3057 | m_numPredictedLayers[iNuhLId] = predIdx; |
---|
| 3058 | } |
---|
| 3059 | m_numPredictedLayers[m_layerIdInNuh[m_uiMaxLayers-1]] = 0; |
---|
| 3060 | } |
---|
| 3061 | |
---|
| 3062 | Void TComVPS::setTreePartitionLayerIdList() |
---|
| 3063 | { |
---|
| 3064 | Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS]; |
---|
| 3065 | memset( countedLayerIdxFlag, 0, sizeof(countedLayerIdxFlag) ); |
---|
| 3066 | |
---|
| 3067 | Int numIndependentLayers = 0; |
---|
| 3068 | |
---|
| 3069 | for (UInt i = 0; i < m_uiMaxLayers; i++) |
---|
| 3070 | { |
---|
| 3071 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
| 3072 | if( m_numDirectRefLayers[iNuhLId] == 0 ) |
---|
| 3073 | { |
---|
| 3074 | m_treePartitionLayerIdList[numIndependentLayers][0] = iNuhLId; |
---|
| 3075 | m_numLayersInTreePartition[numIndependentLayers] = 1; |
---|
| 3076 | for( UInt j = 0; j < m_numPredictedLayers[iNuhLId]; j++ ) |
---|
| 3077 | { |
---|
[1043] | 3078 | if( !countedLayerIdxFlag[m_layerIdxInVps[iNuhLId]] ) |
---|
[1029] | 3079 | { |
---|
| 3080 | m_treePartitionLayerIdList[numIndependentLayers][m_numLayersInTreePartition[numIndependentLayers]] = m_predictedLayerId[iNuhLId][j]; |
---|
| 3081 | m_numLayersInTreePartition[numIndependentLayers] = m_numLayersInTreePartition[numIndependentLayers] + 1; |
---|
[1043] | 3082 | countedLayerIdxFlag[m_layerIdxInVps[m_predictedLayerId[iNuhLId][j]]] = true; |
---|
[1029] | 3083 | } |
---|
| 3084 | } |
---|
| 3085 | numIndependentLayers++; |
---|
| 3086 | } |
---|
| 3087 | } |
---|
| 3088 | |
---|
| 3089 | m_numIndependentLayers = numIndependentLayers; |
---|
| 3090 | } |
---|
| 3091 | |
---|
[1132] | 3092 | Void TComVPS::deriveLayerIdListVariablesForAddLayerSets() |
---|
[1029] | 3093 | { |
---|
| 3094 | m_layerSetLayerIdList.resize(m_vpsNumLayerSetsMinus1 + 1 + m_numAddLayerSets); |
---|
| 3095 | |
---|
| 3096 | for (UInt i = 0; i < m_numAddLayerSets; i++) |
---|
| 3097 | { |
---|
| 3098 | Int layerNum = 0; |
---|
| 3099 | Int lsIdx = m_vpsNumLayerSetsMinus1 + 1 + i; |
---|
| 3100 | for (Int treeIdx = 1; treeIdx < m_numIndependentLayers; treeIdx++) |
---|
| 3101 | { |
---|
| 3102 | for (Int layerCnt = 0; layerCnt < m_highestLayerIdxPlus1[i][treeIdx]; layerCnt++) |
---|
| 3103 | { |
---|
| 3104 | m_layerSetLayerIdList[lsIdx].push_back(m_treePartitionLayerIdList[treeIdx][layerCnt]); |
---|
| 3105 | layerNum++; |
---|
| 3106 | } |
---|
| 3107 | } |
---|
| 3108 | m_numLayerInIdList.push_back(layerNum); |
---|
| 3109 | } |
---|
| 3110 | } |
---|
| 3111 | |
---|
[1235] | 3112 | Int TComVPS::getNumViews() const |
---|
[1029] | 3113 | { |
---|
| 3114 | Int numViews = 1; |
---|
[1235] | 3115 | for( Int i = 0; i < m_uiMaxLayers; i++ ) |
---|
[1029] | 3116 | { |
---|
[1235] | 3117 | Int lId = m_layerIdInNuh[i]; |
---|
[1455] | 3118 | if( i > 0 ) |
---|
[1029] | 3119 | { |
---|
[1455] | 3120 | UChar newViewFlag = 1; |
---|
| 3121 | |
---|
| 3122 | for( Int j = 0; j < i; j++ ) |
---|
| 3123 | { |
---|
| 3124 | if( getViewIndex(lId) == getScalabilityId( m_layerIdInNuh[j], VIEW_ORDER_INDEX ) ) |
---|
| 3125 | { |
---|
| 3126 | newViewFlag = 0; |
---|
| 3127 | break; |
---|
| 3128 | } |
---|
| 3129 | } |
---|
| 3130 | |
---|
| 3131 | numViews += newViewFlag; |
---|
| 3132 | } |
---|
[1029] | 3133 | } |
---|
| 3134 | |
---|
| 3135 | return numViews; |
---|
| 3136 | } |
---|
[1190] | 3137 | |
---|
[1235] | 3138 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
[1029] | 3139 | { |
---|
| 3140 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
[1190] | 3141 | } |
---|
| 3142 | |
---|
[1235] | 3143 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
[1029] | 3144 | { |
---|
[1439] | 3145 | assert( (Int)scalType >= 0 && (Int)scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
| 3146 | assert( (Int)scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
[1029] | 3147 | Int scalIdx = 0; |
---|
| 3148 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
| 3149 | { |
---|
| 3150 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
| 3151 | |
---|
| 3152 | } |
---|
| 3153 | |
---|
| 3154 | return scalIdx; |
---|
| 3155 | } |
---|
[1190] | 3156 | |
---|
[1235] | 3157 | Int TComVPS::getLayerIdcForOls( Int olsIdx, Int layerId ) const |
---|
[1073] | 3158 | { |
---|
| 3159 | Int layerIdc = -1; |
---|
[1086] | 3160 | UInt lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
[1073] | 3161 | |
---|
[1235] | 3162 | std::vector<Int>::const_iterator it = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), layerId ); |
---|
[1073] | 3163 | |
---|
[1086] | 3164 | if( it != m_layerSetLayerIdList[lsIdx].end() ) |
---|
[1073] | 3165 | { |
---|
[1086] | 3166 | layerIdc = (Int)std::distance( m_layerSetLayerIdList[lsIdx].begin(), it ); |
---|
[1073] | 3167 | } |
---|
| 3168 | |
---|
| 3169 | assert( layerIdc >= 0 ); |
---|
| 3170 | |
---|
| 3171 | return layerIdc; |
---|
| 3172 | } |
---|
| 3173 | |
---|
[1029] | 3174 | Void TComVPS::determineSubDpbInfoFlags() |
---|
| 3175 | { |
---|
| 3176 | for(Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
| 3177 | { |
---|
| 3178 | Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i ); |
---|
| 3179 | // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers |
---|
| 3180 | Bool checkFlagOuter = false; // Used to calculate sub_layer_flag_info_present_flag |
---|
| 3181 | Bool checkFlagInner[MAX_TLAYER]; // Used to calculate sub_layer_dpb_info_present_flag |
---|
| 3182 | |
---|
| 3183 | for(Int j = 0; j < getMaxTLayers(); j++) |
---|
| 3184 | { |
---|
| 3185 | // -------------------------------------------------------- |
---|
| 3186 | // To determine value of m_subLayerDpbInfoPresentFlag |
---|
| 3187 | // -------------------------------------------------------- |
---|
| 3188 | if( j == 0 ) // checkFlagInner[0] is always 1 |
---|
| 3189 | { |
---|
| 3190 | checkFlagInner[j] = true; // Always signal sub-layer DPB information for the first sub-layer |
---|
| 3191 | } |
---|
| 3192 | else |
---|
| 3193 | { |
---|
| 3194 | checkFlagInner[j] = false; // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, |
---|
| 3195 | // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled |
---|
| 3196 | checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) ); |
---|
[1135] | 3197 | |
---|
[1029] | 3198 | for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
| 3199 | { |
---|
| 3200 | checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) ); |
---|
| 3201 | } |
---|
| 3202 | } |
---|
| 3203 | // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer |
---|
| 3204 | setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] ); |
---|
| 3205 | } |
---|
| 3206 | |
---|
| 3207 | // -------------------------------------------------------- |
---|
| 3208 | // To determine value of m_subLayerFlagInfoPresentFlag |
---|
| 3209 | // -------------------------------------------------------- |
---|
| 3210 | |
---|
| 3211 | for(Int j = 1; j < getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one |
---|
| 3212 | { |
---|
| 3213 | if( getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
| 3214 | { |
---|
| 3215 | checkFlagOuter = true; |
---|
| 3216 | break; |
---|
| 3217 | } |
---|
| 3218 | } |
---|
| 3219 | setSubLayerFlagInfoPresentFlag( i, checkFlagOuter ); |
---|
| 3220 | } |
---|
| 3221 | } |
---|
| 3222 | |
---|
| 3223 | #if O0164_MULTI_LAYER_HRD |
---|
| 3224 | Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
| 3225 | { |
---|
| 3226 | if( !getVpsVuiBspHrdPresentFlag() ) |
---|
| 3227 | { |
---|
| 3228 | return; |
---|
| 3229 | } |
---|
| 3230 | |
---|
| 3231 | TComHRD *hrd = getBspHrd(hrdIdx); |
---|
| 3232 | |
---|
| 3233 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 3234 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 3235 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
| 3236 | |
---|
| 3237 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
| 3238 | |
---|
| 3239 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 3240 | { |
---|
| 3241 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 3242 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 3243 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
| 3244 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
| 3245 | } |
---|
| 3246 | else |
---|
| 3247 | { |
---|
| 3248 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
| 3249 | } |
---|
| 3250 | |
---|
| 3251 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
| 3252 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 3253 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 3254 | |
---|
| 3255 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 3256 | if( randomAccess ) |
---|
| 3257 | { |
---|
| 3258 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 3259 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 3260 | } |
---|
| 3261 | else |
---|
| 3262 | { |
---|
| 3263 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 3264 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 3265 | } |
---|
| 3266 | |
---|
| 3267 | /* |
---|
| 3268 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
| 3269 | */ |
---|
| 3270 | Int i, j; |
---|
| 3271 | UInt birateValue, cpbSizeValue; |
---|
| 3272 | UInt ducpbSizeValue; |
---|
| 3273 | UInt duBitRateValue = 0; |
---|
| 3274 | |
---|
| 3275 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
| 3276 | { |
---|
| 3277 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
| 3278 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
| 3279 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
| 3280 | hrd->setCpbCntMinus1( i, 0 ); |
---|
| 3281 | |
---|
| 3282 | birateValue = bitRate; |
---|
| 3283 | cpbSizeValue = bitRate; // 1 second |
---|
| 3284 | ducpbSizeValue = bitRate/numDU; |
---|
| 3285 | duBitRateValue = bitRate; |
---|
| 3286 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
| 3287 | { |
---|
| 3288 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
| 3289 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 3290 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
| 3291 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
| 3292 | |
---|
| 3293 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
| 3294 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 3295 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
| 3296 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
| 3297 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
| 3298 | } |
---|
| 3299 | } |
---|
| 3300 | } |
---|
| 3301 | #endif |
---|
[1151] | 3302 | |
---|
[1029] | 3303 | Void TComVPS::deriveNecessaryLayerFlag() |
---|
| 3304 | { |
---|
| 3305 | m_necessaryLayerFlag.empty(); |
---|
| 3306 | m_numNecessaryLayers.empty(); |
---|
| 3307 | // Assumed that output layer sets and variables RecursiveRefLayer are already derived |
---|
[1057] | 3308 | for( Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
[1029] | 3309 | { |
---|
| 3310 | deriveNecessaryLayerFlag(olsIdx); |
---|
| 3311 | } |
---|
| 3312 | } |
---|
[1151] | 3313 | |
---|
[1235] | 3314 | Void TComVPS::deriveNecessaryLayerFlag(const Int olsIdx) |
---|
[1029] | 3315 | { |
---|
[1057] | 3316 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
| 3317 | Int numLayersInLs = m_numLayerInIdList[lsIdx]; |
---|
[1029] | 3318 | assert( m_necessaryLayerFlag.size() == olsIdx ); // Function should be called in the correct order. |
---|
| 3319 | m_necessaryLayerFlag.push_back( std::vector<Bool>( numLayersInLs, false ) ); // Initialize to false |
---|
| 3320 | for( Int lsLayerIdx = 0; lsLayerIdx < numLayersInLs; lsLayerIdx++ ) |
---|
| 3321 | { |
---|
[1057] | 3322 | if( m_outputLayerFlag[olsIdx][lsLayerIdx] ) |
---|
[1029] | 3323 | { |
---|
| 3324 | m_necessaryLayerFlag[olsIdx][lsLayerIdx] = true; |
---|
[1057] | 3325 | Int currNuhLayerId = m_layerSetLayerIdList[lsIdx][lsLayerIdx]; |
---|
[1029] | 3326 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
| 3327 | { |
---|
[1057] | 3328 | Int refNuhLayerId = m_layerSetLayerIdList[lsIdx][rLsLayerIdx]; |
---|
| 3329 | if( m_recursiveRefLayerFlag[currNuhLayerId][refNuhLayerId] ) |
---|
[1029] | 3330 | { |
---|
| 3331 | m_necessaryLayerFlag[olsIdx][rLsLayerIdx] = true; |
---|
| 3332 | } |
---|
| 3333 | } |
---|
| 3334 | } |
---|
| 3335 | } |
---|
| 3336 | m_numNecessaryLayers.push_back(std::accumulate(m_necessaryLayerFlag[olsIdx].begin(), m_necessaryLayerFlag[olsIdx].end(), 0)); |
---|
| 3337 | } |
---|
[1151] | 3338 | |
---|
[1029] | 3339 | Void TComVPS::checkNecessaryLayerFlagCondition() |
---|
| 3340 | { |
---|
| 3341 | /* It is a requirement of bitstream conformance that for each layer index layerIdx in the range of |
---|
| 3342 | ( vps_base_layer_internal_flag ? 0 : 1 ) to MaxLayersMinus1, inclusive, there shall be at least one OLS with index olsIdx such that |
---|
| 3343 | NecessaryLayerFlag[ olsIdx ][ lsLayerIdx ] is equal to 1 for the value of lsLayerIdx |
---|
| 3344 | for which LayerSetLayerIdList[ OlsIdxToLsIdx[ olsIdx ] ][ lsLayerIdx ] is equal to layer_id_in_nuh[ layerIdx ]. */ |
---|
[1057] | 3345 | for(Int layerIdx = m_baseLayerInternalFlag ? 0 : 1; layerIdx < m_uiMaxLayers; layerIdx++) |
---|
[1029] | 3346 | { |
---|
| 3347 | Bool layerFoundNecessaryLayerFlag = false; |
---|
[1057] | 3348 | for(Int olsIdx = 0; olsIdx < m_numOutputLayerSets; olsIdx++) |
---|
[1029] | 3349 | { |
---|
[1057] | 3350 | Int lsIdx = m_outputLayerSetIdx[olsIdx]; |
---|
| 3351 | Int currNuhLayerId = m_layerIdInNuh[layerIdx]; |
---|
[1029] | 3352 | std::vector<Int>::iterator iter = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), currNuhLayerId ); |
---|
| 3353 | if( iter != m_layerSetLayerIdList[lsIdx].end() ) // Layer present in layer set |
---|
| 3354 | { |
---|
| 3355 | size_t positionLayer = iter - m_layerSetLayerIdList[lsIdx].begin(); |
---|
| 3356 | if( *(m_necessaryLayerFlag[olsIdx].begin() + positionLayer) == true ) |
---|
| 3357 | { |
---|
| 3358 | layerFoundNecessaryLayerFlag = true; |
---|
| 3359 | break; |
---|
| 3360 | } |
---|
| 3361 | } |
---|
| 3362 | } |
---|
| 3363 | assert( layerFoundNecessaryLayerFlag ); |
---|
| 3364 | } |
---|
| 3365 | } |
---|
[1151] | 3366 | |
---|
[1235] | 3367 | Int TComVPS::calculateLenOfSyntaxElement( const Int numVal ) const |
---|
[1029] | 3368 | { |
---|
| 3369 | Int numBits = 1; |
---|
| 3370 | while((1 << numBits) < numVal) |
---|
| 3371 | { |
---|
| 3372 | numBits++; |
---|
| 3373 | } |
---|
| 3374 | return numBits; |
---|
| 3375 | } |
---|
[1136] | 3376 | |
---|
[1029] | 3377 | Void TComVPS::calculateMaxSLInLayerSets() |
---|
| 3378 | { |
---|
| 3379 | for(Int lsIdx = 0; lsIdx < getNumLayerSets(); lsIdx++) |
---|
| 3380 | { |
---|
[1497] | 3381 | UChar maxSLMinus1 = 0; |
---|
[1029] | 3382 | for(Int k = 0; k < getNumLayersInIdList(lsIdx); k++ ) { |
---|
| 3383 | Int lId = getLayerSetLayerIdList(lsIdx, k); |
---|
[1043] | 3384 | maxSLMinus1 = std::max(maxSLMinus1, getMaxTSLayersMinus1(getLayerIdxInVps(lId))); |
---|
[1029] | 3385 | } |
---|
| 3386 | setMaxSLayersInLayerSetMinus1(lsIdx,maxSLMinus1); |
---|
| 3387 | } |
---|
| 3388 | } |
---|
| 3389 | |
---|
| 3390 | RepFormat::RepFormat() |
---|
| 3391 | #if AUXILIARY_PICTURES |
---|
| 3392 | : m_chromaFormatVpsIdc (CHROMA_420) |
---|
| 3393 | #else |
---|
| 3394 | : m_chromaFormatVpsIdc (0) |
---|
| 3395 | #endif |
---|
| 3396 | , m_separateColourPlaneVpsFlag (false) |
---|
| 3397 | , m_picWidthVpsInLumaSamples (0) |
---|
| 3398 | , m_picHeightVpsInLumaSamples (0) |
---|
| 3399 | , m_bitDepthVpsLuma (0) |
---|
| 3400 | , m_bitDepthVpsChroma (0) |
---|
| 3401 | {} |
---|
| 3402 | |
---|
[313] | 3403 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
| 3404 | { |
---|
| 3405 | // Copy all information related to general profile |
---|
| 3406 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
| 3407 | } |
---|
| 3408 | |
---|
[540] | 3409 | Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
[313] | 3410 | { |
---|
| 3411 | if(m_layerId == 0) |
---|
| 3412 | { |
---|
| 3413 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
[540] | 3414 | return false; |
---|
[313] | 3415 | } |
---|
[1210] | 3416 | |
---|
[815] | 3417 | TComPic* pic = xGetRefPic( rcListPic, getPOC() ); |
---|
[540] | 3418 | |
---|
| 3419 | if( pic ) |
---|
[442] | 3420 | { |
---|
[540] | 3421 | setBaseColPic(refLayerIdc, pic ); |
---|
[442] | 3422 | } |
---|
| 3423 | else |
---|
| 3424 | { |
---|
[540] | 3425 | return false; |
---|
[442] | 3426 | } |
---|
[540] | 3427 | |
---|
| 3428 | return true; |
---|
[313] | 3429 | } |
---|
| 3430 | |
---|
[494] | 3431 | TComPic* TComSlice::getBaseColPic( TComList<TComPic*>& rcListPic ) |
---|
| 3432 | { |
---|
| 3433 | return xGetRefPic( rcListPic, m_iPOC ); |
---|
| 3434 | } |
---|
| 3435 | |
---|
[821] | 3436 | Void TComSlice::setILRPic(TComPic **pcIlpPic) |
---|
[313] | 3437 | { |
---|
[821] | 3438 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
[313] | 3439 | { |
---|
[821] | 3440 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
[313] | 3441 | |
---|
[821] | 3442 | if( pcIlpPic[refLayerIdc] ) |
---|
| 3443 | { |
---|
| 3444 | TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc]; |
---|
[713] | 3445 | |
---|
[869] | 3446 | // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block |
---|
[1512] | 3447 | pcIlpPic[refLayerIdc]->setRequireResamplingFlag( refLayerIdc, m_pcPic->requireResampling(refLayerIdc) ); |
---|
[827] | 3448 | |
---|
[821] | 3449 | pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() ); |
---|
| 3450 | pcIlpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
[313] | 3451 | |
---|
[821] | 3452 | //set reference picture POC of each ILP reference |
---|
| 3453 | pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC ); |
---|
[313] | 3454 | |
---|
[821] | 3455 | //set temporal Id |
---|
| 3456 | pcIlpPic[refLayerIdc]->getSlice(0)->setTLayer( m_uiTLayer ); |
---|
[313] | 3457 | |
---|
[821] | 3458 | //copy layer id from the reference layer |
---|
| 3459 | pcIlpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() ); |
---|
[1083] | 3460 | pcIlpPic[refLayerIdc]->getSlice(0)->setLayerId(pcRefPicBL->getLayerId()); |
---|
[713] | 3461 | |
---|
[821] | 3462 | pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false ); |
---|
[1485] | 3463 | pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
[1483] | 3464 | pcIlpPic[refLayerIdc]->setIsLongTerm(true); |
---|
[713] | 3465 | |
---|
[1057] | 3466 | // assign PPS to ILRP to be used for reference location offsets |
---|
[1030] | 3467 | pcIlpPic[refLayerIdc]->getSlice(0)->setPPS( m_pcPic->getSlice(0)->getPPS() ); |
---|
| 3468 | |
---|
[1287] | 3469 | // assign SPS to ILRP to be used for obtaining bit depth |
---|
| 3470 | pcIlpPic[refLayerIdc]->getSlice(0)->setSPS( m_pcPic->getSlice(0)->getSPS() ); |
---|
| 3471 | |
---|
[1057] | 3472 | // assing VPS to ILRP to be used for deriving layerIdx |
---|
| 3473 | pcIlpPic[refLayerIdc]->getSlice(0)->setVPS( m_pcPic->getSlice(0)->getVPS() ); |
---|
| 3474 | |
---|
[821] | 3475 | if( m_bMFMEnabledFlag && !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) |
---|
| 3476 | { |
---|
| 3477 | //set reference picture POC of each ILP reference |
---|
| 3478 | assert( pcIlpPic[refLayerIdc]->getPOC() == pcRefPicBL->getPOC() ); |
---|
[313] | 3479 | |
---|
[821] | 3480 | //copy slice type from the reference layer |
---|
| 3481 | pcIlpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() ); |
---|
[313] | 3482 | |
---|
[821] | 3483 | //copy "used for reference" |
---|
| 3484 | pcIlpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() ); |
---|
[313] | 3485 | |
---|
[821] | 3486 | for( Int refList = 0; refList < 2; refList++ ) |
---|
| 3487 | { |
---|
| 3488 | RefPicList refPicList = RefPicList( refList ); |
---|
| 3489 | |
---|
| 3490 | //set reference POC of ILP |
---|
| 3491 | pcIlpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
| 3492 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
| 3493 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
| 3494 | |
---|
| 3495 | //initialize reference POC of ILP |
---|
| 3496 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
| 3497 | { |
---|
| 3498 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
| 3499 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
| 3500 | } |
---|
| 3501 | |
---|
| 3502 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
| 3503 | { |
---|
| 3504 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
| 3505 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
| 3506 | } |
---|
| 3507 | |
---|
| 3508 | //copy reference pictures' marking from the reference layer |
---|
| 3509 | for(Int j = 0; j < MAX_NUM_REF + 1; j++) |
---|
| 3510 | { |
---|
| 3511 | pcIlpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j)); |
---|
| 3512 | } |
---|
| 3513 | } |
---|
| 3514 | |
---|
[1419] | 3515 | pcIlpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcPic->getMvScalingFactor(), m_pcPic->getPosScalingFactor() ); |
---|
[313] | 3516 | } |
---|
[821] | 3517 | else |
---|
[713] | 3518 | { |
---|
[821] | 3519 | pcIlpPic[refLayerIdc]->initUpsampledMvField(); |
---|
[713] | 3520 | } |
---|
[313] | 3521 | |
---|
[1085] | 3522 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() ); |
---|
[821] | 3523 | assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) ); |
---|
[494] | 3524 | |
---|
| 3525 | } |
---|
| 3526 | } |
---|
| 3527 | } |
---|
[890] | 3528 | |
---|
| 3529 | Int TComSlice::getReferenceLayerIdc( UInt refLayerId ) |
---|
| 3530 | { |
---|
| 3531 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 3532 | { |
---|
| 3533 | if( m_pcVPS->getRefLayerId(m_layerId, m_interLayerPredLayerIdc[i]) == refLayerId ) |
---|
| 3534 | { |
---|
| 3535 | return m_interLayerPredLayerIdc[i]; |
---|
| 3536 | } |
---|
| 3537 | } |
---|
| 3538 | |
---|
| 3539 | return -1; |
---|
| 3540 | } |
---|
[1029] | 3541 | |
---|
[1210] | 3542 | Bool TComSlice::getBlaPicFlag() |
---|
[1029] | 3543 | { |
---|
| 3544 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 3545 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 3546 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP; |
---|
| 3547 | } |
---|
[1139] | 3548 | |
---|
[1210] | 3549 | Bool TComSlice::getCraPicFlag() |
---|
[1029] | 3550 | { |
---|
| 3551 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
| 3552 | } |
---|
[1139] | 3553 | |
---|
[1210] | 3554 | Bool TComSlice::getRaslPicFlag() |
---|
[1029] | 3555 | { |
---|
| 3556 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R |
---|
| 3557 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N; |
---|
| 3558 | } |
---|
[1210] | 3559 | |
---|
| 3560 | Bool TComSlice::getRadlPicFlag() |
---|
[1029] | 3561 | { |
---|
| 3562 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R |
---|
| 3563 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N; |
---|
| 3564 | } |
---|
[1209] | 3565 | |
---|
[1029] | 3566 | Void TComSlice::decrementRefPocValues(Int const decrementValue) |
---|
| 3567 | { |
---|
| 3568 | for(Int listNum = 0; listNum < 2; listNum++) |
---|
| 3569 | { |
---|
| 3570 | RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
| 3571 | for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++) |
---|
| 3572 | { |
---|
| 3573 | setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue, |
---|
| 3574 | dpbPicSliceList, |
---|
| 3575 | listIdx |
---|
| 3576 | ); |
---|
| 3577 | } |
---|
| 3578 | } |
---|
| 3579 | } |
---|
| 3580 | |
---|
| 3581 | Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal ) |
---|
| 3582 | { |
---|
| 3583 | if( prevLsb - currLsb >= (maxLsbVal >> 1) ) |
---|
| 3584 | { |
---|
| 3585 | return prevMsb + maxLsbVal; |
---|
| 3586 | } |
---|
| 3587 | else if( currLsb - prevLsb > (maxLsbVal >> 1) ) |
---|
| 3588 | { |
---|
| 3589 | return prevMsb - maxLsbVal; |
---|
| 3590 | } |
---|
| 3591 | else |
---|
| 3592 | { |
---|
| 3593 | return prevMsb; |
---|
| 3594 | } |
---|
| 3595 | } |
---|
| 3596 | |
---|
[1534] | 3597 | #if VIEW_SCALABILITY |
---|
| 3598 | Void TComSlice::setRefPicListModificationSvc( TComPic** ilpPic ) |
---|
| 3599 | #else |
---|
[1029] | 3600 | Void TComSlice::setRefPicListModificationSvc() |
---|
[1534] | 3601 | #endif |
---|
[1029] | 3602 | { |
---|
| 3603 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
| 3604 | { |
---|
| 3605 | return; |
---|
| 3606 | } |
---|
| 3607 | |
---|
| 3608 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
| 3609 | { |
---|
| 3610 | return; |
---|
| 3611 | } |
---|
| 3612 | |
---|
| 3613 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
| 3614 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
[1534] | 3615 | Int numberOfPocBeforeCurr = getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
[1029] | 3616 | |
---|
| 3617 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
| 3618 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
| 3619 | |
---|
| 3620 | //set L0 inter-layer reference picture modification |
---|
[1534] | 3621 | #if VIEW_SCALABILITY |
---|
| 3622 | Int numberOfPocAfterCurr = 0; |
---|
| 3623 | Int numberOfInterLayer0 = 0; |
---|
| 3624 | Int numberOfInterLayer1 = 0; |
---|
| 3625 | #endif |
---|
[1029] | 3626 | |
---|
[1534] | 3627 | Bool hasModification = false; |
---|
| 3628 | |
---|
| 3629 | if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
[1029] | 3630 | { |
---|
[1534] | 3631 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
| 3632 | |
---|
| 3633 | if( m_activeNumILRRefIdx > 1 ) |
---|
| 3634 | { |
---|
| 3635 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
| 3636 | } |
---|
[1029] | 3637 | } |
---|
[1534] | 3638 | #if VIEW_SCALABILITY |
---|
| 3639 | else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view |
---|
| 3640 | { |
---|
| 3641 | numberOfPocAfterCurr = getNumfPositiveRpsCurrTempList(); |
---|
| 3642 | numberOfInterLayer0 = getNumRpsInterLayerX(0, ilpPic); |
---|
| 3643 | numberOfInterLayer1 = getNumRpsInterLayerX(1, ilpPic); |
---|
| 3644 | |
---|
| 3645 | if( (numberOfInterLayer1 > 0 && m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfRpsCurrTempList) || (numberOfInterLayer1 == 0 && m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfPocBeforeCurr + numberOfInterLayer0 ) ) |
---|
| 3646 | { |
---|
| 3647 | hasModification = true; |
---|
| 3648 | } |
---|
| 3649 | else |
---|
| 3650 | { |
---|
| 3651 | hasModification = false; |
---|
| 3652 | } |
---|
| 3653 | } |
---|
[1029] | 3654 | #endif |
---|
[1534] | 3655 | |
---|
[1029] | 3656 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
| 3657 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
| 3658 | if(hasModification) |
---|
| 3659 | { |
---|
| 3660 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
| 3661 | { |
---|
| 3662 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
| 3663 | } |
---|
| 3664 | |
---|
| 3665 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
| 3666 | { |
---|
| 3667 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
| 3668 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
| 3669 | { |
---|
| 3670 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
| 3671 | } |
---|
| 3672 | } |
---|
[1534] | 3673 | else if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
[1029] | 3674 | { |
---|
| 3675 | // number of ILRPs included into the reference picture list with the list modification |
---|
| 3676 | Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx); |
---|
| 3677 | |
---|
| 3678 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
| 3679 | { |
---|
[1195] | 3680 | if( numberOfPocBeforeCurr >= m_aiNumRefIdx[REF_PIC_LIST_0] ) |
---|
[1029] | 3681 | { |
---|
| 3682 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
| 3683 | } |
---|
| 3684 | else |
---|
| 3685 | { |
---|
| 3686 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
[1195] | 3687 | for( Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++ ) |
---|
[1029] | 3688 | { |
---|
| 3689 | assert( j + includeNumILRP < numberOfRpsCurrTempList ); |
---|
| 3690 | refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP); |
---|
| 3691 | } |
---|
| 3692 | } |
---|
| 3693 | } |
---|
| 3694 | } |
---|
[1534] | 3695 | #if VIEW_SCALABILITY |
---|
| 3696 | else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view |
---|
| 3697 | { |
---|
| 3698 | Int includeNumILRP = m_activeNumILRRefIdx; |
---|
| 3699 | Int iNumILRP = includeNumILRP; |
---|
| 3700 | |
---|
| 3701 | if( numberOfInterLayer1 > 0 ) |
---|
| 3702 | { |
---|
| 3703 | if( m_aiNumRefIdx[REF_PIC_LIST_0] < numberOfPocBeforeCurr + m_activeNumILRRefIdx ) |
---|
| 3704 | { |
---|
| 3705 | for( Int i = 0; i < numberOfInterLayer0 && iNumILRP > 0; i++, iNumILRP-- ) |
---|
| 3706 | { |
---|
| 3707 | refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - includeNumILRP + i, numberOfPocBeforeCurr + i ); |
---|
| 3708 | } |
---|
| 3709 | |
---|
| 3710 | for( Int i = 0; i < numberOfInterLayer1 && iNumILRP > 0; i++, iNumILRP-- ) |
---|
| 3711 | { |
---|
| 3712 | refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - includeNumILRP +numberOfInterLayer0+ i, numberOfRpsCurrTempList- numberOfInterLayer1 + i ); |
---|
| 3713 | } |
---|
| 3714 | } |
---|
| 3715 | else |
---|
| 3716 | { |
---|
| 3717 | iNumILRP -= numberOfInterLayer0; |
---|
| 3718 | |
---|
| 3719 | for( Int i = numberOfInterLayer1; i >0 && iNumILRP > 0; i--, iNumILRP-- ) |
---|
| 3720 | { |
---|
| 3721 | refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i ); |
---|
| 3722 | } |
---|
| 3723 | } |
---|
| 3724 | } |
---|
| 3725 | else |
---|
| 3726 | { |
---|
| 3727 | for( Int i = numberOfInterLayer0; i >0 && iNumILRP >0 ; i--, iNumILRP-- ) |
---|
| 3728 | { |
---|
| 3729 | refPicListModification->setRefPicSetIdxL0( m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + numberOfInterLayer0 - i ); |
---|
| 3730 | } |
---|
| 3731 | } |
---|
| 3732 | } |
---|
| 3733 | #endif |
---|
[1029] | 3734 | } |
---|
| 3735 | |
---|
| 3736 | //set L1 inter-layer reference picture modification |
---|
[1534] | 3737 | if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
| 3738 | { |
---|
| 3739 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true; |
---|
| 3740 | } |
---|
| 3741 | #if VIEW_SCALABILITY |
---|
| 3742 | else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view |
---|
| 3743 | { |
---|
| 3744 | if( (numberOfInterLayer0 > 0 && m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfRpsCurrTempList) || (numberOfInterLayer0 == 0 && m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfPocAfterCurr + numberOfInterLayer1) ) |
---|
| 3745 | { |
---|
| 3746 | hasModification = true; |
---|
| 3747 | } |
---|
| 3748 | else |
---|
| 3749 | { |
---|
| 3750 | hasModification = false; |
---|
| 3751 | } |
---|
| 3752 | } |
---|
| 3753 | #endif |
---|
[1029] | 3754 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
| 3755 | |
---|
| 3756 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
| 3757 | if(hasModification) |
---|
| 3758 | { |
---|
| 3759 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
| 3760 | { |
---|
| 3761 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
| 3762 | } |
---|
| 3763 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
| 3764 | { |
---|
| 3765 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
| 3766 | { |
---|
| 3767 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
| 3768 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
| 3769 | } |
---|
| 3770 | } |
---|
[1534] | 3771 | else if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) //scalable layer |
---|
[1029] | 3772 | { |
---|
| 3773 | Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx); |
---|
| 3774 | |
---|
| 3775 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
| 3776 | { |
---|
| 3777 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
| 3778 | } |
---|
| 3779 | } |
---|
[1534] | 3780 | #if VIEW_SCALABILITY |
---|
| 3781 | else if( m_pcVPS->getScalabilityMask( VIEW_ORDER_INDEX ) ) //multi-view |
---|
| 3782 | { |
---|
| 3783 | Int includeNumILRP = m_activeNumILRRefIdx; |
---|
| 3784 | Int iNumILRP=includeNumILRP; |
---|
| 3785 | |
---|
| 3786 | if( numberOfInterLayer0 > 0 ) |
---|
| 3787 | { |
---|
| 3788 | if( m_aiNumRefIdx[REF_PIC_LIST_1] < numberOfPocAfterCurr + m_activeNumILRRefIdx ) |
---|
| 3789 | { |
---|
| 3790 | for( Int i = 0; i < numberOfInterLayer1 && iNumILRP>0; i++,iNumILRP-- ) |
---|
| 3791 | { |
---|
| 3792 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - includeNumILRP + i, numberOfPocAfterCurr + i); |
---|
| 3793 | } |
---|
| 3794 | |
---|
| 3795 | for(Int i = 0; i < numberOfInterLayer0 && iNumILRP>0; i++,iNumILRP-- ) |
---|
| 3796 | { |
---|
| 3797 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - includeNumILRP +numberOfInterLayer1+ i, numberOfRpsCurrTempList-numberOfInterLayer0+i); |
---|
| 3798 | } |
---|
| 3799 | } |
---|
| 3800 | else |
---|
| 3801 | { |
---|
| 3802 | iNumILRP -= numberOfInterLayer1; |
---|
| 3803 | for( Int i = numberOfInterLayer0; i > 0 && iNumILRP > 0; i--,iNumILRP-- ) |
---|
| 3804 | { |
---|
| 3805 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
| 3806 | } |
---|
| 3807 | } |
---|
| 3808 | } |
---|
| 3809 | else |
---|
| 3810 | { |
---|
| 3811 | for( Int i = numberOfInterLayer1; i >0 && iNumILRP>0; i--, iNumILRP-- ) |
---|
| 3812 | { |
---|
| 3813 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfPocAfterCurr + numberOfInterLayer1 - i); |
---|
| 3814 | } |
---|
| 3815 | } |
---|
| 3816 | } |
---|
| 3817 | #endif |
---|
[1029] | 3818 | } |
---|
| 3819 | return; |
---|
| 3820 | } |
---|
| 3821 | |
---|
| 3822 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
| 3823 | { |
---|
| 3824 | if( m_eSliceType == I_SLICE ) |
---|
| 3825 | { |
---|
| 3826 | return 0; |
---|
| 3827 | } |
---|
| 3828 | |
---|
| 3829 | Int numPocBeforeCurr = 0; |
---|
[1195] | 3830 | |
---|
[1367] | 3831 | for( UInt i = 0; i < m_pRPS->getNumberOfNegativePictures(); i++ ) |
---|
[1029] | 3832 | { |
---|
[1367] | 3833 | if( m_pRPS->getUsed(i) ) |
---|
[1029] | 3834 | { |
---|
| 3835 | numPocBeforeCurr++; |
---|
| 3836 | } |
---|
| 3837 | } |
---|
| 3838 | |
---|
| 3839 | return numPocBeforeCurr; |
---|
| 3840 | } |
---|
[1502] | 3841 | |
---|
| 3842 | Void TComSPS::inferSPS( const UInt layerId, TComVPS* vps ) |
---|
| 3843 | { |
---|
| 3844 | RepFormat* repFormat = NULL; |
---|
| 3845 | |
---|
| 3846 | if( layerId == 0 || m_bV1CompatibleSPSFlag == 1 ) |
---|
| 3847 | { |
---|
| 3848 | if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
| 3849 | { |
---|
[1503] | 3850 | // infered from vps_rep_format_idx[ 0 ]-th rep_format( ) syntax structure in the active VPS |
---|
| 3851 | repFormat = vps->getVpsRepFormat(0); |
---|
[1502] | 3852 | } |
---|
| 3853 | } |
---|
| 3854 | else |
---|
| 3855 | { |
---|
| 3856 | repFormat = vps->getVpsRepFormat(m_updateRepFormatFlag ? m_updateRepFormatIndex : vps->getVpsRepFormatIdx(vps->getLayerIdxInVps(layerId))); |
---|
| 3857 | } |
---|
| 3858 | |
---|
| 3859 | if( repFormat ) |
---|
| 3860 | { |
---|
| 3861 | m_chromaFormatIdc = repFormat->getChromaFormatVpsIdc(); |
---|
| 3862 | m_picWidthInLumaSamples = repFormat->getPicWidthVpsInLumaSamples(); |
---|
| 3863 | m_picHeightInLumaSamples = repFormat->getPicHeightVpsInLumaSamples(); |
---|
| 3864 | |
---|
| 3865 | m_bitDepths.recon[CHANNEL_TYPE_LUMA] = repFormat->getBitDepthVps(CHANNEL_TYPE_LUMA); |
---|
| 3866 | m_bitDepths.recon[CHANNEL_TYPE_CHROMA] = repFormat->getBitDepthVps(CHANNEL_TYPE_CHROMA); |
---|
| 3867 | |
---|
| 3868 | m_qpBDOffset[CHANNEL_TYPE_LUMA] = (m_bitDepths.recon[CHANNEL_TYPE_LUMA] - 8) * 6; |
---|
| 3869 | m_qpBDOffset[CHANNEL_TYPE_CHROMA] = (m_bitDepths.recon[CHANNEL_TYPE_CHROMA] - 8) * 6; |
---|
| 3870 | |
---|
| 3871 | m_conformanceWindow = repFormat->getConformanceWindowVps(); |
---|
| 3872 | } |
---|
| 3873 | } |
---|
[1534] | 3874 | |
---|
| 3875 | #if VIEW_SCALABILITY |
---|
| 3876 | Int TComSlice::getNumfPositiveRpsCurrTempList() |
---|
| 3877 | { |
---|
| 3878 | if( m_eSliceType == I_SLICE ) |
---|
| 3879 | { |
---|
| 3880 | return 0; |
---|
| 3881 | } |
---|
| 3882 | |
---|
| 3883 | Int numPocAfterCurr = 0; |
---|
| 3884 | |
---|
| 3885 | for( UInt i = 0; i < m_pRPS->getNumberOfPositivePictures(); i++ ) |
---|
| 3886 | { |
---|
| 3887 | if( m_pRPS->getUsed(i) ) |
---|
| 3888 | { |
---|
| 3889 | numPocAfterCurr++; |
---|
| 3890 | } |
---|
| 3891 | } |
---|
| 3892 | |
---|
| 3893 | return numPocAfterCurr; |
---|
| 3894 | } |
---|
| 3895 | #endif |
---|
| 3896 | |
---|
[494] | 3897 | #endif //SVC_EXTENSION |
---|
| 3898 | |
---|
[313] | 3899 | //! \} |
---|