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