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