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