[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 | { |
---|
[25] | 521 | #if REF_IDX_MFM |
---|
| 522 | assert(iRefPicNum == 1); |
---|
[27] | 523 | if( getPOC() != 0 ) |
---|
[25] | 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 | } |
---|
[25] | 555 | |
---|
| 556 | #if REF_IDX_MFM |
---|
[27] | 557 | Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL ) |
---|
[25] | 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 | |
---|
| 564 | //initialize reference POC of ILP |
---|
| 565 | for(Int refIdx = 0; refIdx < MAX_NUM_REF; refIdx++) |
---|
| 566 | { |
---|
| 567 | ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_0, refIdx); |
---|
| 568 | ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_1, refIdx); |
---|
| 569 | |
---|
| 570 | ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_0, refIdx); |
---|
| 571 | ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_1, refIdx); |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | //set reference POC of ILP |
---|
| 575 | ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_0, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0)); |
---|
| 576 | assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0) <= MAX_NUM_REF); |
---|
| 577 | ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_1, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1)); |
---|
| 578 | assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1) <= MAX_NUM_REF); |
---|
[27] | 579 | |
---|
[25] | 580 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++) |
---|
[27] | 581 | { |
---|
[32] | 582 | ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx); |
---|
[27] | 583 | } |
---|
[25] | 584 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++) |
---|
[27] | 585 | { |
---|
[32] | 586 | ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx); |
---|
[27] | 587 | } |
---|
[25] | 588 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++) |
---|
[27] | 589 | { |
---|
[32] | 590 | ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx); |
---|
[27] | 591 | } |
---|
[25] | 592 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++) |
---|
[27] | 593 | { |
---|
[32] | 594 | ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx); |
---|
[27] | 595 | } |
---|
| 596 | return; |
---|
[25] | 597 | } |
---|
[2] | 598 | #endif |
---|
| 599 | |
---|
[25] | 600 | #endif |
---|
| 601 | |
---|
[2] | 602 | Int TComSlice::getNumRpsCurrTempList() |
---|
| 603 | { |
---|
| 604 | Int numRpsCurrTempList = 0; |
---|
| 605 | |
---|
| 606 | if (m_eSliceType == I_SLICE) |
---|
| 607 | { |
---|
| 608 | return 0; |
---|
| 609 | } |
---|
| 610 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
| 611 | { |
---|
| 612 | if(m_pcRPS->getUsed(i)) |
---|
| 613 | { |
---|
| 614 | numRpsCurrTempList++; |
---|
| 615 | } |
---|
| 616 | } |
---|
| 617 | return numRpsCurrTempList; |
---|
| 618 | } |
---|
| 619 | #if SVC_EXTENSION |
---|
| 620 | Void TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt layerID ) |
---|
| 621 | { |
---|
| 622 | if (layerID == 0) |
---|
| 623 | { |
---|
| 624 | m_pcBaseColPic = NULL; |
---|
| 625 | return; |
---|
| 626 | } |
---|
| 627 | setBaseColPic(xGetRefPic(rcListPic, getPOC())); |
---|
| 628 | } |
---|
| 629 | #endif |
---|
| 630 | |
---|
| 631 | Void TComSlice::initEqualRef() |
---|
| 632 | { |
---|
| 633 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 634 | { |
---|
| 635 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 636 | { |
---|
| 637 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 638 | { |
---|
| 639 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 640 | } |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | } |
---|
| 644 | |
---|
| 645 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 646 | { |
---|
| 647 | Int i; |
---|
| 648 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
| 649 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
| 650 | TComSlice* preSlice; |
---|
| 651 | Int preColRefPOC; |
---|
| 652 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 653 | { |
---|
| 654 | preSlice = pic->getSlice(i); |
---|
| 655 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 656 | { |
---|
| 657 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
| 658 | if(currColRefPOC != preColRefPOC) |
---|
| 659 | { |
---|
| 660 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 661 | exit(EXIT_FAILURE); |
---|
| 662 | } |
---|
| 663 | else |
---|
| 664 | { |
---|
| 665 | break; |
---|
| 666 | } |
---|
| 667 | } |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | |
---|
| 671 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic*>& rcListPic) |
---|
| 672 | { |
---|
| 673 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 674 | { |
---|
| 675 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 676 | { |
---|
| 677 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 681 | { |
---|
| 682 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 683 | { |
---|
| 684 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | #if SUPPORT_FOR_RAP_N_LP |
---|
| 688 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
| 689 | #else |
---|
| 690 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR ) // IDR picture found |
---|
| 691 | #endif |
---|
| 692 | { |
---|
| 693 | prevRAPisBLA = false; |
---|
| 694 | } |
---|
| 695 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
| 696 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 697 | #else |
---|
| 698 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT ) // CRA/CRANT picture found |
---|
| 699 | #endif |
---|
| 700 | { |
---|
| 701 | pocCRA = getPOC(); |
---|
| 702 | prevRAPisBLA = false; |
---|
| 703 | } |
---|
| 704 | #if SUPPORT_FOR_RAP_N_LP |
---|
| 705 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
| 706 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
| 707 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 708 | #else |
---|
| 709 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT ) // BLA/BLANT picture found |
---|
| 710 | #endif |
---|
| 711 | { |
---|
| 712 | pocCRA = getPOC(); |
---|
| 713 | prevRAPisBLA = true; |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 718 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
| 719 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 720 | * \param rcListPic reference to the reference picture list |
---|
| 721 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
| 722 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
| 723 | * are marked as "unused for reference" |
---|
| 724 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 725 | * Otherwise |
---|
| 726 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
| 727 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 728 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
| 729 | * the bRefreshPending flag to false. |
---|
| 730 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
| 731 | * reference of the current picture. |
---|
| 732 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 733 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 734 | */ |
---|
| 735 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
| 736 | { |
---|
| 737 | TComPic* rpcPic; |
---|
| 738 | UInt uiPOCCurr = getPOC(); |
---|
| 739 | |
---|
| 740 | #if SUPPORT_FOR_RAP_N_LP |
---|
| 741 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
| 742 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
| 743 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 744 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR |
---|
| 745 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
| 746 | #else |
---|
| 747 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT) // IDR/BLA/BLANT |
---|
| 748 | #endif |
---|
| 749 | { |
---|
| 750 | // mark all pictures as not used for reference |
---|
| 751 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 752 | while (iterPic != rcListPic.end()) |
---|
| 753 | { |
---|
| 754 | rpcPic = *(iterPic); |
---|
| 755 | rpcPic->setCurrSliceIdx(0); |
---|
| 756 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
| 757 | iterPic++; |
---|
| 758 | } |
---|
| 759 | #if SUPPORT_FOR_RAP_N_LP |
---|
| 760 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA |
---|
| 761 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT |
---|
| 762 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 763 | #else |
---|
| 764 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT) |
---|
| 765 | #endif |
---|
| 766 | { |
---|
| 767 | pocCRA = uiPOCCurr; |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | else // CRA or No DR |
---|
| 771 | { |
---|
| 772 | if (bRefreshPending==true && uiPOCCurr > pocCRA) // CRA reference marking pending |
---|
| 773 | { |
---|
| 774 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 775 | while (iterPic != rcListPic.end()) |
---|
| 776 | { |
---|
| 777 | rpcPic = *(iterPic); |
---|
| 778 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false); |
---|
| 779 | iterPic++; |
---|
| 780 | } |
---|
| 781 | bRefreshPending = false; |
---|
| 782 | } |
---|
| 783 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
| 784 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 785 | #else |
---|
| 786 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT) // CRA/CRANT picture found |
---|
| 787 | #endif |
---|
| 788 | { |
---|
| 789 | bRefreshPending = true; |
---|
| 790 | pocCRA = uiPOCCurr; |
---|
| 791 | } |
---|
| 792 | } |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 796 | { |
---|
| 797 | assert( pSrc != NULL ); |
---|
| 798 | |
---|
| 799 | Int i, j, k; |
---|
| 800 | |
---|
| 801 | m_iPOC = pSrc->m_iPOC; |
---|
| 802 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
| 803 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 804 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
| 805 | #if ADAPTIVE_QP_SELECTION |
---|
| 806 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 807 | #endif |
---|
| 808 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 809 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 810 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 811 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
| 812 | |
---|
| 813 | for (i = 0; i < 3; i++) |
---|
| 814 | { |
---|
| 815 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 816 | } |
---|
| 817 | |
---|
| 818 | for (i = 0; i < 2; i++) |
---|
| 819 | { |
---|
| 820 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
| 821 | { |
---|
| 822 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
| 823 | } |
---|
| 824 | } |
---|
| 825 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
| 826 | { |
---|
| 827 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
| 828 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
| 829 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
| 830 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
| 831 | } |
---|
| 832 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
| 833 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
| 834 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 835 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
| 836 | #if CHROMA_QP_EXTENSION |
---|
| 837 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
| 838 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
| 839 | #endif |
---|
| 840 | for (i = 0; i < 2; i++) |
---|
| 841 | { |
---|
| 842 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 843 | { |
---|
| 844 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 845 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | m_iDepth = pSrc->m_iDepth; |
---|
| 849 | |
---|
| 850 | // referenced slice |
---|
| 851 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 852 | |
---|
| 853 | // access channel |
---|
| 854 | m_pcSPS = pSrc->m_pcSPS; |
---|
| 855 | m_pcPPS = pSrc->m_pcPPS; |
---|
| 856 | m_pcRPS = pSrc->m_pcRPS; |
---|
| 857 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 858 | |
---|
| 859 | m_pcPic = pSrc->m_pcPic; |
---|
| 860 | #if !REMOVE_APS |
---|
| 861 | m_pcAPS = pSrc->m_pcAPS; |
---|
| 862 | m_iAPSId = pSrc->m_iAPSId; |
---|
| 863 | #endif |
---|
| 864 | |
---|
| 865 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
| 866 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
| 867 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
| 868 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
| 869 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
| 870 | #else |
---|
| 871 | m_dLambda = pSrc->m_dLambda; |
---|
| 872 | #endif |
---|
| 873 | for (i = 0; i < 2; i++) |
---|
| 874 | { |
---|
| 875 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 876 | { |
---|
| 877 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 878 | { |
---|
| 879 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 880 | } |
---|
| 881 | } |
---|
| 882 | } |
---|
| 883 | |
---|
| 884 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
| 885 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 886 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 887 | |
---|
| 888 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
| 889 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
| 890 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
| 891 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
| 892 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
| 893 | m_uiDependentSliceMode = pSrc->m_uiDependentSliceMode; |
---|
| 894 | m_uiDependentSliceArgument = pSrc->m_uiDependentSliceArgument; |
---|
| 895 | m_uiDependentSliceCurStartCUAddr = pSrc->m_uiDependentSliceCurStartCUAddr; |
---|
| 896 | m_uiDependentSliceCurEndCUAddr = pSrc->m_uiDependentSliceCurEndCUAddr; |
---|
| 897 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
| 898 | m_bNextDependentSlice = pSrc->m_bNextDependentSlice; |
---|
| 899 | for ( int e=0 ; e<2 ; e++ ) |
---|
| 900 | { |
---|
| 901 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
| 902 | { |
---|
| 903 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
| 904 | } |
---|
| 905 | } |
---|
| 906 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
| 907 | #if SAO_TYPE_SHARING |
---|
| 908 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
| 909 | #else |
---|
| 910 | m_saoEnabledFlagCb = pSrc->m_saoEnabledFlagCb; |
---|
| 911 | m_saoEnabledFlagCr = pSrc->m_saoEnabledFlagCr; |
---|
| 912 | #endif |
---|
| 913 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
| 914 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
| 915 | |
---|
| 916 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 917 | #if !REMOVE_ALF |
---|
| 918 | for(Int compIdx=0; compIdx < 3; compIdx++) |
---|
| 919 | { |
---|
| 920 | m_alfEnabledFlag[compIdx] = pSrc->m_alfEnabledFlag[compIdx]; |
---|
| 921 | } |
---|
| 922 | #endif |
---|
| 923 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
| 924 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | #if PREVREFPIC_DEFN |
---|
| 928 | int TComSlice::m_prevPOC[MAX_TLAYER] = {0}; |
---|
| 929 | #else |
---|
| 930 | int TComSlice::m_prevPOC = 0; |
---|
| 931 | #endif |
---|
| 932 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 933 | * \param uiTLayer Temporal layer ID of the current slice |
---|
| 934 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 935 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
| 936 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 937 | */ |
---|
| 938 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
| 939 | { |
---|
| 940 | m_uiTLayer = uiTLayer; |
---|
| 941 | } |
---|
| 942 | |
---|
| 943 | /** Function for checking if this is a switching-point |
---|
| 944 | */ |
---|
| 945 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 946 | { |
---|
| 947 | TComPic* rpcPic; |
---|
| 948 | // loop through all pictures in the reference picture buffer |
---|
| 949 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 950 | while ( iterPic != rcListPic.end()) |
---|
| 951 | { |
---|
| 952 | rpcPic = *(iterPic++); |
---|
| 953 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 954 | { |
---|
| 955 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 956 | { |
---|
| 957 | return false; |
---|
| 958 | } |
---|
| 959 | } |
---|
| 960 | } |
---|
| 961 | return true; |
---|
| 962 | } |
---|
| 963 | |
---|
| 964 | #if STSA |
---|
| 965 | /** Function for checking if this is a STSA candidate |
---|
| 966 | */ |
---|
| 967 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 968 | { |
---|
| 969 | TComPic* rpcPic; |
---|
| 970 | |
---|
| 971 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 972 | while ( iterPic != rcListPic.end()) |
---|
| 973 | { |
---|
| 974 | rpcPic = *(iterPic++); |
---|
| 975 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
| 976 | { |
---|
| 977 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 978 | { |
---|
| 979 | return false; |
---|
| 980 | } |
---|
| 981 | } |
---|
| 982 | } |
---|
| 983 | return true; |
---|
| 984 | } |
---|
| 985 | #endif |
---|
| 986 | |
---|
| 987 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 988 | */ |
---|
| 989 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 990 | { |
---|
| 991 | TComPic* rpcPic; |
---|
| 992 | Int i, isReference; |
---|
| 993 | |
---|
| 994 | Int j = 0; |
---|
| 995 | // loop through all pictures in the reference picture buffer |
---|
| 996 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 997 | while ( iterPic != rcListPic.end()) |
---|
| 998 | { |
---|
| 999 | j++; |
---|
| 1000 | rpcPic = *(iterPic++); |
---|
| 1001 | |
---|
| 1002 | isReference = 0; |
---|
| 1003 | // loop through all pictures in the Reference Picture Set |
---|
| 1004 | // to see if the picture should be kept as reference picture |
---|
| 1005 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1006 | { |
---|
| 1007 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1008 | { |
---|
| 1009 | isReference = 1; |
---|
| 1010 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1011 | rpcPic->setIsLongTerm(0); |
---|
| 1012 | rpcPic->setIsUsedAsLongTerm(0); |
---|
| 1013 | } |
---|
| 1014 | } |
---|
| 1015 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1016 | { |
---|
| 1017 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1018 | { |
---|
| 1019 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1020 | { |
---|
| 1021 | isReference = 1; |
---|
| 1022 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1023 | } |
---|
| 1024 | } |
---|
| 1025 | else |
---|
| 1026 | { |
---|
| 1027 | 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())) |
---|
| 1028 | { |
---|
| 1029 | isReference = 1; |
---|
| 1030 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1031 | } |
---|
| 1032 | } |
---|
| 1033 | |
---|
| 1034 | } |
---|
| 1035 | // mark the picture as "unused for reference" if it is not in |
---|
| 1036 | // the Reference Picture Set |
---|
| 1037 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1038 | { |
---|
| 1039 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
| 1040 | rpcPic->setIsLongTerm(0); |
---|
| 1041 | } |
---|
| 1042 | //check that pictures of higher temporal layers are not used |
---|
| 1043 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1044 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
| 1045 | #if NAL_UNIT_TYPES_J1003_D7 |
---|
| 1046 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
| 1047 | #else |
---|
| 1048 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA) |
---|
| 1049 | #endif |
---|
| 1050 | { |
---|
| 1051 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1052 | } |
---|
| 1053 | #if TEMPORAL_LAYER_NON_REFERENCE |
---|
| 1054 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1055 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1056 | { |
---|
| 1057 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1058 | } |
---|
| 1059 | #endif |
---|
| 1060 | } |
---|
| 1061 | } |
---|
| 1062 | |
---|
| 1063 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1064 | */ |
---|
| 1065 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
| 1066 | { |
---|
| 1067 | TComPic* rpcPic; |
---|
| 1068 | Int i, isAvailable, j; |
---|
| 1069 | Int atLeastOneLost = 0; |
---|
| 1070 | Int atLeastOneRemoved = 0; |
---|
| 1071 | Int iPocLost = 0; |
---|
| 1072 | |
---|
| 1073 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1074 | // to see if the picture should be kept as reference picture |
---|
| 1075 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1076 | { |
---|
| 1077 | j = 0; |
---|
| 1078 | isAvailable = 0; |
---|
| 1079 | // loop through all pictures in the reference picture buffer |
---|
| 1080 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1081 | while ( iterPic != rcListPic.end()) |
---|
| 1082 | { |
---|
| 1083 | j++; |
---|
| 1084 | rpcPic = *(iterPic++); |
---|
| 1085 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1086 | { |
---|
| 1087 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1088 | { |
---|
| 1089 | isAvailable = 1; |
---|
| 1090 | } |
---|
| 1091 | } |
---|
| 1092 | else |
---|
| 1093 | { |
---|
| 1094 | 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()) |
---|
| 1095 | { |
---|
| 1096 | isAvailable = 1; |
---|
| 1097 | } |
---|
| 1098 | } |
---|
| 1099 | } |
---|
| 1100 | // if there was no such long-term check the short terms |
---|
| 1101 | if(!isAvailable) |
---|
| 1102 | { |
---|
| 1103 | iterPic = rcListPic.begin(); |
---|
| 1104 | while ( iterPic != rcListPic.end()) |
---|
| 1105 | { |
---|
| 1106 | j++; |
---|
| 1107 | rpcPic = *(iterPic++); |
---|
| 1108 | |
---|
| 1109 | 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()) |
---|
| 1110 | { |
---|
| 1111 | isAvailable = 1; |
---|
| 1112 | rpcPic->setIsLongTerm(1); |
---|
| 1113 | rpcPic->setIsUsedAsLongTerm(1); |
---|
| 1114 | break; |
---|
| 1115 | } |
---|
| 1116 | } |
---|
| 1117 | } |
---|
| 1118 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1119 | // but not available as reference picture |
---|
| 1120 | if(isAvailable == 0) |
---|
| 1121 | { |
---|
| 1122 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1123 | { |
---|
| 1124 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1125 | { |
---|
| 1126 | if(printErrors) |
---|
| 1127 | { |
---|
| 1128 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1129 | } |
---|
| 1130 | atLeastOneRemoved = 1; |
---|
| 1131 | } |
---|
| 1132 | else |
---|
| 1133 | { |
---|
| 1134 | if(printErrors) |
---|
| 1135 | { |
---|
| 1136 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1137 | } |
---|
| 1138 | atLeastOneLost = 1; |
---|
| 1139 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1140 | } |
---|
| 1141 | } |
---|
| 1142 | } |
---|
| 1143 | } |
---|
| 1144 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1145 | // to see if the picture should be kept as reference picture |
---|
| 1146 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1147 | { |
---|
| 1148 | j = 0; |
---|
| 1149 | isAvailable = 0; |
---|
| 1150 | // loop through all pictures in the reference picture buffer |
---|
| 1151 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1152 | while ( iterPic != rcListPic.end()) |
---|
| 1153 | { |
---|
| 1154 | j++; |
---|
| 1155 | rpcPic = *(iterPic++); |
---|
| 1156 | |
---|
| 1157 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1158 | { |
---|
| 1159 | isAvailable = 1; |
---|
| 1160 | } |
---|
| 1161 | } |
---|
| 1162 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1163 | // but not available as reference picture |
---|
| 1164 | if(isAvailable == 0) |
---|
| 1165 | { |
---|
| 1166 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1167 | { |
---|
| 1168 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1169 | { |
---|
| 1170 | if(printErrors) |
---|
| 1171 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1172 | atLeastOneRemoved = 1; |
---|
| 1173 | } |
---|
| 1174 | else |
---|
| 1175 | { |
---|
| 1176 | if(printErrors) |
---|
| 1177 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1178 | atLeastOneLost = 1; |
---|
| 1179 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1180 | } |
---|
| 1181 | } |
---|
| 1182 | } |
---|
| 1183 | } |
---|
| 1184 | if(atLeastOneLost) |
---|
| 1185 | { |
---|
| 1186 | return iPocLost+1; |
---|
| 1187 | } |
---|
| 1188 | if(atLeastOneRemoved) |
---|
| 1189 | { |
---|
| 1190 | return -2; |
---|
| 1191 | } |
---|
| 1192 | else |
---|
| 1193 | { |
---|
| 1194 | return 0; |
---|
| 1195 | } |
---|
| 1196 | } |
---|
| 1197 | |
---|
| 1198 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1199 | */ |
---|
| 1200 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1201 | { |
---|
| 1202 | TComPic* rpcPic; |
---|
| 1203 | Int i, j; |
---|
| 1204 | Int k = 0; |
---|
| 1205 | Int nrOfNegativePictures = 0; |
---|
| 1206 | Int nrOfPositivePictures = 0; |
---|
| 1207 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
| 1208 | |
---|
| 1209 | // loop through all pictures in the Reference Picture Set |
---|
| 1210 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1211 | { |
---|
| 1212 | j = 0; |
---|
| 1213 | // loop through all pictures in the reference picture buffer |
---|
| 1214 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1215 | while ( iterPic != rcListPic.end()) |
---|
| 1216 | { |
---|
| 1217 | j++; |
---|
| 1218 | rpcPic = *(iterPic++); |
---|
| 1219 | |
---|
| 1220 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1221 | { |
---|
| 1222 | // This picture exists as a reference picture |
---|
| 1223 | // and should be added to the explicit Reference Picture Set |
---|
| 1224 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1225 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
| 1226 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
| 1227 | { |
---|
| 1228 | nrOfNegativePictures++; |
---|
| 1229 | } |
---|
| 1230 | else |
---|
| 1231 | { |
---|
| 1232 | nrOfPositivePictures++; |
---|
| 1233 | } |
---|
| 1234 | k++; |
---|
| 1235 | } |
---|
| 1236 | } |
---|
| 1237 | } |
---|
| 1238 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1239 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1240 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1241 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
| 1242 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1243 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
| 1244 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
| 1245 | { |
---|
| 1246 | pcRPS->setInterRPSPrediction(false); |
---|
| 1247 | pcRPS->setNumRefIdc(0); |
---|
| 1248 | } |
---|
| 1249 | else |
---|
| 1250 | { |
---|
| 1251 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1252 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
| 1253 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1254 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1255 | Int iNewIdc=0; |
---|
| 1256 | for(i=0; i<= iRefPics; i++) |
---|
| 1257 | { |
---|
| 1258 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1259 | Int iRefIdc = 0; |
---|
| 1260 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
| 1261 | { |
---|
| 1262 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
| 1263 | { |
---|
| 1264 | if (pcRPS->getUsed(j)) |
---|
| 1265 | { |
---|
| 1266 | iRefIdc = 1; |
---|
| 1267 | } |
---|
| 1268 | else |
---|
| 1269 | { |
---|
| 1270 | iRefIdc = 2; |
---|
| 1271 | } |
---|
| 1272 | } |
---|
| 1273 | } |
---|
| 1274 | pcRPS->setRefIdc(i, iRefIdc); |
---|
| 1275 | iNewIdc++; |
---|
| 1276 | } |
---|
| 1277 | pcRPS->setInterRPSPrediction(true); |
---|
| 1278 | pcRPS->setNumRefIdc(iNewIdc); |
---|
| 1279 | pcRPS->setDeltaRPS(deltaRPS); |
---|
| 1280 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1281 | } |
---|
| 1282 | |
---|
| 1283 | this->setRPS(pcRPS); |
---|
| 1284 | this->setRPSidx(-1); |
---|
| 1285 | } |
---|
| 1286 | |
---|
| 1287 | /** get AC and DC values for weighted pred |
---|
| 1288 | * \param *wp |
---|
| 1289 | * \returns Void |
---|
| 1290 | */ |
---|
| 1291 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
| 1292 | { |
---|
| 1293 | wp = m_weightACDCParam; |
---|
| 1294 | } |
---|
| 1295 | |
---|
| 1296 | /** init AC and DC values for weighted pred |
---|
| 1297 | * \returns Void |
---|
| 1298 | */ |
---|
| 1299 | Void TComSlice::initWpAcDcParam() |
---|
| 1300 | { |
---|
| 1301 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
| 1302 | { |
---|
| 1303 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1304 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1305 | } |
---|
| 1306 | } |
---|
| 1307 | |
---|
| 1308 | /** get WP tables for weighted pred |
---|
| 1309 | * \param RefPicList |
---|
| 1310 | * \param iRefIdx |
---|
| 1311 | * \param *&wpScalingParam |
---|
| 1312 | * \returns Void |
---|
| 1313 | */ |
---|
| 1314 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
| 1315 | { |
---|
| 1316 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1317 | } |
---|
| 1318 | |
---|
| 1319 | /** reset Default WP tables settings : no weight. |
---|
| 1320 | * \param wpScalingParam |
---|
| 1321 | * \returns Void |
---|
| 1322 | */ |
---|
| 1323 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
| 1324 | { |
---|
| 1325 | for ( int e=0 ; e<2 ; e++ ) |
---|
| 1326 | { |
---|
| 1327 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1328 | { |
---|
| 1329 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1330 | { |
---|
| 1331 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
| 1332 | pwp->bPresentFlag = false; |
---|
| 1333 | pwp->uiLog2WeightDenom = 0; |
---|
| 1334 | pwp->uiLog2WeightDenom = 0; |
---|
| 1335 | pwp->iWeight = 1; |
---|
| 1336 | pwp->iOffset = 0; |
---|
| 1337 | } |
---|
| 1338 | } |
---|
| 1339 | } |
---|
| 1340 | } |
---|
| 1341 | |
---|
| 1342 | /** init WP table |
---|
| 1343 | * \returns Void |
---|
| 1344 | */ |
---|
| 1345 | Void TComSlice::initWpScaling() |
---|
| 1346 | { |
---|
| 1347 | initWpScaling(m_weightPredTable); |
---|
| 1348 | } |
---|
| 1349 | |
---|
| 1350 | /** set WP tables |
---|
| 1351 | * \param wpScalingParam |
---|
| 1352 | * \returns Void |
---|
| 1353 | */ |
---|
| 1354 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
| 1355 | { |
---|
| 1356 | for ( int e=0 ; e<2 ; e++ ) |
---|
| 1357 | { |
---|
| 1358 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1359 | { |
---|
| 1360 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1361 | { |
---|
| 1362 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
| 1363 | if ( !pwp->bPresentFlag ) { |
---|
| 1364 | // Inferring values not present : |
---|
| 1365 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1366 | pwp->iOffset = 0; |
---|
| 1367 | } |
---|
| 1368 | |
---|
| 1369 | pwp->w = pwp->iWeight; |
---|
| 1370 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
| 1371 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1372 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1373 | } |
---|
| 1374 | } |
---|
| 1375 | } |
---|
| 1376 | } |
---|
| 1377 | |
---|
| 1378 | // ------------------------------------------------------------------------------------------------ |
---|
| 1379 | // Video parameter set (VPS) |
---|
| 1380 | // ------------------------------------------------------------------------------------------------ |
---|
| 1381 | TComVPS::TComVPS() |
---|
| 1382 | : m_VPSId ( 0) |
---|
| 1383 | , m_uiMaxTLayers ( 1) |
---|
| 1384 | , m_uiMaxLayers ( 1) |
---|
| 1385 | , m_bTemporalIdNestingFlag (false) |
---|
| 1386 | { |
---|
| 1387 | |
---|
| 1388 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1389 | { |
---|
| 1390 | m_numReorderPics[i] = 0; |
---|
| 1391 | m_uiMaxDecPicBuffering[i] = 0; |
---|
| 1392 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1393 | } |
---|
| 1394 | } |
---|
| 1395 | |
---|
| 1396 | TComVPS::~TComVPS() |
---|
| 1397 | { |
---|
| 1398 | |
---|
| 1399 | |
---|
| 1400 | } |
---|
| 1401 | |
---|
| 1402 | // ------------------------------------------------------------------------------------------------ |
---|
| 1403 | // Sequence parameter set (SPS) |
---|
| 1404 | // ------------------------------------------------------------------------------------------------ |
---|
| 1405 | |
---|
| 1406 | TComSPS::TComSPS() |
---|
| 1407 | : m_SPSId ( 0) |
---|
| 1408 | #if !SPS_SYNTAX_CHANGES |
---|
| 1409 | , m_ProfileSpace ( 0) |
---|
| 1410 | , m_ProfileIdc ( 0) |
---|
| 1411 | , m_ReservedIndicatorFlags ( 0) |
---|
| 1412 | , m_LevelIdc ( 0) |
---|
| 1413 | , m_ProfileCompatibility ( 0) |
---|
| 1414 | #endif |
---|
| 1415 | , m_VPSId ( 0) |
---|
| 1416 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 1417 | , m_uiMaxTLayers ( 1) |
---|
| 1418 | // Structure |
---|
| 1419 | , m_picWidthInLumaSamples (352) |
---|
| 1420 | , m_picHeightInLumaSamples (288) |
---|
| 1421 | , m_picCroppingFlag (false) |
---|
| 1422 | , m_picCropLeftOffset ( 0) |
---|
| 1423 | , m_picCropRightOffset ( 0) |
---|
| 1424 | , m_picCropTopOffset ( 0) |
---|
| 1425 | , m_picCropBottomOffset ( 0) |
---|
| 1426 | , m_uiMaxCUWidth ( 32) |
---|
| 1427 | , m_uiMaxCUHeight ( 32) |
---|
| 1428 | , m_uiMaxCUDepth ( 3) |
---|
| 1429 | , m_uiMinTrDepth ( 0) |
---|
| 1430 | , m_uiMaxTrDepth ( 1) |
---|
| 1431 | , m_bLongTermRefsPresent (false) |
---|
| 1432 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 1433 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 1434 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 1435 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 1436 | // Tool list |
---|
| 1437 | , m_usePCM (false) |
---|
| 1438 | , m_pcmLog2MaxSize ( 5) |
---|
| 1439 | , m_uiPCMLog2MinSize ( 7) |
---|
| 1440 | #if !REMOVE_ALF |
---|
| 1441 | , m_bUseALF (false) |
---|
| 1442 | #endif |
---|
| 1443 | #if !REMOVE_LMCHROMA |
---|
| 1444 | , m_bUseLMChroma (false) |
---|
| 1445 | #endif |
---|
| 1446 | #if !PPS_TS_FLAG |
---|
| 1447 | , m_useTransformSkip (false) |
---|
| 1448 | , m_useTransformSkipFast (false) |
---|
| 1449 | #endif |
---|
| 1450 | , m_bUseLComb (false) |
---|
| 1451 | , m_restrictedRefPicListsFlag ( 1) |
---|
| 1452 | , m_listsModificationPresentFlag( 0) |
---|
| 1453 | , m_uiBitDepth ( 8) |
---|
| 1454 | , m_uiBitIncrement ( 0) |
---|
| 1455 | , m_qpBDOffsetY ( 0) |
---|
| 1456 | , m_qpBDOffsetC ( 0) |
---|
| 1457 | , m_useLossless (false) |
---|
| 1458 | , m_uiPCMBitDepthLuma ( 8) |
---|
| 1459 | , m_uiPCMBitDepthChroma ( 8) |
---|
| 1460 | , m_bPCMFilterDisableFlag (false) |
---|
| 1461 | , m_uiBitsForPOC ( 8) |
---|
| 1462 | #if LTRP_IN_SPS |
---|
| 1463 | , m_numLongTermRefPicSPS ( 0) |
---|
| 1464 | #endif |
---|
| 1465 | , m_uiMaxTrSize ( 32) |
---|
| 1466 | #if !MOVE_LOOP_FILTER_SLICES_FLAG |
---|
| 1467 | , m_bLFCrossSliceBoundaryFlag (false) |
---|
| 1468 | #endif |
---|
| 1469 | , m_bUseSAO (false) |
---|
| 1470 | , m_bTemporalIdNestingFlag (false) |
---|
| 1471 | , m_scalingListEnabledFlag (false) |
---|
| 1472 | #if SUPPORT_FOR_VUI |
---|
| 1473 | , m_vuiParametersPresentFlag (false) |
---|
| 1474 | , m_vuiParameters () |
---|
| 1475 | #endif |
---|
| 1476 | #if SVC_EXTENSION |
---|
| 1477 | , m_layerId(0) |
---|
| 1478 | #endif |
---|
| 1479 | { |
---|
| 1480 | #if !SPS_AMVP_CLEANUP |
---|
| 1481 | // AMVP parameter |
---|
| 1482 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
| 1483 | #endif |
---|
| 1484 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 1485 | { |
---|
| 1486 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1487 | m_uiMaxDecPicBuffering[i] = 0; |
---|
| 1488 | m_numReorderPics[i] = 0; |
---|
| 1489 | } |
---|
| 1490 | m_scalingList = new TComScalingList; |
---|
| 1491 | #if LTRP_IN_SPS |
---|
| 1492 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 1493 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
| 1494 | #endif |
---|
| 1495 | } |
---|
| 1496 | |
---|
| 1497 | TComSPS::~TComSPS() |
---|
| 1498 | { |
---|
| 1499 | delete m_scalingList; |
---|
| 1500 | m_RPSList.destroy(); |
---|
| 1501 | } |
---|
| 1502 | |
---|
| 1503 | Void TComSPS::createRPSList( Int numRPS ) |
---|
| 1504 | { |
---|
| 1505 | m_RPSList.destroy(); |
---|
| 1506 | m_RPSList.create(numRPS); |
---|
| 1507 | } |
---|
| 1508 | #if BUFFERING_PERIOD_AND_TIMING_SEI |
---|
| 1509 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
| 1510 | { |
---|
| 1511 | if( !getVuiParametersPresentFlag() ) |
---|
| 1512 | { |
---|
| 1513 | return; |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | TComVUI *vui = getVuiParameters(); |
---|
| 1517 | |
---|
| 1518 | vui->setTimingInfoPresentFlag( true ); |
---|
| 1519 | switch( frameRate ) |
---|
| 1520 | { |
---|
| 1521 | case 24: |
---|
| 1522 | vui->setNumUnitsInTick( 1125000 ); vui->setTimeScale ( 27000000 ); |
---|
| 1523 | break; |
---|
| 1524 | case 25: |
---|
| 1525 | vui->setNumUnitsInTick( 1080000 ); vui->setTimeScale ( 27000000 ); |
---|
| 1526 | break; |
---|
| 1527 | case 30: |
---|
| 1528 | vui->setNumUnitsInTick( 900900 ); vui->setTimeScale ( 27000000 ); |
---|
| 1529 | break; |
---|
| 1530 | case 50: |
---|
| 1531 | vui->setNumUnitsInTick( 540000 ); vui->setTimeScale ( 27000000 ); |
---|
| 1532 | break; |
---|
| 1533 | case 60: |
---|
| 1534 | vui->setNumUnitsInTick( 450450 ); vui->setTimeScale ( 27000000 ); |
---|
| 1535 | break; |
---|
| 1536 | default: |
---|
| 1537 | vui->setNumUnitsInTick( 1001 ); vui->setTimeScale ( 60000 ); |
---|
| 1538 | break; |
---|
| 1539 | } |
---|
| 1540 | |
---|
| 1541 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 1542 | vui->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 1543 | vui->setVclHrdParametersPresentFlag( rateCnt ); |
---|
| 1544 | |
---|
| 1545 | vui->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
| 1546 | |
---|
| 1547 | if( vui->getSubPicCpbParamsPresentFlag() ) |
---|
| 1548 | { |
---|
| 1549 | vui->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 1550 | vui->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 1551 | } |
---|
| 1552 | |
---|
| 1553 | vui->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
| 1554 | vui->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 1555 | |
---|
| 1556 | vui->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 1557 | if( randomAccess ) |
---|
| 1558 | { |
---|
| 1559 | vui->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 1560 | vui->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 1561 | } |
---|
| 1562 | else |
---|
| 1563 | { |
---|
| 1564 | vui->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 1565 | vui->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 1566 | } |
---|
| 1567 | |
---|
| 1568 | /* |
---|
| 1569 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
| 1570 | */ |
---|
| 1571 | Int i, j; |
---|
| 1572 | UInt birateValue, cpbSizeValue; |
---|
| 1573 | |
---|
| 1574 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
| 1575 | { |
---|
| 1576 | vui->setFixedPicRateFlag( i, 1 ); |
---|
| 1577 | vui->setPicDurationInTcMinus1( i, 0 ); |
---|
| 1578 | vui->setLowDelayHrdFlag( i, 0 ); |
---|
| 1579 | vui->setCpbCntMinus1( i, 0 ); |
---|
| 1580 | |
---|
| 1581 | birateValue = bitRate; |
---|
| 1582 | cpbSizeValue = bitRate; // 1 second |
---|
| 1583 | for( j = 0; j < ( vui->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
| 1584 | { |
---|
| 1585 | vui->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
| 1586 | vui->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 1587 | vui->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
| 1588 | |
---|
| 1589 | vui->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
| 1590 | vui->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 1591 | vui->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
| 1592 | } |
---|
| 1593 | } |
---|
| 1594 | } |
---|
| 1595 | #endif |
---|
| 1596 | const Int TComSPS::m_cropUnitX[]={1,2,2,1}; |
---|
| 1597 | const Int TComSPS::m_cropUnitY[]={1,2,1,1}; |
---|
| 1598 | |
---|
| 1599 | TComPPS::TComPPS() |
---|
| 1600 | : m_PPSId (0) |
---|
| 1601 | , m_SPSId (0) |
---|
| 1602 | , m_picInitQPMinus26 (0) |
---|
| 1603 | , m_useDQP (false) |
---|
| 1604 | , m_bConstrainedIntraPred (false) |
---|
| 1605 | #if CHROMA_QP_EXTENSION |
---|
| 1606 | , m_bSliceChromaQpFlag (false) |
---|
| 1607 | #endif |
---|
| 1608 | , m_pcSPS (NULL) |
---|
| 1609 | , m_uiMaxCuDQPDepth (0) |
---|
| 1610 | , m_uiMinCuDQPSize (0) |
---|
| 1611 | , m_chromaCbQpOffset (0) |
---|
| 1612 | , m_chromaCrQpOffset (0) |
---|
| 1613 | , m_numRefIdxL0DefaultActive (1) |
---|
| 1614 | , m_numRefIdxL1DefaultActive (1) |
---|
| 1615 | #if !REMOVE_FGS |
---|
| 1616 | , m_iSliceGranularity (0) |
---|
| 1617 | #endif |
---|
| 1618 | , m_TransquantBypassEnableFlag (false) |
---|
| 1619 | #if PPS_TS_FLAG |
---|
| 1620 | , m_useTransformSkip (false) |
---|
| 1621 | #endif |
---|
| 1622 | #if TILES_WPP_ENTROPYSLICES_FLAGS |
---|
| 1623 | , m_dependentSliceEnabledFlag (false) |
---|
| 1624 | , m_tilesEnabledFlag (false) |
---|
| 1625 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 1626 | , m_entropySliceEnabledFlag (false) |
---|
| 1627 | #endif |
---|
| 1628 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 1629 | , m_uniformSpacingFlag (0) |
---|
| 1630 | , m_iNumColumnsMinus1 (0) |
---|
| 1631 | , m_puiColumnWidth (NULL) |
---|
| 1632 | , m_iNumRowsMinus1 (0) |
---|
| 1633 | , m_puiRowHeight (NULL) |
---|
| 1634 | , m_iNumSubstreams (1) |
---|
| 1635 | , m_signHideFlag(0) |
---|
| 1636 | , m_cabacInitPresentFlag (false) |
---|
| 1637 | , m_encCABACTableIdx (I_SLICE) |
---|
| 1638 | #if SLICE_HEADER_EXTENSION |
---|
| 1639 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 1640 | #endif |
---|
| 1641 | #if MOVE_LOOP_FILTER_SLICES_FLAG |
---|
| 1642 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
| 1643 | #endif |
---|
| 1644 | { |
---|
| 1645 | m_scalingList = new TComScalingList; |
---|
| 1646 | #if !TILES_WPP_ENTROPYSLICES_FLAGS |
---|
| 1647 | #if DEPENDENT_SLICES |
---|
| 1648 | m_bDependentSliceEnabledFlag = false; |
---|
| 1649 | m_bCabacIndependentFlag = false; |
---|
| 1650 | #endif |
---|
| 1651 | #endif |
---|
| 1652 | } |
---|
| 1653 | |
---|
| 1654 | TComPPS::~TComPPS() |
---|
| 1655 | { |
---|
| 1656 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 1657 | { |
---|
| 1658 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
| 1659 | m_puiColumnWidth = NULL; |
---|
| 1660 | } |
---|
| 1661 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 1662 | { |
---|
| 1663 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
| 1664 | m_puiRowHeight = NULL; |
---|
| 1665 | } |
---|
| 1666 | delete m_scalingList; |
---|
| 1667 | } |
---|
| 1668 | |
---|
| 1669 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 1670 | : m_numberOfPictures (0) |
---|
| 1671 | , m_numberOfNegativePictures (0) |
---|
| 1672 | , m_numberOfPositivePictures (0) |
---|
| 1673 | , m_numberOfLongtermPictures (0) |
---|
| 1674 | , m_interRPSPrediction (0) |
---|
| 1675 | , m_deltaRIdxMinus1 (0) |
---|
| 1676 | , m_deltaRPS (0) |
---|
| 1677 | , m_numRefIdc (0) |
---|
| 1678 | { |
---|
| 1679 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 1680 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 1681 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 1682 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
| 1683 | } |
---|
| 1684 | |
---|
| 1685 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 1686 | { |
---|
| 1687 | } |
---|
| 1688 | |
---|
| 1689 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 1690 | { |
---|
| 1691 | m_used[bufferNum] = used; |
---|
| 1692 | } |
---|
| 1693 | |
---|
| 1694 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 1695 | { |
---|
| 1696 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 1697 | } |
---|
| 1698 | |
---|
| 1699 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 1700 | { |
---|
| 1701 | m_numberOfPictures = numberOfPictures; |
---|
| 1702 | } |
---|
| 1703 | |
---|
| 1704 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
| 1705 | { |
---|
| 1706 | return m_used[bufferNum]; |
---|
| 1707 | } |
---|
| 1708 | |
---|
| 1709 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
| 1710 | { |
---|
| 1711 | return m_deltaPOC[bufferNum]; |
---|
| 1712 | } |
---|
| 1713 | |
---|
| 1714 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
| 1715 | { |
---|
| 1716 | return m_numberOfPictures; |
---|
| 1717 | } |
---|
| 1718 | |
---|
| 1719 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
| 1720 | { |
---|
| 1721 | return m_POC[bufferNum]; |
---|
| 1722 | } |
---|
| 1723 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 1724 | { |
---|
| 1725 | m_POC[bufferNum] = POC; |
---|
| 1726 | } |
---|
| 1727 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
| 1728 | { |
---|
| 1729 | return m_bCheckLTMSB[bufferNum]; |
---|
| 1730 | } |
---|
| 1731 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 1732 | { |
---|
| 1733 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 1734 | } |
---|
| 1735 | |
---|
| 1736 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
| 1737 | * \param uiBufferNum |
---|
| 1738 | * \param iRefIdc |
---|
| 1739 | * \returns Void |
---|
| 1740 | */ |
---|
| 1741 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 1742 | { |
---|
| 1743 | m_refIdc[bufferNum] = refIdc; |
---|
| 1744 | } |
---|
| 1745 | |
---|
| 1746 | /** get the reference idc value at uiBufferNum |
---|
| 1747 | * \param uiBufferNum |
---|
| 1748 | * \returns Int |
---|
| 1749 | */ |
---|
| 1750 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
| 1751 | { |
---|
| 1752 | return m_refIdc[bufferNum]; |
---|
| 1753 | } |
---|
| 1754 | |
---|
| 1755 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 1756 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 1757 | * +ve values are in increasing order. |
---|
| 1758 | * \returns Void |
---|
| 1759 | */ |
---|
| 1760 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 1761 | { |
---|
| 1762 | // sort in increasing order (smallest first) |
---|
| 1763 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
| 1764 | { |
---|
| 1765 | Int deltaPOC = getDeltaPOC(j); |
---|
| 1766 | Bool used = getUsed(j); |
---|
| 1767 | for (Int k=j-1; k >= 0; k--) |
---|
| 1768 | { |
---|
| 1769 | Int temp = getDeltaPOC(k); |
---|
| 1770 | if (deltaPOC < temp) |
---|
| 1771 | { |
---|
| 1772 | setDeltaPOC(k+1, temp); |
---|
| 1773 | setUsed(k+1, getUsed(k)); |
---|
| 1774 | setDeltaPOC(k, deltaPOC); |
---|
| 1775 | setUsed(k, used); |
---|
| 1776 | } |
---|
| 1777 | } |
---|
| 1778 | } |
---|
| 1779 | // flip the negative values to largest first |
---|
| 1780 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 1781 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
| 1782 | { |
---|
| 1783 | Int deltaPOC = getDeltaPOC(j); |
---|
| 1784 | Bool used = getUsed(j); |
---|
| 1785 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 1786 | setUsed(j, getUsed(k)); |
---|
| 1787 | setDeltaPOC(k, deltaPOC); |
---|
| 1788 | setUsed(k, used); |
---|
| 1789 | } |
---|
| 1790 | } |
---|
| 1791 | |
---|
| 1792 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 1793 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 1794 | * \returns Void |
---|
| 1795 | */ |
---|
| 1796 | Void TComReferencePictureSet::printDeltaPOC() |
---|
| 1797 | { |
---|
| 1798 | printf("DeltaPOC = { "); |
---|
| 1799 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 1800 | { |
---|
| 1801 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
| 1802 | } |
---|
| 1803 | if (getInterRPSPrediction()) |
---|
| 1804 | { |
---|
| 1805 | printf("}, RefIdc = { "); |
---|
| 1806 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 1807 | { |
---|
| 1808 | printf("%d ", getRefIdc(j)); |
---|
| 1809 | } |
---|
| 1810 | } |
---|
| 1811 | printf("}\n"); |
---|
| 1812 | } |
---|
| 1813 | |
---|
| 1814 | TComRPSList::TComRPSList() |
---|
| 1815 | :m_referencePictureSets (NULL) |
---|
| 1816 | { |
---|
| 1817 | } |
---|
| 1818 | |
---|
| 1819 | TComRPSList::~TComRPSList() |
---|
| 1820 | { |
---|
| 1821 | } |
---|
| 1822 | |
---|
| 1823 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
| 1824 | { |
---|
| 1825 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 1826 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
| 1827 | } |
---|
| 1828 | |
---|
| 1829 | Void TComRPSList::destroy() |
---|
| 1830 | { |
---|
| 1831 | if (m_referencePictureSets) |
---|
| 1832 | { |
---|
| 1833 | delete [] m_referencePictureSets; |
---|
| 1834 | } |
---|
| 1835 | m_numberOfReferencePictureSets = 0; |
---|
| 1836 | m_referencePictureSets = NULL; |
---|
| 1837 | } |
---|
| 1838 | |
---|
| 1839 | |
---|
| 1840 | |
---|
| 1841 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
| 1842 | { |
---|
| 1843 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
| 1844 | } |
---|
| 1845 | |
---|
| 1846 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
| 1847 | { |
---|
| 1848 | return m_numberOfReferencePictureSets; |
---|
| 1849 | } |
---|
| 1850 | |
---|
| 1851 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
| 1852 | { |
---|
| 1853 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 1854 | } |
---|
| 1855 | |
---|
| 1856 | TComRefPicListModification::TComRefPicListModification() |
---|
| 1857 | : m_bRefPicListModificationFlagL0 (false) |
---|
| 1858 | , m_bRefPicListModificationFlagL1 (false) |
---|
| 1859 | { |
---|
| 1860 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 1861 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 1862 | } |
---|
| 1863 | |
---|
| 1864 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 1865 | { |
---|
| 1866 | } |
---|
| 1867 | |
---|
| 1868 | #if !REMOVE_APS |
---|
| 1869 | TComAPS::TComAPS() |
---|
| 1870 | { |
---|
| 1871 | m_apsID = 0; |
---|
| 1872 | m_pSaoParam = NULL; |
---|
| 1873 | #if !REMOVE_ALF |
---|
| 1874 | m_alfParam[0] = m_alfParam[1] = m_alfParam[2] = NULL; |
---|
| 1875 | #endif |
---|
| 1876 | } |
---|
| 1877 | |
---|
| 1878 | TComAPS::~TComAPS() |
---|
| 1879 | { |
---|
| 1880 | delete m_pSaoParam; |
---|
| 1881 | #if !REMOVE_ALF |
---|
| 1882 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
| 1883 | { |
---|
| 1884 | delete m_alfParam[compIdx]; |
---|
| 1885 | m_alfParam[compIdx] = NULL; |
---|
| 1886 | } |
---|
| 1887 | #endif |
---|
| 1888 | } |
---|
| 1889 | |
---|
| 1890 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
| 1891 | { |
---|
| 1892 | m_apsID = src.m_apsID; |
---|
| 1893 | m_pSaoParam = src.m_pSaoParam; |
---|
| 1894 | #if !REMOVE_ALF |
---|
| 1895 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
| 1896 | { |
---|
| 1897 | m_alfParam[compIdx] = src.m_alfParam[compIdx]; |
---|
| 1898 | } |
---|
| 1899 | #endif |
---|
| 1900 | return *this; |
---|
| 1901 | } |
---|
| 1902 | |
---|
| 1903 | Void TComAPS::createSaoParam() |
---|
| 1904 | { |
---|
| 1905 | m_pSaoParam = new SAOParam; |
---|
| 1906 | } |
---|
| 1907 | |
---|
| 1908 | Void TComAPS::destroySaoParam() |
---|
| 1909 | { |
---|
| 1910 | if(m_pSaoParam != NULL) |
---|
| 1911 | { |
---|
| 1912 | delete m_pSaoParam; |
---|
| 1913 | m_pSaoParam = NULL; |
---|
| 1914 | } |
---|
| 1915 | } |
---|
| 1916 | |
---|
| 1917 | #if !REMOVE_ALF |
---|
| 1918 | Void TComAPS::createAlfParam() |
---|
| 1919 | { |
---|
| 1920 | for(Int compIdx =0; compIdx < 3; compIdx++) |
---|
| 1921 | { |
---|
| 1922 | m_alfParam[compIdx] = new ALFParam(compIdx); |
---|
| 1923 | m_alfParam[compIdx]->alf_flag = 0; |
---|
| 1924 | } |
---|
| 1925 | } |
---|
| 1926 | Void TComAPS::destroyAlfParam() |
---|
| 1927 | { |
---|
| 1928 | for(Int compIdx=0; compIdx < 3; compIdx++) |
---|
| 1929 | { |
---|
| 1930 | if(m_alfParam[compIdx] != NULL) |
---|
| 1931 | { |
---|
| 1932 | delete m_alfParam[compIdx]; |
---|
| 1933 | m_alfParam[compIdx] = NULL; |
---|
| 1934 | } |
---|
| 1935 | } |
---|
| 1936 | } |
---|
| 1937 | #endif |
---|
| 1938 | #endif |
---|
| 1939 | |
---|
| 1940 | TComScalingList::TComScalingList() |
---|
| 1941 | { |
---|
| 1942 | #if TS_FLAT_QUANTIZATION_MATRIX |
---|
| 1943 | m_useTransformSkip = false; |
---|
| 1944 | #endif |
---|
| 1945 | init(); |
---|
| 1946 | } |
---|
| 1947 | TComScalingList::~TComScalingList() |
---|
| 1948 | { |
---|
| 1949 | destroy(); |
---|
| 1950 | } |
---|
| 1951 | |
---|
| 1952 | /** set default quantization matrix to array |
---|
| 1953 | */ |
---|
| 1954 | Void TComSlice::setDefaultScalingList() |
---|
| 1955 | { |
---|
| 1956 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 1957 | { |
---|
| 1958 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 1959 | { |
---|
| 1960 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
| 1961 | } |
---|
| 1962 | } |
---|
| 1963 | } |
---|
| 1964 | /** check if use default quantization matrix |
---|
| 1965 | * \returns true if use default quantization matrix in all size |
---|
| 1966 | */ |
---|
| 1967 | Bool TComSlice::checkDefaultScalingList() |
---|
| 1968 | { |
---|
| 1969 | UInt defaultCounter=0; |
---|
| 1970 | |
---|
| 1971 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 1972 | { |
---|
| 1973 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 1974 | { |
---|
| 1975 | 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 |
---|
| 1976 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
| 1977 | { |
---|
| 1978 | defaultCounter++; |
---|
| 1979 | } |
---|
| 1980 | } |
---|
| 1981 | } |
---|
| 1982 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
| 1983 | } |
---|
| 1984 | /** get scaling matrix from RefMatrixID |
---|
| 1985 | * \param sizeId size index |
---|
| 1986 | * \param Index of input matrix |
---|
| 1987 | * \param Index of reference matrix |
---|
| 1988 | */ |
---|
| 1989 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 1990 | { |
---|
| 1991 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 1992 | } |
---|
| 1993 | /** parse syntax infomation |
---|
| 1994 | * \param pchFile syntax infomation |
---|
| 1995 | * \returns false if successful |
---|
| 1996 | */ |
---|
| 1997 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
| 1998 | { |
---|
| 1999 | FILE *fp; |
---|
| 2000 | Char line[1024]; |
---|
| 2001 | UInt sizeIdc,listIdc; |
---|
| 2002 | UInt i,size = 0; |
---|
| 2003 | Int *src=0,data; |
---|
| 2004 | Char *ret; |
---|
| 2005 | UInt retval; |
---|
| 2006 | |
---|
| 2007 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
| 2008 | { |
---|
| 2009 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
| 2010 | return true; |
---|
| 2011 | } |
---|
| 2012 | |
---|
| 2013 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2014 | { |
---|
| 2015 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 2016 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
| 2017 | { |
---|
| 2018 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 2019 | |
---|
| 2020 | fseek(fp,0,0); |
---|
| 2021 | do |
---|
| 2022 | { |
---|
| 2023 | ret = fgets(line, 1024, fp); |
---|
| 2024 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2025 | { |
---|
| 2026 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2027 | return true; |
---|
| 2028 | } |
---|
| 2029 | } |
---|
| 2030 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
| 2031 | for (i=0; i<size; i++) |
---|
| 2032 | { |
---|
| 2033 | retval = fscanf(fp, "%d,", &data); |
---|
| 2034 | if (retval!=1) |
---|
| 2035 | { |
---|
| 2036 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2037 | return true; |
---|
| 2038 | } |
---|
| 2039 | src[i] = data; |
---|
| 2040 | } |
---|
| 2041 | //set DC value for default matrix check |
---|
| 2042 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 2043 | |
---|
| 2044 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 2045 | { |
---|
| 2046 | fseek(fp,0,0); |
---|
| 2047 | do |
---|
| 2048 | { |
---|
| 2049 | ret = fgets(line, 1024, fp); |
---|
| 2050 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2051 | { |
---|
| 2052 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
| 2053 | return true; |
---|
| 2054 | } |
---|
| 2055 | } |
---|
| 2056 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
| 2057 | retval = fscanf(fp, "%d,", &data); |
---|
| 2058 | if (retval!=1) |
---|
| 2059 | { |
---|
| 2060 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2061 | return true; |
---|
| 2062 | } |
---|
| 2063 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 2064 | setScalingListDC(sizeIdc,listIdc,data); |
---|
| 2065 | } |
---|
| 2066 | } |
---|
| 2067 | } |
---|
| 2068 | fclose(fp); |
---|
| 2069 | return false; |
---|
| 2070 | } |
---|
| 2071 | |
---|
| 2072 | /** initialization process of quantization matrix array |
---|
| 2073 | */ |
---|
| 2074 | Void TComScalingList::init() |
---|
| 2075 | { |
---|
| 2076 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2077 | { |
---|
| 2078 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2079 | { |
---|
| 2080 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
| 2081 | } |
---|
| 2082 | } |
---|
| 2083 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
| 2084 | } |
---|
| 2085 | /** destroy quantization matrix array |
---|
| 2086 | */ |
---|
| 2087 | Void TComScalingList::destroy() |
---|
| 2088 | { |
---|
| 2089 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2090 | { |
---|
| 2091 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2092 | { |
---|
| 2093 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
| 2094 | } |
---|
| 2095 | } |
---|
| 2096 | } |
---|
| 2097 | /** get default address of quantization matrix |
---|
| 2098 | * \param sizeId size index |
---|
| 2099 | * \param listId list index |
---|
| 2100 | * \returns pointer of quantization matrix |
---|
| 2101 | */ |
---|
| 2102 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
| 2103 | { |
---|
| 2104 | Int *src = 0; |
---|
| 2105 | switch(sizeId) |
---|
| 2106 | { |
---|
| 2107 | case SCALING_LIST_4x4: |
---|
| 2108 | #if TS_FLAT_QUANTIZATION_MATRIX |
---|
| 2109 | if( m_useTransformSkip ) |
---|
| 2110 | { |
---|
| 2111 | src = g_quantTSDefault4x4; |
---|
| 2112 | } |
---|
| 2113 | else |
---|
| 2114 | { |
---|
| 2115 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
| 2116 | } |
---|
| 2117 | #else |
---|
| 2118 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
| 2119 | #endif |
---|
| 2120 | break; |
---|
| 2121 | case SCALING_LIST_8x8: |
---|
| 2122 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2123 | break; |
---|
| 2124 | case SCALING_LIST_16x16: |
---|
| 2125 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2126 | break; |
---|
| 2127 | case SCALING_LIST_32x32: |
---|
| 2128 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2129 | break; |
---|
| 2130 | default: |
---|
| 2131 | assert(0); |
---|
| 2132 | src = NULL; |
---|
| 2133 | break; |
---|
| 2134 | } |
---|
| 2135 | return src; |
---|
| 2136 | } |
---|
| 2137 | /** process of default matrix |
---|
| 2138 | * \param sizeId size index |
---|
| 2139 | * \param Index of input matrix |
---|
| 2140 | */ |
---|
| 2141 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
| 2142 | { |
---|
| 2143 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2144 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 2145 | } |
---|
| 2146 | /** check DC value of matrix for default matrix signaling |
---|
| 2147 | */ |
---|
| 2148 | Void TComScalingList::checkDcOfMatrix() |
---|
| 2149 | { |
---|
| 2150 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2151 | { |
---|
| 2152 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2153 | { |
---|
| 2154 | //check default matrix? |
---|
| 2155 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 2156 | { |
---|
| 2157 | processDefaultMarix(sizeId, listId); |
---|
| 2158 | } |
---|
| 2159 | } |
---|
| 2160 | } |
---|
| 2161 | } |
---|
| 2162 | |
---|
| 2163 | ParameterSetManager::ParameterSetManager() |
---|
| 2164 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 2165 | , m_spsMap(MAX_NUM_SPS) |
---|
| 2166 | , m_ppsMap(MAX_NUM_PPS) |
---|
| 2167 | #if !REMOVE_APS |
---|
| 2168 | , m_apsMap(MAX_NUM_APS) |
---|
| 2169 | #endif |
---|
| 2170 | { |
---|
| 2171 | } |
---|
| 2172 | |
---|
| 2173 | |
---|
| 2174 | ParameterSetManager::~ParameterSetManager() |
---|
| 2175 | { |
---|
| 2176 | } |
---|
| 2177 | |
---|
| 2178 | #if PROFILE_TIER_LEVEL_SYNTAX |
---|
| 2179 | ProfileTierLevel::ProfileTierLevel() |
---|
| 2180 | : m_profileSpace (0) |
---|
| 2181 | , m_tierFlag (false) |
---|
| 2182 | , m_profileIdc (0) |
---|
| 2183 | , m_levelIdc (0) |
---|
| 2184 | { |
---|
| 2185 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 2186 | } |
---|
| 2187 | TComPTL::TComPTL() |
---|
| 2188 | { |
---|
| 2189 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 2190 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 2191 | } |
---|
| 2192 | #endif |
---|
| 2193 | //! \} |
---|