[61] | 1 | /* The copyright in this software is being made available under the BSD |
---|
[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | |
---|
[2] | 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 | |
---|
[56] | 42 | //! \ingroup TLibCommon |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
[2] | 45 | TComSlice::TComSlice() |
---|
[210] | 46 | #if QC_MVHEVC_B0046 |
---|
| 47 | : m_iPPSId ( 0 ) |
---|
| 48 | #else |
---|
[56] | 49 | : m_iPPSId ( -1 ) |
---|
[210] | 50 | #endif |
---|
[56] | 51 | , m_iPOC ( 0 ) |
---|
| 52 | , m_iLastIDR ( 0 ) |
---|
| 53 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR ) |
---|
| 54 | , m_eNalUnitTypeBaseViewMvc ( NAL_UNIT_INVALID ) |
---|
| 55 | , m_eSliceType ( I_SLICE ) |
---|
| 56 | , m_iSliceQp ( 0 ) |
---|
| 57 | #if ADAPTIVE_QP_SELECTION |
---|
| 58 | , m_iSliceQpBase ( 0 ) |
---|
[2] | 59 | #endif |
---|
[56] | 60 | , m_bLoopFilterDisable ( false ) |
---|
| 61 | , m_inheritDblParamFromAPS ( true ) |
---|
| 62 | , m_loopFilterBetaOffsetDiv2 ( 0 ) |
---|
| 63 | , m_loopFilterTcOffsetDiv2 ( 0 ) |
---|
| 64 | , m_bRefPicListModificationFlagLC ( false ) |
---|
| 65 | , m_bRefPicListCombinationFlag ( false ) |
---|
| 66 | , m_bCheckLDC ( false ) |
---|
| 67 | , m_iSliceQpDelta ( 0 ) |
---|
| 68 | , m_pcTexturePic ( NULL ) |
---|
| 69 | , m_iDepth ( 0 ) |
---|
| 70 | , m_bRefenced ( false ) |
---|
| 71 | , m_pcSPS ( NULL ) |
---|
| 72 | , m_pcPPS ( NULL ) |
---|
| 73 | , m_pcPic ( NULL ) |
---|
| 74 | , m_uiColDir ( 0 ) |
---|
| 75 | #if COLLOCATED_REF_IDX |
---|
| 76 | , m_colRefIdx ( 0 ) |
---|
[42] | 77 | #endif |
---|
[56] | 78 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
| 79 | , m_dLambdaLuma( 0.0 ) |
---|
| 80 | , m_dLambdaChroma( 0.0 ) |
---|
| 81 | #else |
---|
| 82 | , m_dLambda ( 0.0 ) |
---|
| 83 | #endif |
---|
| 84 | , m_bNoBackPredFlag ( false ) |
---|
| 85 | , m_bRefIdxCombineCoding ( false ) |
---|
| 86 | , m_uiTLayer ( 0 ) |
---|
| 87 | , m_bTLayerSwitchingFlag ( false ) |
---|
| 88 | , m_uiSliceMode ( 0 ) |
---|
| 89 | , m_uiSliceArgument ( 0 ) |
---|
| 90 | , m_uiSliceCurStartCUAddr ( 0 ) |
---|
| 91 | , m_uiSliceCurEndCUAddr ( 0 ) |
---|
| 92 | , m_uiSliceIdx ( 0 ) |
---|
| 93 | , m_uiEntropySliceMode ( 0 ) |
---|
| 94 | , m_uiEntropySliceArgument ( 0 ) |
---|
| 95 | , m_uiEntropySliceCurStartCUAddr ( 0 ) |
---|
| 96 | , m_uiEntropySliceCurEndCUAddr ( 0 ) |
---|
| 97 | , m_bNextSlice ( false ) |
---|
| 98 | , m_bNextEntropySlice ( false ) |
---|
| 99 | , m_uiSliceBits ( 0 ) |
---|
| 100 | , m_uiEntropySliceCounter ( 0 ) |
---|
| 101 | , m_bFinalized ( false ) |
---|
| 102 | , m_uiTileByteLocation ( NULL ) |
---|
| 103 | , m_uiTileCount ( 0 ) |
---|
| 104 | , m_iTileMarkerFlag ( 0 ) |
---|
| 105 | , m_uiTileOffstForMultES ( 0 ) |
---|
| 106 | , m_puiSubstreamSizes ( NULL ) |
---|
| 107 | #if CABAC_INIT_FLAG |
---|
| 108 | , m_cabacInitFlag ( false ) |
---|
| 109 | #else |
---|
| 110 | , m_cabacInitIdc ( -1 ) |
---|
| 111 | #endif |
---|
| 112 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 113 | , m_numEntryPointOffsets ( 0 ) |
---|
| 114 | #endif |
---|
[21] | 115 | #if SONY_COLPIC_AVAILABILITY |
---|
[56] | 116 | , m_iViewOrderIdx ( 0 ) |
---|
[21] | 117 | #endif |
---|
[189] | 118 | #if LGE_ILLUCOMP_B0045 |
---|
| 119 | , m_bApplyIC ( false ) |
---|
| 120 | #endif |
---|
[56] | 121 | { |
---|
| 122 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0; |
---|
| 123 | |
---|
[2] | 124 | initEqualRef(); |
---|
[56] | 125 | |
---|
| 126 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
| 127 | { |
---|
| 128 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
| 129 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
| 130 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
| 131 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
| 132 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
| 133 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
| 134 | } |
---|
| 135 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF+1; iNumCount++) |
---|
| 136 | { |
---|
| 137 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
| 138 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
| 139 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
| 140 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
| 141 | m_aiRefViewIdList[0][iNumCount] = 0; |
---|
| 142 | m_aiRefViewIdList[1][iNumCount] = 0; |
---|
| 143 | } |
---|
| 144 | m_bCombineWithReferenceFlag = 0; |
---|
[2] | 145 | resetWpScaling(m_weightPredTable); |
---|
[56] | 146 | resetWpScalingLC(m_weightPredTableLC); |
---|
[2] | 147 | initWpAcDcParam(); |
---|
[210] | 148 | #if QC_IV_AS_LT_B0046 |
---|
| 149 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF+1; iNumCount++) |
---|
| 150 | { |
---|
| 151 | m_bWasLongTerm[0][iNumCount] = false; |
---|
| 152 | m_bWasLongTerm[1][iNumCount] = false; |
---|
| 153 | } |
---|
| 154 | #endif |
---|
[2] | 155 | } |
---|
| 156 | |
---|
| 157 | TComSlice::~TComSlice() |
---|
| 158 | { |
---|
[56] | 159 | if (m_uiTileByteLocation) |
---|
| 160 | { |
---|
| 161 | delete [] m_uiTileByteLocation; |
---|
| 162 | m_uiTileByteLocation = NULL; |
---|
| 163 | } |
---|
| 164 | delete[] m_puiSubstreamSizes; |
---|
| 165 | m_puiSubstreamSizes = NULL; |
---|
[2] | 166 | } |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | Void TComSlice::initSlice() |
---|
| 170 | { |
---|
| 171 | m_aiNumRefIdx[0] = 0; |
---|
| 172 | m_aiNumRefIdx[1] = 0; |
---|
[5] | 173 | |
---|
[2] | 174 | m_uiColDir = 0; |
---|
[56] | 175 | |
---|
| 176 | #if COLLOCATED_REF_IDX |
---|
| 177 | m_colRefIdx = 0; |
---|
| 178 | #endif |
---|
| 179 | m_pcTexturePic = NULL; |
---|
[2] | 180 | |
---|
| 181 | initEqualRef(); |
---|
| 182 | m_bNoBackPredFlag = false; |
---|
| 183 | m_bRefIdxCombineCoding = false; |
---|
| 184 | m_bRefPicListCombinationFlag = false; |
---|
| 185 | m_bRefPicListModificationFlagLC = false; |
---|
[56] | 186 | m_bCheckLDC = false; |
---|
| 187 | |
---|
| 188 | m_aiNumRefIdx[REF_PIC_LIST_C] = 0; |
---|
| 189 | |
---|
| 190 | m_uiMaxNumMergeCand = MRG_MAX_NUM_CANDS_SIGNALED; |
---|
| 191 | |
---|
| 192 | m_bFinalized=false; |
---|
| 193 | |
---|
| 194 | m_uiTileCount = 0; |
---|
| 195 | #if CABAC_INIT_FLAG |
---|
| 196 | m_cabacInitFlag = false; |
---|
[2] | 197 | #endif |
---|
[56] | 198 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 199 | m_numEntryPointOffsets = 0; |
---|
| 200 | #endif |
---|
[237] | 201 | #if QC_TMVP_MRG_REFIDX_C0047 |
---|
| 202 | m_aiNewRefIdx[0] = -1; |
---|
| 203 | m_aiNewRefIdx[1] = -1; |
---|
| 204 | #endif |
---|
[2] | 205 | } |
---|
| 206 | |
---|
[56] | 207 | Void TComSlice::initTiles() |
---|
| 208 | { |
---|
| 209 | Int iWidth = m_pcSPS->getPicWidthInLumaSamples(); |
---|
| 210 | Int iHeight = m_pcSPS->getPicHeightInLumaSamples(); |
---|
| 211 | UInt uiWidthInCU = ( iWidth %g_uiMaxCUWidth ) ? iWidth /g_uiMaxCUWidth + 1 : iWidth /g_uiMaxCUWidth; |
---|
| 212 | UInt uiHeightInCU = ( iHeight%g_uiMaxCUHeight ) ? iHeight/g_uiMaxCUHeight + 1 : iHeight/g_uiMaxCUHeight; |
---|
| 213 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
| 214 | |
---|
| 215 | if (m_uiTileByteLocation==NULL) m_uiTileByteLocation = new UInt[uiNumCUsInFrame]; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | /** |
---|
| 220 | - allocate table to contain substream sizes to be written to the slice header. |
---|
| 221 | . |
---|
| 222 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
| 223 | */ |
---|
| 224 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
| 225 | { |
---|
| 226 | delete[] m_puiSubstreamSizes; |
---|
| 227 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
| 228 | } |
---|
| 229 | |
---|
[2] | 230 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
| 231 | { |
---|
| 232 | TComPic* pcPicExtract; |
---|
| 233 | TComPic* pcPicInsert; |
---|
[5] | 234 | |
---|
[2] | 235 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 236 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 237 | TComList<TComPic*>::iterator iterPicInsert; |
---|
[5] | 238 | |
---|
[2] | 239 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 240 | { |
---|
| 241 | iterPicExtract = rcListPic.begin(); |
---|
| 242 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
| 243 | pcPicExtract = *(iterPicExtract); |
---|
| 244 | pcPicExtract->setCurrSliceIdx(0); |
---|
[5] | 245 | |
---|
[2] | 246 | iterPicInsert = rcListPic.begin(); |
---|
| 247 | while (iterPicInsert != iterPicExtract) |
---|
| 248 | { |
---|
| 249 | pcPicInsert = *(iterPicInsert); |
---|
| 250 | pcPicInsert->setCurrSliceIdx(0); |
---|
| 251 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
| 252 | { |
---|
| 253 | break; |
---|
| 254 | } |
---|
[5] | 255 | |
---|
[2] | 256 | iterPicInsert++; |
---|
| 257 | } |
---|
[5] | 258 | |
---|
[2] | 259 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
[5] | 260 | |
---|
[2] | 261 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 262 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 263 | rcListPic.erase (iterPicExtract); |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
[56] | 267 | TComPic* TComSlice::xGetRefPic( TComList<TComPic*>& rcListPic, UInt uiPOC ) |
---|
[2] | 268 | { |
---|
[56] | 269 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 270 | TComPic* pcPic = *(iterPic); |
---|
| 271 | while ( iterPic != rcListPic.end() ) |
---|
[2] | 272 | { |
---|
[56] | 273 | if(pcPic->getPOC() == uiPOC) |
---|
[2] | 274 | { |
---|
[56] | 275 | break; |
---|
[2] | 276 | } |
---|
[56] | 277 | iterPic++; |
---|
| 278 | pcPic = *(iterPic); |
---|
[2] | 279 | } |
---|
[56] | 280 | return pcPic; |
---|
| 281 | } |
---|
[2] | 282 | |
---|
[56] | 283 | |
---|
| 284 | TComPic* TComSlice::xGetLongTermRefPic( TComList<TComPic*>& rcListPic, UInt uiPOC ) |
---|
| 285 | { |
---|
| 286 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 287 | TComPic* pcPic = *(iterPic); |
---|
| 288 | TComPic* pcStPic = pcPic; |
---|
| 289 | while ( iterPic != rcListPic.end() ) |
---|
| 290 | { |
---|
| 291 | pcPic = *(iterPic); |
---|
| 292 | if(pcPic && (pcPic->getPOC()%(1<<getSPS()->getBitsForPOC())) == (uiPOC%(1<<getSPS()->getBitsForPOC()))) |
---|
| 293 | { |
---|
| 294 | if(pcPic->getIsLongTerm()) |
---|
| 295 | return pcPic; |
---|
| 296 | else |
---|
| 297 | pcStPic = pcPic; |
---|
| 298 | break; |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | iterPic++; |
---|
| 302 | } |
---|
| 303 | return pcStPic; |
---|
[2] | 304 | } |
---|
| 305 | |
---|
[56] | 306 | TComPic* TComSlice::xGetInterViewRefPic( std::vector<TComPic*>& rcListIvPic, UInt uiViewId ) |
---|
| 307 | { |
---|
| 308 | TComPic* pcPic = NULL; |
---|
| 309 | for( Int k = 0; k < rcListIvPic.size(); k++ ) |
---|
| 310 | { |
---|
| 311 | if( rcListIvPic[k]->getViewId() == uiViewId ) |
---|
| 312 | { |
---|
| 313 | pcPic = rcListIvPic[k]; |
---|
| 314 | break; |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | assert( pcPic != NULL ); |
---|
| 319 | return pcPic; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | Int TComSlice::getNumPocTotalCurr() |
---|
| 323 | { |
---|
| 324 | if( m_eSliceType == I_SLICE ) |
---|
| 325 | { |
---|
| 326 | return 0; |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | Int numPocTotalCurr = 0; |
---|
| 330 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++ ) |
---|
| 331 | { |
---|
| 332 | if(m_pcRPS->getUsed(i)) |
---|
| 333 | { |
---|
| 334 | numPocTotalCurr++; |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | return numPocTotalCurr; |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | Int TComSlice::getNumPocTotalCurrMvc() |
---|
| 342 | { |
---|
| 343 | if( m_eSliceType == I_SLICE ) |
---|
| 344 | { |
---|
| 345 | return 0; |
---|
| 346 | } |
---|
| 347 | return getNumPocTotalCurr() + m_pcSPS->getNumberOfUsableInterViewRefs(); |
---|
| 348 | } |
---|
| 349 | |
---|
| 350 | Void TComSlice::setRefPOCnViewListsMvc() |
---|
| 351 | { |
---|
| 352 | for(Int iDir = 0; iDir < 2; iDir++) |
---|
| 353 | { |
---|
| 354 | for(Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
| 355 | { |
---|
| 356 | m_aiRefPOCList [iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
| 357 | m_aiRefViewIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getViewId(); |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
[2] | 362 | Void TComSlice::generateCombinedList() |
---|
| 363 | { |
---|
| 364 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
| 365 | { |
---|
| 366 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
| 367 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
| 368 | { |
---|
| 369 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
| 370 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
| 371 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
| 372 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
| 373 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
| 374 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
| 378 | { |
---|
[56] | 379 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
| 380 | { |
---|
[2] | 381 | Bool bTempRefIdxInL2 = true; |
---|
| 382 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
| 383 | { |
---|
[56] | 384 | if( (m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
| 385 | (m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getViewId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewId()) ) |
---|
[2] | 386 | { |
---|
| 387 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
| 388 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
| 389 | bTempRefIdxInL2 = false; |
---|
| 390 | break; |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | if(bTempRefIdxInL2 == true) |
---|
[5] | 395 | { |
---|
[2] | 396 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
| 397 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
| 398 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
| 399 | } |
---|
| 400 | } |
---|
| 401 | |
---|
[56] | 402 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]) |
---|
| 403 | { |
---|
[2] | 404 | Bool bTempRefIdxInL2 = true; |
---|
| 405 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
| 406 | { |
---|
[56] | 407 | if( (m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
| 408 | (m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getViewId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewId()) ) |
---|
[2] | 409 | { |
---|
| 410 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
| 411 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
| 412 | bTempRefIdxInL2 = false; |
---|
| 413 | break; |
---|
| 414 | } |
---|
| 415 | } |
---|
| 416 | if(bTempRefIdxInL2 == true) |
---|
| 417 | { |
---|
| 418 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
| 419 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
| 420 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | } |
---|
[237] | 425 | #if QC_TMVP_MRG_REFIDX_C0047 |
---|
| 426 | Int iCurrPOC = this->getPOC(); |
---|
| 427 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )//just to get one updated ref idx for merge in each L0/L1 direction, if it is not avaialbe, it is still -1 |
---|
| 428 | { |
---|
| 429 | if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0) |
---|
| 430 | continue; |
---|
| 431 | |
---|
| 432 | Bool bZeroIdxInterViewFlag = ( this->getRefPic(RefPicList(uiRefListIdx), 0)->getPOC() == iCurrPOC ) ? true : false; |
---|
| 433 | for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ ) |
---|
| 434 | { |
---|
| 435 | if ( (bZeroIdxInterViewFlag && this->getRefPic(RefPicList(uiRefListIdx), i)->getPOC() != iCurrPOC ) || |
---|
| 436 | (!bZeroIdxInterViewFlag && this->getRefPic(RefPicList(uiRefListIdx), i)->getPOC() == iCurrPOC ) ) |
---|
| 437 | { |
---|
| 438 | this->setNewRefIdx(RefPicList(uiRefListIdx),i); |
---|
| 439 | break; |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | #endif |
---|
[2] | 445 | } |
---|
| 446 | |
---|
[56] | 447 | Void TComSlice::setRefPicListMvc( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcInterViewRefPics ) |
---|
[2] | 448 | { |
---|
[56] | 449 | if( m_eSliceType == I_SLICE ) |
---|
[2] | 450 | { |
---|
[56] | 451 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList) ); |
---|
| 452 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx ) ); |
---|
[2] | 453 | |
---|
| 454 | return; |
---|
| 455 | } |
---|
| 456 | |
---|
[56] | 457 | TComPic* pcRefPic; |
---|
| 458 | TComPic* RefPicSetStCurr0[16]; |
---|
| 459 | TComPic* RefPicSetStCurr1[16]; |
---|
| 460 | TComPic* RefPicSetLtCurr [16]; |
---|
| 461 | TComPic* RefPicSetIvCurr [16]; |
---|
| 462 | |
---|
| 463 | UInt NumPocStCurr0 = 0; |
---|
| 464 | UInt NumPocStCurr1 = 0; |
---|
| 465 | UInt NumPocLtCurr = 0; |
---|
| 466 | UInt NumPocIvCurr = 0; |
---|
| 467 | |
---|
| 468 | Int i; |
---|
| 469 | // short term negative |
---|
| 470 | for( i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
[2] | 471 | { |
---|
[56] | 472 | if( m_pcRPS->getUsed(i) ) |
---|
[2] | 473 | { |
---|
[56] | 474 | pcRefPic = xGetRefPic( rcListPic, getPOC() + m_pcRPS->getDeltaPOC(i) ); |
---|
| 475 | pcRefPic->setIsLongTerm( 0 ); |
---|
| 476 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 477 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 478 | NumPocStCurr0++; |
---|
[2] | 479 | } |
---|
| 480 | } |
---|
[56] | 481 | // short term positive |
---|
| 482 | for( ; i < m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures(); i++ ) |
---|
| 483 | { |
---|
| 484 | if( m_pcRPS->getUsed(i) ) |
---|
| 485 | { |
---|
| 486 | pcRefPic = xGetRefPic( rcListPic, getPOC() + m_pcRPS->getDeltaPOC(i) ); |
---|
| 487 | pcRefPic->setIsLongTerm( 0 ); |
---|
| 488 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 489 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 490 | NumPocStCurr1++; |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | // long term |
---|
| 494 | for( i = m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures() - 1; i > m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures() - 1 ; i-- ) |
---|
| 495 | { |
---|
| 496 | if( m_pcRPS->getUsed(i) ) |
---|
| 497 | { |
---|
| 498 | pcRefPic = xGetLongTermRefPic( rcListPic, m_pcRPS->getPOC(i) ); |
---|
| 499 | pcRefPic->setIsLongTerm( 1 ); |
---|
| 500 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 501 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 502 | NumPocLtCurr++; |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | // inter-view |
---|
| 506 | for( i = 0; i < m_pcSPS->getNumberOfUsableInterViewRefs(); i++ ) |
---|
| 507 | { |
---|
| 508 | pcRefPic = xGetInterViewRefPic( rapcInterViewRefPics, getViewId() + m_pcSPS->getUsableInterViewRef(i) ); |
---|
[210] | 509 | #if QC_IV_AS_LT_B0046 |
---|
| 510 | pcRefPic->setIsLongTerm( 1 ); |
---|
| 511 | #else |
---|
[56] | 512 | pcRefPic->setIsLongTerm( 0 ); |
---|
[210] | 513 | #endif |
---|
[56] | 514 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 515 | RefPicSetIvCurr[NumPocIvCurr] = pcRefPic; |
---|
| 516 | NumPocIvCurr++; |
---|
| 517 | } |
---|
[2] | 518 | |
---|
[56] | 519 | // ref_pic_list_init |
---|
| 520 | UInt cIdx = 0; |
---|
| 521 | UInt num_ref_idx_l0_active_minus1 = m_aiNumRefIdx[0] - 1; |
---|
| 522 | UInt num_ref_idx_l1_active_minus1 = m_aiNumRefIdx[1] - 1; |
---|
| 523 | |
---|
| 524 | assert( (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) == getNumPocTotalCurrMvc() ); |
---|
| 525 | Int numRpsCurrTempList0 = max( (num_ref_idx_l0_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) ); |
---|
| 526 | Int numRpsCurrTempList1 = max( (num_ref_idx_l1_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) ); |
---|
| 527 | |
---|
| 528 | assert( numRpsCurrTempList0 <= 16 ); |
---|
| 529 | TComPic* refPicListTemp0[16]; |
---|
| 530 | assert( numRpsCurrTempList1 <= 16 ); |
---|
| 531 | TComPic* refPicListTemp1[16]; |
---|
| 532 | |
---|
| 533 | cIdx = 0; |
---|
| 534 | while( cIdx < numRpsCurrTempList0 ) |
---|
[2] | 535 | { |
---|
[56] | 536 | for( i = 0; i < NumPocStCurr0 && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetStCurr0[i]; } |
---|
| 537 | for( i = 0; i < NumPocStCurr1 && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetStCurr1[i]; } |
---|
| 538 | for( i = 0; i < NumPocLtCurr && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetLtCurr [i]; } |
---|
| 539 | for( i = 0; i < NumPocIvCurr && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetIvCurr [i]; } |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | cIdx = 0; |
---|
| 543 | while( cIdx < numRpsCurrTempList1 && m_eSliceType == B_SLICE ) |
---|
| 544 | { |
---|
| 545 | for( i = 0; i < NumPocStCurr1 && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetStCurr1[i]; } |
---|
| 546 | for( i = 0; i < NumPocStCurr0 && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetStCurr0[i]; } |
---|
| 547 | for( i = 0; i < NumPocLtCurr && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetLtCurr [i]; } |
---|
| 548 | for( i = 0; i < NumPocIvCurr && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetIvCurr [i]; } |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | for( cIdx = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++ ) |
---|
| 552 | { |
---|
| 553 | m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx]; |
---|
[210] | 554 | #if QC_IV_AS_LT_B0046 |
---|
| 555 | setWasLongTerm(m_apcRefPicList[0][cIdx]->getIsLongTerm(), REF_PIC_LIST_0, cIdx); |
---|
| 556 | #endif |
---|
[56] | 557 | } |
---|
| 558 | if( m_eSliceType == P_SLICE ) |
---|
| 559 | { |
---|
| 560 | m_aiNumRefIdx[1] = 0; |
---|
| 561 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]) ); |
---|
| 562 | } |
---|
| 563 | else |
---|
| 564 | { |
---|
| 565 | for( cIdx = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++ ) |
---|
[2] | 566 | { |
---|
[56] | 567 | m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx]; |
---|
[210] | 568 | #if QC_IV_AS_LT_B0046 |
---|
| 569 | setWasLongTerm(m_apcRefPicList[1][cIdx]->getIsLongTerm(), REF_PIC_LIST_1, cIdx); |
---|
| 570 | #endif |
---|
[2] | 571 | } |
---|
| 572 | } |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | Void TComSlice::initEqualRef() |
---|
| 576 | { |
---|
| 577 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 578 | { |
---|
| 579 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 580 | { |
---|
| 581 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 582 | { |
---|
| 583 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 584 | } |
---|
| 585 | } |
---|
| 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | Void TComSlice::initMultiviewSlice( Int** aaiScale, Int** aaiOffset ) |
---|
| 590 | { |
---|
| 591 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
| 592 | { |
---|
| 593 | UInt uiViewId = m_pcSPS->getViewId(); |
---|
| 594 | for( UInt uiBaseViewId = 0; uiBaseViewId < uiViewId; uiBaseViewId++ ) |
---|
| 595 | { |
---|
| 596 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ uiViewId ]; |
---|
| 597 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ uiViewId ][ uiBaseViewId ]; |
---|
| 598 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ uiViewId ]; |
---|
| 599 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ uiViewId ][ uiBaseViewId ]; |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | } |
---|
| 603 | |
---|
[56] | 604 | #if COLLOCATED_REF_IDX |
---|
| 605 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 606 | { |
---|
| 607 | Int i; |
---|
| 608 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
| 609 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(curSlice->getColDir()), curSlice->getColRefIdx()); |
---|
| 610 | TComSlice* preSlice; |
---|
| 611 | Int preColRefPOC; |
---|
| 612 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 613 | { |
---|
| 614 | preSlice = pic->getSlice(i); |
---|
| 615 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 616 | { |
---|
| 617 | preColRefPOC = preSlice->getRefPOC( RefPicList(preSlice->getColDir()), preSlice->getColRefIdx()); |
---|
| 618 | if(currColRefPOC != preColRefPOC) |
---|
| 619 | { |
---|
| 620 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 621 | exit(EXIT_FAILURE); |
---|
| 622 | } |
---|
| 623 | else |
---|
| 624 | { |
---|
| 625 | break; |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | } |
---|
| 630 | #endif |
---|
| 631 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, TComList<TComPic*>& rcListPic) |
---|
| 632 | { |
---|
| 633 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 634 | { |
---|
| 635 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 636 | { |
---|
| 637 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 638 | } |
---|
| 639 | } |
---|
| 640 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 641 | { |
---|
| 642 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 643 | { |
---|
| 644 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | #if H0566_TLA |
---|
| 648 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 649 | #else |
---|
| 650 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) // CDR picture found |
---|
| 651 | #endif |
---|
| 652 | { |
---|
| 653 | pocCRA = getPOC(); |
---|
| 654 | } |
---|
| 655 | } |
---|
[2] | 656 | |
---|
[56] | 657 | /** Function for marking the reference pictures when an IDR and CRA is encountered. |
---|
| 658 | * \param pocCRA POC of the CRA picture |
---|
[2] | 659 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 660 | * \param rcListPic reference to the reference picture list |
---|
| 661 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
[5] | 662 | * If the nal_unit_type is IDR all pictures in the reference picture list |
---|
| 663 | * is marked as "unused for reference" |
---|
[56] | 664 | * Otherwise do for the CRA case (non CRA case has no effect since both if conditions below will not be true) |
---|
[5] | 665 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
[56] | 666 | * temporal reference is greater than the temporal reference of the latest CRA picture (pocCRA), |
---|
| 667 | * mark all reference pictures except the latest CRA picture as "unused for reference" and set |
---|
[2] | 668 | * the bRefreshPending flag to false. |
---|
[56] | 669 | * If the nal_unit_type is CRA, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
[2] | 670 | * reference of the current picture. |
---|
| 671 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 672 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 673 | */ |
---|
[56] | 674 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
[2] | 675 | { |
---|
| 676 | TComPic* rpcPic; |
---|
[5] | 677 | UInt uiPOCCurr = getPOC(); |
---|
[2] | 678 | |
---|
[56] | 679 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR ) // IDR |
---|
[2] | 680 | { |
---|
| 681 | // mark all pictures as not used for reference |
---|
| 682 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 683 | while (iterPic != rcListPic.end()) |
---|
| 684 | { |
---|
| 685 | rpcPic = *(iterPic); |
---|
| 686 | rpcPic->setCurrSliceIdx(0); |
---|
| 687 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
| 688 | iterPic++; |
---|
| 689 | } |
---|
| 690 | } |
---|
[56] | 691 | else // CRA or No DR |
---|
[2] | 692 | { |
---|
[56] | 693 | if (bRefreshPending==true && uiPOCCurr > pocCRA) // CRA reference marking pending |
---|
[2] | 694 | { |
---|
| 695 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 696 | while (iterPic != rcListPic.end()) |
---|
| 697 | { |
---|
| 698 | rpcPic = *(iterPic); |
---|
[56] | 699 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false); |
---|
[2] | 700 | iterPic++; |
---|
| 701 | } |
---|
[5] | 702 | bRefreshPending = false; |
---|
[2] | 703 | } |
---|
[56] | 704 | #if H0566_TLA |
---|
| 705 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 706 | #else |
---|
| 707 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) // CDR picture found |
---|
| 708 | #endif |
---|
[2] | 709 | { |
---|
[5] | 710 | bRefreshPending = true; |
---|
[56] | 711 | pocCRA = uiPOCCurr; |
---|
[2] | 712 | } |
---|
| 713 | } |
---|
| 714 | } |
---|
| 715 | |
---|
| 716 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 717 | { |
---|
| 718 | assert( pSrc != NULL ); |
---|
| 719 | |
---|
| 720 | Int i, j, k; |
---|
| 721 | |
---|
| 722 | m_iPOC = pSrc->m_iPOC; |
---|
[56] | 723 | m_viewId = pSrc->m_viewId; |
---|
[21] | 724 | #if SONY_COLPIC_AVAILABILITY |
---|
| 725 | m_iViewOrderIdx = pSrc->m_iViewOrderIdx; |
---|
| 726 | #endif |
---|
[2] | 727 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
[56] | 728 | m_eNalUnitTypeBaseViewMvc = pSrc->m_eNalUnitTypeBaseViewMvc; |
---|
[2] | 729 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 730 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
[56] | 731 | #if ADAPTIVE_QP_SELECTION |
---|
| 732 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 733 | #endif |
---|
[2] | 734 | m_bLoopFilterDisable = pSrc->m_bLoopFilterDisable; |
---|
[56] | 735 | m_inheritDblParamFromAPS = pSrc->m_inheritDblParamFromAPS; |
---|
| 736 | m_loopFilterBetaOffsetDiv2 = pSrc->m_loopFilterBetaOffsetDiv2; |
---|
| 737 | m_loopFilterTcOffsetDiv2 = pSrc->m_loopFilterTcOffsetDiv2; |
---|
[5] | 738 | |
---|
[2] | 739 | for (i = 0; i < 3; i++) |
---|
| 740 | { |
---|
| 741 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | for (i = 0; i < 2; i++) |
---|
| 745 | { |
---|
| 746 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
| 747 | { |
---|
| 748 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
| 749 | } |
---|
| 750 | } |
---|
| 751 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
| 752 | { |
---|
| 753 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
| 754 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
| 755 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
| 756 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
| 757 | } |
---|
| 758 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
| 759 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
[56] | 760 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
[2] | 761 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
| 762 | for (i = 0; i < 2; i++) |
---|
| 763 | { |
---|
| 764 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 765 | { |
---|
[56] | 766 | m_apcRefPicList [i][j] = pSrc->m_apcRefPicList [i][j]; |
---|
| 767 | m_aiRefPOCList [i][j] = pSrc->m_aiRefPOCList [i][j]; |
---|
| 768 | m_aiRefViewIdList[i][j] = pSrc->m_aiRefViewIdList[i][j]; |
---|
[2] | 769 | } |
---|
[5] | 770 | } |
---|
[2] | 771 | m_iDepth = pSrc->m_iDepth; |
---|
| 772 | |
---|
| 773 | // referenced slice |
---|
| 774 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 775 | |
---|
| 776 | // access channel |
---|
| 777 | m_pcSPS = pSrc->m_pcSPS; |
---|
| 778 | m_pcPPS = pSrc->m_pcPPS; |
---|
[56] | 779 | m_pcRPS = pSrc->m_pcRPS; |
---|
| 780 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 781 | |
---|
[2] | 782 | m_pcPic = pSrc->m_pcPic; |
---|
[56] | 783 | m_pcAPS = pSrc->m_pcAPS; |
---|
| 784 | m_iAPSId = pSrc->m_iAPSId; |
---|
[2] | 785 | |
---|
| 786 | m_uiColDir = pSrc->m_uiColDir; |
---|
[56] | 787 | #if COLLOCATED_REF_IDX |
---|
| 788 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
| 789 | #endif |
---|
| 790 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
| 791 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
| 792 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
| 793 | #else |
---|
[2] | 794 | m_dLambda = pSrc->m_dLambda; |
---|
[56] | 795 | #endif |
---|
[2] | 796 | for (i = 0; i < 2; i++) |
---|
| 797 | { |
---|
| 798 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 799 | { |
---|
| 800 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 801 | { |
---|
| 802 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
| 808 | m_bRefIdxCombineCoding = pSrc->m_bRefIdxCombineCoding; |
---|
[56] | 809 | |
---|
| 810 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 811 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 812 | |
---|
[2] | 813 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
| 814 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
| 815 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
| 816 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
| 817 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
| 818 | m_uiEntropySliceMode = pSrc->m_uiEntropySliceMode; |
---|
[5] | 819 | m_uiEntropySliceArgument = pSrc->m_uiEntropySliceArgument; |
---|
[2] | 820 | m_uiEntropySliceCurStartCUAddr = pSrc->m_uiEntropySliceCurStartCUAddr; |
---|
| 821 | m_uiEntropySliceCurEndCUAddr = pSrc->m_uiEntropySliceCurEndCUAddr; |
---|
| 822 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
| 823 | m_bNextEntropySlice = pSrc->m_bNextEntropySlice; |
---|
[56] | 824 | m_iTileMarkerFlag = pSrc->m_iTileMarkerFlag; |
---|
[2] | 825 | for ( int e=0 ; e<2 ; e++ ) |
---|
[56] | 826 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
| 827 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
| 828 | |
---|
| 829 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
| 830 | #if SAO_UNIT_INTERLEAVING |
---|
| 831 | m_saoInterleavingFlag = pSrc->m_saoInterleavingFlag; |
---|
| 832 | m_saoEnabledFlagCb = pSrc->m_saoEnabledFlagCb; |
---|
| 833 | m_saoEnabledFlagCr = pSrc->m_saoEnabledFlagCr; |
---|
| 834 | #endif |
---|
| 835 | #if CABAC_INIT_FLAG |
---|
| 836 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
[2] | 837 | #endif |
---|
[56] | 838 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 839 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
| 840 | #endif |
---|
| 841 | |
---|
| 842 | #if H0111_MVD_L1_ZERO |
---|
| 843 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 844 | #endif |
---|
[2] | 845 | } |
---|
| 846 | |
---|
[56] | 847 | int TComSlice::m_prevPOC = 0; |
---|
| 848 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 849 | * \param uiTLayer Temporal layer ID of the current slice |
---|
| 850 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 851 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
| 852 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 853 | */ |
---|
| 854 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
[2] | 855 | { |
---|
[56] | 856 | #if !H0566_TLA |
---|
| 857 | // If temporal_id_nesting_flag == 1, then num_temporal_layer_switching_point_flags shall be inferred to be 0 and temporal_layer_switching_point_flag shall be inferred to be 1 for all temporal layers |
---|
| 858 | if ( m_pcSPS->getTemporalIdNestingFlag() ) |
---|
| 859 | { |
---|
| 860 | m_pcPPS->setNumTLayerSwitchingFlags( 0 ); |
---|
| 861 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
| 862 | { |
---|
| 863 | m_pcPPS->setTLayerSwitchingFlag( i, true ); |
---|
| 864 | } |
---|
| 865 | } |
---|
| 866 | else |
---|
| 867 | { |
---|
| 868 | for ( UInt i = m_pcPPS->getNumTLayerSwitchingFlags(); i < MAX_TLAYER; i++ ) |
---|
| 869 | { |
---|
| 870 | m_pcPPS->setTLayerSwitchingFlag( i, false ); |
---|
| 871 | } |
---|
| 872 | } |
---|
| 873 | #endif |
---|
| 874 | |
---|
| 875 | m_uiTLayer = uiTLayer; |
---|
| 876 | #if !H0566_TLA |
---|
| 877 | m_bTLayerSwitchingFlag = m_pcPPS->getTLayerSwitchingFlag( uiTLayer ); |
---|
| 878 | #endif |
---|
[2] | 879 | } |
---|
| 880 | |
---|
[56] | 881 | #if H0566_TLA && H0566_TLA_SET_FOR_SWITCHING_POINTS |
---|
| 882 | /** Function for checking if this is a switching-point |
---|
| 883 | */ |
---|
| 884 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
[2] | 885 | { |
---|
[56] | 886 | TComPic* rpcPic; |
---|
| 887 | // loop through all pictures in the reference picture buffer |
---|
| 888 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 889 | while ( iterPic != rcListPic.end()) |
---|
| 890 | { |
---|
| 891 | rpcPic = *(iterPic++); |
---|
| 892 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 893 | { |
---|
| 894 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 895 | { |
---|
| 896 | return false; |
---|
| 897 | } |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | return true; |
---|
| 901 | } |
---|
| 902 | #endif |
---|
| 903 | |
---|
| 904 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 905 | */ |
---|
| 906 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 907 | { |
---|
| 908 | TComPic* rpcPic; |
---|
| 909 | Int i, isReference; |
---|
| 910 | |
---|
| 911 | Int j = 0; |
---|
| 912 | // loop through all pictures in the reference picture buffer |
---|
| 913 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 914 | while ( iterPic != rcListPic.end()) |
---|
| 915 | { |
---|
| 916 | j++; |
---|
| 917 | rpcPic = *(iterPic++); |
---|
| 918 | |
---|
| 919 | isReference = 0; |
---|
| 920 | // loop through all pictures in the Reference Picture Set to see if the picture should be kept as reference picture |
---|
| 921 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 922 | { |
---|
[210] | 923 | #if QC_IV_AS_LT_B0046 |
---|
| 924 | if( rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 925 | #else |
---|
[56] | 926 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
[210] | 927 | #endif |
---|
[56] | 928 | { |
---|
| 929 | isReference = 1; |
---|
| 930 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 931 | rpcPic->setIsLongTerm(0); |
---|
| 932 | } |
---|
| 933 | } |
---|
| 934 | // long term pictures |
---|
| 935 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 936 | { |
---|
[210] | 937 | #if QC_IV_AS_LT_B0046 |
---|
| 938 | if( (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) |
---|
| 939 | #else |
---|
[56] | 940 | 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())) |
---|
[210] | 941 | #endif |
---|
[56] | 942 | { |
---|
| 943 | isReference = 1; |
---|
| 944 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | // mark the picture as "unused for reference" if it is not in |
---|
| 948 | // the Reference Picture Set |
---|
| 949 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 950 | { |
---|
| 951 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
| 952 | rpcPic->setIsLongTerm(0); |
---|
| 953 | } |
---|
| 954 | } |
---|
| 955 | } |
---|
| 956 | |
---|
| 957 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 958 | */ |
---|
| 959 | #if START_DECODING_AT_CRA |
---|
| 960 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool outputFlag, Int pocRandomAccess) |
---|
| 961 | #else |
---|
| 962 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool outputFlag) |
---|
| 963 | #endif |
---|
| 964 | { |
---|
| 965 | TComPic* rpcPic; |
---|
| 966 | Int i, isAvailable, j; |
---|
| 967 | Int atLeastOneLost = 0; |
---|
| 968 | Int atLeastOneRemoved = 0; |
---|
| 969 | Int iPocLost = 0; |
---|
| 970 | |
---|
| 971 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 972 | // to see if the picture should be kept as reference picture |
---|
| 973 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();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 | 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()) |
---|
| 984 | { |
---|
| 985 | isAvailable = 1; |
---|
| 986 | } |
---|
| 987 | } |
---|
| 988 | // if there was no such long-term check the short terms |
---|
| 989 | if(!isAvailable) |
---|
| 990 | { |
---|
| 991 | iterPic = rcListPic.begin(); |
---|
| 992 | while ( iterPic != rcListPic.end()) |
---|
| 993 | { |
---|
| 994 | j++; |
---|
| 995 | rpcPic = *(iterPic++); |
---|
| 996 | |
---|
| 997 | 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()) |
---|
| 998 | { |
---|
| 999 | isAvailable = 1; |
---|
| 1000 | rpcPic->setIsLongTerm(1); |
---|
| 1001 | break; |
---|
[2] | 1002 | } |
---|
[56] | 1003 | } |
---|
| 1004 | } |
---|
| 1005 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1006 | // but not available as reference picture |
---|
| 1007 | if(isAvailable == 0) |
---|
| 1008 | { |
---|
| 1009 | #if START_DECODING_AT_CRA |
---|
| 1010 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1011 | { |
---|
| 1012 | #endif |
---|
| 1013 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1014 | { |
---|
| 1015 | if(outputFlag) |
---|
| 1016 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1017 | atLeastOneRemoved = 1; |
---|
[2] | 1018 | } |
---|
[56] | 1019 | else |
---|
| 1020 | { |
---|
| 1021 | if(outputFlag) |
---|
| 1022 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1023 | atLeastOneLost = 1; |
---|
| 1024 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
[2] | 1025 | } |
---|
[56] | 1026 | #if START_DECODING_AT_CRA |
---|
[2] | 1027 | } |
---|
[56] | 1028 | #endif |
---|
| 1029 | } |
---|
| 1030 | } |
---|
| 1031 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1032 | // to see if the picture should be kept as reference picture |
---|
| 1033 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1034 | { |
---|
| 1035 | j = 0; |
---|
| 1036 | isAvailable = 0; |
---|
| 1037 | // loop through all pictures in the reference picture buffer |
---|
| 1038 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1039 | while ( iterPic != rcListPic.end()) |
---|
| 1040 | { |
---|
| 1041 | j++; |
---|
| 1042 | rpcPic = *(iterPic++); |
---|
| 1043 | |
---|
| 1044 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1045 | { |
---|
| 1046 | isAvailable = 1; |
---|
| 1047 | } |
---|
| 1048 | } |
---|
| 1049 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1050 | // but not available as reference picture |
---|
| 1051 | if(isAvailable == 0) |
---|
| 1052 | { |
---|
| 1053 | #if START_DECODING_AT_CRA |
---|
| 1054 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1055 | { |
---|
| 1056 | #endif |
---|
| 1057 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1058 | { |
---|
| 1059 | if(outputFlag) |
---|
| 1060 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1061 | atLeastOneRemoved = 1; |
---|
| 1062 | } |
---|
| 1063 | else |
---|
| 1064 | { |
---|
| 1065 | if(outputFlag) |
---|
| 1066 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1067 | atLeastOneLost = 1; |
---|
| 1068 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1069 | } |
---|
| 1070 | #if START_DECODING_AT_CRA |
---|
| 1071 | } |
---|
| 1072 | #endif |
---|
| 1073 | } |
---|
| 1074 | } |
---|
| 1075 | if(atLeastOneLost) |
---|
| 1076 | { |
---|
| 1077 | return iPocLost+1; |
---|
[2] | 1078 | } |
---|
[56] | 1079 | if(atLeastOneRemoved) |
---|
| 1080 | { |
---|
| 1081 | return -2; |
---|
| 1082 | } |
---|
| 1083 | else |
---|
| 1084 | return 0; |
---|
[2] | 1085 | } |
---|
| 1086 | |
---|
[56] | 1087 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1088 | */ |
---|
| 1089 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1090 | { |
---|
| 1091 | TComPic* rpcPic; |
---|
| 1092 | Int i, j; |
---|
| 1093 | Int k = 0; |
---|
| 1094 | Int nrOfNegativePictures = 0; |
---|
| 1095 | Int nrOfPositivePictures = 0; |
---|
| 1096 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
| 1097 | |
---|
| 1098 | // loop through all pictures in the Reference Picture Set |
---|
| 1099 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1100 | { |
---|
| 1101 | j = 0; |
---|
| 1102 | // loop through all pictures in the reference picture buffer |
---|
| 1103 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1104 | while ( iterPic != rcListPic.end()) |
---|
| 1105 | { |
---|
| 1106 | j++; |
---|
| 1107 | rpcPic = *(iterPic++); |
---|
| 1108 | |
---|
| 1109 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1110 | { |
---|
| 1111 | // This picture exists as a reference picture |
---|
| 1112 | // and should be added to the explicit Reference Picture Set |
---|
| 1113 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1114 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
| 1115 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
| 1116 | nrOfNegativePictures++; |
---|
| 1117 | else |
---|
| 1118 | nrOfPositivePictures++; |
---|
| 1119 | k++; |
---|
| 1120 | } |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1124 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1125 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1126 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
| 1127 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1128 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
| 1129 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
| 1130 | { |
---|
| 1131 | pcRPS->setInterRPSPrediction(false); |
---|
| 1132 | pcRPS->setNumRefIdc(0); |
---|
| 1133 | } |
---|
| 1134 | else |
---|
| 1135 | { |
---|
| 1136 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1137 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
| 1138 | #if RPS_IN_SPS |
---|
| 1139 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1140 | #else |
---|
| 1141 | TComReferencePictureSet* pcRefRPS = this->getPPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1142 | #endif |
---|
| 1143 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1144 | Int iNewIdc=0; |
---|
| 1145 | for(i=0; i<= iRefPics; i++) |
---|
| 1146 | { |
---|
| 1147 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1148 | Int iRefIdc = 0; |
---|
| 1149 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
| 1150 | { |
---|
| 1151 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
| 1152 | { |
---|
| 1153 | if (pcRPS->getUsed(j)) |
---|
| 1154 | { |
---|
| 1155 | iRefIdc = 1; |
---|
| 1156 | } |
---|
| 1157 | else |
---|
| 1158 | { |
---|
| 1159 | iRefIdc = 2; |
---|
| 1160 | } |
---|
| 1161 | } |
---|
| 1162 | } |
---|
| 1163 | pcRPS->setRefIdc(i, iRefIdc); |
---|
| 1164 | iNewIdc++; |
---|
| 1165 | } |
---|
| 1166 | pcRPS->setInterRPSPrediction(true); |
---|
| 1167 | pcRPS->setNumRefIdc(iNewIdc); |
---|
| 1168 | pcRPS->setDeltaRPS(deltaRPS); |
---|
| 1169 | #if RPS_IN_SPS |
---|
| 1170 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1171 | #else |
---|
| 1172 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getPPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1173 | #endif |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | this->setRPS(pcRPS); |
---|
| 1177 | this->setRPSidx(-1); |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | Void TComSlice::decodingMarkingForNoTMVP( TComList<TComPic*>& rcListPic, Int currentPOC ) |
---|
| 1181 | { |
---|
| 1182 | TComList<TComPic*>::iterator it; |
---|
| 1183 | for ( it = rcListPic.begin(); it != rcListPic.end(); it++ ) |
---|
| 1184 | { |
---|
| 1185 | if ( (*it)->getSlice(0)->getPOC() != currentPOC ) |
---|
| 1186 | { |
---|
| 1187 | (*it)->setUsedForTMVP( false ); |
---|
| 1188 | } |
---|
| 1189 | } |
---|
| 1190 | } |
---|
| 1191 | |
---|
| 1192 | /** get AC and DC values for weighted pred |
---|
| 1193 | * \param *wp |
---|
| 1194 | * \returns Void |
---|
| 1195 | */ |
---|
| 1196 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
| 1197 | { |
---|
| 1198 | wp = m_weightACDCParam; |
---|
| 1199 | } |
---|
| 1200 | |
---|
| 1201 | /** init AC and DC values for weighted pred |
---|
| 1202 | * \returns Void |
---|
| 1203 | */ |
---|
| 1204 | Void TComSlice::initWpAcDcParam() |
---|
| 1205 | { |
---|
| 1206 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
| 1207 | { |
---|
| 1208 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1209 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1210 | } |
---|
| 1211 | } |
---|
| 1212 | |
---|
| 1213 | /** get WP tables for weighted pred |
---|
| 1214 | * \param RefPicList |
---|
| 1215 | * \param iRefIdx |
---|
| 1216 | * \param *&wpScalingParam |
---|
| 1217 | * \returns Void |
---|
| 1218 | */ |
---|
| 1219 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
| 1220 | { |
---|
| 1221 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1222 | } |
---|
| 1223 | |
---|
| 1224 | /** reset Default WP tables settings : no weight. |
---|
| 1225 | * \param wpScalingParam |
---|
| 1226 | * \returns Void |
---|
| 1227 | */ |
---|
[2] | 1228 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
| 1229 | { |
---|
[56] | 1230 | for ( int e=0 ; e<2 ; e++ ) |
---|
| 1231 | { |
---|
[2] | 1232 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1233 | { |
---|
| 1234 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1235 | { |
---|
[2] | 1236 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
| 1237 | pwp->bPresentFlag = false; |
---|
| 1238 | pwp->uiLog2WeightDenom = 0; |
---|
| 1239 | pwp->uiLog2WeightDenom = 0; |
---|
| 1240 | pwp->iWeight = 1; |
---|
| 1241 | pwp->iOffset = 0; |
---|
| 1242 | } |
---|
[56] | 1243 | } |
---|
[2] | 1244 | } |
---|
| 1245 | } |
---|
| 1246 | |
---|
[56] | 1247 | /** init WP table |
---|
| 1248 | * \returns Void |
---|
| 1249 | */ |
---|
[2] | 1250 | Void TComSlice::initWpScaling() |
---|
| 1251 | { |
---|
| 1252 | initWpScaling(m_weightPredTable); |
---|
| 1253 | } |
---|
| 1254 | |
---|
[56] | 1255 | /** set WP tables |
---|
| 1256 | * \param wpScalingParam |
---|
| 1257 | * \returns Void |
---|
| 1258 | */ |
---|
[2] | 1259 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
| 1260 | { |
---|
[56] | 1261 | for ( int e=0 ; e<2 ; e++ ) |
---|
| 1262 | { |
---|
[2] | 1263 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1264 | { |
---|
| 1265 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1266 | { |
---|
[2] | 1267 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
| 1268 | if ( !pwp->bPresentFlag ) { |
---|
| 1269 | // Inferring values not present : |
---|
| 1270 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1271 | pwp->iOffset = 0; |
---|
| 1272 | } |
---|
| 1273 | |
---|
| 1274 | pwp->w = pwp->iWeight; |
---|
| 1275 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
| 1276 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1277 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1278 | } |
---|
[56] | 1279 | } |
---|
[2] | 1280 | } |
---|
| 1281 | } |
---|
| 1282 | |
---|
[56] | 1283 | /** get WP tables for weighted pred of LC |
---|
| 1284 | * \param iRefIdxLC |
---|
| 1285 | * \param *&wpScalingParam |
---|
| 1286 | * \returns Void |
---|
| 1287 | */ |
---|
| 1288 | Void TComSlice::getWpScalingLC( Int iRefIdx, wpScalingParam *&wp ) |
---|
[2] | 1289 | { |
---|
[56] | 1290 | wp = m_weightPredTableLC[iRefIdx]; |
---|
[2] | 1291 | } |
---|
[56] | 1292 | /** reset Default WP tables settings for LC : no weight. |
---|
| 1293 | * \param wpScalingParam |
---|
| 1294 | * \returns Void |
---|
| 1295 | */ |
---|
| 1296 | Void TComSlice::resetWpScalingLC(wpScalingParam wp[2*MAX_NUM_REF][3]) |
---|
| 1297 | { |
---|
| 1298 | for ( int i=0 ; i<2*MAX_NUM_REF ; i++ ) |
---|
| 1299 | { |
---|
| 1300 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1301 | { |
---|
| 1302 | wpScalingParam *pwp = &(wp[i][yuv]); |
---|
| 1303 | pwp->bPresentFlag = false; |
---|
| 1304 | pwp->uiLog2WeightDenom = 0; |
---|
| 1305 | pwp->uiLog2WeightDenom = 0; |
---|
| 1306 | pwp->iWeight = 1; |
---|
| 1307 | pwp->iOffset = 0; |
---|
| 1308 | } |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | /** set current WP tables settings for LC |
---|
| 1312 | * \returns Void |
---|
| 1313 | */ |
---|
| 1314 | Void TComSlice::setWpParamforLC() |
---|
| 1315 | { |
---|
| 1316 | for ( Int iRefIdx=0 ; iRefIdx<getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
| 1317 | { |
---|
| 1318 | RefPicList eRefPicList = (RefPicList)getListIdFromIdxOfLC(iRefIdx); |
---|
| 1319 | Int iCombRefIdx = getRefIdxFromIdxOfLC(iRefIdx); |
---|
[2] | 1320 | |
---|
[56] | 1321 | wpScalingParam *wp_src, *wp_dst; |
---|
| 1322 | getWpScalingLC(iRefIdx, wp_src); |
---|
| 1323 | getWpScaling(eRefPicList, iCombRefIdx, wp_dst); |
---|
| 1324 | copyWPtable(wp_src, wp_dst); |
---|
| 1325 | |
---|
| 1326 | if(eRefPicList == REF_PIC_LIST_0) |
---|
| 1327 | { |
---|
| 1328 | Int iRefIdxL1 = getRefIdxOfL1FromRefIdxOfL0(iCombRefIdx); |
---|
| 1329 | if(iRefIdxL1 >= 0) |
---|
| 1330 | { |
---|
| 1331 | getWpScaling(REF_PIC_LIST_1, iRefIdxL1, wp_dst); |
---|
| 1332 | copyWPtable(wp_src, wp_dst); |
---|
| 1333 | } |
---|
| 1334 | } |
---|
| 1335 | if(eRefPicList == REF_PIC_LIST_1) |
---|
| 1336 | { |
---|
| 1337 | Int iRefIdxL0 = getRefIdxOfL0FromRefIdxOfL1(iCombRefIdx); |
---|
| 1338 | if(iRefIdxL0 >= 0) |
---|
| 1339 | { |
---|
| 1340 | getWpScaling(REF_PIC_LIST_0, iRefIdxL0, wp_dst); |
---|
| 1341 | copyWPtable(wp_src, wp_dst); |
---|
| 1342 | } |
---|
| 1343 | } |
---|
| 1344 | } |
---|
| 1345 | initWpScaling(); |
---|
| 1346 | } |
---|
| 1347 | /** copy source WP tables to destination table for LC |
---|
| 1348 | * \param wpScalingParam *&wp_src : source |
---|
| 1349 | * \param wpScalingParam *&wp_dst : destination |
---|
| 1350 | * \returns Void |
---|
| 1351 | */ |
---|
| 1352 | Void TComSlice::copyWPtable(wpScalingParam *&wp_src, wpScalingParam *&wp_dst) |
---|
[2] | 1353 | { |
---|
[56] | 1354 | for ( Int iComp = 0; iComp < 3; iComp++ ) |
---|
[2] | 1355 | { |
---|
[56] | 1356 | wp_dst[iComp].uiLog2WeightDenom = (iComp==0) ? wp_src[0].uiLog2WeightDenom : wp_src[1].uiLog2WeightDenom; |
---|
| 1357 | wp_dst[iComp].bPresentFlag = wp_src[iComp].bPresentFlag; |
---|
| 1358 | wp_dst[iComp].iWeight = wp_src[iComp].iWeight; |
---|
| 1359 | wp_dst[iComp].iOffset = wp_src[iComp].iOffset; |
---|
[2] | 1360 | } |
---|
| 1361 | } |
---|
| 1362 | |
---|
[189] | 1363 | #if LGE_ILLUCOMP_B0045 |
---|
| 1364 | Void TComSlice::xSetApplyIC() |
---|
| 1365 | { |
---|
| 1366 | Int iMaxPelValue = (1<<g_uiBitDepth); |
---|
| 1367 | Int *aiRefOrgHist; |
---|
| 1368 | Int *aiCurrHist; |
---|
| 1369 | aiRefOrgHist = new Int; |
---|
| 1370 | aiCurrHist = new Int; |
---|
| 1371 | aiRefOrgHist = (Int *)xMalloc(Int,iMaxPelValue); |
---|
| 1372 | aiCurrHist = (Int *)xMalloc(Int,iMaxPelValue); |
---|
| 1373 | memset(aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
| 1374 | memset(aiCurrHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
| 1375 | // Reference Idx Number |
---|
| 1376 | Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 ); |
---|
| 1377 | TComPic* pcCurrPic = NULL; |
---|
| 1378 | TComPic* pcRefPic = NULL; |
---|
| 1379 | TComPicYuv* pcCurrPicYuv = NULL; |
---|
| 1380 | TComPicYuv* pcRefPicYuvOrg = NULL; |
---|
| 1381 | pcCurrPic = getPic(); |
---|
| 1382 | pcCurrPicYuv = pcCurrPic->getPicYuvOrg(); |
---|
| 1383 | Int iWidth = pcCurrPicYuv->getWidth(); |
---|
| 1384 | Int iHeight = pcCurrPicYuv->getHeight(); |
---|
| 1385 | |
---|
| 1386 | |
---|
| 1387 | // Get InterView Reference picture |
---|
| 1388 | // !!!!! Assume only one Interview Reference Picture in L0 |
---|
| 1389 | for (Int i = 0; i < iNumRefIdx; i++) |
---|
| 1390 | { |
---|
| 1391 | pcRefPic = getRefPic( REF_PIC_LIST_0, i); |
---|
| 1392 | if (pcRefPic != NULL) |
---|
| 1393 | { |
---|
| 1394 | // Current Picture |
---|
| 1395 | if (pcCurrPic->getViewId() != pcRefPic->getViewId()) |
---|
| 1396 | { |
---|
| 1397 | pcRefPicYuvOrg = pcRefPic->getPicYuvOrg(); |
---|
| 1398 | } |
---|
| 1399 | } |
---|
| 1400 | } |
---|
| 1401 | if (pcRefPicYuvOrg != NULL) |
---|
| 1402 | { |
---|
| 1403 | Pel* pCurrY = pcCurrPicYuv ->getLumaAddr(); |
---|
| 1404 | Pel* pRefOrgY = pcRefPicYuvOrg ->getLumaAddr(); |
---|
| 1405 | Int iCurrStride = pcCurrPicYuv->getStride(); |
---|
| 1406 | Int iRefStride = pcRefPicYuvOrg->getStride(); |
---|
| 1407 | Int iSumOrgSAD = 0; |
---|
| 1408 | double dThresholdOrgSAD = 0.05; |
---|
| 1409 | // Histogram building - luminance |
---|
| 1410 | for ( Int y = 0; y < iHeight; y++) |
---|
| 1411 | { |
---|
| 1412 | for ( Int x = 0; x < iWidth; x++) |
---|
| 1413 | { |
---|
| 1414 | aiCurrHist[pCurrY[x]]++; |
---|
| 1415 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
| 1416 | } |
---|
| 1417 | pCurrY += iCurrStride; |
---|
| 1418 | pRefOrgY += iRefStride; |
---|
| 1419 | } |
---|
| 1420 | // Calc SAD |
---|
| 1421 | for (Int i = 0; i < iMaxPelValue; i++) |
---|
| 1422 | { |
---|
| 1423 | iSumOrgSAD += abs(aiCurrHist[i] - aiRefOrgHist[i]); |
---|
| 1424 | } |
---|
| 1425 | // Setting |
---|
| 1426 | if ( iSumOrgSAD > Int(dThresholdOrgSAD * iWidth * iHeight) ) |
---|
| 1427 | { |
---|
| 1428 | m_bApplyIC = true; |
---|
| 1429 | } |
---|
| 1430 | else |
---|
| 1431 | { |
---|
| 1432 | m_bApplyIC = false; |
---|
| 1433 | } |
---|
| 1434 | } |
---|
| 1435 | xFree(aiCurrHist); |
---|
| 1436 | xFree(aiRefOrgHist); |
---|
| 1437 | aiCurrHist = NULL; |
---|
| 1438 | aiRefOrgHist = NULL; |
---|
| 1439 | } |
---|
| 1440 | #endif |
---|
| 1441 | |
---|
[77] | 1442 | // ------------------------------------------------------------------------------------------------ |
---|
| 1443 | // Video parameter set (VPS) |
---|
| 1444 | // ------------------------------------------------------------------------------------------------ |
---|
[210] | 1445 | #if QC_MVHEVC_B0046 |
---|
| 1446 | TComVPS::TComVPS() |
---|
| 1447 | : m_VPSId ( 0) |
---|
| 1448 | , m_uiMaxTLayers ( 1) |
---|
| 1449 | , m_uiMaxLayers ( 1) |
---|
| 1450 | , m_bTemporalIdNestingFlag (false) |
---|
| 1451 | , m_uiNumHRDParameter ( 0) |
---|
| 1452 | , m_numAddiLayerOperationPoints (2) |
---|
| 1453 | , m_numAddiProLevelSets ( 1) |
---|
| 1454 | { |
---|
| 1455 | for( Int i = 0; i < MAX_LAYER_NUM; i++) |
---|
| 1456 | { |
---|
| 1457 | m_numOpLayerIdMinus1[i] = 0; |
---|
| 1458 | if(i) |
---|
| 1459 | m_numDirectRefLayer[i] = 1; |
---|
| 1460 | else |
---|
| 1461 | m_numDirectRefLayer[i] = 0; |
---|
| 1462 | for( Int j = 0; j < MAX_LAYER_NUM; j++) |
---|
| 1463 | { |
---|
| 1464 | m_numDirectRefID[i][j] = 0; |
---|
| 1465 | m_numOpLayerId[i][j] = 0; |
---|
| 1466 | } |
---|
| 1467 | m_uiViewId[i] = 0; |
---|
| 1468 | m_iViewOrderIdx[i] = 0; |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1472 | { |
---|
| 1473 | m_numReorderPics[i] = 0; |
---|
| 1474 | m_uiMaxDecPicBuffering[i] = 0; |
---|
| 1475 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1476 | } |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | TComVPS::~TComVPS() |
---|
| 1480 | { |
---|
| 1481 | } |
---|
| 1482 | #else |
---|
[77] | 1483 | #if VIDYO_VPS_INTEGRATION |
---|
| 1484 | TComVPS::TComVPS() |
---|
| 1485 | : m_VPSId ( 0) |
---|
| 1486 | , m_uiMaxTLayers ( 1) |
---|
| 1487 | , m_uiMaxLayers ( 1) |
---|
| 1488 | , m_bTemporalIdNestingFlag (false) |
---|
| 1489 | , m_uiExtensionType ( 0) |
---|
| 1490 | { |
---|
| 1491 | for( Int i = 0; i < MAX_LAYER_NUM; i++) |
---|
| 1492 | { |
---|
| 1493 | m_uiDependentLayer[i] = i? i-1: 0; |
---|
| 1494 | m_bDependentFlag[i] = false; |
---|
| 1495 | m_uiViewId[i] = 0; |
---|
| 1496 | m_bDepthFlag[i] = 0; |
---|
| 1497 | m_iViewOrderIdx[i] = 0; |
---|
| 1498 | } |
---|
| 1499 | |
---|
| 1500 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1501 | { |
---|
| 1502 | m_numReorderPics[i] = 0; |
---|
| 1503 | m_uiMaxDecPicBuffering[i] = 0; |
---|
| 1504 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1505 | } |
---|
| 1506 | } |
---|
[56] | 1507 | |
---|
[77] | 1508 | TComVPS::~TComVPS() |
---|
| 1509 | { |
---|
[100] | 1510 | |
---|
| 1511 | |
---|
[77] | 1512 | } |
---|
| 1513 | |
---|
| 1514 | #endif |
---|
[210] | 1515 | #endif |
---|
[77] | 1516 | |
---|
[2] | 1517 | // ------------------------------------------------------------------------------------------------ |
---|
| 1518 | // Sequence parameter set (SPS) |
---|
| 1519 | // ------------------------------------------------------------------------------------------------ |
---|
| 1520 | |
---|
| 1521 | TComSPS::TComSPS() |
---|
[210] | 1522 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 1523 | : m_VPSId ( 0) |
---|
| 1524 | , m_SPSId ( 0) |
---|
| 1525 | #else |
---|
[56] | 1526 | : m_SPSId ( 0) |
---|
[77] | 1527 | #endif |
---|
[56] | 1528 | , m_ProfileIdc ( 0) |
---|
| 1529 | , m_LevelIdc ( 0) |
---|
| 1530 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 1531 | , m_uiMaxTLayers ( 1) |
---|
| 1532 | // Structure |
---|
| 1533 | , m_picWidthInLumaSamples (352) |
---|
| 1534 | , m_picHeightInLumaSamples (288) |
---|
| 1535 | #if PIC_CROPPING |
---|
| 1536 | , m_picCroppingFlag (false) |
---|
| 1537 | , m_picCropLeftOffset ( 0) |
---|
| 1538 | , m_picCropRightOffset ( 0) |
---|
| 1539 | , m_picCropTopOffset ( 0) |
---|
| 1540 | , m_picCropBottomOffset ( 0) |
---|
| 1541 | #endif |
---|
| 1542 | , m_uiMaxCUWidth ( 32) |
---|
| 1543 | , m_uiMaxCUHeight ( 32) |
---|
| 1544 | , m_uiMaxCUDepth ( 3) |
---|
| 1545 | , m_uiMinTrDepth ( 0) |
---|
| 1546 | , m_uiMaxTrDepth ( 1) |
---|
| 1547 | #if RPS_IN_SPS |
---|
| 1548 | , m_bLongTermRefsPresent (false) |
---|
| 1549 | #endif |
---|
| 1550 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 1551 | , m_numReorderFrames ( 0) |
---|
| 1552 | #endif |
---|
| 1553 | , m_iNumberOfUsableInterViewRefs( 0 ) |
---|
| 1554 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 1555 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 1556 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 1557 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 1558 | // Tool list |
---|
| 1559 | , m_usePCM (false) |
---|
| 1560 | , m_pcmLog2MaxSize ( 5) |
---|
| 1561 | , m_uiPCMLog2MinSize ( 7) |
---|
| 1562 | , m_bDisInter4x4 ( 1) |
---|
| 1563 | , m_bUseALF (false) |
---|
| 1564 | #if LCU_SYNTAX_ALF |
---|
| 1565 | , m_bALFCoefInSlice (false) |
---|
| 1566 | #endif |
---|
| 1567 | #if !PIC_CROPPING |
---|
| 1568 | , m_bUsePAD (false) |
---|
| 1569 | #endif |
---|
| 1570 | , m_bUseLMChroma (false) |
---|
| 1571 | , m_bUseLComb (false) |
---|
| 1572 | , m_bLCMod (false) |
---|
| 1573 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
[210] | 1574 | #if QC_MVHEVC_B0046 |
---|
| 1575 | , m_restrictedRefPicListsFlag ( 0) |
---|
| 1576 | #else |
---|
[56] | 1577 | , m_restrictedRefPicListsFlag ( 1) |
---|
[210] | 1578 | #endif |
---|
[56] | 1579 | , m_listsModificationPresentFlag( 0) |
---|
| 1580 | #endif |
---|
| 1581 | , m_uiBitDepth ( 8) |
---|
| 1582 | , m_uiBitIncrement ( 0) |
---|
| 1583 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1584 | , m_qpBDOffsetY ( 0) |
---|
| 1585 | , m_qpBDOffsetC ( 0) |
---|
| 1586 | #endif |
---|
| 1587 | #if LOSSLESS_CODING |
---|
| 1588 | , m_useLossless (false) |
---|
| 1589 | #endif |
---|
| 1590 | , m_uiPCMBitDepthLuma ( 8) |
---|
| 1591 | , m_uiPCMBitDepthChroma ( 8) |
---|
| 1592 | , m_bPCMFilterDisableFlag (false) |
---|
| 1593 | , m_uiBitsForPOC ( 8) |
---|
| 1594 | , m_uiMaxTrSize ( 32) |
---|
| 1595 | , m_bLFCrossSliceBoundaryFlag (false) |
---|
| 1596 | , m_bUseSAO (false) |
---|
[5] | 1597 | #if HHI_MPI |
---|
[56] | 1598 | , m_bUseMVI (false) |
---|
[5] | 1599 | #endif |
---|
[56] | 1600 | , m_bLFCrossTileBoundaryFlag (false) |
---|
| 1601 | , m_iUniformSpacingIdr ( 0 ) |
---|
| 1602 | , m_iTileBoundaryIndependenceIdr ( 0 ) |
---|
| 1603 | , m_iNumColumnsMinus1 ( 0 ) |
---|
| 1604 | , m_puiColumnWidth ( NULL ) |
---|
| 1605 | , m_iNumRowsMinus1 ( 0 ) |
---|
| 1606 | , m_puiRowHeight ( NULL ) |
---|
| 1607 | , m_bTemporalIdNestingFlag (false) |
---|
| 1608 | , m_scalingListEnabledFlag (false) |
---|
| 1609 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 1610 | , m_uiMaxDecFrameBuffering ( 0) |
---|
| 1611 | , m_uiMaxLatencyIncrease ( 0) |
---|
| 1612 | #endif |
---|
| 1613 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
| 1614 | , m_tilesOrEntropyCodingSyncIdc( 0 ) |
---|
| 1615 | , m_numSubstreams ( 0 ) |
---|
| 1616 | #endif |
---|
| 1617 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 1618 | , m_bUseDMM (false) |
---|
| 1619 | #endif |
---|
[210] | 1620 | #if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX |
---|
| 1621 | , m_bUseDMM34 (false) |
---|
| 1622 | #endif |
---|
[189] | 1623 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
| 1624 | , m_bUseQTLPC (false) |
---|
[115] | 1625 | #endif |
---|
[56] | 1626 | { |
---|
| 1627 | // AMVP parameter |
---|
| 1628 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
| 1629 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 1630 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 1631 | { |
---|
| 1632 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1633 | m_uiMaxDecPicBuffering[i] = 0; |
---|
| 1634 | m_numReorderPics[i] = 0; |
---|
| 1635 | } |
---|
| 1636 | #endif |
---|
[42] | 1637 | |
---|
[2] | 1638 | m_uiViewId = 0; |
---|
| 1639 | m_iViewOrderIdx = 0; |
---|
| 1640 | m_bDepth = false; |
---|
| 1641 | m_uiCamParPrecision = 0; |
---|
| 1642 | m_bCamParInSliceHeader = false; |
---|
| 1643 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
| 1644 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
| 1645 | |
---|
[5] | 1646 | #if DEPTH_MAP_GENERATION |
---|
[2] | 1647 | m_uiPredDepthMapGeneration = 0; |
---|
| 1648 | m_uiPdmPrecision = 0; |
---|
| 1649 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
| 1650 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
[5] | 1651 | #endif |
---|
| 1652 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 1653 | m_uiMultiviewMvPredMode = 0; |
---|
| 1654 | #endif |
---|
[2] | 1655 | |
---|
[56] | 1656 | ::memset( m_aiUsableInterViewRefs, 0, sizeof( m_aiUsableInterViewRefs ) ); |
---|
[189] | 1657 | |
---|
| 1658 | #if RWTH_SDC_DLT_B0036 |
---|
| 1659 | m_bUseDLT = false; |
---|
| 1660 | |
---|
| 1661 | m_uiBitsPerDepthValue = g_uiBitDepth; |
---|
| 1662 | m_uiNumDepthmapValues = 0; |
---|
| 1663 | m_uiDepthValue2Idx = NULL; |
---|
| 1664 | m_uiIdx2DepthValue = NULL; |
---|
| 1665 | #endif |
---|
[2] | 1666 | } |
---|
| 1667 | |
---|
| 1668 | TComSPS::~TComSPS() |
---|
| 1669 | { |
---|
[56] | 1670 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
| 1671 | { |
---|
| 1672 | delete [] m_puiColumnWidth; |
---|
| 1673 | m_puiColumnWidth = NULL; |
---|
| 1674 | } |
---|
| 1675 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
| 1676 | { |
---|
| 1677 | delete [] m_puiRowHeight; |
---|
| 1678 | m_puiRowHeight = NULL; |
---|
| 1679 | } |
---|
[2] | 1680 | } |
---|
| 1681 | |
---|
[189] | 1682 | #if RWTH_SDC_DLT_B0036 |
---|
| 1683 | Void TComSPS::setDepthLUTs(UInt* uidx2DepthValue, UInt uiNumDepthValues) |
---|
| 1684 | { |
---|
| 1685 | UInt uiMaxDepthValue = g_uiIBDI_MAX; |
---|
| 1686 | |
---|
| 1687 | // allocate some memory |
---|
| 1688 | if( m_uiNumDepthmapValues == 0 ) |
---|
| 1689 | { |
---|
| 1690 | m_uiNumDepthmapValues = uiMaxDepthValue+1; |
---|
| 1691 | m_uiBitsPerDepthValue = (UInt)ceil(Log2(m_uiNumDepthmapValues)); |
---|
| 1692 | |
---|
| 1693 | m_uiDepthValue2Idx = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues); |
---|
| 1694 | m_uiIdx2DepthValue = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues); |
---|
| 1695 | |
---|
| 1696 | //default mapping |
---|
| 1697 | for (Int i=0; i<m_uiNumDepthmapValues; i++) |
---|
| 1698 | { |
---|
| 1699 | m_uiDepthValue2Idx[i] = i; |
---|
| 1700 | m_uiIdx2DepthValue[i] = i; |
---|
| 1701 | } |
---|
| 1702 | } |
---|
| 1703 | |
---|
| 1704 | if( uidx2DepthValue == NULL || uiNumDepthValues == 0 ) // default mapping only |
---|
| 1705 | return; |
---|
| 1706 | |
---|
| 1707 | // copy idx2DepthValue to internal array |
---|
| 1708 | memcpy(m_uiIdx2DepthValue, uidx2DepthValue, uiNumDepthValues*sizeof(UInt)); |
---|
| 1709 | |
---|
| 1710 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
| 1711 | { |
---|
| 1712 | Int iIdxDown = 0; |
---|
| 1713 | Int iIdxUp = uiNumDepthValues-1; |
---|
| 1714 | Bool bFound = false; |
---|
| 1715 | |
---|
| 1716 | // iterate over indices to find lower closest depth |
---|
| 1717 | Int i = 1; |
---|
| 1718 | while(!bFound && i<uiNumDepthValues) |
---|
| 1719 | { |
---|
| 1720 | if( m_uiIdx2DepthValue[i] > p ) |
---|
| 1721 | { |
---|
| 1722 | iIdxDown = i-1; |
---|
| 1723 | bFound = true; |
---|
| 1724 | } |
---|
| 1725 | |
---|
| 1726 | i++; |
---|
| 1727 | } |
---|
| 1728 | // iterate over indices to find upper closest depth |
---|
| 1729 | i = uiNumDepthValues-2; |
---|
| 1730 | bFound = false; |
---|
| 1731 | while(!bFound && i>=0) |
---|
| 1732 | { |
---|
| 1733 | if( m_uiIdx2DepthValue[i] < p ) |
---|
| 1734 | { |
---|
| 1735 | iIdxUp = i+1; |
---|
| 1736 | bFound = true; |
---|
| 1737 | } |
---|
| 1738 | |
---|
| 1739 | i--; |
---|
| 1740 | } |
---|
| 1741 | |
---|
| 1742 | // assert monotony |
---|
| 1743 | assert(iIdxDown<=iIdxUp); |
---|
| 1744 | |
---|
| 1745 | // assign closer depth value/idx |
---|
| 1746 | if( abs(p-(Int)m_uiIdx2DepthValue[iIdxDown]) < abs(p-(Int)m_uiIdx2DepthValue[iIdxUp]) ) |
---|
| 1747 | { |
---|
| 1748 | m_uiDepthValue2Idx[p] = iIdxDown; |
---|
| 1749 | } |
---|
| 1750 | else |
---|
| 1751 | { |
---|
| 1752 | m_uiDepthValue2Idx[p] = iIdxUp; |
---|
| 1753 | } |
---|
| 1754 | |
---|
| 1755 | } |
---|
| 1756 | |
---|
| 1757 | // update globals |
---|
| 1758 | m_uiNumDepthmapValues = uiNumDepthValues; |
---|
| 1759 | m_uiBitsPerDepthValue = (UInt)ceil(Log2(m_uiNumDepthmapValues)); |
---|
| 1760 | } |
---|
| 1761 | #endif |
---|
| 1762 | |
---|
[2] | 1763 | TComPPS::TComPPS() |
---|
[56] | 1764 | : m_PPSId (0) |
---|
| 1765 | , m_SPSId (0) |
---|
| 1766 | , m_picInitQPMinus26 (0) |
---|
| 1767 | , m_useDQP (false) |
---|
| 1768 | , m_bConstrainedIntraPred (false) |
---|
| 1769 | , m_pcSPS (NULL) |
---|
| 1770 | , m_uiMaxCuDQPDepth (0) |
---|
| 1771 | , m_uiMinCuDQPSize (0) |
---|
| 1772 | , m_iChromaQpOffset (0) |
---|
| 1773 | , m_iChromaQpOffset2nd (0) |
---|
| 1774 | #if !RPS_IN_SPS |
---|
| 1775 | , m_bLongTermRefsPresent (false) |
---|
| 1776 | #endif |
---|
| 1777 | #if !H0566_TLA |
---|
| 1778 | , m_uiNumTlayerSwitchingFlags (0) |
---|
| 1779 | #endif |
---|
| 1780 | , m_iSliceGranularity (0) |
---|
| 1781 | , m_iTileBehaviorControlPresentFlag (0) |
---|
| 1782 | , m_bLFCrossTileBoundaryFlag (true) |
---|
| 1783 | , m_iColumnRowInfoPresent (0) |
---|
| 1784 | , m_iUniformSpacingIdr (0) |
---|
| 1785 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 1786 | , m_iTileBoundaryIndependenceIdr (0) |
---|
| 1787 | #endif |
---|
| 1788 | , m_iNumColumnsMinus1 (0) |
---|
| 1789 | , m_puiColumnWidth (NULL) |
---|
| 1790 | , m_iNumRowsMinus1 (0) |
---|
| 1791 | , m_puiRowHeight (NULL) |
---|
| 1792 | #if !WPP_SIMPLIFICATION |
---|
| 1793 | , m_iEntropyCodingSynchro (0) |
---|
| 1794 | , m_bCabacIstateReset (false) |
---|
| 1795 | #endif |
---|
| 1796 | , m_iNumSubstreams (1) |
---|
| 1797 | #if MULTIBITS_DATA_HIDING |
---|
| 1798 | , m_signHideFlag(0) |
---|
| 1799 | , m_signHidingThreshold(0) |
---|
| 1800 | #endif |
---|
| 1801 | #if CABAC_INIT_FLAG |
---|
| 1802 | , m_cabacInitPresentFlag (false) |
---|
| 1803 | , m_encCABACTableIdx (0) |
---|
[189] | 1804 | #if FIX_POZNAN_CABAC_INIT_FLAG |
---|
[101] | 1805 | , m_encPrevPOC (0) |
---|
[56] | 1806 | #endif |
---|
[101] | 1807 | #endif |
---|
[2] | 1808 | { |
---|
[56] | 1809 | #if !H0566_TLA |
---|
| 1810 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
| 1811 | { |
---|
| 1812 | m_abTLayerSwitchingFlag[i] = false; |
---|
| 1813 | } |
---|
[42] | 1814 | #endif |
---|
[2] | 1815 | } |
---|
| 1816 | |
---|
| 1817 | TComPPS::~TComPPS() |
---|
| 1818 | { |
---|
[56] | 1819 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
| 1820 | { |
---|
| 1821 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
| 1822 | m_puiColumnWidth = NULL; |
---|
| 1823 | } |
---|
| 1824 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
| 1825 | { |
---|
| 1826 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
| 1827 | m_puiRowHeight = NULL; |
---|
| 1828 | } |
---|
[2] | 1829 | } |
---|
| 1830 | |
---|
| 1831 | Void |
---|
| 1832 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
| 1833 | { |
---|
[210] | 1834 | #if !QC_MVHEVC_B0046 |
---|
[2] | 1835 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
| 1836 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
| 1837 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
[210] | 1838 | #endif |
---|
[2] | 1839 | m_uiViewId = uiViewId; |
---|
| 1840 | m_iViewOrderIdx = iViewOrderIdx; |
---|
| 1841 | m_bDepth = false; |
---|
| 1842 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
| 1843 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
| 1844 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
| 1845 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
[210] | 1846 | #if !QC_MVHEVC_B0046 |
---|
[2] | 1847 | if( !m_bCamParInSliceHeader ) |
---|
| 1848 | { |
---|
| 1849 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
| 1850 | { |
---|
| 1851 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
| 1852 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
| 1853 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
| 1854 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
| 1855 | } |
---|
| 1856 | } |
---|
[210] | 1857 | #endif |
---|
[2] | 1858 | } |
---|
| 1859 | |
---|
| 1860 | Void |
---|
| 1861 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
| 1862 | { |
---|
| 1863 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
| 1864 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
| 1865 | |
---|
| 1866 | m_uiViewId = uiViewId; |
---|
| 1867 | m_iViewOrderIdx = iViewOrderIdx; |
---|
| 1868 | m_bDepth = true; |
---|
| 1869 | m_uiCamParPrecision = 0; |
---|
| 1870 | m_bCamParInSliceHeader = false; |
---|
| 1871 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
| 1872 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
| 1873 | } |
---|
| 1874 | |
---|
[5] | 1875 | #if DEPTH_MAP_GENERATION |
---|
[2] | 1876 | Void |
---|
| 1877 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
[5] | 1878 | { |
---|
[2] | 1879 | AOF( m_uiViewId == uiViewId ); |
---|
| 1880 | AOF( m_bDepth == bIsDepth ); |
---|
| 1881 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
| 1882 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
| 1883 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
[56] | 1884 | |
---|
[2] | 1885 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
[5] | 1886 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
[2] | 1887 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
[5] | 1888 | #endif |
---|
[56] | 1889 | |
---|
[2] | 1890 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
| 1891 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
| 1892 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
| 1893 | if( m_uiPredDepthMapGeneration ) |
---|
| 1894 | { |
---|
| 1895 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
| 1896 | { |
---|
| 1897 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
| 1898 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
| 1899 | } |
---|
| 1900 | } |
---|
| 1901 | } |
---|
[5] | 1902 | #endif |
---|
[56] | 1903 | |
---|
| 1904 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 1905 | : m_numberOfPictures (0) |
---|
| 1906 | , m_numberOfNegativePictures (0) |
---|
| 1907 | , m_numberOfPositivePictures (0) |
---|
| 1908 | , m_numberOfLongtermPictures (0) |
---|
| 1909 | , m_interRPSPrediction (0) |
---|
| 1910 | , m_deltaRIdxMinus1 (0) |
---|
| 1911 | , m_deltaRPS (0) |
---|
| 1912 | , m_numRefIdc (0) |
---|
| 1913 | { |
---|
| 1914 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 1915 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 1916 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 1917 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
| 1918 | } |
---|
| 1919 | |
---|
| 1920 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 1921 | { |
---|
| 1922 | } |
---|
| 1923 | |
---|
| 1924 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 1925 | { |
---|
| 1926 | m_used[bufferNum] = used; |
---|
| 1927 | } |
---|
| 1928 | |
---|
| 1929 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 1930 | { |
---|
| 1931 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 1932 | } |
---|
| 1933 | |
---|
| 1934 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 1935 | { |
---|
| 1936 | m_numberOfPictures = numberOfPictures; |
---|
| 1937 | } |
---|
| 1938 | |
---|
| 1939 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
| 1940 | { |
---|
| 1941 | return m_used[bufferNum]; |
---|
| 1942 | } |
---|
| 1943 | |
---|
| 1944 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
| 1945 | { |
---|
| 1946 | return m_deltaPOC[bufferNum]; |
---|
| 1947 | } |
---|
| 1948 | |
---|
| 1949 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
| 1950 | { |
---|
| 1951 | return m_numberOfPictures; |
---|
| 1952 | } |
---|
| 1953 | |
---|
| 1954 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
| 1955 | { |
---|
| 1956 | return m_POC[bufferNum]; |
---|
| 1957 | } |
---|
| 1958 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 1959 | { |
---|
| 1960 | m_POC[bufferNum] = POC; |
---|
| 1961 | } |
---|
| 1962 | |
---|
| 1963 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
| 1964 | * \param uiBufferNum |
---|
| 1965 | * \param iRefIdc |
---|
| 1966 | * \returns Void |
---|
| 1967 | */ |
---|
| 1968 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 1969 | { |
---|
| 1970 | m_refIdc[bufferNum] = refIdc; |
---|
| 1971 | } |
---|
| 1972 | |
---|
| 1973 | /** get the reference idc value at uiBufferNum |
---|
| 1974 | * \param uiBufferNum |
---|
| 1975 | * \returns Int |
---|
| 1976 | */ |
---|
| 1977 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
| 1978 | { |
---|
| 1979 | return m_refIdc[bufferNum]; |
---|
| 1980 | } |
---|
| 1981 | |
---|
| 1982 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 1983 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 1984 | * +ve values are in increasing order. |
---|
| 1985 | * \returns Void |
---|
| 1986 | */ |
---|
| 1987 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 1988 | { |
---|
| 1989 | // sort in increasing order (smallest first) |
---|
| 1990 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
| 1991 | { |
---|
| 1992 | Int deltaPOC = getDeltaPOC(j); |
---|
| 1993 | Bool used = getUsed(j); |
---|
| 1994 | for (Int k=j-1; k >= 0; k--) |
---|
| 1995 | { |
---|
| 1996 | Int temp = getDeltaPOC(k); |
---|
| 1997 | if (deltaPOC < temp) |
---|
| 1998 | { |
---|
| 1999 | setDeltaPOC(k+1, temp); |
---|
| 2000 | setUsed(k+1, getUsed(k)); |
---|
| 2001 | setDeltaPOC(k, deltaPOC); |
---|
| 2002 | setUsed(k, used); |
---|
| 2003 | } |
---|
| 2004 | } |
---|
| 2005 | } |
---|
| 2006 | // flip the negative values to largest first |
---|
| 2007 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2008 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
| 2009 | { |
---|
| 2010 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2011 | Bool used = getUsed(j); |
---|
| 2012 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2013 | setUsed(j, getUsed(k)); |
---|
| 2014 | setDeltaPOC(k, deltaPOC); |
---|
| 2015 | setUsed(k, used); |
---|
| 2016 | } |
---|
| 2017 | } |
---|
| 2018 | |
---|
| 2019 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2020 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2021 | * \returns Void |
---|
| 2022 | */ |
---|
| 2023 | Void TComReferencePictureSet::printDeltaPOC() |
---|
| 2024 | { |
---|
| 2025 | printf("DeltaPOC = { "); |
---|
| 2026 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2027 | { |
---|
| 2028 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
| 2029 | } |
---|
| 2030 | if (getInterRPSPrediction()) |
---|
| 2031 | { |
---|
| 2032 | printf("}, RefIdc = { "); |
---|
| 2033 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2034 | { |
---|
| 2035 | printf("%d ", getRefIdc(j)); |
---|
| 2036 | } |
---|
| 2037 | } |
---|
| 2038 | printf("}\n"); |
---|
| 2039 | } |
---|
| 2040 | |
---|
| 2041 | TComRPSList::TComRPSList() |
---|
| 2042 | { |
---|
| 2043 | } |
---|
| 2044 | |
---|
| 2045 | TComRPSList::~TComRPSList() |
---|
| 2046 | { |
---|
| 2047 | } |
---|
| 2048 | |
---|
| 2049 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
| 2050 | { |
---|
| 2051 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2052 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
| 2053 | } |
---|
| 2054 | |
---|
| 2055 | Void TComRPSList::destroy() |
---|
| 2056 | { |
---|
| 2057 | delete [] m_referencePictureSets; |
---|
| 2058 | m_numberOfReferencePictureSets = 0; |
---|
| 2059 | m_referencePictureSets = NULL; |
---|
| 2060 | } |
---|
| 2061 | |
---|
| 2062 | |
---|
| 2063 | |
---|
| 2064 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
| 2065 | { |
---|
| 2066 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
| 2067 | } |
---|
| 2068 | |
---|
| 2069 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
| 2070 | { |
---|
| 2071 | return m_numberOfReferencePictureSets; |
---|
| 2072 | } |
---|
| 2073 | |
---|
| 2074 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
| 2075 | { |
---|
| 2076 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2077 | } |
---|
| 2078 | |
---|
| 2079 | TComRefPicListModification::TComRefPicListModification() |
---|
| 2080 | : m_bRefPicListModificationFlagL0 (false) |
---|
| 2081 | , m_bRefPicListModificationFlagL1 (false) |
---|
| 2082 | #if !H0137_0138_LIST_MODIFICATION |
---|
| 2083 | , m_uiNumberOfRefPicListModificationsL0 (0) |
---|
| 2084 | , m_uiNumberOfRefPicListModificationsL1 (0) |
---|
| 2085 | #endif |
---|
| 2086 | { |
---|
| 2087 | #if !H0137_0138_LIST_MODIFICATION |
---|
| 2088 | ::memset( m_ListIdcL0, 0, sizeof(m_ListIdcL0) ); |
---|
| 2089 | #endif |
---|
| 2090 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2091 | #if !H0137_0138_LIST_MODIFICATION |
---|
| 2092 | ::memset( m_ListIdcL1, 0, sizeof(m_ListIdcL1) ); |
---|
| 2093 | #endif |
---|
| 2094 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2095 | } |
---|
| 2096 | |
---|
| 2097 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2098 | { |
---|
| 2099 | } |
---|
| 2100 | |
---|
| 2101 | TComAPS::TComAPS() |
---|
| 2102 | { |
---|
| 2103 | m_apsID = 0; |
---|
| 2104 | m_bAlfEnabled = false; |
---|
| 2105 | m_bSaoEnabled = false; |
---|
| 2106 | m_pSaoParam = NULL; |
---|
| 2107 | #if LCU_SYNTAX_ALF |
---|
| 2108 | m_alfParamSet = NULL; |
---|
| 2109 | #else |
---|
| 2110 | m_pAlfParam = NULL; |
---|
| 2111 | #endif |
---|
| 2112 | m_scalingList = NULL; |
---|
| 2113 | m_scalingListEnabled = false; |
---|
| 2114 | } |
---|
| 2115 | |
---|
| 2116 | TComAPS::~TComAPS() |
---|
| 2117 | { |
---|
| 2118 | |
---|
| 2119 | } |
---|
| 2120 | |
---|
| 2121 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
| 2122 | { |
---|
| 2123 | m_apsID = src.m_apsID; |
---|
| 2124 | m_loopFilterOffsetInAPS = src.m_loopFilterOffsetInAPS; |
---|
| 2125 | m_loopFilterDisable = src.m_loopFilterDisable; |
---|
| 2126 | m_loopFilterBetaOffsetDiv2 = src.m_loopFilterBetaOffsetDiv2; |
---|
| 2127 | m_loopFilterTcOffsetDiv2 = src.m_loopFilterTcOffsetDiv2; |
---|
| 2128 | m_bAlfEnabled = src.m_bAlfEnabled; |
---|
| 2129 | m_bSaoEnabled = src.m_bSaoEnabled; |
---|
| 2130 | m_pSaoParam = src.m_pSaoParam; |
---|
| 2131 | #if LCU_SYNTAX_ALF |
---|
| 2132 | m_alfParamSet = src.m_alfParamSet; |
---|
| 2133 | #else |
---|
| 2134 | m_pAlfParam = src.m_pAlfParam; |
---|
| 2135 | #endif |
---|
| 2136 | m_scalingList = src.m_scalingList; |
---|
| 2137 | m_scalingListEnabled = src.m_scalingListEnabled; |
---|
| 2138 | #if SAO_UNIT_INTERLEAVING |
---|
| 2139 | m_saoInterleavingFlag = src.m_saoInterleavingFlag; |
---|
| 2140 | #endif |
---|
| 2141 | |
---|
| 2142 | return *this; |
---|
| 2143 | } |
---|
| 2144 | |
---|
| 2145 | Void TComAPS::createSaoParam() |
---|
| 2146 | { |
---|
| 2147 | m_pSaoParam = new SAOParam; |
---|
| 2148 | } |
---|
| 2149 | |
---|
| 2150 | Void TComAPS::destroySaoParam() |
---|
| 2151 | { |
---|
| 2152 | if(m_pSaoParam != NULL) |
---|
| 2153 | { |
---|
| 2154 | delete m_pSaoParam; |
---|
| 2155 | m_pSaoParam = NULL; |
---|
| 2156 | } |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | Void TComAPS::createAlfParam() |
---|
| 2160 | { |
---|
| 2161 | #if LCU_SYNTAX_ALF |
---|
| 2162 | m_alfParamSet = new AlfParamSet; |
---|
| 2163 | #else |
---|
| 2164 | m_pAlfParam = new ALFParam; |
---|
| 2165 | #endif |
---|
| 2166 | } |
---|
| 2167 | Void TComAPS::destroyAlfParam() |
---|
| 2168 | { |
---|
| 2169 | #if LCU_SYNTAX_ALF |
---|
| 2170 | if(m_alfParamSet != NULL) |
---|
| 2171 | { |
---|
| 2172 | delete m_alfParamSet; |
---|
| 2173 | m_alfParamSet = NULL; |
---|
| 2174 | } |
---|
| 2175 | #else |
---|
| 2176 | if(m_pAlfParam != NULL) |
---|
| 2177 | { |
---|
| 2178 | delete m_pAlfParam; |
---|
| 2179 | m_pAlfParam = NULL; |
---|
| 2180 | } |
---|
| 2181 | #endif |
---|
| 2182 | } |
---|
| 2183 | |
---|
| 2184 | Void TComAPS::createScalingList() |
---|
| 2185 | { |
---|
| 2186 | m_scalingList = new TComScalingList; |
---|
| 2187 | } |
---|
| 2188 | Void TComAPS::destroyScalingList() |
---|
| 2189 | { |
---|
| 2190 | delete m_scalingList; |
---|
| 2191 | } |
---|
| 2192 | |
---|
| 2193 | TComScalingList::TComScalingList() |
---|
| 2194 | { |
---|
| 2195 | init(); |
---|
| 2196 | } |
---|
| 2197 | TComScalingList::~TComScalingList() |
---|
| 2198 | { |
---|
| 2199 | destroy(); |
---|
| 2200 | } |
---|
| 2201 | |
---|
| 2202 | /** set default quantization matrix to array |
---|
| 2203 | */ |
---|
| 2204 | Void TComSlice::setDefaultScalingList() |
---|
| 2205 | { |
---|
| 2206 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2207 | { |
---|
| 2208 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2209 | { |
---|
| 2210 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
| 2211 | } |
---|
| 2212 | } |
---|
| 2213 | } |
---|
| 2214 | /** check if use default quantization matrix |
---|
| 2215 | * \returns true if use default quantization matrix in all size |
---|
| 2216 | */ |
---|
| 2217 | #if SCALING_LIST |
---|
| 2218 | Bool TComSlice::checkDefaultScalingList() |
---|
| 2219 | { |
---|
| 2220 | UInt defaultCounter=0; |
---|
| 2221 | |
---|
| 2222 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2223 | { |
---|
| 2224 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2225 | { |
---|
| 2226 | if(getScalingList()->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
| 2227 | { |
---|
| 2228 | defaultCounter++; |
---|
| 2229 | } |
---|
| 2230 | } |
---|
| 2231 | } |
---|
| 2232 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
| 2233 | } |
---|
| 2234 | #else |
---|
| 2235 | Bool TComSlice::checkDefaultScalingList() |
---|
| 2236 | { |
---|
| 2237 | UInt i; |
---|
| 2238 | Int *dst=0; |
---|
| 2239 | Int *src=0; |
---|
| 2240 | UInt defaultCounter=0; |
---|
| 2241 | |
---|
| 2242 | //4x4 |
---|
| 2243 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
| 2244 | { |
---|
| 2245 | src = (i<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
| 2246 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_4x4,i); |
---|
| 2247 | if(::memcmp(dst,src,sizeof(UInt)*16) == 0) defaultCounter++; |
---|
| 2248 | } |
---|
| 2249 | |
---|
| 2250 | //8x8 |
---|
| 2251 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
| 2252 | { |
---|
| 2253 | src = (i<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2254 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_8x8,i); |
---|
| 2255 | if(::memcmp(dst,src,sizeof(UInt)*64) == 0) defaultCounter++; |
---|
| 2256 | } |
---|
| 2257 | //16x16 |
---|
| 2258 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
| 2259 | { |
---|
| 2260 | src = (i<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
| 2261 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_16x16,i); |
---|
| 2262 | if(::memcmp(dst,src,sizeof(UInt)*256) == 0) defaultCounter++; |
---|
| 2263 | } |
---|
| 2264 | //32x32 |
---|
| 2265 | for(i=0;i<SCALING_LIST_NUM_32x32;i++) |
---|
| 2266 | { |
---|
| 2267 | src = (i<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
| 2268 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_32x32,i*3); |
---|
| 2269 | if(::memcmp(dst,src,sizeof(UInt)*1024) == 0) defaultCounter++; |
---|
| 2270 | } |
---|
| 2271 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
| 2272 | } |
---|
| 2273 | #endif |
---|
| 2274 | /** get scaling matrix from RefMatrixID |
---|
| 2275 | * \param sizeId size index |
---|
| 2276 | * \param Index of input matrix |
---|
| 2277 | * \param Index of reference matrix |
---|
| 2278 | */ |
---|
| 2279 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 2280 | { |
---|
| 2281 | #if SCALING_LIST |
---|
| 2282 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2283 | #else |
---|
| 2284 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*g_scalingListSize[sizeId]); |
---|
| 2285 | #endif |
---|
| 2286 | } |
---|
| 2287 | /** parse syntax infomation |
---|
| 2288 | * \param pchFile syntax infomation |
---|
| 2289 | * \returns false if successful |
---|
| 2290 | */ |
---|
| 2291 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
| 2292 | { |
---|
| 2293 | FILE *fp; |
---|
| 2294 | Char line[1024]; |
---|
| 2295 | UInt sizeIdc,listIdc; |
---|
| 2296 | UInt i,size = 0; |
---|
| 2297 | Int *src=0,data; |
---|
| 2298 | Char *ret; |
---|
| 2299 | UInt retval; |
---|
| 2300 | |
---|
| 2301 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
| 2302 | { |
---|
| 2303 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
| 2304 | return true; |
---|
| 2305 | } |
---|
| 2306 | |
---|
| 2307 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2308 | { |
---|
| 2309 | #if SCALING_LIST |
---|
| 2310 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 2311 | #else |
---|
| 2312 | size = g_scalingListSize[sizeIdc]; |
---|
| 2313 | #endif |
---|
| 2314 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
| 2315 | { |
---|
| 2316 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 2317 | |
---|
| 2318 | fseek(fp,0,0); |
---|
| 2319 | do |
---|
| 2320 | { |
---|
| 2321 | ret = fgets(line, 1024, fp); |
---|
| 2322 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2323 | { |
---|
| 2324 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2325 | return true; |
---|
| 2326 | } |
---|
| 2327 | } |
---|
| 2328 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
| 2329 | for (i=0; i<size; i++) |
---|
| 2330 | { |
---|
| 2331 | retval = fscanf(fp, "%d,", &data); |
---|
| 2332 | if (retval!=1) |
---|
| 2333 | { |
---|
| 2334 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2335 | return true; |
---|
| 2336 | } |
---|
| 2337 | src[i] = data; |
---|
| 2338 | } |
---|
| 2339 | #if SCALING_LIST |
---|
| 2340 | //set DC value for default matrix check |
---|
| 2341 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 2342 | |
---|
| 2343 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 2344 | { |
---|
| 2345 | fseek(fp,0,0); |
---|
| 2346 | do |
---|
| 2347 | { |
---|
| 2348 | ret = fgets(line, 1024, fp); |
---|
| 2349 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2350 | { |
---|
| 2351 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
| 2352 | return true; |
---|
| 2353 | } |
---|
| 2354 | } |
---|
| 2355 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
| 2356 | retval = fscanf(fp, "%d,", &data); |
---|
| 2357 | if (retval!=1) |
---|
| 2358 | { |
---|
| 2359 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2360 | return true; |
---|
| 2361 | } |
---|
| 2362 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 2363 | setScalingListDC(sizeIdc,listIdc,data); |
---|
| 2364 | } |
---|
| 2365 | #endif |
---|
| 2366 | } |
---|
| 2367 | } |
---|
| 2368 | fclose(fp); |
---|
| 2369 | return false; |
---|
| 2370 | } |
---|
| 2371 | |
---|
| 2372 | /** initialization process of quantization matrix array |
---|
| 2373 | */ |
---|
| 2374 | Void TComScalingList::init() |
---|
| 2375 | { |
---|
| 2376 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2377 | { |
---|
| 2378 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2379 | { |
---|
| 2380 | #if SCALING_LIST |
---|
| 2381 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
| 2382 | #else |
---|
| 2383 | m_scalingListCoef[sizeId][listId] = new Int [g_scalingListSize[sizeId]]; |
---|
| 2384 | #endif |
---|
| 2385 | } |
---|
| 2386 | } |
---|
| 2387 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
| 2388 | } |
---|
| 2389 | /** destroy quantization matrix array |
---|
| 2390 | */ |
---|
| 2391 | Void TComScalingList::destroy() |
---|
| 2392 | { |
---|
| 2393 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2394 | { |
---|
| 2395 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2396 | { |
---|
| 2397 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
| 2398 | } |
---|
| 2399 | } |
---|
| 2400 | } |
---|
| 2401 | /** get default address of quantization matrix |
---|
| 2402 | * \param sizeId size index |
---|
| 2403 | * \param listId list index |
---|
| 2404 | * \returns pointer of quantization matrix |
---|
| 2405 | */ |
---|
| 2406 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
| 2407 | { |
---|
| 2408 | Int *src = 0; |
---|
| 2409 | switch(sizeId) |
---|
| 2410 | { |
---|
| 2411 | case SCALING_LIST_4x4: |
---|
| 2412 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
| 2413 | break; |
---|
| 2414 | case SCALING_LIST_8x8: |
---|
| 2415 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2416 | break; |
---|
| 2417 | #if SCALING_LIST |
---|
| 2418 | case SCALING_LIST_16x16: |
---|
| 2419 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2420 | break; |
---|
| 2421 | case SCALING_LIST_32x32: |
---|
| 2422 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2423 | break; |
---|
| 2424 | #else |
---|
| 2425 | case SCALING_LIST_16x16: |
---|
| 2426 | src = (listId<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
| 2427 | break; |
---|
| 2428 | case SCALING_LIST_32x32: |
---|
| 2429 | src = (listId<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
| 2430 | break; |
---|
| 2431 | #endif |
---|
| 2432 | default: |
---|
| 2433 | assert(0); |
---|
| 2434 | src = NULL; |
---|
| 2435 | break; |
---|
| 2436 | } |
---|
| 2437 | return src; |
---|
| 2438 | } |
---|
| 2439 | /** process of default matrix |
---|
| 2440 | * \param sizeId size index |
---|
| 2441 | * \param Index of input matrix |
---|
| 2442 | */ |
---|
| 2443 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
| 2444 | { |
---|
| 2445 | #if SCALING_LIST |
---|
| 2446 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2447 | setUseDefaultScalingMatrixFlag(sizeId,listId,true); |
---|
| 2448 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 2449 | #else |
---|
| 2450 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*(Int)g_scalingListSize[sizeId]); |
---|
| 2451 | #endif |
---|
| 2452 | } |
---|
| 2453 | #if SCALING_LIST |
---|
| 2454 | /** check DC value of matrix for default matrix signaling |
---|
| 2455 | */ |
---|
| 2456 | Void TComScalingList::checkDcOfMatrix() |
---|
| 2457 | { |
---|
| 2458 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2459 | { |
---|
| 2460 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2461 | { |
---|
| 2462 | setUseDefaultScalingMatrixFlag(sizeId,listId,false); |
---|
| 2463 | //check default matrix? |
---|
| 2464 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 2465 | { |
---|
| 2466 | processDefaultMarix(sizeId, listId); |
---|
| 2467 | } |
---|
| 2468 | } |
---|
| 2469 | } |
---|
| 2470 | } |
---|
| 2471 | #endif |
---|
| 2472 | |
---|
| 2473 | ParameterSetManager::ParameterSetManager() |
---|
| 2474 | : m_spsMap(MAX_NUM_SPS) |
---|
| 2475 | , m_ppsMap(MAX_NUM_PPS) |
---|
| 2476 | , m_apsMap(MAX_NUM_APS) |
---|
[210] | 2477 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 2478 | , m_vpsMap(MAX_NUM_VPS) |
---|
| 2479 | #endif |
---|
[56] | 2480 | { |
---|
| 2481 | } |
---|
| 2482 | |
---|
| 2483 | |
---|
| 2484 | ParameterSetManager::~ParameterSetManager() |
---|
| 2485 | { |
---|
| 2486 | } |
---|
| 2487 | |
---|
| 2488 | //! \} |
---|