[1313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
[5] | 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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1313] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
[1321] | 8 | |
---|
[5] | 9 | * |
---|
| 10 | * Redistribution and use in source and binary forms, with or without |
---|
| 11 | * modification, are permitted provided that the following conditions are met: |
---|
| 12 | * |
---|
| 13 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 14 | * this list of conditions and the following disclaimer. |
---|
| 15 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 16 | * this list of conditions and the following disclaimer in the documentation |
---|
| 17 | * and/or other materials provided with the distribution. |
---|
[56] | 18 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 19 | * be used to endorse or promote products derived from this software without |
---|
| 20 | * specific prior written permission. |
---|
| 21 | * |
---|
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 26 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 32 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 33 | */ |
---|
| 34 | |
---|
[2] | 35 | /** \file TComSlice.cpp |
---|
| 36 | \brief slice header and SPS class |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include "CommonDef.h" |
---|
| 40 | #include "TComSlice.h" |
---|
| 41 | #include "TComPic.h" |
---|
[608] | 42 | #include "TLibEncoder/TEncSbac.h" |
---|
| 43 | #include "TLibDecoder/TDecSbac.h" |
---|
[2] | 44 | |
---|
[1313] | 45 | |
---|
[56] | 46 | //! \ingroup TLibCommon |
---|
| 47 | //! \{ |
---|
| 48 | |
---|
[2] | 49 | TComSlice::TComSlice() |
---|
[56] | 50 | : m_iPPSId ( -1 ) |
---|
[1313] | 51 | , m_PicOutputFlag ( true ) |
---|
| 52 | #if NH_MV |
---|
[964] | 53 | , m_slicePicOrderCntLsb ( 0 ) |
---|
| 54 | #endif |
---|
[56] | 55 | , m_iPOC ( 0 ) |
---|
| 56 | , m_iLastIDR ( 0 ) |
---|
[1313] | 57 | , m_iAssociatedIRAP ( 0 ) |
---|
| 58 | , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) |
---|
| 59 | , m_pRPS ( 0 ) |
---|
| 60 | , m_localRPS ( ) |
---|
| 61 | , m_rpsIdx ( 0 ) |
---|
| 62 | , m_RefPicListModification ( ) |
---|
[608] | 63 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
[56] | 64 | , m_eSliceType ( I_SLICE ) |
---|
| 65 | , m_iSliceQp ( 0 ) |
---|
[1313] | 66 | , m_dependentSliceSegmentFlag ( false ) |
---|
[56] | 67 | #if ADAPTIVE_QP_SELECTION |
---|
| 68 | , m_iSliceQpBase ( 0 ) |
---|
[2] | 69 | #endif |
---|
[1313] | 70 | , m_ChromaQpAdjEnabled ( false ) |
---|
| 71 | , m_deblockingFilterDisable ( false ) |
---|
| 72 | , m_deblockingFilterOverrideFlag ( false ) |
---|
| 73 | , m_deblockingFilterBetaOffsetDiv2( 0 ) |
---|
| 74 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
[56] | 75 | , m_bCheckLDC ( false ) |
---|
| 76 | , m_iSliceQpDelta ( 0 ) |
---|
| 77 | , m_iDepth ( 0 ) |
---|
| 78 | , m_bRefenced ( false ) |
---|
[1313] | 79 | , m_pcVPS ( NULL ) |
---|
[56] | 80 | , m_pcSPS ( NULL ) |
---|
| 81 | , m_pcPPS ( NULL ) |
---|
| 82 | , m_pcPic ( NULL ) |
---|
[1313] | 83 | , m_colFromL0Flag ( true ) |
---|
[964] | 84 | , m_noOutputPriorPicsFlag ( false ) |
---|
| 85 | , m_noRaslOutputFlag ( false ) |
---|
[1313] | 86 | , m_handleCraAsBlaFlag ( false ) |
---|
[56] | 87 | , m_colRefIdx ( 0 ) |
---|
[1313] | 88 | , m_maxNumMergeCand ( 0 ) |
---|
[56] | 89 | , m_uiTLayer ( 0 ) |
---|
| 90 | , m_bTLayerSwitchingFlag ( false ) |
---|
[1313] | 91 | , m_sliceMode ( NO_SLICES ) |
---|
| 92 | , m_sliceArgument ( 0 ) |
---|
| 93 | , m_sliceCurStartCtuTsAddr ( 0 ) |
---|
| 94 | , m_sliceCurEndCtuTsAddr ( 0 ) |
---|
| 95 | , m_sliceIdx ( 0 ) |
---|
| 96 | , m_sliceSegmentMode ( NO_SLICES ) |
---|
| 97 | , m_sliceSegmentArgument ( 0 ) |
---|
| 98 | , m_sliceSegmentCurStartCtuTsAddr ( 0 ) |
---|
| 99 | , m_sliceSegmentCurEndCtuTsAddr ( 0 ) |
---|
| 100 | , m_nextSlice ( false ) |
---|
| 101 | , m_nextSliceSegment ( false ) |
---|
| 102 | , m_sliceBits ( 0 ) |
---|
| 103 | , m_sliceSegmentBits ( 0 ) |
---|
[56] | 104 | , m_bFinalized ( false ) |
---|
[1313] | 105 | , m_bTestWeightPred ( false ) |
---|
| 106 | , m_bTestWeightBiPred ( false ) |
---|
| 107 | , m_substreamSizes ( ) |
---|
[56] | 108 | , m_cabacInitFlag ( false ) |
---|
[608] | 109 | , m_bLMvdL1Zero ( false ) |
---|
| 110 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
[1313] | 111 | , m_LFCrossSliceBoundaryFlag ( false ) |
---|
[608] | 112 | , m_enableTMVPFlag ( true ) |
---|
[1313] | 113 | , m_encCABACTableIdx (I_SLICE) |
---|
| 114 | #if NH_MV |
---|
| 115 | , m_refPicSetInterLayer0 ( NULL ) |
---|
| 116 | , m_refPicSetInterLayer1 ( NULL ) |
---|
[608] | 117 | , m_layerId (0) |
---|
| 118 | , m_viewId (0) |
---|
[622] | 119 | , m_viewIndex (0) |
---|
[1321] | 120 | #if NH_MV |
---|
[622] | 121 | , m_pocResetFlag (false) |
---|
[738] | 122 | , m_crossLayerBlaFlag (false) |
---|
| 123 | #endif |
---|
[608] | 124 | , m_discardableFlag (false) |
---|
| 125 | , m_interLayerPredEnabledFlag (false) |
---|
| 126 | , m_numInterLayerRefPicsMinus1 (0) |
---|
[1313] | 127 | #if NH_MV |
---|
[872] | 128 | , m_sliceSegmentHeaderExtensionLength (0) |
---|
[1313] | 129 | , m_pocResetIdc (0) |
---|
| 130 | , m_pocResetPeriodId (0) |
---|
[1321] | 131 | , m_hasPocResetPeriodIdPresent (false) |
---|
[1313] | 132 | , m_fullPocResetFlag (false) |
---|
| 133 | , m_pocLsbVal (0) |
---|
[1321] | 134 | , m_pocMsbCycleValPresentFlag (false) |
---|
| 135 | , m_pocMsbCycleVal (0) |
---|
[1313] | 136 | , m_pocMsbValRequiredFlag (false) |
---|
[872] | 137 | #endif |
---|
[189] | 138 | #endif |
---|
[56] | 139 | { |
---|
[1321] | 140 | |
---|
| 141 | #if NH_MV |
---|
| 142 | m_shortTermRefPicSetIdx = 0; |
---|
| 143 | m_numLongTermSps = 0; |
---|
| 144 | m_numLongTermPics = 0; |
---|
| 145 | for (Int i = 0; i < MAX_NUM_PICS_RPS; i++) |
---|
| 146 | { |
---|
| 147 | m_ltIdxSps [i] = 0; |
---|
| 148 | m_deltaPocMsbCycleLt[i] = 0; |
---|
| 149 | } |
---|
| 150 | setSliceTemporalMvpEnabledFlag( false ); |
---|
| 151 | #endif |
---|
[1313] | 152 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
[872] | 153 | { |
---|
[1313] | 154 | m_aiNumRefIdx[i] = 0; |
---|
[872] | 155 | } |
---|
[1313] | 156 | |
---|
| 157 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
| 158 | { |
---|
| 159 | m_lambdas [component] = 0.0; |
---|
| 160 | m_iSliceChromaQpDelta[component] = 0; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | initEqualRef(); |
---|
| 164 | |
---|
[608] | 165 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
[56] | 166 | { |
---|
[608] | 167 | m_list1IdxToList0Idx[idx] = -1; |
---|
| 168 | } |
---|
[1313] | 169 | |
---|
[608] | 170 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
[56] | 171 | { |
---|
[1313] | 172 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 173 | { |
---|
| 174 | m_apcRefPicList [i][iNumCount] = NULL; |
---|
| 175 | m_aiRefPOCList [i][iNumCount] = 0; |
---|
| 176 | } |
---|
| 177 | #if NH_MV |
---|
[608] | 178 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
| 179 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
| 180 | #endif |
---|
[56] | 181 | } |
---|
[1313] | 182 | |
---|
[608] | 183 | resetWpScaling(); |
---|
[2] | 184 | initWpAcDcParam(); |
---|
[1313] | 185 | |
---|
| 186 | for(Int ch=0; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 187 | { |
---|
| 188 | m_saoEnabledFlag[ch] = false; |
---|
| 189 | } |
---|
| 190 | #if NH_MV |
---|
[608] | 191 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
[210] | 192 | { |
---|
[738] | 193 | m_interLayerPredLayerIdc[ i ] = -1; |
---|
[210] | 194 | } |
---|
| 195 | #endif |
---|
[1313] | 196 | |
---|
[2] | 197 | } |
---|
| 198 | |
---|
| 199 | TComSlice::~TComSlice() |
---|
| 200 | { |
---|
[608] | 201 | |
---|
[2] | 202 | } |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | Void TComSlice::initSlice() |
---|
| 206 | { |
---|
[1313] | 207 | for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++) |
---|
| 208 | { |
---|
| 209 | m_aiNumRefIdx[i] = 0; |
---|
| 210 | } |
---|
| 211 | m_colFromL0Flag = true; |
---|
| 212 | |
---|
[56] | 213 | m_colRefIdx = 0; |
---|
[2] | 214 | initEqualRef(); |
---|
[1313] | 215 | |
---|
[56] | 216 | m_bCheckLDC = false; |
---|
| 217 | |
---|
[1313] | 218 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
| 219 | { |
---|
| 220 | m_iSliceChromaQpDelta[component] = 0; |
---|
| 221 | } |
---|
[608] | 222 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
[56] | 223 | |
---|
| 224 | m_bFinalized=false; |
---|
| 225 | |
---|
[1313] | 226 | m_substreamSizes.clear(); |
---|
[56] | 227 | m_cabacInitFlag = false; |
---|
[608] | 228 | m_enableTMVPFlag = true; |
---|
[2] | 229 | } |
---|
| 230 | |
---|
[1313] | 231 | Bool TComSlice::getRapPicFlag() const |
---|
[56] | 232 | { |
---|
[608] | 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; |
---|
[56] | 239 | } |
---|
| 240 | |
---|
| 241 | |
---|
[2] | 242 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
| 243 | { |
---|
| 244 | TComPic* pcPicExtract; |
---|
| 245 | TComPic* pcPicInsert; |
---|
[1313] | 246 | |
---|
[2] | 247 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 248 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 249 | TComList<TComPic*>::iterator iterPicInsert; |
---|
[1313] | 250 | |
---|
[2] | 251 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 252 | { |
---|
| 253 | iterPicExtract = rcListPic.begin(); |
---|
[1313] | 254 | for (Int j = 0; j < i; j++) |
---|
| 255 | { |
---|
| 256 | iterPicExtract++; |
---|
| 257 | } |
---|
[2] | 258 | pcPicExtract = *(iterPicExtract); |
---|
| 259 | pcPicExtract->setCurrSliceIdx(0); |
---|
[1313] | 260 | |
---|
[2] | 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 | } |
---|
[1313] | 270 | |
---|
[2] | 271 | iterPicInsert++; |
---|
| 272 | } |
---|
[1313] | 273 | |
---|
[2] | 274 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
[1313] | 275 | |
---|
[2] | 276 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 277 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 278 | rcListPic.erase (iterPicExtract); |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | |
---|
[1313] | 282 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, Int poc) |
---|
[2] | 283 | { |
---|
[1313] | 284 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
[56] | 285 | TComPic* pcPic = *(iterPic); |
---|
| 286 | while ( iterPic != rcListPic.end() ) |
---|
[2] | 287 | { |
---|
[608] | 288 | if(pcPic->getPOC() == poc) |
---|
[2] | 289 | { |
---|
[56] | 290 | break; |
---|
[2] | 291 | } |
---|
[56] | 292 | iterPic++; |
---|
| 293 | pcPic = *(iterPic); |
---|
[2] | 294 | } |
---|
[56] | 295 | return pcPic; |
---|
| 296 | } |
---|
[2] | 297 | |
---|
[56] | 298 | |
---|
[608] | 299 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
[56] | 300 | { |
---|
[1313] | 301 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
[56] | 302 | TComPic* pcPic = *(iterPic); |
---|
| 303 | TComPic* pcStPic = pcPic; |
---|
[1313] | 304 | |
---|
[608] | 305 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
| 306 | if (!pocHasMsb) |
---|
| 307 | { |
---|
[655] | 308 | poc = poc & (pocCycle - 1); |
---|
[608] | 309 | } |
---|
[1313] | 310 | |
---|
[56] | 311 | while ( iterPic != rcListPic.end() ) |
---|
| 312 | { |
---|
| 313 | pcPic = *(iterPic); |
---|
[608] | 314 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
[56] | 315 | { |
---|
[608] | 316 | Int picPoc = pcPic->getPOC(); |
---|
| 317 | if (!pocHasMsb) |
---|
| 318 | { |
---|
[655] | 319 | picPoc = picPoc & (pocCycle - 1); |
---|
[608] | 320 | } |
---|
[1313] | 321 | |
---|
[608] | 322 | if (poc == picPoc) |
---|
| 323 | { |
---|
[1313] | 324 | if(pcPic->getIsLongTerm()) |
---|
| 325 | { |
---|
| 326 | return pcPic; |
---|
| 327 | } |
---|
| 328 | else |
---|
| 329 | { |
---|
| 330 | pcStPic = pcPic; |
---|
| 331 | } |
---|
| 332 | break; |
---|
[608] | 333 | } |
---|
[56] | 334 | } |
---|
| 335 | |
---|
| 336 | iterPic++; |
---|
| 337 | } |
---|
[1313] | 338 | |
---|
[56] | 339 | return pcStPic; |
---|
[2] | 340 | } |
---|
| 341 | |
---|
[608] | 342 | Void TComSlice::setRefPOCList () |
---|
[56] | 343 | { |
---|
[1313] | 344 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
[56] | 345 | { |
---|
[608] | 346 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
[56] | 347 | { |
---|
[608] | 348 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
[1313] | 349 | #if NH_MV |
---|
[608] | 350 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
| 351 | #endif |
---|
[56] | 352 | } |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | } |
---|
| 356 | |
---|
[608] | 357 | Void TComSlice::setList1IdxToList0Idx() |
---|
[56] | 358 | { |
---|
[608] | 359 | Int idxL0, idxL1; |
---|
| 360 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
[56] | 361 | { |
---|
[608] | 362 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
| 363 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
[56] | 364 | { |
---|
[608] | 365 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
| 366 | { |
---|
| 367 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
| 368 | break; |
---|
| 369 | } |
---|
[56] | 370 | } |
---|
| 371 | } |
---|
| 372 | } |
---|
[872] | 373 | |
---|
[1313] | 374 | #if !NH_MV |
---|
[622] | 375 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
| 376 | { |
---|
| 377 | if (m_eSliceType == I_SLICE) |
---|
| 378 | { |
---|
| 379 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 380 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 381 | |
---|
[1386] | 382 | if (!checkNumPocTotalCurr) |
---|
| 383 | { |
---|
[622] | 384 | return; |
---|
| 385 | } |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | TComPic* pcRefPic= NULL; |
---|
[1313] | 389 | static const UInt MAX_NUM_NEGATIVE_PICTURES=16; |
---|
| 390 | TComPic* RefPicSetStCurr0[MAX_NUM_NEGATIVE_PICTURES]; |
---|
| 391 | TComPic* RefPicSetStCurr1[MAX_NUM_NEGATIVE_PICTURES]; |
---|
| 392 | TComPic* RefPicSetLtCurr[MAX_NUM_NEGATIVE_PICTURES]; |
---|
| 393 | UInt NumPicStCurr0 = 0; |
---|
| 394 | UInt NumPicStCurr1 = 0; |
---|
| 395 | UInt NumPicLtCurr = 0; |
---|
[622] | 396 | Int i; |
---|
| 397 | |
---|
[1313] | 398 | for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++) |
---|
[622] | 399 | { |
---|
[1313] | 400 | if(m_pRPS->getUsed(i)) |
---|
[622] | 401 | { |
---|
[1313] | 402 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[622] | 403 | pcRefPic->setIsLongTerm(0); |
---|
| 404 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1313] | 405 | RefPicSetStCurr0[NumPicStCurr0] = pcRefPic; |
---|
| 406 | NumPicStCurr0++; |
---|
| 407 | pcRefPic->setCheckLTMSBPresent(false); |
---|
[622] | 408 | } |
---|
| 409 | } |
---|
| 410 | |
---|
[1313] | 411 | for(; i < m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures(); i++) |
---|
[622] | 412 | { |
---|
[1313] | 413 | if(m_pRPS->getUsed(i)) |
---|
[622] | 414 | { |
---|
[1313] | 415 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[622] | 416 | pcRefPic->setIsLongTerm(0); |
---|
| 417 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1313] | 418 | RefPicSetStCurr1[NumPicStCurr1] = pcRefPic; |
---|
| 419 | NumPicStCurr1++; |
---|
| 420 | pcRefPic->setCheckLTMSBPresent(false); |
---|
[622] | 421 | } |
---|
| 422 | } |
---|
| 423 | |
---|
[1313] | 424 | for(i = m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()+m_pRPS->getNumberOfLongtermPictures()-1; i > m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
[622] | 425 | { |
---|
[1313] | 426 | if(m_pRPS->getUsed(i)) |
---|
[622] | 427 | { |
---|
[1313] | 428 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 429 | pcRefPic->setIsLongTerm(1); |
---|
| 430 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
[1313] | 431 | RefPicSetLtCurr[NumPicLtCurr] = pcRefPic; |
---|
| 432 | NumPicLtCurr++; |
---|
[622] | 433 | } |
---|
[1313] | 434 | if(pcRefPic==NULL) |
---|
[622] | 435 | { |
---|
[1313] | 436 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 437 | } |
---|
[1313] | 438 | pcRefPic->setCheckLTMSBPresent(m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 439 | } |
---|
| 440 | |
---|
| 441 | // ref_pic_list_init |
---|
| 442 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
| 443 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
[1313] | 444 | Int numPicTotalCurr = NumPicStCurr0 + NumPicStCurr1 + NumPicLtCurr; |
---|
| 445 | |
---|
[622] | 446 | if (checkNumPocTotalCurr) |
---|
| 447 | { |
---|
| 448 | // 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: |
---|
[964] | 449 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 450 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
[622] | 451 | if (getRapPicFlag()) |
---|
| 452 | { |
---|
[1313] | 453 | assert(numPicTotalCurr == 0); |
---|
[622] | 454 | } |
---|
| 455 | |
---|
| 456 | if (m_eSliceType == I_SLICE) |
---|
| 457 | { |
---|
| 458 | return; |
---|
| 459 | } |
---|
| 460 | |
---|
[1313] | 461 | assert(numPicTotalCurr > 0); |
---|
| 462 | // general tier and level limit: |
---|
| 463 | assert(numPicTotalCurr <= 8); |
---|
[622] | 464 | } |
---|
| 465 | |
---|
| 466 | Int cIdx = 0; |
---|
[1313] | 467 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
[622] | 468 | { |
---|
| 469 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
| 470 | } |
---|
[1313] | 471 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
[622] | 472 | { |
---|
| 473 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
| 474 | } |
---|
[1313] | 475 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
[622] | 476 | { |
---|
| 477 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
| 478 | } |
---|
[1313] | 479 | assert(cIdx == numPicTotalCurr); |
---|
[622] | 480 | |
---|
| 481 | if (m_eSliceType==B_SLICE) |
---|
| 482 | { |
---|
| 483 | cIdx = 0; |
---|
[1313] | 484 | for ( i=0; i<NumPicStCurr1; i++, cIdx++) |
---|
[622] | 485 | { |
---|
| 486 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
| 487 | } |
---|
[1313] | 488 | for ( i=0; i<NumPicStCurr0; i++, cIdx++) |
---|
[622] | 489 | { |
---|
| 490 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
| 491 | } |
---|
[1313] | 492 | for ( i=0; i<NumPicLtCurr; i++, cIdx++) |
---|
[622] | 493 | { |
---|
| 494 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
| 495 | } |
---|
[1313] | 496 | assert(cIdx == numPicTotalCurr); |
---|
[622] | 497 | } |
---|
| 498 | |
---|
| 499 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 500 | |
---|
[1313] | 501 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_0]; rIdx ++) |
---|
[622] | 502 | { |
---|
[1313] | 503 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPicTotalCurr; |
---|
| 504 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
| 505 | m_apcRefPicList[REF_PIC_LIST_0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
| 506 | m_bIsUsedAsLongTerm[REF_PIC_LIST_0][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
[622] | 507 | } |
---|
| 508 | if ( m_eSliceType != B_SLICE ) |
---|
| 509 | { |
---|
[1313] | 510 | m_aiNumRefIdx[REF_PIC_LIST_1] = 0; |
---|
| 511 | ::memset( m_apcRefPicList[REF_PIC_LIST_1], 0, sizeof(m_apcRefPicList[REF_PIC_LIST_1])); |
---|
[622] | 512 | } |
---|
| 513 | else |
---|
| 514 | { |
---|
[1313] | 515 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[REF_PIC_LIST_1]; rIdx ++) |
---|
[622] | 516 | { |
---|
[1313] | 517 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPicTotalCurr; |
---|
| 518 | assert(cIdx >= 0 && cIdx < numPicTotalCurr); |
---|
| 519 | m_apcRefPicList[REF_PIC_LIST_1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
| 520 | m_bIsUsedAsLongTerm[REF_PIC_LIST_1][rIdx] = ( cIdx >= NumPicStCurr0 + NumPicStCurr1 ); |
---|
[622] | 521 | } |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | #else |
---|
| 525 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
| 526 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
| 527 | { |
---|
| 528 | if (!checkNumPocTotalCurr) |
---|
| 529 | { |
---|
| 530 | if (m_eSliceType == I_SLICE) |
---|
| 531 | { |
---|
| 532 | return; |
---|
| 533 | } |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | TComPic* pcRefPic= NULL; |
---|
| 537 | TComPic* RefPicSetStCurr0[16]; |
---|
| 538 | TComPic* RefPicSetStCurr1[16]; |
---|
| 539 | TComPic* RefPicSetLtCurr[16]; |
---|
| 540 | UInt NumPocStCurr0 = 0; |
---|
| 541 | UInt NumPocStCurr1 = 0; |
---|
| 542 | UInt NumPocLtCurr = 0; |
---|
| 543 | Int i; |
---|
[1313] | 544 | for(i=0; i < m_pRPS->getNumberOfNegativePictures(); i++) |
---|
[622] | 545 | { |
---|
[1313] | 546 | if(m_pRPS->getUsed(i)) |
---|
[622] | 547 | { |
---|
[1313] | 548 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[622] | 549 | pcRefPic->setIsLongTerm(0); |
---|
| 550 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 551 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 552 | NumPocStCurr0++; |
---|
| 553 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 554 | } |
---|
| 555 | } |
---|
| 556 | |
---|
[1313] | 557 | for(; i < m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures(); i++) |
---|
[622] | 558 | { |
---|
[1313] | 559 | if(m_pRPS->getUsed(i)) |
---|
[622] | 560 | { |
---|
[1313] | 561 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pRPS->getDeltaPOC(i)); |
---|
[622] | 562 | pcRefPic->setIsLongTerm(0); |
---|
| 563 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 564 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 565 | NumPocStCurr1++; |
---|
| 566 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 567 | } |
---|
| 568 | } |
---|
| 569 | |
---|
[1313] | 570 | for(i = m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()+m_pRPS->getNumberOfLongtermPictures()-1; i > m_pRPS->getNumberOfNegativePictures()+m_pRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
[622] | 571 | { |
---|
[1313] | 572 | if(m_pRPS->getUsed(i)) |
---|
[622] | 573 | { |
---|
[1313] | 574 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 575 | pcRefPic->setIsLongTerm(1); |
---|
| 576 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 577 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 578 | NumPocLtCurr++; |
---|
| 579 | } |
---|
| 580 | if(pcRefPic==NULL) |
---|
| 581 | { |
---|
[1313] | 582 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pRPS->getPOC(i), m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 583 | } |
---|
[1313] | 584 | pcRefPic->setCheckLTMSBPresent(m_pRPS->getCheckLTMSBPresent(i)); |
---|
[622] | 585 | } |
---|
| 586 | |
---|
| 587 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
| 588 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
| 589 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
| 590 | |
---|
| 591 | if (checkNumPocTotalCurr) |
---|
| 592 | { |
---|
| 593 | // 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: |
---|
| 594 | // - If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 595 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 596 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
| 597 | { |
---|
| 598 | assert(numPocTotalCurr == 0); |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | if (m_eSliceType == I_SLICE) |
---|
| 602 | { |
---|
| 603 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 604 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 605 | |
---|
| 606 | return; |
---|
| 607 | } |
---|
| 608 | |
---|
| 609 | assert(numPocTotalCurr > 0); |
---|
| 610 | |
---|
| 611 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 612 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 613 | } |
---|
| 614 | |
---|
| 615 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
| 616 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
| 617 | |
---|
| 618 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
[1039] | 619 | Int numPocStCurr[2] = { (Int)NumPocStCurr0, (Int)NumPocStCurr1 }; |
---|
[622] | 620 | |
---|
| 621 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
| 622 | { |
---|
| 623 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
| 624 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
| 625 | |
---|
| 626 | Int cIdx = 0; |
---|
| 627 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
| 628 | { |
---|
| 629 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
| 630 | usedAsLongTerm [li][cIdx] = false; |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
| 634 | { |
---|
| 635 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
| 636 | usedAsLongTerm [li][cIdx] = true; |
---|
| 637 | } |
---|
| 638 | |
---|
| 639 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
| 640 | { |
---|
| 641 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
| 642 | usedAsLongTerm [li][cIdx] = false; |
---|
| 643 | } |
---|
| 644 | |
---|
| 645 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 646 | { |
---|
| 647 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
| 648 | usedAsLongTerm [li][cIdx] = true; |
---|
| 649 | } |
---|
| 650 | |
---|
| 651 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
| 652 | { |
---|
| 653 | assert( cIdx < MAX_NUM_REF ); |
---|
| 654 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
| 655 | usedAsLongTerm [li][cIdx] = true; |
---|
| 656 | } |
---|
| 657 | |
---|
| 658 | assert(cIdx == numPocTotalCurr); |
---|
| 659 | } |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
| 663 | |
---|
| 664 | { |
---|
| 665 | if (!checkNumPocTotalCurr) |
---|
| 666 | { |
---|
| 667 | if (m_eSliceType == I_SLICE) |
---|
| 668 | { |
---|
| 669 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 670 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 671 | |
---|
| 672 | return; |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | |
---|
| 676 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 677 | |
---|
| 678 | for (Int li = 0; li < 2; li++) |
---|
| 679 | { |
---|
| 680 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
| 681 | { |
---|
| 682 | m_aiNumRefIdx[1] = 0; |
---|
| 683 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
| 684 | } |
---|
| 685 | else |
---|
| 686 | { |
---|
| 687 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
| 688 | { |
---|
| 689 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
| 690 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
| 691 | |
---|
| 692 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
[1066] | 693 | assert( rpsCurrList[li][ orgIdx ]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
[622] | 694 | m_apcRefPicList [li][rIdx] = rpsCurrList [li][ orgIdx ]; |
---|
| 695 | m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; |
---|
| 696 | } |
---|
| 697 | } |
---|
| 698 | } |
---|
| 699 | } |
---|
| 700 | #endif |
---|
[1313] | 701 | |
---|
[1321] | 702 | |
---|
[1313] | 703 | Int TComSlice::getNumRpsCurrTempList() const |
---|
[608] | 704 | { |
---|
| 705 | Int numRpsCurrTempList = 0; |
---|
| 706 | |
---|
[1313] | 707 | if (m_eSliceType == I_SLICE) |
---|
[608] | 708 | { |
---|
| 709 | return 0; |
---|
| 710 | } |
---|
[1313] | 711 | for(UInt i=0; i < m_pRPS->getNumberOfNegativePictures()+ m_pRPS->getNumberOfPositivePictures() + m_pRPS->getNumberOfLongtermPictures(); i++) |
---|
[608] | 712 | { |
---|
[1313] | 713 | if(m_pRPS->getUsed(i)) |
---|
[608] | 714 | { |
---|
| 715 | numRpsCurrTempList++; |
---|
[2] | 716 | } |
---|
| 717 | } |
---|
[1313] | 718 | #if NH_MV |
---|
[1321] | 719 | numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics(); |
---|
[608] | 720 | #endif |
---|
| 721 | return numRpsCurrTempList; |
---|
[2] | 722 | } |
---|
| 723 | |
---|
| 724 | Void TComSlice::initEqualRef() |
---|
| 725 | { |
---|
[1313] | 726 | for (Int iDir = 0; iDir < NUM_REF_PIC_LIST_01; iDir++) |
---|
[2] | 727 | { |
---|
| 728 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 729 | { |
---|
| 730 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 731 | { |
---|
| 732 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | } |
---|
[1313] | 737 | |
---|
[1179] | 738 | |
---|
[56] | 739 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 740 | { |
---|
| 741 | Int i; |
---|
| 742 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
[1313] | 743 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1 - curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
[56] | 744 | TComSlice* preSlice; |
---|
| 745 | Int preColRefPOC; |
---|
| 746 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 747 | { |
---|
| 748 | preSlice = pic->getSlice(i); |
---|
| 749 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 750 | { |
---|
[1313] | 751 | preColRefPOC = preSlice->getRefPOC( RefPicList(1 - preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
[56] | 752 | if(currColRefPOC != preColRefPOC) |
---|
| 753 | { |
---|
| 754 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 755 | exit(EXIT_FAILURE); |
---|
| 756 | } |
---|
| 757 | else |
---|
| 758 | { |
---|
| 759 | break; |
---|
| 760 | } |
---|
| 761 | } |
---|
| 762 | } |
---|
| 763 | } |
---|
[608] | 764 | |
---|
[1313] | 765 | Void TComSlice::checkCRA(const TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
[56] | 766 | { |
---|
| 767 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 768 | { |
---|
| 769 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 770 | { |
---|
| 771 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 772 | } |
---|
| 773 | } |
---|
| 774 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 775 | { |
---|
| 776 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 777 | { |
---|
[608] | 778 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 779 | { |
---|
| 780 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
| 781 | } |
---|
| 782 | else |
---|
| 783 | { |
---|
[1313] | 784 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 785 | } |
---|
[56] | 786 | } |
---|
| 787 | } |
---|
[608] | 788 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
[56] | 789 | { |
---|
| 790 | pocCRA = getPOC(); |
---|
[655] | 791 | associatedIRAPType = getNalUnitType(); |
---|
[56] | 792 | } |
---|
[608] | 793 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 794 | { |
---|
| 795 | pocCRA = getPOC(); |
---|
[655] | 796 | associatedIRAPType = getNalUnitType(); |
---|
[608] | 797 | } |
---|
| 798 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 799 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 800 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 801 | { |
---|
| 802 | pocCRA = getPOC(); |
---|
[655] | 803 | associatedIRAPType = getNalUnitType(); |
---|
[608] | 804 | } |
---|
[56] | 805 | } |
---|
[2] | 806 | |
---|
[608] | 807 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 808 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
[2] | 809 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 810 | * \param rcListPic reference to the reference picture list |
---|
| 811 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
[1313] | 812 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
[608] | 813 | * are marked as "unused for reference" |
---|
| 814 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 815 | * Otherwise |
---|
[1313] | 816 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
| 817 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 818 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
[2] | 819 | * the bRefreshPending flag to false. |
---|
[1313] | 820 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
[2] | 821 | * reference of the current picture. |
---|
| 822 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 823 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 824 | */ |
---|
[1313] | 825 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, const bool bEfficientFieldIRAPEnabled) |
---|
[2] | 826 | { |
---|
[1313] | 827 | TComPic* rpcPic; |
---|
| 828 | Int pocCurr = getPOC(); |
---|
[2] | 829 | |
---|
[608] | 830 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 831 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 832 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 833 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 834 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
[2] | 835 | { |
---|
| 836 | // mark all pictures as not used for reference |
---|
| 837 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 838 | while (iterPic != rcListPic.end()) |
---|
| 839 | { |
---|
| 840 | rpcPic = *(iterPic); |
---|
| 841 | rpcPic->setCurrSliceIdx(0); |
---|
[1313] | 842 | if (rpcPic->getPOC() != pocCurr) |
---|
| 843 | { |
---|
| 844 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 845 | } |
---|
[2] | 846 | iterPic++; |
---|
| 847 | } |
---|
[608] | 848 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 849 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 850 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 851 | { |
---|
| 852 | pocCRA = pocCurr; |
---|
| 853 | } |
---|
[1313] | 854 | if (bEfficientFieldIRAPEnabled) |
---|
| 855 | { |
---|
[964] | 856 | bRefreshPending = true; |
---|
[1313] | 857 | } |
---|
[2] | 858 | } |
---|
[56] | 859 | else // CRA or No DR |
---|
[2] | 860 | { |
---|
[1313] | 861 | if(bEfficientFieldIRAPEnabled && (getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
[964] | 862 | { |
---|
| 863 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
| 864 | { |
---|
| 865 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 866 | while (iterPic != rcListPic.end()) |
---|
| 867 | { |
---|
| 868 | rpcPic = *(iterPic); |
---|
| 869 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
| 870 | { |
---|
| 871 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 872 | } |
---|
| 873 | iterPic++; |
---|
| 874 | } |
---|
| 875 | bRefreshPending = false; |
---|
| 876 | } |
---|
| 877 | } |
---|
| 878 | else |
---|
| 879 | { |
---|
[1313] | 880 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
[2] | 881 | { |
---|
[1313] | 882 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 883 | while (iterPic != rcListPic.end()) |
---|
[608] | 884 | { |
---|
[1313] | 885 | rpcPic = *(iterPic); |
---|
| 886 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
| 887 | { |
---|
| 888 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 889 | } |
---|
| 890 | iterPic++; |
---|
[608] | 891 | } |
---|
[1313] | 892 | bRefreshPending = false; |
---|
[2] | 893 | } |
---|
| 894 | } |
---|
[608] | 895 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
[2] | 896 | { |
---|
[1313] | 897 | bRefreshPending = true; |
---|
[608] | 898 | pocCRA = pocCurr; |
---|
[2] | 899 | } |
---|
| 900 | } |
---|
| 901 | } |
---|
| 902 | |
---|
| 903 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 904 | { |
---|
| 905 | assert( pSrc != NULL ); |
---|
| 906 | |
---|
| 907 | Int i, j, k; |
---|
| 908 | |
---|
| 909 | m_iPOC = pSrc->m_iPOC; |
---|
[608] | 910 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
[1313] | 911 | #if NH_MV |
---|
[608] | 912 | m_layerId = pSrc->m_layerId; |
---|
| 913 | // GT: Copying of several other values might be be missing here, or is above not necessary? |
---|
[21] | 914 | #endif |
---|
[2] | 915 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 916 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
[56] | 917 | #if ADAPTIVE_QP_SELECTION |
---|
| 918 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 919 | #endif |
---|
[1313] | 920 | m_ChromaQpAdjEnabled = pSrc->m_ChromaQpAdjEnabled; |
---|
[608] | 921 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 922 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 923 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 924 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
[1313] | 925 | |
---|
| 926 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
[2] | 927 | { |
---|
| 928 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 929 | } |
---|
| 930 | |
---|
[608] | 931 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
| 932 | { |
---|
| 933 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
[1313] | 934 | } |
---|
| 935 | |
---|
[608] | 936 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 937 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
[1313] | 938 | for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) |
---|
[2] | 939 | { |
---|
[1313] | 940 | m_iSliceChromaQpDelta[component] = pSrc->m_iSliceChromaQpDelta[component]; |
---|
| 941 | } |
---|
| 942 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
| 943 | { |
---|
[608] | 944 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
[2] | 945 | { |
---|
[608] | 946 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 947 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
[1313] | 948 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
| 949 | #if NH_MV |
---|
[608] | 950 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
| 951 | #endif |
---|
[2] | 952 | } |
---|
[1313] | 953 | m_bIsUsedAsLongTerm[i][MAX_NUM_REF] = pSrc->m_bIsUsedAsLongTerm[i][MAX_NUM_REF]; |
---|
[2] | 954 | } |
---|
| 955 | m_iDepth = pSrc->m_iDepth; |
---|
| 956 | |
---|
| 957 | // referenced slice |
---|
| 958 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 959 | |
---|
| 960 | // access channel |
---|
[1313] | 961 | #if NH_MV |
---|
[608] | 962 | m_pcVPS = pSrc->m_pcVPS; |
---|
| 963 | #endif |
---|
[1321] | 964 | m_pRPS = pSrc->m_pRPS; |
---|
| 965 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
[56] | 966 | |
---|
[2] | 967 | m_pcPic = pSrc->m_pcPic; |
---|
| 968 | |
---|
[608] | 969 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
[56] | 970 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
[1313] | 971 | |
---|
[872] | 972 | setLambdas(pSrc->getLambdas()); |
---|
[1313] | 973 | |
---|
| 974 | for (i = 0; i < NUM_REF_PIC_LIST_01; i++) |
---|
[2] | 975 | { |
---|
| 976 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 977 | { |
---|
| 978 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 979 | { |
---|
| 980 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 981 | } |
---|
| 982 | } |
---|
| 983 | } |
---|
| 984 | |
---|
[56] | 985 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 986 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 987 | |
---|
[1313] | 988 | m_sliceMode = pSrc->m_sliceMode; |
---|
| 989 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
| 990 | m_sliceCurStartCtuTsAddr = pSrc->m_sliceCurStartCtuTsAddr; |
---|
| 991 | m_sliceCurEndCtuTsAddr = pSrc->m_sliceCurEndCtuTsAddr; |
---|
| 992 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
| 993 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
| 994 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
| 995 | m_sliceSegmentCurStartCtuTsAddr = pSrc->m_sliceSegmentCurStartCtuTsAddr; |
---|
| 996 | m_sliceSegmentCurEndCtuTsAddr = pSrc->m_sliceSegmentCurEndCtuTsAddr; |
---|
| 997 | m_nextSlice = pSrc->m_nextSlice; |
---|
| 998 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
| 999 | |
---|
| 1000 | for ( UInt e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[608] | 1001 | { |
---|
[1313] | 1002 | for ( UInt n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
[608] | 1003 | { |
---|
[1313] | 1004 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(WPScalingParam)*MAX_NUM_COMPONENT ); |
---|
[608] | 1005 | } |
---|
| 1006 | } |
---|
[56] | 1007 | |
---|
[1313] | 1008 | for( UInt ch = 0 ; ch < MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 1009 | { |
---|
| 1010 | m_saoEnabledFlag[ch] = pSrc->m_saoEnabledFlag[ch]; |
---|
| 1011 | } |
---|
| 1012 | |
---|
| 1013 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
| 1014 | |
---|
| 1015 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 1016 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
[608] | 1017 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 1018 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
[1313] | 1019 | m_encCABACTableIdx = pSrc->m_encCABACTableIdx; |
---|
[608] | 1020 | |
---|
[1313] | 1021 | #if NH_MV |
---|
[608] | 1022 | // Additional slice header syntax elements |
---|
[622] | 1023 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
[608] | 1024 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
| 1025 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
| 1026 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
| 1027 | |
---|
| 1028 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
| 1029 | { |
---|
| 1030 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
| 1031 | } |
---|
| 1032 | #endif |
---|
[1313] | 1033 | |
---|
[2] | 1034 | } |
---|
| 1035 | |
---|
[608] | 1036 | |
---|
[56] | 1037 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 1038 | * \param uiTLayer Temporal layer ID of the current slice |
---|
[1313] | 1039 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 1040 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
[56] | 1041 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 1042 | */ |
---|
| 1043 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
[2] | 1044 | { |
---|
[56] | 1045 | m_uiTLayer = uiTLayer; |
---|
[2] | 1046 | } |
---|
| 1047 | |
---|
[56] | 1048 | /** Function for checking if this is a switching-point |
---|
| 1049 | */ |
---|
[1313] | 1050 | Bool TComSlice::isTemporalLayerSwitchingPoint(TComList<TComPic*>& rcListPic) |
---|
[2] | 1051 | { |
---|
[56] | 1052 | TComPic* rpcPic; |
---|
| 1053 | // loop through all pictures in the reference picture buffer |
---|
| 1054 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1055 | while ( iterPic != rcListPic.end()) |
---|
| 1056 | { |
---|
| 1057 | rpcPic = *(iterPic++); |
---|
| 1058 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 1059 | { |
---|
| 1060 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1061 | { |
---|
| 1062 | return false; |
---|
| 1063 | } |
---|
| 1064 | } |
---|
| 1065 | } |
---|
| 1066 | return true; |
---|
| 1067 | } |
---|
| 1068 | |
---|
[1313] | 1069 | /** Function for checking if this is a STSA candidate |
---|
[608] | 1070 | */ |
---|
[1313] | 1071 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate(TComList<TComPic*>& rcListPic) |
---|
[608] | 1072 | { |
---|
[1313] | 1073 | TComPic* rpcPic; |
---|
| 1074 | |
---|
| 1075 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1076 | while ( iterPic != rcListPic.end()) |
---|
| 1077 | { |
---|
| 1078 | rpcPic = *(iterPic++); |
---|
| 1079 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
[608] | 1080 | { |
---|
[1313] | 1081 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1082 | { |
---|
| 1083 | return false; |
---|
| 1084 | } |
---|
[608] | 1085 | } |
---|
[1313] | 1086 | } |
---|
| 1087 | return true; |
---|
[608] | 1088 | } |
---|
| 1089 | |
---|
[655] | 1090 | |
---|
| 1091 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
| 1092 | { |
---|
| 1093 | TComPic* rpcPic; |
---|
| 1094 | |
---|
| 1095 | Int nalUnitType = this->getNalUnitType(); |
---|
| 1096 | |
---|
| 1097 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
| 1098 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
| 1099 | { |
---|
| 1100 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
| 1101 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1102 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
| 1103 | { |
---|
| 1104 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1105 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1106 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1107 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1108 | } |
---|
| 1109 | } |
---|
| 1110 | |
---|
| 1111 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
| 1112 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
| 1113 | { |
---|
| 1114 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
| 1115 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
| 1116 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
| 1117 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | // No RASL pictures shall be present in the bitstream that are associated |
---|
| 1121 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
| 1122 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1123 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1124 | { |
---|
| 1125 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
| 1126 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
| 1130 | // an IDR picture. |
---|
| 1131 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1132 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1133 | { |
---|
| 1134 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
| 1135 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
| 1136 | } |
---|
| 1137 | |
---|
| 1138 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
| 1139 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
| 1140 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
| 1141 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1142 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1143 | { |
---|
| 1144 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
| 1145 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
| 1146 | } |
---|
| 1147 | |
---|
| 1148 | // loop through all pictures in the reference picture buffer |
---|
| 1149 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1150 | while ( iterPic != rcListPic.end()) |
---|
| 1151 | { |
---|
| 1152 | rpcPic = *(iterPic++); |
---|
[872] | 1153 | if(!rpcPic->getReconMark()) |
---|
| 1154 | { |
---|
| 1155 | continue; |
---|
| 1156 | } |
---|
[655] | 1157 | if (rpcPic->getPOC() == this->getPOC()) |
---|
| 1158 | { |
---|
| 1159 | continue; |
---|
| 1160 | } |
---|
| 1161 | |
---|
| 1162 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1163 | // in decoding order shall precede the IRAP picture in output order. |
---|
| 1164 | // (Note that any picture following in output order would be present in the DPB) |
---|
[964] | 1165 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
[655] | 1166 | { |
---|
| 1167 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1168 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1169 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1170 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
| 1171 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1172 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
| 1173 | { |
---|
| 1174 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1175 | } |
---|
| 1176 | } |
---|
| 1177 | |
---|
| 1178 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1179 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
| 1180 | // picture in output order. |
---|
| 1181 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
| 1182 | { |
---|
| 1183 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1184 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
| 1185 | { |
---|
| 1186 | // rpcPic precedes the IRAP in decoding order |
---|
| 1187 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1188 | { |
---|
| 1189 | // rpcPic must not be the IRAP picture |
---|
| 1190 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
| 1191 | { |
---|
| 1192 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | } |
---|
| 1196 | } |
---|
| 1197 | |
---|
| 1198 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
| 1199 | // all trailing pictures that are associated with the same IRAP picture. |
---|
[1313] | 1200 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1201 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1202 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1203 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
[655] | 1204 | { |
---|
[1313] | 1205 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
| 1206 | { |
---|
| 1207 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
| 1208 | // rpcPic would violate the constraint if it was a trailing picture |
---|
| 1209 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
| 1210 | } |
---|
[655] | 1211 | } |
---|
| 1212 | |
---|
| 1213 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
| 1214 | // RADL picture associated with the CRA or BLA picture in output order |
---|
| 1215 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1216 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
[1313] | 1217 | { |
---|
[655] | 1218 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1219 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1220 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1221 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
| 1222 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1223 | { |
---|
| 1224 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1225 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1226 | { |
---|
| 1227 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
| 1228 | } |
---|
| 1229 | } |
---|
| 1230 | } |
---|
| 1231 | |
---|
| 1232 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
| 1233 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
| 1234 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1235 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1236 | { |
---|
| 1237 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 1238 | { |
---|
| 1239 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
| 1240 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1241 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1242 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1243 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1244 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
| 1245 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
| 1246 | { |
---|
| 1247 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
| 1248 | } |
---|
| 1249 | } |
---|
| 1250 | } |
---|
| 1251 | } |
---|
| 1252 | } |
---|
| 1253 | |
---|
| 1254 | |
---|
[1313] | 1255 | |
---|
[56] | 1256 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1257 | */ |
---|
[1313] | 1258 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet) |
---|
[56] | 1259 | { |
---|
| 1260 | TComPic* rpcPic; |
---|
| 1261 | Int i, isReference; |
---|
| 1262 | |
---|
[655] | 1263 | checkLeadingPictureRestrictions(rcListPic); |
---|
| 1264 | |
---|
[56] | 1265 | // loop through all pictures in the reference picture buffer |
---|
| 1266 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1267 | while ( iterPic != rcListPic.end()) |
---|
| 1268 | { |
---|
| 1269 | rpcPic = *(iterPic++); |
---|
| 1270 | |
---|
[608] | 1271 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
| 1272 | { |
---|
| 1273 | continue; |
---|
| 1274 | } |
---|
| 1275 | |
---|
[56] | 1276 | isReference = 0; |
---|
[608] | 1277 | // loop through all pictures in the Reference Picture Set |
---|
| 1278 | // to see if the picture should be kept as reference picture |
---|
[56] | 1279 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1280 | { |
---|
| 1281 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1282 | { |
---|
| 1283 | isReference = 1; |
---|
| 1284 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1285 | rpcPic->setIsLongTerm(0); |
---|
| 1286 | } |
---|
| 1287 | } |
---|
| 1288 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1289 | { |
---|
[608] | 1290 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
[56] | 1291 | { |
---|
[608] | 1292 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1293 | { |
---|
| 1294 | isReference = 1; |
---|
| 1295 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1296 | } |
---|
[56] | 1297 | } |
---|
[1313] | 1298 | else |
---|
[608] | 1299 | { |
---|
[655] | 1300 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1301 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1302 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1303 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
[608] | 1304 | { |
---|
| 1305 | isReference = 1; |
---|
| 1306 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1307 | } |
---|
| 1308 | } |
---|
| 1309 | |
---|
[56] | 1310 | } |
---|
[1313] | 1311 | #if NH_MV |
---|
[872] | 1312 | if( isReference ) // Current picture is in the temporal RPS |
---|
| 1313 | { |
---|
| 1314 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
| 1315 | } |
---|
| 1316 | #endif |
---|
[56] | 1317 | // mark the picture as "unused for reference" if it is not in |
---|
| 1318 | // the Reference Picture Set |
---|
[1313] | 1319 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1320 | { |
---|
| 1321 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
[608] | 1322 | rpcPic->setUsedByCurr(0); |
---|
[56] | 1323 | rpcPic->setIsLongTerm(0); |
---|
| 1324 | } |
---|
[608] | 1325 | //check that pictures of higher temporal layers are not used |
---|
| 1326 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1327 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
[872] | 1328 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
[608] | 1329 | { |
---|
| 1330 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1331 | } |
---|
| 1332 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1333 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1334 | { |
---|
| 1335 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1336 | } |
---|
| 1337 | } |
---|
[56] | 1338 | } |
---|
| 1339 | |
---|
| 1340 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1341 | */ |
---|
[1313] | 1342 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
[56] | 1343 | { |
---|
[964] | 1344 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
| 1345 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
[56] | 1346 | TComPic* rpcPic; |
---|
[608] | 1347 | Int i, isAvailable; |
---|
[56] | 1348 | Int atLeastOneLost = 0; |
---|
| 1349 | Int atLeastOneRemoved = 0; |
---|
| 1350 | Int iPocLost = 0; |
---|
| 1351 | |
---|
| 1352 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1353 | // to see if the picture should be kept as reference picture |
---|
| 1354 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1355 | { |
---|
| 1356 | isAvailable = 0; |
---|
| 1357 | // loop through all pictures in the reference picture buffer |
---|
| 1358 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1359 | while ( iterPic != rcListPic.end()) |
---|
| 1360 | { |
---|
| 1361 | rpcPic = *(iterPic++); |
---|
[608] | 1362 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
[56] | 1363 | { |
---|
[608] | 1364 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1365 | { |
---|
[964] | 1366 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1367 | { |
---|
| 1368 | isAvailable = 0; |
---|
| 1369 | } |
---|
| 1370 | else |
---|
| 1371 | { |
---|
[1313] | 1372 | isAvailable = 1; |
---|
| 1373 | } |
---|
[608] | 1374 | } |
---|
[56] | 1375 | } |
---|
[1313] | 1376 | else |
---|
[608] | 1377 | { |
---|
[655] | 1378 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1379 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1380 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1381 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
[608] | 1382 | { |
---|
[964] | 1383 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1384 | { |
---|
| 1385 | isAvailable = 0; |
---|
| 1386 | } |
---|
| 1387 | else |
---|
| 1388 | { |
---|
[1313] | 1389 | isAvailable = 1; |
---|
| 1390 | } |
---|
[608] | 1391 | } |
---|
| 1392 | } |
---|
[56] | 1393 | } |
---|
| 1394 | // if there was no such long-term check the short terms |
---|
| 1395 | if(!isAvailable) |
---|
| 1396 | { |
---|
| 1397 | iterPic = rcListPic.begin(); |
---|
| 1398 | while ( iterPic != rcListPic.end()) |
---|
| 1399 | { |
---|
| 1400 | rpcPic = *(iterPic++); |
---|
| 1401 | |
---|
[608] | 1402 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1403 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
| 1404 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
| 1405 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
[56] | 1406 | { |
---|
[655] | 1407 | curPoc = curPoc & (pocCycle - 1); |
---|
| 1408 | refPoc = refPoc & (pocCycle - 1); |
---|
[608] | 1409 | } |
---|
[1313] | 1410 | |
---|
[608] | 1411 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
| 1412 | { |
---|
[964] | 1413 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1414 | { |
---|
| 1415 | isAvailable = 0; |
---|
| 1416 | } |
---|
| 1417 | else |
---|
| 1418 | { |
---|
[1313] | 1419 | isAvailable = 1; |
---|
| 1420 | rpcPic->setIsLongTerm(1); |
---|
| 1421 | break; |
---|
| 1422 | } |
---|
[2] | 1423 | } |
---|
[56] | 1424 | } |
---|
| 1425 | } |
---|
| 1426 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1427 | // but not available as reference picture |
---|
[1313] | 1428 | if(isAvailable == 0) |
---|
| 1429 | { |
---|
[56] | 1430 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1431 | { |
---|
| 1432 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1433 | { |
---|
[608] | 1434 | if(printErrors) |
---|
| 1435 | { |
---|
[56] | 1436 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1437 | } |
---|
[56] | 1438 | atLeastOneRemoved = 1; |
---|
[2] | 1439 | } |
---|
[56] | 1440 | else |
---|
| 1441 | { |
---|
[608] | 1442 | if(printErrors) |
---|
| 1443 | { |
---|
[56] | 1444 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1445 | } |
---|
[56] | 1446 | atLeastOneLost = 1; |
---|
| 1447 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
[2] | 1448 | } |
---|
| 1449 | } |
---|
[964] | 1450 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
| 1451 | { |
---|
| 1452 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
| 1453 | } |
---|
| 1454 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
| 1455 | { |
---|
| 1456 | atLeastOneFlushedByPreviousIDR = 1; |
---|
| 1457 | } |
---|
[56] | 1458 | } |
---|
[1313] | 1459 | } |
---|
[56] | 1460 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1461 | // to see if the picture should be kept as reference picture |
---|
| 1462 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1463 | { |
---|
| 1464 | isAvailable = 0; |
---|
| 1465 | // loop through all pictures in the reference picture buffer |
---|
| 1466 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1467 | while ( iterPic != rcListPic.end()) |
---|
| 1468 | { |
---|
| 1469 | rpcPic = *(iterPic++); |
---|
| 1470 | |
---|
| 1471 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1472 | { |
---|
[964] | 1473 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
| 1474 | { |
---|
| 1475 | isAvailable = 0; |
---|
| 1476 | } |
---|
| 1477 | else |
---|
| 1478 | { |
---|
[1313] | 1479 | isAvailable = 1; |
---|
| 1480 | } |
---|
[56] | 1481 | } |
---|
| 1482 | } |
---|
| 1483 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1484 | // but not available as reference picture |
---|
[1313] | 1485 | if(isAvailable == 0) |
---|
| 1486 | { |
---|
[56] | 1487 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1488 | { |
---|
| 1489 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1490 | { |
---|
[608] | 1491 | if(printErrors) |
---|
| 1492 | { |
---|
[56] | 1493 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1494 | } |
---|
[56] | 1495 | atLeastOneRemoved = 1; |
---|
| 1496 | } |
---|
| 1497 | else |
---|
| 1498 | { |
---|
[608] | 1499 | if(printErrors) |
---|
| 1500 | { |
---|
[56] | 1501 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1502 | } |
---|
[56] | 1503 | atLeastOneLost = 1; |
---|
| 1504 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1505 | } |
---|
| 1506 | } |
---|
[964] | 1507 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
| 1508 | { |
---|
| 1509 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
[1313] | 1510 | } |
---|
[964] | 1511 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
| 1512 | { |
---|
| 1513 | atLeastOneFlushedByPreviousIDR = 1; |
---|
[1313] | 1514 | } |
---|
[964] | 1515 | } |
---|
[1313] | 1516 | } |
---|
| 1517 | |
---|
[964] | 1518 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
| 1519 | { |
---|
| 1520 | return -1; |
---|
| 1521 | } |
---|
[56] | 1522 | if(atLeastOneLost) |
---|
| 1523 | { |
---|
| 1524 | return iPocLost+1; |
---|
[2] | 1525 | } |
---|
[56] | 1526 | if(atLeastOneRemoved) |
---|
| 1527 | { |
---|
| 1528 | return -2; |
---|
| 1529 | } |
---|
| 1530 | else |
---|
[608] | 1531 | { |
---|
[56] | 1532 | return 0; |
---|
[608] | 1533 | } |
---|
[2] | 1534 | } |
---|
| 1535 | |
---|
[56] | 1536 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1537 | */ |
---|
[1313] | 1538 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, const TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint, const Bool bEfficientFieldIRAPEnabled) |
---|
[56] | 1539 | { |
---|
| 1540 | TComPic* rpcPic; |
---|
| 1541 | Int i, j; |
---|
| 1542 | Int k = 0; |
---|
| 1543 | Int nrOfNegativePictures = 0; |
---|
| 1544 | Int nrOfPositivePictures = 0; |
---|
[1313] | 1545 | TComReferencePictureSet* pLocalRPS = this->getLocalRPS(); |
---|
| 1546 | (*pLocalRPS)=TComReferencePictureSet(); |
---|
[56] | 1547 | |
---|
[1313] | 1548 | Bool irapIsInRPS = false; // Used when bEfficientFieldIRAPEnabled==true |
---|
| 1549 | |
---|
[56] | 1550 | // loop through all pictures in the Reference Picture Set |
---|
| 1551 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1552 | { |
---|
| 1553 | j = 0; |
---|
| 1554 | // loop through all pictures in the reference picture buffer |
---|
| 1555 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1556 | while ( iterPic != rcListPic.end()) |
---|
| 1557 | { |
---|
| 1558 | j++; |
---|
| 1559 | rpcPic = *(iterPic++); |
---|
| 1560 | |
---|
| 1561 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1562 | { |
---|
| 1563 | // This picture exists as a reference picture |
---|
| 1564 | // and should be added to the explicit Reference Picture Set |
---|
[1313] | 1565 | pLocalRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1566 | pLocalRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
| 1567 | if (bEfficientFieldIRAPEnabled) |
---|
[608] | 1568 | { |
---|
[1313] | 1569 | pLocalRPS->setUsed(k, pLocalRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
| 1570 | } |
---|
| 1571 | |
---|
| 1572 | if(pLocalRPS->getDeltaPOC(k) < 0) |
---|
| 1573 | { |
---|
[56] | 1574 | nrOfNegativePictures++; |
---|
[608] | 1575 | } |
---|
[56] | 1576 | else |
---|
[608] | 1577 | { |
---|
[1313] | 1578 | if(bEfficientFieldIRAPEnabled && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
| 1579 | { |
---|
| 1580 | irapIsInRPS = true; |
---|
| 1581 | } |
---|
[56] | 1582 | nrOfPositivePictures++; |
---|
[608] | 1583 | } |
---|
[56] | 1584 | k++; |
---|
| 1585 | } |
---|
| 1586 | } |
---|
| 1587 | } |
---|
[1313] | 1588 | |
---|
[964] | 1589 | Bool useNewRPS = false; |
---|
| 1590 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
[1313] | 1591 | if(bEfficientFieldIRAPEnabled && m_pcPic->isField() && !irapIsInRPS) |
---|
[964] | 1592 | { |
---|
| 1593 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1594 | while ( iterPic != rcListPic.end()) |
---|
| 1595 | { |
---|
| 1596 | rpcPic = *(iterPic++); |
---|
| 1597 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
| 1598 | { |
---|
[1313] | 1599 | pLocalRPS->setDeltaPOC(k, 1); |
---|
| 1600 | pLocalRPS->setUsed(k, true); |
---|
[964] | 1601 | nrOfPositivePictures++; |
---|
| 1602 | k ++; |
---|
| 1603 | useNewRPS = true; |
---|
| 1604 | } |
---|
| 1605 | } |
---|
| 1606 | } |
---|
[1313] | 1607 | pLocalRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1608 | pLocalRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1609 | pLocalRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1610 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
[56] | 1611 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1612 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
[1313] | 1613 | if (!pReferencePictureSet->getInterRPSPrediction() || useNewRPS ) |
---|
[56] | 1614 | { |
---|
[1313] | 1615 | pLocalRPS->setInterRPSPrediction(false); |
---|
| 1616 | pLocalRPS->setNumRefIdc(0); |
---|
[56] | 1617 | } |
---|
| 1618 | else |
---|
| 1619 | { |
---|
| 1620 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1621 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
[1313] | 1622 | const TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
[56] | 1623 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1624 | Int iNewIdc=0; |
---|
[1313] | 1625 | for(i=0; i<= iRefPics; i++) |
---|
[56] | 1626 | { |
---|
| 1627 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1628 | Int iRefIdc = 0; |
---|
[1313] | 1629 | for (j=0; j < pLocalRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
[56] | 1630 | { |
---|
[1313] | 1631 | if ( (deltaPOC + deltaRPS) == pLocalRPS->getDeltaPOC(j)) |
---|
[56] | 1632 | { |
---|
[1313] | 1633 | if (pLocalRPS->getUsed(j)) |
---|
[56] | 1634 | { |
---|
| 1635 | iRefIdc = 1; |
---|
| 1636 | } |
---|
| 1637 | else |
---|
| 1638 | { |
---|
| 1639 | iRefIdc = 2; |
---|
| 1640 | } |
---|
| 1641 | } |
---|
| 1642 | } |
---|
[1313] | 1643 | pLocalRPS->setRefIdc(i, iRefIdc); |
---|
[56] | 1644 | iNewIdc++; |
---|
| 1645 | } |
---|
[1313] | 1646 | pLocalRPS->setInterRPSPrediction(true); |
---|
| 1647 | pLocalRPS->setNumRefIdc(iNewIdc); |
---|
| 1648 | pLocalRPS->setDeltaRPS(deltaRPS); |
---|
| 1649 | pLocalRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
[56] | 1650 | } |
---|
| 1651 | |
---|
[1313] | 1652 | this->setRPS(pLocalRPS); |
---|
[56] | 1653 | this->setRPSidx(-1); |
---|
| 1654 | } |
---|
| 1655 | |
---|
[1313] | 1656 | //! get AC and DC values for weighted pred |
---|
| 1657 | Void TComSlice::getWpAcDcParam(WPACDCParam *&wp) |
---|
[56] | 1658 | { |
---|
| 1659 | wp = m_weightACDCParam; |
---|
| 1660 | } |
---|
| 1661 | |
---|
[1313] | 1662 | //! init AC and DC values for weighted pred |
---|
[56] | 1663 | Void TComSlice::initWpAcDcParam() |
---|
| 1664 | { |
---|
[1313] | 1665 | for(Int iComp = 0; iComp < MAX_NUM_COMPONENT; iComp++ ) |
---|
[56] | 1666 | { |
---|
| 1667 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1668 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1669 | } |
---|
| 1670 | } |
---|
| 1671 | |
---|
[1313] | 1672 | //! get tables for weighted prediction |
---|
| 1673 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, WPScalingParam *&wp ) |
---|
[56] | 1674 | { |
---|
[1313] | 1675 | assert (e<NUM_REF_PIC_LIST_01); |
---|
[56] | 1676 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1677 | } |
---|
| 1678 | |
---|
[1313] | 1679 | //! reset Default WP tables settings : no weight. |
---|
[608] | 1680 | Void TComSlice::resetWpScaling() |
---|
[2] | 1681 | { |
---|
[1313] | 1682 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[56] | 1683 | { |
---|
[608] | 1684 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1685 | { |
---|
[1313] | 1686 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
[56] | 1687 | { |
---|
[1313] | 1688 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
[2] | 1689 | pwp->bPresentFlag = false; |
---|
| 1690 | pwp->uiLog2WeightDenom = 0; |
---|
| 1691 | pwp->uiLog2WeightDenom = 0; |
---|
| 1692 | pwp->iWeight = 1; |
---|
| 1693 | pwp->iOffset = 0; |
---|
| 1694 | } |
---|
[56] | 1695 | } |
---|
[2] | 1696 | } |
---|
| 1697 | } |
---|
| 1698 | |
---|
[1313] | 1699 | //! init WP table |
---|
| 1700 | Void TComSlice::initWpScaling(const TComSPS *sps) |
---|
[2] | 1701 | { |
---|
[1313] | 1702 | const Bool bUseHighPrecisionPredictionWeighting = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag(); |
---|
| 1703 | for ( Int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) |
---|
[56] | 1704 | { |
---|
[608] | 1705 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1706 | { |
---|
[1313] | 1707 | for ( Int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) |
---|
[56] | 1708 | { |
---|
[1313] | 1709 | WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1710 | if ( !pwp->bPresentFlag ) |
---|
[608] | 1711 | { |
---|
[2] | 1712 | // Inferring values not present : |
---|
| 1713 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1714 | pwp->iOffset = 0; |
---|
| 1715 | } |
---|
| 1716 | |
---|
[1313] | 1717 | const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8)); |
---|
| 1718 | |
---|
[2] | 1719 | pwp->w = pwp->iWeight; |
---|
[1313] | 1720 | pwp->o = pwp->iOffset * offsetScalingFactor; //NOTE: This value of the ".o" variable is never used - .o is set immediately before it gets used |
---|
[2] | 1721 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1722 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1723 | } |
---|
[56] | 1724 | } |
---|
[2] | 1725 | } |
---|
| 1726 | } |
---|
| 1727 | |
---|
[608] | 1728 | // ------------------------------------------------------------------------------------------------ |
---|
| 1729 | // Video parameter set (VPS) |
---|
| 1730 | // ------------------------------------------------------------------------------------------------ |
---|
| 1731 | TComVPS::TComVPS() |
---|
| 1732 | : m_VPSId ( 0) |
---|
| 1733 | , m_uiMaxTLayers ( 1) |
---|
[1313] | 1734 | #if NH_MV |
---|
[622] | 1735 | , m_uiMaxLayersMinus1 ( 0) |
---|
| 1736 | #else |
---|
[608] | 1737 | , m_uiMaxLayers ( 1) |
---|
[622] | 1738 | #endif |
---|
[608] | 1739 | , m_bTemporalIdNestingFlag (false) |
---|
| 1740 | , m_numHrdParameters ( 0) |
---|
[1313] | 1741 | #if NH_MV |
---|
[608] | 1742 | , m_maxLayerId ( 0) |
---|
| 1743 | #else |
---|
| 1744 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
| 1745 | #endif |
---|
[1313] | 1746 | , m_hrdParameters () |
---|
| 1747 | , m_hrdOpSetIdx () |
---|
| 1748 | , m_cprmsPresentFlag () |
---|
[2] | 1749 | { |
---|
[1313] | 1750 | #if NH_MV |
---|
[964] | 1751 | m_vpsBaseLayerInternalFlag = true; |
---|
[1066] | 1752 | m_vpsBaseLayerAvailableFlag = true; |
---|
[1124] | 1753 | |
---|
| 1754 | m_numViews = 0; |
---|
[964] | 1755 | |
---|
[1124] | 1756 | #endif |
---|
| 1757 | |
---|
[608] | 1758 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
[56] | 1759 | { |
---|
[608] | 1760 | m_numReorderPics[i] = 0; |
---|
[1313] | 1761 | m_uiMaxDecPicBuffering[i] = 1; |
---|
[608] | 1762 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1763 | } |
---|
[1313] | 1764 | #if NH_MV |
---|
[608] | 1765 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
| 1766 | { |
---|
| 1767 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
[56] | 1768 | { |
---|
[738] | 1769 | m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; |
---|
[56] | 1770 | } |
---|
[608] | 1771 | } |
---|
| 1772 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
| 1773 | |
---|
[964] | 1774 | m_numAddLayerSets = 0; |
---|
| 1775 | m_numAddOlss = 0; |
---|
| 1776 | m_defaultOutputLayerIdc = 0; |
---|
[608] | 1777 | |
---|
| 1778 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
| 1779 | { |
---|
[964] | 1780 | m_layerSetIdxForOlsMinus1[i] = -1; |
---|
[608] | 1781 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
| 1782 | { |
---|
[1066] | 1783 | m_profileTierLevelIdx[i][j] = -1; |
---|
[608] | 1784 | m_outputLayerFlag[i][j] = false; |
---|
| 1785 | } |
---|
[872] | 1786 | m_altOutputLayerFlag[ i ] = false; |
---|
[608] | 1787 | } |
---|
[964] | 1788 | |
---|
| 1789 | m_repFormatIdxPresentFlag = false; |
---|
[608] | 1790 | m_maxOneActiveRefLayerFlag = false; |
---|
[1124] | 1791 | m_vpsPocLsbAlignedFlag = false; |
---|
[608] | 1792 | m_directDepTypeLenMinus2 = 0; |
---|
| 1793 | |
---|
| 1794 | |
---|
[964] | 1795 | m_vpsExtensionFlag = true; |
---|
[872] | 1796 | m_vpsNonVuiExtensionLength = 0; |
---|
[608] | 1797 | m_splittingFlag = false; |
---|
[1124] | 1798 | |
---|
[608] | 1799 | |
---|
| 1800 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
| 1801 | { |
---|
[622] | 1802 | m_scalabilityMaskFlag[i] = false; |
---|
[608] | 1803 | m_dimensionIdLen [i] = -1; |
---|
| 1804 | } |
---|
| 1805 | |
---|
| 1806 | m_vpsNuhLayerIdPresentFlag = false; |
---|
| 1807 | |
---|
| 1808 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
| 1809 | { |
---|
| 1810 | m_vpsProfilePresentFlag [i] = false; |
---|
[964] | 1811 | m_layerSetIdxForOlsMinus1 [i] = 0; |
---|
[608] | 1812 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
| 1813 | { |
---|
| 1814 | m_outputLayerFlag[i][j] = false; |
---|
| 1815 | } |
---|
| 1816 | } |
---|
| 1817 | |
---|
| 1818 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
| 1819 | { |
---|
| 1820 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
| 1821 | } |
---|
| 1822 | |
---|
| 1823 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 1824 | { |
---|
| 1825 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
| 1826 | m_numDirectRefLayers[i] = 0; |
---|
[622] | 1827 | m_vpsRepFormatIdx [i] = 0; |
---|
[1313] | 1828 | m_pocLsbNotPresentFlag[i] = 0; |
---|
[622] | 1829 | m_viewIdVal [i] = 0; |
---|
| 1830 | |
---|
[608] | 1831 | |
---|
| 1832 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
| 1833 | { |
---|
| 1834 | m_directDependencyFlag[i][j] = false; |
---|
| 1835 | m_directDependencyType[i][j] = -1; |
---|
[1066] | 1836 | m_dependencyFlag [i][j] = false; |
---|
| 1837 | m_idDirectRefLayer[i][j] = -1; |
---|
| 1838 | m_idPredictedLayer[i][j] = -1; |
---|
| 1839 | m_idRefLayer [i][j] = -1; |
---|
[738] | 1840 | m_maxTidIlRefPicsPlus1[i][j] = 7; |
---|
[608] | 1841 | } |
---|
| 1842 | |
---|
| 1843 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
| 1844 | { |
---|
| 1845 | m_dimensionId[i][j] = 0; |
---|
| 1846 | } |
---|
[1313] | 1847 | } |
---|
[1124] | 1848 | #endif |
---|
[56] | 1849 | } |
---|
[608] | 1850 | |
---|
| 1851 | TComVPS::~TComVPS() |
---|
[56] | 1852 | { |
---|
[608] | 1853 | } |
---|
| 1854 | |
---|
[1313] | 1855 | #if NH_MV |
---|
[608] | 1856 | |
---|
| 1857 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
| 1858 | { |
---|
[622] | 1859 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
[608] | 1860 | { |
---|
| 1861 | // check layer_id_in_nuh constraint |
---|
| 1862 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
| 1863 | } |
---|
[964] | 1864 | |
---|
| 1865 | //The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
| 1866 | assert( getVpsNumRepFormatsMinus1() >= 0 ); |
---|
| 1867 | assert( getVpsNumRepFormatsMinus1() <= 255 ); |
---|
| 1868 | |
---|
[1066] | 1869 | // The value of num_add_layer_sets shall be in the range of 0 to 1023, inclusive. |
---|
| 1870 | assert( getNumAddLayerSets() >= 0 && getNumAddLayerSets() <= 1023 ); |
---|
[608] | 1871 | return true; |
---|
[56] | 1872 | } |
---|
[608] | 1873 | |
---|
[1313] | 1874 | Int TComVPS::getNumScalabilityTypes() const |
---|
[2] | 1875 | { |
---|
[608] | 1876 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
| 1877 | } |
---|
| 1878 | |
---|
[1313] | 1879 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const |
---|
[608] | 1880 | { |
---|
[1313] | 1881 | assert( (Int)scalType >= 0 && (Int)scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
| 1882 | assert( (Int)scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
[608] | 1883 | Int scalIdx = 0; |
---|
| 1884 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
[2] | 1885 | { |
---|
[622] | 1886 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
| 1887 | |
---|
[2] | 1888 | } |
---|
[608] | 1889 | |
---|
| 1890 | return scalIdx; |
---|
[2] | 1891 | } |
---|
[622] | 1892 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
| 1893 | { |
---|
| 1894 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
| 1895 | { |
---|
| 1896 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
| 1897 | } |
---|
| 1898 | } |
---|
[189] | 1899 | |
---|
[608] | 1900 | Void TComVPS::setRefLayers() |
---|
| 1901 | { |
---|
[1066] | 1902 | |
---|
| 1903 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 1904 | { |
---|
| 1905 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
| 1906 | { |
---|
| 1907 | m_dependencyFlag[ i ][ j ] = getDirectDependencyFlag( i , j ); |
---|
| 1908 | for( Int k = 0; k < i; k++ ) |
---|
| 1909 | { |
---|
| 1910 | if( getDirectDependencyFlag(i , k ) && m_dependencyFlag[k][j] ) |
---|
| 1911 | { |
---|
| 1912 | m_dependencyFlag[ i ][ j ] = true; |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | } |
---|
| 1916 | } |
---|
| 1917 | |
---|
| 1918 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 1919 | { |
---|
| 1920 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
| 1921 | Int d = 0; |
---|
| 1922 | Int r = 0; |
---|
| 1923 | Int p = 0; |
---|
[1124] | 1924 | |
---|
[1066] | 1925 | for( Int j = 0; j <= getMaxLayersMinus1(); j++ ) |
---|
| 1926 | { |
---|
| 1927 | Int jNuhLid = getLayerIdInNuh( j ); |
---|
| 1928 | if( getDirectDependencyFlag( i , j ) ) |
---|
| 1929 | { |
---|
| 1930 | m_idDirectRefLayer[iNuhLId][d++] = jNuhLid; |
---|
| 1931 | } |
---|
[1124] | 1932 | |
---|
[1066] | 1933 | if( getDependencyFlag( i , j ) ) |
---|
| 1934 | { |
---|
| 1935 | m_idRefLayer [iNuhLId][r++] = jNuhLid; |
---|
| 1936 | } |
---|
| 1937 | if( getDependencyFlag( j , i ) ) |
---|
| 1938 | { |
---|
| 1939 | m_idPredictedLayer[iNuhLId][p++] = jNuhLid; |
---|
| 1940 | } |
---|
| 1941 | } |
---|
| 1942 | m_numDirectRefLayers[ iNuhLId ] = d; |
---|
[1124] | 1943 | |
---|
[1066] | 1944 | m_numRefLayers [ iNuhLId ] = r; |
---|
| 1945 | m_numPredictedLayers[ iNuhLId ] = p; |
---|
| 1946 | } |
---|
| 1947 | |
---|
| 1948 | Bool layerIdInListFlag[ 64 ]; |
---|
| 1949 | for( Int i = 0; i <= 63; i++ ) |
---|
| 1950 | { |
---|
| 1951 | layerIdInListFlag[ i ] = 0; |
---|
| 1952 | } |
---|
| 1953 | |
---|
| 1954 | Int k = 0; |
---|
| 1955 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 1956 | { |
---|
| 1957 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
| 1958 | if( getNumDirectRefLayers( iNuhLId ) == 0 ) |
---|
| 1959 | { |
---|
| 1960 | m_treePartitionLayerIdList[ k ][ 0 ] = iNuhLId; |
---|
| 1961 | Int h = 1; |
---|
| 1962 | for( Int j = 0; j < getNumPredictedLayers( iNuhLId ); j++ ) |
---|
| 1963 | { |
---|
| 1964 | Int predLId = getIdPredictedLayer( iNuhLId, j ); |
---|
| 1965 | if ( !layerIdInListFlag[ predLId ] ) |
---|
| 1966 | { |
---|
| 1967 | m_treePartitionLayerIdList[ k ][ h++ ] = predLId; |
---|
| 1968 | layerIdInListFlag[ predLId ] = 1; |
---|
| 1969 | } |
---|
| 1970 | } |
---|
| 1971 | m_numLayersInTreePartition[ k++ ] = h; |
---|
| 1972 | } |
---|
| 1973 | } |
---|
| 1974 | m_numIndependentLayers = k; |
---|
[622] | 1975 | } |
---|
| 1976 | |
---|
| 1977 | |
---|
[1124] | 1978 | Void TComVPS::initNumViews( ) |
---|
| 1979 | { |
---|
| 1980 | m_numViews = 1; |
---|
| 1981 | |
---|
| 1982 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 1983 | { |
---|
| 1984 | Int lId = getLayerIdInNuh( i ); |
---|
| 1985 | if( i > 0 ) |
---|
| 1986 | { |
---|
| 1987 | Bool newViewFlag = true; |
---|
| 1988 | for( Int j = 0; j < i; j++ ) |
---|
| 1989 | { |
---|
| 1990 | if( getViewOrderIdx( lId ) == getViewOrderIdx( getLayerIdInNuh( j ) ) ) |
---|
| 1991 | { |
---|
| 1992 | newViewFlag = false; |
---|
| 1993 | } |
---|
| 1994 | } |
---|
| 1995 | if( newViewFlag ) |
---|
| 1996 | { |
---|
| 1997 | m_numViews++; |
---|
| 1998 | } |
---|
| 1999 | } |
---|
| 2000 | } |
---|
| 2001 | } |
---|
| 2002 | |
---|
| 2003 | |
---|
[1313] | 2004 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) const |
---|
[622] | 2005 | { |
---|
| 2006 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
| 2007 | } |
---|
| 2008 | |
---|
| 2009 | |
---|
[758] | 2010 | |
---|
[1313] | 2011 | Int TComVPS::xGetDimBitOffset( Int j ) const |
---|
[608] | 2012 | { |
---|
| 2013 | Int dimBitOffset = 0; |
---|
| 2014 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
| 2015 | { |
---|
| 2016 | dimBitOffset = 6; |
---|
| 2017 | } |
---|
[443] | 2018 | else |
---|
| 2019 | { |
---|
[608] | 2020 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
[443] | 2021 | { |
---|
[608] | 2022 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
[443] | 2023 | } |
---|
| 2024 | } |
---|
[608] | 2025 | return dimBitOffset; |
---|
[443] | 2026 | } |
---|
[608] | 2027 | |
---|
[1313] | 2028 | Int TComVPS::inferDimensionId( Int i, Int j ) const |
---|
[210] | 2029 | { |
---|
[608] | 2030 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
[210] | 2031 | } |
---|
| 2032 | |
---|
[1313] | 2033 | Int TComVPS::inferLastDimsionIdLenMinus1() const |
---|
[210] | 2034 | { |
---|
[608] | 2035 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
[210] | 2036 | } |
---|
[608] | 2037 | |
---|
[1313] | 2038 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) const |
---|
[77] | 2039 | { |
---|
[608] | 2040 | assert( lsIdx >= 0 ); |
---|
[1066] | 2041 | assert( lsIdx <= getNumLayerSets() ); |
---|
[738] | 2042 | return (Int) m_layerSetLayerIdList[ lsIdx ].size(); |
---|
[77] | 2043 | } |
---|
[738] | 2044 | |
---|
[1313] | 2045 | Int TComVPS::getNumOutputLayerSets() const |
---|
[738] | 2046 | { |
---|
[964] | 2047 | return getNumAddOlss() + getNumLayerSets(); |
---|
[738] | 2048 | } |
---|
| 2049 | |
---|
[622] | 2050 | |
---|
| 2051 | |
---|
[738] | 2052 | Void TComVPS::deriveLayerSetLayerIdList() |
---|
| 2053 | { |
---|
| 2054 | m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); |
---|
| 2055 | for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ ) |
---|
| 2056 | { |
---|
| 2057 | for( Int m = 0; m <= getVpsMaxLayerId(); m++ ) |
---|
| 2058 | { |
---|
| 2059 | if( getLayerIdIncludedFlag( i, m) ) |
---|
| 2060 | { |
---|
| 2061 | m_layerSetLayerIdList[ i ].push_back( m ); |
---|
| 2062 | } |
---|
| 2063 | } |
---|
| 2064 | } |
---|
| 2065 | } |
---|
| 2066 | |
---|
[872] | 2067 | Void TComVPS::initTargetLayerIdLists() |
---|
| 2068 | { |
---|
| 2069 | m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
| 2070 | m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); |
---|
| 2071 | } |
---|
| 2072 | |
---|
| 2073 | Void TComVPS::deriveTargetLayerIdList( Int i ) |
---|
| 2074 | { |
---|
[964] | 2075 | Int lsIdx = olsIdxToLsIdx( i ); |
---|
[1066] | 2076 | |
---|
[872] | 2077 | for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ ) |
---|
| 2078 | { |
---|
[1066] | 2079 | if ( getNecessaryLayerFlag( i , j )) |
---|
| 2080 | { |
---|
| 2081 | m_targetDecLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
| 2082 | } |
---|
| 2083 | |
---|
[872] | 2084 | if( getOutputLayerFlag( i, j )) |
---|
| 2085 | { |
---|
| 2086 | m_targetOptLayerIdLists[i].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); |
---|
| 2087 | } |
---|
| 2088 | } |
---|
[964] | 2089 | assert( getNumOutputLayersInOutputLayerSet( i ) > 0 ); |
---|
[872] | 2090 | } |
---|
[884] | 2091 | |
---|
[1313] | 2092 | Bool TComVPS::inferOutputLayerFlag( Int i, Int j ) const |
---|
[738] | 2093 | { |
---|
[884] | 2094 | Bool outputLayerFlag; |
---|
[964] | 2095 | switch ( getDefaultOutputLayerIdc( ) ) |
---|
[738] | 2096 | { |
---|
[884] | 2097 | case 0: |
---|
| 2098 | outputLayerFlag = true; |
---|
| 2099 | break; |
---|
| 2100 | case 1: |
---|
[964] | 2101 | outputLayerFlag = ( j == m_layerSetLayerIdList[ olsIdxToLsIdx( i ) ].size() - 1 ); |
---|
[884] | 2102 | break; |
---|
| 2103 | case 2: |
---|
| 2104 | if ( i == 0 && j == 0) |
---|
| 2105 | { |
---|
| 2106 | outputLayerFlag = true; // This is a software only fix for a bug in the spec. In spec outputLayerFlag is neither present nor inferred. |
---|
| 2107 | } |
---|
| 2108 | else |
---|
[738] | 2109 | { |
---|
[884] | 2110 | assert( 0 ); |
---|
| 2111 | } |
---|
| 2112 | break; |
---|
| 2113 | default: |
---|
| 2114 | assert( 0 ); |
---|
| 2115 | break; |
---|
[738] | 2116 | } |
---|
[884] | 2117 | return outputLayerFlag; |
---|
[738] | 2118 | } |
---|
[872] | 2119 | |
---|
[1313] | 2120 | Int TComVPS::getMaxSubLayersInLayerSetMinus1( Int i ) const |
---|
[884] | 2121 | { |
---|
| 2122 | Int maxSLMinus1 = 0; |
---|
[964] | 2123 | for( Int k = 0; k < getNumLayersInIdList( i ); k++ ) |
---|
| 2124 | { |
---|
| 2125 | Int lId = m_layerSetLayerIdList[i][k]; |
---|
[884] | 2126 | maxSLMinus1 = std::max( maxSLMinus1, getSubLayersVpsMaxMinus1( getLayerIdInVps( lId ) )); |
---|
| 2127 | } |
---|
| 2128 | return maxSLMinus1; |
---|
| 2129 | } |
---|
[976] | 2130 | |
---|
[1313] | 2131 | Bool TComVPS::getAltOutputLayerFlagVar( Int i ) const |
---|
[976] | 2132 | { |
---|
| 2133 | // Semantics variable not syntax element ! |
---|
| 2134 | |
---|
| 2135 | Bool altOptLayerFlag = false; |
---|
| 2136 | if ( i > 0 && getNumOutputLayersInOutputLayerSet( i ) == 1 && |
---|
| 2137 | getNumDirectRefLayers( getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
| 2138 | { |
---|
| 2139 | altOptLayerFlag = getAltOutputLayerFlag( i ); |
---|
| 2140 | } |
---|
| 2141 | return altOptLayerFlag; |
---|
| 2142 | } |
---|
| 2143 | |
---|
| 2144 | |
---|
| 2145 | |
---|
[1313] | 2146 | Int TComVPS::inferProfileTierLevelIdx(Int i, Int j) const |
---|
[1066] | 2147 | { |
---|
| 2148 | Bool inferZero = ( i == 0 && j == 0 && getVpsBaseLayerInternalFlag() ); |
---|
| 2149 | Bool inferGreaterZero = getNecessaryLayerFlag(i,j) && ( getVpsNumProfileTierLevelMinus1() == 0 ); |
---|
| 2150 | assert( inferZero || inferGreaterZero ); |
---|
| 2151 | |
---|
| 2152 | Bool ptlIdx = 0; // inference for greaterZero |
---|
| 2153 | if ( inferZero ) |
---|
| 2154 | { |
---|
| 2155 | ptlIdx = getMaxLayersMinus1() > 0 ? 1 : 0; |
---|
| 2156 | if ( inferGreaterZero ) |
---|
| 2157 | { |
---|
| 2158 | assert( ptlIdx == 0 ); |
---|
| 2159 | // This should never happen since : |
---|
| 2160 | // When vps_max_layers_minus1 is greater than 0, the value of vps_num_profile_tier_level_minus1 shall be greater than or equal to 1. |
---|
| 2161 | } |
---|
| 2162 | } |
---|
| 2163 | return ptlIdx; |
---|
| 2164 | } |
---|
| 2165 | |
---|
| 2166 | Void TComVPS::deriveAddLayerSetLayerIdList(Int i) |
---|
| 2167 | { |
---|
| 2168 | assert( m_layerSetLayerIdList.size() == ( getVpsNumLayerSetsMinus1() + 1 + i ) ); |
---|
| 2169 | std::vector<Int> layerSetLayerIdList; |
---|
| 2170 | |
---|
| 2171 | for( Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++ ) |
---|
| 2172 | { |
---|
| 2173 | // The value of highest_layer_idx_plus1[ i ][ j ] shall be in the range of 0 to NumLayersInTreePartition[ j ], inclusive. |
---|
| 2174 | assert( getHighestLayerIdxPlus1( i, treeIdx ) >= 0 && getHighestLayerIdxPlus1( i, treeIdx ) <= getNumLayersInTreePartition( treeIdx ) ); |
---|
| 2175 | |
---|
| 2176 | for( Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1( i, treeIdx ); layerCnt++ ) |
---|
| 2177 | { |
---|
| 2178 | layerSetLayerIdList.push_back( getTreePartitionLayerIdList( treeIdx, layerCnt ) ); |
---|
| 2179 | } |
---|
| 2180 | } |
---|
| 2181 | m_layerSetLayerIdList.push_back( layerSetLayerIdList ); |
---|
| 2182 | |
---|
| 2183 | //It is a requirement of bitstream conformance that |
---|
| 2184 | //NumLayersInIdList[ vps_num_layer_sets_minus1 + 1 + i ] shall be greater than 0. |
---|
| 2185 | assert( getNumLayersInIdList( getVpsNumLayerSetsMinus1() + 1 + i ) > 0 ); |
---|
| 2186 | } |
---|
| 2187 | |
---|
| 2188 | |
---|
| 2189 | Void TComVPS::deriveNecessaryLayerFlags(Int olsIdx) |
---|
| 2190 | { |
---|
| 2191 | AOF( olsIdx >= 0 && olsIdx < getNumOutputLayerSets() ); |
---|
| 2192 | Int lsIdx = olsIdxToLsIdx( olsIdx ); |
---|
| 2193 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx) ; lsLayerIdx++ ) |
---|
| 2194 | { |
---|
| 2195 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 0; |
---|
| 2196 | } |
---|
| 2197 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
| 2198 | { |
---|
| 2199 | if( getOutputLayerFlag( olsIdx, lsLayerIdx )) |
---|
| 2200 | { |
---|
| 2201 | m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ] = 1; |
---|
| 2202 | Int currLayerId = getLayerSetLayerIdList( lsIdx, lsLayerIdx ); |
---|
| 2203 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
| 2204 | { |
---|
| 2205 | Int refLayerId = getLayerSetLayerIdList( lsIdx, rLsLayerIdx ); |
---|
| 2206 | if( getDependencyFlag( getLayerIdInVps( currLayerId ), getLayerIdInVps( refLayerId ) ) ) |
---|
| 2207 | { |
---|
| 2208 | m_necessaryLayerFlag[ olsIdx ][ rLsLayerIdx ] = 1; |
---|
| 2209 | } |
---|
| 2210 | } |
---|
| 2211 | } |
---|
| 2212 | } |
---|
| 2213 | m_numNecessaryLayers[ olsIdx ] = 0; |
---|
| 2214 | for( Int lsLayerIdx = 0; lsLayerIdx < getNumLayersInIdList( lsIdx ); lsLayerIdx++ ) |
---|
| 2215 | { |
---|
| 2216 | m_numNecessaryLayers[ olsIdx ] += m_necessaryLayerFlag[ olsIdx ][ lsLayerIdx ]; |
---|
| 2217 | } |
---|
| 2218 | } |
---|
| 2219 | |
---|
[1313] | 2220 | Void TComVPS::printPTL() const |
---|
[1066] | 2221 | { |
---|
| 2222 | std::vector<Int> idx; |
---|
| 2223 | std::vector<Int> num; |
---|
[1313] | 2224 | IntAry2d ptlInfo; |
---|
[1066] | 2225 | |
---|
| 2226 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; |
---|
| 2227 | |
---|
| 2228 | for ( Int i = 0; i <= getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 2229 | { |
---|
| 2230 | std::vector<Int> curPtlInfo; |
---|
[1313] | 2231 | const ProfileTierLevel* ptl = getPTL( i )->getGeneralPTL(); |
---|
[1066] | 2232 | curPtlInfo.push_back( (Int) ptl->getProfileIdc() ); |
---|
| 2233 | curPtlInfo.push_back( (Int) ptl->getTierFlag() ); |
---|
| 2234 | curPtlInfo.push_back( (Int) ptl->getLevelIdc() ); |
---|
| 2235 | curPtlInfo.push_back( (Int) ptl->getInbldFlag() ); |
---|
| 2236 | |
---|
| 2237 | idx.push_back ( i ); |
---|
| 2238 | num.push_back ( 4 ); |
---|
| 2239 | ptlInfo.push_back( curPtlInfo ); |
---|
| 2240 | } |
---|
| 2241 | |
---|
| 2242 | xPrintArray( "VpsProfileTierLevel", getVpsNumProfileTierLevelMinus1() + 1, idx, num, ptlInfo, false ); |
---|
| 2243 | |
---|
| 2244 | num.clear(); |
---|
| 2245 | idx.clear(); |
---|
| 2246 | for (Int i = 0; i < getNumOutputLayerSets(); i++) |
---|
| 2247 | { |
---|
| 2248 | num.push_back ( getNumLayersInIdList( olsIdxToLsIdx( i )) ); |
---|
| 2249 | idx.push_back( i ); |
---|
| 2250 | } |
---|
| 2251 | |
---|
| 2252 | xPrintArray( "profile_tier_level_idx", getNumOutputLayerSets(), idx, num, m_profileTierLevelIdx, true ); |
---|
| 2253 | std::cout << std::endl; |
---|
| 2254 | } |
---|
| 2255 | |
---|
[1313] | 2256 | Void TComVPS::printLayerDependencies() const |
---|
[1066] | 2257 | { |
---|
| 2258 | vector<Int> fullArray; |
---|
| 2259 | vector<Int> range; |
---|
| 2260 | |
---|
| 2261 | |
---|
| 2262 | vector<Int> viewOrderIndex; |
---|
| 2263 | vector<Int> auxId; |
---|
| 2264 | vector<Int> dependencyId; |
---|
| 2265 | vector<Int> viewId; |
---|
| 2266 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 2267 | { |
---|
| 2268 | fullArray.push_back( getMaxLayersMinus1() + 1 ); |
---|
| 2269 | range.push_back( i ); |
---|
| 2270 | viewOrderIndex.push_back( getViewIndex ( i ) ); |
---|
| 2271 | dependencyId .push_back( getDependencyId( i ) ); |
---|
| 2272 | auxId .push_back( getAuxId ( i ) ); |
---|
| 2273 | viewId .push_back( getViewId ( getLayerIdInNuh( i ) ) ); |
---|
| 2274 | } |
---|
| 2275 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Dependencies" << std::endl; |
---|
| 2276 | xPrintArray( "direct_dependency_flag", getMaxLayersMinus1()+1, range, fullArray, m_directDependencyFlag, false ); |
---|
| 2277 | xPrintArray( "DependencyFlag", getMaxLayersMinus1()+1, range, fullArray, m_dependencyFlag, false ); |
---|
| 2278 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, true ); |
---|
| 2279 | xPrintArray( "IdPredictedLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numPredictedLayers, m_idPredictedLayer, true ); |
---|
| 2280 | xPrintArray( "IdRefLayer" , getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numRefLayers, m_idRefLayer, true ); |
---|
| 2281 | xPrintArray( "IdDirectRefLayer", getMaxLayersMinus1() + 1, m_layerIdInNuh, m_numDirectRefLayers, m_idDirectRefLayer, true ); |
---|
[1124] | 2282 | |
---|
[1066] | 2283 | std::cout << std::endl; |
---|
| 2284 | } |
---|
| 2285 | |
---|
[1313] | 2286 | Void TComVPS::printScalabilityId() const |
---|
[1066] | 2287 | { |
---|
| 2288 | vector<Int> layerIdxInVps; |
---|
| 2289 | |
---|
[1313] | 2290 | |
---|
[1066] | 2291 | vector<Int> depthId; |
---|
| 2292 | vector<Int> viewOrderIndex; |
---|
| 2293 | vector<Int> auxId; |
---|
| 2294 | vector<Int> dependencyId; |
---|
| 2295 | vector<Int> viewId; |
---|
| 2296 | |
---|
| 2297 | for (Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 2298 | { |
---|
| 2299 | Int layerIdInNuh = getLayerIdInNuh( i ); |
---|
| 2300 | layerIdxInVps .push_back( i ); |
---|
[1313] | 2301 | depthId .push_back( getDepthId ( layerIdInNuh ) ); |
---|
[1066] | 2302 | viewOrderIndex.push_back( getViewIndex ( layerIdInNuh ) ); |
---|
| 2303 | dependencyId .push_back( getDependencyId( layerIdInNuh ) ); |
---|
| 2304 | auxId .push_back( getAuxId ( layerIdInNuh ) ); |
---|
| 2305 | viewId .push_back( getViewId ( layerIdInNuh ) ); |
---|
[1313] | 2306 | |
---|
[1066] | 2307 | } |
---|
| 2308 | |
---|
| 2309 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Scalability Ids" << std::endl; |
---|
| 2310 | xPrintArray( "layerIdxInVps" , getMaxLayersMinus1()+1, layerIdxInVps, false ); |
---|
| 2311 | xPrintArray( "layer_id_in_nuh", getMaxLayersMinus1()+1, m_layerIdInNuh, false ); |
---|
| 2312 | |
---|
[1313] | 2313 | xPrintArray( "DepthLayerFlag", getMaxLayersMinus1()+1, depthId , false ); |
---|
| 2314 | xPrintArray( "ViewOrderIdx" , getMaxLayersMinus1()+1, viewOrderIndex, false ); |
---|
[1066] | 2315 | xPrintArray( "DependencyId" , getMaxLayersMinus1()+1, dependencyId , false ); |
---|
| 2316 | xPrintArray( "AuxId" , getMaxLayersMinus1()+1, auxId , false ); |
---|
[1313] | 2317 | xPrintArray( "ViewIdVal" , getMaxLayersMinus1()+1, viewId , false ); |
---|
[1066] | 2318 | |
---|
| 2319 | std::cout << std::endl; |
---|
| 2320 | } |
---|
| 2321 | |
---|
[1313] | 2322 | Void TComVPS::printLayerSets() const |
---|
[1066] | 2323 | { |
---|
| 2324 | vector<Int> fullArray; |
---|
| 2325 | vector<Int> numLayersInIdList; |
---|
| 2326 | vector<Int> rangeLayerSets; |
---|
| 2327 | |
---|
| 2328 | |
---|
| 2329 | for (Int i = 0; i < getNumLayerSets(); i++ ) |
---|
| 2330 | { |
---|
| 2331 | numLayersInIdList.push_back( getNumLayersInIdList( i ) ); |
---|
| 2332 | rangeLayerSets.push_back( i ); |
---|
| 2333 | } |
---|
| 2334 | |
---|
| 2335 | vector<Int> rangeOutputLayerSets; |
---|
| 2336 | vector<Int> numOutputLayersInOutputLayerSet; |
---|
| 2337 | vector<Int> numDecLayer; |
---|
| 2338 | vector<Int> numLayersInLayerSetForOutputLayerSet; |
---|
| 2339 | vector<Int> vOlsIdxToLsIdx; |
---|
| 2340 | for (Int i = 0; i < getNumOutputLayerSets(); i++ ) |
---|
| 2341 | { |
---|
| 2342 | vOlsIdxToLsIdx.push_back( olsIdxToLsIdx(i)); |
---|
| 2343 | numOutputLayersInOutputLayerSet.push_back( getNumOutputLayersInOutputLayerSet( i ) ); |
---|
| 2344 | numDecLayer.push_back( (Int) m_targetDecLayerIdLists[ i ].size() ); |
---|
| 2345 | rangeOutputLayerSets.push_back( i ); |
---|
| 2346 | numLayersInLayerSetForOutputLayerSet.push_back( getNumLayersInIdList( olsIdxToLsIdx( i ) ) ); |
---|
| 2347 | } |
---|
| 2348 | |
---|
| 2349 | vector<Int> rangeIndependentLayers; |
---|
| 2350 | for(Int i = 0; i < getNumIndependentLayers(); i++ ) |
---|
| 2351 | { |
---|
| 2352 | rangeIndependentLayers.push_back( i ); |
---|
| 2353 | } |
---|
| 2354 | |
---|
| 2355 | vector<Int> rangeAddLayerSets; |
---|
| 2356 | vector<Int> numHighestLayerIdxPlus1; |
---|
| 2357 | for(Int i = 0; i < getNumAddLayerSets(); i++ ) |
---|
| 2358 | { |
---|
| 2359 | rangeAddLayerSets.push_back( i ); |
---|
| 2360 | numHighestLayerIdxPlus1.push_back( getNumIndependentLayers() ); |
---|
| 2361 | } |
---|
| 2362 | |
---|
| 2363 | std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "Layer Sets" << std::endl; |
---|
| 2364 | xPrintArray( "TreePartitionLayerIdList", getNumIndependentLayers(), rangeIndependentLayers, m_numLayersInTreePartition, m_treePartitionLayerIdList, true ); |
---|
| 2365 | xPrintArray( "highest_layer_idx_plus1", getNumAddLayerSets(), rangeAddLayerSets, numHighestLayerIdxPlus1, m_highestLayerIdxPlus1, true ); |
---|
| 2366 | xPrintArray( "LayerSetLayerIdList" , (Int) getNumLayerSets() , rangeLayerSets , numLayersInIdList, m_layerSetLayerIdList, true ); |
---|
| 2367 | xPrintArray( "OlsIdxToLsIdx", (Int) vOlsIdxToLsIdx.size(), vOlsIdxToLsIdx, true ); |
---|
| 2368 | xPrintArray( "OutputLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_outputLayerFlag, true ); |
---|
| 2369 | xPrintArray( "TargetOptLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numOutputLayersInOutputLayerSet, m_targetOptLayerIdLists, true ); |
---|
| 2370 | xPrintArray( "NecessaryLayerFlag" , getNumOutputLayerSets(), rangeOutputLayerSets, numLayersInLayerSetForOutputLayerSet, m_necessaryLayerFlag , true ); |
---|
| 2371 | xPrintArray( "TargetDecLayerIdList", getNumOutputLayerSets(), rangeOutputLayerSets, numDecLayer, m_targetDecLayerIdLists, true ); |
---|
| 2372 | std::cout << endl; |
---|
| 2373 | } |
---|
| 2374 | |
---|
[1313] | 2375 | #endif // NH_MV |
---|
[56] | 2376 | |
---|
[2] | 2377 | // ------------------------------------------------------------------------------------------------ |
---|
| 2378 | // Sequence parameter set (SPS) |
---|
| 2379 | // ------------------------------------------------------------------------------------------------ |
---|
| 2380 | |
---|
[1313] | 2381 | TComSPSRExt::TComSPSRExt() |
---|
| 2382 | : m_transformSkipRotationEnabledFlag (false) |
---|
| 2383 | , m_transformSkipContextEnabledFlag (false) |
---|
| 2384 | // m_rdpcmEnabledFlag initialized below |
---|
| 2385 | , m_extendedPrecisionProcessingFlag (false) |
---|
| 2386 | , m_intraSmoothingDisabledFlag (false) |
---|
| 2387 | , m_highPrecisionOffsetsEnabledFlag (false) |
---|
| 2388 | , m_persistentRiceAdaptationEnabledFlag(false) |
---|
| 2389 | , m_cabacBypassAlignmentEnabledFlag (false) |
---|
| 2390 | { |
---|
| 2391 | for (UInt signallingModeIndex = 0; signallingModeIndex < NUMBER_OF_RDPCM_SIGNALLING_MODES; signallingModeIndex++) |
---|
| 2392 | { |
---|
| 2393 | m_rdpcmEnabledFlag[signallingModeIndex] = false; |
---|
| 2394 | } |
---|
| 2395 | } |
---|
| 2396 | |
---|
[2] | 2397 | TComSPS::TComSPS() |
---|
[56] | 2398 | : m_SPSId ( 0) |
---|
[608] | 2399 | , m_VPSId ( 0) |
---|
[56] | 2400 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 2401 | , m_uiMaxTLayers ( 1) |
---|
| 2402 | // Structure |
---|
| 2403 | , m_picWidthInLumaSamples (352) |
---|
| 2404 | , m_picHeightInLumaSamples (288) |
---|
[608] | 2405 | , m_log2MinCodingBlockSize ( 0) |
---|
[1313] | 2406 | , m_log2DiffMaxMinCodingBlockSize(0) |
---|
[56] | 2407 | , m_uiMaxCUWidth ( 32) |
---|
| 2408 | , m_uiMaxCUHeight ( 32) |
---|
[1313] | 2409 | , m_uiMaxTotalCUDepth ( 3) |
---|
[56] | 2410 | , m_bLongTermRefsPresent (false) |
---|
| 2411 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 2412 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 2413 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 2414 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 2415 | // Tool list |
---|
[1313] | 2416 | , m_usePCM (false) |
---|
[56] | 2417 | , m_pcmLog2MaxSize ( 5) |
---|
| 2418 | , m_uiPCMLog2MinSize ( 7) |
---|
| 2419 | , m_bPCMFilterDisableFlag (false) |
---|
| 2420 | , m_uiBitsForPOC ( 8) |
---|
[1313] | 2421 | , m_numLongTermRefPicSPS ( 0) |
---|
[1321] | 2422 | #if NH_MV |
---|
| 2423 | , m_numShortTermRefPicSets ( 0) |
---|
| 2424 | #endif |
---|
[56] | 2425 | , m_uiMaxTrSize ( 32) |
---|
[1313] | 2426 | , m_bUseSAO (false) |
---|
[56] | 2427 | , m_bTemporalIdNestingFlag (false) |
---|
| 2428 | , m_scalingListEnabledFlag (false) |
---|
[608] | 2429 | , m_useStrongIntraSmoothing (false) |
---|
| 2430 | , m_vuiParametersPresentFlag (false) |
---|
| 2431 | , m_vuiParameters () |
---|
[1313] | 2432 | #if NH_MV |
---|
[622] | 2433 | , m_pcVPS ( NULL ) |
---|
| 2434 | , m_spsInferScalingListFlag ( false ) |
---|
| 2435 | , m_spsScalingListRefLayerId ( 0 ) |
---|
[738] | 2436 | |
---|
| 2437 | , m_updateRepFormatFlag ( false ) |
---|
| 2438 | , m_spsRepFormatIdx ( 0 ) |
---|
[608] | 2439 | , m_interViewMvVertConstraintFlag (false) |
---|
[56] | 2440 | #endif |
---|
[1313] | 2441 | |
---|
[56] | 2442 | { |
---|
[1313] | 2443 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
| 2444 | { |
---|
| 2445 | m_bitDepths.recon[ch] = 8; |
---|
| 2446 | #if O0043_BEST_EFFORT_DECODING |
---|
| 2447 | m_bitDepths.stream[ch] = 8; |
---|
| 2448 | #endif |
---|
| 2449 | m_pcmBitDepths[ch] = 8; |
---|
| 2450 | m_qpBDOffset [ch] = 0; |
---|
| 2451 | } |
---|
| 2452 | |
---|
| 2453 | |
---|
[56] | 2454 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 2455 | { |
---|
[1321] | 2456 | #if NH_MV |
---|
| 2457 | m_uiSpsMaxLatencyIncreasePlus1[i] = 0; |
---|
| 2458 | #else |
---|
[1386] | 2459 | m_uiMaxLatencyIncreasePlus1[i] = 0; |
---|
[1321] | 2460 | #endif |
---|
[608] | 2461 | m_uiMaxDecPicBuffering[i] = 1; |
---|
[56] | 2462 | m_numReorderPics[i] = 0; |
---|
| 2463 | } |
---|
[1313] | 2464 | |
---|
[608] | 2465 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 2466 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
[1313] | 2467 | #if NH_MV |
---|
[964] | 2468 | m_spsRangeExtensionsFlag = false; |
---|
| 2469 | m_spsMultilayerExtensionFlag = false; |
---|
| 2470 | m_spsExtension5bits = 0; |
---|
| 2471 | m_sps3dExtensionFlag = false; |
---|
[1313] | 2472 | |
---|
[964] | 2473 | #endif |
---|
| 2474 | |
---|
[2] | 2475 | } |
---|
| 2476 | |
---|
| 2477 | TComSPS::~TComSPS() |
---|
| 2478 | { |
---|
[608] | 2479 | m_RPSList.destroy(); |
---|
| 2480 | } |
---|
| 2481 | |
---|
| 2482 | Void TComSPS::createRPSList( Int numRPS ) |
---|
[1313] | 2483 | { |
---|
[608] | 2484 | m_RPSList.destroy(); |
---|
| 2485 | m_RPSList.create(numRPS); |
---|
| 2486 | } |
---|
| 2487 | |
---|
[1313] | 2488 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
| 2489 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
| 2490 | |
---|
| 2491 | TComPPSRExt::TComPPSRExt() |
---|
| 2492 | : m_log2MaxTransformSkipBlockSize (2) |
---|
| 2493 | , m_crossComponentPredictionEnabledFlag(false) |
---|
| 2494 | , m_diffCuChromaQpOffsetDepth (0) |
---|
| 2495 | , m_chromaQpOffsetListLen (0) |
---|
| 2496 | // m_ChromaQpAdjTableIncludingNullEntry initialized below |
---|
| 2497 | // m_log2SaoOffsetScale initialized below |
---|
[608] | 2498 | { |
---|
[1313] | 2499 | 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. |
---|
| 2500 | m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0; |
---|
| 2501 | for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) |
---|
[56] | 2502 | { |
---|
[1313] | 2503 | m_log2SaoOffsetScale[ch] = 0; |
---|
[56] | 2504 | } |
---|
[189] | 2505 | } |
---|
| 2506 | |
---|
[2] | 2507 | TComPPS::TComPPS() |
---|
[1313] | 2508 | : m_PPSId (0) |
---|
| 2509 | , m_SPSId (0) |
---|
| 2510 | , m_picInitQPMinus26 (0) |
---|
| 2511 | , m_useDQP (false) |
---|
| 2512 | , m_bConstrainedIntraPred (false) |
---|
| 2513 | , m_bSliceChromaQpFlag (false) |
---|
| 2514 | , m_uiMaxCuDQPDepth (0) |
---|
| 2515 | , m_chromaCbQpOffset (0) |
---|
| 2516 | , m_chromaCrQpOffset (0) |
---|
| 2517 | , m_numRefIdxL0DefaultActive (1) |
---|
| 2518 | , m_numRefIdxL1DefaultActive (1) |
---|
| 2519 | , m_TransquantBypassEnableFlag (false) |
---|
| 2520 | , m_useTransformSkip (false) |
---|
| 2521 | , m_dependentSliceSegmentsEnabledFlag(false) |
---|
| 2522 | , m_tilesEnabledFlag (false) |
---|
| 2523 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 2524 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 2525 | , m_uniformSpacingFlag (false) |
---|
| 2526 | , m_numTileColumnsMinus1 (0) |
---|
| 2527 | , m_numTileRowsMinus1 (0) |
---|
| 2528 | , m_signHideFlag (false) |
---|
| 2529 | , m_cabacInitPresentFlag (false) |
---|
| 2530 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 2531 | , m_loopFilterAcrossSlicesEnabledFlag(false) |
---|
| 2532 | , m_listsModificationPresentFlag (0) |
---|
| 2533 | , m_numExtraSliceHeaderBits (0) |
---|
| 2534 | #if NH_MV |
---|
| 2535 | , m_ppsInferScalingListFlag (false) |
---|
| 2536 | , m_ppsScalingListRefLayerId (0) |
---|
| 2537 | , m_pocResetInfoPresentFlag (false) |
---|
[622] | 2538 | #endif |
---|
[2] | 2539 | { |
---|
[1313] | 2540 | #if NH_MV |
---|
[964] | 2541 | m_ppsRangeExtensionsFlag = false; |
---|
| 2542 | m_ppsMultilayerExtensionFlag = false; |
---|
| 2543 | m_pps3dExtensionFlag = false; |
---|
| 2544 | m_ppsExtension5bits = 0; |
---|
| 2545 | #endif |
---|
[1313] | 2546 | |
---|
[2] | 2547 | } |
---|
| 2548 | |
---|
| 2549 | TComPPS::~TComPPS() |
---|
| 2550 | { |
---|
| 2551 | } |
---|
| 2552 | |
---|
[758] | 2553 | |
---|
[1313] | 2554 | #if NH_MV |
---|
| 2555 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr, Bool encoder ) |
---|
[622] | 2556 | { |
---|
[1066] | 2557 | if ( getMultiLayerExtSpsFlag() ) |
---|
[1313] | 2558 | { |
---|
[738] | 2559 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
[1313] | 2560 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
[622] | 2561 | |
---|
[1313] | 2562 | if ( encoder ) |
---|
| 2563 | { |
---|
| 2564 | assert( getChromaFormatIdc() == (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
| 2565 | //// ToDo: add when supported: |
---|
| 2566 | // assert( getSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
[622] | 2567 | |
---|
[1313] | 2568 | assert( getPicWidthInLumaSamples() == repFormat->getPicWidthVpsInLumaSamples() ); |
---|
| 2569 | assert( getPicHeightInLumaSamples() == repFormat->getPicHeightVpsInLumaSamples() ); |
---|
[622] | 2570 | |
---|
[1313] | 2571 | assert( getBitDepth ( CHANNEL_TYPE_LUMA ) == repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
| 2572 | assert( getQpBDOffset ( CHANNEL_TYPE_LUMA ) == (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
[1066] | 2573 | |
---|
[1313] | 2574 | assert( getBitDepth ( CHANNEL_TYPE_CHROMA ) == repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
| 2575 | assert( getQpBDOffset ( CHANNEL_TYPE_CHROMA ) == (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
| 2576 | } |
---|
| 2577 | else |
---|
| 2578 | { |
---|
| 2579 | setChromaFormatIdc( (ChromaFormat) repFormat->getChromaFormatVpsIdc() ); |
---|
| 2580 | //// ToDo: add when supported: |
---|
| 2581 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
[1066] | 2582 | |
---|
[1313] | 2583 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
| 2584 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
| 2585 | |
---|
| 2586 | setBitDepth ( CHANNEL_TYPE_LUMA, repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
| 2587 | setQpBDOffset ( CHANNEL_TYPE_LUMA, (Int) (6*( getBitDepth( CHANNEL_TYPE_LUMA ) - 8 )) ); |
---|
| 2588 | |
---|
| 2589 | setBitDepth ( CHANNEL_TYPE_CHROMA, repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
| 2590 | setQpBDOffset ( CHANNEL_TYPE_CHROMA, (Int) (6* ( getBitDepth( CHANNEL_TYPE_CHROMA ) -8 ) ) ); |
---|
| 2591 | Window &spsConf = getConformanceWindow(); |
---|
| 2592 | |
---|
| 2593 | // Scaled later |
---|
| 2594 | spsConf.setScaledFlag( false ); |
---|
| 2595 | spsConf.setWindowLeftOffset ( repFormat->getConfWinVpsLeftOffset() ); |
---|
| 2596 | spsConf.setWindowRightOffset ( repFormat->getConfWinVpsRightOffset() ); |
---|
| 2597 | spsConf.setWindowTopOffset ( repFormat->getConfWinVpsTopOffset() ); |
---|
| 2598 | spsConf.setWindowBottomOffset( repFormat->getConfWinVpsBottomOffset() ); |
---|
| 2599 | } |
---|
| 2600 | |
---|
[1066] | 2601 | if ( getMultiLayerExtSpsFlag() && getUpdateRepFormatFlag() ) |
---|
[622] | 2602 | { |
---|
| 2603 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
| 2604 | //// ToDo: add when supported: |
---|
| 2605 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
| 2606 | |
---|
| 2607 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
| 2608 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
| 2609 | |
---|
[1313] | 2610 | assert( getBitDepth( CHANNEL_TYPE_LUMA ) <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
| 2611 | assert( getBitDepth( CHANNEL_TYPE_CHROMA ) <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
[622] | 2612 | } |
---|
| 2613 | } |
---|
| 2614 | |
---|
| 2615 | // Set conformance window |
---|
| 2616 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
| 2617 | getConformanceWindow().scaleOffsets( scal ); |
---|
| 2618 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
[1313] | 2619 | |
---|
| 2620 | if (encoder && getMultiLayerExtSpsFlag() ) |
---|
| 2621 | { |
---|
| 2622 | Int repFormatIdx = getUpdateRepFormatFlag() ? getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ; |
---|
| 2623 | const TComRepFormat* repFormat = vps->getRepFormat( repFormatIdx ); |
---|
| 2624 | |
---|
| 2625 | Window &spsConf = getConformanceWindow(); |
---|
| 2626 | assert( spsConf.getWindowLeftOffset () == repFormat->getConfWinVpsLeftOffset() ); |
---|
| 2627 | assert( spsConf.getWindowRightOffset () == repFormat->getConfWinVpsRightOffset() ); |
---|
| 2628 | assert( spsConf.getWindowTopOffset () == repFormat->getConfWinVpsTopOffset() ); |
---|
| 2629 | assert( spsConf.getWindowBottomOffset() == repFormat->getConfWinVpsBottomOffset() ); |
---|
| 2630 | } |
---|
[622] | 2631 | } |
---|
| 2632 | |
---|
[1313] | 2633 | Void TComSPS::inferScalingList( const TComSPS* spsSrc ) |
---|
[622] | 2634 | { |
---|
| 2635 | if ( getSpsInferScalingListFlag() ) |
---|
| 2636 | { |
---|
| 2637 | assert( spsSrc != NULL ); |
---|
| 2638 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
[1313] | 2639 | getScalingList().inferFrom( (spsSrc->getScalingList()) ); |
---|
[622] | 2640 | } |
---|
| 2641 | } |
---|
[976] | 2642 | |
---|
| 2643 | Void TComSPS::inferSpsMaxDecPicBufferingMinus1( TComVPS* vps, Int targetOptLayerSetIdx, Int currLayerId, Bool encoder ) |
---|
| 2644 | { |
---|
[1066] | 2645 | if ( getMultiLayerExtSpsFlag() ) |
---|
[976] | 2646 | { |
---|
[1321] | 2647 | const std::vector<Int>& targetDecLayerIdList = vps->getTargetDecLayerIdList( vps->olsIdxToLsIdx( targetOptLayerSetIdx )); |
---|
[976] | 2648 | Int layerIdx = 0; |
---|
| 2649 | while (layerIdx < (Int) targetDecLayerIdList.size() ) |
---|
| 2650 | { |
---|
| 2651 | if ( targetDecLayerIdList[layerIdx] == currLayerId ) |
---|
| 2652 | { |
---|
| 2653 | break; |
---|
| 2654 | } |
---|
| 2655 | layerIdx++; |
---|
| 2656 | } |
---|
| 2657 | |
---|
| 2658 | assert( layerIdx < (Int) targetDecLayerIdList.size() ); |
---|
| 2659 | |
---|
| 2660 | for (Int i = 0; i <= getSpsMaxSubLayersMinus1(); i++ ) |
---|
| 2661 | { |
---|
| 2662 | Int maxDecPicBufferingMinus1 = vps->getDpbSize()->getMaxVpsDecPicBufferingMinus1( targetOptLayerSetIdx, layerIdx, i ) ; |
---|
| 2663 | |
---|
[1066] | 2664 | // This preliminary fix needs to be checked. |
---|
| 2665 | Int maxNumReorderPics = vps->getDpbSize()->getMaxVpsNumReorderPics( targetOptLayerSetIdx, i ); |
---|
| 2666 | Int maxLatencyIncreasePlus1 = vps->getDpbSize()->getMaxVpsLatencyIncreasePlus1( targetOptLayerSetIdx, i ); |
---|
| 2667 | if ( encoder ) |
---|
[976] | 2668 | { |
---|
| 2669 | assert( getMaxDecPicBuffering( i ) - 1 == maxDecPicBufferingMinus1 ); |
---|
[1066] | 2670 | // This preliminary fix needs to be checked. |
---|
| 2671 | assert( getNumReorderPics( i ) == maxNumReorderPics ); |
---|
[1321] | 2672 | assert( getSpsMaxLatencyIncreasePlus1( i ) == maxLatencyIncreasePlus1 ); |
---|
[1066] | 2673 | |
---|
[976] | 2674 | } |
---|
| 2675 | else |
---|
| 2676 | { |
---|
[1066] | 2677 | // This preliminary fix needs to be checked. |
---|
| 2678 | setMaxDecPicBuffering( maxDecPicBufferingMinus1 + 1 , i); |
---|
| 2679 | setNumReorderPics ( maxNumReorderPics, i ); |
---|
[1321] | 2680 | setSpsMaxLatencyIncreasePlus1( maxLatencyIncreasePlus1 , i); |
---|
[976] | 2681 | } |
---|
[1066] | 2682 | } |
---|
[976] | 2683 | } |
---|
| 2684 | } |
---|
| 2685 | |
---|
[1313] | 2686 | Void TComSPS::checkRpsMaxNumPics( const TComVPS* vps, Int currLayerId ) const |
---|
[976] | 2687 | { |
---|
| 2688 | for (Int i = 0; i < getRPSList()->getNumberOfReferencePictureSets(); i++ ) |
---|
| 2689 | { |
---|
[1313] | 2690 | const TComReferencePictureSet* rps = getRPSList()->getReferencePictureSet( i ); |
---|
[976] | 2691 | if ( !rps->getInterRPSPrediction() ) |
---|
| 2692 | { |
---|
[1066] | 2693 | rps->checkMaxNumPics( vps->getVpsExtensionFlag(), MAX_INT, getLayerId(), getMaxDecPicBuffering( getSpsMaxSubLayersMinus1() ) - 1 ); // INT_MAX to be replaced by DpbSize |
---|
[976] | 2694 | } |
---|
| 2695 | } |
---|
| 2696 | } |
---|
| 2697 | |
---|
[1066] | 2698 | Void TComSPS::inferSpsMaxSubLayersMinus1(Bool atPsActivation, TComVPS* vps) |
---|
| 2699 | { |
---|
| 2700 | assert( getLayerId() != 0 ); |
---|
| 2701 | if ( !atPsActivation ) |
---|
| 2702 | { |
---|
| 2703 | assert( vps == NULL ); |
---|
| 2704 | if (getSpsExtOrMaxSubLayersMinus1() != 7) |
---|
| 2705 | { |
---|
| 2706 | setSpsMaxSubLayersMinus1( getSpsExtOrMaxSubLayersMinus1() ); |
---|
| 2707 | } |
---|
| 2708 | } |
---|
| 2709 | else |
---|
| 2710 | { |
---|
| 2711 | assert( vps != NULL ); |
---|
| 2712 | if (getSpsExtOrMaxSubLayersMinus1() == 7) |
---|
| 2713 | { |
---|
| 2714 | setSpsMaxSubLayersMinus1( vps->getMaxSubLayersMinus1() ); |
---|
| 2715 | } |
---|
| 2716 | } |
---|
| 2717 | } |
---|
[622] | 2718 | #endif |
---|
[2] | 2719 | |
---|
[1313] | 2720 | |
---|
[56] | 2721 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 2722 | : m_numberOfPictures (0) |
---|
| 2723 | , m_numberOfNegativePictures (0) |
---|
| 2724 | , m_numberOfPositivePictures (0) |
---|
| 2725 | , m_numberOfLongtermPictures (0) |
---|
[1313] | 2726 | , m_interRPSPrediction (0) |
---|
| 2727 | , m_deltaRIdxMinus1 (0) |
---|
| 2728 | , m_deltaRPS (0) |
---|
| 2729 | , m_numRefIdc (0) |
---|
[56] | 2730 | { |
---|
| 2731 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 2732 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 2733 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 2734 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
[1313] | 2735 | ::memset( m_bCheckLTMSB, 0, sizeof(m_bCheckLTMSB) ); |
---|
| 2736 | ::memset( m_pocLSBLT, 0, sizeof(m_pocLSBLT) ); |
---|
| 2737 | ::memset( m_deltaPOCMSBCycleLT, 0, sizeof(m_deltaPOCMSBCycleLT) ); |
---|
| 2738 | ::memset( m_deltaPocMSBPresentFlag, 0, sizeof(m_deltaPocMSBPresentFlag) ); |
---|
[56] | 2739 | } |
---|
| 2740 | |
---|
| 2741 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 2742 | { |
---|
| 2743 | } |
---|
| 2744 | |
---|
| 2745 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 2746 | { |
---|
| 2747 | m_used[bufferNum] = used; |
---|
| 2748 | } |
---|
| 2749 | |
---|
| 2750 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 2751 | { |
---|
| 2752 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 2753 | } |
---|
| 2754 | |
---|
| 2755 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 2756 | { |
---|
| 2757 | m_numberOfPictures = numberOfPictures; |
---|
| 2758 | } |
---|
| 2759 | |
---|
[1313] | 2760 | Int TComReferencePictureSet::getUsed(Int bufferNum) const |
---|
[56] | 2761 | { |
---|
| 2762 | return m_used[bufferNum]; |
---|
| 2763 | } |
---|
| 2764 | |
---|
[1313] | 2765 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) const |
---|
[56] | 2766 | { |
---|
| 2767 | return m_deltaPOC[bufferNum]; |
---|
| 2768 | } |
---|
| 2769 | |
---|
[1313] | 2770 | Int TComReferencePictureSet::getNumberOfPictures() const |
---|
[56] | 2771 | { |
---|
| 2772 | return m_numberOfPictures; |
---|
| 2773 | } |
---|
| 2774 | |
---|
[1313] | 2775 | Int TComReferencePictureSet::getPOC(Int bufferNum) const |
---|
[56] | 2776 | { |
---|
| 2777 | return m_POC[bufferNum]; |
---|
| 2778 | } |
---|
[608] | 2779 | |
---|
[56] | 2780 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 2781 | { |
---|
| 2782 | m_POC[bufferNum] = POC; |
---|
| 2783 | } |
---|
| 2784 | |
---|
[1313] | 2785 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) const |
---|
[608] | 2786 | { |
---|
| 2787 | return m_bCheckLTMSB[bufferNum]; |
---|
| 2788 | } |
---|
| 2789 | |
---|
| 2790 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 2791 | { |
---|
| 2792 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 2793 | } |
---|
| 2794 | |
---|
[1313] | 2795 | //! set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
[56] | 2796 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 2797 | { |
---|
| 2798 | m_refIdc[bufferNum] = refIdc; |
---|
| 2799 | } |
---|
| 2800 | |
---|
[1313] | 2801 | //! get the reference idc value at uiBufferNum |
---|
| 2802 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) const |
---|
[56] | 2803 | { |
---|
| 2804 | return m_refIdc[bufferNum]; |
---|
| 2805 | } |
---|
| 2806 | |
---|
| 2807 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 2808 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 2809 | * +ve values are in increasing order. |
---|
| 2810 | * \returns Void |
---|
| 2811 | */ |
---|
| 2812 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 2813 | { |
---|
| 2814 | // sort in increasing order (smallest first) |
---|
| 2815 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
[1313] | 2816 | { |
---|
[56] | 2817 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2818 | Bool used = getUsed(j); |
---|
| 2819 | for (Int k=j-1; k >= 0; k--) |
---|
| 2820 | { |
---|
| 2821 | Int temp = getDeltaPOC(k); |
---|
| 2822 | if (deltaPOC < temp) |
---|
| 2823 | { |
---|
| 2824 | setDeltaPOC(k+1, temp); |
---|
| 2825 | setUsed(k+1, getUsed(k)); |
---|
| 2826 | setDeltaPOC(k, deltaPOC); |
---|
| 2827 | setUsed(k, used); |
---|
| 2828 | } |
---|
| 2829 | } |
---|
| 2830 | } |
---|
| 2831 | // flip the negative values to largest first |
---|
| 2832 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2833 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
[1313] | 2834 | { |
---|
[56] | 2835 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2836 | Bool used = getUsed(j); |
---|
| 2837 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2838 | setUsed(j, getUsed(k)); |
---|
| 2839 | setDeltaPOC(k, deltaPOC); |
---|
| 2840 | setUsed(k, used); |
---|
| 2841 | } |
---|
| 2842 | } |
---|
| 2843 | |
---|
| 2844 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2845 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2846 | * \returns Void |
---|
| 2847 | */ |
---|
[1313] | 2848 | Void TComReferencePictureSet::printDeltaPOC() const |
---|
[56] | 2849 | { |
---|
| 2850 | printf("DeltaPOC = { "); |
---|
| 2851 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2852 | { |
---|
| 2853 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
[1313] | 2854 | } |
---|
| 2855 | if (getInterRPSPrediction()) |
---|
[56] | 2856 | { |
---|
| 2857 | printf("}, RefIdc = { "); |
---|
| 2858 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2859 | { |
---|
| 2860 | printf("%d ", getRefIdc(j)); |
---|
[1313] | 2861 | } |
---|
[56] | 2862 | } |
---|
| 2863 | printf("}\n"); |
---|
| 2864 | } |
---|
[1313] | 2865 | |
---|
| 2866 | #if NH_MV |
---|
| 2867 | Void TComReferencePictureSet::checkMaxNumPics( Bool vpsExtensionFlag, Int maxNumPics, Int nuhLayerId, Int spsMaxDecPicBufferingMinus1 ) const |
---|
[976] | 2868 | { |
---|
| 2869 | assert( getNumberOfPictures() >= 0 ); |
---|
| 2870 | if ( nuhLayerId == 0 ) |
---|
| 2871 | { |
---|
| 2872 | assert( getNumberOfPictures() <= spsMaxDecPicBufferingMinus1 ); |
---|
| 2873 | } |
---|
[56] | 2874 | |
---|
[976] | 2875 | if ( vpsExtensionFlag ) |
---|
| 2876 | { |
---|
| 2877 | assert( getNumberOfPictures() <= maxNumPics ); |
---|
| 2878 | } |
---|
| 2879 | } |
---|
| 2880 | #endif |
---|
| 2881 | |
---|
[56] | 2882 | |
---|
| 2883 | |
---|
| 2884 | |
---|
| 2885 | TComRefPicListModification::TComRefPicListModification() |
---|
[1313] | 2886 | : m_refPicListModificationFlagL0 (false) |
---|
| 2887 | , m_refPicListModificationFlagL1 (false) |
---|
[56] | 2888 | { |
---|
| 2889 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2890 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2891 | } |
---|
| 2892 | |
---|
| 2893 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2894 | { |
---|
| 2895 | } |
---|
| 2896 | |
---|
[608] | 2897 | TComScalingList::TComScalingList() |
---|
[56] | 2898 | { |
---|
[1313] | 2899 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2900 | { |
---|
| 2901 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
| 2902 | { |
---|
| 2903 | m_scalingListCoef[sizeId][listId].resize(min<Int>(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2904 | } |
---|
| 2905 | } |
---|
[56] | 2906 | } |
---|
| 2907 | |
---|
[608] | 2908 | /** set default quantization matrix to array |
---|
| 2909 | */ |
---|
[1313] | 2910 | Void TComScalingList::setDefaultScalingList() |
---|
[56] | 2911 | { |
---|
[608] | 2912 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2913 | { |
---|
[1313] | 2914 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
[608] | 2915 | { |
---|
[1313] | 2916 | processDefaultMatrix(sizeId, listId); |
---|
[608] | 2917 | } |
---|
| 2918 | } |
---|
| 2919 | } |
---|
| 2920 | /** check if use default quantization matrix |
---|
| 2921 | * \returns true if use default quantization matrix in all size |
---|
| 2922 | */ |
---|
[1313] | 2923 | Bool TComScalingList::checkDefaultScalingList() |
---|
[608] | 2924 | { |
---|
| 2925 | UInt defaultCounter=0; |
---|
[56] | 2926 | |
---|
[608] | 2927 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2928 | { |
---|
[1313] | 2929 | for(UInt listId=0;listId<SCALING_LIST_NUM;listId++) |
---|
[608] | 2930 | { |
---|
[1313] | 2931 | if( !memcmp(getScalingListAddress(sizeId,listId), getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2932 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
[608] | 2933 | { |
---|
| 2934 | defaultCounter++; |
---|
| 2935 | } |
---|
| 2936 | } |
---|
| 2937 | } |
---|
[1313] | 2938 | |
---|
| 2939 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM )) ? false : true; |
---|
[56] | 2940 | } |
---|
| 2941 | |
---|
[1313] | 2942 | #if NH_MV |
---|
[622] | 2943 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
| 2944 | { |
---|
| 2945 | refPicSetInterLayer0.clear(); |
---|
| 2946 | refPicSetInterLayer1.clear(); |
---|
| 2947 | |
---|
| 2948 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
| 2949 | { |
---|
| 2950 | Int layerIdRef = getRefPicLayerId( i ); |
---|
| 2951 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
[872] | 2952 | assert ( picRef != 0 ); // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
[622] | 2953 | |
---|
| 2954 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
| 2955 | picRef->setIsLongTerm( true ); |
---|
| 2956 | picRef->getSlice(0)->setReferenced( true ); |
---|
| 2957 | |
---|
| 2958 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
| 2959 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
| 2960 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
| 2961 | |
---|
| 2962 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
| 2963 | { |
---|
| 2964 | refPicSetInterLayer0.push_back( picRef ); |
---|
| 2965 | } |
---|
| 2966 | else |
---|
| 2967 | { |
---|
| 2968 | refPicSetInterLayer1.push_back( picRef ); |
---|
| 2969 | } |
---|
| 2970 | // Consider to check here: |
---|
| 2971 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
[872] | 2972 | assert( picRef->getSlice(0)->getDiscardableFlag() == false ); // "There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1". |
---|
[622] | 2973 | } |
---|
| 2974 | } |
---|
| 2975 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
| 2976 | { |
---|
[964] | 2977 | // Mark as short-term |
---|
[622] | 2978 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
| 2979 | { |
---|
| 2980 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
| 2981 | } |
---|
| 2982 | |
---|
| 2983 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
| 2984 | { |
---|
| 2985 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
| 2986 | } |
---|
| 2987 | |
---|
| 2988 | } |
---|
[964] | 2989 | |
---|
[622] | 2990 | Void TComSlice::printRefPicList() |
---|
[608] | 2991 | { |
---|
| 2992 | for ( Int li = 0; li < 2; li++) |
---|
| 2993 | { |
---|
| 2994 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
| 2995 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
| 2996 | { |
---|
[1321] | 2997 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( 1 ); |
---|
| 2998 | m_apcRefPicList[li][rIdx]->print( 0 ); |
---|
[608] | 2999 | |
---|
| 3000 | } |
---|
| 3001 | } |
---|
| 3002 | } |
---|
| 3003 | |
---|
| 3004 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
[56] | 3005 | { |
---|
[976] | 3006 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
| 3007 | currPic->setIsLongTerm( false ); |
---|
[964] | 3008 | |
---|
| 3009 | currPic->setReconMark( true ); |
---|
| 3010 | currPic->setPicOutputFlag( currPic->getSlice(0)->getPicOutputFlag() ); |
---|
[56] | 3011 | } |
---|
| 3012 | |
---|
[622] | 3013 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
| 3014 | { |
---|
| 3015 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
| 3016 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
| 3017 | } |
---|
| 3018 | |
---|
[1321] | 3019 | TComPic* TComSlice::getRefPicSetInterLayer( Int setIdc, Int i ) const |
---|
| 3020 | { |
---|
| 3021 | TComPic* pic = NULL; |
---|
| 3022 | if (setIdc == 0 ) |
---|
| 3023 | { |
---|
| 3024 | pic = (*m_refPicSetInterLayer0)[ i ]; |
---|
| 3025 | } |
---|
| 3026 | else if (setIdc == 1 ) |
---|
| 3027 | { |
---|
| 3028 | pic = (*m_refPicSetInterLayer1)[ i ]; |
---|
| 3029 | } |
---|
| 3030 | |
---|
| 3031 | assert( pic != NULL ); |
---|
| 3032 | |
---|
| 3033 | return pic; |
---|
| 3034 | } |
---|
| 3035 | |
---|
| 3036 | |
---|
[1313] | 3037 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) const |
---|
[622] | 3038 | { |
---|
| 3039 | assert ( setIdc == 0 || setIdc == 1); |
---|
| 3040 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
| 3041 | assert( refPicSetInterLayer != 0 ); |
---|
| 3042 | |
---|
| 3043 | TComPic* pcPic = NULL; |
---|
| 3044 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
| 3045 | { |
---|
| 3046 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
| 3047 | { |
---|
| 3048 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
| 3049 | } |
---|
| 3050 | } |
---|
| 3051 | |
---|
| 3052 | assert(pcPic != NULL); |
---|
| 3053 | return pcPic; |
---|
| 3054 | } |
---|
[738] | 3055 | |
---|
| 3056 | |
---|
[1313] | 3057 | Int TComSlice::getRefLayerPicFlag( Int i ) const |
---|
[738] | 3058 | { |
---|
[1313] | 3059 | const TComVPS* vps = getVPS(); |
---|
[1066] | 3060 | Int refLayerIdx = vps->getLayerIdInVps( vps->getIdDirectRefLayer( getLayerId(), i ) ); |
---|
[738] | 3061 | |
---|
[1124] | 3062 | Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >= getTLayer() && ( getTLayer() == 0 || |
---|
| 3063 | vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() )); |
---|
[738] | 3064 | return refLayerPicFlag; |
---|
| 3065 | } |
---|
| 3066 | |
---|
[1313] | 3067 | Int TComSlice::getRefLayerPicIdc( Int j ) const |
---|
[738] | 3068 | { |
---|
| 3069 | Int refLayerPicIdc = -1; |
---|
| 3070 | Int curj = 0; |
---|
| 3071 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
| 3072 | { |
---|
| 3073 | if( getRefLayerPicFlag( i ) ) |
---|
| 3074 | { |
---|
| 3075 | if ( curj == j ) |
---|
| 3076 | { |
---|
| 3077 | refLayerPicIdc = i; |
---|
| 3078 | break; |
---|
| 3079 | } |
---|
| 3080 | curj++; |
---|
| 3081 | } |
---|
| 3082 | } |
---|
| 3083 | |
---|
| 3084 | assert( curj == j ); |
---|
| 3085 | assert( refLayerPicIdc != -1 ); |
---|
| 3086 | return refLayerPicIdc; |
---|
| 3087 | } |
---|
| 3088 | |
---|
[1313] | 3089 | Int TComSlice::getNumRefLayerPics( ) const |
---|
[738] | 3090 | { |
---|
| 3091 | Int numRefLayerPics = 0; |
---|
| 3092 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ ) |
---|
| 3093 | { |
---|
| 3094 | numRefLayerPics += getRefLayerPicFlag( i ); |
---|
| 3095 | } |
---|
| 3096 | return numRefLayerPics; |
---|
| 3097 | } |
---|
| 3098 | |
---|
| 3099 | |
---|
| 3100 | |
---|
[1313] | 3101 | Int TComSlice::getNumActiveRefLayerPics() const |
---|
[56] | 3102 | { |
---|
[608] | 3103 | Int numActiveRefLayerPics; |
---|
| 3104 | |
---|
[872] | 3105 | if( getLayerId() == 0 || getNumRefLayerPics() == 0 ) |
---|
[622] | 3106 | { |
---|
| 3107 | numActiveRefLayerPics = 0; |
---|
| 3108 | } |
---|
| 3109 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
| 3110 | { |
---|
[738] | 3111 | numActiveRefLayerPics = getNumRefLayerPics(); |
---|
[622] | 3112 | } |
---|
| 3113 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
| 3114 | { |
---|
| 3115 | numActiveRefLayerPics = 0; |
---|
| 3116 | } |
---|
| 3117 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
[608] | 3118 | { |
---|
[872] | 3119 | numActiveRefLayerPics = 1; |
---|
[608] | 3120 | } |
---|
| 3121 | else |
---|
| 3122 | { |
---|
| 3123 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
| 3124 | } |
---|
| 3125 | return numActiveRefLayerPics; |
---|
[56] | 3126 | } |
---|
[608] | 3127 | |
---|
[1313] | 3128 | Int TComSlice::getRefPicLayerId( Int i ) const |
---|
[56] | 3129 | { |
---|
[1066] | 3130 | return getVPS()->getIdDirectRefLayer( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
[56] | 3131 | } |
---|
[1321] | 3132 | #endif |
---|
[1124] | 3133 | |
---|
[1313] | 3134 | |
---|
| 3135 | |
---|
| 3136 | |
---|
[1124] | 3137 | |
---|
[1313] | 3138 | #if NH_MV |
---|
| 3139 | Void TComSlice::checkCrossLayerBlaFlag() const |
---|
[976] | 3140 | { |
---|
| 3141 | // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0. |
---|
| 3142 | if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
| 3143 | { |
---|
| 3144 | assert( m_crossLayerBlaFlag == 0 ); |
---|
| 3145 | } |
---|
| 3146 | } |
---|
| 3147 | |
---|
[1321] | 3148 | Bool TComSlice::inferPocMsbCycleValPresentFlag() |
---|
[976] | 3149 | { |
---|
| 3150 | Bool pocMsbValPresentFlag; |
---|
| 3151 | if( getSliceSegmentHeaderExtensionLength() == 0 ) |
---|
| 3152 | { |
---|
| 3153 | pocMsbValPresentFlag = false; |
---|
| 3154 | } |
---|
| 3155 | else if ( getPocMsbValRequiredFlag() ) |
---|
| 3156 | { |
---|
| 3157 | pocMsbValPresentFlag = true; |
---|
| 3158 | } |
---|
| 3159 | else |
---|
| 3160 | { |
---|
| 3161 | pocMsbValPresentFlag = false; |
---|
| 3162 | } |
---|
| 3163 | |
---|
| 3164 | return pocMsbValPresentFlag; |
---|
| 3165 | } |
---|
| 3166 | |
---|
| 3167 | |
---|
[1321] | 3168 | Void TComSlice::f834decProcForRefPicListConst() |
---|
| 3169 | { |
---|
| 3170 | // This process is invoked at the beginning of the decoding process for each P or B slice. |
---|
| 3171 | assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE ); |
---|
| 3172 | |
---|
| 3173 | // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into |
---|
| 3174 | // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B |
---|
| 3175 | // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0. |
---|
| 3176 | |
---|
| 3177 | // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1 |
---|
| 3178 | // are derived as follows: |
---|
| 3179 | |
---|
| 3180 | // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr ) |
---|
| 3181 | Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() ); |
---|
| 3182 | |
---|
| 3183 | // and the list RefPicListTemp0 is constructed as follows: |
---|
| 3184 | std::vector<TComPic*> refPicListTemp0; |
---|
| 3185 | refPicListTemp0.resize((MAX_NUM_REF+1),NULL); |
---|
| 3186 | |
---|
| 3187 | const TComDecodedRps* decRps = getPic()->getDecodedRps(); |
---|
| 3188 | |
---|
| 3189 | const std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
| 3190 | const std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter; |
---|
| 3191 | const std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr; |
---|
| 3192 | |
---|
| 3193 | const Int numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
| 3194 | const Int numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
| 3195 | const Int numPocLtCurr = decRps->m_numPocLtCurr; |
---|
| 3196 | |
---|
| 3197 | const Int numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0; |
---|
| 3198 | const Int numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1; |
---|
| 3199 | |
---|
| 3200 | const std::vector<TComPic*>& refPicSetInterLayer0 = decRps->m_refPicSetInterLayer0; |
---|
| 3201 | const std::vector<TComPic*>& refPicSetInterLayer1 = decRps->m_refPicSetInterLayer1; |
---|
| 3202 | |
---|
| 3203 | Int rIdx = 0; |
---|
| 3204 | while( rIdx < numRpsCurrTempList0 ) |
---|
| 3205 | { |
---|
| 3206 | for(Int i = 0; i < numPocStCurrBefore && rIdx < numRpsCurrTempList0; rIdx++, i++ ) |
---|
| 3207 | { |
---|
| 3208 | refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ]; |
---|
| 3209 | } |
---|
| 3210 | |
---|
| 3211 | for(Int i = 0; i < numActiveRefLayerPics0; rIdx++, i++ ) |
---|
| 3212 | { |
---|
| 3213 | refPicListTemp0[ rIdx ] = refPicSetInterLayer0[ i ]; |
---|
| 3214 | } |
---|
| 3215 | |
---|
| 3216 | for(Int i = 0; i < numPocStCurrAfter && rIdx < numRpsCurrTempList0; rIdx++, i++ ) // (F 65) |
---|
| 3217 | { |
---|
| 3218 | refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ]; |
---|
| 3219 | } |
---|
| 3220 | |
---|
| 3221 | for(Int i = 0; i < numPocLtCurr && rIdx < numRpsCurrTempList0; rIdx++, i++ ) |
---|
| 3222 | { |
---|
| 3223 | refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ]; |
---|
| 3224 | } |
---|
| 3225 | |
---|
| 3226 | for(Int i = 0; i < numActiveRefLayerPics1; rIdx++, i++ ) |
---|
| 3227 | { |
---|
| 3228 | refPicListTemp0[ rIdx ] = refPicSetInterLayer1[ i ]; |
---|
| 3229 | } |
---|
| 3230 | } |
---|
| 3231 | |
---|
| 3232 | // The list RefPicList0 is constructed as follows: |
---|
| 3233 | TComRefPicListModification* rplm = getRefPicListModification(); |
---|
| 3234 | for( rIdx = 0; rIdx <= getNumRefIdxL0ActiveMinus1(); rIdx++ ) // (F 66) |
---|
| 3235 | { |
---|
| 3236 | m_apcRefPicList[ 0 ][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ]; |
---|
| 3237 | // The decoding process below slice level requires the status |
---|
| 3238 | // of the reference pictures, when decoding the RPS. So store it here. |
---|
| 3239 | m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm(); |
---|
| 3240 | m_aiRefPOCList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC(); |
---|
| 3241 | m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId(); |
---|
| 3242 | } |
---|
| 3243 | |
---|
| 3244 | std::vector<TComPic*> refPicListTemp1; |
---|
| 3245 | refPicListTemp1.resize((MAX_NUM_REF+1),NULL); |
---|
| 3246 | |
---|
| 3247 | if (getSliceType() == B_SLICE ) |
---|
| 3248 | { |
---|
| 3249 | // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to |
---|
| 3250 | // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows: |
---|
| 3251 | Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() ); |
---|
| 3252 | |
---|
| 3253 | rIdx = 0; |
---|
| 3254 | while( rIdx < numRpsCurrTempList1 ) |
---|
| 3255 | { |
---|
| 3256 | for( Int i = 0; i < numPocStCurrAfter && rIdx < numRpsCurrTempList1; rIdx++, i++ ) |
---|
| 3257 | { |
---|
| 3258 | refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ]; |
---|
| 3259 | } |
---|
| 3260 | for( Int i = 0; i< numActiveRefLayerPics1; rIdx++, i++ ) |
---|
| 3261 | { |
---|
| 3262 | refPicListTemp1[ rIdx ] = refPicSetInterLayer1[ i ]; |
---|
| 3263 | } |
---|
| 3264 | for( Int i = 0; i < numPocStCurrBefore && rIdx < numRpsCurrTempList1; rIdx++, i++ ) // (F 67) |
---|
| 3265 | { |
---|
| 3266 | refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ]; |
---|
| 3267 | } |
---|
| 3268 | for( Int i = 0; i < numPocLtCurr && rIdx < numRpsCurrTempList1; rIdx++, i++ ) |
---|
| 3269 | { |
---|
| 3270 | refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ]; |
---|
| 3271 | } |
---|
| 3272 | for( Int i = 0; i< numActiveRefLayerPics0; rIdx++, i++ ) |
---|
| 3273 | { |
---|
| 3274 | refPicListTemp1[ rIdx ] = refPicSetInterLayer0[ i ]; |
---|
| 3275 | } |
---|
| 3276 | } |
---|
| 3277 | } |
---|
| 3278 | |
---|
| 3279 | if (getSliceType() == B_SLICE ) |
---|
| 3280 | { |
---|
| 3281 | // When the slice is a B slice, the list RefPicList1 is constructed as follows: |
---|
| 3282 | for( rIdx = 0; rIdx <= getNumRefIdxL1ActiveMinus1(); rIdx++ ) // (F 68) |
---|
| 3283 | { |
---|
| 3284 | m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ]; |
---|
| 3285 | |
---|
| 3286 | // The decoding process below slice level requires the marking status |
---|
| 3287 | // of the reference pictures, when decoding the RPS. So store it here. |
---|
| 3288 | m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm(); |
---|
| 3289 | m_aiRefPOCList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC(); |
---|
| 3290 | m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId(); |
---|
| 3291 | } |
---|
| 3292 | } |
---|
| 3293 | } |
---|
| 3294 | |
---|
| 3295 | |
---|
| 3296 | Void TComSlice::cl834DecProcForRefPicListConst() |
---|
| 3297 | { |
---|
| 3298 | // This process is invoked at the beginning of the decoding process for each P or B slice. |
---|
| 3299 | assert( getSliceType() == B_SLICE || getSliceType() == P_SLICE ); |
---|
| 3300 | |
---|
| 3301 | // Reference pictures are addressed through reference indices as specified in clause 8.5.3.3.2. A reference index is an index into |
---|
| 3302 | // a reference picture list. When decoding a P slice, there is a single reference picture list RefPicList0. When decoding a B |
---|
| 3303 | // slice, there is a second independent reference picture list RefPicList1 in addition to RefPicList0. |
---|
| 3304 | |
---|
| 3305 | // At the beginning of the decoding process for each slice, the reference picture lists RefPicList0 and, for B slices, RefPicList1 |
---|
| 3306 | // are derived as follows: |
---|
| 3307 | |
---|
| 3308 | // The variable NumRpsCurrTempList0 is set equal to Max( num_ref_idx_l0_active_minus1 + 1, NumPicTotalCurr ) |
---|
| 3309 | Int numRpsCurrTempList0 = std::max( getNumRefIdxL0ActiveMinus1() + 1, getNumPicTotalCurr() ); |
---|
| 3310 | |
---|
| 3311 | // and the list RefPicListTemp0 is constructed as follows: |
---|
| 3312 | std::vector<TComPic*> refPicListTemp0; |
---|
| 3313 | refPicListTemp0.resize((MAX_NUM_REF+1),NULL); |
---|
| 3314 | |
---|
| 3315 | const TComDecodedRps* decRps = getPic()->getDecodedRps(); |
---|
| 3316 | |
---|
| 3317 | const std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
| 3318 | const std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter; |
---|
| 3319 | const std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr; |
---|
| 3320 | |
---|
| 3321 | const Int numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
| 3322 | const Int numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
| 3323 | const Int numPocLtCurr = decRps->m_numPocLtCurr; |
---|
| 3324 | |
---|
| 3325 | Int rIdx = 0; |
---|
| 3326 | while( rIdx < numRpsCurrTempList0 ) |
---|
| 3327 | { |
---|
| 3328 | for(Int i = 0; i < numPocStCurrBefore && rIdx < numRpsCurrTempList0; rIdx++, i++ ) |
---|
| 3329 | { |
---|
| 3330 | refPicListTemp0[ rIdx ] = refPicSetStCurrBefore[ i ]; |
---|
| 3331 | } |
---|
| 3332 | |
---|
| 3333 | for(Int i = 0; i < numPocStCurrAfter && rIdx < numRpsCurrTempList0; rIdx++, i++ ) // (8 8) |
---|
| 3334 | { |
---|
| 3335 | refPicListTemp0[ rIdx ] = refPicSetStCurrAfter[ i ]; |
---|
| 3336 | } |
---|
| 3337 | |
---|
| 3338 | for(Int i = 0; i < numPocLtCurr && rIdx < numRpsCurrTempList0; rIdx++, i++ ) |
---|
| 3339 | { |
---|
| 3340 | refPicListTemp0[ rIdx ] = refPicSetLtCurr[ i ]; |
---|
| 3341 | } |
---|
| 3342 | } |
---|
| 3343 | |
---|
| 3344 | // The list RefPicList0 is constructed as follows: |
---|
| 3345 | |
---|
| 3346 | TComRefPicListModification* rplm = getRefPicListModification(); |
---|
| 3347 | for( rIdx = 0; rIdx <= getNumRefIdxL0ActiveMinus1(); rIdx++ ) // (8-9) |
---|
| 3348 | { |
---|
| 3349 | m_apcRefPicList[0][ rIdx ] = rplm->getRefPicListModificationFlagL0( ) ? refPicListTemp0[ rplm->getListEntryL0( rIdx )] : refPicListTemp0[ rIdx ]; |
---|
| 3350 | |
---|
| 3351 | // The decoding process below slice level requires the marking status |
---|
| 3352 | // of the reference pictures, when decoding the RPS. So store it here. |
---|
| 3353 | m_bIsUsedAsLongTerm[ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getIsLongTerm(); |
---|
| 3354 | m_aiRefPOCList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getPOC(); |
---|
| 3355 | m_aiRefLayerIdList [ 0 ][ rIdx ] = m_apcRefPicList[ 0 ][ rIdx ]->getLayerId(); |
---|
| 3356 | } |
---|
| 3357 | |
---|
| 3358 | std::vector<TComPic*> refPicListTemp1; |
---|
| 3359 | refPicListTemp1.resize((MAX_NUM_REF+1),NULL); |
---|
| 3360 | |
---|
| 3361 | if (getSliceType() == B_SLICE ) |
---|
| 3362 | { |
---|
| 3363 | // When the slice is a B slice, the variable NumRpsCurrTempList1 is set equal to |
---|
| 3364 | // Max( num_ref_idx_l1_active_minus1 + 1, NumPicTotalCurr ) and the list RefPicListTemp1 is constructed as follows: |
---|
| 3365 | Int numRpsCurrTempList1 = std::max( getNumRefIdxL1ActiveMinus1() + 1, getNumPicTotalCurr() ); |
---|
| 3366 | |
---|
| 3367 | rIdx = 0; |
---|
| 3368 | while( rIdx < numRpsCurrTempList1 ) |
---|
| 3369 | { |
---|
| 3370 | for( Int i = 0; i < numPocStCurrAfter && rIdx < numRpsCurrTempList1; rIdx++, i++ ) |
---|
| 3371 | { |
---|
| 3372 | refPicListTemp1[ rIdx ] = refPicSetStCurrAfter[ i ]; |
---|
| 3373 | } |
---|
| 3374 | for( Int i = 0; i < numPocStCurrBefore && rIdx < numRpsCurrTempList1; rIdx++, i++ ) // (8-10) |
---|
| 3375 | { |
---|
| 3376 | refPicListTemp1[ rIdx ] = refPicSetStCurrBefore[ i ]; |
---|
| 3377 | } |
---|
| 3378 | for( Int i = 0; i < numPocLtCurr && rIdx < numRpsCurrTempList1; rIdx++, i++ ) |
---|
| 3379 | { |
---|
| 3380 | refPicListTemp1[ rIdx ] = refPicSetLtCurr[ i ]; |
---|
| 3381 | } |
---|
| 3382 | } |
---|
| 3383 | } |
---|
| 3384 | |
---|
| 3385 | if (getSliceType() == B_SLICE ) |
---|
| 3386 | { |
---|
| 3387 | // When the slice is a B slice, the list RefPicList1 is constructed as follows: |
---|
| 3388 | for( rIdx = 0; rIdx <= getNumRefIdxL1ActiveMinus1(); rIdx++ ) // (F 68) |
---|
| 3389 | { |
---|
| 3390 | m_apcRefPicList[ 1 ][ rIdx ] = rplm->getRefPicListModificationFlagL1() ? refPicListTemp1[ rplm->getListEntryL1( rIdx ) ] : refPicListTemp1[ rIdx ]; |
---|
| 3391 | |
---|
| 3392 | // The decoding process below slice level requires the marking status |
---|
| 3393 | // of the reference pictures, when decoding the RPS. So store it here. |
---|
| 3394 | m_bIsUsedAsLongTerm[ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getIsLongTerm(); |
---|
| 3395 | m_aiRefPOCList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getPOC(); |
---|
| 3396 | m_aiRefLayerIdList [ 1 ][ rIdx ] = m_apcRefPicList[ 1 ][ rIdx ]->getLayerId(); |
---|
| 3397 | } |
---|
| 3398 | } |
---|
| 3399 | } |
---|
| 3400 | |
---|
| 3401 | Int TComSlice::getNumPicTotalCurr() const |
---|
| 3402 | { |
---|
| 3403 | Int numPicTotalCurr = 0; |
---|
| 3404 | #if NH_MV_FIX_NUM_POC_TOTAL_CUR |
---|
| 3405 | if ( !isIdr() ) |
---|
| 3406 | { |
---|
| 3407 | const TComStRefPicSet* stRps = getStRps( getCurrRpsIdx() ); |
---|
[976] | 3408 | #endif |
---|
[1321] | 3409 | for( Int i = 0; i < stRps->getNumNegativePicsVar(); i++ ) |
---|
| 3410 | { |
---|
| 3411 | if( stRps->getUsedByCurrPicS0Var( i ) ) |
---|
| 3412 | { |
---|
| 3413 | numPicTotalCurr++; |
---|
| 3414 | } |
---|
| 3415 | } |
---|
| 3416 | for( Int i = 0; i < stRps->getNumPositivePicsVar(); i++) //(7 55) |
---|
| 3417 | { |
---|
| 3418 | if( stRps->getUsedByCurrPicS1Var(i) ) |
---|
| 3419 | { |
---|
| 3420 | numPicTotalCurr++; |
---|
| 3421 | } |
---|
| 3422 | } |
---|
| 3423 | for( Int i = 0; i < getNumLongTermSps() + getNumLongTermPics(); i++ ) |
---|
| 3424 | { |
---|
| 3425 | if( getUsedByCurrPicLtVar( i ) ) |
---|
| 3426 | { |
---|
| 3427 | numPicTotalCurr++; |
---|
| 3428 | } |
---|
| 3429 | } |
---|
| 3430 | #if NH_MV_FIX_NUM_POC_TOTAL_CUR |
---|
| 3431 | } |
---|
| 3432 | #endif |
---|
[976] | 3433 | |
---|
[1321] | 3434 | if ( decProcAnnexF() ) |
---|
| 3435 | { |
---|
| 3436 | numPicTotalCurr += getNumActiveRefLayerPics(); |
---|
| 3437 | } |
---|
| 3438 | return numPicTotalCurr; |
---|
| 3439 | } |
---|
[976] | 3440 | |
---|
[1321] | 3441 | |
---|
| 3442 | |
---|
| 3443 | Int TComSlice::getPocLsbLtVar( Int i ) |
---|
| 3444 | { |
---|
| 3445 | Int pocLsbLtVar; |
---|
| 3446 | if (i < getNumLongTermSps() ) |
---|
| 3447 | { |
---|
| 3448 | |
---|
| 3449 | pocLsbLtVar = getSPS()->getLtRefPicPocLsbSps( getLtIdxSps( i ) ); |
---|
| 3450 | } |
---|
| 3451 | else |
---|
| 3452 | { |
---|
| 3453 | pocLsbLtVar = getPocLsbLt( i ); |
---|
| 3454 | } |
---|
| 3455 | return pocLsbLtVar; |
---|
| 3456 | } |
---|
| 3457 | |
---|
| 3458 | |
---|
| 3459 | Bool TComSlice::getUsedByCurrPicLtVar( Int i ) const |
---|
| 3460 | { |
---|
| 3461 | Bool usedByCurrPicLtVar; |
---|
| 3462 | if (i < getNumLongTermSps() ) |
---|
| 3463 | { |
---|
| 3464 | usedByCurrPicLtVar = getSPS()->getUsedByCurrPicLtSPSFlag( getLtIdxSps( i ) ); |
---|
| 3465 | } |
---|
| 3466 | else |
---|
| 3467 | { |
---|
| 3468 | usedByCurrPicLtVar = getUsedByCurrPicLtFlag( i ); |
---|
| 3469 | } |
---|
| 3470 | return usedByCurrPicLtVar; |
---|
| 3471 | } |
---|
| 3472 | |
---|
| 3473 | |
---|
| 3474 | Int TComSlice::getDeltaPocMsbCycleLtVar( Int i ) const |
---|
| 3475 | { |
---|
| 3476 | Int deltaPocMsbCycleVar; |
---|
| 3477 | if (i == 0 || i == getNumLongTermSps() ) |
---|
| 3478 | { |
---|
| 3479 | deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i ); |
---|
| 3480 | } |
---|
| 3481 | else |
---|
| 3482 | { |
---|
| 3483 | deltaPocMsbCycleVar = getDeltaPocMsbCycleLt( i ) + getDeltaPocMsbCycleLtVar( i - 1 ); |
---|
| 3484 | } |
---|
| 3485 | return deltaPocMsbCycleVar; |
---|
| 3486 | } |
---|
| 3487 | |
---|
| 3488 | #endif |
---|
| 3489 | |
---|
| 3490 | |
---|
[1124] | 3491 | |
---|
[56] | 3492 | /** get scaling matrix from RefMatrixID |
---|
[1313] | 3493 | * \param sizeId size index |
---|
| 3494 | * \param listId index of input matrix |
---|
| 3495 | * \param refListId index of reference matrix |
---|
[56] | 3496 | */ |
---|
| 3497 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 3498 | { |
---|
[608] | 3499 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
[56] | 3500 | } |
---|
[608] | 3501 | |
---|
[1313] | 3502 | Void TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
[56] | 3503 | { |
---|
[1313] | 3504 | Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
[56] | 3505 | |
---|
[1313] | 3506 | for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx-=predListStep) |
---|
[56] | 3507 | { |
---|
[1313] | 3508 | if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? |
---|
| 3509 | getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 3510 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
| 3511 | { |
---|
| 3512 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
| 3513 | setScalingListPredModeFlag(sizeId, listId, false); |
---|
| 3514 | return; |
---|
| 3515 | } |
---|
[56] | 3516 | } |
---|
[1313] | 3517 | setScalingListPredModeFlag(sizeId, listId, true); |
---|
| 3518 | } |
---|
[56] | 3519 | |
---|
[1313] | 3520 | static Void outputScalingListHelp(std::ostream &os) |
---|
| 3521 | { |
---|
| 3522 | os << "The scaling list file specifies all matrices and their DC values; none can be missing,\n" |
---|
| 3523 | "but their order is arbitrary.\n\n" |
---|
| 3524 | "The matrices are specified by:\n" |
---|
| 3525 | "<matrix name><unchecked data>\n" |
---|
| 3526 | " <value>,<value>,<value>,....\n\n" |
---|
| 3527 | " Line-feeds can be added arbitrarily between values, and the number of values needs to be\n" |
---|
| 3528 | " at least the number of entries for the matrix (superfluous entries are ignored).\n" |
---|
| 3529 | " The <unchecked data> is text on the same line as the matrix that is not checked\n" |
---|
| 3530 | " except to ensure that the matrix name token is unique. It is recommended that it is ' ='\n" |
---|
| 3531 | " The values in the matrices are the absolute values (0-255), not the delta values as\n" |
---|
| 3532 | " exchanged between the encoder and decoder\n\n" |
---|
| 3533 | "The DC values (for matrix sizes larger than 8x8) are specified by:\n" |
---|
| 3534 | "<matrix name>_DC<unchecked data>\n" |
---|
| 3535 | " <value>\n"; |
---|
| 3536 | |
---|
| 3537 | os << "The permitted matrix names are:\n"; |
---|
| 3538 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
[56] | 3539 | { |
---|
[1313] | 3540 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
[56] | 3541 | { |
---|
[1313] | 3542 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
| 3543 | { |
---|
| 3544 | os << " " << MatrixType[sizeIdc][listIdc] << '\n'; |
---|
| 3545 | } |
---|
| 3546 | } |
---|
| 3547 | } |
---|
| 3548 | } |
---|
[56] | 3549 | |
---|
[1313] | 3550 | Void TComScalingList::outputScalingLists(std::ostream &os) const |
---|
| 3551 | { |
---|
| 3552 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 3553 | { |
---|
| 3554 | const UInt size = min(8,4<<(sizeIdc)); |
---|
| 3555 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
| 3556 | { |
---|
| 3557 | if ((sizeIdc!=SCALING_LIST_32x32) || (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) == 0)) |
---|
[56] | 3558 | { |
---|
[1313] | 3559 | const Int *src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 3560 | os << (MatrixType[sizeIdc][listIdc]) << " =\n "; |
---|
| 3561 | for(UInt y=0; y<size; y++) |
---|
[56] | 3562 | { |
---|
[1313] | 3563 | for(UInt x=0; x<size; x++, src++) |
---|
| 3564 | { |
---|
| 3565 | os << std::setw(3) << (*src) << ", "; |
---|
| 3566 | } |
---|
| 3567 | os << (y+1<size?"\n ":"\n"); |
---|
[56] | 3568 | } |
---|
[1313] | 3569 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 3570 | { |
---|
| 3571 | os << MatrixType_DC[sizeIdc][listIdc] << " = \n " << std::setw(3) << getScalingListDC(sizeIdc, listIdc) << "\n"; |
---|
| 3572 | } |
---|
| 3573 | os << "\n"; |
---|
[56] | 3574 | } |
---|
[1313] | 3575 | } |
---|
| 3576 | } |
---|
| 3577 | } |
---|
| 3578 | |
---|
[1386] | 3579 | Bool TComScalingList::xParseScalingList(const std::string &fileName) |
---|
[1313] | 3580 | { |
---|
| 3581 | static const Int LINE_SIZE=1024; |
---|
| 3582 | FILE *fp = NULL; |
---|
[1386] | 3583 | TChar line[LINE_SIZE]; |
---|
[1313] | 3584 | |
---|
[1386] | 3585 | if (fileName.empty()) |
---|
[1313] | 3586 | { |
---|
| 3587 | fprintf(stderr, "Error: no scaling list file specified. Help on scaling lists being output\n"); |
---|
| 3588 | outputScalingListHelp(std::cout); |
---|
| 3589 | std::cout << "\n\nExample scaling list file using default values:\n\n"; |
---|
| 3590 | outputScalingLists(std::cout); |
---|
| 3591 | exit (1); |
---|
| 3592 | return true; |
---|
| 3593 | } |
---|
[1386] | 3594 | else if ((fp = fopen(fileName.c_str(),"r")) == (FILE*)NULL) |
---|
[1313] | 3595 | { |
---|
[1386] | 3596 | fprintf(stderr, "Error: cannot open scaling list file %s for reading\n", fileName.c_str()); |
---|
[1313] | 3597 | return true; |
---|
| 3598 | } |
---|
| 3599 | |
---|
| 3600 | for(UInt sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 3601 | { |
---|
| 3602 | const UInt size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 3603 | |
---|
| 3604 | for(UInt listIdc = 0; listIdc < SCALING_LIST_NUM; listIdc++) |
---|
| 3605 | { |
---|
| 3606 | Int * const src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 3607 | |
---|
| 3608 | if ((sizeIdc==SCALING_LIST_32x32) && (listIdc%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) // derive chroma32x32 from chroma16x16 |
---|
[56] | 3609 | { |
---|
[1313] | 3610 | const Int *srcNextSmallerSize = getScalingListAddress(sizeIdc-1, listIdc); |
---|
| 3611 | for(UInt i=0; i<size; i++) |
---|
[56] | 3612 | { |
---|
[1313] | 3613 | src[i] = srcNextSmallerSize[i]; |
---|
[56] | 3614 | } |
---|
[1313] | 3615 | setScalingListDC(sizeIdc,listIdc,(sizeIdc > SCALING_LIST_8x8) ? getScalingListDC(sizeIdc-1, listIdc) : src[0]); |
---|
[56] | 3616 | } |
---|
[1313] | 3617 | else |
---|
[56] | 3618 | { |
---|
| 3619 | { |
---|
[1313] | 3620 | fseek(fp, 0, SEEK_SET); |
---|
| 3621 | Bool bFound=false; |
---|
| 3622 | while ((!feof(fp)) && (!bFound)) |
---|
[56] | 3623 | { |
---|
[1386] | 3624 | TChar *ret = fgets(line, LINE_SIZE, fp); |
---|
| 3625 | TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType[sizeIdc][listIdc]); |
---|
[1313] | 3626 | // This could be a match against the DC string as well, so verify it isn't |
---|
| 3627 | if (findNamePosition!= NULL && (MatrixType_DC[sizeIdc][listIdc]==NULL || strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL)) |
---|
| 3628 | { |
---|
| 3629 | bFound=true; |
---|
| 3630 | } |
---|
| 3631 | } |
---|
| 3632 | if (!bFound) |
---|
| 3633 | { |
---|
[1386] | 3634 | fprintf(stderr, "Error: cannot find Matrix %s from scaling list file %s\n", MatrixType[sizeIdc][listIdc], fileName.c_str()); |
---|
[56] | 3635 | return true; |
---|
| 3636 | } |
---|
| 3637 | } |
---|
[1313] | 3638 | for (UInt i=0; i<size; i++) |
---|
[608] | 3639 | { |
---|
[1313] | 3640 | Int data; |
---|
| 3641 | if (fscanf(fp, "%d,", &data)!=1) |
---|
| 3642 | { |
---|
[1386] | 3643 | 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)); |
---|
[1313] | 3644 | return true; |
---|
| 3645 | } |
---|
| 3646 | if (data<0 || data>255) |
---|
| 3647 | { |
---|
[1386] | 3648 | 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)); |
---|
[1313] | 3649 | return true; |
---|
| 3650 | } |
---|
| 3651 | src[i] = data; |
---|
[608] | 3652 | } |
---|
[1313] | 3653 | |
---|
| 3654 | //set DC value for default matrix check |
---|
| 3655 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 3656 | |
---|
| 3657 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 3658 | { |
---|
| 3659 | { |
---|
| 3660 | fseek(fp, 0, SEEK_SET); |
---|
| 3661 | Bool bFound=false; |
---|
| 3662 | while ((!feof(fp)) && (!bFound)) |
---|
| 3663 | { |
---|
[1386] | 3664 | TChar *ret = fgets(line, LINE_SIZE, fp); |
---|
| 3665 | TChar *findNamePosition= ret==NULL ? NULL : strstr(line, MatrixType_DC[sizeIdc][listIdc]); |
---|
[1313] | 3666 | if (findNamePosition!= NULL) |
---|
| 3667 | { |
---|
| 3668 | // This won't be a match against the non-DC string. |
---|
| 3669 | bFound=true; |
---|
| 3670 | } |
---|
| 3671 | } |
---|
| 3672 | if (!bFound) |
---|
| 3673 | { |
---|
[1386] | 3674 | fprintf(stderr, "Error: cannot find DC Matrix %s from scaling list file %s\n", MatrixType_DC[sizeIdc][listIdc], fileName.c_str()); |
---|
[1313] | 3675 | return true; |
---|
| 3676 | } |
---|
| 3677 | } |
---|
| 3678 | Int data; |
---|
| 3679 | if (fscanf(fp, "%d,", &data)!=1) |
---|
| 3680 | { |
---|
[1386] | 3681 | 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)); |
---|
[1313] | 3682 | return true; |
---|
| 3683 | } |
---|
| 3684 | if (data<0 || data>255) |
---|
| 3685 | { |
---|
[1386] | 3686 | 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)); |
---|
[1313] | 3687 | return true; |
---|
| 3688 | } |
---|
| 3689 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 3690 | setScalingListDC(sizeIdc,listIdc,data); |
---|
| 3691 | } |
---|
[56] | 3692 | } |
---|
| 3693 | } |
---|
| 3694 | } |
---|
[1313] | 3695 | // std::cout << "\n\nRead scaling lists of:\n\n"; |
---|
| 3696 | // outputScalingLists(std::cout); |
---|
| 3697 | |
---|
[56] | 3698 | fclose(fp); |
---|
| 3699 | return false; |
---|
| 3700 | } |
---|
| 3701 | |
---|
[1313] | 3702 | #if NH_MV |
---|
| 3703 | Void TComScalingList::inferFrom( const TComScalingList& srcScLi ) |
---|
[622] | 3704 | { |
---|
| 3705 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3706 | { |
---|
[1313] | 3707 | for(Int listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
[622] | 3708 | { |
---|
[1313] | 3709 | setRefMatrixId (sizeId,listId, srcScLi.getRefMatrixId (sizeId,listId)); |
---|
| 3710 | setScalingListDC(sizeId,listId, srcScLi.getScalingListDC(sizeId,listId)); |
---|
| 3711 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi.getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
[622] | 3712 | } |
---|
| 3713 | } |
---|
| 3714 | } |
---|
| 3715 | #endif |
---|
[608] | 3716 | |
---|
| 3717 | |
---|
[1313] | 3718 | /** get default address of quantization matrix |
---|
[56] | 3719 | * \param sizeId size index |
---|
| 3720 | * \param listId list index |
---|
| 3721 | * \returns pointer of quantization matrix |
---|
| 3722 | */ |
---|
[1313] | 3723 | const Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
[56] | 3724 | { |
---|
[1313] | 3725 | const Int *src = 0; |
---|
[56] | 3726 | switch(sizeId) |
---|
| 3727 | { |
---|
| 3728 | case SCALING_LIST_4x4: |
---|
[608] | 3729 | src = g_quantTSDefault4x4; |
---|
[56] | 3730 | break; |
---|
| 3731 | case SCALING_LIST_8x8: |
---|
| 3732 | case SCALING_LIST_16x16: |
---|
| 3733 | case SCALING_LIST_32x32: |
---|
[1313] | 3734 | src = (listId < (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) ) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
[56] | 3735 | break; |
---|
| 3736 | default: |
---|
| 3737 | assert(0); |
---|
| 3738 | src = NULL; |
---|
| 3739 | break; |
---|
| 3740 | } |
---|
| 3741 | return src; |
---|
| 3742 | } |
---|
[608] | 3743 | |
---|
[56] | 3744 | /** process of default matrix |
---|
| 3745 | * \param sizeId size index |
---|
[1313] | 3746 | * \param listId index of input matrix |
---|
[56] | 3747 | */ |
---|
[872] | 3748 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
[56] | 3749 | { |
---|
| 3750 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 3751 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 3752 | } |
---|
[608] | 3753 | |
---|
[56] | 3754 | /** check DC value of matrix for default matrix signaling |
---|
| 3755 | */ |
---|
| 3756 | Void TComScalingList::checkDcOfMatrix() |
---|
| 3757 | { |
---|
| 3758 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3759 | { |
---|
[1313] | 3760 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
[56] | 3761 | { |
---|
| 3762 | //check default matrix? |
---|
| 3763 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 3764 | { |
---|
[872] | 3765 | processDefaultMatrix(sizeId, listId); |
---|
[56] | 3766 | } |
---|
| 3767 | } |
---|
| 3768 | } |
---|
| 3769 | } |
---|
| 3770 | |
---|
| 3771 | ParameterSetManager::ParameterSetManager() |
---|
[608] | 3772 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 3773 | , m_spsMap(MAX_NUM_SPS) |
---|
[56] | 3774 | , m_ppsMap(MAX_NUM_PPS) |
---|
[608] | 3775 | , m_activeVPSId(-1) |
---|
[1313] | 3776 | #if !NH_MV |
---|
[608] | 3777 | , m_activeSPSId(-1) |
---|
[1313] | 3778 | #endif |
---|
[56] | 3779 | { |
---|
[1313] | 3780 | #if NH_MV |
---|
[622] | 3781 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
[1313] | 3782 | { |
---|
| 3783 | m_activeSPSId[i] = -1; |
---|
[622] | 3784 | } |
---|
| 3785 | #endif |
---|
[56] | 3786 | } |
---|
| 3787 | |
---|
| 3788 | |
---|
| 3789 | ParameterSetManager::~ParameterSetManager() |
---|
| 3790 | { |
---|
| 3791 | } |
---|
| 3792 | |
---|
[608] | 3793 | //! activate a SPS from a active parameter sets SEI message |
---|
| 3794 | //! \returns true, if activation is successful |
---|
[1313] | 3795 | #if NH_MV |
---|
| 3796 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
[622] | 3797 | #else |
---|
[1313] | 3798 | //Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
[622] | 3799 | #endif |
---|
[1313] | 3800 | //{ |
---|
| 3801 | //TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 3802 | // if (sps) |
---|
| 3803 | // { |
---|
| 3804 | // Int vpsId = sps->getVPSId(); |
---|
| 3805 | // TComVPS *vps = m_vpsMap.getPS(vpsId); |
---|
| 3806 | // if (vps) |
---|
| 3807 | // { |
---|
| 3808 | #if NH_MV |
---|
| 3809 | // m_activeVPS = *(vps); |
---|
| 3810 | // m_activeSPS[ layerId ] = *(sps); |
---|
[622] | 3811 | #else |
---|
[1313] | 3812 | // m_activeVPS = *(vps); |
---|
| 3813 | // m_activeSPS = *(sps); |
---|
[622] | 3814 | #endif |
---|
[1313] | 3815 | // return true; |
---|
| 3816 | // } |
---|
| 3817 | // else |
---|
| 3818 | // { |
---|
| 3819 | // printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
| 3820 | // } |
---|
| 3821 | // } |
---|
| 3822 | // else |
---|
| 3823 | // { |
---|
| 3824 | // printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
| 3825 | // } |
---|
| 3826 | // return false; |
---|
| 3827 | //} |
---|
[608] | 3828 | |
---|
| 3829 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
| 3830 | //! \returns true, if activation is successful |
---|
[1313] | 3831 | #if NH_MV |
---|
[622] | 3832 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
| 3833 | #else |
---|
[608] | 3834 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
[622] | 3835 | #endif |
---|
[608] | 3836 | { |
---|
| 3837 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
| 3838 | if (pps) |
---|
| 3839 | { |
---|
| 3840 | Int spsId = pps->getSPSId(); |
---|
[1313] | 3841 | #if NH_MV |
---|
| 3842 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ] )) |
---|
[622] | 3843 | #else |
---|
[1313] | 3844 | if (!isIRAP && (spsId != m_activeSPSId )) |
---|
[622] | 3845 | #endif |
---|
| 3846 | { |
---|
[1313] | 3847 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IDR."); |
---|
[622] | 3848 | } |
---|
[1313] | 3849 | else |
---|
[622] | 3850 | { |
---|
[1313] | 3851 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 3852 | if (sps) |
---|
[622] | 3853 | { |
---|
[1313] | 3854 | Int vpsId = sps->getVPSId(); |
---|
| 3855 | if (!isIRAP && (vpsId != m_activeVPSId )) |
---|
| 3856 | { |
---|
| 3857 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IDR."); |
---|
| 3858 | } |
---|
| 3859 | else |
---|
| 3860 | { |
---|
| 3861 | TComVPS *vps =m_vpsMap.getPS(vpsId); |
---|
| 3862 | if (vps) |
---|
| 3863 | { |
---|
| 3864 | m_activeVPSId = vpsId; |
---|
| 3865 | #if NH_MV |
---|
| 3866 | m_activeSPSId[layerId] = spsId; |
---|
[622] | 3867 | #else |
---|
[1313] | 3868 | m_activeSPSId = spsId; |
---|
[622] | 3869 | #endif |
---|
[1313] | 3870 | return true; |
---|
| 3871 | } |
---|
| 3872 | else |
---|
| 3873 | { |
---|
| 3874 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
| 3875 | } |
---|
| 3876 | } |
---|
[608] | 3877 | } |
---|
| 3878 | else |
---|
| 3879 | { |
---|
[1313] | 3880 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
[608] | 3881 | } |
---|
| 3882 | } |
---|
| 3883 | } |
---|
| 3884 | else |
---|
| 3885 | { |
---|
| 3886 | printf("Warning: tried to activate non-existing PPS."); |
---|
| 3887 | } |
---|
[1313] | 3888 | |
---|
| 3889 | // Failed to activate if reach here. |
---|
| 3890 | #if NH_MV |
---|
| 3891 | m_activeSPSId[layerId]=-1; |
---|
| 3892 | #else |
---|
| 3893 | m_activeSPSId=-1; |
---|
| 3894 | #endif |
---|
| 3895 | m_activeVPSId=-1; |
---|
| 3896 | |
---|
[608] | 3897 | return false; |
---|
| 3898 | } |
---|
| 3899 | |
---|
| 3900 | ProfileTierLevel::ProfileTierLevel() |
---|
| 3901 | : m_profileSpace (0) |
---|
[1313] | 3902 | , m_tierFlag (Level::MAIN) |
---|
| 3903 | , m_profileIdc (Profile::NONE) |
---|
| 3904 | , m_levelIdc (Level::NONE) |
---|
| 3905 | , m_progressiveSourceFlag (false) |
---|
| 3906 | , m_interlacedSourceFlag (false) |
---|
| 3907 | , m_nonPackedConstraintFlag(false) |
---|
| 3908 | , m_frameOnlyConstraintFlag(false) |
---|
| 3909 | #if NH_MV |
---|
| 3910 | , m_intraConstraintFlag ( false ) |
---|
| 3911 | , m_onePictureOnlyConstraintFlag( false ) |
---|
| 3912 | , m_lowerBitRateConstraintFlag ( false ) |
---|
[1066] | 3913 | , m_max12bitConstraintFlag ( false ) |
---|
| 3914 | , m_max10bitConstraintFlag ( false ) |
---|
| 3915 | , m_max8bitConstraintFlag ( false ) |
---|
| 3916 | , m_max422chromaConstraintFlag ( false ) |
---|
| 3917 | , m_max420chromaConstraintFlag ( false ) |
---|
[1313] | 3918 | , m_maxMonochromeConstraintFlag ( false ) |
---|
[1066] | 3919 | , m_inbldFlag ( false ) |
---|
| 3920 | #endif |
---|
[608] | 3921 | { |
---|
| 3922 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 3923 | } |
---|
| 3924 | |
---|
[1313] | 3925 | #if NH_MV |
---|
| 3926 | Bool ProfileTierLevel::getV2ConstraintsPresentFlag() const |
---|
[1066] | 3927 | { |
---|
| 3928 | return ( |
---|
| 3929 | getProfileIdc( ) == 4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) == 5 || getProfileCompatibilityFlag( 5 ) || |
---|
| 3930 | getProfileIdc( ) == 6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) == 7 || getProfileCompatibilityFlag( 7 ) |
---|
| 3931 | ); |
---|
| 3932 | } |
---|
| 3933 | |
---|
[1313] | 3934 | Bool ProfileTierLevel::getInbldPresentFlag() const |
---|
[1066] | 3935 | { |
---|
| 3936 | return ( |
---|
| 3937 | ( getProfileIdc() >= 1 && getProfileIdc() <= 5 ) || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || |
---|
| 3938 | getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 ) || getProfileCompatibilityFlag( 5 ) |
---|
| 3939 | ); |
---|
| 3940 | } |
---|
| 3941 | |
---|
| 3942 | Void ProfileTierLevel::copyV2ConstraintFlags(ProfileTierLevel* ptlRef) |
---|
| 3943 | { |
---|
| 3944 | setMax12bitConstraintFlag ( ptlRef->getMax12bitConstraintFlag ( ) ); |
---|
| 3945 | setMax10bitConstraintFlag ( ptlRef->getMax10bitConstraintFlag ( ) ); |
---|
| 3946 | setMax8bitConstraintFlag ( ptlRef->getMax8bitConstraintFlag ( ) ); |
---|
| 3947 | setMax422chromaConstraintFlag ( ptlRef->getMax422chromaConstraintFlag ( ) ); |
---|
| 3948 | setMax420chromaConstraintFlag ( ptlRef->getMax420chromaConstraintFlag ( ) ); |
---|
| 3949 | setMaxMonochromeConstraintFlag ( ptlRef->getMaxMonochromeConstraintFlag ( ) ); |
---|
| 3950 | setIntraConstraintFlag ( ptlRef->getIntraConstraintFlag ( ) ); |
---|
| 3951 | setOnePictureOnlyConstraintFlag ( ptlRef->getOnePictureOnlyConstraintFlag ( ) ); |
---|
| 3952 | setLowerBitRateConstraintFlag ( ptlRef->getLowerBitRateConstraintFlag ( ) ); |
---|
| 3953 | } |
---|
| 3954 | |
---|
| 3955 | Void ProfileTierLevel::copyProfile(ProfileTierLevel* ptlRef) |
---|
| 3956 | { |
---|
| 3957 | setProfileSpace ( ptlRef->getProfileSpace ( ) ); |
---|
| 3958 | setTierFlag ( ptlRef->getTierFlag ( ) ); |
---|
| 3959 | setProfileIdc ( ptlRef->getProfileIdc ( ) ); |
---|
| 3960 | for (Int j = 0; j < 32; j++) |
---|
| 3961 | { |
---|
| 3962 | setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag ( j ) ); |
---|
| 3963 | } |
---|
| 3964 | setProgressiveSourceFlag ( ptlRef->getProgressiveSourceFlag ( ) ); |
---|
| 3965 | setInterlacedSourceFlag ( ptlRef->getInterlacedSourceFlag ( ) ); |
---|
| 3966 | setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag ( ) ); |
---|
| 3967 | setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag ( ) ); |
---|
| 3968 | copyV2ConstraintFlags ( ptlRef ); |
---|
| 3969 | } |
---|
| 3970 | #endif |
---|
| 3971 | |
---|
[608] | 3972 | TComPTL::TComPTL() |
---|
| 3973 | { |
---|
| 3974 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 3975 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 3976 | } |
---|
| 3977 | |
---|
[1313] | 3978 | Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> &newData) |
---|
| 3979 | { |
---|
| 3980 | if (!bChanged) |
---|
| 3981 | { |
---|
| 3982 | if ((pOldData==0 && pOldData!=0) || (pOldData!=0 && pOldData==0)) |
---|
| 3983 | { |
---|
| 3984 | bChanged=true; |
---|
| 3985 | } |
---|
| 3986 | else if (pOldData!=0 && pOldData!=0) |
---|
| 3987 | { |
---|
| 3988 | // compare the two |
---|
| 3989 | if (pOldData->size() != pOldData->size()) |
---|
| 3990 | { |
---|
| 3991 | bChanged=true; |
---|
| 3992 | } |
---|
| 3993 | else |
---|
| 3994 | { |
---|
| 3995 | const UChar *pNewDataArray=&(newData)[0]; |
---|
| 3996 | const UChar *pOldDataArray=&(*pOldData)[0]; |
---|
| 3997 | if (memcmp(pOldDataArray, pNewDataArray, pOldData->size())) |
---|
| 3998 | { |
---|
| 3999 | bChanged=true; |
---|
| 4000 | } |
---|
| 4001 | } |
---|
| 4002 | } |
---|
| 4003 | } |
---|
| 4004 | } |
---|
| 4005 | #if NH_MV |
---|
[1066] | 4006 | Void TComPTL::inferGeneralValues(Bool profilePresentFlag, Int k, TComPTL* refPTL) |
---|
| 4007 | { |
---|
| 4008 | ProfileTierLevel* refProfileTierLevel = NULL; |
---|
| 4009 | if ( k > 0 ) |
---|
| 4010 | { |
---|
| 4011 | assert( refPTL != NULL); |
---|
| 4012 | refProfileTierLevel = refPTL->getGeneralPTL(); |
---|
| 4013 | } |
---|
| 4014 | |
---|
| 4015 | ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); |
---|
[1321] | 4016 | assert( curProfileTierLevel != NULL ); |
---|
[1066] | 4017 | |
---|
| 4018 | if( !profilePresentFlag ) |
---|
| 4019 | { |
---|
| 4020 | assert( k > 0 ); |
---|
| 4021 | assert( refProfileTierLevel != NULL ); |
---|
| 4022 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
| 4023 | } |
---|
| 4024 | else |
---|
| 4025 | { |
---|
| 4026 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
| 4027 | { |
---|
| 4028 | curProfileTierLevel->setMax12bitConstraintFlag ( false ); |
---|
| 4029 | curProfileTierLevel->setMax10bitConstraintFlag ( false ); |
---|
| 4030 | curProfileTierLevel->setMax8bitConstraintFlag ( false ); |
---|
| 4031 | curProfileTierLevel->setMax422chromaConstraintFlag ( false ); |
---|
| 4032 | curProfileTierLevel->setMax420chromaConstraintFlag ( false ); |
---|
| 4033 | curProfileTierLevel->setMaxMonochromeConstraintFlag ( false ); |
---|
| 4034 | curProfileTierLevel->setIntraConstraintFlag ( false ); |
---|
| 4035 | curProfileTierLevel->setOnePictureOnlyConstraintFlag ( false ); |
---|
| 4036 | curProfileTierLevel->setLowerBitRateConstraintFlag ( false ); |
---|
| 4037 | } |
---|
| 4038 | |
---|
| 4039 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
| 4040 | { |
---|
| 4041 | curProfileTierLevel->setInbldFlag( false ); |
---|
| 4042 | } |
---|
| 4043 | } |
---|
| 4044 | } |
---|
| 4045 | |
---|
| 4046 | Void TComPTL::inferSubLayerValues(Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL) |
---|
| 4047 | { |
---|
[1321] | 4048 | assert( k == 0 || refPTL != NULL ); |
---|
[1066] | 4049 | for (Int i = maxNumSubLayersMinus1; i >= 0; i--) |
---|
| 4050 | { |
---|
| 4051 | ProfileTierLevel* refProfileTierLevel; |
---|
| 4052 | if ( k != 0 ) |
---|
| 4053 | { |
---|
| 4054 | refProfileTierLevel = refPTL->getSubLayerPTL( i ); |
---|
| 4055 | } |
---|
| 4056 | else |
---|
| 4057 | { |
---|
| 4058 | if ( i == maxNumSubLayersMinus1) |
---|
| 4059 | { |
---|
| 4060 | refProfileTierLevel = getGeneralPTL(); |
---|
| 4061 | } |
---|
| 4062 | else |
---|
| 4063 | { |
---|
| 4064 | refProfileTierLevel = getSubLayerPTL( i + 1 ); |
---|
| 4065 | } |
---|
| 4066 | } |
---|
| 4067 | |
---|
[1321] | 4068 | assert( refProfileTierLevel != NULL ); |
---|
[1066] | 4069 | ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); |
---|
[1321] | 4070 | assert( curProfileTierLevel != NULL ); |
---|
[1066] | 4071 | if( !getSubLayerLevelPresentFlag( i ) ) |
---|
| 4072 | { |
---|
| 4073 | curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); |
---|
| 4074 | } |
---|
| 4075 | |
---|
| 4076 | if( !getSubLayerProfilePresentFlag( i ) ) |
---|
| 4077 | { |
---|
| 4078 | curProfileTierLevel->copyProfile( refProfileTierLevel); |
---|
| 4079 | } |
---|
| 4080 | else |
---|
| 4081 | { |
---|
| 4082 | if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() ) |
---|
| 4083 | { |
---|
| 4084 | curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); |
---|
| 4085 | } |
---|
| 4086 | |
---|
| 4087 | if ( !curProfileTierLevel->getInbldPresentFlag() ) |
---|
| 4088 | { |
---|
| 4089 | curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); |
---|
| 4090 | } |
---|
| 4091 | } |
---|
| 4092 | } |
---|
| 4093 | } |
---|
| 4094 | |
---|
[608] | 4095 | #endif |
---|
[1313] | 4096 | |
---|
[622] | 4097 | //! \} |
---|
| 4098 | |
---|
[1313] | 4099 | #if NH_MV |
---|
| 4100 | Void TComVPSVUI::init( Int numLayerSets, Int maxNumSubLayers, Int maxNumLayers ) |
---|
[608] | 4101 | { |
---|
[738] | 4102 | m_crossLayerIrapAlignedFlag = true; |
---|
[872] | 4103 | m_allLayersIdrAlignedFlag = false; |
---|
[1313] | 4104 | m_bitRatePresentVpsFlag = false; |
---|
| 4105 | m_picRatePresentVpsFlag = false; |
---|
| 4106 | |
---|
| 4107 | m_bitRatePresentFlag .resize(numLayerSets); |
---|
| 4108 | m_picRatePresentFlag .resize(numLayerSets); |
---|
| 4109 | m_avgBitRate .resize(numLayerSets); |
---|
| 4110 | m_maxBitRate .resize(numLayerSets); |
---|
| 4111 | m_constantPicRateIdc .resize(numLayerSets); |
---|
| 4112 | m_avgPicRate .resize(numLayerSets); |
---|
| 4113 | |
---|
| 4114 | for ( Int i = 0; i < numLayerSets; i++) |
---|
| 4115 | { |
---|
| 4116 | m_bitRatePresentFlag [i].resize( maxNumSubLayers); |
---|
| 4117 | m_picRatePresentFlag [i].resize( maxNumSubLayers); |
---|
| 4118 | m_avgBitRate [i].resize( maxNumSubLayers); |
---|
| 4119 | m_maxBitRate [i].resize( maxNumSubLayers); |
---|
| 4120 | m_constantPicRateIdc [i].resize( maxNumSubLayers); |
---|
| 4121 | m_avgPicRate [i].resize( maxNumSubLayers); |
---|
| 4122 | for ( Int j = 0; j < maxNumSubLayers; j++) |
---|
[622] | 4123 | { |
---|
| 4124 | m_bitRatePresentFlag [i][j] = false; |
---|
| 4125 | m_picRatePresentFlag [i][j] = false; |
---|
| 4126 | m_avgBitRate [i][j] = -1; |
---|
| 4127 | m_maxBitRate [i][j] = -1; |
---|
| 4128 | m_constantPicRateIdc [i][j] = -1; |
---|
| 4129 | m_avgPicRate [i][j] = -1; |
---|
| 4130 | } |
---|
| 4131 | } |
---|
| 4132 | |
---|
| 4133 | m_ilpRestrictedRefLayersFlag = false; |
---|
| 4134 | |
---|
[1313] | 4135 | m_tileBoundariesAlignedFlag .resize( maxNumLayers ); |
---|
| 4136 | m_minSpatialSegmentOffsetPlus1 .resize( maxNumLayers ); |
---|
| 4137 | m_ctuBasedOffsetEnabledFlag .resize( maxNumLayers ); |
---|
| 4138 | m_minHorizontalCtuOffsetPlus1 .resize( maxNumLayers ); |
---|
| 4139 | m_baseLayerParameterSetCompatibilityFlag.resize( maxNumLayers ); |
---|
| 4140 | |
---|
| 4141 | for ( Int i = 0; i < maxNumLayers; i++) |
---|
[622] | 4142 | { |
---|
[1313] | 4143 | m_tileBoundariesAlignedFlag [i].resize( maxNumLayers ); |
---|
| 4144 | m_minSpatialSegmentOffsetPlus1[i].resize( maxNumLayers ); |
---|
| 4145 | m_ctuBasedOffsetEnabledFlag [i].resize( maxNumLayers ); |
---|
| 4146 | m_minHorizontalCtuOffsetPlus1 [i].resize( maxNumLayers ); |
---|
| 4147 | for ( Int j = 0; j < maxNumLayers; j++) |
---|
[622] | 4148 | { |
---|
| 4149 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
| 4150 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
| 4151 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
| 4152 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
| 4153 | } |
---|
[872] | 4154 | m_baseLayerParameterSetCompatibilityFlag[i] = false; |
---|
[622] | 4155 | } |
---|
[738] | 4156 | m_vpsVuiBspHrdPresentFlag = false; |
---|
[608] | 4157 | } |
---|
[738] | 4158 | |
---|
[1313] | 4159 | Void TComRepFormat::inferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) |
---|
[738] | 4160 | { |
---|
| 4161 | setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
| 4162 | setSeparateColourPlaneVpsFlag ( prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
| 4163 | setBitDepthVpsLumaMinus8 ( prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
| 4164 | setBitDepthVpsChromaMinus8 ( prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
[1313] | 4165 | } |
---|
| 4166 | |
---|
| 4167 | Void TComRepFormat::checkInferChromaAndBitDepth( const TComRepFormat* prevRepFormat ) const |
---|
| 4168 | { |
---|
[738] | 4169 | assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
| 4170 | assert( getSeparateColourPlaneVpsFlag () == prevRepFormat->getSeparateColourPlaneVpsFlag () ); |
---|
| 4171 | assert( getBitDepthVpsLumaMinus8 () == prevRepFormat->getBitDepthVpsLumaMinus8 () ); |
---|
| 4172 | assert( getBitDepthVpsChromaMinus8 () == prevRepFormat->getBitDepthVpsChromaMinus8 () ); |
---|
| 4173 | } |
---|
| 4174 | |
---|
[1313] | 4175 | Int TComVpsVuiBspHrdParameters::getBspHrdIdxLen( const TComVPS* vps) const |
---|
[1066] | 4176 | { |
---|
| 4177 | return gCeilLog2( vps->getNumHrdParameters() + getVpsNumAddHrdParams() ); |
---|
| 4178 | } |
---|
| 4179 | |
---|
[1313] | 4180 | Void TComVpsVuiBspHrdParameters::createAfterVpsNumAddHrdParams( const TComVPS* vps ) |
---|
[1066] | 4181 | { |
---|
| 4182 | m_offsetHrdParamIdx = vps->getNumHrdParameters(); |
---|
| 4183 | m_numHrdParam = vps->getNumHrdParameters() + getVpsNumAddHrdParams() - m_offsetHrdParamIdx; |
---|
| 4184 | m_numOls = vps->getNumOutputLayerSets(); |
---|
| 4185 | |
---|
[1313] | 4186 | m_cprmsAddPresentFlag .resize( m_numHrdParam ); |
---|
| 4187 | m_numSubLayerHrdMinus1.resize( m_numHrdParam ); |
---|
| 4188 | m_hrdParameters .resize( m_numHrdParam ); |
---|
[1066] | 4189 | |
---|
[1313] | 4190 | m_numSignalledPartitioningSchemes .resize( m_numOls ); |
---|
| 4191 | m_numPartitionsInSchemeMinus1 .resize( m_numOls ); |
---|
| 4192 | m_numBspSchedulesMinus1 .resize( m_numOls ); |
---|
| 4193 | m_bspHrdIdx .resize( m_numOls ); |
---|
| 4194 | m_bspSchedIdx .resize( m_numOls ); |
---|
[1066] | 4195 | } |
---|
| 4196 | |
---|
[1313] | 4197 | Void TComVpsVuiBspHrdParameters::createAfterNumSignalledPartitioningSchemes( const TComVPS* vps, Int h ) |
---|
[1066] | 4198 | { |
---|
[1313] | 4199 | m_numPartitionsInSchemeMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
| 4200 | m_layerIncludedInPartitionFlag[h].resize( getNumSignalledPartitioningSchemes(h) ); |
---|
[1066] | 4201 | |
---|
[1313] | 4202 | m_numBspSchedulesMinus1 [h].resize( getNumSignalledPartitioningSchemes(h) + 1 ); |
---|
[1066] | 4203 | for (Int i = 0; i < getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
| 4204 | { |
---|
[1313] | 4205 | Int tMax = vps->getMaxSubLayersInLayerSetMinus1( m_vps->olsIdxToLsIdx(h) ) + 1; |
---|
| 4206 | m_numBspSchedulesMinus1[h][i].resize( tMax ); |
---|
| 4207 | m_bspHrdIdx [h][i].resize( tMax ); |
---|
| 4208 | m_bspSchedIdx [h][i].resize( tMax ); |
---|
[1066] | 4209 | } |
---|
| 4210 | } |
---|
| 4211 | |
---|
[1313] | 4212 | Void TComVpsVuiBspHrdParameters::createAfterNumPartitionsInSchemeMinus1( const TComVPS* vps, Int h, Int j ) |
---|
[1066] | 4213 | { |
---|
[1313] | 4214 | m_layerIncludedInPartitionFlag[h][j].resize( getNumPartitionsInSchemeMinus1(h,j)); |
---|
[1066] | 4215 | for( Int k = 0; k < getNumPartitionsInSchemeMinus1(h,j); k++ ) |
---|
| 4216 | { |
---|
[1313] | 4217 | m_layerIncludedInPartitionFlag[h][j][k].resize( m_vps->getNumLayersInIdList( vps->olsIdxToLsIdx(h))); |
---|
[1066] | 4218 | } |
---|
| 4219 | } |
---|
| 4220 | |
---|
[1313] | 4221 | Void TComVpsVuiBspHrdParameters::createAfterNumBspSchedulesMinus1( const TComVPS* vps, Int h, Int i, Int t ) |
---|
[1066] | 4222 | { |
---|
[1313] | 4223 | m_bspSchedIdx[h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
| 4224 | m_bspHrdIdx [h][i][t].resize( getNumBspSchedulesMinus1( h, i, t ) + 1 ); |
---|
[1066] | 4225 | for( Int j = 0; j < getNumBspSchedulesMinus1( h, i, t ) + 1; j++ ) |
---|
| 4226 | { |
---|
[1313] | 4227 | m_bspSchedIdx[h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
| 4228 | m_bspHrdIdx [h][i][t][j].resize( getNumPartitionsInSchemeMinus1( h, i ) ); |
---|
[1066] | 4229 | } |
---|
| 4230 | } |
---|
| 4231 | |
---|
| 4232 | |
---|
[1313] | 4233 | Void TComVUI::inferVideoSignalInfo( const TComVPS* vps, Int layerIdCurr ) |
---|
[773] | 4234 | { |
---|
| 4235 | if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) |
---|
| 4236 | { |
---|
| 4237 | return; |
---|
| 4238 | } |
---|
| 4239 | |
---|
[1313] | 4240 | const TComVPSVUI* vpsVui = vps->getVPSVUI(); |
---|
| 4241 | assert( vpsVui != NULL ); |
---|
[773] | 4242 | |
---|
[1313] | 4243 | const TComVideoSignalInfo* videoSignalInfo = vpsVui->getVideoSignalInfo( vpsVui->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
[773] | 4244 | assert( videoSignalInfo != NULL ); |
---|
| 4245 | |
---|
| 4246 | setVideoFormat ( videoSignalInfo->getVideoVpsFormat () ); |
---|
| 4247 | setVideoFullRangeFlag ( videoSignalInfo->getVideoFullRangeVpsFlag () ); |
---|
| 4248 | setColourPrimaries ( videoSignalInfo->getColourPrimariesVps () ); |
---|
| 4249 | setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() ); |
---|
| 4250 | setMatrixCoefficients ( videoSignalInfo->getMatrixCoeffsVps () ); |
---|
| 4251 | } |
---|
[884] | 4252 | |
---|
[1313] | 4253 | Void TComDpbSize::init( Int numOutputLayerSets, Int maxNumLayerIds, Int maxNumSubLayers ) |
---|
[884] | 4254 | { |
---|
[1313] | 4255 | m_subLayerFlagInfoPresentFlag.resize( numOutputLayerSets ); |
---|
| 4256 | m_subLayerDpbInfoPresentFlag .resize( numOutputLayerSets ); |
---|
| 4257 | m_maxVpsDecPicBufferingMinus1.resize( numOutputLayerSets ); |
---|
| 4258 | m_maxVpsNumReorderPics .resize( numOutputLayerSets ); |
---|
| 4259 | m_maxVpsLatencyIncreasePlus1 .resize( numOutputLayerSets ); |
---|
| 4260 | |
---|
| 4261 | for (Int i = 0; i < numOutputLayerSets; i++ ) |
---|
[884] | 4262 | { |
---|
| 4263 | m_subLayerFlagInfoPresentFlag[i] = false; |
---|
| 4264 | |
---|
[1313] | 4265 | m_subLayerDpbInfoPresentFlag [i].resize( maxNumSubLayers ); |
---|
| 4266 | m_maxVpsDecPicBufferingMinus1[i].resize( maxNumLayerIds ); |
---|
| 4267 | m_maxVpsNumReorderPics [i].resize( maxNumSubLayers ); |
---|
| 4268 | m_maxVpsLatencyIncreasePlus1 [i].resize( maxNumSubLayers ); |
---|
| 4269 | |
---|
| 4270 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
[884] | 4271 | { |
---|
| 4272 | m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ; |
---|
| 4273 | m_maxVpsNumReorderPics [i][j] = 0; |
---|
| 4274 | m_maxVpsLatencyIncreasePlus1 [i][j] = 0; |
---|
[1313] | 4275 | } |
---|
[884] | 4276 | |
---|
[1313] | 4277 | for (Int k = 0; k < maxNumLayerIds; k++ ) |
---|
| 4278 | { |
---|
| 4279 | m_maxVpsDecPicBufferingMinus1[i][k].resize( maxNumSubLayers ); |
---|
| 4280 | for (Int j = 0; j < maxNumSubLayers; j++ ) |
---|
| 4281 | { |
---|
[1066] | 4282 | m_maxVpsDecPicBufferingMinus1[i][k][j] = MIN_INT; |
---|
[884] | 4283 | } |
---|
| 4284 | } |
---|
| 4285 | } |
---|
| 4286 | } |
---|
[976] | 4287 | |
---|
[1321] | 4288 | |
---|
| 4289 | Int TComDpbSize::getVpsMaxLatencyPictures( Int i, Int j ) const |
---|
| 4290 | { |
---|
| 4291 | return getMaxVpsNumReorderPics( i, j ) + getMaxVpsLatencyIncreasePlus1(i, j) - 1; |
---|
| 4292 | } |
---|
| 4293 | |
---|
[976] | 4294 | Void Window::scaleOffsets( Int scal ) |
---|
| 4295 | { |
---|
| 4296 | if (! m_scaledFlag ) |
---|
| 4297 | { |
---|
| 4298 | m_scaledFlag = true; |
---|
| 4299 | m_winLeftOffset *= scal; |
---|
| 4300 | m_winRightOffset *= scal; |
---|
| 4301 | m_winTopOffset *= scal; |
---|
| 4302 | m_winBottomOffset *= scal; |
---|
| 4303 | } |
---|
| 4304 | } |
---|
[1321] | 4305 | |
---|
| 4306 | Void TComStRefPicSet::inferRps( Int stRpsIdx, TComSPS* sps, Bool encoder ) |
---|
| 4307 | { |
---|
| 4308 | if ( getInterRefPicSetPredictionFlag() ) |
---|
| 4309 | { |
---|
| 4310 | // When inter_ref_pic_set_prediction_flag is equal to 1, the variables DeltaPocS0[ stRpsIdx ][ i ], UsedByCurrPicS0[ stRpsIdx ][ i ], |
---|
| 4311 | // NumNegativePics[ stRpsIdx ], DeltaPocS1[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ] and NumPositivePics[ stRpsIdx ] are |
---|
| 4312 | // derived as follows: |
---|
| 4313 | |
---|
| 4314 | Int i = 0; |
---|
| 4315 | Int refRpsIdx = getRefRpsIdx( stRpsIdx ); |
---|
| 4316 | TComStRefPicSet* refRps = sps->getStRefPicSet( refRpsIdx ); |
---|
| 4317 | |
---|
| 4318 | for( Int j = refRps->getNumPositivePicsVar( ) - 1; j >= 0; j-- ) |
---|
| 4319 | { |
---|
| 4320 | Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps(); |
---|
| 4321 | if( dPoc < 0 && getUseDeltaFlag( refRps->getNumNegativePicsVar( ) + j ) ) |
---|
| 4322 | { |
---|
| 4323 | setDeltaPocS0Var ( i, dPoc ); |
---|
| 4324 | setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumNegativePicsVar( ) + j ) ); |
---|
| 4325 | } |
---|
| 4326 | } |
---|
| 4327 | if( getDeltaRps() < 0 && getUseDeltaFlag( refRps->getNumDeltaPocs() ) ) // (7 59) |
---|
| 4328 | { |
---|
| 4329 | setDeltaPocS0Var( i, getDeltaRps() ); |
---|
| 4330 | setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() ) ); |
---|
| 4331 | } |
---|
| 4332 | for( Int j = 0; j < refRps->getNumNegativePicsVar(); j++ ) |
---|
| 4333 | { |
---|
| 4334 | Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps(); |
---|
| 4335 | if( dPoc < 0 && getUseDeltaFlag( j ) ) |
---|
| 4336 | { |
---|
| 4337 | setDeltaPocS0Var( i , dPoc); |
---|
| 4338 | setUsedByCurrPicS0Var( i++ , getUsedByCurrPicFlag( j )) ; |
---|
| 4339 | } |
---|
| 4340 | } |
---|
| 4341 | |
---|
| 4342 | setNumNegativePicsVar( i ); |
---|
| 4343 | |
---|
| 4344 | i = 0; |
---|
| 4345 | for( Int j = refRps->getNumNegativePicsVar() - 1; j >= 0; j-- ) |
---|
| 4346 | { |
---|
| 4347 | Int dPoc = refRps->getDeltaPocS0Var( j ) + getDeltaRps(); |
---|
| 4348 | if( dPoc > 0 && getUseDeltaFlag( j ) ) |
---|
| 4349 | { |
---|
| 4350 | setDeltaPocS1Var( i, dPoc ); |
---|
| 4351 | setUsedByCurrPicS1Var( i++, getUsedByCurrPicFlag( j ) ) ; |
---|
| 4352 | } |
---|
| 4353 | } |
---|
| 4354 | |
---|
| 4355 | if( getDeltaRps() > 0 && getUseDeltaFlag( refRps->getNumDeltaPocs() ) ) // (7 60) |
---|
| 4356 | { |
---|
| 4357 | setDeltaPocS1Var( i , getDeltaRps() ); |
---|
| 4358 | setUsedByCurrPicS1Var( i++ , getUsedByCurrPicFlag( refRps->getNumDeltaPocs() )); |
---|
| 4359 | } |
---|
| 4360 | |
---|
| 4361 | for( Int j = 0; j < refRps->getNumPositivePicsVar( ); j++) |
---|
| 4362 | { |
---|
| 4363 | Int dPoc = refRps->getDeltaPocS1Var( j ) + getDeltaRps(); |
---|
| 4364 | if( dPoc > 0 && getUseDeltaFlag( refRps->getNumNegativePicsVar() + j ) ) |
---|
| 4365 | { |
---|
| 4366 | setDeltaPocS1Var( i, dPoc); |
---|
| 4367 | setUsedByCurrPicS1Var( i++, getUsedByCurrPicFlag( refRps->getNumNegativePicsVar() + j )); |
---|
| 4368 | } |
---|
| 4369 | } |
---|
| 4370 | setNumPositivePicsVar( i ); |
---|
| 4371 | } |
---|
| 4372 | else |
---|
| 4373 | { |
---|
| 4374 | // When inter_ref_pic_set_prediction_flag is equal to 0, the variables NumNegativePics[ stRpsIdx ], NumPositivePics[ stRpsIdx ], |
---|
| 4375 | // UsedByCurrPicS0[ stRpsIdx ][ i ], UsedByCurrPicS1[ stRpsIdx ][ i ], DeltaPocS0[ stRpsIdx ][ i ] and DeltaPocS1[ stRpsIdx ][ i ] |
---|
| 4376 | // are derived as follows: |
---|
| 4377 | |
---|
| 4378 | setNumNegativePicsVar( getNumNegativePics( ) ); // (7 61) |
---|
| 4379 | setNumPositivePicsVar( getNumPositivePics( ) ); // (7 62) |
---|
| 4380 | |
---|
| 4381 | for (Int i = 0 ; i < getNumNegativePics(); i++ ) |
---|
| 4382 | { |
---|
| 4383 | setUsedByCurrPicS0Var( i, getUsedByCurrPicS0Flag( i ) ); // (7 63) |
---|
| 4384 | if (i == 0 ) |
---|
| 4385 | { |
---|
| 4386 | setDeltaPocS0Var( i , -( getDeltaPocS0Minus1( i ) + 1 )); // (7 65) |
---|
| 4387 | } |
---|
| 4388 | else |
---|
| 4389 | { |
---|
| 4390 | setDeltaPocS0Var( i , getDeltaPocS0Var( i - 1 ) - ( getDeltaPocS0Minus1( i ) + 1 )); // (7 67) |
---|
| 4391 | } |
---|
| 4392 | } |
---|
| 4393 | |
---|
| 4394 | for (Int i = 0 ; i < getNumPositivePics(); i++ ) |
---|
| 4395 | { |
---|
| 4396 | setUsedByCurrPicS1Var( i, getUsedByCurrPicS1Flag( i ) ); // (7 64) |
---|
| 4397 | |
---|
| 4398 | if (i == 0 ) |
---|
| 4399 | { |
---|
| 4400 | setDeltaPocS1Var( i , getDeltaPocS1Minus1( i ) + 1 ); // (7 66) |
---|
| 4401 | } |
---|
| 4402 | else |
---|
| 4403 | { |
---|
| 4404 | setDeltaPocS1Var( i , getDeltaPocS1Var( i - 1 ) + ( getDeltaPocS1Minus1( i ) + 1 )); // (7 68) |
---|
| 4405 | } |
---|
| 4406 | } |
---|
| 4407 | } |
---|
| 4408 | } |
---|
| 4409 | |
---|
[738] | 4410 | #endif |
---|