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