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