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