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