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