[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 | * |
---|
[608] | 6 | * Copyright (c) 2010-2013, 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" |
---|
[608] | 41 | #include "TLibEncoder/TEncSbac.h" |
---|
| 42 | #include "TLibDecoder/TDecSbac.h" |
---|
[2] | 43 | |
---|
[56] | 44 | //! \ingroup TLibCommon |
---|
| 45 | //! \{ |
---|
| 46 | |
---|
[2] | 47 | TComSlice::TComSlice() |
---|
[56] | 48 | : m_iPPSId ( -1 ) |
---|
| 49 | , m_iPOC ( 0 ) |
---|
| 50 | , m_iLastIDR ( 0 ) |
---|
[608] | 51 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
[56] | 52 | , m_eSliceType ( I_SLICE ) |
---|
| 53 | , m_iSliceQp ( 0 ) |
---|
[608] | 54 | , m_dependentSliceSegmentFlag ( false ) |
---|
[56] | 55 | #if ADAPTIVE_QP_SELECTION |
---|
| 56 | , m_iSliceQpBase ( 0 ) |
---|
[2] | 57 | #endif |
---|
[608] | 58 | , m_deblockingFilterDisable ( false ) |
---|
| 59 | , m_deblockingFilterOverrideFlag ( false ) |
---|
| 60 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
| 61 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
[56] | 62 | , m_bCheckLDC ( false ) |
---|
| 63 | , m_iSliceQpDelta ( 0 ) |
---|
[608] | 64 | , m_iSliceQpDeltaCb ( 0 ) |
---|
| 65 | , m_iSliceQpDeltaCr ( 0 ) |
---|
[56] | 66 | , m_iDepth ( 0 ) |
---|
| 67 | , m_bRefenced ( false ) |
---|
| 68 | , m_pcSPS ( NULL ) |
---|
| 69 | , m_pcPPS ( NULL ) |
---|
| 70 | , m_pcPic ( NULL ) |
---|
[608] | 71 | , m_colFromL0Flag ( 1 ) |
---|
[56] | 72 | , m_colRefIdx ( 0 ) |
---|
[608] | 73 | #if SAO_CHROMA_LAMBDA |
---|
[56] | 74 | , m_dLambdaLuma( 0.0 ) |
---|
| 75 | , m_dLambdaChroma( 0.0 ) |
---|
| 76 | #else |
---|
| 77 | , m_dLambda ( 0.0 ) |
---|
| 78 | #endif |
---|
| 79 | , m_uiTLayer ( 0 ) |
---|
| 80 | , m_bTLayerSwitchingFlag ( false ) |
---|
[608] | 81 | , m_sliceMode ( 0 ) |
---|
| 82 | , m_sliceArgument ( 0 ) |
---|
| 83 | , m_sliceCurStartCUAddr ( 0 ) |
---|
| 84 | , m_sliceCurEndCUAddr ( 0 ) |
---|
| 85 | , m_sliceIdx ( 0 ) |
---|
| 86 | , m_sliceSegmentMode ( 0 ) |
---|
| 87 | , m_sliceSegmentArgument ( 0 ) |
---|
| 88 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
| 89 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
| 90 | , m_nextSlice ( false ) |
---|
| 91 | , m_nextSliceSegment ( false ) |
---|
| 92 | , m_sliceBits ( 0 ) |
---|
| 93 | , m_sliceSegmentBits ( 0 ) |
---|
[56] | 94 | , m_bFinalized ( false ) |
---|
| 95 | , m_uiTileOffstForMultES ( 0 ) |
---|
| 96 | , m_puiSubstreamSizes ( NULL ) |
---|
| 97 | , m_cabacInitFlag ( false ) |
---|
[608] | 98 | , m_bLMvdL1Zero ( false ) |
---|
| 99 | , m_numEntryPointOffsets ( 0 ) |
---|
| 100 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
| 101 | , m_enableTMVPFlag ( true ) |
---|
| 102 | #if H_MV |
---|
[622] | 103 | , m_refPicSetInterLayer0 ( NULL ) |
---|
| 104 | , m_refPicSetInterLayer1 ( NULL ) |
---|
[608] | 105 | , m_layerId (0) |
---|
| 106 | , m_viewId (0) |
---|
[622] | 107 | , m_viewIndex (0) |
---|
[608] | 108 | #if H_3D |
---|
| 109 | , m_isDepth (false) |
---|
[56] | 110 | #endif |
---|
[622] | 111 | , m_pocResetFlag (false) |
---|
[608] | 112 | , m_discardableFlag (false) |
---|
| 113 | , m_interLayerPredEnabledFlag (false) |
---|
| 114 | , m_numInterLayerRefPicsMinus1 (0) |
---|
| 115 | #if H_3D_IC |
---|
[189] | 116 | , m_bApplyIC ( false ) |
---|
[443] | 117 | , m_icSkipParseFlag ( false ) |
---|
[189] | 118 | #endif |
---|
[608] | 119 | #if H_3D |
---|
| 120 | , m_depthToDisparityB ( NULL ) |
---|
| 121 | , m_depthToDisparityF ( NULL ) |
---|
[443] | 122 | #endif |
---|
[296] | 123 | #endif |
---|
[56] | 124 | { |
---|
[608] | 125 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
| 126 | |
---|
[2] | 127 | initEqualRef(); |
---|
[56] | 128 | |
---|
[608] | 129 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
[56] | 130 | { |
---|
[608] | 131 | m_list1IdxToList0Idx[idx] = -1; |
---|
| 132 | } |
---|
| 133 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
[56] | 134 | { |
---|
[608] | 135 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
| 136 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
| 137 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
| 138 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
| 139 | #if H_MV |
---|
| 140 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
| 141 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
| 142 | #endif |
---|
[56] | 143 | } |
---|
[608] | 144 | resetWpScaling(); |
---|
[2] | 145 | initWpAcDcParam(); |
---|
[608] | 146 | m_saoEnabledFlag = false; |
---|
| 147 | #if H_MV |
---|
| 148 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
[210] | 149 | { |
---|
[622] | 150 | m_interLayerPredLayerIdc[ i ] = i; |
---|
[210] | 151 | } |
---|
| 152 | #endif |
---|
[2] | 153 | } |
---|
| 154 | |
---|
| 155 | TComSlice::~TComSlice() |
---|
| 156 | { |
---|
[608] | 157 | delete[] m_puiSubstreamSizes; |
---|
| 158 | m_puiSubstreamSizes = NULL; |
---|
| 159 | #if H_3D |
---|
| 160 | for( UInt i = 0; i < getViewIndex(); i++ ) |
---|
[56] | 161 | { |
---|
[608] | 162 | if ( m_depthToDisparityB && m_depthToDisparityB[ i ] ) |
---|
[622] | 163 | { |
---|
[608] | 164 | delete[] m_depthToDisparityB [ i ]; |
---|
[622] | 165 | } |
---|
[608] | 166 | |
---|
| 167 | if ( m_depthToDisparityF && m_depthToDisparityF[ i ] ) |
---|
[622] | 168 | { |
---|
[608] | 169 | delete[] m_depthToDisparityF [ i ]; |
---|
[56] | 170 | } |
---|
[622] | 171 | } |
---|
[608] | 172 | |
---|
| 173 | if ( m_depthToDisparityF ) |
---|
[622] | 174 | { |
---|
[608] | 175 | delete[] m_depthToDisparityF; |
---|
[622] | 176 | } |
---|
[608] | 177 | |
---|
| 178 | m_depthToDisparityF = NULL; |
---|
| 179 | |
---|
| 180 | if ( m_depthToDisparityB ) |
---|
| 181 | delete[] m_depthToDisparityB; |
---|
| 182 | |
---|
| 183 | m_depthToDisparityB = NULL; |
---|
| 184 | #endif |
---|
[2] | 185 | } |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | Void TComSlice::initSlice() |
---|
| 189 | { |
---|
| 190 | m_aiNumRefIdx[0] = 0; |
---|
| 191 | m_aiNumRefIdx[1] = 0; |
---|
[5] | 192 | |
---|
[608] | 193 | m_colFromL0Flag = 1; |
---|
[56] | 194 | |
---|
| 195 | m_colRefIdx = 0; |
---|
[2] | 196 | initEqualRef(); |
---|
[56] | 197 | m_bCheckLDC = false; |
---|
[608] | 198 | m_iSliceQpDeltaCb = 0; |
---|
| 199 | m_iSliceQpDeltaCr = 0; |
---|
[56] | 200 | |
---|
[608] | 201 | #if H_3D_IV_MERGE |
---|
| 202 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM; |
---|
| 203 | #else |
---|
| 204 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
| 205 | #endif |
---|
[56] | 206 | |
---|
| 207 | m_bFinalized=false; |
---|
| 208 | |
---|
[608] | 209 | m_tileByteLocation.clear(); |
---|
[56] | 210 | m_cabacInitFlag = false; |
---|
| 211 | m_numEntryPointOffsets = 0; |
---|
[608] | 212 | m_enableTMVPFlag = true; |
---|
| 213 | #if H_3D_TMVP |
---|
| 214 | m_aiAlterRefIdx[0] = -1; |
---|
| 215 | m_aiAlterRefIdx[1] = -1; |
---|
[56] | 216 | #endif |
---|
[2] | 217 | } |
---|
| 218 | |
---|
[608] | 219 | Bool TComSlice::getRapPicFlag() |
---|
[56] | 220 | { |
---|
[608] | 221 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 222 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 223 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 224 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 225 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 226 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
[56] | 227 | } |
---|
| 228 | |
---|
| 229 | /** |
---|
| 230 | - allocate table to contain substream sizes to be written to the slice header. |
---|
| 231 | . |
---|
| 232 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
| 233 | */ |
---|
| 234 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
| 235 | { |
---|
| 236 | delete[] m_puiSubstreamSizes; |
---|
| 237 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
| 238 | } |
---|
| 239 | |
---|
[2] | 240 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
| 241 | { |
---|
| 242 | TComPic* pcPicExtract; |
---|
| 243 | TComPic* pcPicInsert; |
---|
[5] | 244 | |
---|
[2] | 245 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 246 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 247 | TComList<TComPic*>::iterator iterPicInsert; |
---|
[5] | 248 | |
---|
[2] | 249 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 250 | { |
---|
| 251 | iterPicExtract = rcListPic.begin(); |
---|
| 252 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
| 253 | pcPicExtract = *(iterPicExtract); |
---|
| 254 | pcPicExtract->setCurrSliceIdx(0); |
---|
[5] | 255 | |
---|
[2] | 256 | iterPicInsert = rcListPic.begin(); |
---|
| 257 | while (iterPicInsert != iterPicExtract) |
---|
| 258 | { |
---|
| 259 | pcPicInsert = *(iterPicInsert); |
---|
| 260 | pcPicInsert->setCurrSliceIdx(0); |
---|
| 261 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
| 262 | { |
---|
| 263 | break; |
---|
| 264 | } |
---|
[5] | 265 | |
---|
[2] | 266 | iterPicInsert++; |
---|
| 267 | } |
---|
[5] | 268 | |
---|
[2] | 269 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
[5] | 270 | |
---|
[2] | 271 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 272 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 273 | rcListPic.erase (iterPicExtract); |
---|
| 274 | } |
---|
| 275 | } |
---|
| 276 | |
---|
[608] | 277 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
| 278 | Int poc) |
---|
[2] | 279 | { |
---|
[56] | 280 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 281 | TComPic* pcPic = *(iterPic); |
---|
| 282 | while ( iterPic != rcListPic.end() ) |
---|
[2] | 283 | { |
---|
[608] | 284 | if(pcPic->getPOC() == poc) |
---|
[2] | 285 | { |
---|
[56] | 286 | break; |
---|
[2] | 287 | } |
---|
[56] | 288 | iterPic++; |
---|
| 289 | pcPic = *(iterPic); |
---|
[2] | 290 | } |
---|
[56] | 291 | return pcPic; |
---|
| 292 | } |
---|
[2] | 293 | |
---|
[56] | 294 | |
---|
[608] | 295 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
[56] | 296 | { |
---|
| 297 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 298 | TComPic* pcPic = *(iterPic); |
---|
| 299 | TComPic* pcStPic = pcPic; |
---|
[608] | 300 | |
---|
| 301 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
| 302 | if (!pocHasMsb) |
---|
| 303 | { |
---|
[655] | 304 | poc = poc & (pocCycle - 1); |
---|
[608] | 305 | } |
---|
| 306 | |
---|
[56] | 307 | while ( iterPic != rcListPic.end() ) |
---|
| 308 | { |
---|
| 309 | pcPic = *(iterPic); |
---|
[608] | 310 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
[56] | 311 | { |
---|
[608] | 312 | Int picPoc = pcPic->getPOC(); |
---|
| 313 | if (!pocHasMsb) |
---|
| 314 | { |
---|
[655] | 315 | picPoc = picPoc & (pocCycle - 1); |
---|
[608] | 316 | } |
---|
| 317 | |
---|
| 318 | if (poc == picPoc) |
---|
| 319 | { |
---|
[56] | 320 | if(pcPic->getIsLongTerm()) |
---|
[608] | 321 | { |
---|
[56] | 322 | return pcPic; |
---|
[608] | 323 | } |
---|
[56] | 324 | else |
---|
[608] | 325 | { |
---|
[56] | 326 | pcStPic = pcPic; |
---|
[608] | 327 | } |
---|
[56] | 328 | break; |
---|
| 329 | } |
---|
[608] | 330 | } |
---|
[56] | 331 | |
---|
| 332 | iterPic++; |
---|
| 333 | } |
---|
[608] | 334 | |
---|
[56] | 335 | return pcStPic; |
---|
[2] | 336 | } |
---|
| 337 | |
---|
[608] | 338 | Void TComSlice::setRefPOCList () |
---|
[56] | 339 | { |
---|
[608] | 340 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
[56] | 341 | { |
---|
[608] | 342 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
[56] | 343 | { |
---|
[608] | 344 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
| 345 | #if H_MV |
---|
| 346 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
| 347 | #endif |
---|
[56] | 348 | } |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | } |
---|
| 352 | |
---|
[608] | 353 | Void TComSlice::setList1IdxToList0Idx() |
---|
[56] | 354 | { |
---|
[608] | 355 | Int idxL0, idxL1; |
---|
| 356 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
[56] | 357 | { |
---|
[608] | 358 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
| 359 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
[56] | 360 | { |
---|
[608] | 361 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
| 362 | { |
---|
| 363 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
| 364 | break; |
---|
| 365 | } |
---|
[56] | 366 | } |
---|
| 367 | } |
---|
| 368 | } |
---|
[622] | 369 | #if !H_MV |
---|
| 370 | #if FIX1071 |
---|
| 371 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
| 372 | #else |
---|
| 373 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) |
---|
| 374 | #endif |
---|
| 375 | { |
---|
| 376 | #if FIX1071 |
---|
| 377 | if (!checkNumPocTotalCurr) |
---|
| 378 | #endif |
---|
| 379 | { |
---|
| 380 | if (m_eSliceType == I_SLICE) |
---|
| 381 | { |
---|
| 382 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 383 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 384 | |
---|
| 385 | return; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 389 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | TComPic* pcRefPic= NULL; |
---|
| 393 | TComPic* RefPicSetStCurr0[16]; |
---|
| 394 | TComPic* RefPicSetStCurr1[16]; |
---|
| 395 | TComPic* RefPicSetLtCurr[16]; |
---|
| 396 | UInt NumPocStCurr0 = 0; |
---|
| 397 | UInt NumPocStCurr1 = 0; |
---|
| 398 | UInt NumPocLtCurr = 0; |
---|
| 399 | Int i; |
---|
| 400 | |
---|
| 401 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
| 402 | { |
---|
| 403 | if(m_pcRPS->getUsed(i)) |
---|
| 404 | { |
---|
| 405 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 406 | pcRefPic->setIsLongTerm(0); |
---|
| 407 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 408 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 409 | NumPocStCurr0++; |
---|
| 410 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 411 | } |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
| 415 | { |
---|
| 416 | if(m_pcRPS->getUsed(i)) |
---|
| 417 | { |
---|
| 418 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 419 | pcRefPic->setIsLongTerm(0); |
---|
| 420 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 421 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 422 | NumPocStCurr1++; |
---|
| 423 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
| 428 | { |
---|
| 429 | if(m_pcRPS->getUsed(i)) |
---|
| 430 | { |
---|
| 431 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 432 | pcRefPic->setIsLongTerm(1); |
---|
| 433 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 434 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 435 | NumPocLtCurr++; |
---|
| 436 | } |
---|
| 437 | if(pcRefPic==NULL) |
---|
| 438 | { |
---|
| 439 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 440 | } |
---|
| 441 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | // ref_pic_list_init |
---|
| 445 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
| 446 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
| 447 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
| 448 | |
---|
| 449 | #if FIX1071 |
---|
| 450 | if (checkNumPocTotalCurr) |
---|
| 451 | { |
---|
| 452 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
[655] | 453 | // ?If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 454 | // ?Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
[622] | 455 | if (getRapPicFlag()) |
---|
| 456 | { |
---|
| 457 | assert(numPocTotalCurr == 0); |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | if (m_eSliceType == I_SLICE) |
---|
| 461 | { |
---|
| 462 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 463 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 464 | |
---|
| 465 | return; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | assert(numPocTotalCurr > 0); |
---|
| 469 | |
---|
| 470 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 471 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 472 | } |
---|
| 473 | #endif |
---|
| 474 | |
---|
| 475 | Int cIdx = 0; |
---|
| 476 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 477 | { |
---|
| 478 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
| 479 | } |
---|
| 480 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 481 | { |
---|
| 482 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
| 483 | } |
---|
| 484 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 485 | { |
---|
| 486 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
| 487 | } |
---|
| 488 | assert(cIdx == numPocTotalCurr); |
---|
| 489 | |
---|
| 490 | if (m_eSliceType==B_SLICE) |
---|
| 491 | { |
---|
| 492 | cIdx = 0; |
---|
| 493 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 494 | { |
---|
| 495 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
| 496 | } |
---|
| 497 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 498 | { |
---|
| 499 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
| 500 | } |
---|
| 501 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 502 | { |
---|
| 503 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
| 504 | } |
---|
| 505 | assert(cIdx == numPocTotalCurr); |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 509 | |
---|
| 510 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
| 511 | { |
---|
| 512 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
| 513 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
| 514 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
| 515 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
| 516 | } |
---|
| 517 | if ( m_eSliceType != B_SLICE ) |
---|
| 518 | { |
---|
| 519 | m_aiNumRefIdx[1] = 0; |
---|
| 520 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
| 521 | } |
---|
| 522 | else |
---|
| 523 | { |
---|
| 524 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
| 525 | { |
---|
| 526 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
| 527 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
| 528 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
| 529 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
| 530 | } |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | #else |
---|
| 535 | Void TComSlice::getTempRefPicLists( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1, |
---|
| 536 | std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int& numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
| 537 | { |
---|
| 538 | if (!checkNumPocTotalCurr) |
---|
| 539 | { |
---|
| 540 | if (m_eSliceType == I_SLICE) |
---|
| 541 | { |
---|
| 542 | return; |
---|
| 543 | } |
---|
| 544 | } |
---|
| 545 | |
---|
| 546 | TComPic* pcRefPic= NULL; |
---|
| 547 | TComPic* RefPicSetStCurr0[16]; |
---|
| 548 | TComPic* RefPicSetStCurr1[16]; |
---|
| 549 | TComPic* RefPicSetLtCurr[16]; |
---|
| 550 | UInt NumPocStCurr0 = 0; |
---|
| 551 | UInt NumPocStCurr1 = 0; |
---|
| 552 | UInt NumPocLtCurr = 0; |
---|
| 553 | Int i; |
---|
| 554 | |
---|
| 555 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
| 556 | { |
---|
| 557 | if(m_pcRPS->getUsed(i)) |
---|
| 558 | { |
---|
| 559 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 560 | pcRefPic->setIsLongTerm(0); |
---|
| 561 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 562 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 563 | NumPocStCurr0++; |
---|
| 564 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 565 | } |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
| 569 | { |
---|
| 570 | if(m_pcRPS->getUsed(i)) |
---|
| 571 | { |
---|
| 572 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 573 | pcRefPic->setIsLongTerm(0); |
---|
| 574 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 575 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 576 | NumPocStCurr1++; |
---|
| 577 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 578 | } |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
| 582 | { |
---|
| 583 | if(m_pcRPS->getUsed(i)) |
---|
| 584 | { |
---|
| 585 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 586 | pcRefPic->setIsLongTerm(1); |
---|
| 587 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 588 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 589 | NumPocLtCurr++; |
---|
| 590 | } |
---|
| 591 | if(pcRefPic==NULL) |
---|
| 592 | { |
---|
| 593 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 594 | } |
---|
| 595 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | Int numPocInterCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
| 599 | numPocTotalCurr = numPocInterCurr + getNumActiveRefLayerPics( ); |
---|
| 600 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
| 601 | |
---|
| 602 | if (checkNumPocTotalCurr) |
---|
| 603 | { |
---|
| 604 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
| 605 | // - If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 606 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 607 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
| 608 | { |
---|
| 609 | assert(numPocTotalCurr == 0); |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | if (m_eSliceType == I_SLICE) |
---|
| 613 | { |
---|
| 614 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 615 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 616 | |
---|
| 617 | return; |
---|
| 618 | } |
---|
| 619 | |
---|
| 620 | assert(numPocTotalCurr > 0); |
---|
| 621 | |
---|
| 622 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 623 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | std::vector<TComPic*>* refPicSetInterLayer[2] = { &refPicSetInterLayer0, &refPicSetInterLayer1}; |
---|
| 627 | Int numPocInterLayer[2] = { getNumActiveRefLayerPics0( ), getNumActiveRefLayerPics1( ) }; |
---|
| 628 | |
---|
| 629 | TComPic** refPicSetStCurr [2] = { RefPicSetStCurr0, RefPicSetStCurr1 }; |
---|
| 630 | Int numPocStCurr[2] = { NumPocStCurr0, NumPocStCurr1 }; |
---|
| 631 | |
---|
| 632 | for (Int li = 0; li < ((m_eSliceType==B_SLICE) ? 2 : 1); li++) |
---|
| 633 | { |
---|
| 634 | rpsCurrList [li].resize(MAX_NUM_REF+1,NULL ); |
---|
| 635 | usedAsLongTerm[li].resize(MAX_NUM_REF+1,false); |
---|
| 636 | |
---|
| 637 | Int cIdx = 0; |
---|
| 638 | for ( i=0; i < numPocStCurr[li]; i++, cIdx++) |
---|
| 639 | { |
---|
| 640 | rpsCurrList[li][cIdx] = refPicSetStCurr[li][i]; |
---|
| 641 | usedAsLongTerm [li][cIdx] = false; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | for ( i=0; i < numPocInterLayer[li]; i++, cIdx++) |
---|
| 645 | { |
---|
| 646 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[li])[i]; |
---|
| 647 | usedAsLongTerm [li][cIdx] = true; |
---|
| 648 | } |
---|
| 649 | |
---|
| 650 | for ( i=0; i < numPocStCurr[1-li]; i++, cIdx++) |
---|
| 651 | { |
---|
| 652 | rpsCurrList[li][cIdx] = refPicSetStCurr[1-li][i]; |
---|
| 653 | usedAsLongTerm [li][cIdx] = false; |
---|
| 654 | } |
---|
| 655 | |
---|
| 656 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 657 | { |
---|
| 658 | rpsCurrList[li][cIdx] = RefPicSetLtCurr[i]; |
---|
| 659 | usedAsLongTerm [li][cIdx] = true; |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | for ( i=0; i < numPocInterLayer[1-li]; i++, cIdx++) |
---|
| 663 | { |
---|
| 664 | assert( cIdx < MAX_NUM_REF ); |
---|
| 665 | rpsCurrList[li][cIdx] = (*refPicSetInterLayer[1-li])[i]; |
---|
| 666 | usedAsLongTerm [li][cIdx] = true; |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | assert(cIdx == numPocTotalCurr); |
---|
| 670 | } |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | Void TComSlice::setRefPicList( std::vector<TComPic*> rpsCurrList[2], std::vector<Bool> usedAsLongTerm[2], Int numPocTotalCurr, Bool checkNumPocTotalCurr ) |
---|
| 674 | |
---|
| 675 | { |
---|
| 676 | if (!checkNumPocTotalCurr) |
---|
| 677 | { |
---|
| 678 | if (m_eSliceType == I_SLICE) |
---|
| 679 | { |
---|
| 680 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 681 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 682 | |
---|
| 683 | return; |
---|
| 684 | } |
---|
| 685 | } |
---|
| 686 | |
---|
| 687 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 688 | |
---|
| 689 | for (Int li = 0; li < 2; li++) |
---|
| 690 | { |
---|
| 691 | if ( m_eSliceType == P_SLICE && li == 1 ) |
---|
| 692 | { |
---|
| 693 | m_aiNumRefIdx[1] = 0; |
---|
| 694 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
| 695 | } |
---|
| 696 | else |
---|
| 697 | { |
---|
| 698 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[ li ] - 1 ); rIdx ++) |
---|
| 699 | { |
---|
| 700 | Bool listModified = m_RefPicListModification.getRefPicListModificationFlagL( li ); |
---|
| 701 | Int orgIdx = listModified ? m_RefPicListModification.getRefPicSetIdxL(li, rIdx) : (rIdx % numPocTotalCurr); |
---|
| 702 | |
---|
| 703 | assert( rpsCurrList[li][ orgIdx ] != NULL ); |
---|
| 704 | m_apcRefPicList [li][rIdx] = rpsCurrList [li][ orgIdx ]; |
---|
| 705 | m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; |
---|
| 706 | } |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | } |
---|
| 710 | #endif |
---|
[608] | 711 | Int TComSlice::getNumRpsCurrTempList() |
---|
| 712 | { |
---|
| 713 | Int numRpsCurrTempList = 0; |
---|
| 714 | |
---|
| 715 | if (m_eSliceType == I_SLICE) |
---|
| 716 | { |
---|
| 717 | return 0; |
---|
| 718 | } |
---|
| 719 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
| 720 | { |
---|
| 721 | if(m_pcRPS->getUsed(i)) |
---|
| 722 | { |
---|
| 723 | numRpsCurrTempList++; |
---|
[2] | 724 | } |
---|
| 725 | } |
---|
[608] | 726 | #if H_MV |
---|
| 727 | numRpsCurrTempList = numRpsCurrTempList + getNumActiveRefLayerPics(); |
---|
| 728 | #endif |
---|
| 729 | return numRpsCurrTempList; |
---|
[2] | 730 | } |
---|
| 731 | |
---|
| 732 | Void TComSlice::initEqualRef() |
---|
| 733 | { |
---|
| 734 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 735 | { |
---|
| 736 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 737 | { |
---|
| 738 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 739 | { |
---|
| 740 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | } |
---|
[608] | 745 | #if H_3D |
---|
| 746 | #if H_3D_TMVP |
---|
| 747 | Void TComSlice::generateAlterRefforTMVP() |
---|
| 748 | { |
---|
| 749 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 750 | { |
---|
| 751 | if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0) |
---|
| 752 | continue; |
---|
[2] | 753 | |
---|
[608] | 754 | Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm(); |
---|
| 755 | for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ ) |
---|
[2] | 756 | { |
---|
[608] | 757 | if ( ( bZeroIdxLtFlag && !this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) || |
---|
| 758 | (!bZeroIdxLtFlag && this->getRefPic(RefPicList(uiRefListIdx), i)->getIsLongTerm() ) ) |
---|
| 759 | { |
---|
| 760 | this->setAlterRefIdx(RefPicList(uiRefListIdx),i); |
---|
| 761 | break; |
---|
| 762 | } |
---|
[2] | 763 | } |
---|
| 764 | } |
---|
| 765 | } |
---|
[608] | 766 | #endif |
---|
| 767 | Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset ) |
---|
| 768 | { |
---|
| 769 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
| 770 | { |
---|
| 771 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < m_viewIndex; uiBaseViewIndex++ ) |
---|
| 772 | { |
---|
| 773 | m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ m_viewIndex ]; |
---|
| 774 | m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [ m_viewIndex ][ uiBaseViewIndex ]; |
---|
| 775 | m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ m_viewIndex ]; |
---|
| 776 | m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[ m_viewIndex ][ uiBaseViewIndex ]; |
---|
| 777 | } |
---|
| 778 | } |
---|
| 779 | } |
---|
| 780 | #endif |
---|
[2] | 781 | |
---|
[56] | 782 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 783 | { |
---|
| 784 | Int i; |
---|
| 785 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
[608] | 786 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
[56] | 787 | TComSlice* preSlice; |
---|
| 788 | Int preColRefPOC; |
---|
| 789 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 790 | { |
---|
| 791 | preSlice = pic->getSlice(i); |
---|
| 792 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 793 | { |
---|
[608] | 794 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
[56] | 795 | if(currColRefPOC != preColRefPOC) |
---|
| 796 | { |
---|
| 797 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 798 | exit(EXIT_FAILURE); |
---|
| 799 | } |
---|
| 800 | else |
---|
| 801 | { |
---|
| 802 | break; |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | } |
---|
[608] | 807 | |
---|
[655] | 808 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
[56] | 809 | { |
---|
| 810 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 811 | { |
---|
| 812 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 813 | { |
---|
| 814 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 815 | } |
---|
| 816 | } |
---|
| 817 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 818 | { |
---|
| 819 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 820 | { |
---|
[608] | 821 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 822 | { |
---|
| 823 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
| 824 | } |
---|
| 825 | else |
---|
| 826 | { |
---|
[56] | 827 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 828 | } |
---|
| 829 | } |
---|
[608] | 830 | } |
---|
| 831 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
[56] | 832 | { |
---|
| 833 | pocCRA = getPOC(); |
---|
[655] | 834 | associatedIRAPType = getNalUnitType(); |
---|
[56] | 835 | } |
---|
[608] | 836 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 837 | { |
---|
| 838 | pocCRA = getPOC(); |
---|
[655] | 839 | associatedIRAPType = getNalUnitType(); |
---|
[608] | 840 | } |
---|
| 841 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 842 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 843 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 844 | { |
---|
| 845 | pocCRA = getPOC(); |
---|
[655] | 846 | associatedIRAPType = getNalUnitType(); |
---|
[608] | 847 | } |
---|
[56] | 848 | } |
---|
[2] | 849 | |
---|
[608] | 850 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 851 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
[2] | 852 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 853 | * \param rcListPic reference to the reference picture list |
---|
| 854 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
[608] | 855 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
| 856 | * are marked as "unused for reference" |
---|
| 857 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 858 | * Otherwise |
---|
[5] | 859 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
[608] | 860 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 861 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
[2] | 862 | * the bRefreshPending flag to false. |
---|
[608] | 863 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
[2] | 864 | * reference of the current picture. |
---|
| 865 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 866 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 867 | */ |
---|
[56] | 868 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
[2] | 869 | { |
---|
| 870 | TComPic* rpcPic; |
---|
[655] | 871 | setAssociatedIRAPPOC(pocCRA); |
---|
[608] | 872 | Int pocCurr = getPOC(); |
---|
[2] | 873 | |
---|
[608] | 874 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 875 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 876 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 877 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
| 878 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
[2] | 879 | { |
---|
| 880 | // mark all pictures as not used for reference |
---|
| 881 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 882 | while (iterPic != rcListPic.end()) |
---|
| 883 | { |
---|
| 884 | rpcPic = *(iterPic); |
---|
| 885 | rpcPic->setCurrSliceIdx(0); |
---|
[608] | 886 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
[2] | 887 | iterPic++; |
---|
| 888 | } |
---|
[608] | 889 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 890 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 891 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 892 | { |
---|
| 893 | pocCRA = pocCurr; |
---|
| 894 | } |
---|
[2] | 895 | } |
---|
[56] | 896 | else // CRA or No DR |
---|
[2] | 897 | { |
---|
[608] | 898 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
[2] | 899 | { |
---|
| 900 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 901 | while (iterPic != rcListPic.end()) |
---|
| 902 | { |
---|
| 903 | rpcPic = *(iterPic); |
---|
[608] | 904 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
| 905 | { |
---|
| 906 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 907 | } |
---|
[2] | 908 | iterPic++; |
---|
| 909 | } |
---|
[5] | 910 | bRefreshPending = false; |
---|
[2] | 911 | } |
---|
[608] | 912 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
[2] | 913 | { |
---|
[5] | 914 | bRefreshPending = true; |
---|
[608] | 915 | pocCRA = pocCurr; |
---|
[2] | 916 | } |
---|
| 917 | } |
---|
| 918 | } |
---|
| 919 | |
---|
| 920 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 921 | { |
---|
| 922 | assert( pSrc != NULL ); |
---|
| 923 | |
---|
| 924 | Int i, j, k; |
---|
| 925 | |
---|
| 926 | m_iPOC = pSrc->m_iPOC; |
---|
[608] | 927 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
| 928 | #if H_MV |
---|
| 929 | m_layerId = pSrc->m_layerId; |
---|
| 930 | // GT: Copying of several other values might be be missing here, or is above not necessary? |
---|
[21] | 931 | #endif |
---|
[2] | 932 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 933 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
[56] | 934 | #if ADAPTIVE_QP_SELECTION |
---|
| 935 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 936 | #endif |
---|
[608] | 937 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 938 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 939 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 940 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
[5] | 941 | |
---|
[608] | 942 | for (i = 0; i < 2; i++) |
---|
[2] | 943 | { |
---|
| 944 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 945 | } |
---|
| 946 | |
---|
[608] | 947 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
| 948 | { |
---|
| 949 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
| 950 | } |
---|
| 951 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 952 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
| 953 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
| 954 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
[2] | 955 | for (i = 0; i < 2; i++) |
---|
| 956 | { |
---|
[608] | 957 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
[2] | 958 | { |
---|
[608] | 959 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 960 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
| 961 | #if H_MV |
---|
| 962 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
| 963 | #endif |
---|
[2] | 964 | } |
---|
| 965 | } |
---|
| 966 | for (i = 0; i < 2; i++) |
---|
| 967 | { |
---|
[608] | 968 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
[2] | 969 | { |
---|
[608] | 970 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
[2] | 971 | } |
---|
[608] | 972 | } |
---|
[2] | 973 | m_iDepth = pSrc->m_iDepth; |
---|
| 974 | |
---|
| 975 | // referenced slice |
---|
| 976 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 977 | |
---|
| 978 | // access channel |
---|
[608] | 979 | #if H_MV |
---|
| 980 | m_pcVPS = pSrc->m_pcVPS; |
---|
| 981 | #endif |
---|
[2] | 982 | m_pcSPS = pSrc->m_pcSPS; |
---|
| 983 | m_pcPPS = pSrc->m_pcPPS; |
---|
[56] | 984 | m_pcRPS = pSrc->m_pcRPS; |
---|
| 985 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 986 | |
---|
[2] | 987 | m_pcPic = pSrc->m_pcPic; |
---|
| 988 | |
---|
[608] | 989 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
[56] | 990 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
[608] | 991 | #if SAO_CHROMA_LAMBDA |
---|
[56] | 992 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
| 993 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
| 994 | #else |
---|
[2] | 995 | m_dLambda = pSrc->m_dLambda; |
---|
[56] | 996 | #endif |
---|
[2] | 997 | for (i = 0; i < 2; i++) |
---|
| 998 | { |
---|
| 999 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 1000 | { |
---|
| 1001 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 1002 | { |
---|
| 1003 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 1004 | } |
---|
| 1005 | } |
---|
| 1006 | } |
---|
| 1007 | |
---|
[56] | 1008 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 1009 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 1010 | |
---|
[608] | 1011 | m_sliceMode = pSrc->m_sliceMode; |
---|
| 1012 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
| 1013 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
| 1014 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
| 1015 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
| 1016 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
| 1017 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
| 1018 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
| 1019 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
| 1020 | m_nextSlice = pSrc->m_nextSlice; |
---|
| 1021 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
| 1022 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1023 | { |
---|
| 1024 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
| 1025 | { |
---|
[56] | 1026 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
[608] | 1027 | } |
---|
| 1028 | } |
---|
[56] | 1029 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
[443] | 1030 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
[56] | 1031 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
| 1032 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
| 1033 | |
---|
| 1034 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
[608] | 1035 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
| 1036 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 1037 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
| 1038 | |
---|
| 1039 | #if H_MV |
---|
| 1040 | // Additional slice header syntax elements |
---|
[622] | 1041 | m_pocResetFlag = pSrc->m_pocResetFlag; |
---|
[608] | 1042 | m_discardableFlag = pSrc->m_discardableFlag; |
---|
| 1043 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
| 1044 | m_numInterLayerRefPicsMinus1 = pSrc->m_numInterLayerRefPicsMinus1; |
---|
| 1045 | |
---|
| 1046 | for (Int layer = 0; layer < MAX_NUM_LAYERS; layer++ ) |
---|
| 1047 | { |
---|
| 1048 | m_interLayerPredLayerIdc[ layer ] = pSrc->m_interLayerPredLayerIdc[ layer ]; |
---|
| 1049 | } |
---|
| 1050 | #endif |
---|
| 1051 | #if H_3D_IC |
---|
[443] | 1052 | m_bApplyIC = pSrc->m_bApplyIC; |
---|
| 1053 | m_icSkipParseFlag = pSrc->m_icSkipParseFlag; |
---|
| 1054 | #endif |
---|
[2] | 1055 | } |
---|
| 1056 | |
---|
[655] | 1057 | Int TComSlice::m_prevTid0POC = 0; |
---|
[608] | 1058 | |
---|
[56] | 1059 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 1060 | * \param uiTLayer Temporal layer ID of the current slice |
---|
| 1061 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 1062 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
| 1063 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 1064 | */ |
---|
| 1065 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
[2] | 1066 | { |
---|
[56] | 1067 | m_uiTLayer = uiTLayer; |
---|
[2] | 1068 | } |
---|
| 1069 | |
---|
[56] | 1070 | /** Function for checking if this is a switching-point |
---|
| 1071 | */ |
---|
[608] | 1072 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
[2] | 1073 | { |
---|
[56] | 1074 | TComPic* rpcPic; |
---|
| 1075 | // loop through all pictures in the reference picture buffer |
---|
| 1076 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1077 | while ( iterPic != rcListPic.end()) |
---|
| 1078 | { |
---|
| 1079 | rpcPic = *(iterPic++); |
---|
| 1080 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 1081 | { |
---|
| 1082 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1083 | { |
---|
| 1084 | return false; |
---|
| 1085 | } |
---|
| 1086 | } |
---|
| 1087 | } |
---|
| 1088 | return true; |
---|
| 1089 | } |
---|
| 1090 | |
---|
[608] | 1091 | /** Function for checking if this is a STSA candidate |
---|
| 1092 | */ |
---|
| 1093 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
| 1094 | { |
---|
| 1095 | TComPic* rpcPic; |
---|
| 1096 | |
---|
| 1097 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1098 | while ( iterPic != rcListPic.end()) |
---|
| 1099 | { |
---|
| 1100 | rpcPic = *(iterPic++); |
---|
| 1101 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
| 1102 | { |
---|
| 1103 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1104 | { |
---|
| 1105 | return false; |
---|
| 1106 | } |
---|
| 1107 | } |
---|
| 1108 | } |
---|
| 1109 | return true; |
---|
| 1110 | } |
---|
| 1111 | |
---|
[655] | 1112 | |
---|
| 1113 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
| 1114 | { |
---|
| 1115 | TComPic* rpcPic; |
---|
| 1116 | |
---|
| 1117 | Int nalUnitType = this->getNalUnitType(); |
---|
| 1118 | |
---|
| 1119 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
| 1120 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
| 1121 | { |
---|
| 1122 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
| 1123 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1124 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
| 1125 | { |
---|
| 1126 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1127 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1128 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1129 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1130 | } |
---|
| 1131 | } |
---|
| 1132 | |
---|
| 1133 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
| 1134 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
| 1135 | { |
---|
| 1136 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
| 1137 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
| 1138 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
| 1139 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
| 1140 | } |
---|
| 1141 | |
---|
| 1142 | // No RASL pictures shall be present in the bitstream that are associated |
---|
| 1143 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
| 1144 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1145 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1146 | { |
---|
| 1147 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
| 1148 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
| 1149 | } |
---|
| 1150 | |
---|
| 1151 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
| 1152 | // an IDR picture. |
---|
| 1153 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1154 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1155 | { |
---|
| 1156 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
| 1157 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
| 1158 | } |
---|
| 1159 | |
---|
| 1160 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
| 1161 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
| 1162 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
| 1163 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1164 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1165 | { |
---|
| 1166 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
| 1167 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
| 1168 | } |
---|
| 1169 | |
---|
| 1170 | // loop through all pictures in the reference picture buffer |
---|
| 1171 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1172 | while ( iterPic != rcListPic.end()) |
---|
| 1173 | { |
---|
| 1174 | rpcPic = *(iterPic++); |
---|
| 1175 | if (rpcPic->getPOC() == this->getPOC()) |
---|
| 1176 | { |
---|
| 1177 | continue; |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1181 | // in decoding order shall precede the IRAP picture in output order. |
---|
| 1182 | // (Note that any picture following in output order would be present in the DPB) |
---|
| 1183 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
| 1184 | { |
---|
| 1185 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1186 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1187 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1188 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
| 1189 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1190 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
| 1191 | { |
---|
| 1192 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
| 1197 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
| 1198 | // picture in output order. |
---|
| 1199 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
| 1200 | { |
---|
| 1201 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1202 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
| 1203 | { |
---|
| 1204 | // rpcPic precedes the IRAP in decoding order |
---|
| 1205 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1206 | { |
---|
| 1207 | // rpcPic must not be the IRAP picture |
---|
| 1208 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
| 1209 | { |
---|
| 1210 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | } |
---|
| 1214 | } |
---|
| 1215 | |
---|
| 1216 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
| 1217 | // all trailing pictures that are associated with the same IRAP picture. |
---|
| 1218 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1219 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
| 1220 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1221 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1222 | { |
---|
| 1223 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
| 1224 | { |
---|
| 1225 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
| 1226 | // rpcPic would violate the constraint if it was a trailing picture |
---|
| 1227 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
| 1228 | } |
---|
| 1229 | } |
---|
| 1230 | |
---|
| 1231 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
| 1232 | // RADL picture associated with the CRA or BLA picture in output order |
---|
| 1233 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1234 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1235 | { |
---|
| 1236 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1237 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1238 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1239 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
| 1240 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
| 1241 | { |
---|
| 1242 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1243 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
| 1244 | { |
---|
| 1245 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
| 1246 | } |
---|
| 1247 | } |
---|
| 1248 | } |
---|
| 1249 | |
---|
| 1250 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
| 1251 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
| 1252 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 1253 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1254 | { |
---|
| 1255 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 1256 | { |
---|
| 1257 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
| 1258 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
| 1259 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
| 1260 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
| 1261 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
| 1262 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
| 1263 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
| 1264 | { |
---|
| 1265 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
| 1266 | } |
---|
| 1267 | } |
---|
| 1268 | } |
---|
| 1269 | } |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | |
---|
| 1273 | |
---|
[56] | 1274 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1275 | */ |
---|
| 1276 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1277 | { |
---|
| 1278 | TComPic* rpcPic; |
---|
| 1279 | Int i, isReference; |
---|
| 1280 | |
---|
[655] | 1281 | checkLeadingPictureRestrictions(rcListPic); |
---|
| 1282 | |
---|
[56] | 1283 | // loop through all pictures in the reference picture buffer |
---|
| 1284 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1285 | while ( iterPic != rcListPic.end()) |
---|
| 1286 | { |
---|
| 1287 | rpcPic = *(iterPic++); |
---|
| 1288 | |
---|
[608] | 1289 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
| 1290 | { |
---|
| 1291 | continue; |
---|
| 1292 | } |
---|
| 1293 | |
---|
[56] | 1294 | isReference = 0; |
---|
[608] | 1295 | // loop through all pictures in the Reference Picture Set |
---|
| 1296 | // to see if the picture should be kept as reference picture |
---|
[56] | 1297 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1298 | { |
---|
| 1299 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1300 | { |
---|
| 1301 | isReference = 1; |
---|
| 1302 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1303 | rpcPic->setIsLongTerm(0); |
---|
| 1304 | } |
---|
| 1305 | } |
---|
| 1306 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1307 | { |
---|
[608] | 1308 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
[56] | 1309 | { |
---|
[608] | 1310 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1311 | { |
---|
| 1312 | isReference = 1; |
---|
| 1313 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1314 | } |
---|
[56] | 1315 | } |
---|
[608] | 1316 | else |
---|
| 1317 | { |
---|
[655] | 1318 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1319 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1320 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1321 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
[608] | 1322 | { |
---|
| 1323 | isReference = 1; |
---|
| 1324 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1325 | } |
---|
| 1326 | } |
---|
| 1327 | |
---|
[56] | 1328 | } |
---|
| 1329 | // mark the picture as "unused for reference" if it is not in |
---|
| 1330 | // the Reference Picture Set |
---|
| 1331 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1332 | { |
---|
| 1333 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
[608] | 1334 | rpcPic->setUsedByCurr(0); |
---|
[56] | 1335 | rpcPic->setIsLongTerm(0); |
---|
| 1336 | } |
---|
[608] | 1337 | //check that pictures of higher temporal layers are not used |
---|
| 1338 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1339 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
| 1340 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
| 1341 | { |
---|
| 1342 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1343 | } |
---|
| 1344 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1345 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1346 | { |
---|
| 1347 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1348 | } |
---|
| 1349 | } |
---|
[56] | 1350 | } |
---|
| 1351 | |
---|
| 1352 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1353 | */ |
---|
[608] | 1354 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
[56] | 1355 | { |
---|
| 1356 | TComPic* rpcPic; |
---|
[608] | 1357 | Int i, isAvailable; |
---|
[56] | 1358 | Int atLeastOneLost = 0; |
---|
| 1359 | Int atLeastOneRemoved = 0; |
---|
| 1360 | Int iPocLost = 0; |
---|
| 1361 | |
---|
| 1362 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1363 | // to see if the picture should be kept as reference picture |
---|
| 1364 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1365 | { |
---|
| 1366 | isAvailable = 0; |
---|
| 1367 | // loop through all pictures in the reference picture buffer |
---|
| 1368 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1369 | while ( iterPic != rcListPic.end()) |
---|
| 1370 | { |
---|
| 1371 | rpcPic = *(iterPic++); |
---|
[608] | 1372 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
[56] | 1373 | { |
---|
[608] | 1374 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1375 | { |
---|
| 1376 | isAvailable = 1; |
---|
| 1377 | } |
---|
[56] | 1378 | } |
---|
[608] | 1379 | else |
---|
| 1380 | { |
---|
[655] | 1381 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1382 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
| 1383 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
| 1384 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
[608] | 1385 | { |
---|
| 1386 | isAvailable = 1; |
---|
| 1387 | } |
---|
| 1388 | } |
---|
[56] | 1389 | } |
---|
| 1390 | // if there was no such long-term check the short terms |
---|
| 1391 | if(!isAvailable) |
---|
| 1392 | { |
---|
| 1393 | iterPic = rcListPic.begin(); |
---|
| 1394 | while ( iterPic != rcListPic.end()) |
---|
| 1395 | { |
---|
| 1396 | rpcPic = *(iterPic++); |
---|
| 1397 | |
---|
[608] | 1398 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1399 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
| 1400 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
| 1401 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
[56] | 1402 | { |
---|
[655] | 1403 | curPoc = curPoc & (pocCycle - 1); |
---|
| 1404 | refPoc = refPoc & (pocCycle - 1); |
---|
[608] | 1405 | } |
---|
| 1406 | |
---|
| 1407 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
| 1408 | { |
---|
[56] | 1409 | isAvailable = 1; |
---|
| 1410 | rpcPic->setIsLongTerm(1); |
---|
| 1411 | break; |
---|
[2] | 1412 | } |
---|
[56] | 1413 | } |
---|
| 1414 | } |
---|
| 1415 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1416 | // but not available as reference picture |
---|
| 1417 | if(isAvailable == 0) |
---|
| 1418 | { |
---|
| 1419 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1420 | { |
---|
| 1421 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1422 | { |
---|
[608] | 1423 | if(printErrors) |
---|
| 1424 | { |
---|
[56] | 1425 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1426 | } |
---|
[56] | 1427 | atLeastOneRemoved = 1; |
---|
[2] | 1428 | } |
---|
[56] | 1429 | else |
---|
| 1430 | { |
---|
[608] | 1431 | if(printErrors) |
---|
| 1432 | { |
---|
[56] | 1433 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1434 | } |
---|
[56] | 1435 | atLeastOneLost = 1; |
---|
| 1436 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
[2] | 1437 | } |
---|
| 1438 | } |
---|
[56] | 1439 | } |
---|
| 1440 | } |
---|
| 1441 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1442 | // to see if the picture should be kept as reference picture |
---|
| 1443 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1444 | { |
---|
| 1445 | isAvailable = 0; |
---|
| 1446 | // loop through all pictures in the reference picture buffer |
---|
| 1447 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1448 | while ( iterPic != rcListPic.end()) |
---|
| 1449 | { |
---|
| 1450 | rpcPic = *(iterPic++); |
---|
| 1451 | |
---|
| 1452 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1453 | { |
---|
| 1454 | isAvailable = 1; |
---|
| 1455 | } |
---|
| 1456 | } |
---|
| 1457 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1458 | // but not available as reference picture |
---|
| 1459 | if(isAvailable == 0) |
---|
| 1460 | { |
---|
| 1461 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1462 | { |
---|
| 1463 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1464 | { |
---|
[608] | 1465 | if(printErrors) |
---|
| 1466 | { |
---|
[56] | 1467 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1468 | } |
---|
[56] | 1469 | atLeastOneRemoved = 1; |
---|
| 1470 | } |
---|
| 1471 | else |
---|
| 1472 | { |
---|
[608] | 1473 | if(printErrors) |
---|
| 1474 | { |
---|
[56] | 1475 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1476 | } |
---|
[56] | 1477 | atLeastOneLost = 1; |
---|
| 1478 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1479 | } |
---|
| 1480 | } |
---|
| 1481 | } |
---|
| 1482 | } |
---|
| 1483 | if(atLeastOneLost) |
---|
| 1484 | { |
---|
| 1485 | return iPocLost+1; |
---|
[2] | 1486 | } |
---|
[56] | 1487 | if(atLeastOneRemoved) |
---|
| 1488 | { |
---|
| 1489 | return -2; |
---|
| 1490 | } |
---|
| 1491 | else |
---|
[608] | 1492 | { |
---|
[56] | 1493 | return 0; |
---|
[608] | 1494 | } |
---|
[2] | 1495 | } |
---|
| 1496 | |
---|
[56] | 1497 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1498 | */ |
---|
[608] | 1499 | #if FIX1071 |
---|
| 1500 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
| 1501 | #else |
---|
[56] | 1502 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
[608] | 1503 | #endif |
---|
[56] | 1504 | { |
---|
| 1505 | TComPic* rpcPic; |
---|
| 1506 | Int i, j; |
---|
| 1507 | Int k = 0; |
---|
| 1508 | Int nrOfNegativePictures = 0; |
---|
| 1509 | Int nrOfPositivePictures = 0; |
---|
| 1510 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
| 1511 | |
---|
| 1512 | // loop through all pictures in the Reference Picture Set |
---|
| 1513 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1514 | { |
---|
| 1515 | j = 0; |
---|
| 1516 | // loop through all pictures in the reference picture buffer |
---|
| 1517 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1518 | while ( iterPic != rcListPic.end()) |
---|
| 1519 | { |
---|
| 1520 | j++; |
---|
| 1521 | rpcPic = *(iterPic++); |
---|
| 1522 | |
---|
| 1523 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1524 | { |
---|
| 1525 | // This picture exists as a reference picture |
---|
| 1526 | // and should be added to the explicit Reference Picture Set |
---|
| 1527 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
[608] | 1528 | #if FIX1071 |
---|
| 1529 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
| 1530 | #else |
---|
[56] | 1531 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
[608] | 1532 | #endif |
---|
[56] | 1533 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
[608] | 1534 | { |
---|
[56] | 1535 | nrOfNegativePictures++; |
---|
[608] | 1536 | } |
---|
[56] | 1537 | else |
---|
[608] | 1538 | { |
---|
[56] | 1539 | nrOfPositivePictures++; |
---|
[608] | 1540 | } |
---|
[56] | 1541 | k++; |
---|
| 1542 | } |
---|
| 1543 | } |
---|
| 1544 | } |
---|
| 1545 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1546 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1547 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1548 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
| 1549 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1550 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
| 1551 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
| 1552 | { |
---|
| 1553 | pcRPS->setInterRPSPrediction(false); |
---|
| 1554 | pcRPS->setNumRefIdc(0); |
---|
| 1555 | } |
---|
| 1556 | else |
---|
| 1557 | { |
---|
| 1558 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1559 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
| 1560 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1561 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1562 | Int iNewIdc=0; |
---|
| 1563 | for(i=0; i<= iRefPics; i++) |
---|
| 1564 | { |
---|
| 1565 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1566 | Int iRefIdc = 0; |
---|
| 1567 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
| 1568 | { |
---|
| 1569 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
| 1570 | { |
---|
| 1571 | if (pcRPS->getUsed(j)) |
---|
| 1572 | { |
---|
| 1573 | iRefIdc = 1; |
---|
| 1574 | } |
---|
| 1575 | else |
---|
| 1576 | { |
---|
| 1577 | iRefIdc = 2; |
---|
| 1578 | } |
---|
| 1579 | } |
---|
| 1580 | } |
---|
| 1581 | pcRPS->setRefIdc(i, iRefIdc); |
---|
| 1582 | iNewIdc++; |
---|
| 1583 | } |
---|
| 1584 | pcRPS->setInterRPSPrediction(true); |
---|
| 1585 | pcRPS->setNumRefIdc(iNewIdc); |
---|
| 1586 | pcRPS->setDeltaRPS(deltaRPS); |
---|
| 1587 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1588 | } |
---|
| 1589 | |
---|
| 1590 | this->setRPS(pcRPS); |
---|
| 1591 | this->setRPSidx(-1); |
---|
| 1592 | } |
---|
| 1593 | |
---|
| 1594 | /** get AC and DC values for weighted pred |
---|
| 1595 | * \param *wp |
---|
| 1596 | * \returns Void |
---|
| 1597 | */ |
---|
| 1598 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
| 1599 | { |
---|
| 1600 | wp = m_weightACDCParam; |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | /** init AC and DC values for weighted pred |
---|
| 1604 | * \returns Void |
---|
| 1605 | */ |
---|
| 1606 | Void TComSlice::initWpAcDcParam() |
---|
| 1607 | { |
---|
| 1608 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
| 1609 | { |
---|
| 1610 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1611 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1612 | } |
---|
| 1613 | } |
---|
| 1614 | |
---|
| 1615 | /** get WP tables for weighted pred |
---|
| 1616 | * \param RefPicList |
---|
| 1617 | * \param iRefIdx |
---|
| 1618 | * \param *&wpScalingParam |
---|
| 1619 | * \returns Void |
---|
| 1620 | */ |
---|
| 1621 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
| 1622 | { |
---|
| 1623 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1624 | } |
---|
| 1625 | |
---|
| 1626 | /** reset Default WP tables settings : no weight. |
---|
| 1627 | * \param wpScalingParam |
---|
| 1628 | * \returns Void |
---|
| 1629 | */ |
---|
[608] | 1630 | Void TComSlice::resetWpScaling() |
---|
[2] | 1631 | { |
---|
[608] | 1632 | for ( Int e=0 ; e<2 ; e++ ) |
---|
[56] | 1633 | { |
---|
[608] | 1634 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1635 | { |
---|
[608] | 1636 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
[56] | 1637 | { |
---|
[608] | 1638 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
[2] | 1639 | pwp->bPresentFlag = false; |
---|
| 1640 | pwp->uiLog2WeightDenom = 0; |
---|
| 1641 | pwp->uiLog2WeightDenom = 0; |
---|
| 1642 | pwp->iWeight = 1; |
---|
| 1643 | pwp->iOffset = 0; |
---|
| 1644 | } |
---|
[56] | 1645 | } |
---|
[2] | 1646 | } |
---|
| 1647 | } |
---|
| 1648 | |
---|
[56] | 1649 | /** init WP table |
---|
| 1650 | * \returns Void |
---|
| 1651 | */ |
---|
[2] | 1652 | Void TComSlice::initWpScaling() |
---|
| 1653 | { |
---|
[608] | 1654 | for ( Int e=0 ; e<2 ; e++ ) |
---|
[56] | 1655 | { |
---|
[608] | 1656 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
[56] | 1657 | { |
---|
[608] | 1658 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
[56] | 1659 | { |
---|
[608] | 1660 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1661 | if ( !pwp->bPresentFlag ) |
---|
| 1662 | { |
---|
[2] | 1663 | // Inferring values not present : |
---|
| 1664 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1665 | pwp->iOffset = 0; |
---|
| 1666 | } |
---|
| 1667 | |
---|
| 1668 | pwp->w = pwp->iWeight; |
---|
[608] | 1669 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
| 1670 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
[2] | 1671 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1672 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1673 | } |
---|
[56] | 1674 | } |
---|
[2] | 1675 | } |
---|
| 1676 | } |
---|
| 1677 | |
---|
[608] | 1678 | // ------------------------------------------------------------------------------------------------ |
---|
| 1679 | // Video parameter set (VPS) |
---|
| 1680 | // ------------------------------------------------------------------------------------------------ |
---|
| 1681 | TComVPS::TComVPS() |
---|
| 1682 | : m_VPSId ( 0) |
---|
| 1683 | , m_uiMaxTLayers ( 1) |
---|
[622] | 1684 | #if H_MV |
---|
| 1685 | , m_uiMaxLayersMinus1 ( 0) |
---|
| 1686 | #else |
---|
[608] | 1687 | , m_uiMaxLayers ( 1) |
---|
[622] | 1688 | #endif |
---|
[608] | 1689 | , m_bTemporalIdNestingFlag (false) |
---|
| 1690 | , m_numHrdParameters ( 0) |
---|
| 1691 | #if H_MV |
---|
| 1692 | , m_maxLayerId ( 0) |
---|
| 1693 | #else |
---|
| 1694 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
| 1695 | #endif |
---|
| 1696 | , m_hrdParameters (NULL) |
---|
| 1697 | , m_hrdOpSetIdx (NULL) |
---|
| 1698 | , m_cprmsPresentFlag (NULL) |
---|
[622] | 1699 | #if H_MV |
---|
| 1700 | , m_vpsVUI ( NULL ) |
---|
| 1701 | #endif |
---|
[2] | 1702 | { |
---|
[608] | 1703 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
[56] | 1704 | { |
---|
[608] | 1705 | m_numReorderPics[i] = 0; |
---|
| 1706 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 1707 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1708 | } |
---|
| 1709 | #if H_MV |
---|
| 1710 | for (Int lsIdx = 0; lsIdx < MAX_VPS_OP_SETS_PLUS1; lsIdx++ ) |
---|
| 1711 | { |
---|
| 1712 | for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ ) |
---|
[56] | 1713 | { |
---|
[608] | 1714 | m_layerIdIncludedFlag[lsIdx][layerId] = false; |
---|
[56] | 1715 | } |
---|
[608] | 1716 | } |
---|
| 1717 | |
---|
| 1718 | m_vpsNumberLayerSetsMinus1 = -1; |
---|
| 1719 | m_vpsNumProfileTierLevelMinus1 = -1; |
---|
| 1720 | |
---|
| 1721 | for ( Int i = 0; i < MAX_VPS_PROFILE_TIER_LEVEL; i++) |
---|
| 1722 | { |
---|
| 1723 | m_profileRefMinus1[ i ] = -1; |
---|
[56] | 1724 | } |
---|
[608] | 1725 | |
---|
| 1726 | m_moreOutputLayerSetsThanDefaultFlag = false; |
---|
| 1727 | m_numAddOutputLayerSetsMinus1 = -1; |
---|
| 1728 | m_defaultOneTargetOutputLayerFlag = false; |
---|
| 1729 | |
---|
| 1730 | for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++) |
---|
| 1731 | { |
---|
| 1732 | m_outputLayerSetIdxMinus1[i] = -1; |
---|
| 1733 | m_profileLevelTierIdx[i] = 0; |
---|
| 1734 | for ( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++) |
---|
| 1735 | { |
---|
| 1736 | m_outputLayerFlag[i][j] = false; |
---|
| 1737 | } |
---|
| 1738 | } |
---|
| 1739 | |
---|
| 1740 | m_maxOneActiveRefLayerFlag = false; |
---|
| 1741 | m_directDepTypeLenMinus2 = 0; |
---|
| 1742 | |
---|
| 1743 | |
---|
| 1744 | m_avcBaseLayerFlag = false; |
---|
[622] | 1745 | m_vpsVuiOffset = 0; |
---|
[608] | 1746 | m_splittingFlag = false; |
---|
| 1747 | |
---|
| 1748 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
| 1749 | { |
---|
[622] | 1750 | m_scalabilityMaskFlag[i] = false; |
---|
[608] | 1751 | m_dimensionIdLen [i] = -1; |
---|
| 1752 | } |
---|
| 1753 | |
---|
| 1754 | m_vpsNuhLayerIdPresentFlag = false; |
---|
| 1755 | |
---|
| 1756 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
| 1757 | { |
---|
| 1758 | m_vpsProfilePresentFlag [i] = false; |
---|
| 1759 | m_profileRefMinus1[i] = 0; |
---|
| 1760 | m_outputLayerSetIdxMinus1 [i] = 0; |
---|
| 1761 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
| 1762 | { |
---|
| 1763 | m_outputLayerFlag[i][j] = false; |
---|
| 1764 | } |
---|
| 1765 | } |
---|
| 1766 | |
---|
| 1767 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
| 1768 | { |
---|
| 1769 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
| 1770 | } |
---|
| 1771 | |
---|
| 1772 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 1773 | { |
---|
| 1774 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
| 1775 | m_numDirectRefLayers[i] = 0; |
---|
[622] | 1776 | m_maxTidIlRefPicPlus1[i] = 7; |
---|
| 1777 | m_vpsRepFormatIdx [i] = 0; |
---|
| 1778 | m_repFormat [i] = NULL; |
---|
| 1779 | m_viewIdVal [i] = 0; |
---|
| 1780 | |
---|
[608] | 1781 | #if H_3D |
---|
| 1782 | m_viewIndex [i] = -1; |
---|
| 1783 | m_vpsDepthModesFlag [i] = false; |
---|
| 1784 | #if H_3D_DIM_DLT |
---|
| 1785 | m_bUseDLTFlag [i] = false; |
---|
| 1786 | |
---|
| 1787 | // allocate some memory and initialize with default mapping |
---|
| 1788 | m_iNumDepthmapValues[i] = ((1 << g_bitDepthY)-1)+1; |
---|
| 1789 | m_iBitsPerDepthValue[i] = numBitsForValue(m_iNumDepthmapValues[i]); |
---|
| 1790 | |
---|
| 1791 | m_iDepthValue2Idx[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
| 1792 | m_iIdx2DepthValue[i] = (Int*) xMalloc(Int, m_iNumDepthmapValues[i]); |
---|
| 1793 | |
---|
| 1794 | //default mapping |
---|
| 1795 | for (Int d=0; d<m_iNumDepthmapValues[i]; d++) |
---|
| 1796 | { |
---|
| 1797 | m_iDepthValue2Idx[i][d] = d; |
---|
| 1798 | m_iIdx2DepthValue[i][d] = d; |
---|
| 1799 | } |
---|
| 1800 | #endif |
---|
[622] | 1801 | #if H_3D |
---|
[608] | 1802 | m_ivMvScalingFlag = true; |
---|
| 1803 | #endif |
---|
| 1804 | #endif |
---|
| 1805 | |
---|
| 1806 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
| 1807 | { |
---|
| 1808 | m_directDependencyFlag[i][j] = false; |
---|
| 1809 | m_directDependencyType[i][j] = -1; |
---|
| 1810 | m_refLayerId[i][j] = -1; |
---|
| 1811 | } |
---|
| 1812 | |
---|
| 1813 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
| 1814 | { |
---|
| 1815 | m_dimensionId[i][j] = 0; |
---|
| 1816 | } |
---|
| 1817 | #if H_3D_ARP |
---|
| 1818 | m_uiUseAdvResPred[i] = 0; |
---|
| 1819 | m_uiARPStepNum[i] = 1; |
---|
| 1820 | #endif |
---|
| 1821 | } |
---|
[622] | 1822 | m_vpsVUI = new TComVPSVUI; |
---|
[608] | 1823 | #if H_3D |
---|
| 1824 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 1825 | { |
---|
| 1826 | #if H_3D_IV_MERGE |
---|
| 1827 | m_ivMvPredFlag [ i ] = false; |
---|
| 1828 | #endif |
---|
| 1829 | #if H_3D_VSP |
---|
| 1830 | m_viewSynthesisPredFlag[ i ] = false; |
---|
| 1831 | #endif |
---|
| 1832 | #if H_3D_NBDV_REF |
---|
| 1833 | m_depthRefinementFlag [ i ] = false; |
---|
| 1834 | #endif |
---|
[655] | 1835 | #if H_3D_INTER_SDC |
---|
[608] | 1836 | m_bInterSDCFlag [ i ] = false; |
---|
| 1837 | #endif |
---|
[696] | 1838 | #if SEC_MPI_ENABLING_MERGE_F0150 |
---|
| 1839 | m_bMPIFlag [ i ] = false; |
---|
| 1840 | #endif |
---|
[608] | 1841 | } |
---|
| 1842 | #endif |
---|
| 1843 | #endif |
---|
[56] | 1844 | } |
---|
[608] | 1845 | |
---|
| 1846 | TComVPS::~TComVPS() |
---|
[56] | 1847 | { |
---|
[608] | 1848 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
| 1849 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
| 1850 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
[622] | 1851 | #if H_MV |
---|
| 1852 | if ( m_vpsVUI != NULL ) delete m_vpsVUI; |
---|
| 1853 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 1854 | { |
---|
| 1855 | if (m_repFormat[ i ] != NULL ) delete m_repFormat[ i ]; |
---|
[608] | 1856 | #if H_3D_DIM_DLT |
---|
[622] | 1857 | if ( m_iDepthValue2Idx[i] != 0 ) |
---|
| 1858 | { |
---|
| 1859 | xFree( m_iDepthValue2Idx[i] ); |
---|
| 1860 | m_iDepthValue2Idx[i] = 0; |
---|
| 1861 | } |
---|
| 1862 | |
---|
| 1863 | if ( m_iIdx2DepthValue[i] != 0 ) |
---|
| 1864 | { |
---|
| 1865 | xFree( m_iIdx2DepthValue[i] ); |
---|
| 1866 | m_iIdx2DepthValue[i] = 0; |
---|
| 1867 | } |
---|
| 1868 | #endif |
---|
| 1869 | } |
---|
| 1870 | #endif |
---|
[608] | 1871 | } |
---|
| 1872 | |
---|
| 1873 | #if H_3D_DIM_DLT |
---|
| 1874 | Void TComVPS::setDepthLUTs(Int layerIdInVps, Int* idxToDepthValueTable, Int iNumDepthValues) |
---|
| 1875 | { |
---|
| 1876 | if( idxToDepthValueTable == NULL || iNumDepthValues == 0 ) // default mapping only |
---|
| 1877 | return; |
---|
| 1878 | |
---|
| 1879 | // copy idx2DepthValue to internal array |
---|
| 1880 | memcpy(m_iIdx2DepthValue[layerIdInVps], idxToDepthValueTable, iNumDepthValues*sizeof(UInt)); |
---|
| 1881 | |
---|
| 1882 | UInt uiMaxDepthValue = ((1 << g_bitDepthY)-1); |
---|
| 1883 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
[56] | 1884 | { |
---|
[608] | 1885 | Int iIdxDown = 0; |
---|
| 1886 | Int iIdxUp = iNumDepthValues-1; |
---|
| 1887 | Bool bFound = false; |
---|
| 1888 | |
---|
| 1889 | // iterate over indices to find lower closest depth |
---|
| 1890 | Int i = 1; |
---|
| 1891 | while(!bFound && i<iNumDepthValues) |
---|
[56] | 1892 | { |
---|
[608] | 1893 | if( m_iIdx2DepthValue[layerIdInVps][i] > p ) |
---|
| 1894 | { |
---|
| 1895 | iIdxDown = i-1; |
---|
| 1896 | bFound = true; |
---|
| 1897 | } |
---|
| 1898 | |
---|
| 1899 | i++; |
---|
[56] | 1900 | } |
---|
[608] | 1901 | // iterate over indices to find upper closest depth |
---|
| 1902 | i = iNumDepthValues-2; |
---|
| 1903 | bFound = false; |
---|
| 1904 | while(!bFound && i>=0) |
---|
[56] | 1905 | { |
---|
[608] | 1906 | if( m_iIdx2DepthValue[layerIdInVps][i] < p ) |
---|
| 1907 | { |
---|
| 1908 | iIdxUp = i+1; |
---|
| 1909 | bFound = true; |
---|
| 1910 | } |
---|
| 1911 | |
---|
| 1912 | i--; |
---|
[56] | 1913 | } |
---|
[608] | 1914 | |
---|
| 1915 | // assert monotony |
---|
| 1916 | assert(iIdxDown<=iIdxUp); |
---|
| 1917 | |
---|
| 1918 | // assign closer depth value/idx |
---|
| 1919 | if( abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxDown]) < abs(p-m_iIdx2DepthValue[layerIdInVps][iIdxUp]) ) |
---|
| 1920 | { |
---|
| 1921 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxDown; |
---|
| 1922 | } |
---|
| 1923 | else |
---|
| 1924 | { |
---|
| 1925 | m_iDepthValue2Idx[layerIdInVps][p] = iIdxUp; |
---|
| 1926 | } |
---|
| 1927 | |
---|
[56] | 1928 | } |
---|
[608] | 1929 | |
---|
| 1930 | // update DLT variables |
---|
| 1931 | m_iNumDepthmapValues[layerIdInVps] = iNumDepthValues; |
---|
| 1932 | m_iBitsPerDepthValue[layerIdInVps] = numBitsForValue(m_iNumDepthmapValues[layerIdInVps]); |
---|
[56] | 1933 | } |
---|
[608] | 1934 | #endif |
---|
| 1935 | |
---|
| 1936 | #if H_MV |
---|
| 1937 | |
---|
| 1938 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
| 1939 | { |
---|
[622] | 1940 | for( Int layer = 1; layer <= getMaxLayersMinus1(); layer++ ) |
---|
[608] | 1941 | { |
---|
| 1942 | // check layer_id_in_nuh constraint |
---|
| 1943 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
| 1944 | } |
---|
| 1945 | return true; |
---|
[56] | 1946 | } |
---|
[608] | 1947 | |
---|
| 1948 | Int TComVPS::getNumScalabilityTypes() |
---|
[2] | 1949 | { |
---|
[608] | 1950 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
| 1951 | } |
---|
| 1952 | |
---|
| 1953 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
| 1954 | { |
---|
| 1955 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
[622] | 1956 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) ); |
---|
[608] | 1957 | Int scalIdx = 0; |
---|
| 1958 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
[2] | 1959 | { |
---|
[622] | 1960 | scalIdx += ( getScalabilityMaskFlag( curScalType ) ? 1 : 0 ); |
---|
| 1961 | |
---|
[2] | 1962 | } |
---|
[608] | 1963 | |
---|
| 1964 | return scalIdx; |
---|
[2] | 1965 | } |
---|
[622] | 1966 | Void TComVPS::setScalabilityMaskFlag( UInt val ) |
---|
| 1967 | { |
---|
| 1968 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
| 1969 | { |
---|
| 1970 | setScalabilityMaskFlag( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
| 1971 | } |
---|
| 1972 | } |
---|
[189] | 1973 | |
---|
[608] | 1974 | Void TComVPS::setRefLayers() |
---|
| 1975 | { |
---|
[622] | 1976 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 1977 | { |
---|
| 1978 | Int iNuhLId = getLayerIdInNuh( i ); |
---|
| 1979 | m_numDirectRefLayers[ iNuhLId ] = 0; |
---|
| 1980 | for( Int j = 0; j < i; j++ ) |
---|
| 1981 | { |
---|
| 1982 | if( getDirectDependencyFlag(i , j) ) |
---|
| 1983 | { |
---|
| 1984 | m_refLayerId[ iNuhLId ][m_numDirectRefLayers[ iNuhLId ]++ ] = getLayerIdInNuh( j ); |
---|
| 1985 | } |
---|
| 1986 | } |
---|
| 1987 | } |
---|
| 1988 | } |
---|
| 1989 | |
---|
| 1990 | Int TComVPS::getRefLayerId( Int layerIdInNuh, Int idx ) |
---|
| 1991 | { |
---|
| 1992 | assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInNuh] ); |
---|
| 1993 | Int refLayerIdInNuh = m_refLayerId[ layerIdInNuh ][ idx ]; |
---|
| 1994 | assert ( refLayerIdInNuh >= 0 ); |
---|
| 1995 | return refLayerIdInNuh; |
---|
| 1996 | } |
---|
| 1997 | |
---|
| 1998 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
| 1999 | { |
---|
| 2000 | return getScalabilityMaskFlag( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
| 2001 | } |
---|
| 2002 | |
---|
| 2003 | #if H_3D |
---|
| 2004 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) |
---|
| 2005 | { |
---|
| 2006 | Int foundLayerIdinNuh = -1; |
---|
| 2007 | |
---|
| 2008 | for (Int layerIdInVps = 0 ; layerIdInVps <= getMaxLayersMinus1(); layerIdInVps++ ) |
---|
| 2009 | { |
---|
| 2010 | Int layerIdInNuh = getLayerIdInNuh( layerIdInVps ); |
---|
| 2011 | if( ( getViewIndex( layerIdInNuh ) == viewIndex ) && ( getDepthId( layerIdInNuh ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
| 2012 | { |
---|
| 2013 | foundLayerIdinNuh = layerIdInNuh; |
---|
| 2014 | break; |
---|
| 2015 | } |
---|
| 2016 | } |
---|
| 2017 | assert( foundLayerIdinNuh != -1 ); |
---|
| 2018 | |
---|
| 2019 | return foundLayerIdinNuh; |
---|
| 2020 | } |
---|
| 2021 | #endif // H_3D |
---|
[189] | 2022 | |
---|
[608] | 2023 | |
---|
| 2024 | Int TComVPS::xGetDimBitOffset( Int j ) |
---|
| 2025 | { |
---|
| 2026 | Int dimBitOffset = 0; |
---|
| 2027 | if ( getSplittingFlag() && j == getNumScalabilityTypes() ) |
---|
| 2028 | { |
---|
| 2029 | dimBitOffset = 6; |
---|
| 2030 | } |
---|
[443] | 2031 | else |
---|
| 2032 | { |
---|
[608] | 2033 | for (Int dimIdx = 0; dimIdx <= j-1; dimIdx++) |
---|
[443] | 2034 | { |
---|
[608] | 2035 | dimBitOffset += getDimensionIdLen( dimIdx ); |
---|
[443] | 2036 | } |
---|
| 2037 | } |
---|
[608] | 2038 | return dimBitOffset; |
---|
[443] | 2039 | } |
---|
[608] | 2040 | |
---|
| 2041 | Int TComVPS::inferDimensionId( Int i, Int j ) |
---|
[210] | 2042 | { |
---|
[608] | 2043 | return ( ( getLayerIdInNuh( i ) & ( (1 << xGetDimBitOffset( j + 1 ) ) - 1) ) >> xGetDimBitOffset( j ) ); |
---|
[210] | 2044 | } |
---|
| 2045 | |
---|
[608] | 2046 | Int TComVPS::inferLastDimsionIdLenMinus1() |
---|
[210] | 2047 | { |
---|
[608] | 2048 | return ( 5 - xGetDimBitOffset( getNumScalabilityTypes() - 1 ) ); |
---|
[210] | 2049 | } |
---|
[608] | 2050 | |
---|
| 2051 | Int TComVPS::getNumLayersInIdList( Int lsIdx ) |
---|
[77] | 2052 | { |
---|
[608] | 2053 | assert( lsIdx >= 0 ); |
---|
| 2054 | assert( lsIdx <= getVpsNumLayerSetsMinus1() ); |
---|
| 2055 | Int numLayersInIdList = 0; |
---|
| 2056 | for (Int layerId = 0; layerId < getVpsMaxLayerId(); layerId++ ) |
---|
[77] | 2057 | { |
---|
[608] | 2058 | numLayersInIdList += ( getLayerIdIncludedFlag( lsIdx, layerId ) ); |
---|
[77] | 2059 | } |
---|
[608] | 2060 | return numLayersInIdList; |
---|
[77] | 2061 | } |
---|
[622] | 2062 | Int TComVPS::getNumViews() |
---|
| 2063 | { |
---|
| 2064 | Int numViews = 1; |
---|
| 2065 | for( Int i = 0; i <= getMaxLayersMinus1(); i++ ) |
---|
| 2066 | { |
---|
| 2067 | Int lId = getLayerIdInNuh( i ); |
---|
| 2068 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
| 2069 | { |
---|
| 2070 | numViews++; |
---|
| 2071 | } |
---|
| 2072 | } |
---|
| 2073 | |
---|
| 2074 | return numViews; |
---|
| 2075 | } |
---|
| 2076 | |
---|
| 2077 | Bool TComVPS::getInDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Int depth /*= 0 */ ) |
---|
| 2078 | { |
---|
| 2079 | assert( depth < 65 ); |
---|
| 2080 | Bool dependentFlag = getDirectDependencyFlag( depLayeridInVps, refLayeridInVps ); |
---|
| 2081 | |
---|
| 2082 | for( Int i = 0; i < depLayeridInVps && !dependentFlag; i++ ) |
---|
| 2083 | { |
---|
| 2084 | if ( getDirectDependencyFlag( depLayeridInVps, i ) ) |
---|
| 2085 | { |
---|
| 2086 | dependentFlag = getInDirectDependencyFlag( i, refLayeridInVps, depth++ ); |
---|
| 2087 | } |
---|
| 2088 | } |
---|
| 2089 | return dependentFlag; |
---|
| 2090 | } |
---|
[608] | 2091 | #endif // H_MV |
---|
[56] | 2092 | |
---|
[2] | 2093 | // ------------------------------------------------------------------------------------------------ |
---|
| 2094 | // Sequence parameter set (SPS) |
---|
| 2095 | // ------------------------------------------------------------------------------------------------ |
---|
| 2096 | |
---|
| 2097 | TComSPS::TComSPS() |
---|
[56] | 2098 | : m_SPSId ( 0) |
---|
[608] | 2099 | , m_VPSId ( 0) |
---|
[56] | 2100 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 2101 | , m_uiMaxTLayers ( 1) |
---|
| 2102 | // Structure |
---|
| 2103 | , m_picWidthInLumaSamples (352) |
---|
| 2104 | , m_picHeightInLumaSamples (288) |
---|
[608] | 2105 | , m_log2MinCodingBlockSize ( 0) |
---|
| 2106 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
[56] | 2107 | , m_uiMaxCUWidth ( 32) |
---|
| 2108 | , m_uiMaxCUHeight ( 32) |
---|
| 2109 | , m_uiMaxCUDepth ( 3) |
---|
| 2110 | , m_bLongTermRefsPresent (false) |
---|
| 2111 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 2112 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 2113 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 2114 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 2115 | // Tool list |
---|
| 2116 | , m_usePCM (false) |
---|
| 2117 | , m_pcmLog2MaxSize ( 5) |
---|
| 2118 | , m_uiPCMLog2MinSize ( 7) |
---|
[608] | 2119 | #if H_3D_QTLPC |
---|
| 2120 | , m_bUseQTL (false) |
---|
| 2121 | , m_bUsePC (false) |
---|
[210] | 2122 | #endif |
---|
[608] | 2123 | , m_bitDepthY ( 8) |
---|
| 2124 | , m_bitDepthC ( 8) |
---|
[56] | 2125 | , m_qpBDOffsetY ( 0) |
---|
| 2126 | , m_qpBDOffsetC ( 0) |
---|
| 2127 | , m_useLossless (false) |
---|
| 2128 | , m_uiPCMBitDepthLuma ( 8) |
---|
| 2129 | , m_uiPCMBitDepthChroma ( 8) |
---|
| 2130 | , m_bPCMFilterDisableFlag (false) |
---|
| 2131 | , m_uiBitsForPOC ( 8) |
---|
[608] | 2132 | , m_numLongTermRefPicSPS ( 0) |
---|
[56] | 2133 | , m_uiMaxTrSize ( 32) |
---|
| 2134 | , m_bUseSAO (false) |
---|
| 2135 | , m_bTemporalIdNestingFlag (false) |
---|
| 2136 | , m_scalingListEnabledFlag (false) |
---|
[608] | 2137 | , m_useStrongIntraSmoothing (false) |
---|
| 2138 | , m_vuiParametersPresentFlag (false) |
---|
| 2139 | , m_vuiParameters () |
---|
| 2140 | #if H_MV |
---|
[622] | 2141 | , m_pcVPS ( NULL ) |
---|
| 2142 | , m_spsInferScalingListFlag ( false ) |
---|
| 2143 | , m_spsScalingListRefLayerId ( 0 ) |
---|
| 2144 | , m_updateRepFormatFlag ( true ) |
---|
[608] | 2145 | , m_interViewMvVertConstraintFlag (false) |
---|
[56] | 2146 | #endif |
---|
[608] | 2147 | #if H_3D |
---|
| 2148 | , m_bCamParInSliceHeader (false) |
---|
[210] | 2149 | #endif |
---|
[56] | 2150 | { |
---|
| 2151 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 2152 | { |
---|
| 2153 | m_uiMaxLatencyIncrease[i] = 0; |
---|
[608] | 2154 | m_uiMaxDecPicBuffering[i] = 1; |
---|
[56] | 2155 | m_numReorderPics[i] = 0; |
---|
| 2156 | } |
---|
[608] | 2157 | m_scalingList = new TComScalingList; |
---|
| 2158 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 2159 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
[2] | 2160 | } |
---|
| 2161 | |
---|
| 2162 | TComSPS::~TComSPS() |
---|
| 2163 | { |
---|
[608] | 2164 | delete m_scalingList; |
---|
| 2165 | m_RPSList.destroy(); |
---|
| 2166 | } |
---|
| 2167 | |
---|
| 2168 | Void TComSPS::createRPSList( Int numRPS ) |
---|
| 2169 | { |
---|
| 2170 | m_RPSList.destroy(); |
---|
| 2171 | m_RPSList.create(numRPS); |
---|
| 2172 | } |
---|
| 2173 | |
---|
| 2174 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
| 2175 | { |
---|
| 2176 | if( !getVuiParametersPresentFlag() ) |
---|
[56] | 2177 | { |
---|
[608] | 2178 | return; |
---|
[56] | 2179 | } |
---|
[608] | 2180 | |
---|
| 2181 | TComVUI *vui = getVuiParameters(); |
---|
| 2182 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 2183 | |
---|
| 2184 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
| 2185 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
| 2186 | switch( frameRate ) |
---|
[56] | 2187 | { |
---|
[608] | 2188 | case 24: |
---|
| 2189 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2190 | break; |
---|
| 2191 | case 25: |
---|
| 2192 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2193 | break; |
---|
| 2194 | case 30: |
---|
| 2195 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2196 | break; |
---|
| 2197 | case 50: |
---|
| 2198 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2199 | break; |
---|
| 2200 | case 60: |
---|
| 2201 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 2202 | break; |
---|
| 2203 | default: |
---|
| 2204 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
| 2205 | break; |
---|
[56] | 2206 | } |
---|
[2] | 2207 | |
---|
[608] | 2208 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 2209 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 2210 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
| 2211 | |
---|
| 2212 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
| 2213 | |
---|
| 2214 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[189] | 2215 | { |
---|
[608] | 2216 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 2217 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 2218 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
| 2219 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
[189] | 2220 | } |
---|
[608] | 2221 | else |
---|
| 2222 | { |
---|
| 2223 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
| 2224 | } |
---|
| 2225 | |
---|
| 2226 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
| 2227 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 2228 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
[189] | 2229 | |
---|
[608] | 2230 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 2231 | if( randomAccess ) |
---|
[189] | 2232 | { |
---|
[608] | 2233 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 2234 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 2235 | } |
---|
| 2236 | else |
---|
| 2237 | { |
---|
| 2238 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 2239 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 2240 | } |
---|
| 2241 | |
---|
| 2242 | /* |
---|
| 2243 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
| 2244 | */ |
---|
| 2245 | Int i, j; |
---|
| 2246 | UInt birateValue, cpbSizeValue; |
---|
| 2247 | UInt ducpbSizeValue; |
---|
| 2248 | UInt duBitRateValue = 0; |
---|
| 2249 | |
---|
| 2250 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
| 2251 | { |
---|
| 2252 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
| 2253 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
| 2254 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
| 2255 | hrd->setCpbCntMinus1( i, 0 ); |
---|
| 2256 | |
---|
| 2257 | birateValue = bitRate; |
---|
| 2258 | cpbSizeValue = bitRate; // 1 second |
---|
| 2259 | ducpbSizeValue = bitRate/numDU; |
---|
| 2260 | duBitRateValue = bitRate; |
---|
| 2261 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
[189] | 2262 | { |
---|
[608] | 2263 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
| 2264 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 2265 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
| 2266 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
| 2267 | |
---|
| 2268 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
| 2269 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 2270 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
| 2271 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
| 2272 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
[189] | 2273 | } |
---|
| 2274 | } |
---|
| 2275 | } |
---|
[608] | 2276 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
| 2277 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
[189] | 2278 | |
---|
[2] | 2279 | TComPPS::TComPPS() |
---|
[56] | 2280 | : m_PPSId (0) |
---|
| 2281 | , m_SPSId (0) |
---|
| 2282 | , m_picInitQPMinus26 (0) |
---|
| 2283 | , m_useDQP (false) |
---|
| 2284 | , m_bConstrainedIntraPred (false) |
---|
[608] | 2285 | , m_bSliceChromaQpFlag (false) |
---|
[56] | 2286 | , m_pcSPS (NULL) |
---|
| 2287 | , m_uiMaxCuDQPDepth (0) |
---|
| 2288 | , m_uiMinCuDQPSize (0) |
---|
[608] | 2289 | , m_chromaCbQpOffset (0) |
---|
| 2290 | , m_chromaCrQpOffset (0) |
---|
| 2291 | , m_numRefIdxL0DefaultActive (1) |
---|
| 2292 | , m_numRefIdxL1DefaultActive (1) |
---|
| 2293 | , m_TransquantBypassEnableFlag (false) |
---|
| 2294 | , m_useTransformSkip (false) |
---|
| 2295 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
| 2296 | , m_tilesEnabledFlag (false) |
---|
| 2297 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 2298 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 2299 | , m_uniformSpacingFlag (0) |
---|
[56] | 2300 | , m_iNumColumnsMinus1 (0) |
---|
| 2301 | , m_puiColumnWidth (NULL) |
---|
| 2302 | , m_iNumRowsMinus1 (0) |
---|
| 2303 | , m_puiRowHeight (NULL) |
---|
[608] | 2304 | , m_iNumSubstreams (1) |
---|
[56] | 2305 | , m_signHideFlag(0) |
---|
| 2306 | , m_cabacInitPresentFlag (false) |
---|
[608] | 2307 | , m_encCABACTableIdx (I_SLICE) |
---|
| 2308 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 2309 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
| 2310 | , m_listsModificationPresentFlag( 0) |
---|
| 2311 | , m_numExtraSliceHeaderBits(0) |
---|
[622] | 2312 | #if H_MV |
---|
| 2313 | , m_ppsInferScalingListFlag(false) |
---|
| 2314 | , m_ppsScalingListRefLayerId(0) |
---|
| 2315 | #endif |
---|
[2] | 2316 | { |
---|
[608] | 2317 | m_scalingList = new TComScalingList; |
---|
[2] | 2318 | } |
---|
| 2319 | |
---|
| 2320 | TComPPS::~TComPPS() |
---|
| 2321 | { |
---|
[608] | 2322 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
[56] | 2323 | { |
---|
| 2324 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
| 2325 | m_puiColumnWidth = NULL; |
---|
| 2326 | } |
---|
[608] | 2327 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
[56] | 2328 | { |
---|
| 2329 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
| 2330 | m_puiRowHeight = NULL; |
---|
| 2331 | } |
---|
[608] | 2332 | delete m_scalingList; |
---|
[2] | 2333 | } |
---|
| 2334 | |
---|
[622] | 2335 | #if H_MV |
---|
| 2336 | Void TComSPS::inferRepFormat( TComVPS* vps, Int layerIdCurr ) |
---|
| 2337 | { |
---|
| 2338 | if ( layerIdCurr > 0 ) |
---|
| 2339 | { |
---|
| 2340 | TComRepFormat* repFormat = vps->getRepFormat( vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); |
---|
| 2341 | if ( !getUpdateRepFormatFlag() ) |
---|
| 2342 | { |
---|
| 2343 | setChromaFormatIdc( repFormat->getChromaFormatVpsIdc() ); |
---|
| 2344 | //// ToDo: add when supported: |
---|
| 2345 | // setSeperateColourPlaneFlag( repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
| 2346 | |
---|
| 2347 | setPicWidthInLumaSamples ( repFormat->getPicWidthVpsInLumaSamples() ); |
---|
| 2348 | setPicHeightInLumaSamples( repFormat->getPicHeightVpsInLumaSamples() ); |
---|
| 2349 | |
---|
| 2350 | setBitDepthY ( repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
| 2351 | setQpBDOffsetY ( (Int) (6*( getBitDepthY() - 8 )) ); |
---|
| 2352 | |
---|
| 2353 | setBitDepthC ( repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
| 2354 | setQpBDOffsetC ( (Int) (6* ( getBitDepthC() -8 ) ) ); |
---|
| 2355 | } |
---|
| 2356 | else |
---|
| 2357 | { |
---|
| 2358 | assert( getChromaFormatIdc() <= repFormat->getChromaFormatVpsIdc() ); |
---|
| 2359 | //// ToDo: add when supported: |
---|
| 2360 | // assert( getSeperateColourPlaneFlag() <= repFormat->getSeparateColourPlaneVpsFlag() ) ; |
---|
| 2361 | |
---|
| 2362 | assert( getPicWidthInLumaSamples() <= repFormat->getPicWidthVpsInLumaSamples() ); |
---|
| 2363 | assert( getPicHeightInLumaSamples() <= repFormat->getPicHeightVpsInLumaSamples() ); |
---|
| 2364 | |
---|
| 2365 | assert( getBitDepthY() <= repFormat->getBitDepthVpsLumaMinus8() + 8 ); |
---|
| 2366 | assert( getBitDepthC() <= repFormat->getBitDepthVpsChromaMinus8() + 8 ); |
---|
| 2367 | } |
---|
| 2368 | } |
---|
| 2369 | |
---|
| 2370 | // Set conformance window |
---|
| 2371 | Int scal = TComSPS::getWinUnitX( getChromaFormatIdc() ) ; |
---|
| 2372 | getConformanceWindow().scaleOffsets( scal ); |
---|
| 2373 | getVuiParameters()->getDefaultDisplayWindow().scaleOffsets( scal ); |
---|
| 2374 | } |
---|
| 2375 | |
---|
| 2376 | Void TComSPS::inferScalingList( TComSPS* spsSrc ) |
---|
| 2377 | { |
---|
| 2378 | if ( getSpsInferScalingListFlag() ) |
---|
| 2379 | { |
---|
| 2380 | assert( spsSrc != NULL ); |
---|
| 2381 | assert( !spsSrc->getSpsInferScalingListFlag() ); |
---|
| 2382 | getScalingList()->inferFrom( spsSrc->getScalingList() ); |
---|
| 2383 | } |
---|
| 2384 | } |
---|
| 2385 | #endif |
---|
[608] | 2386 | #if H_3D |
---|
[2] | 2387 | Void |
---|
[608] | 2388 | TComSPS::initCamParaSPS( UInt uiViewIndex, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
[2] | 2389 | { |
---|
[608] | 2390 | AOT( uiViewIndex != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
| 2391 | |
---|
| 2392 | m_uiCamParPrecision = ( uiViewIndex ? uiCamParPrecision : 0 ); |
---|
| 2393 | m_bCamParInSliceHeader = ( uiViewIndex ? bCamParSlice : false ); |
---|
[2] | 2394 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
| 2395 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
| 2396 | |
---|
[313] | 2397 | if( !m_bCamParInSliceHeader ) |
---|
| 2398 | { |
---|
[608] | 2399 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ ) |
---|
[313] | 2400 | { |
---|
[608] | 2401 | m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ uiViewIndex ]; |
---|
| 2402 | m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [ uiViewIndex ][ uiBaseViewIndex ]; |
---|
| 2403 | m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ uiViewIndex ]; |
---|
| 2404 | m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[ uiViewIndex ][ uiBaseViewIndex ]; |
---|
[313] | 2405 | } |
---|
| 2406 | } |
---|
[2] | 2407 | } |
---|
[5] | 2408 | #endif |
---|
[56] | 2409 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 2410 | : m_numberOfPictures (0) |
---|
| 2411 | , m_numberOfNegativePictures (0) |
---|
| 2412 | , m_numberOfPositivePictures (0) |
---|
| 2413 | , m_numberOfLongtermPictures (0) |
---|
| 2414 | , m_interRPSPrediction (0) |
---|
| 2415 | , m_deltaRIdxMinus1 (0) |
---|
| 2416 | , m_deltaRPS (0) |
---|
| 2417 | , m_numRefIdc (0) |
---|
| 2418 | { |
---|
| 2419 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 2420 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 2421 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 2422 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
| 2423 | } |
---|
| 2424 | |
---|
| 2425 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 2426 | { |
---|
| 2427 | } |
---|
| 2428 | |
---|
| 2429 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 2430 | { |
---|
| 2431 | m_used[bufferNum] = used; |
---|
| 2432 | } |
---|
| 2433 | |
---|
| 2434 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 2435 | { |
---|
| 2436 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 2437 | } |
---|
| 2438 | |
---|
| 2439 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 2440 | { |
---|
| 2441 | m_numberOfPictures = numberOfPictures; |
---|
| 2442 | } |
---|
| 2443 | |
---|
| 2444 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
| 2445 | { |
---|
| 2446 | return m_used[bufferNum]; |
---|
| 2447 | } |
---|
| 2448 | |
---|
| 2449 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
| 2450 | { |
---|
| 2451 | return m_deltaPOC[bufferNum]; |
---|
| 2452 | } |
---|
| 2453 | |
---|
| 2454 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
| 2455 | { |
---|
| 2456 | return m_numberOfPictures; |
---|
| 2457 | } |
---|
| 2458 | |
---|
| 2459 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
| 2460 | { |
---|
| 2461 | return m_POC[bufferNum]; |
---|
| 2462 | } |
---|
[608] | 2463 | |
---|
[56] | 2464 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 2465 | { |
---|
| 2466 | m_POC[bufferNum] = POC; |
---|
| 2467 | } |
---|
| 2468 | |
---|
[608] | 2469 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
| 2470 | { |
---|
| 2471 | return m_bCheckLTMSB[bufferNum]; |
---|
| 2472 | } |
---|
| 2473 | |
---|
| 2474 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 2475 | { |
---|
| 2476 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 2477 | } |
---|
| 2478 | |
---|
[56] | 2479 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
| 2480 | * \param uiBufferNum |
---|
| 2481 | * \param iRefIdc |
---|
| 2482 | * \returns Void |
---|
| 2483 | */ |
---|
| 2484 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 2485 | { |
---|
| 2486 | m_refIdc[bufferNum] = refIdc; |
---|
| 2487 | } |
---|
| 2488 | |
---|
| 2489 | /** get the reference idc value at uiBufferNum |
---|
| 2490 | * \param uiBufferNum |
---|
| 2491 | * \returns Int |
---|
| 2492 | */ |
---|
| 2493 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
| 2494 | { |
---|
| 2495 | return m_refIdc[bufferNum]; |
---|
| 2496 | } |
---|
| 2497 | |
---|
| 2498 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 2499 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 2500 | * +ve values are in increasing order. |
---|
| 2501 | * \returns Void |
---|
| 2502 | */ |
---|
| 2503 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 2504 | { |
---|
| 2505 | // sort in increasing order (smallest first) |
---|
| 2506 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
| 2507 | { |
---|
| 2508 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2509 | Bool used = getUsed(j); |
---|
| 2510 | for (Int k=j-1; k >= 0; k--) |
---|
| 2511 | { |
---|
| 2512 | Int temp = getDeltaPOC(k); |
---|
| 2513 | if (deltaPOC < temp) |
---|
| 2514 | { |
---|
| 2515 | setDeltaPOC(k+1, temp); |
---|
| 2516 | setUsed(k+1, getUsed(k)); |
---|
| 2517 | setDeltaPOC(k, deltaPOC); |
---|
| 2518 | setUsed(k, used); |
---|
| 2519 | } |
---|
| 2520 | } |
---|
| 2521 | } |
---|
| 2522 | // flip the negative values to largest first |
---|
| 2523 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2524 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
| 2525 | { |
---|
| 2526 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2527 | Bool used = getUsed(j); |
---|
| 2528 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2529 | setUsed(j, getUsed(k)); |
---|
| 2530 | setDeltaPOC(k, deltaPOC); |
---|
| 2531 | setUsed(k, used); |
---|
| 2532 | } |
---|
| 2533 | } |
---|
| 2534 | |
---|
| 2535 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2536 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2537 | * \returns Void |
---|
| 2538 | */ |
---|
| 2539 | Void TComReferencePictureSet::printDeltaPOC() |
---|
| 2540 | { |
---|
| 2541 | printf("DeltaPOC = { "); |
---|
| 2542 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2543 | { |
---|
| 2544 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
| 2545 | } |
---|
| 2546 | if (getInterRPSPrediction()) |
---|
| 2547 | { |
---|
| 2548 | printf("}, RefIdc = { "); |
---|
| 2549 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2550 | { |
---|
| 2551 | printf("%d ", getRefIdc(j)); |
---|
| 2552 | } |
---|
| 2553 | } |
---|
| 2554 | printf("}\n"); |
---|
| 2555 | } |
---|
| 2556 | |
---|
| 2557 | TComRPSList::TComRPSList() |
---|
[608] | 2558 | :m_referencePictureSets (NULL) |
---|
[56] | 2559 | { |
---|
| 2560 | } |
---|
| 2561 | |
---|
| 2562 | TComRPSList::~TComRPSList() |
---|
| 2563 | { |
---|
| 2564 | } |
---|
| 2565 | |
---|
| 2566 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
| 2567 | { |
---|
| 2568 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2569 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
| 2570 | } |
---|
| 2571 | |
---|
| 2572 | Void TComRPSList::destroy() |
---|
| 2573 | { |
---|
[608] | 2574 | if (m_referencePictureSets) |
---|
| 2575 | { |
---|
| 2576 | delete [] m_referencePictureSets; |
---|
| 2577 | } |
---|
[56] | 2578 | m_numberOfReferencePictureSets = 0; |
---|
| 2579 | m_referencePictureSets = NULL; |
---|
| 2580 | } |
---|
| 2581 | |
---|
| 2582 | |
---|
| 2583 | |
---|
| 2584 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
| 2585 | { |
---|
| 2586 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
| 2587 | } |
---|
| 2588 | |
---|
| 2589 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
| 2590 | { |
---|
| 2591 | return m_numberOfReferencePictureSets; |
---|
| 2592 | } |
---|
| 2593 | |
---|
| 2594 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
| 2595 | { |
---|
| 2596 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2597 | } |
---|
| 2598 | |
---|
| 2599 | TComRefPicListModification::TComRefPicListModification() |
---|
| 2600 | : m_bRefPicListModificationFlagL0 (false) |
---|
| 2601 | , m_bRefPicListModificationFlagL1 (false) |
---|
| 2602 | { |
---|
| 2603 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2604 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2605 | } |
---|
| 2606 | |
---|
| 2607 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2608 | { |
---|
| 2609 | } |
---|
| 2610 | |
---|
[608] | 2611 | TComScalingList::TComScalingList() |
---|
[56] | 2612 | { |
---|
[608] | 2613 | init(); |
---|
[56] | 2614 | } |
---|
[608] | 2615 | TComScalingList::~TComScalingList() |
---|
| 2616 | { |
---|
| 2617 | destroy(); |
---|
| 2618 | } |
---|
[56] | 2619 | |
---|
[608] | 2620 | /** set default quantization matrix to array |
---|
| 2621 | */ |
---|
| 2622 | Void TComSlice::setDefaultScalingList() |
---|
[56] | 2623 | { |
---|
[608] | 2624 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2625 | { |
---|
| 2626 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2627 | { |
---|
| 2628 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
| 2629 | } |
---|
| 2630 | } |
---|
| 2631 | } |
---|
| 2632 | /** check if use default quantization matrix |
---|
| 2633 | * \returns true if use default quantization matrix in all size |
---|
| 2634 | */ |
---|
| 2635 | Bool TComSlice::checkDefaultScalingList() |
---|
| 2636 | { |
---|
| 2637 | UInt defaultCounter=0; |
---|
[56] | 2638 | |
---|
[608] | 2639 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2640 | { |
---|
| 2641 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2642 | { |
---|
| 2643 | if( !memcmp(getScalingList()->getScalingListAddress(sizeId,listId), getScalingList()->getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
| 2644 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
| 2645 | { |
---|
| 2646 | defaultCounter++; |
---|
| 2647 | } |
---|
| 2648 | } |
---|
| 2649 | } |
---|
| 2650 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
[56] | 2651 | } |
---|
| 2652 | |
---|
[608] | 2653 | #if H_MV |
---|
[622] | 2654 | Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 ) |
---|
| 2655 | { |
---|
| 2656 | refPicSetInterLayer0.clear(); |
---|
| 2657 | refPicSetInterLayer1.clear(); |
---|
| 2658 | |
---|
| 2659 | for( Int i = 0; i < getNumActiveRefLayerPics(); i++ ) |
---|
| 2660 | { |
---|
| 2661 | Int layerIdRef = getRefPicLayerId( i ); |
---|
| 2662 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
| 2663 | assert ( picRef != 0 ); |
---|
| 2664 | |
---|
| 2665 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
| 2666 | picRef->setIsLongTerm( true ); |
---|
| 2667 | picRef->getSlice(0)->setReferenced( true ); |
---|
| 2668 | |
---|
| 2669 | Int viewIdCur = getVPS()->getViewId( getLayerId() ); |
---|
| 2670 | Int viewIdZero = getVPS()->getViewId( 0 ); |
---|
| 2671 | Int viewIdRef = getVPS()->getViewId( layerIdRef ); |
---|
| 2672 | |
---|
| 2673 | if ( ( viewIdCur <= viewIdZero && viewIdCur <= viewIdRef ) || ( viewIdCur >= viewIdZero && viewIdCur >= viewIdRef ) ) |
---|
| 2674 | { |
---|
| 2675 | refPicSetInterLayer0.push_back( picRef ); |
---|
| 2676 | } |
---|
| 2677 | else |
---|
| 2678 | { |
---|
| 2679 | refPicSetInterLayer1.push_back( picRef ); |
---|
| 2680 | } |
---|
| 2681 | // Consider to check here: |
---|
| 2682 | // "If the current picture is a RADL picture, there shall be no entry in the RefPicSetInterLayer0 and RefPicSetInterLayer1 that is a RASL picture. " |
---|
| 2683 | } |
---|
| 2684 | } |
---|
[56] | 2685 | |
---|
[622] | 2686 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer0, std::vector<TComPic*> refPicSetInterLayer1 ) |
---|
| 2687 | { |
---|
| 2688 | // Mark as shortterm |
---|
| 2689 | for ( Int i = 0; i < refPicSetInterLayer0.size(); i++ ) |
---|
| 2690 | { |
---|
| 2691 | refPicSetInterLayer0[i]->setIsLongTerm( false ); |
---|
| 2692 | } |
---|
| 2693 | |
---|
| 2694 | for ( Int i = 0; i < refPicSetInterLayer1.size(); i++ ) |
---|
| 2695 | { |
---|
| 2696 | refPicSetInterLayer1[i]->setIsLongTerm( false ); |
---|
| 2697 | } |
---|
| 2698 | |
---|
| 2699 | } |
---|
[608] | 2700 | Void TComSlice::markIvRefPicsAsUnused( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc ) |
---|
[56] | 2701 | { |
---|
[608] | 2702 | // Fill targetDecLayerIdSet with all layers if empty. |
---|
| 2703 | if (targetDecLayerIdSet.size() == 0 ) |
---|
[56] | 2704 | { |
---|
[622] | 2705 | for ( Int layerIdInVps = 0; layerIdInVps <= vps->getMaxLayersMinus1(); layerIdInVps++ ) |
---|
[608] | 2706 | { |
---|
| 2707 | targetDecLayerIdSet.push_back( vps->getLayerIdInNuh( layerIdInVps ) ); |
---|
| 2708 | } |
---|
| 2709 | } |
---|
| 2710 | |
---|
| 2711 | Int numTargetDecLayers = (Int) targetDecLayerIdSet.size(); |
---|
| 2712 | Int latestDecIdx; |
---|
| 2713 | for ( latestDecIdx = 0; latestDecIdx < numTargetDecLayers; latestDecIdx++) |
---|
| 2714 | { |
---|
| 2715 | if ( targetDecLayerIdSet[ latestDecIdx ] == curLayerId ) |
---|
[622] | 2716 | { |
---|
[608] | 2717 | break; |
---|
| 2718 | } |
---|
[622] | 2719 | } |
---|
[608] | 2720 | |
---|
| 2721 | for( Int i = 0; i <= latestDecIdx; i++ ) |
---|
| 2722 | { |
---|
| 2723 | if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ i ] ) ) |
---|
| 2724 | { |
---|
| 2725 | TComPic* pcPic = ivPicLists->getPic( targetDecLayerIdSet[ i ], curPoc ); |
---|
| 2726 | if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() ) |
---|
| 2727 | { |
---|
| 2728 | Bool remainingInterLayerReferencesFlag = false; |
---|
| 2729 | for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
| 2730 | { |
---|
| 2731 | TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS(); |
---|
| 2732 | if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) ) |
---|
| 2733 | { |
---|
[622] | 2734 | for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdSet[ j ] ); k++ ) |
---|
| 2735 | { |
---|
| 2736 | if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdSet[ j ], k ) ) |
---|
| 2737 | { |
---|
[608] | 2738 | remainingInterLayerReferencesFlag = true; |
---|
| 2739 | } |
---|
| 2740 | } |
---|
[622] | 2741 | } |
---|
| 2742 | } |
---|
[608] | 2743 | if( !remainingInterLayerReferencesFlag ) |
---|
[622] | 2744 | { |
---|
[608] | 2745 | pcPic->getSlice(0)->setReferenced( false ); |
---|
| 2746 | } |
---|
| 2747 | } |
---|
[56] | 2748 | } |
---|
| 2749 | } |
---|
[622] | 2750 | } |
---|
[56] | 2751 | |
---|
[622] | 2752 | Void TComSlice::printRefPicList() |
---|
[608] | 2753 | { |
---|
| 2754 | for ( Int li = 0; li < 2; li++) |
---|
| 2755 | { |
---|
| 2756 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
| 2757 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
| 2758 | { |
---|
| 2759 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
| 2760 | |
---|
| 2761 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
| 2762 | } |
---|
| 2763 | } |
---|
| 2764 | } |
---|
| 2765 | |
---|
| 2766 | Void TComSlice::markCurrPic( TComPic* currPic ) |
---|
[56] | 2767 | { |
---|
[608] | 2768 | if ( !currPic->getSlice(0)->getDiscardableFlag() ) |
---|
[56] | 2769 | { |
---|
[608] | 2770 | currPic->getSlice(0)->setReferenced( true ) ; |
---|
| 2771 | currPic->setIsLongTerm( false ); |
---|
[56] | 2772 | } |
---|
[608] | 2773 | else |
---|
| 2774 | { |
---|
| 2775 | currPic->getSlice(0)->setReferenced( false ) ; |
---|
| 2776 | } |
---|
[56] | 2777 | } |
---|
| 2778 | |
---|
[622] | 2779 | Void TComSlice::setRefPicSetInterLayer( std::vector<TComPic*>* refPicSetInterLayer0, std::vector<TComPic*>* refPicSetInterLayer1 ) |
---|
| 2780 | { |
---|
| 2781 | m_refPicSetInterLayer0 = refPicSetInterLayer0; |
---|
| 2782 | m_refPicSetInterLayer1 = refPicSetInterLayer1; |
---|
| 2783 | } |
---|
| 2784 | |
---|
| 2785 | TComPic* TComSlice::getPicFromRefPicSetInterLayer(Int setIdc, Int layerId ) |
---|
| 2786 | { |
---|
| 2787 | assert ( setIdc == 0 || setIdc == 1); |
---|
| 2788 | std::vector<TComPic*>* refPicSetInterLayer = ( setIdc == 0 ? m_refPicSetInterLayer0 : m_refPicSetInterLayer1); |
---|
| 2789 | assert( refPicSetInterLayer != 0 ); |
---|
| 2790 | |
---|
| 2791 | TComPic* pcPic = NULL; |
---|
| 2792 | for ( Int i = 0; i < (*refPicSetInterLayer).size(); i++ ) |
---|
| 2793 | { |
---|
| 2794 | if ((*refPicSetInterLayer)[ i ]->getLayerId() == layerId ) |
---|
| 2795 | { |
---|
| 2796 | pcPic = (*refPicSetInterLayer)[ i ]; |
---|
| 2797 | } |
---|
| 2798 | } |
---|
| 2799 | |
---|
| 2800 | assert(pcPic != NULL); |
---|
| 2801 | return pcPic; |
---|
| 2802 | } |
---|
[608] | 2803 | Int TComSlice::getNumActiveRefLayerPics() |
---|
[56] | 2804 | { |
---|
[608] | 2805 | Int numActiveRefLayerPics; |
---|
| 2806 | |
---|
[622] | 2807 | if( getLayerId() == 0 || getVPS()->getNumDirectRefLayers( getLayerId() ) == 0 ) |
---|
| 2808 | { |
---|
| 2809 | numActiveRefLayerPics = 0; |
---|
| 2810 | } |
---|
| 2811 | else if (getVPS()->getAllRefLayersActiveFlag() ) |
---|
| 2812 | { |
---|
| 2813 | numActiveRefLayerPics = getVPS()->getNumDirectRefLayers( getLayerId() ); |
---|
| 2814 | } |
---|
| 2815 | else if ( !getInterLayerPredEnabledFlag() ) |
---|
| 2816 | { |
---|
| 2817 | numActiveRefLayerPics = 0; |
---|
| 2818 | } |
---|
| 2819 | else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 ) |
---|
[608] | 2820 | { |
---|
| 2821 | numActiveRefLayerPics = 1; |
---|
| 2822 | } |
---|
| 2823 | else |
---|
| 2824 | { |
---|
| 2825 | numActiveRefLayerPics = getNumInterLayerRefPicsMinus1() + 1; |
---|
| 2826 | } |
---|
| 2827 | return numActiveRefLayerPics; |
---|
[56] | 2828 | } |
---|
[608] | 2829 | |
---|
| 2830 | Int TComSlice::getRefPicLayerId( Int i ) |
---|
[56] | 2831 | { |
---|
[622] | 2832 | return getVPS()->getRefLayerId( getLayerId(), getInterLayerPredLayerIdc( i ) ); |
---|
[56] | 2833 | } |
---|
| 2834 | |
---|
[608] | 2835 | #if H_3D_ARP |
---|
| 2836 | Void TComSlice::setARPStepNum() |
---|
| 2837 | { |
---|
| 2838 | Bool bAllIvRef = true; |
---|
[56] | 2839 | |
---|
[608] | 2840 | if(!getVPS()->getUseAdvRP(getLayerId())) |
---|
[56] | 2841 | { |
---|
[608] | 2842 | m_nARPStepNum = 0; |
---|
| 2843 | } |
---|
| 2844 | else |
---|
| 2845 | { |
---|
| 2846 | for( Int iRefListId = 0; iRefListId < 2; iRefListId++ ) |
---|
[56] | 2847 | { |
---|
[608] | 2848 | RefPicList eRefPicList = RefPicList( iRefListId ); |
---|
| 2849 | Int iNumRefIdx = getNumRefIdx(eRefPicList); |
---|
| 2850 | |
---|
| 2851 | if( iNumRefIdx <= 0 ) |
---|
[56] | 2852 | { |
---|
[608] | 2853 | continue; |
---|
[56] | 2854 | } |
---|
[608] | 2855 | |
---|
| 2856 | for ( Int i = 0; i < iNumRefIdx; i++ ) |
---|
| 2857 | { |
---|
| 2858 | if( getRefPic( eRefPicList, i)->getPOC() != getPOC() ) |
---|
| 2859 | { |
---|
| 2860 | bAllIvRef = false; |
---|
| 2861 | break; |
---|
| 2862 | } |
---|
| 2863 | } |
---|
| 2864 | |
---|
| 2865 | if( bAllIvRef == false ) { break; } |
---|
[56] | 2866 | } |
---|
[608] | 2867 | m_nARPStepNum = !bAllIvRef ? getVPS()->getARPStepNum(getLayerId()) : 0; |
---|
[56] | 2868 | } |
---|
| 2869 | } |
---|
[608] | 2870 | #endif |
---|
| 2871 | #if H_3D_IC |
---|
| 2872 | Void TComSlice::xSetApplyIC() |
---|
| 2873 | { |
---|
| 2874 | Int iMaxPelValue = ( 1 << g_bitDepthY ); |
---|
| 2875 | Int *aiRefOrgHist; |
---|
| 2876 | Int *aiCurrHist; |
---|
| 2877 | aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
| 2878 | aiCurrHist = (Int *) xMalloc( Int,iMaxPelValue ); |
---|
| 2879 | memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
| 2880 | memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) ); |
---|
| 2881 | // Reference Idx Number |
---|
| 2882 | Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 ); |
---|
| 2883 | TComPic* pcCurrPic = NULL; |
---|
| 2884 | TComPic* pcRefPic = NULL; |
---|
| 2885 | TComPicYuv* pcCurrPicYuv = NULL; |
---|
| 2886 | TComPicYuv* pcRefPicYuvOrg = NULL; |
---|
| 2887 | pcCurrPic = getPic(); |
---|
| 2888 | pcCurrPicYuv = pcCurrPic->getPicYuvOrg(); |
---|
| 2889 | Int iWidth = pcCurrPicYuv->getWidth(); |
---|
| 2890 | Int iHeight = pcCurrPicYuv->getHeight(); |
---|
| 2891 | |
---|
| 2892 | |
---|
| 2893 | // Get InterView Reference picture |
---|
| 2894 | // !!!!! Assume only one Interview Reference Picture in L0 |
---|
| 2895 | for ( Int i = 0; i < iNumRefIdx; i++ ) |
---|
| 2896 | { |
---|
| 2897 | pcRefPic = getRefPic( REF_PIC_LIST_0, i ); |
---|
| 2898 | if ( pcRefPic != NULL ) |
---|
| 2899 | { |
---|
| 2900 | if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() ) |
---|
| 2901 | { |
---|
| 2902 | pcRefPicYuvOrg = pcRefPic->getPicYuvOrg(); |
---|
| 2903 | } |
---|
| 2904 | } |
---|
| 2905 | } |
---|
| 2906 | |
---|
| 2907 | if ( pcRefPicYuvOrg != NULL ) |
---|
| 2908 | { |
---|
| 2909 | Pel* pCurrY = pcCurrPicYuv ->getLumaAddr(); |
---|
| 2910 | Pel* pRefOrgY = pcRefPicYuvOrg ->getLumaAddr(); |
---|
| 2911 | Int iCurrStride = pcCurrPicYuv->getStride(); |
---|
| 2912 | Int iRefStride = pcRefPicYuvOrg->getStride(); |
---|
| 2913 | Int iSumOrgSAD = 0; |
---|
| 2914 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
| 2915 | |
---|
| 2916 | // Histogram building - luminance |
---|
| 2917 | for ( Int y = 0; y < iHeight; y++ ) |
---|
| 2918 | { |
---|
| 2919 | for ( Int x = 0; x < iWidth; x++ ) |
---|
| 2920 | { |
---|
| 2921 | aiCurrHist[pCurrY[x]]++; |
---|
| 2922 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
| 2923 | } |
---|
| 2924 | pCurrY += iCurrStride; |
---|
| 2925 | pRefOrgY += iRefStride; |
---|
| 2926 | } |
---|
| 2927 | // Histogram SAD |
---|
| 2928 | for ( Int i = 0; i < iMaxPelValue; i++ ) |
---|
| 2929 | { |
---|
| 2930 | iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] ); |
---|
| 2931 | } |
---|
| 2932 | // Setting |
---|
| 2933 | if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) ) |
---|
| 2934 | { |
---|
| 2935 | m_bApplyIC = true; |
---|
| 2936 | } |
---|
| 2937 | else |
---|
| 2938 | { |
---|
| 2939 | m_bApplyIC = false; |
---|
| 2940 | } |
---|
| 2941 | } |
---|
| 2942 | |
---|
| 2943 | xFree( aiCurrHist ); |
---|
| 2944 | xFree( aiRefOrgHist ); |
---|
| 2945 | aiCurrHist = NULL; |
---|
| 2946 | aiRefOrgHist = NULL; |
---|
| 2947 | } |
---|
| 2948 | #endif |
---|
| 2949 | #if H_3D |
---|
| 2950 | Void TComSlice::setIvPicLists( TComPicLists* m_ivPicLists ) |
---|
| 2951 | { |
---|
| 2952 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 2953 | { |
---|
| 2954 | for ( Int depthId = 0; depthId < 2; depthId++ ) |
---|
| 2955 | { |
---|
| 2956 | m_ivPicsCurrPoc[ depthId ][ i ] = ( i <= m_viewIndex ) ? m_ivPicLists->getPic( i, ( depthId == 1) , getPOC() ) : NULL; |
---|
| 2957 | } |
---|
| 2958 | } |
---|
| 2959 | } |
---|
| 2960 | Void TComSlice::setDepthToDisparityLUTs() |
---|
| 2961 | { |
---|
| 2962 | Bool setupLUT = false; |
---|
| 2963 | Int layerIdInVPS = getVPS()->getLayerIdInNuh( m_layerId ); |
---|
| 2964 | |
---|
| 2965 | #if H_3D_VSP |
---|
| 2966 | setupLUT = setupLUT || getVPS()->getViewSynthesisPredFlag( layerIdInVPS); |
---|
| 2967 | #endif |
---|
| 2968 | |
---|
| 2969 | #if H_3D_NBDV_REF |
---|
| 2970 | setupLUT = setupLUT || getVPS()->getDepthRefinementFlag( layerIdInVPS ); |
---|
| 2971 | #endif |
---|
| 2972 | |
---|
[669] | 2973 | #if QC_DEPTH_IV_MRG_F0125 |
---|
| 2974 | setupLUT = setupLUT || ( getVPS()->getIvMvPredFlag(layerIdInVPS ) && getIsDepth() ); |
---|
| 2975 | #endif |
---|
| 2976 | |
---|
[608] | 2977 | if( !setupLUT ) |
---|
| 2978 | return; |
---|
| 2979 | |
---|
| 2980 | /// GT: Allocation should be moved to a better place later; |
---|
| 2981 | if ( m_depthToDisparityB == NULL ) |
---|
| 2982 | { |
---|
| 2983 | m_depthToDisparityB = new Int*[ getViewIndex() ]; |
---|
| 2984 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
| 2985 | { |
---|
| 2986 | m_depthToDisparityB[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
| 2987 | } |
---|
| 2988 | } |
---|
| 2989 | |
---|
| 2990 | if ( m_depthToDisparityF == NULL ) |
---|
| 2991 | { |
---|
| 2992 | m_depthToDisparityF= new Int*[ getViewIndex() ]; |
---|
| 2993 | for ( Int i = 0; i < getViewIndex(); i++ ) |
---|
| 2994 | { |
---|
| 2995 | m_depthToDisparityF[ i ] = new Int[ Int(1 << g_bitDepthY) ]; |
---|
| 2996 | } |
---|
| 2997 | } |
---|
| 2998 | |
---|
| 2999 | assert( m_depthToDisparityB != NULL ); |
---|
| 3000 | assert( m_depthToDisparityF != NULL ); |
---|
| 3001 | |
---|
| 3002 | TComSPS* sps = getSPS(); |
---|
| 3003 | |
---|
| 3004 | Int log2Div = g_bitDepthY - 1 + sps->getCamParPrecision(); |
---|
| 3005 | |
---|
| 3006 | Bool camParaSH = m_pcSPS->hasCamParInSliceHeader(); |
---|
| 3007 | |
---|
| 3008 | Int* codScale = camParaSH ? m_aaiCodedScale [ 0 ] : sps->getCodedScale (); |
---|
| 3009 | Int* codOffset = camParaSH ? m_aaiCodedOffset[ 0 ] : sps->getCodedOffset (); |
---|
| 3010 | Int* invCodScale = camParaSH ? m_aaiCodedScale [ 1 ] : sps->getInvCodedScale (); |
---|
| 3011 | Int* invCodOffset = camParaSH ? m_aaiCodedOffset[ 1 ] : sps->getInvCodedOffset(); |
---|
| 3012 | |
---|
| 3013 | for (Int i = 0; i <= ( getViewIndex() - 1); i++) |
---|
| 3014 | { |
---|
| 3015 | for ( Int d = 0; d <= ( ( 1 << g_bitDepthY ) - 1 ); d++ ) |
---|
| 3016 | { |
---|
| 3017 | Int offset = ( codOffset [ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
| 3018 | m_depthToDisparityB[ i ][ d ] = ( codScale [ i ] * d + offset ) >> log2Div; |
---|
| 3019 | |
---|
| 3020 | Int invOffset = ( invCodOffset[ i ] << g_bitDepthY ) + ( ( 1 << log2Div ) >> 1 ); |
---|
| 3021 | m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div; |
---|
| 3022 | } |
---|
| 3023 | } |
---|
| 3024 | } |
---|
| 3025 | #endif |
---|
| 3026 | #endif |
---|
[56] | 3027 | /** get scaling matrix from RefMatrixID |
---|
| 3028 | * \param sizeId size index |
---|
| 3029 | * \param Index of input matrix |
---|
| 3030 | * \param Index of reference matrix |
---|
| 3031 | */ |
---|
| 3032 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 3033 | { |
---|
[608] | 3034 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
[56] | 3035 | } |
---|
[608] | 3036 | |
---|
[56] | 3037 | /** parse syntax infomation |
---|
| 3038 | * \param pchFile syntax infomation |
---|
| 3039 | * \returns false if successful |
---|
| 3040 | */ |
---|
[608] | 3041 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
[56] | 3042 | { |
---|
| 3043 | FILE *fp; |
---|
| 3044 | Char line[1024]; |
---|
| 3045 | UInt sizeIdc,listIdc; |
---|
| 3046 | UInt i,size = 0; |
---|
| 3047 | Int *src=0,data; |
---|
| 3048 | Char *ret; |
---|
| 3049 | UInt retval; |
---|
| 3050 | |
---|
| 3051 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
| 3052 | { |
---|
| 3053 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
| 3054 | return true; |
---|
| 3055 | } |
---|
| 3056 | |
---|
| 3057 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 3058 | { |
---|
| 3059 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 3060 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
| 3061 | { |
---|
| 3062 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 3063 | |
---|
| 3064 | fseek(fp,0,0); |
---|
| 3065 | do |
---|
| 3066 | { |
---|
| 3067 | ret = fgets(line, 1024, fp); |
---|
| 3068 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 3069 | { |
---|
| 3070 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 3071 | return true; |
---|
| 3072 | } |
---|
| 3073 | } |
---|
| 3074 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
| 3075 | for (i=0; i<size; i++) |
---|
| 3076 | { |
---|
| 3077 | retval = fscanf(fp, "%d,", &data); |
---|
| 3078 | if (retval!=1) |
---|
| 3079 | { |
---|
| 3080 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 3081 | return true; |
---|
| 3082 | } |
---|
| 3083 | src[i] = data; |
---|
| 3084 | } |
---|
| 3085 | //set DC value for default matrix check |
---|
| 3086 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 3087 | |
---|
| 3088 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 3089 | { |
---|
| 3090 | fseek(fp,0,0); |
---|
| 3091 | do |
---|
| 3092 | { |
---|
| 3093 | ret = fgets(line, 1024, fp); |
---|
| 3094 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 3095 | { |
---|
| 3096 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
| 3097 | return true; |
---|
| 3098 | } |
---|
| 3099 | } |
---|
| 3100 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
[608] | 3101 | retval = fscanf(fp, "%d,", &data); |
---|
| 3102 | if (retval!=1) |
---|
| 3103 | { |
---|
| 3104 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 3105 | return true; |
---|
| 3106 | } |
---|
| 3107 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 3108 | setScalingListDC(sizeIdc,listIdc,data); |
---|
[56] | 3109 | } |
---|
| 3110 | } |
---|
| 3111 | } |
---|
| 3112 | fclose(fp); |
---|
| 3113 | return false; |
---|
| 3114 | } |
---|
| 3115 | |
---|
[622] | 3116 | #if H_MV |
---|
| 3117 | Void TComScalingList::inferFrom( TComScalingList* srcScLi ) |
---|
| 3118 | { |
---|
| 3119 | for(Int sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3120 | { |
---|
| 3121 | for(Int listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3122 | { |
---|
| 3123 | setRefMatrixId (sizeId,listId, srcScLi->getRefMatrixId (sizeId,listId)); |
---|
| 3124 | setScalingListDC(sizeId,listId, srcScLi->getScalingListDC(sizeId,listId)); |
---|
| 3125 | ::memcpy(getScalingListAddress(sizeId, listId),srcScLi->getScalingListAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 3126 | } |
---|
| 3127 | } |
---|
| 3128 | } |
---|
| 3129 | #endif |
---|
[56] | 3130 | /** initialization process of quantization matrix array |
---|
| 3131 | */ |
---|
| 3132 | Void TComScalingList::init() |
---|
| 3133 | { |
---|
| 3134 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3135 | { |
---|
| 3136 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3137 | { |
---|
| 3138 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
| 3139 | } |
---|
| 3140 | } |
---|
| 3141 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
| 3142 | } |
---|
[608] | 3143 | |
---|
[56] | 3144 | /** destroy quantization matrix array |
---|
| 3145 | */ |
---|
| 3146 | Void TComScalingList::destroy() |
---|
| 3147 | { |
---|
| 3148 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3149 | { |
---|
| 3150 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3151 | { |
---|
| 3152 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
| 3153 | } |
---|
| 3154 | } |
---|
| 3155 | } |
---|
[608] | 3156 | |
---|
[56] | 3157 | /** get default address of quantization matrix |
---|
| 3158 | * \param sizeId size index |
---|
| 3159 | * \param listId list index |
---|
| 3160 | * \returns pointer of quantization matrix |
---|
| 3161 | */ |
---|
| 3162 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
| 3163 | { |
---|
| 3164 | Int *src = 0; |
---|
| 3165 | switch(sizeId) |
---|
| 3166 | { |
---|
| 3167 | case SCALING_LIST_4x4: |
---|
[608] | 3168 | src = g_quantTSDefault4x4; |
---|
[56] | 3169 | break; |
---|
| 3170 | case SCALING_LIST_8x8: |
---|
| 3171 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 3172 | break; |
---|
| 3173 | case SCALING_LIST_16x16: |
---|
| 3174 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 3175 | break; |
---|
| 3176 | case SCALING_LIST_32x32: |
---|
| 3177 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 3178 | break; |
---|
| 3179 | default: |
---|
| 3180 | assert(0); |
---|
| 3181 | src = NULL; |
---|
| 3182 | break; |
---|
| 3183 | } |
---|
| 3184 | return src; |
---|
| 3185 | } |
---|
[608] | 3186 | |
---|
[56] | 3187 | /** process of default matrix |
---|
| 3188 | * \param sizeId size index |
---|
| 3189 | * \param Index of input matrix |
---|
| 3190 | */ |
---|
| 3191 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
| 3192 | { |
---|
| 3193 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 3194 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 3195 | } |
---|
[608] | 3196 | |
---|
[56] | 3197 | /** check DC value of matrix for default matrix signaling |
---|
| 3198 | */ |
---|
| 3199 | Void TComScalingList::checkDcOfMatrix() |
---|
| 3200 | { |
---|
| 3201 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3202 | { |
---|
| 3203 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3204 | { |
---|
| 3205 | //check default matrix? |
---|
| 3206 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 3207 | { |
---|
| 3208 | processDefaultMarix(sizeId, listId); |
---|
| 3209 | } |
---|
| 3210 | } |
---|
| 3211 | } |
---|
| 3212 | } |
---|
| 3213 | |
---|
| 3214 | ParameterSetManager::ParameterSetManager() |
---|
[608] | 3215 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 3216 | , m_spsMap(MAX_NUM_SPS) |
---|
[56] | 3217 | , m_ppsMap(MAX_NUM_PPS) |
---|
[608] | 3218 | , m_activeVPSId(-1) |
---|
[622] | 3219 | #if !H_MV |
---|
[608] | 3220 | , m_activeSPSId(-1) |
---|
| 3221 | , m_activePPSId(-1) |
---|
[56] | 3222 | { |
---|
[622] | 3223 | #else |
---|
| 3224 | { |
---|
| 3225 | for (Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 3226 | { |
---|
| 3227 | m_activeSPSId[ i ] = -1; |
---|
| 3228 | m_activePPSId[ i ] = -1; |
---|
| 3229 | } |
---|
| 3230 | #endif |
---|
[56] | 3231 | } |
---|
| 3232 | |
---|
| 3233 | |
---|
| 3234 | ParameterSetManager::~ParameterSetManager() |
---|
| 3235 | { |
---|
| 3236 | } |
---|
| 3237 | |
---|
[608] | 3238 | //! activate a SPS from a active parameter sets SEI message |
---|
| 3239 | //! \returns true, if activation is successful |
---|
[622] | 3240 | #if H_MV |
---|
| 3241 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId, Int layerId ) |
---|
| 3242 | #else |
---|
[608] | 3243 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
[622] | 3244 | #endif |
---|
[608] | 3245 | { |
---|
| 3246 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 3247 | if (sps) |
---|
| 3248 | { |
---|
| 3249 | Int vpsId = sps->getVPSId(); |
---|
| 3250 | if (m_vpsMap.getPS(vpsId)) |
---|
| 3251 | { |
---|
| 3252 | m_activeVPSId = vpsId; |
---|
[622] | 3253 | #if H_MV |
---|
| 3254 | m_activeSPSId[ layerId ] = spsId; |
---|
| 3255 | #else |
---|
| 3256 | m_activeSPSId = spsId; |
---|
| 3257 | #endif |
---|
[608] | 3258 | return true; |
---|
| 3259 | } |
---|
| 3260 | else |
---|
| 3261 | { |
---|
| 3262 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
| 3263 | } |
---|
| 3264 | } |
---|
| 3265 | else |
---|
| 3266 | { |
---|
| 3267 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
| 3268 | } |
---|
| 3269 | return false; |
---|
| 3270 | } |
---|
| 3271 | |
---|
| 3272 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
| 3273 | //! \returns true, if activation is successful |
---|
[622] | 3274 | #if H_MV |
---|
| 3275 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP, Int layerId ) |
---|
| 3276 | #else |
---|
[608] | 3277 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
[622] | 3278 | #endif |
---|
[608] | 3279 | { |
---|
| 3280 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
| 3281 | if (pps) |
---|
| 3282 | { |
---|
| 3283 | Int spsId = pps->getSPSId(); |
---|
| 3284 | #if H_MV |
---|
[622] | 3285 | if (!isIRAP && (spsId != m_activeSPSId[ layerId ])) |
---|
| 3286 | #else |
---|
| 3287 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
| 3288 | #endif |
---|
| 3289 | { |
---|
| 3290 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
| 3291 | return false; |
---|
| 3292 | } |
---|
| 3293 | |
---|
| 3294 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 3295 | if (sps) |
---|
| 3296 | { |
---|
| 3297 | Int vpsId = sps->getVPSId(); |
---|
| 3298 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
| 3299 | { |
---|
| 3300 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
| 3301 | return false; |
---|
| 3302 | } |
---|
| 3303 | if (m_vpsMap.getPS(vpsId)) |
---|
| 3304 | { |
---|
| 3305 | #if H_MV |
---|
| 3306 | m_activePPSId[ layerId ] = ppsId; |
---|
| 3307 | m_activeVPSId = vpsId; |
---|
| 3308 | m_activeSPSId[ layerId ] = spsId; |
---|
| 3309 | #else |
---|
| 3310 | m_activePPSId = ppsId; |
---|
| 3311 | m_activeVPSId = vpsId; |
---|
| 3312 | m_activeSPSId = spsId; |
---|
| 3313 | #endif |
---|
[608] | 3314 | return true; |
---|
| 3315 | } |
---|
| 3316 | else |
---|
| 3317 | { |
---|
| 3318 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
| 3319 | } |
---|
| 3320 | } |
---|
| 3321 | else |
---|
| 3322 | { |
---|
| 3323 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
| 3324 | } |
---|
| 3325 | } |
---|
| 3326 | else |
---|
| 3327 | { |
---|
| 3328 | printf("Warning: tried to activate non-existing PPS."); |
---|
| 3329 | } |
---|
| 3330 | return false; |
---|
| 3331 | } |
---|
| 3332 | |
---|
| 3333 | ProfileTierLevel::ProfileTierLevel() |
---|
| 3334 | : m_profileSpace (0) |
---|
| 3335 | , m_tierFlag (false) |
---|
| 3336 | , m_profileIdc (0) |
---|
| 3337 | , m_levelIdc (0) |
---|
| 3338 | , m_progressiveSourceFlag (false) |
---|
| 3339 | , m_interlacedSourceFlag (false) |
---|
| 3340 | , m_nonPackedConstraintFlag(false) |
---|
| 3341 | , m_frameOnlyConstraintFlag(false) |
---|
| 3342 | { |
---|
| 3343 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 3344 | } |
---|
| 3345 | |
---|
| 3346 | TComPTL::TComPTL() |
---|
| 3347 | { |
---|
| 3348 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 3349 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 3350 | } |
---|
| 3351 | |
---|
| 3352 | #if H_MV |
---|
| 3353 | Void TComPTL::copyLevelFrom( TComPTL* source ) |
---|
| 3354 | { |
---|
| 3355 | getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() ); |
---|
| 3356 | for( Int subLayer = 0; subLayer < 6; subLayer++ ) |
---|
| 3357 | { |
---|
| 3358 | setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) ); |
---|
| 3359 | getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() ); |
---|
| 3360 | } |
---|
| 3361 | } |
---|
| 3362 | #endif |
---|
[622] | 3363 | //! \} |
---|
| 3364 | |
---|
| 3365 | #if H_MV |
---|
| 3366 | TComVPSVUI::TComVPSVUI() |
---|
[608] | 3367 | { |
---|
[622] | 3368 | m_bitRatePresentVpsFlag = false; |
---|
| 3369 | m_picRatePresentVpsFlag = false; |
---|
| 3370 | for ( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++) |
---|
| 3371 | { |
---|
| 3372 | for ( Int j = 0; j < MAX_TLAYER; j++) |
---|
| 3373 | { |
---|
| 3374 | m_bitRatePresentFlag [i][j] = false; |
---|
| 3375 | m_picRatePresentFlag [i][j] = false; |
---|
| 3376 | m_avgBitRate [i][j] = -1; |
---|
| 3377 | m_maxBitRate [i][j] = -1; |
---|
| 3378 | m_constantPicRateIdc [i][j] = -1; |
---|
| 3379 | m_avgPicRate [i][j] = -1; |
---|
| 3380 | } |
---|
| 3381 | } |
---|
| 3382 | |
---|
| 3383 | m_ilpRestrictedRefLayersFlag = false; |
---|
| 3384 | |
---|
| 3385 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
| 3386 | { |
---|
| 3387 | for ( Int j = 0; j < MAX_NUM_LAYERS; j++) |
---|
| 3388 | { |
---|
| 3389 | m_tileBoundariesAlignedFlag [i][j] = false; |
---|
| 3390 | m_minSpatialSegmentOffsetPlus1[i][j] = 0; |
---|
| 3391 | m_ctuBasedOffsetEnabledFlag [i][j] = false; |
---|
| 3392 | m_minHorizontalCtuOffsetPlus1 [i][j] = -1; |
---|
| 3393 | } |
---|
| 3394 | } |
---|
[608] | 3395 | } |
---|
| 3396 | #endif |
---|