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