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