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