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