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