[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, 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 |
---|
[414] | 48 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
| 49 | Int ParameterSetManager::m_activeVPSId = -1; |
---|
| 50 | #if IL_SL_SIGNALLING_N0371 |
---|
| 51 | TComSPS* TComSPS::m_pcSPS[MAX_LAYERS]; |
---|
| 52 | TComPPS* TComPPS::m_pcPPS[MAX_LAYERS]; |
---|
[313] | 53 | #endif |
---|
[414] | 54 | #endif |
---|
[313] | 55 | |
---|
| 56 | TComSlice::TComSlice() |
---|
| 57 | : m_iPPSId ( -1 ) |
---|
| 58 | , m_iPOC ( 0 ) |
---|
| 59 | , m_iLastIDR ( 0 ) |
---|
| 60 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
| 61 | , m_eSliceType ( I_SLICE ) |
---|
| 62 | , m_iSliceQp ( 0 ) |
---|
| 63 | , m_dependentSliceSegmentFlag ( false ) |
---|
| 64 | #if ADAPTIVE_QP_SELECTION |
---|
| 65 | , m_iSliceQpBase ( 0 ) |
---|
| 66 | #endif |
---|
| 67 | , m_deblockingFilterDisable ( false ) |
---|
| 68 | , m_deblockingFilterOverrideFlag ( false ) |
---|
| 69 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
| 70 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
| 71 | , m_bCheckLDC ( false ) |
---|
| 72 | , m_iSliceQpDelta ( 0 ) |
---|
| 73 | , m_iSliceQpDeltaCb ( 0 ) |
---|
| 74 | , m_iSliceQpDeltaCr ( 0 ) |
---|
| 75 | , m_iDepth ( 0 ) |
---|
| 76 | , m_bRefenced ( false ) |
---|
[411] | 77 | #if POC_RESET_FLAG |
---|
| 78 | , m_bPocResetFlag ( false ) |
---|
| 79 | #endif |
---|
[313] | 80 | #if SH_DISCARDABLE_FLAG |
---|
| 81 | , m_bDiscardableFlag ( false ) |
---|
| 82 | #endif |
---|
| 83 | , m_pcSPS ( NULL ) |
---|
| 84 | , m_pcPPS ( NULL ) |
---|
| 85 | , m_pcPic ( NULL ) |
---|
| 86 | , m_colFromL0Flag ( 1 ) |
---|
| 87 | , m_colRefIdx ( 0 ) |
---|
| 88 | #if SAO_CHROMA_LAMBDA |
---|
| 89 | , m_dLambdaLuma( 0.0 ) |
---|
| 90 | , m_dLambdaChroma( 0.0 ) |
---|
| 91 | #else |
---|
| 92 | , m_dLambda ( 0.0 ) |
---|
| 93 | #endif |
---|
| 94 | , m_uiTLayer ( 0 ) |
---|
| 95 | #if SVC_EXTENSION |
---|
| 96 | , m_layerId ( 0 ) |
---|
| 97 | #endif |
---|
| 98 | , m_bTLayerSwitchingFlag ( false ) |
---|
| 99 | , m_sliceMode ( 0 ) |
---|
| 100 | , m_sliceArgument ( 0 ) |
---|
| 101 | , m_sliceCurStartCUAddr ( 0 ) |
---|
| 102 | , m_sliceCurEndCUAddr ( 0 ) |
---|
| 103 | , m_sliceIdx ( 0 ) |
---|
| 104 | , m_sliceSegmentMode ( 0 ) |
---|
| 105 | , m_sliceSegmentArgument ( 0 ) |
---|
| 106 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
| 107 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
| 108 | , m_nextSlice ( false ) |
---|
| 109 | , m_nextSliceSegment ( false ) |
---|
| 110 | , m_sliceBits ( 0 ) |
---|
| 111 | , m_sliceSegmentBits ( 0 ) |
---|
| 112 | , m_bFinalized ( false ) |
---|
| 113 | , m_uiTileOffstForMultES ( 0 ) |
---|
| 114 | , m_puiSubstreamSizes ( NULL ) |
---|
| 115 | , m_cabacInitFlag ( false ) |
---|
| 116 | , m_bLMvdL1Zero ( false ) |
---|
| 117 | , m_numEntryPointOffsets ( 0 ) |
---|
| 118 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
| 119 | , m_enableTMVPFlag ( true ) |
---|
| 120 | { |
---|
| 121 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
| 122 | |
---|
| 123 | #if SVC_EXTENSION |
---|
| 124 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
| 125 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 126 | m_activeNumILRRefIdx = 0; |
---|
| 127 | m_interLayerPredEnabledFlag = 0; |
---|
| 128 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
| 129 | #else |
---|
| 130 | m_numILRRefIdx = 0; |
---|
| 131 | #endif |
---|
[345] | 132 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 133 | m_altColIndicationFlag = false; |
---|
| 134 | m_colRefLayerIdx = 0; |
---|
| 135 | #endif |
---|
| 136 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 137 | m_numSamplePredRefLayers = 0; |
---|
| 138 | m_interLayerSamplePredOnlyFlag = false; |
---|
| 139 | #endif |
---|
| 140 | #endif |
---|
| 141 | |
---|
| 142 | initEqualRef(); |
---|
| 143 | |
---|
| 144 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
| 145 | { |
---|
| 146 | m_list1IdxToList0Idx[idx] = -1; |
---|
| 147 | } |
---|
| 148 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
| 149 | { |
---|
| 150 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
| 151 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
| 152 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
| 153 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
| 154 | } |
---|
| 155 | resetWpScaling(); |
---|
| 156 | initWpAcDcParam(); |
---|
| 157 | m_saoEnabledFlag = false; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | TComSlice::~TComSlice() |
---|
| 161 | { |
---|
| 162 | delete[] m_puiSubstreamSizes; |
---|
| 163 | m_puiSubstreamSizes = NULL; |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | #if SVC_EXTENSION |
---|
| 168 | Void TComSlice::initSlice( UInt layerId ) |
---|
| 169 | #else |
---|
| 170 | Void TComSlice::initSlice() |
---|
| 171 | #endif |
---|
| 172 | { |
---|
| 173 | #if SVC_EXTENSION |
---|
| 174 | m_layerId = layerId; |
---|
| 175 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 176 | m_activeNumILRRefIdx = 0; |
---|
| 177 | m_interLayerPredEnabledFlag = 0; |
---|
| 178 | #else |
---|
| 179 | m_numILRRefIdx = 0; |
---|
[377] | 180 | #endif |
---|
[313] | 181 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 182 | m_numSamplePredRefLayers = 0; |
---|
| 183 | m_interLayerSamplePredOnlyFlag = false; |
---|
| 184 | #endif |
---|
| 185 | #endif |
---|
[377] | 186 | m_aiNumRefIdx[0] = 0; |
---|
| 187 | m_aiNumRefIdx[1] = 0; |
---|
[313] | 188 | m_colFromL0Flag = 1; |
---|
| 189 | |
---|
| 190 | m_colRefIdx = 0; |
---|
| 191 | initEqualRef(); |
---|
| 192 | m_bCheckLDC = false; |
---|
| 193 | m_iSliceQpDeltaCb = 0; |
---|
| 194 | m_iSliceQpDeltaCr = 0; |
---|
| 195 | |
---|
| 196 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
| 197 | |
---|
| 198 | m_bFinalized=false; |
---|
| 199 | |
---|
| 200 | m_tileByteLocation.clear(); |
---|
| 201 | m_cabacInitFlag = false; |
---|
| 202 | m_numEntryPointOffsets = 0; |
---|
| 203 | m_enableTMVPFlag = true; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | Bool TComSlice::getRapPicFlag() |
---|
| 207 | { |
---|
| 208 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 209 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 210 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 211 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 212 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 213 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | /** |
---|
| 217 | - allocate table to contain substream sizes to be written to the slice header. |
---|
| 218 | . |
---|
| 219 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
| 220 | */ |
---|
| 221 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
| 222 | { |
---|
| 223 | delete[] m_puiSubstreamSizes; |
---|
| 224 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | Void TComSlice::sortPicList(TComList<TComPic*>& rcListPic) |
---|
| 228 | { |
---|
| 229 | TComPic* pcPicExtract; |
---|
| 230 | TComPic* pcPicInsert; |
---|
| 231 | |
---|
| 232 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 233 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 234 | TComList<TComPic*>::iterator iterPicInsert; |
---|
| 235 | |
---|
| 236 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 237 | { |
---|
| 238 | iterPicExtract = rcListPic.begin(); |
---|
| 239 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
| 240 | pcPicExtract = *(iterPicExtract); |
---|
| 241 | pcPicExtract->setCurrSliceIdx(0); |
---|
| 242 | |
---|
| 243 | iterPicInsert = rcListPic.begin(); |
---|
| 244 | while (iterPicInsert != iterPicExtract) |
---|
| 245 | { |
---|
| 246 | pcPicInsert = *(iterPicInsert); |
---|
| 247 | pcPicInsert->setCurrSliceIdx(0); |
---|
| 248 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
| 249 | { |
---|
| 250 | break; |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | iterPicInsert++; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
| 257 | |
---|
| 258 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 259 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 260 | rcListPic.erase (iterPicExtract); |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
| 265 | Int poc) |
---|
| 266 | { |
---|
| 267 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 268 | TComPic* pcPic = *(iterPic); |
---|
| 269 | while ( iterPic != rcListPic.end() ) |
---|
| 270 | { |
---|
| 271 | if(pcPic->getPOC() == poc) |
---|
| 272 | { |
---|
| 273 | break; |
---|
| 274 | } |
---|
| 275 | iterPic++; |
---|
| 276 | pcPic = *(iterPic); |
---|
| 277 | } |
---|
[411] | 278 | #if POC_RESET_FLAG |
---|
| 279 | assert( pcPic->getSlice(0)->isReferenced() ); |
---|
| 280 | #endif |
---|
[313] | 281 | return pcPic; |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
| 286 | { |
---|
| 287 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 288 | TComPic* pcPic = *(iterPic); |
---|
| 289 | TComPic* pcStPic = pcPic; |
---|
| 290 | |
---|
| 291 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
| 292 | if (!pocHasMsb) |
---|
| 293 | { |
---|
| 294 | poc = poc % pocCycle; |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | while ( iterPic != rcListPic.end() ) |
---|
| 298 | { |
---|
| 299 | pcPic = *(iterPic); |
---|
| 300 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
| 301 | { |
---|
| 302 | Int picPoc = pcPic->getPOC(); |
---|
| 303 | if (!pocHasMsb) |
---|
| 304 | { |
---|
| 305 | picPoc = picPoc % pocCycle; |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | if (poc == picPoc) |
---|
| 309 | { |
---|
| 310 | if (pcPic->getIsLongTerm()) |
---|
| 311 | { |
---|
| 312 | return pcPic; |
---|
| 313 | } |
---|
| 314 | else |
---|
| 315 | { |
---|
| 316 | pcStPic = pcPic; |
---|
| 317 | } |
---|
| 318 | break; |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | iterPic++; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | return pcStPic; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | Void TComSlice::setRefPOCList() |
---|
| 329 | { |
---|
| 330 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 331 | { |
---|
| 332 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
| 333 | { |
---|
| 334 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | Void TComSlice::setList1IdxToList0Idx() |
---|
| 341 | { |
---|
| 342 | Int idxL0, idxL1; |
---|
| 343 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
| 344 | { |
---|
| 345 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
| 346 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
| 347 | { |
---|
| 348 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
| 349 | { |
---|
| 350 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
| 351 | break; |
---|
| 352 | } |
---|
| 353 | } |
---|
| 354 | } |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | #if FIX1071 |
---|
| 358 | #if SVC_EXTENSION |
---|
| 359 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
| 360 | #else |
---|
| 361 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
| 362 | #endif |
---|
| 363 | #else |
---|
| 364 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) |
---|
| 365 | #endif |
---|
| 366 | { |
---|
| 367 | #if FIX1071 |
---|
| 368 | if (!checkNumPocTotalCurr) |
---|
| 369 | #endif |
---|
| 370 | { |
---|
| 371 | if (m_eSliceType == I_SLICE) |
---|
| 372 | { |
---|
| 373 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 374 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 375 | |
---|
| 376 | return; |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 380 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | TComPic* pcRefPic= NULL; |
---|
| 384 | TComPic* RefPicSetStCurr0[16]; |
---|
| 385 | TComPic* RefPicSetStCurr1[16]; |
---|
| 386 | TComPic* RefPicSetLtCurr[16]; |
---|
| 387 | UInt NumPocStCurr0 = 0; |
---|
| 388 | UInt NumPocStCurr1 = 0; |
---|
| 389 | UInt NumPocLtCurr = 0; |
---|
| 390 | Int i; |
---|
| 391 | |
---|
[377] | 392 | #if SVC_EXTENSION |
---|
[313] | 393 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) ) |
---|
| 394 | { |
---|
| 395 | #endif |
---|
| 396 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
| 397 | { |
---|
| 398 | if(m_pcRPS->getUsed(i)) |
---|
| 399 | { |
---|
| 400 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 401 | pcRefPic->setIsLongTerm(0); |
---|
| 402 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 403 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 404 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 405 | if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) |
---|
| 406 | #endif |
---|
| 407 | NumPocStCurr0++; |
---|
| 408 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 409 | } |
---|
| 410 | } |
---|
| 411 | |
---|
| 412 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
| 413 | { |
---|
| 414 | if(m_pcRPS->getUsed(i)) |
---|
| 415 | { |
---|
| 416 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 417 | pcRefPic->setIsLongTerm(0); |
---|
| 418 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 419 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 420 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 421 | if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) |
---|
| 422 | #endif |
---|
| 423 | NumPocStCurr1++; |
---|
| 424 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
| 429 | { |
---|
| 430 | if(m_pcRPS->getUsed(i)) |
---|
| 431 | { |
---|
| 432 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 433 | pcRefPic->setIsLongTerm(1); |
---|
| 434 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 435 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 436 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 437 | if( !m_interLayerSamplePredOnlyFlag || pcRefPic->getLayerId() < getLayerId()) |
---|
| 438 | #endif |
---|
| 439 | NumPocLtCurr++; |
---|
| 440 | } |
---|
| 441 | if(pcRefPic==NULL) |
---|
| 442 | { |
---|
| 443 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 444 | } |
---|
| 445 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 446 | } |
---|
[377] | 447 | #if SVC_EXTENSION |
---|
[313] | 448 | } |
---|
| 449 | #endif |
---|
| 450 | |
---|
[377] | 451 | #if SVC_EXTENSION |
---|
[313] | 452 | for( i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 453 | { |
---|
| 454 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 455 | //inter-layer reference picture |
---|
| 456 | |
---|
| 457 | #if ILR_RESTR |
---|
[399] | 458 | Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0; |
---|
| 459 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) ) |
---|
[313] | 460 | #else //#if ILR_RESTR |
---|
| 461 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
| 462 | #endif //#if ILR_RESTR |
---|
| 463 | { |
---|
| 464 | #if REF_IDX_MFM |
---|
| 465 | #if M0457_COL_PICTURE_SIGNALING |
---|
| 466 | if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && getMFMEnabledFlag()) |
---|
| 467 | #else |
---|
| 468 | if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag()) |
---|
| 469 | #endif |
---|
| 470 | { |
---|
| 471 | ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] ); |
---|
| 472 | } |
---|
| 473 | else |
---|
| 474 | { |
---|
| 475 | ilpPic[refLayerIdc]->initUpsampledMvField(); |
---|
| 476 | } |
---|
| 477 | #endif |
---|
| 478 | ilpPic[refLayerIdc]->setIsLongTerm(1); |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | #endif |
---|
| 482 | // ref_pic_list_init |
---|
| 483 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
| 484 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
[377] | 485 | #if SVC_EXTENSION |
---|
[313] | 486 | #if ILR_RESTR |
---|
| 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 | { |
---|
[399] | 496 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
| 497 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) ) |
---|
[313] | 498 | { |
---|
| 499 | numInterLayerRPSPics++; |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 503 | if (numInterLayerRPSPics < m_activeNumILRRefIdx) |
---|
| 504 | { |
---|
| 505 | m_activeNumILRRefIdx = numInterLayerRPSPics; |
---|
| 506 | } |
---|
[370] | 507 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
[405] | 508 | #if SCALABILITY_MASK_E0104 |
---|
| 509 | if( m_pcVPS->getScalabilityMask(2) ) |
---|
| 510 | #else |
---|
[313] | 511 | if( m_pcVPS->getScalabilityMask(1) ) |
---|
[405] | 512 | #endif |
---|
[313] | 513 | { |
---|
| 514 | Int numResampler = 0; |
---|
[396] | 515 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
| 516 | Int numMotionResamplers = 0; |
---|
| 517 | Int refResamplingLayer[MAX_LAYERS]; |
---|
| 518 | memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); |
---|
| 519 | #endif |
---|
[313] | 520 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
| 521 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
| 522 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
| 523 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
| 524 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
| 525 | ); |
---|
| 526 | |
---|
| 527 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 528 | { |
---|
| 529 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
[387] | 530 | if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x |
---|
[313] | 531 | { |
---|
[396] | 532 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
| 533 | UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ) ) + 1; |
---|
| 534 | |
---|
| 535 | if( predType & 0x1 ) |
---|
| 536 | { |
---|
| 537 | numResampler++; |
---|
| 538 | refResamplingLayer[i] = refLayerIdc + 1; |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | if( predType & 0x2 ) |
---|
| 542 | { |
---|
| 543 | numMotionResamplers++; |
---|
| 544 | refResamplingLayer[i] -= refLayerIdc + 1; |
---|
| 545 | } |
---|
| 546 | #else |
---|
[313] | 547 | numResampler++; |
---|
[396] | 548 | #endif |
---|
[313] | 549 | } |
---|
| 550 | } |
---|
[396] | 551 | |
---|
| 552 | // 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. |
---|
| 553 | if( m_activeNumILRRefIdx > 1 && numResampler > 0 ) |
---|
| 554 | { |
---|
| 555 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 556 | { |
---|
| 557 | assert( refResamplingLayer[i] >= 0 && "Motion and sample inter-layer prediction shall be from the same layer" ); |
---|
| 558 | } |
---|
| 559 | } |
---|
[313] | 560 | |
---|
[396] | 561 | // Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture. |
---|
[313] | 562 | assert(numResampler <= 1); |
---|
[396] | 563 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
| 564 | assert( numMotionResamplers <= 1 && "Up to 1 motion resampling is allowed" ); |
---|
| 565 | #endif |
---|
[313] | 566 | } |
---|
| 567 | #endif |
---|
| 568 | #else |
---|
| 569 | if (numInterLayerRPSPics < m_numILRRefIdx) |
---|
| 570 | { |
---|
| 571 | m_numILRRefIdx = numInterLayerRPSPics; |
---|
| 572 | } |
---|
| 573 | #endif |
---|
| 574 | } |
---|
| 575 | #endif |
---|
| 576 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 577 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx; |
---|
| 578 | #else |
---|
| 579 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_numILRRefIdx; |
---|
| 580 | #endif |
---|
| 581 | #else |
---|
| 582 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
| 583 | #endif |
---|
| 584 | #if FIX1071 |
---|
| 585 | if (checkNumPocTotalCurr) |
---|
| 586 | { |
---|
| 587 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
| 588 | #if ILP_RAP // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
| 589 | // – 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. |
---|
| 590 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 591 | if (getRapPicFlag() && getLayerId()==0) |
---|
| 592 | #else |
---|
| 593 | // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 594 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 595 | if (getRapPicFlag()) |
---|
| 596 | #endif |
---|
| 597 | { |
---|
| 598 | assert(numPocTotalCurr == 0); |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | if (m_eSliceType == I_SLICE) |
---|
| 602 | { |
---|
| 603 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 604 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 605 | |
---|
| 606 | return; |
---|
| 607 | } |
---|
| 608 | |
---|
| 609 | assert(numPocTotalCurr > 0); |
---|
| 610 | |
---|
| 611 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 612 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 613 | } |
---|
| 614 | #endif |
---|
| 615 | |
---|
| 616 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 617 | if( m_interLayerSamplePredOnlyFlag && getLayerId() ) |
---|
| 618 | { |
---|
| 619 | m_aiNumRefIdx[0] = m_aiNumRefIdx[0] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[0]; |
---|
| 620 | m_aiNumRefIdx[1] = m_aiNumRefIdx[1] > m_activeNumILRRefIdx ? m_activeNumILRRefIdx : m_aiNumRefIdx[1]; |
---|
| 621 | } |
---|
| 622 | #endif |
---|
| 623 | |
---|
| 624 | Int cIdx = 0; |
---|
| 625 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 626 | { |
---|
| 627 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
| 628 | } |
---|
[377] | 629 | #if SVC_EXTENSION |
---|
[345] | 630 | #if RPL_INIT_N0316_N0082 |
---|
| 631 | if( m_layerId > 0 ) |
---|
| 632 | { |
---|
| 633 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 634 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 635 | #else |
---|
| 636 | for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 637 | #endif |
---|
| 638 | { |
---|
| 639 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 640 | #if ILR_RESTR |
---|
[399] | 641 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
| 642 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
[345] | 643 | #endif |
---|
| 644 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | #endif |
---|
| 648 | #endif |
---|
[313] | 649 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 650 | { |
---|
| 651 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
| 652 | } |
---|
| 653 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 654 | { |
---|
| 655 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
| 656 | } |
---|
[345] | 657 | #if !RPL_INIT_N0316_N0082 |
---|
[377] | 658 | #if SVC_EXTENSION |
---|
[313] | 659 | if( m_layerId > 0 ) |
---|
| 660 | { |
---|
| 661 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 662 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 663 | #else |
---|
| 664 | for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 665 | #endif |
---|
| 666 | { |
---|
| 667 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 668 | #if ILR_RESTR |
---|
[399] | 669 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
| 670 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
[313] | 671 | #endif |
---|
| 672 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | #endif |
---|
[345] | 676 | #endif |
---|
[313] | 677 | assert(cIdx == numPocTotalCurr); |
---|
| 678 | |
---|
| 679 | if (m_eSliceType==B_SLICE) |
---|
| 680 | { |
---|
| 681 | cIdx = 0; |
---|
| 682 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 683 | { |
---|
| 684 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
| 685 | } |
---|
| 686 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 687 | { |
---|
| 688 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
| 689 | } |
---|
| 690 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 691 | { |
---|
| 692 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
| 693 | } |
---|
| 694 | |
---|
[377] | 695 | #if SVC_EXTENSION |
---|
[313] | 696 | if( m_layerId > 0 ) |
---|
| 697 | { |
---|
| 698 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 699 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 700 | #else |
---|
| 701 | for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
| 702 | #endif |
---|
| 703 | { |
---|
| 704 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 705 | #if ILR_RESTR |
---|
[399] | 706 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
| 707 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
[313] | 708 | #endif |
---|
| 709 | rpsCurrList1[cIdx] = ilpPic[refLayerIdc]; |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | #endif |
---|
| 713 | |
---|
| 714 | assert(cIdx == numPocTotalCurr); |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 718 | |
---|
| 719 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
| 720 | { |
---|
| 721 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
| 722 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
| 723 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
[349] | 724 | #if RPL_INIT_N0316_N0082 |
---|
[361] | 725 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 && cIdx < NumPocStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPocStCurr0 + NumPocStCurr1 + m_activeNumILRRefIdx ); |
---|
[349] | 726 | #else |
---|
[313] | 727 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
[349] | 728 | #endif |
---|
[313] | 729 | } |
---|
| 730 | if ( m_eSliceType != B_SLICE ) |
---|
| 731 | { |
---|
| 732 | m_aiNumRefIdx[1] = 0; |
---|
| 733 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
| 734 | } |
---|
| 735 | else |
---|
| 736 | { |
---|
| 737 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
| 738 | { |
---|
| 739 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
| 740 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
| 741 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
| 742 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
| 743 | } |
---|
| 744 | } |
---|
| 745 | } |
---|
| 746 | |
---|
[377] | 747 | #if SVC_EXTENSION |
---|
[313] | 748 | Void TComSlice::setRefPicListModificationSvc() |
---|
| 749 | { |
---|
| 750 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
| 751 | { |
---|
| 752 | return; |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
| 756 | { |
---|
| 757 | return; |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
| 761 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
[345] | 762 | #if RPL_INIT_N0316_N0082 |
---|
| 763 | Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
| 764 | #endif |
---|
[313] | 765 | |
---|
[429] | 766 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 767 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
| 768 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
| 769 | #else |
---|
[313] | 770 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1); |
---|
| 771 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 1); |
---|
[429] | 772 | #endif |
---|
[313] | 773 | |
---|
[429] | 774 | |
---|
[313] | 775 | //set L0 inter-layer reference picture modification |
---|
[345] | 776 | #if RPL_INIT_N0316_N0082 |
---|
| 777 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
[429] | 778 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 779 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
| 780 | #endif |
---|
[345] | 781 | #else |
---|
[313] | 782 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
[429] | 783 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 784 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
[345] | 785 | #endif |
---|
[429] | 786 | |
---|
| 787 | #endif |
---|
[345] | 788 | #if FINAL_RPL_CHANGE_N0082 |
---|
| 789 | hasModification = false; //modification is not necessary |
---|
| 790 | #endif |
---|
[313] | 791 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
| 792 | if(hasModification) |
---|
| 793 | { |
---|
| 794 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
| 795 | { |
---|
| 796 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
| 797 | } |
---|
| 798 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
| 799 | { |
---|
| 800 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
| 801 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
| 802 | { |
---|
| 803 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | else |
---|
| 807 | { |
---|
| 808 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 809 | for(Int i = m_activeNumILRRefIdx; i > 0; i-- ) |
---|
| 810 | #else |
---|
| 811 | for(Int i = m_numILRRefIdx; i > 0; i-- ) |
---|
| 812 | #endif |
---|
| 813 | { |
---|
[345] | 814 | #if RPL_INIT_N0316_N0082 |
---|
| 815 | if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
[355] | 816 | { |
---|
[345] | 817 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr); |
---|
[355] | 818 | } |
---|
[345] | 819 | else |
---|
| 820 | { |
---|
| 821 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr); |
---|
| 822 | for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++) |
---|
[355] | 823 | { |
---|
[345] | 824 | refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx); |
---|
[355] | 825 | } |
---|
[345] | 826 | } |
---|
| 827 | #else |
---|
[313] | 828 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
[345] | 829 | #endif |
---|
[313] | 830 | } |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | //set L1 inter-layer reference picture modification |
---|
| 835 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] == numberOfRpsCurrTempList) ? false : true; |
---|
[429] | 836 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 837 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
| 838 | #endif |
---|
| 839 | |
---|
[313] | 840 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
| 841 | if(hasModification) |
---|
| 842 | { |
---|
| 843 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
| 844 | { |
---|
| 845 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
| 846 | } |
---|
| 847 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
| 848 | { |
---|
| 849 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
| 850 | { |
---|
| 851 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
| 852 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | else |
---|
| 856 | { |
---|
| 857 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 858 | for(Int i = m_activeNumILRRefIdx; i > 0; i-- ) |
---|
| 859 | #else |
---|
| 860 | for(Int i = m_numILRRefIdx; i > 0; i-- ) |
---|
| 861 | #endif |
---|
| 862 | { |
---|
| 863 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
| 864 | } |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | return; |
---|
| 868 | } |
---|
| 869 | #endif |
---|
[345] | 870 | #if RPL_INIT_N0316_N0082 |
---|
| 871 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
| 872 | { |
---|
| 873 | if( m_eSliceType == I_SLICE ) |
---|
| 874 | { |
---|
| 875 | return 0; |
---|
| 876 | } |
---|
[313] | 877 | |
---|
[345] | 878 | Int numPocBeforeCurr = 0; |
---|
| 879 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
| 880 | { |
---|
| 881 | if(m_pcRPS->getUsed(i)) |
---|
| 882 | { |
---|
| 883 | numPocBeforeCurr++; |
---|
| 884 | } |
---|
| 885 | } |
---|
| 886 | |
---|
| 887 | return numPocBeforeCurr; |
---|
| 888 | } |
---|
| 889 | #endif |
---|
[313] | 890 | Int TComSlice::getNumRpsCurrTempList() |
---|
| 891 | { |
---|
| 892 | Int numRpsCurrTempList = 0; |
---|
| 893 | |
---|
[377] | 894 | #if SVC_EXTENSION |
---|
[313] | 895 | if( m_eSliceType == I_SLICE || ( m_pcSPS->getLayerId() && |
---|
| 896 | (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
| 897 | (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
| 898 | #else |
---|
| 899 | if (m_eSliceType == I_SLICE) |
---|
| 900 | #endif |
---|
| 901 | { |
---|
[377] | 902 | #if SVC_EXTENSION |
---|
[313] | 903 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 904 | return m_activeNumILRRefIdx; |
---|
| 905 | #else |
---|
| 906 | return getNumILRRefIdx(); |
---|
| 907 | #endif |
---|
| 908 | #else |
---|
| 909 | return 0; |
---|
| 910 | #endif |
---|
| 911 | } |
---|
| 912 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
| 913 | { |
---|
| 914 | if(m_pcRPS->getUsed(i)) |
---|
| 915 | { |
---|
| 916 | numRpsCurrTempList++; |
---|
| 917 | } |
---|
| 918 | } |
---|
[377] | 919 | #if SVC_EXTENSION |
---|
[313] | 920 | if( m_layerId > 0 ) |
---|
| 921 | { |
---|
| 922 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 923 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
| 924 | #else |
---|
| 925 | numRpsCurrTempList += getNumILRRefIdx(); |
---|
| 926 | #endif |
---|
| 927 | } |
---|
| 928 | #endif |
---|
| 929 | |
---|
| 930 | return numRpsCurrTempList; |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | Void TComSlice::initEqualRef() |
---|
| 934 | { |
---|
| 935 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 936 | { |
---|
| 937 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 938 | { |
---|
| 939 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 940 | { |
---|
| 941 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 942 | } |
---|
| 943 | } |
---|
| 944 | } |
---|
| 945 | } |
---|
| 946 | |
---|
| 947 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 948 | { |
---|
| 949 | Int i; |
---|
| 950 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
| 951 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
| 952 | TComSlice* preSlice; |
---|
| 953 | Int preColRefPOC; |
---|
| 954 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 955 | { |
---|
| 956 | preSlice = pic->getSlice(i); |
---|
| 957 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 958 | { |
---|
| 959 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
| 960 | if(currColRefPOC != preColRefPOC) |
---|
| 961 | { |
---|
| 962 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 963 | exit(EXIT_FAILURE); |
---|
| 964 | } |
---|
| 965 | else |
---|
| 966 | { |
---|
| 967 | break; |
---|
| 968 | } |
---|
| 969 | } |
---|
| 970 | } |
---|
| 971 | } |
---|
| 972 | |
---|
| 973 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic) |
---|
| 974 | { |
---|
| 975 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 976 | { |
---|
| 977 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 978 | { |
---|
| 979 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 980 | } |
---|
| 981 | } |
---|
| 982 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 983 | { |
---|
| 984 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 985 | { |
---|
| 986 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 987 | { |
---|
| 988 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
| 989 | } |
---|
| 990 | else |
---|
| 991 | { |
---|
| 992 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 993 | } |
---|
| 994 | } |
---|
| 995 | } |
---|
| 996 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
| 997 | { |
---|
| 998 | pocCRA = getPOC(); |
---|
| 999 | prevRAPisBLA = false; |
---|
| 1000 | } |
---|
| 1001 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 1002 | { |
---|
| 1003 | pocCRA = getPOC(); |
---|
| 1004 | prevRAPisBLA = false; |
---|
| 1005 | } |
---|
| 1006 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1007 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1008 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 1009 | { |
---|
| 1010 | pocCRA = getPOC(); |
---|
| 1011 | prevRAPisBLA = true; |
---|
| 1012 | } |
---|
| 1013 | } |
---|
| 1014 | |
---|
| 1015 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 1016 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
| 1017 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 1018 | * \param rcListPic reference to the reference picture list |
---|
| 1019 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
| 1020 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
| 1021 | * are marked as "unused for reference" |
---|
| 1022 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 1023 | * Otherwise |
---|
| 1024 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
| 1025 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 1026 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
| 1027 | * the bRefreshPending flag to false. |
---|
| 1028 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
| 1029 | * reference of the current picture. |
---|
| 1030 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 1031 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 1032 | */ |
---|
| 1033 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
| 1034 | { |
---|
| 1035 | TComPic* rpcPic; |
---|
| 1036 | Int pocCurr = getPOC(); |
---|
| 1037 | |
---|
| 1038 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1039 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1040 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1041 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 1042 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
| 1043 | { |
---|
| 1044 | // mark all pictures as not used for reference |
---|
| 1045 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1046 | while (iterPic != rcListPic.end()) |
---|
| 1047 | { |
---|
| 1048 | rpcPic = *(iterPic); |
---|
| 1049 | rpcPic->setCurrSliceIdx(0); |
---|
| 1050 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
| 1051 | iterPic++; |
---|
| 1052 | } |
---|
| 1053 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1054 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1055 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1056 | { |
---|
| 1057 | pocCRA = pocCurr; |
---|
| 1058 | } |
---|
| 1059 | } |
---|
| 1060 | else // CRA or No DR |
---|
| 1061 | { |
---|
| 1062 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
| 1063 | { |
---|
| 1064 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1065 | while (iterPic != rcListPic.end()) |
---|
| 1066 | { |
---|
| 1067 | rpcPic = *(iterPic); |
---|
| 1068 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
| 1069 | { |
---|
| 1070 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 1071 | } |
---|
| 1072 | iterPic++; |
---|
| 1073 | } |
---|
| 1074 | bRefreshPending = false; |
---|
| 1075 | } |
---|
| 1076 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 1077 | { |
---|
| 1078 | bRefreshPending = true; |
---|
| 1079 | pocCRA = pocCurr; |
---|
| 1080 | } |
---|
| 1081 | } |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 1085 | { |
---|
| 1086 | assert( pSrc != NULL ); |
---|
| 1087 | |
---|
| 1088 | Int i, j, k; |
---|
| 1089 | |
---|
| 1090 | m_iPOC = pSrc->m_iPOC; |
---|
| 1091 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
| 1092 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 1093 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
| 1094 | #if ADAPTIVE_QP_SELECTION |
---|
| 1095 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 1096 | #endif |
---|
| 1097 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 1098 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 1099 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 1100 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
| 1101 | |
---|
| 1102 | for (i = 0; i < 2; i++) |
---|
| 1103 | { |
---|
| 1104 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 1105 | } |
---|
| 1106 | |
---|
| 1107 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
| 1108 | { |
---|
| 1109 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
| 1110 | } |
---|
| 1111 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 1112 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
| 1113 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
| 1114 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
| 1115 | for (i = 0; i < 2; i++) |
---|
| 1116 | { |
---|
| 1117 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 1118 | { |
---|
| 1119 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 1120 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | for (i = 0; i < 2; i++) |
---|
| 1124 | { |
---|
| 1125 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
| 1126 | { |
---|
| 1127 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
| 1128 | } |
---|
| 1129 | } |
---|
| 1130 | m_iDepth = pSrc->m_iDepth; |
---|
| 1131 | |
---|
| 1132 | // referenced slice |
---|
| 1133 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 1134 | |
---|
| 1135 | // access channel |
---|
| 1136 | #if SVC_EXTENSION |
---|
| 1137 | m_pcVPS = pSrc->m_pcVPS; |
---|
| 1138 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1139 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
| 1140 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
| 1141 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
| 1142 | #endif |
---|
| 1143 | #endif |
---|
| 1144 | m_pcSPS = pSrc->m_pcSPS; |
---|
| 1145 | m_pcPPS = pSrc->m_pcPPS; |
---|
| 1146 | m_pcRPS = pSrc->m_pcRPS; |
---|
| 1147 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 1148 | |
---|
| 1149 | m_pcPic = pSrc->m_pcPic; |
---|
| 1150 | |
---|
| 1151 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
| 1152 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
| 1153 | #if SAO_CHROMA_LAMBDA |
---|
| 1154 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
| 1155 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
| 1156 | #else |
---|
| 1157 | m_dLambda = pSrc->m_dLambda; |
---|
| 1158 | #endif |
---|
| 1159 | for (i = 0; i < 2; i++) |
---|
| 1160 | { |
---|
| 1161 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 1162 | { |
---|
| 1163 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 1164 | { |
---|
| 1165 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 1166 | } |
---|
| 1167 | } |
---|
| 1168 | } |
---|
| 1169 | |
---|
| 1170 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 1171 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 1172 | |
---|
| 1173 | m_sliceMode = pSrc->m_sliceMode; |
---|
| 1174 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
| 1175 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
| 1176 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
| 1177 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
| 1178 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
| 1179 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
| 1180 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
| 1181 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
| 1182 | m_nextSlice = pSrc->m_nextSlice; |
---|
| 1183 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
| 1184 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1185 | { |
---|
| 1186 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
| 1187 | { |
---|
| 1188 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
| 1189 | } |
---|
| 1190 | } |
---|
| 1191 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
| 1192 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
| 1193 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
| 1194 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
| 1195 | |
---|
| 1196 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 1197 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
| 1198 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 1199 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
| 1200 | } |
---|
| 1201 | |
---|
| 1202 | Int TComSlice::m_prevPOC = 0; |
---|
| 1203 | |
---|
| 1204 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 1205 | * \param uiTLayer Temporal layer ID of the current slice |
---|
| 1206 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 1207 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
| 1208 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 1209 | */ |
---|
| 1210 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
| 1211 | { |
---|
| 1212 | m_uiTLayer = uiTLayer; |
---|
| 1213 | } |
---|
| 1214 | |
---|
| 1215 | /** Function for checking if this is a switching-point |
---|
| 1216 | */ |
---|
| 1217 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
| 1218 | { |
---|
| 1219 | TComPic* rpcPic; |
---|
| 1220 | // loop through all pictures in the reference picture buffer |
---|
| 1221 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1222 | while ( iterPic != rcListPic.end()) |
---|
| 1223 | { |
---|
| 1224 | rpcPic = *(iterPic++); |
---|
| 1225 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 1226 | { |
---|
| 1227 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1228 | { |
---|
| 1229 | return false; |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | } |
---|
| 1233 | return true; |
---|
| 1234 | } |
---|
| 1235 | |
---|
| 1236 | /** Function for checking if this is a STSA candidate |
---|
| 1237 | */ |
---|
| 1238 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
| 1239 | { |
---|
| 1240 | TComPic* rpcPic; |
---|
| 1241 | |
---|
| 1242 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1243 | while ( iterPic != rcListPic.end()) |
---|
| 1244 | { |
---|
| 1245 | rpcPic = *(iterPic++); |
---|
| 1246 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
| 1247 | { |
---|
| 1248 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1249 | { |
---|
| 1250 | return false; |
---|
| 1251 | } |
---|
| 1252 | } |
---|
| 1253 | } |
---|
| 1254 | return true; |
---|
| 1255 | } |
---|
| 1256 | |
---|
| 1257 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1258 | */ |
---|
| 1259 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1260 | { |
---|
| 1261 | TComPic* rpcPic; |
---|
| 1262 | Int i, isReference; |
---|
| 1263 | |
---|
| 1264 | // loop through all pictures in the reference picture buffer |
---|
| 1265 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1266 | while ( iterPic != rcListPic.end()) |
---|
| 1267 | { |
---|
| 1268 | rpcPic = *(iterPic++); |
---|
| 1269 | |
---|
| 1270 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
| 1271 | { |
---|
| 1272 | continue; |
---|
| 1273 | } |
---|
| 1274 | |
---|
| 1275 | isReference = 0; |
---|
| 1276 | // loop through all pictures in the Reference Picture Set |
---|
| 1277 | // to see if the picture should be kept as reference picture |
---|
| 1278 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1279 | { |
---|
| 1280 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1281 | { |
---|
| 1282 | isReference = 1; |
---|
| 1283 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1284 | rpcPic->setIsLongTerm(0); |
---|
| 1285 | } |
---|
| 1286 | } |
---|
| 1287 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1288 | { |
---|
| 1289 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1290 | { |
---|
| 1291 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1292 | { |
---|
| 1293 | isReference = 1; |
---|
| 1294 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1295 | } |
---|
| 1296 | } |
---|
| 1297 | else |
---|
| 1298 | { |
---|
| 1299 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) |
---|
| 1300 | { |
---|
| 1301 | isReference = 1; |
---|
| 1302 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1303 | } |
---|
| 1304 | } |
---|
| 1305 | |
---|
| 1306 | } |
---|
| 1307 | // mark the picture as "unused for reference" if it is not in |
---|
| 1308 | // the Reference Picture Set |
---|
| 1309 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1310 | { |
---|
| 1311 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
| 1312 | rpcPic->setUsedByCurr(0); |
---|
| 1313 | rpcPic->setIsLongTerm(0); |
---|
| 1314 | } |
---|
| 1315 | //check that pictures of higher temporal layers are not used |
---|
| 1316 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1317 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
[412] | 1318 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
[313] | 1319 | { |
---|
| 1320 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1321 | } |
---|
| 1322 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1323 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1324 | { |
---|
| 1325 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1326 | } |
---|
| 1327 | } |
---|
| 1328 | } |
---|
| 1329 | |
---|
| 1330 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1331 | */ |
---|
| 1332 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
| 1333 | { |
---|
| 1334 | TComPic* rpcPic; |
---|
| 1335 | Int i, isAvailable; |
---|
| 1336 | Int atLeastOneLost = 0; |
---|
| 1337 | Int atLeastOneRemoved = 0; |
---|
| 1338 | Int iPocLost = 0; |
---|
| 1339 | |
---|
| 1340 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1341 | // to see if the picture should be kept as reference picture |
---|
| 1342 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1343 | { |
---|
| 1344 | isAvailable = 0; |
---|
| 1345 | // loop through all pictures in the reference picture buffer |
---|
| 1346 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1347 | while ( iterPic != rcListPic.end()) |
---|
| 1348 | { |
---|
| 1349 | rpcPic = *(iterPic++); |
---|
| 1350 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1351 | { |
---|
| 1352 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1353 | { |
---|
| 1354 | isAvailable = 1; |
---|
| 1355 | } |
---|
| 1356 | } |
---|
| 1357 | else |
---|
| 1358 | { |
---|
| 1359 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1360 | { |
---|
| 1361 | isAvailable = 1; |
---|
| 1362 | } |
---|
| 1363 | } |
---|
| 1364 | } |
---|
| 1365 | // if there was no such long-term check the short terms |
---|
| 1366 | if(!isAvailable) |
---|
| 1367 | { |
---|
| 1368 | iterPic = rcListPic.begin(); |
---|
| 1369 | while ( iterPic != rcListPic.end()) |
---|
| 1370 | { |
---|
| 1371 | rpcPic = *(iterPic++); |
---|
| 1372 | |
---|
| 1373 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1374 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
| 1375 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
| 1376 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 1377 | { |
---|
| 1378 | curPoc = curPoc % pocCycle; |
---|
| 1379 | refPoc = refPoc % pocCycle; |
---|
| 1380 | } |
---|
| 1381 | |
---|
| 1382 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
| 1383 | { |
---|
| 1384 | isAvailable = 1; |
---|
| 1385 | rpcPic->setIsLongTerm(1); |
---|
| 1386 | break; |
---|
| 1387 | } |
---|
| 1388 | } |
---|
| 1389 | } |
---|
| 1390 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1391 | // but not available as reference picture |
---|
| 1392 | if(isAvailable == 0) |
---|
| 1393 | { |
---|
| 1394 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1395 | { |
---|
| 1396 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1397 | { |
---|
| 1398 | if(printErrors) |
---|
| 1399 | { |
---|
| 1400 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1401 | } |
---|
| 1402 | atLeastOneRemoved = 1; |
---|
| 1403 | } |
---|
| 1404 | else |
---|
| 1405 | { |
---|
| 1406 | if(printErrors) |
---|
| 1407 | { |
---|
| 1408 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1409 | } |
---|
| 1410 | atLeastOneLost = 1; |
---|
| 1411 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1412 | } |
---|
| 1413 | } |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1417 | // to see if the picture should be kept as reference picture |
---|
| 1418 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1419 | { |
---|
| 1420 | isAvailable = 0; |
---|
| 1421 | // loop through all pictures in the reference picture buffer |
---|
| 1422 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1423 | while ( iterPic != rcListPic.end()) |
---|
| 1424 | { |
---|
| 1425 | rpcPic = *(iterPic++); |
---|
| 1426 | |
---|
| 1427 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1428 | { |
---|
| 1429 | isAvailable = 1; |
---|
| 1430 | } |
---|
| 1431 | } |
---|
| 1432 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1433 | // but not available as reference picture |
---|
| 1434 | if(isAvailable == 0) |
---|
| 1435 | { |
---|
| 1436 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1437 | { |
---|
| 1438 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1439 | { |
---|
| 1440 | if(printErrors) |
---|
| 1441 | { |
---|
| 1442 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1443 | } |
---|
| 1444 | atLeastOneRemoved = 1; |
---|
| 1445 | } |
---|
| 1446 | else |
---|
| 1447 | { |
---|
| 1448 | if(printErrors) |
---|
| 1449 | { |
---|
| 1450 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1451 | } |
---|
| 1452 | atLeastOneLost = 1; |
---|
| 1453 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1454 | } |
---|
| 1455 | } |
---|
| 1456 | } |
---|
| 1457 | } |
---|
| 1458 | if(atLeastOneLost) |
---|
| 1459 | { |
---|
| 1460 | return iPocLost+1; |
---|
| 1461 | } |
---|
| 1462 | if(atLeastOneRemoved) |
---|
| 1463 | { |
---|
| 1464 | return -2; |
---|
| 1465 | } |
---|
| 1466 | else |
---|
| 1467 | { |
---|
| 1468 | return 0; |
---|
| 1469 | } |
---|
| 1470 | } |
---|
| 1471 | |
---|
| 1472 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1473 | */ |
---|
| 1474 | #if FIX1071 |
---|
| 1475 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
| 1476 | #else |
---|
| 1477 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1478 | #endif |
---|
| 1479 | { |
---|
| 1480 | TComPic* rpcPic; |
---|
| 1481 | Int i, j; |
---|
| 1482 | Int k = 0; |
---|
| 1483 | Int nrOfNegativePictures = 0; |
---|
| 1484 | Int nrOfPositivePictures = 0; |
---|
| 1485 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
| 1486 | |
---|
| 1487 | // loop through all pictures in the Reference Picture Set |
---|
| 1488 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1489 | { |
---|
| 1490 | j = 0; |
---|
| 1491 | // loop through all pictures in the reference picture buffer |
---|
| 1492 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1493 | while ( iterPic != rcListPic.end()) |
---|
| 1494 | { |
---|
| 1495 | j++; |
---|
| 1496 | rpcPic = *(iterPic++); |
---|
| 1497 | |
---|
| 1498 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1499 | { |
---|
| 1500 | // This picture exists as a reference picture |
---|
| 1501 | // and should be added to the explicit Reference Picture Set |
---|
| 1502 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1503 | #if FIX1071 |
---|
| 1504 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
| 1505 | #else |
---|
| 1506 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
| 1507 | #endif |
---|
| 1508 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
| 1509 | { |
---|
| 1510 | nrOfNegativePictures++; |
---|
| 1511 | } |
---|
| 1512 | else |
---|
| 1513 | { |
---|
| 1514 | nrOfPositivePictures++; |
---|
| 1515 | } |
---|
| 1516 | k++; |
---|
| 1517 | } |
---|
| 1518 | } |
---|
| 1519 | } |
---|
| 1520 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1521 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1522 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1523 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
| 1524 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1525 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
| 1526 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
| 1527 | { |
---|
| 1528 | pcRPS->setInterRPSPrediction(false); |
---|
| 1529 | pcRPS->setNumRefIdc(0); |
---|
| 1530 | } |
---|
| 1531 | else |
---|
| 1532 | { |
---|
| 1533 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1534 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
| 1535 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1536 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1537 | Int iNewIdc=0; |
---|
| 1538 | for(i=0; i<= iRefPics; i++) |
---|
| 1539 | { |
---|
| 1540 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1541 | Int iRefIdc = 0; |
---|
| 1542 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
| 1543 | { |
---|
| 1544 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
| 1545 | { |
---|
| 1546 | if (pcRPS->getUsed(j)) |
---|
| 1547 | { |
---|
| 1548 | iRefIdc = 1; |
---|
| 1549 | } |
---|
| 1550 | else |
---|
| 1551 | { |
---|
| 1552 | iRefIdc = 2; |
---|
| 1553 | } |
---|
| 1554 | } |
---|
| 1555 | } |
---|
| 1556 | pcRPS->setRefIdc(i, iRefIdc); |
---|
| 1557 | iNewIdc++; |
---|
| 1558 | } |
---|
| 1559 | pcRPS->setInterRPSPrediction(true); |
---|
| 1560 | pcRPS->setNumRefIdc(iNewIdc); |
---|
| 1561 | pcRPS->setDeltaRPS(deltaRPS); |
---|
| 1562 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1563 | } |
---|
| 1564 | |
---|
| 1565 | this->setRPS(pcRPS); |
---|
| 1566 | this->setRPSidx(-1); |
---|
| 1567 | } |
---|
| 1568 | |
---|
| 1569 | /** get AC and DC values for weighted pred |
---|
| 1570 | * \param *wp |
---|
| 1571 | * \returns Void |
---|
| 1572 | */ |
---|
| 1573 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
| 1574 | { |
---|
| 1575 | wp = m_weightACDCParam; |
---|
| 1576 | } |
---|
| 1577 | |
---|
| 1578 | /** init AC and DC values for weighted pred |
---|
| 1579 | * \returns Void |
---|
| 1580 | */ |
---|
| 1581 | Void TComSlice::initWpAcDcParam() |
---|
| 1582 | { |
---|
| 1583 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
| 1584 | { |
---|
| 1585 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1586 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1587 | } |
---|
| 1588 | } |
---|
| 1589 | |
---|
| 1590 | /** get WP tables for weighted pred |
---|
| 1591 | * \param RefPicList |
---|
| 1592 | * \param iRefIdx |
---|
| 1593 | * \param *&wpScalingParam |
---|
| 1594 | * \returns Void |
---|
| 1595 | */ |
---|
| 1596 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
| 1597 | { |
---|
| 1598 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1599 | } |
---|
| 1600 | |
---|
| 1601 | /** reset Default WP tables settings : no weight. |
---|
| 1602 | * \param wpScalingParam |
---|
| 1603 | * \returns Void |
---|
| 1604 | */ |
---|
| 1605 | Void TComSlice::resetWpScaling() |
---|
| 1606 | { |
---|
| 1607 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1608 | { |
---|
| 1609 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1610 | { |
---|
| 1611 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1612 | { |
---|
| 1613 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1614 | pwp->bPresentFlag = false; |
---|
| 1615 | pwp->uiLog2WeightDenom = 0; |
---|
| 1616 | pwp->uiLog2WeightDenom = 0; |
---|
| 1617 | pwp->iWeight = 1; |
---|
| 1618 | pwp->iOffset = 0; |
---|
| 1619 | } |
---|
| 1620 | } |
---|
| 1621 | } |
---|
| 1622 | } |
---|
| 1623 | |
---|
| 1624 | /** init WP table |
---|
| 1625 | * \returns Void |
---|
| 1626 | */ |
---|
| 1627 | Void TComSlice::initWpScaling() |
---|
| 1628 | { |
---|
| 1629 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1630 | { |
---|
| 1631 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1632 | { |
---|
| 1633 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1634 | { |
---|
| 1635 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1636 | if ( !pwp->bPresentFlag ) |
---|
| 1637 | { |
---|
| 1638 | // Inferring values not present : |
---|
| 1639 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1640 | pwp->iOffset = 0; |
---|
| 1641 | } |
---|
| 1642 | |
---|
| 1643 | pwp->w = pwp->iWeight; |
---|
| 1644 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
| 1645 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
| 1646 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1647 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1648 | } |
---|
| 1649 | } |
---|
| 1650 | } |
---|
| 1651 | } |
---|
| 1652 | |
---|
[389] | 1653 | #if REPN_FORMAT_IN_VPS |
---|
| 1654 | UInt TComSlice::getPicWidthInLumaSamples() |
---|
| 1655 | { |
---|
| 1656 | TComSPS *sps = getSPS(); |
---|
| 1657 | TComVPS *vps = getVPS(); |
---|
| 1658 | UInt retVal, layerId = getLayerId(); |
---|
| 1659 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 1660 | { |
---|
| 1661 | retVal = sps->getPicWidthInLumaSamples(); |
---|
| 1662 | } |
---|
| 1663 | else |
---|
| 1664 | { |
---|
| 1665 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples(); |
---|
| 1666 | } |
---|
| 1667 | return retVal; |
---|
| 1668 | } |
---|
| 1669 | UInt TComSlice::getPicHeightInLumaSamples() |
---|
| 1670 | { |
---|
| 1671 | TComSPS *sps = getSPS(); |
---|
| 1672 | TComVPS *vps = getVPS(); |
---|
| 1673 | UInt retVal, layerId = getLayerId(); |
---|
| 1674 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 1675 | { |
---|
| 1676 | retVal = sps->getPicHeightInLumaSamples(); |
---|
| 1677 | } |
---|
| 1678 | else |
---|
| 1679 | { |
---|
| 1680 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples(); |
---|
| 1681 | } |
---|
| 1682 | return retVal; |
---|
| 1683 | } |
---|
| 1684 | UInt TComSlice::getChromaFormatIdc() |
---|
| 1685 | { |
---|
| 1686 | TComSPS *sps = getSPS(); |
---|
| 1687 | TComVPS *vps = getVPS(); |
---|
| 1688 | UInt retVal, layerId = getLayerId(); |
---|
| 1689 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 1690 | { |
---|
| 1691 | retVal = sps->getChromaFormatIdc(); |
---|
| 1692 | } |
---|
| 1693 | else |
---|
| 1694 | { |
---|
| 1695 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc(); |
---|
| 1696 | } |
---|
| 1697 | return retVal; |
---|
| 1698 | } |
---|
| 1699 | UInt TComSlice::getBitDepthY() |
---|
| 1700 | { |
---|
| 1701 | TComSPS *sps = getSPS(); |
---|
| 1702 | TComVPS *vps = getVPS(); |
---|
| 1703 | UInt retVal, layerId = getLayerId(); |
---|
| 1704 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 1705 | { |
---|
| 1706 | retVal = sps->getBitDepthY(); |
---|
| 1707 | } |
---|
| 1708 | else |
---|
| 1709 | { |
---|
| 1710 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma(); |
---|
| 1711 | } |
---|
| 1712 | return retVal; |
---|
| 1713 | } |
---|
| 1714 | UInt TComSlice::getBitDepthC() |
---|
| 1715 | { |
---|
| 1716 | TComSPS *sps = getSPS(); |
---|
| 1717 | TComVPS *vps = getVPS(); |
---|
| 1718 | UInt retVal, layerId = getLayerId(); |
---|
| 1719 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 1720 | { |
---|
| 1721 | retVal = sps->getBitDepthC(); |
---|
| 1722 | } |
---|
| 1723 | else |
---|
| 1724 | { |
---|
| 1725 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma(); |
---|
| 1726 | } |
---|
| 1727 | return retVal; |
---|
| 1728 | } |
---|
| 1729 | Int TComSlice::getQpBDOffsetY() |
---|
| 1730 | { |
---|
| 1731 | return (getBitDepthY() - 8) * 6; |
---|
| 1732 | } |
---|
| 1733 | Int TComSlice::getQpBDOffsetC() |
---|
| 1734 | { |
---|
| 1735 | return (getBitDepthC() - 8) * 6; |
---|
| 1736 | } |
---|
| 1737 | |
---|
| 1738 | RepFormat::RepFormat() |
---|
| 1739 | : m_chromaFormatVpsIdc (0) |
---|
| 1740 | , m_separateColourPlaneVpsFlag (false) |
---|
| 1741 | , m_picWidthVpsInLumaSamples (0) |
---|
| 1742 | , m_picHeightVpsInLumaSamples (0) |
---|
| 1743 | , m_bitDepthVpsLuma (0) |
---|
| 1744 | , m_bitDepthVpsChroma (0) |
---|
| 1745 | {} |
---|
| 1746 | #endif |
---|
| 1747 | |
---|
[313] | 1748 | // ------------------------------------------------------------------------------------------------ |
---|
| 1749 | // Video parameter set (VPS) |
---|
| 1750 | // ------------------------------------------------------------------------------------------------ |
---|
| 1751 | TComVPS::TComVPS() |
---|
| 1752 | : m_VPSId ( 0) |
---|
| 1753 | , m_uiMaxTLayers ( 1) |
---|
| 1754 | , m_uiMaxLayers ( 1) |
---|
| 1755 | , m_bTemporalIdNestingFlag (false) |
---|
| 1756 | , m_numHrdParameters ( 0) |
---|
| 1757 | #if !VPS_RENAME |
---|
| 1758 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
| 1759 | #endif |
---|
| 1760 | , m_hrdParameters (NULL) |
---|
| 1761 | , m_hrdOpSetIdx (NULL) |
---|
| 1762 | , m_cprmsPresentFlag (NULL) |
---|
| 1763 | #if VPS_RENAME |
---|
| 1764 | , m_maxLayerId (0) |
---|
| 1765 | , m_numLayerSets (0) |
---|
| 1766 | #endif |
---|
| 1767 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 1768 | , m_numOutputLayerSets (0) |
---|
| 1769 | #endif |
---|
| 1770 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1771 | , m_numProfileTierLevel (0) |
---|
| 1772 | , m_moreOutputLayerSetsThanDefaultFlag (false) |
---|
| 1773 | , m_numAddOutputLayerSets (0) |
---|
| 1774 | , m_defaultOneTargetOutputLayerFlag (false) |
---|
| 1775 | #endif |
---|
[385] | 1776 | #if VPS_VUI_BITRATE_PICRATE |
---|
| 1777 | , m_bitRatePresentVpsFlag (false) |
---|
| 1778 | , m_picRatePresentVpsFlag (false) |
---|
| 1779 | #endif |
---|
[389] | 1780 | #if REPN_FORMAT_IN_VPS |
---|
| 1781 | , m_repFormatIdxPresentFlag (true) |
---|
| 1782 | , m_vpsNumRepFormats (1) |
---|
| 1783 | #endif |
---|
[407] | 1784 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1785 | , m_viewIdLenMinus1 (0) |
---|
| 1786 | #endif |
---|
[313] | 1787 | { |
---|
| 1788 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1789 | { |
---|
| 1790 | m_numReorderPics[i] = 0; |
---|
| 1791 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 1792 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1793 | } |
---|
| 1794 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 1795 | m_avcBaseLayerFlag = false; |
---|
| 1796 | m_splittingFlag = false; |
---|
| 1797 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
| 1798 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
| 1799 | m_nuhLayerIdPresentFlag = false; |
---|
| 1800 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
| 1801 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
| 1802 | |
---|
| 1803 | m_numScalabilityTypes = 0; |
---|
| 1804 | ::memset(m_layerIdInVps, 0, sizeof(m_layerIdInVps)); |
---|
| 1805 | #endif |
---|
| 1806 | #if VPS_EXTN_PROFILE_INFO |
---|
| 1807 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
| 1808 | ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef)); |
---|
| 1809 | #endif |
---|
| 1810 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 1811 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
| 1812 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
| 1813 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
| 1814 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
| 1815 | #endif |
---|
| 1816 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1817 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
| 1818 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
| 1819 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
| 1820 | #if M0457_PREDICTION_INDICATIONS |
---|
| 1821 | m_directDepTypeLen = 2; |
---|
| 1822 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
| 1823 | #endif |
---|
| 1824 | #endif |
---|
| 1825 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 1826 | ::memset(m_layerSetLayerIdList, 0, sizeof(m_layerSetLayerIdList)); |
---|
| 1827 | ::memset(m_numLayerInIdList, 0, sizeof(m_numLayerInIdList )); |
---|
| 1828 | #endif |
---|
| 1829 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1830 | ::memset(m_profileLevelTierIdx, 0, sizeof(m_profileLevelTierIdx)); |
---|
| 1831 | #endif |
---|
| 1832 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1833 | m_maxOneActiveRefLayerFlag = true; |
---|
| 1834 | #endif |
---|
[409] | 1835 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 1836 | m_crossLayerIrapAlignFlag = true; |
---|
| 1837 | #endif |
---|
[313] | 1838 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
[345] | 1839 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
[399] | 1840 | m_maxTidRefPresentFlag = true; |
---|
[345] | 1841 | #endif |
---|
[313] | 1842 | for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++) |
---|
| 1843 | { |
---|
[399] | 1844 | m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1; |
---|
[313] | 1845 | } |
---|
| 1846 | #endif |
---|
[386] | 1847 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
[382] | 1848 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
| 1849 | #endif |
---|
| 1850 | #if N0160_VUI_EXT_ILP_REF |
---|
| 1851 | m_numIlpRestrictedRefLayers = false; |
---|
| 1852 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
| 1853 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
| 1854 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
| 1855 | #endif |
---|
[385] | 1856 | #if VPS_VUI_BITRATE_PICRATE |
---|
| 1857 | ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag)); |
---|
| 1858 | ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag)); |
---|
| 1859 | ::memset(m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
| 1860 | ::memset(m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
| 1861 | ::memset(m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
| 1862 | ::memset(m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
| 1863 | #endif |
---|
[389] | 1864 | #if REPN_FORMAT_IN_VPS |
---|
| 1865 | ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) ); |
---|
| 1866 | #endif |
---|
[407] | 1867 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1868 | ::memset(m_viewIdVal, 0, sizeof(m_viewIdVal)); |
---|
| 1869 | #endif |
---|
[313] | 1870 | } |
---|
| 1871 | |
---|
| 1872 | TComVPS::~TComVPS() |
---|
| 1873 | { |
---|
| 1874 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
| 1875 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
| 1876 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
| 1877 | } |
---|
| 1878 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 1879 | Void TComVPS::deriveLayerIdListVariables() |
---|
| 1880 | { |
---|
| 1881 | // For layer 0 |
---|
| 1882 | setNumLayersInIdList(0, 1); |
---|
| 1883 | setLayerSetLayerIdList(0, 0, 0); |
---|
| 1884 | |
---|
| 1885 | // For other layers |
---|
| 1886 | Int i, m, n; |
---|
| 1887 | for( i = 1; i <= getNumLayerSets() - 1; i++ ) |
---|
| 1888 | { |
---|
| 1889 | n = 0; |
---|
| 1890 | for( m = 0; m <= this->getMaxLayerId(); m++) |
---|
| 1891 | { |
---|
| 1892 | if(this->getLayerIdIncludedFlag(i, m)) |
---|
| 1893 | { |
---|
| 1894 | setLayerSetLayerIdList(i, n, m); |
---|
| 1895 | n++; |
---|
| 1896 | } |
---|
| 1897 | } |
---|
| 1898 | setNumLayersInIdList(i, n); |
---|
| 1899 | } |
---|
| 1900 | } |
---|
| 1901 | #endif |
---|
[414] | 1902 | |
---|
| 1903 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1904 | Bool TComVPS::checkLayerDependency(UInt i, UInt j) |
---|
| 1905 | { |
---|
| 1906 | if( this->getDirectDependencyFlag(i, j) == true ) |
---|
| 1907 | { |
---|
| 1908 | return true; |
---|
| 1909 | } |
---|
| 1910 | else |
---|
| 1911 | { |
---|
| 1912 | for(UInt k=i-1; k>j; k--) |
---|
| 1913 | { |
---|
| 1914 | if( this->getDirectDependencyFlag(i, k) == true ) |
---|
| 1915 | { |
---|
| 1916 | checkLayerDependency( k,j ); |
---|
| 1917 | } |
---|
| 1918 | } |
---|
| 1919 | } |
---|
| 1920 | return false; |
---|
| 1921 | } |
---|
| 1922 | #endif |
---|
| 1923 | |
---|
[407] | 1924 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1925 | Int TComVPS::getNumViews() |
---|
| 1926 | { |
---|
| 1927 | Int numViews = 1; |
---|
| 1928 | for( Int i = 0; i <= getMaxLayers() - 1; i++ ) |
---|
| 1929 | { |
---|
| 1930 | Int lId = getLayerIdInNuh( i ); |
---|
| 1931 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
| 1932 | { |
---|
| 1933 | numViews++; |
---|
| 1934 | } |
---|
| 1935 | } |
---|
| 1936 | |
---|
| 1937 | return numViews; |
---|
| 1938 | } |
---|
| 1939 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
| 1940 | { |
---|
| 1941 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
| 1942 | } |
---|
| 1943 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
| 1944 | { |
---|
| 1945 | assert( scalType >= 0 && scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
| 1946 | assert( scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
| 1947 | Int scalIdx = 0; |
---|
| 1948 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
| 1949 | { |
---|
| 1950 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
| 1951 | |
---|
| 1952 | } |
---|
| 1953 | |
---|
| 1954 | return scalIdx; |
---|
| 1955 | } |
---|
| 1956 | #endif |
---|
[313] | 1957 | // ------------------------------------------------------------------------------------------------ |
---|
| 1958 | // Sequence parameter set (SPS) |
---|
| 1959 | // ------------------------------------------------------------------------------------------------ |
---|
| 1960 | |
---|
| 1961 | TComSPS::TComSPS() |
---|
| 1962 | : m_SPSId ( 0) |
---|
| 1963 | , m_VPSId ( 0) |
---|
| 1964 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 1965 | , m_uiMaxTLayers ( 1) |
---|
| 1966 | // Structure |
---|
| 1967 | , m_picWidthInLumaSamples (352) |
---|
| 1968 | , m_picHeightInLumaSamples (288) |
---|
| 1969 | , m_log2MinCodingBlockSize ( 0) |
---|
| 1970 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
| 1971 | , m_uiMaxCUWidth ( 32) |
---|
| 1972 | , m_uiMaxCUHeight ( 32) |
---|
| 1973 | , m_uiMaxCUDepth ( 3) |
---|
| 1974 | , m_bLongTermRefsPresent (false) |
---|
| 1975 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 1976 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 1977 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 1978 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 1979 | // Tool list |
---|
| 1980 | , m_usePCM (false) |
---|
| 1981 | , m_pcmLog2MaxSize ( 5) |
---|
| 1982 | , m_uiPCMLog2MinSize ( 7) |
---|
| 1983 | , m_bitDepthY ( 8) |
---|
| 1984 | , m_bitDepthC ( 8) |
---|
| 1985 | , m_qpBDOffsetY ( 0) |
---|
| 1986 | , m_qpBDOffsetC ( 0) |
---|
| 1987 | , m_useLossless (false) |
---|
| 1988 | , m_uiPCMBitDepthLuma ( 8) |
---|
| 1989 | , m_uiPCMBitDepthChroma ( 8) |
---|
| 1990 | , m_bPCMFilterDisableFlag (false) |
---|
| 1991 | , m_uiBitsForPOC ( 8) |
---|
| 1992 | , m_numLongTermRefPicSPS ( 0) |
---|
| 1993 | , m_uiMaxTrSize ( 32) |
---|
| 1994 | , m_bUseSAO (false) |
---|
| 1995 | , m_bTemporalIdNestingFlag (false) |
---|
| 1996 | , m_scalingListEnabledFlag (false) |
---|
| 1997 | , m_useStrongIntraSmoothing (false) |
---|
| 1998 | , m_vuiParametersPresentFlag (false) |
---|
| 1999 | , m_vuiParameters () |
---|
| 2000 | #if M0463_VUI_EXT_ILP_REF |
---|
| 2001 | , m_interViewMvVertConstraintFlag (false) |
---|
| 2002 | , m_numIlpRestrictedRefLayers ( 0 ) |
---|
| 2003 | #endif |
---|
| 2004 | #if SVC_EXTENSION |
---|
| 2005 | , m_layerId(0) |
---|
| 2006 | #endif |
---|
| 2007 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 2008 | , m_numScaledRefLayerOffsets (0) |
---|
| 2009 | #endif |
---|
[389] | 2010 | #if REPN_FORMAT_IN_VPS |
---|
| 2011 | , m_updateRepFormatFlag (false) |
---|
| 2012 | #endif |
---|
[313] | 2013 | { |
---|
| 2014 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 2015 | { |
---|
| 2016 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 2017 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 2018 | m_numReorderPics[i] = 0; |
---|
| 2019 | } |
---|
| 2020 | m_scalingList = new TComScalingList; |
---|
| 2021 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 2022 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
| 2023 | #if M0463_VUI_EXT_ILP_REF |
---|
| 2024 | for (Int i = 0; i < MAX_LAYERS; i++ ) |
---|
| 2025 | { |
---|
| 2026 | m_minSpatialSegmentOffsetPlus1[ i ] = 0; |
---|
| 2027 | m_ctuBasedOffsetEnabledFlag [ i ] = false; |
---|
| 2028 | m_minHorizontalCtuOffsetPlus1 [ i ] = 0; |
---|
| 2029 | } |
---|
| 2030 | #endif |
---|
| 2031 | } |
---|
| 2032 | |
---|
| 2033 | TComSPS::~TComSPS() |
---|
| 2034 | { |
---|
| 2035 | delete m_scalingList; |
---|
| 2036 | m_RPSList.destroy(); |
---|
| 2037 | } |
---|
| 2038 | |
---|
| 2039 | Void TComSPS::createRPSList( Int numRPS ) |
---|
| 2040 | { |
---|
| 2041 | m_RPSList.destroy(); |
---|
| 2042 | m_RPSList.create(numRPS); |
---|
| 2043 | } |
---|
| 2044 | |
---|
| 2045 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
| 2046 | { |
---|
| 2047 | if( !getVuiParametersPresentFlag() ) |
---|
| 2048 | { |
---|
| 2049 | return; |
---|
| 2050 | } |
---|
| 2051 | |
---|
| 2052 | TComVUI *vui = getVuiParameters(); |
---|
| 2053 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 2054 | |
---|
| 2055 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
[376] | 2056 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
| 2057 | if( getLayerId() > 0 ) |
---|
[313] | 2058 | { |
---|
[376] | 2059 | timingInfo->setTimingInfoPresentFlag( false ); |
---|
[313] | 2060 | } |
---|
[376] | 2061 | else |
---|
| 2062 | { |
---|
| 2063 | #endif |
---|
| 2064 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
| 2065 | switch( frameRate ) |
---|
| 2066 | { |
---|
| 2067 | case 24: |
---|
| 2068 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2069 | break; |
---|
| 2070 | case 25: |
---|
| 2071 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2072 | break; |
---|
| 2073 | case 30: |
---|
| 2074 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2075 | break; |
---|
| 2076 | case 50: |
---|
| 2077 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2078 | break; |
---|
| 2079 | case 60: |
---|
| 2080 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2081 | break; |
---|
| 2082 | default: |
---|
| 2083 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
| 2084 | break; |
---|
| 2085 | } |
---|
[313] | 2086 | |
---|
[376] | 2087 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 2088 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 2089 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
[313] | 2090 | |
---|
[376] | 2091 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
[313] | 2092 | |
---|
[376] | 2093 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 2094 | { |
---|
| 2095 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 2096 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 2097 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
| 2098 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
| 2099 | } |
---|
| 2100 | else |
---|
| 2101 | { |
---|
| 2102 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
| 2103 | } |
---|
[313] | 2104 | |
---|
[376] | 2105 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
| 2106 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 2107 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
[313] | 2108 | |
---|
[376] | 2109 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 2110 | if( randomAccess ) |
---|
| 2111 | { |
---|
| 2112 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 2113 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 2114 | } |
---|
| 2115 | else |
---|
| 2116 | { |
---|
| 2117 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 2118 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 2119 | } |
---|
[313] | 2120 | |
---|
[376] | 2121 | /* |
---|
| 2122 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
| 2123 | */ |
---|
| 2124 | Int i, j; |
---|
| 2125 | UInt birateValue, cpbSizeValue; |
---|
| 2126 | UInt ducpbSizeValue; |
---|
| 2127 | UInt duBitRateValue = 0; |
---|
[313] | 2128 | |
---|
[376] | 2129 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
[313] | 2130 | { |
---|
[376] | 2131 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
| 2132 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
| 2133 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
| 2134 | hrd->setCpbCntMinus1( i, 0 ); |
---|
[313] | 2135 | |
---|
[376] | 2136 | birateValue = bitRate; |
---|
| 2137 | cpbSizeValue = bitRate; // 1 second |
---|
| 2138 | ducpbSizeValue = bitRate/numDU; |
---|
| 2139 | duBitRateValue = bitRate; |
---|
| 2140 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
| 2141 | { |
---|
| 2142 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
| 2143 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 2144 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
| 2145 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
| 2146 | |
---|
| 2147 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
| 2148 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 2149 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
| 2150 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
| 2151 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
| 2152 | } |
---|
[313] | 2153 | } |
---|
[376] | 2154 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
[313] | 2155 | } |
---|
[376] | 2156 | #endif |
---|
[313] | 2157 | } |
---|
| 2158 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
| 2159 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
| 2160 | |
---|
| 2161 | TComPPS::TComPPS() |
---|
| 2162 | : m_PPSId (0) |
---|
| 2163 | , m_SPSId (0) |
---|
| 2164 | , m_picInitQPMinus26 (0) |
---|
| 2165 | , m_useDQP (false) |
---|
| 2166 | , m_bConstrainedIntraPred (false) |
---|
| 2167 | , m_bSliceChromaQpFlag (false) |
---|
| 2168 | , m_pcSPS (NULL) |
---|
| 2169 | , m_uiMaxCuDQPDepth (0) |
---|
| 2170 | , m_uiMinCuDQPSize (0) |
---|
| 2171 | , m_chromaCbQpOffset (0) |
---|
| 2172 | , m_chromaCrQpOffset (0) |
---|
| 2173 | , m_numRefIdxL0DefaultActive (1) |
---|
| 2174 | , m_numRefIdxL1DefaultActive (1) |
---|
| 2175 | , m_TransquantBypassEnableFlag (false) |
---|
| 2176 | , m_useTransformSkip (false) |
---|
| 2177 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
| 2178 | , m_tilesEnabledFlag (false) |
---|
| 2179 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 2180 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 2181 | , m_uniformSpacingFlag (0) |
---|
| 2182 | , m_iNumColumnsMinus1 (0) |
---|
| 2183 | , m_puiColumnWidth (NULL) |
---|
| 2184 | , m_iNumRowsMinus1 (0) |
---|
| 2185 | , m_puiRowHeight (NULL) |
---|
| 2186 | , m_iNumSubstreams (1) |
---|
| 2187 | , m_signHideFlag(0) |
---|
| 2188 | , m_cabacInitPresentFlag (false) |
---|
| 2189 | , m_encCABACTableIdx (I_SLICE) |
---|
| 2190 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 2191 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
| 2192 | , m_listsModificationPresentFlag( 0) |
---|
| 2193 | , m_numExtraSliceHeaderBits(0) |
---|
| 2194 | { |
---|
| 2195 | m_scalingList = new TComScalingList; |
---|
| 2196 | } |
---|
| 2197 | |
---|
| 2198 | TComPPS::~TComPPS() |
---|
| 2199 | { |
---|
| 2200 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 2201 | { |
---|
| 2202 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
| 2203 | m_puiColumnWidth = NULL; |
---|
| 2204 | } |
---|
| 2205 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 2206 | { |
---|
| 2207 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
| 2208 | m_puiRowHeight = NULL; |
---|
| 2209 | } |
---|
| 2210 | delete m_scalingList; |
---|
| 2211 | } |
---|
| 2212 | |
---|
| 2213 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 2214 | : m_numberOfPictures (0) |
---|
| 2215 | , m_numberOfNegativePictures (0) |
---|
| 2216 | , m_numberOfPositivePictures (0) |
---|
| 2217 | , m_numberOfLongtermPictures (0) |
---|
| 2218 | , m_interRPSPrediction (0) |
---|
| 2219 | , m_deltaRIdxMinus1 (0) |
---|
| 2220 | , m_deltaRPS (0) |
---|
| 2221 | , m_numRefIdc (0) |
---|
| 2222 | { |
---|
| 2223 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 2224 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 2225 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 2226 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
| 2227 | } |
---|
| 2228 | |
---|
| 2229 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 2230 | { |
---|
| 2231 | } |
---|
| 2232 | |
---|
| 2233 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 2234 | { |
---|
| 2235 | m_used[bufferNum] = used; |
---|
| 2236 | } |
---|
| 2237 | |
---|
| 2238 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 2239 | { |
---|
| 2240 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 2241 | } |
---|
| 2242 | |
---|
| 2243 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 2244 | { |
---|
| 2245 | m_numberOfPictures = numberOfPictures; |
---|
| 2246 | } |
---|
| 2247 | |
---|
| 2248 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
| 2249 | { |
---|
| 2250 | return m_used[bufferNum]; |
---|
| 2251 | } |
---|
| 2252 | |
---|
| 2253 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
| 2254 | { |
---|
| 2255 | return m_deltaPOC[bufferNum]; |
---|
| 2256 | } |
---|
| 2257 | |
---|
| 2258 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
| 2259 | { |
---|
| 2260 | return m_numberOfPictures; |
---|
| 2261 | } |
---|
| 2262 | |
---|
| 2263 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
| 2264 | { |
---|
| 2265 | return m_POC[bufferNum]; |
---|
| 2266 | } |
---|
| 2267 | |
---|
| 2268 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 2269 | { |
---|
| 2270 | m_POC[bufferNum] = POC; |
---|
| 2271 | } |
---|
| 2272 | |
---|
| 2273 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
| 2274 | { |
---|
| 2275 | return m_bCheckLTMSB[bufferNum]; |
---|
| 2276 | } |
---|
| 2277 | |
---|
| 2278 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 2279 | { |
---|
| 2280 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 2281 | } |
---|
| 2282 | |
---|
| 2283 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
| 2284 | * \param uiBufferNum |
---|
| 2285 | * \param iRefIdc |
---|
| 2286 | * \returns Void |
---|
| 2287 | */ |
---|
| 2288 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 2289 | { |
---|
| 2290 | m_refIdc[bufferNum] = refIdc; |
---|
| 2291 | } |
---|
| 2292 | |
---|
| 2293 | /** get the reference idc value at uiBufferNum |
---|
| 2294 | * \param uiBufferNum |
---|
| 2295 | * \returns Int |
---|
| 2296 | */ |
---|
| 2297 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
| 2298 | { |
---|
| 2299 | return m_refIdc[bufferNum]; |
---|
| 2300 | } |
---|
| 2301 | |
---|
| 2302 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 2303 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 2304 | * +ve values are in increasing order. |
---|
| 2305 | * \returns Void |
---|
| 2306 | */ |
---|
| 2307 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 2308 | { |
---|
| 2309 | // sort in increasing order (smallest first) |
---|
| 2310 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
| 2311 | { |
---|
| 2312 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2313 | Bool used = getUsed(j); |
---|
| 2314 | for (Int k=j-1; k >= 0; k--) |
---|
| 2315 | { |
---|
| 2316 | Int temp = getDeltaPOC(k); |
---|
| 2317 | if (deltaPOC < temp) |
---|
| 2318 | { |
---|
| 2319 | setDeltaPOC(k+1, temp); |
---|
| 2320 | setUsed(k+1, getUsed(k)); |
---|
| 2321 | setDeltaPOC(k, deltaPOC); |
---|
| 2322 | setUsed(k, used); |
---|
| 2323 | } |
---|
| 2324 | } |
---|
| 2325 | } |
---|
| 2326 | // flip the negative values to largest first |
---|
| 2327 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2328 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
| 2329 | { |
---|
| 2330 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2331 | Bool used = getUsed(j); |
---|
| 2332 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2333 | setUsed(j, getUsed(k)); |
---|
| 2334 | setDeltaPOC(k, deltaPOC); |
---|
| 2335 | setUsed(k, used); |
---|
| 2336 | } |
---|
| 2337 | } |
---|
| 2338 | |
---|
| 2339 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2340 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2341 | * \returns Void |
---|
| 2342 | */ |
---|
| 2343 | Void TComReferencePictureSet::printDeltaPOC() |
---|
| 2344 | { |
---|
| 2345 | printf("DeltaPOC = { "); |
---|
| 2346 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2347 | { |
---|
| 2348 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
| 2349 | } |
---|
| 2350 | if (getInterRPSPrediction()) |
---|
| 2351 | { |
---|
| 2352 | printf("}, RefIdc = { "); |
---|
| 2353 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2354 | { |
---|
| 2355 | printf("%d ", getRefIdc(j)); |
---|
| 2356 | } |
---|
| 2357 | } |
---|
| 2358 | printf("}\n"); |
---|
| 2359 | } |
---|
| 2360 | |
---|
| 2361 | TComRPSList::TComRPSList() |
---|
| 2362 | :m_referencePictureSets (NULL) |
---|
| 2363 | { |
---|
| 2364 | } |
---|
| 2365 | |
---|
| 2366 | TComRPSList::~TComRPSList() |
---|
| 2367 | { |
---|
| 2368 | } |
---|
| 2369 | |
---|
| 2370 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
| 2371 | { |
---|
| 2372 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2373 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
| 2374 | } |
---|
| 2375 | |
---|
| 2376 | Void TComRPSList::destroy() |
---|
| 2377 | { |
---|
| 2378 | if (m_referencePictureSets) |
---|
| 2379 | { |
---|
| 2380 | delete [] m_referencePictureSets; |
---|
| 2381 | } |
---|
| 2382 | m_numberOfReferencePictureSets = 0; |
---|
| 2383 | m_referencePictureSets = NULL; |
---|
| 2384 | } |
---|
| 2385 | |
---|
| 2386 | |
---|
| 2387 | |
---|
| 2388 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
| 2389 | { |
---|
| 2390 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
| 2391 | } |
---|
| 2392 | |
---|
| 2393 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
| 2394 | { |
---|
| 2395 | return m_numberOfReferencePictureSets; |
---|
| 2396 | } |
---|
| 2397 | |
---|
| 2398 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
| 2399 | { |
---|
| 2400 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2401 | } |
---|
| 2402 | |
---|
| 2403 | TComRefPicListModification::TComRefPicListModification() |
---|
| 2404 | : m_bRefPicListModificationFlagL0 (false) |
---|
| 2405 | , m_bRefPicListModificationFlagL1 (false) |
---|
| 2406 | { |
---|
| 2407 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2408 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2409 | } |
---|
| 2410 | |
---|
| 2411 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2412 | { |
---|
| 2413 | } |
---|
| 2414 | |
---|
| 2415 | TComScalingList::TComScalingList() |
---|
| 2416 | { |
---|
| 2417 | m_useTransformSkip = false; |
---|
| 2418 | init(); |
---|
| 2419 | } |
---|
| 2420 | TComScalingList::~TComScalingList() |
---|
| 2421 | { |
---|
| 2422 | destroy(); |
---|
| 2423 | } |
---|
| 2424 | |
---|
| 2425 | /** set default quantization matrix to array |
---|
| 2426 | */ |
---|
[414] | 2427 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2428 | Void TComSlice::setDefaultScalingList( UInt layerId ) |
---|
| 2429 | #else |
---|
[313] | 2430 | Void TComSlice::setDefaultScalingList() |
---|
[414] | 2431 | #endif |
---|
[313] | 2432 | { |
---|
| 2433 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2434 | { |
---|
| 2435 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2436 | { |
---|
[414] | 2437 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2438 | getScalingList()->processDefaultMarix(sizeId, listId, layerId); |
---|
| 2439 | #else |
---|
[313] | 2440 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
[414] | 2441 | #endif |
---|
[313] | 2442 | } |
---|
| 2443 | } |
---|
| 2444 | } |
---|
| 2445 | /** check if use default quantization matrix |
---|
| 2446 | * \returns true if use default quantization matrix in all size |
---|
| 2447 | */ |
---|
| 2448 | Bool TComSlice::checkDefaultScalingList() |
---|
| 2449 | { |
---|
| 2450 | UInt defaultCounter=0; |
---|
| 2451 | |
---|
| 2452 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2453 | { |
---|
| 2454 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2455 | { |
---|
| 2456 | 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 |
---|
| 2457 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
| 2458 | { |
---|
| 2459 | defaultCounter++; |
---|
| 2460 | } |
---|
| 2461 | } |
---|
| 2462 | } |
---|
| 2463 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
| 2464 | } |
---|
| 2465 | |
---|
| 2466 | /** get scaling matrix from RefMatrixID |
---|
| 2467 | * \param sizeId size index |
---|
| 2468 | * \param Index of input matrix |
---|
| 2469 | * \param Index of reference matrix |
---|
| 2470 | */ |
---|
| 2471 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 2472 | { |
---|
| 2473 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2474 | } |
---|
| 2475 | |
---|
| 2476 | /** parse syntax infomation |
---|
| 2477 | * \param pchFile syntax infomation |
---|
| 2478 | * \returns false if successful |
---|
| 2479 | */ |
---|
| 2480 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
| 2481 | { |
---|
| 2482 | FILE *fp; |
---|
| 2483 | Char line[1024]; |
---|
| 2484 | UInt sizeIdc,listIdc; |
---|
| 2485 | UInt i,size = 0; |
---|
| 2486 | Int *src=0,data; |
---|
| 2487 | Char *ret; |
---|
| 2488 | UInt retval; |
---|
| 2489 | |
---|
| 2490 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
| 2491 | { |
---|
| 2492 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
| 2493 | return true; |
---|
| 2494 | } |
---|
| 2495 | |
---|
| 2496 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2497 | { |
---|
| 2498 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 2499 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
| 2500 | { |
---|
| 2501 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 2502 | fseek(fp,0,0); |
---|
| 2503 | do |
---|
| 2504 | { |
---|
| 2505 | ret = fgets(line, 1024, fp); |
---|
| 2506 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2507 | { |
---|
| 2508 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2509 | return true; |
---|
| 2510 | } |
---|
| 2511 | } |
---|
| 2512 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
| 2513 | for (i=0; i<size; i++) |
---|
| 2514 | { |
---|
| 2515 | retval = fscanf(fp, "%d,", &data); |
---|
| 2516 | if (retval!=1) |
---|
| 2517 | { |
---|
| 2518 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2519 | return true; |
---|
| 2520 | } |
---|
| 2521 | src[i] = data; |
---|
| 2522 | } |
---|
| 2523 | //set DC value for default matrix check |
---|
| 2524 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 2525 | |
---|
| 2526 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 2527 | { |
---|
| 2528 | fseek(fp,0,0); |
---|
| 2529 | do |
---|
| 2530 | { |
---|
| 2531 | ret = fgets(line, 1024, fp); |
---|
| 2532 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2533 | { |
---|
| 2534 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
| 2535 | return true; |
---|
| 2536 | } |
---|
| 2537 | } |
---|
| 2538 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
| 2539 | retval = fscanf(fp, "%d,", &data); |
---|
| 2540 | if (retval!=1) |
---|
| 2541 | { |
---|
| 2542 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2543 | return true; |
---|
| 2544 | } |
---|
| 2545 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 2546 | setScalingListDC(sizeIdc,listIdc,data); |
---|
| 2547 | } |
---|
| 2548 | } |
---|
| 2549 | } |
---|
| 2550 | fclose(fp); |
---|
| 2551 | return false; |
---|
| 2552 | } |
---|
| 2553 | |
---|
| 2554 | /** initialization process of quantization matrix array |
---|
| 2555 | */ |
---|
| 2556 | Void TComScalingList::init() |
---|
| 2557 | { |
---|
| 2558 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2559 | { |
---|
| 2560 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2561 | { |
---|
| 2562 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
| 2563 | } |
---|
| 2564 | } |
---|
| 2565 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
| 2566 | } |
---|
| 2567 | |
---|
| 2568 | /** destroy quantization matrix array |
---|
| 2569 | */ |
---|
| 2570 | Void TComScalingList::destroy() |
---|
| 2571 | { |
---|
| 2572 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2573 | { |
---|
| 2574 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2575 | { |
---|
| 2576 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
| 2577 | } |
---|
| 2578 | } |
---|
| 2579 | } |
---|
| 2580 | |
---|
| 2581 | /** get default address of quantization matrix |
---|
| 2582 | * \param sizeId size index |
---|
| 2583 | * \param listId list index |
---|
| 2584 | * \returns pointer of quantization matrix |
---|
| 2585 | */ |
---|
| 2586 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
| 2587 | { |
---|
| 2588 | Int *src = 0; |
---|
| 2589 | switch(sizeId) |
---|
| 2590 | { |
---|
| 2591 | case SCALING_LIST_4x4: |
---|
| 2592 | src = g_quantTSDefault4x4; |
---|
| 2593 | break; |
---|
| 2594 | case SCALING_LIST_8x8: |
---|
| 2595 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2596 | break; |
---|
| 2597 | case SCALING_LIST_16x16: |
---|
| 2598 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2599 | break; |
---|
| 2600 | case SCALING_LIST_32x32: |
---|
| 2601 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2602 | break; |
---|
| 2603 | default: |
---|
| 2604 | assert(0); |
---|
| 2605 | src = NULL; |
---|
| 2606 | break; |
---|
| 2607 | } |
---|
| 2608 | return src; |
---|
| 2609 | } |
---|
| 2610 | |
---|
| 2611 | /** process of default matrix |
---|
| 2612 | * \param sizeId size index |
---|
| 2613 | * \param Index of input matrix |
---|
| 2614 | */ |
---|
[414] | 2615 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2616 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId, UInt layerId) |
---|
| 2617 | #else |
---|
[313] | 2618 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
[414] | 2619 | #endif |
---|
[313] | 2620 | { |
---|
[414] | 2621 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2622 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2623 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
| 2624 | Int *src = getScalingListDefaultAddress(sizeId, listId); |
---|
| 2625 | #endif |
---|
| 2626 | |
---|
[313] | 2627 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
[414] | 2628 | |
---|
| 2629 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2630 | for(i = 0; i < coefNum; i++) |
---|
| 2631 | { |
---|
| 2632 | ref_scalingListCoef[layerId][sizeId][listId][i] = src[scan[i]]; |
---|
| 2633 | } |
---|
| 2634 | #endif |
---|
| 2635 | |
---|
[313] | 2636 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
[414] | 2637 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2638 | ref_scalingListDC[layerId][sizeId][listId] = SCALING_LIST_DC; |
---|
| 2639 | #endif |
---|
[313] | 2640 | } |
---|
| 2641 | |
---|
| 2642 | /** check DC value of matrix for default matrix signaling |
---|
| 2643 | */ |
---|
[414] | 2644 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2645 | Void TComScalingList::checkDcOfMatrix( UInt layerId ) |
---|
| 2646 | #else |
---|
[313] | 2647 | Void TComScalingList::checkDcOfMatrix() |
---|
[414] | 2648 | #endif |
---|
[313] | 2649 | { |
---|
| 2650 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2651 | { |
---|
| 2652 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2653 | { |
---|
| 2654 | //check default matrix? |
---|
| 2655 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 2656 | { |
---|
[414] | 2657 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2658 | processDefaultMarix(sizeId, listId, layerId); |
---|
| 2659 | #else |
---|
[313] | 2660 | processDefaultMarix(sizeId, listId); |
---|
[414] | 2661 | #endif |
---|
[313] | 2662 | } |
---|
| 2663 | } |
---|
| 2664 | } |
---|
| 2665 | } |
---|
| 2666 | |
---|
| 2667 | ParameterSetManager::ParameterSetManager() |
---|
| 2668 | #if SVC_EXTENSION |
---|
| 2669 | : m_spsMap(MAX_NUM_SPS) |
---|
| 2670 | , m_ppsMap(MAX_NUM_PPS) |
---|
| 2671 | , m_activeSPSId(-1) |
---|
| 2672 | , m_activePPSId(-1) |
---|
| 2673 | #else |
---|
| 2674 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 2675 | , m_spsMap(MAX_NUM_SPS) |
---|
| 2676 | , m_ppsMap(MAX_NUM_PPS) |
---|
| 2677 | , m_activeVPSId(-1) |
---|
| 2678 | , m_activeSPSId(-1) |
---|
| 2679 | , m_activePPSId(-1) |
---|
| 2680 | #endif |
---|
| 2681 | { |
---|
| 2682 | } |
---|
| 2683 | |
---|
| 2684 | |
---|
| 2685 | ParameterSetManager::~ParameterSetManager() |
---|
| 2686 | { |
---|
| 2687 | } |
---|
| 2688 | |
---|
| 2689 | //! activate a SPS from a active parameter sets SEI message |
---|
| 2690 | //! \returns true, if activation is successful |
---|
| 2691 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
| 2692 | { |
---|
| 2693 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2694 | if (sps) |
---|
| 2695 | { |
---|
| 2696 | Int vpsId = sps->getVPSId(); |
---|
| 2697 | if (m_vpsMap.getPS(vpsId)) |
---|
| 2698 | { |
---|
| 2699 | m_activeVPSId = vpsId; |
---|
| 2700 | m_activeSPSId = spsId; |
---|
| 2701 | return true; |
---|
| 2702 | } |
---|
| 2703 | else |
---|
| 2704 | { |
---|
| 2705 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
| 2706 | } |
---|
| 2707 | } |
---|
| 2708 | else |
---|
| 2709 | { |
---|
| 2710 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
| 2711 | } |
---|
| 2712 | return false; |
---|
| 2713 | } |
---|
| 2714 | |
---|
| 2715 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
| 2716 | //! \returns true, if activation is successful |
---|
| 2717 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
| 2718 | { |
---|
| 2719 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
| 2720 | if (pps) |
---|
| 2721 | { |
---|
| 2722 | Int spsId = pps->getSPSId(); |
---|
| 2723 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
| 2724 | { |
---|
| 2725 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
| 2726 | return false; |
---|
| 2727 | } |
---|
| 2728 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2729 | if (sps) |
---|
| 2730 | { |
---|
| 2731 | Int vpsId = sps->getVPSId(); |
---|
| 2732 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
| 2733 | { |
---|
| 2734 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
| 2735 | return false; |
---|
| 2736 | } |
---|
| 2737 | if (m_vpsMap.getPS(vpsId)) |
---|
| 2738 | { |
---|
| 2739 | m_activePPSId = ppsId; |
---|
| 2740 | m_activeVPSId = vpsId; |
---|
| 2741 | m_activeSPSId = spsId; |
---|
[414] | 2742 | |
---|
| 2743 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2744 | activeRefPPSId[ sps->getLayerId() ] = ppsId; |
---|
| 2745 | activeRefSPSId[ sps->getLayerId() ] = spsId; |
---|
| 2746 | #endif |
---|
| 2747 | |
---|
[313] | 2748 | return true; |
---|
| 2749 | } |
---|
| 2750 | else |
---|
| 2751 | { |
---|
| 2752 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
| 2753 | } |
---|
| 2754 | } |
---|
| 2755 | else |
---|
| 2756 | { |
---|
| 2757 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
| 2758 | } |
---|
| 2759 | } |
---|
| 2760 | else |
---|
| 2761 | { |
---|
| 2762 | printf("Warning: tried to activate non-existing PPS."); |
---|
| 2763 | } |
---|
| 2764 | return false; |
---|
| 2765 | } |
---|
| 2766 | |
---|
| 2767 | ProfileTierLevel::ProfileTierLevel() |
---|
| 2768 | : m_profileSpace (0) |
---|
| 2769 | , m_tierFlag (false) |
---|
| 2770 | , m_profileIdc (0) |
---|
| 2771 | , m_levelIdc (0) |
---|
| 2772 | , m_progressiveSourceFlag (false) |
---|
| 2773 | , m_interlacedSourceFlag (false) |
---|
| 2774 | , m_nonPackedConstraintFlag(false) |
---|
| 2775 | , m_frameOnlyConstraintFlag(false) |
---|
| 2776 | { |
---|
| 2777 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 2778 | } |
---|
| 2779 | #if VPS_EXTN_PROFILE_INFO |
---|
| 2780 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
| 2781 | { |
---|
| 2782 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
| 2783 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
| 2784 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
| 2785 | for(Int j = 0; j < 32; j++) |
---|
| 2786 | { |
---|
| 2787 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
| 2788 | } |
---|
| 2789 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
| 2790 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
| 2791 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
| 2792 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
| 2793 | } |
---|
| 2794 | #endif |
---|
| 2795 | |
---|
| 2796 | TComPTL::TComPTL() |
---|
| 2797 | { |
---|
| 2798 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 2799 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 2800 | } |
---|
| 2801 | #if VPS_EXTN_PROFILE_INFO |
---|
| 2802 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
| 2803 | { |
---|
| 2804 | // Copy all information related to general profile |
---|
| 2805 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
| 2806 | } |
---|
| 2807 | #endif |
---|
| 2808 | |
---|
| 2809 | #if SVC_EXTENSION |
---|
| 2810 | #if AVC_SYNTAX |
---|
| 2811 | Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice ) |
---|
| 2812 | { |
---|
| 2813 | // 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 |
---|
| 2814 | setPOC( pcSlice->getPOC() ); |
---|
| 2815 | if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) |
---|
| 2816 | { |
---|
| 2817 | setSliceType( I_SLICE ); |
---|
| 2818 | } |
---|
| 2819 | else |
---|
| 2820 | { |
---|
| 2821 | setSliceType( pcSlice->getSliceType() ); |
---|
| 2822 | } |
---|
| 2823 | |
---|
| 2824 | if( this->isIntra() ) |
---|
| 2825 | { |
---|
| 2826 | return; |
---|
| 2827 | } |
---|
| 2828 | |
---|
| 2829 | //initialize reference POC of BL |
---|
| 2830 | for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ ) |
---|
| 2831 | { |
---|
| 2832 | RefPicList eRefPicList = RefPicList( iRefPicList ); |
---|
| 2833 | |
---|
| 2834 | assert( pcSlice->getNumRefIdx( eRefPicList) >= 0 ); |
---|
| 2835 | setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 ); |
---|
| 2836 | assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF); |
---|
| 2837 | |
---|
| 2838 | for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++) |
---|
| 2839 | { |
---|
| 2840 | setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx ); |
---|
| 2841 | setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx ); |
---|
| 2842 | /* |
---|
| 2843 | // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused. |
---|
| 2844 | getRefPic( eRefPicList, refIdx )->setLayerId( 0 ); |
---|
| 2845 | getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() ); |
---|
| 2846 | */ |
---|
| 2847 | |
---|
| 2848 | } |
---|
| 2849 | } |
---|
| 2850 | return; |
---|
| 2851 | } |
---|
| 2852 | #endif |
---|
| 2853 | |
---|
| 2854 | Void TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
| 2855 | { |
---|
| 2856 | if(m_layerId == 0) |
---|
| 2857 | { |
---|
| 2858 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
| 2859 | return; |
---|
| 2860 | } |
---|
[411] | 2861 | #if POC_RESET_FLAG |
---|
| 2862 | if( this->getPocResetFlag() ) |
---|
| 2863 | { |
---|
| 2864 | setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, 0)); |
---|
| 2865 | } |
---|
| 2866 | else |
---|
| 2867 | { |
---|
| 2868 | setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); |
---|
| 2869 | } |
---|
| 2870 | #else |
---|
[313] | 2871 | setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); |
---|
[411] | 2872 | #endif |
---|
[313] | 2873 | } |
---|
| 2874 | #endif |
---|
| 2875 | |
---|
| 2876 | #if REF_IDX_MFM |
---|
| 2877 | Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL ) |
---|
| 2878 | { |
---|
| 2879 | for( UInt i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
| 2880 | { |
---|
| 2881 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
| 2882 | |
---|
| 2883 | TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc]; |
---|
| 2884 | //set reference picture POC of each ILP reference |
---|
| 2885 | Int thePoc = ilpPic[refLayerIdc]->getPOC(); |
---|
[411] | 2886 | assert(thePoc >= 0); |
---|
[313] | 2887 | assert(thePoc == pcRefPicBL->getPOC()); |
---|
| 2888 | |
---|
| 2889 | ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
| 2890 | |
---|
| 2891 | //copy reference pictures marking from the reference layer |
---|
| 2892 | ilpPic[refLayerIdc]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0)); |
---|
| 2893 | |
---|
| 2894 | for( Int refList = 0; refList < 2; refList++ ) |
---|
| 2895 | { |
---|
| 2896 | RefPicList refPicList = RefPicList( refList ); |
---|
| 2897 | |
---|
| 2898 | //set reference POC of ILP |
---|
| 2899 | ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
| 2900 | assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
| 2901 | assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
| 2902 | |
---|
| 2903 | //initialize reference POC of ILP |
---|
| 2904 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
| 2905 | { |
---|
| 2906 | ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
| 2907 | ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
| 2908 | } |
---|
| 2909 | |
---|
| 2910 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
| 2911 | { |
---|
| 2912 | ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
| 2913 | ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
| 2914 | } |
---|
| 2915 | } |
---|
| 2916 | } |
---|
| 2917 | return; |
---|
| 2918 | } |
---|
| 2919 | #endif |
---|
| 2920 | |
---|
| 2921 | //! \} |
---|