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