[324] | 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 ) |
---|
[446] | 51 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
[324] | 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 ) |
---|
[446] | 62 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 63 | , m_bRefPicListModificationFlagLC ( false ) |
---|
| 64 | , m_bRefPicListCombinationFlag ( false ) |
---|
[446] | 65 | #endif |
---|
[324] | 66 | , m_bCheckLDC ( false ) |
---|
| 67 | , m_iSliceQpDelta ( 0 ) |
---|
| 68 | , m_iSliceQpDeltaCb ( 0 ) |
---|
| 69 | , m_iSliceQpDeltaCr ( 0 ) |
---|
| 70 | , m_iDepth ( 0 ) |
---|
| 71 | , m_bRefenced ( false ) |
---|
| 72 | , m_pcSPS ( NULL ) |
---|
| 73 | , m_pcPPS ( NULL ) |
---|
| 74 | , m_pcPic ( NULL ) |
---|
| 75 | , m_colFromL0Flag ( 1 ) |
---|
| 76 | , m_colRefIdx ( 0 ) |
---|
| 77 | #if SAO_CHROMA_LAMBDA |
---|
| 78 | , m_dLambdaLuma( 0.0 ) |
---|
| 79 | , m_dLambdaChroma( 0.0 ) |
---|
| 80 | #else |
---|
| 81 | , m_dLambda ( 0.0 ) |
---|
| 82 | #endif |
---|
[446] | 83 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 84 | , m_bNoBackPredFlag ( false ) |
---|
[446] | 85 | #endif |
---|
[324] | 86 | , m_uiTLayer ( 0 ) |
---|
| 87 | , m_bTLayerSwitchingFlag ( false ) |
---|
| 88 | , m_sliceMode ( 0 ) |
---|
| 89 | , m_sliceArgument ( 0 ) |
---|
| 90 | , m_sliceCurStartCUAddr ( 0 ) |
---|
| 91 | , m_sliceCurEndCUAddr ( 0 ) |
---|
| 92 | , m_sliceIdx ( 0 ) |
---|
| 93 | , m_sliceSegmentMode ( 0 ) |
---|
| 94 | , m_sliceSegmentArgument ( 0 ) |
---|
| 95 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
| 96 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
| 97 | , m_nextSlice ( false ) |
---|
| 98 | , m_nextSliceSegment ( false ) |
---|
| 99 | , m_sliceBits ( 0 ) |
---|
| 100 | , m_sliceSegmentBits ( 0 ) |
---|
| 101 | , m_bFinalized ( false ) |
---|
| 102 | , m_uiTileOffstForMultES ( 0 ) |
---|
| 103 | , m_puiSubstreamSizes ( NULL ) |
---|
| 104 | , m_cabacInitFlag ( false ) |
---|
| 105 | , m_bLMvdL1Zero ( false ) |
---|
| 106 | , m_numEntryPointOffsets ( 0 ) |
---|
| 107 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
| 108 | , m_enableTMVPFlag ( true ) |
---|
[368] | 109 | #if H_MV |
---|
| 110 | , m_layerId (0) |
---|
| 111 | , m_viewId (0) |
---|
| 112 | #if H_3D |
---|
[446] | 113 | , m_viewIndex (0) |
---|
[368] | 114 | , m_isDepth (false) |
---|
| 115 | #endif |
---|
| 116 | #endif |
---|
[324] | 117 | { |
---|
[446] | 118 | #if L0034_COMBINED_LIST_CLEANUP |
---|
| 119 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
| 120 | #else |
---|
[324] | 121 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0; |
---|
[446] | 122 | #endif |
---|
[324] | 123 | |
---|
| 124 | initEqualRef(); |
---|
| 125 | |
---|
[446] | 126 | #if L0034_COMBINED_LIST_CLEANUP |
---|
| 127 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
| 128 | { |
---|
| 129 | m_list1IdxToList0Idx[idx] = -1; |
---|
| 130 | } |
---|
| 131 | #else |
---|
[324] | 132 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
| 133 | { |
---|
| 134 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
| 135 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
| 136 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
| 137 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
| 138 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
| 139 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
| 140 | } |
---|
[446] | 141 | #endif |
---|
[324] | 142 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
| 143 | { |
---|
| 144 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
| 145 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
| 146 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
| 147 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
[368] | 148 | #if H_MV |
---|
| 149 | m_aiRefLayerIdList[0][iNumCount] = 0; |
---|
| 150 | m_aiRefLayerIdList[1][iNumCount] = 0; |
---|
| 151 | #endif |
---|
[324] | 152 | } |
---|
[446] | 153 | resetWpScaling(); |
---|
[324] | 154 | initWpAcDcParam(); |
---|
| 155 | m_saoEnabledFlag = false; |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | TComSlice::~TComSlice() |
---|
| 159 | { |
---|
| 160 | delete[] m_puiSubstreamSizes; |
---|
| 161 | m_puiSubstreamSizes = NULL; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | Void TComSlice::initSlice() |
---|
| 166 | { |
---|
| 167 | m_aiNumRefIdx[0] = 0; |
---|
| 168 | m_aiNumRefIdx[1] = 0; |
---|
| 169 | |
---|
| 170 | m_colFromL0Flag = 1; |
---|
| 171 | |
---|
| 172 | m_colRefIdx = 0; |
---|
| 173 | initEqualRef(); |
---|
[446] | 174 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 175 | m_bNoBackPredFlag = false; |
---|
| 176 | m_bRefPicListCombinationFlag = false; |
---|
| 177 | m_bRefPicListModificationFlagLC = false; |
---|
[446] | 178 | #endif |
---|
[324] | 179 | m_bCheckLDC = false; |
---|
| 180 | m_iSliceQpDeltaCb = 0; |
---|
| 181 | m_iSliceQpDeltaCr = 0; |
---|
| 182 | |
---|
[446] | 183 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 184 | m_aiNumRefIdx[REF_PIC_LIST_C] = 0; |
---|
[446] | 185 | #endif |
---|
[324] | 186 | |
---|
| 187 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
| 188 | |
---|
| 189 | m_bFinalized=false; |
---|
| 190 | |
---|
| 191 | m_tileByteLocation.clear(); |
---|
| 192 | m_cabacInitFlag = false; |
---|
| 193 | m_numEntryPointOffsets = 0; |
---|
| 194 | m_enableTMVPFlag = true; |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | Bool TComSlice::getRapPicFlag() |
---|
| 198 | { |
---|
[446] | 199 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
[324] | 200 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
| 201 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
[446] | 202 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 203 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
[324] | 204 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | /** |
---|
| 208 | - allocate table to contain substream sizes to be written to the slice header. |
---|
| 209 | . |
---|
| 210 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
| 211 | */ |
---|
| 212 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
| 213 | { |
---|
| 214 | delete[] m_puiSubstreamSizes; |
---|
| 215 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
| 219 | { |
---|
| 220 | TComPic* pcPicExtract; |
---|
| 221 | TComPic* pcPicInsert; |
---|
| 222 | |
---|
| 223 | TComList<TComPic*>::iterator iterPicExtract; |
---|
| 224 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
| 225 | TComList<TComPic*>::iterator iterPicInsert; |
---|
| 226 | |
---|
| 227 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
| 228 | { |
---|
| 229 | iterPicExtract = rcListPic.begin(); |
---|
| 230 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
| 231 | pcPicExtract = *(iterPicExtract); |
---|
| 232 | pcPicExtract->setCurrSliceIdx(0); |
---|
| 233 | |
---|
| 234 | iterPicInsert = rcListPic.begin(); |
---|
| 235 | while (iterPicInsert != iterPicExtract) |
---|
| 236 | { |
---|
| 237 | pcPicInsert = *(iterPicInsert); |
---|
| 238 | pcPicInsert->setCurrSliceIdx(0); |
---|
| 239 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
| 240 | { |
---|
| 241 | break; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | iterPicInsert++; |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
| 248 | |
---|
| 249 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
| 250 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
| 251 | rcListPic.erase (iterPicExtract); |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
| 256 | Int poc) |
---|
| 257 | { |
---|
| 258 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 259 | TComPic* pcPic = *(iterPic); |
---|
| 260 | while ( iterPic != rcListPic.end() ) |
---|
| 261 | { |
---|
| 262 | if(pcPic->getPOC() == poc) |
---|
| 263 | { |
---|
| 264 | break; |
---|
| 265 | } |
---|
| 266 | iterPic++; |
---|
| 267 | pcPic = *(iterPic); |
---|
| 268 | } |
---|
| 269 | return pcPic; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | |
---|
[446] | 273 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
[324] | 274 | { |
---|
| 275 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 276 | TComPic* pcPic = *(iterPic); |
---|
| 277 | TComPic* pcStPic = pcPic; |
---|
[446] | 278 | |
---|
| 279 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
| 280 | if (!pocHasMsb) |
---|
| 281 | { |
---|
| 282 | poc = poc % pocCycle; |
---|
| 283 | } |
---|
| 284 | |
---|
[324] | 285 | while ( iterPic != rcListPic.end() ) |
---|
| 286 | { |
---|
| 287 | pcPic = *(iterPic); |
---|
[446] | 288 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
[324] | 289 | { |
---|
[446] | 290 | Int picPoc = pcPic->getPOC(); |
---|
| 291 | if (!pocHasMsb) |
---|
| 292 | { |
---|
| 293 | picPoc = picPoc % pocCycle; |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | if (poc == picPoc) |
---|
| 297 | { |
---|
[324] | 298 | if(pcPic->getIsLongTerm()) |
---|
| 299 | { |
---|
| 300 | return pcPic; |
---|
| 301 | } |
---|
| 302 | else |
---|
| 303 | { |
---|
| 304 | pcStPic = pcPic; |
---|
| 305 | } |
---|
| 306 | break; |
---|
| 307 | } |
---|
[446] | 308 | } |
---|
[324] | 309 | |
---|
| 310 | iterPic++; |
---|
| 311 | } |
---|
[446] | 312 | |
---|
[324] | 313 | return pcStPic; |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | Void TComSlice::setRefPOCList () |
---|
| 317 | { |
---|
| 318 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 319 | { |
---|
| 320 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
| 321 | { |
---|
| 322 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
[368] | 323 | #if H_MV |
---|
| 324 | m_aiRefLayerIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getLayerId(); |
---|
| 325 | #endif |
---|
[324] | 326 | } |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | } |
---|
| 330 | |
---|
[446] | 331 | #if L0034_COMBINED_LIST_CLEANUP |
---|
| 332 | Void TComSlice::setList1IdxToList0Idx() |
---|
| 333 | { |
---|
| 334 | Int idxL0, idxL1; |
---|
| 335 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
| 336 | { |
---|
| 337 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
| 338 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
| 339 | { |
---|
| 340 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
| 341 | { |
---|
| 342 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
| 343 | break; |
---|
| 344 | } |
---|
| 345 | } |
---|
| 346 | } |
---|
| 347 | } |
---|
| 348 | #else |
---|
[324] | 349 | Void TComSlice::generateCombinedList() |
---|
| 350 | { |
---|
| 351 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
| 352 | { |
---|
| 353 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
| 354 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
| 355 | { |
---|
| 356 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
| 357 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
| 358 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
| 359 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
| 360 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
| 361 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
| 365 | { |
---|
| 366 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
| 367 | { |
---|
| 368 | Bool bTempRefIdxInL2 = true; |
---|
| 369 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
| 370 | { |
---|
[368] | 371 | #if H_MV |
---|
| 372 | if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() && |
---|
| 373 | m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getLayerId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getLayerId() ) |
---|
| 374 | #else |
---|
[324] | 375 | if ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
[368] | 376 | #endif |
---|
[324] | 377 | { |
---|
| 378 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
| 379 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
| 380 | bTempRefIdxInL2 = false; |
---|
| 381 | break; |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | if(bTempRefIdxInL2 == true) |
---|
| 386 | { |
---|
| 387 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
| 388 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
| 389 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
| 390 | } |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]) |
---|
| 394 | { |
---|
| 395 | Bool bTempRefIdxInL2 = true; |
---|
| 396 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
| 397 | { |
---|
[368] | 398 | #if H_MV |
---|
| 399 | if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() && |
---|
| 400 | m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getLayerId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getLayerId() ) |
---|
| 401 | #else |
---|
[324] | 402 | if ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) |
---|
[368] | 403 | #endif |
---|
[324] | 404 | { |
---|
| 405 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
| 406 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
| 407 | bTempRefIdxInL2 = false; |
---|
| 408 | break; |
---|
| 409 | } |
---|
| 410 | } |
---|
| 411 | if(bTempRefIdxInL2 == true) |
---|
| 412 | { |
---|
| 413 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
| 414 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
| 415 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | } |
---|
| 420 | } |
---|
[446] | 421 | #endif |
---|
[324] | 422 | |
---|
[368] | 423 | #if H_MV |
---|
[446] | 424 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& refPicSetInterLayer , Bool checkNumPocTotalCurr) |
---|
[368] | 425 | #else |
---|
[446] | 426 | #if FIX1071 |
---|
| 427 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
| 428 | #else |
---|
[324] | 429 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic ) |
---|
| 430 | #endif |
---|
[446] | 431 | #endif |
---|
[324] | 432 | { |
---|
[446] | 433 | #if FIX1071 |
---|
| 434 | if (!checkNumPocTotalCurr) |
---|
| 435 | #endif |
---|
[324] | 436 | { |
---|
[446] | 437 | if (m_eSliceType == I_SLICE) |
---|
| 438 | { |
---|
| 439 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 440 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 441 | |
---|
| 442 | return; |
---|
| 443 | } |
---|
[324] | 444 | |
---|
[368] | 445 | #if !H_MV |
---|
[446] | 446 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 447 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
[368] | 448 | #endif |
---|
[446] | 449 | } |
---|
[324] | 450 | |
---|
| 451 | TComPic* pcRefPic= NULL; |
---|
| 452 | TComPic* RefPicSetStCurr0[16]; |
---|
| 453 | TComPic* RefPicSetStCurr1[16]; |
---|
| 454 | TComPic* RefPicSetLtCurr[16]; |
---|
| 455 | UInt NumPocStCurr0 = 0; |
---|
| 456 | UInt NumPocStCurr1 = 0; |
---|
| 457 | UInt NumPocLtCurr = 0; |
---|
[368] | 458 | #if H_MV |
---|
| 459 | Int numDirectRefLayers = getVPS()->getNumDirectRefLayers( getLayerIdInVps() ); |
---|
| 460 | assert( numDirectRefLayers == refPicSetInterLayer.size() ); |
---|
| 461 | #endif |
---|
[324] | 462 | Int i; |
---|
| 463 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
| 464 | { |
---|
| 465 | if(m_pcRPS->getUsed(i)) |
---|
| 466 | { |
---|
| 467 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 468 | pcRefPic->setIsLongTerm(0); |
---|
| 469 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 470 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
| 471 | NumPocStCurr0++; |
---|
| 472 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 473 | } |
---|
| 474 | } |
---|
[446] | 475 | |
---|
[324] | 476 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
| 477 | { |
---|
| 478 | if(m_pcRPS->getUsed(i)) |
---|
| 479 | { |
---|
| 480 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
| 481 | pcRefPic->setIsLongTerm(0); |
---|
| 482 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 483 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
| 484 | NumPocStCurr1++; |
---|
| 485 | pcRefPic->setCheckLTMSBPresent(false); |
---|
| 486 | } |
---|
| 487 | } |
---|
[446] | 488 | |
---|
[324] | 489 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
| 490 | { |
---|
| 491 | if(m_pcRPS->getUsed(i)) |
---|
| 492 | { |
---|
[446] | 493 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
[324] | 494 | pcRefPic->setIsLongTerm(1); |
---|
| 495 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
| 496 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
| 497 | NumPocLtCurr++; |
---|
| 498 | } |
---|
| 499 | if(pcRefPic==NULL) |
---|
| 500 | { |
---|
[446] | 501 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
[324] | 502 | } |
---|
| 503 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | // ref_pic_list_init |
---|
| 507 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
| 508 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
[368] | 509 | #if H_MV |
---|
| 510 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + numDirectRefLayers; |
---|
| 511 | assert( numPocTotalCurr == getNumRpsCurrTempList() ); |
---|
| 512 | #else |
---|
[324] | 513 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
[368] | 514 | #endif |
---|
[446] | 515 | #if FIX1071 |
---|
| 516 | if (checkNumPocTotalCurr) |
---|
[324] | 517 | { |
---|
[446] | 518 | // 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: |
---|
| 519 | #if H_MV |
---|
| 520 | // – 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. |
---|
| 521 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 522 | if ( getRapPicFlag() && m_layerId == 0 ) |
---|
| 523 | #else |
---|
| 524 | // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
| 525 | // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
| 526 | if (getRapPicFlag()) |
---|
| 527 | #endif |
---|
[324] | 528 | { |
---|
[446] | 529 | assert(numPocTotalCurr == 0); |
---|
[324] | 530 | } |
---|
[446] | 531 | |
---|
| 532 | if (m_eSliceType == I_SLICE) |
---|
[324] | 533 | { |
---|
[446] | 534 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
| 535 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
| 536 | |
---|
| 537 | return; |
---|
[324] | 538 | } |
---|
[446] | 539 | |
---|
| 540 | assert(numPocTotalCurr != 0); |
---|
| 541 | |
---|
| 542 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
| 543 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
| 544 | } |
---|
| 545 | #endif |
---|
| 546 | |
---|
| 547 | Int cIdx = 0; |
---|
| 548 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 549 | { |
---|
| 550 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
| 551 | } |
---|
| 552 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 553 | { |
---|
| 554 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
| 555 | } |
---|
| 556 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 557 | { |
---|
| 558 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
| 559 | } |
---|
[368] | 560 | #if H_MV |
---|
[446] | 561 | for ( i=0; i<numDirectRefLayers; i++, cIdx++) |
---|
| 562 | { |
---|
| 563 | if( cIdx <= MAX_NUM_REF ) |
---|
[368] | 564 | { |
---|
[446] | 565 | rpsCurrList0[cIdx] = refPicSetInterLayer[i]; |
---|
[368] | 566 | } |
---|
[446] | 567 | } |
---|
[438] | 568 | #endif |
---|
[324] | 569 | |
---|
| 570 | if (m_eSliceType==B_SLICE) |
---|
| 571 | { |
---|
[446] | 572 | cIdx = 0; |
---|
[324] | 573 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
| 574 | { |
---|
| 575 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
| 576 | } |
---|
| 577 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
| 578 | { |
---|
| 579 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
| 580 | } |
---|
| 581 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
| 582 | { |
---|
| 583 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
| 584 | } |
---|
[368] | 585 | #if H_MV |
---|
| 586 | for ( i=0; i<numDirectRefLayers; i++, cIdx++) |
---|
| 587 | { |
---|
| 588 | if( cIdx <= MAX_NUM_REF ) |
---|
| 589 | { |
---|
| 590 | rpsCurrList1[cIdx] = refPicSetInterLayer[i]; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | #endif |
---|
[324] | 594 | } |
---|
| 595 | |
---|
| 596 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
| 597 | |
---|
| 598 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[0]-1); rIdx ++) |
---|
| 599 | { |
---|
| 600 | m_apcRefPicList[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? rpsCurrList0[ m_RefPicListModification.getRefPicSetIdxL0(rIdx) ] : rpsCurrList0[rIdx % numPocTotalCurr]; |
---|
| 601 | m_bIsUsedAsLongTerm[0][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? (m_RefPicListModification.getRefPicSetIdxL0(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)) |
---|
| 602 | : ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1)); |
---|
| 603 | } |
---|
| 604 | if ( m_eSliceType == P_SLICE ) |
---|
| 605 | { |
---|
| 606 | m_aiNumRefIdx[1] = 0; |
---|
| 607 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
| 608 | } |
---|
| 609 | else |
---|
| 610 | { |
---|
| 611 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[1]-1); rIdx ++) |
---|
| 612 | { |
---|
| 613 | m_apcRefPicList[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? rpsCurrList1[ m_RefPicListModification.getRefPicSetIdxL1(rIdx) ] : rpsCurrList1[rIdx % numPocTotalCurr]; |
---|
| 614 | m_bIsUsedAsLongTerm[1][rIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? |
---|
| 615 | (m_RefPicListModification.getRefPicSetIdxL1(rIdx) >= (NumPocStCurr0 + NumPocStCurr1)): ((rIdx % numPocTotalCurr) >= (NumPocStCurr0 + NumPocStCurr1)); |
---|
| 616 | } |
---|
| 617 | } |
---|
| 618 | } |
---|
| 619 | |
---|
[446] | 620 | #if H_MV |
---|
| 621 | // Temporary fix for FIX1071 should be removed later |
---|
| 622 | Int TComSlice::getNumRpsCurrTempList( TComReferencePictureSet* rps /* = 0 */) |
---|
| 623 | #else |
---|
[324] | 624 | Int TComSlice::getNumRpsCurrTempList() |
---|
[446] | 625 | #endif |
---|
[324] | 626 | { |
---|
[446] | 627 | |
---|
[324] | 628 | Int numRpsCurrTempList = 0; |
---|
| 629 | |
---|
| 630 | if (m_eSliceType == I_SLICE) |
---|
| 631 | { |
---|
| 632 | return 0; |
---|
| 633 | } |
---|
[446] | 634 | #if H_MV |
---|
| 635 | // Temporary fix for FIX1071 should be removed later |
---|
| 636 | if (rps == NULL) |
---|
| 637 | { |
---|
| 638 | rps = m_pcRPS; |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | for(UInt i=0; i < rps->getNumberOfNegativePictures()+ rps->getNumberOfPositivePictures() + rps->getNumberOfLongtermPictures(); i++) |
---|
| 642 | { |
---|
| 643 | if(rps->getUsed(i)) |
---|
| 644 | #else |
---|
[324] | 645 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
| 646 | { |
---|
| 647 | if(m_pcRPS->getUsed(i)) |
---|
[446] | 648 | #endif |
---|
[324] | 649 | { |
---|
| 650 | numRpsCurrTempList++; |
---|
| 651 | } |
---|
| 652 | } |
---|
[368] | 653 | #if H_MV |
---|
| 654 | numRpsCurrTempList = numRpsCurrTempList + getVPS()->getNumDirectRefLayers( getLayerIdInVps() ); |
---|
| 655 | #endif |
---|
[324] | 656 | return numRpsCurrTempList; |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | Void TComSlice::initEqualRef() |
---|
| 660 | { |
---|
| 661 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
| 662 | { |
---|
| 663 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
| 664 | { |
---|
| 665 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
| 666 | { |
---|
| 667 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | } |
---|
[446] | 672 | #if H_3D |
---|
| 673 | Void TComSlice::setCamparaSlice( Int** aaiScale, Int** aaiOffset ) |
---|
| 674 | { |
---|
| 675 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
| 676 | { |
---|
| 677 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < m_viewIndex; uiBaseViewIndex++ ) |
---|
| 678 | { |
---|
| 679 | m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ m_viewIndex ]; |
---|
| 680 | m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [ m_viewIndex ][ uiBaseViewIndex ]; |
---|
| 681 | m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ m_viewIndex ]; |
---|
| 682 | m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[ m_viewIndex ][ uiBaseViewIndex ]; |
---|
| 683 | } |
---|
| 684 | } |
---|
| 685 | } |
---|
| 686 | #endif |
---|
[324] | 687 | |
---|
| 688 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
| 689 | { |
---|
| 690 | Int i; |
---|
| 691 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
| 692 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
| 693 | TComSlice* preSlice; |
---|
| 694 | Int preColRefPOC; |
---|
| 695 | for(i=curSliceIdx-1; i>=0; i--) |
---|
| 696 | { |
---|
| 697 | preSlice = pic->getSlice(i); |
---|
| 698 | if(preSlice->getSliceType() != I_SLICE) |
---|
| 699 | { |
---|
| 700 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
| 701 | if(currColRefPOC != preColRefPOC) |
---|
| 702 | { |
---|
| 703 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
| 704 | exit(EXIT_FAILURE); |
---|
| 705 | } |
---|
| 706 | else |
---|
| 707 | { |
---|
| 708 | break; |
---|
| 709 | } |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | |
---|
[446] | 714 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic) |
---|
[324] | 715 | { |
---|
| 716 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
| 717 | { |
---|
| 718 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 719 | { |
---|
| 720 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
| 721 | } |
---|
| 722 | } |
---|
| 723 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
| 724 | { |
---|
| 725 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
| 726 | { |
---|
[446] | 727 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
| 728 | { |
---|
| 729 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
| 730 | } |
---|
| 731 | else |
---|
| 732 | { |
---|
[324] | 733 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
| 734 | } |
---|
| 735 | } |
---|
[446] | 736 | } |
---|
| 737 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
[324] | 738 | { |
---|
| 739 | pocCRA = getPOC(); |
---|
| 740 | prevRAPisBLA = false; |
---|
| 741 | } |
---|
| 742 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 743 | { |
---|
| 744 | pocCRA = getPOC(); |
---|
| 745 | prevRAPisBLA = false; |
---|
| 746 | } |
---|
[446] | 747 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 748 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
[324] | 749 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
| 750 | { |
---|
| 751 | pocCRA = getPOC(); |
---|
| 752 | prevRAPisBLA = true; |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
| 757 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
| 758 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
| 759 | * \param rcListPic reference to the reference picture list |
---|
| 760 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
| 761 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
| 762 | * are marked as "unused for reference" |
---|
| 763 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
| 764 | * Otherwise |
---|
| 765 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
| 766 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
| 767 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
| 768 | * the bRefreshPending flag to false. |
---|
| 769 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
| 770 | * reference of the current picture. |
---|
| 771 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
| 772 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
| 773 | */ |
---|
| 774 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
| 775 | { |
---|
| 776 | TComPic* rpcPic; |
---|
| 777 | Int pocCurr = getPOC(); |
---|
| 778 | |
---|
[446] | 779 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 780 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
[324] | 781 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
[446] | 782 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
[324] | 783 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
| 784 | { |
---|
| 785 | // mark all pictures as not used for reference |
---|
| 786 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 787 | while (iterPic != rcListPic.end()) |
---|
| 788 | { |
---|
| 789 | rpcPic = *(iterPic); |
---|
| 790 | rpcPic->setCurrSliceIdx(0); |
---|
| 791 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
| 792 | iterPic++; |
---|
| 793 | } |
---|
[446] | 794 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 795 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
[324] | 796 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 797 | { |
---|
| 798 | pocCRA = pocCurr; |
---|
| 799 | } |
---|
| 800 | } |
---|
| 801 | else // CRA or No DR |
---|
| 802 | { |
---|
| 803 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
| 804 | { |
---|
| 805 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 806 | while (iterPic != rcListPic.end()) |
---|
| 807 | { |
---|
| 808 | rpcPic = *(iterPic); |
---|
[446] | 809 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
| 810 | { |
---|
| 811 | rpcPic->getSlice(0)->setReferenced(false); |
---|
| 812 | } |
---|
[324] | 813 | iterPic++; |
---|
| 814 | } |
---|
| 815 | bRefreshPending = false; |
---|
| 816 | } |
---|
| 817 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
| 818 | { |
---|
| 819 | bRefreshPending = true; |
---|
| 820 | pocCRA = pocCurr; |
---|
| 821 | } |
---|
| 822 | } |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
| 826 | { |
---|
| 827 | assert( pSrc != NULL ); |
---|
| 828 | |
---|
| 829 | Int i, j, k; |
---|
| 830 | |
---|
| 831 | m_iPOC = pSrc->m_iPOC; |
---|
| 832 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
[368] | 833 | #if H_MV |
---|
| 834 | m_layerId = pSrc->m_layerId; |
---|
| 835 | #endif |
---|
[324] | 836 | m_eSliceType = pSrc->m_eSliceType; |
---|
| 837 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
| 838 | #if ADAPTIVE_QP_SELECTION |
---|
| 839 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
| 840 | #endif |
---|
| 841 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
| 842 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
| 843 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
| 844 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
| 845 | |
---|
[446] | 846 | #if L0034_COMBINED_LIST_CLEANUP |
---|
| 847 | for (i = 0; i < 2; i++) |
---|
| 848 | #else |
---|
[324] | 849 | for (i = 0; i < 3; i++) |
---|
[446] | 850 | #endif |
---|
[324] | 851 | { |
---|
| 852 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
| 853 | } |
---|
| 854 | |
---|
[446] | 855 | #if L0034_COMBINED_LIST_CLEANUP |
---|
| 856 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
| 857 | { |
---|
| 858 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
| 859 | } |
---|
| 860 | #else |
---|
[324] | 861 | for (i = 0; i < 2; i++) |
---|
| 862 | { |
---|
| 863 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
| 864 | { |
---|
| 865 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
| 866 | } |
---|
| 867 | } |
---|
| 868 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
| 869 | { |
---|
| 870 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
| 871 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
| 872 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
| 873 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
| 874 | } |
---|
| 875 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
| 876 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
[446] | 877 | #endif |
---|
[324] | 878 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
| 879 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
| 880 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
| 881 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
| 882 | for (i = 0; i < 2; i++) |
---|
| 883 | { |
---|
| 884 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 885 | { |
---|
| 886 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
| 887 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
[368] | 888 | #if H_MV |
---|
| 889 | m_aiRefLayerIdList[i][j] = pSrc->m_aiRefLayerIdList[i][j]; |
---|
| 890 | #endif |
---|
[324] | 891 | } |
---|
| 892 | } |
---|
| 893 | for (i = 0; i < 2; i++) |
---|
| 894 | { |
---|
| 895 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
| 896 | { |
---|
| 897 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
| 898 | } |
---|
| 899 | } |
---|
| 900 | m_iDepth = pSrc->m_iDepth; |
---|
| 901 | |
---|
| 902 | // referenced slice |
---|
| 903 | m_bRefenced = pSrc->m_bRefenced; |
---|
| 904 | |
---|
| 905 | // access channel |
---|
[368] | 906 | #if H_MV |
---|
| 907 | m_pcVPS = pSrc->m_pcVPS; |
---|
| 908 | #endif |
---|
[324] | 909 | m_pcSPS = pSrc->m_pcSPS; |
---|
| 910 | m_pcPPS = pSrc->m_pcPPS; |
---|
| 911 | m_pcRPS = pSrc->m_pcRPS; |
---|
| 912 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
| 913 | |
---|
| 914 | m_pcPic = pSrc->m_pcPic; |
---|
| 915 | |
---|
| 916 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
| 917 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
| 918 | #if SAO_CHROMA_LAMBDA |
---|
| 919 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
| 920 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
| 921 | #else |
---|
| 922 | m_dLambda = pSrc->m_dLambda; |
---|
| 923 | #endif |
---|
| 924 | for (i = 0; i < 2; i++) |
---|
| 925 | { |
---|
| 926 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
| 927 | { |
---|
| 928 | for (k =0; k < MAX_NUM_REF; k++) |
---|
| 929 | { |
---|
| 930 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | } |
---|
| 934 | |
---|
[446] | 935 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 936 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
[446] | 937 | #endif |
---|
[324] | 938 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
| 939 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
| 940 | |
---|
| 941 | m_sliceMode = pSrc->m_sliceMode; |
---|
| 942 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
| 943 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
| 944 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
| 945 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
| 946 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
| 947 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
| 948 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
| 949 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
| 950 | m_nextSlice = pSrc->m_nextSlice; |
---|
| 951 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
| 952 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 953 | { |
---|
| 954 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
| 955 | { |
---|
| 956 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
| 960 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
| 961 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
| 962 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
| 963 | |
---|
| 964 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
| 965 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
| 966 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
| 967 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
| 968 | } |
---|
| 969 | |
---|
| 970 | Int TComSlice::m_prevPOC = 0; |
---|
[446] | 971 | |
---|
[324] | 972 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
| 973 | * \param uiTLayer Temporal layer ID of the current slice |
---|
| 974 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
| 975 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
| 976 | * temporal_layer_switching_point_flag is set accordingly. |
---|
| 977 | */ |
---|
| 978 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
| 979 | { |
---|
| 980 | m_uiTLayer = uiTLayer; |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | /** Function for checking if this is a switching-point |
---|
| 984 | */ |
---|
| 985 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
| 986 | { |
---|
| 987 | TComPic* rpcPic; |
---|
| 988 | // loop through all pictures in the reference picture buffer |
---|
| 989 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 990 | while ( iterPic != rcListPic.end()) |
---|
| 991 | { |
---|
| 992 | rpcPic = *(iterPic++); |
---|
| 993 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
| 994 | { |
---|
| 995 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 996 | { |
---|
| 997 | return false; |
---|
| 998 | } |
---|
| 999 | } |
---|
| 1000 | } |
---|
| 1001 | return true; |
---|
| 1002 | } |
---|
| 1003 | |
---|
| 1004 | /** Function for checking if this is a STSA candidate |
---|
| 1005 | */ |
---|
| 1006 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
| 1007 | { |
---|
| 1008 | TComPic* rpcPic; |
---|
| 1009 | |
---|
| 1010 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1011 | while ( iterPic != rcListPic.end()) |
---|
| 1012 | { |
---|
| 1013 | rpcPic = *(iterPic++); |
---|
| 1014 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
| 1015 | { |
---|
| 1016 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
| 1017 | { |
---|
| 1018 | return false; |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | } |
---|
| 1022 | return true; |
---|
| 1023 | } |
---|
| 1024 | |
---|
| 1025 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1026 | */ |
---|
| 1027 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1028 | { |
---|
| 1029 | TComPic* rpcPic; |
---|
| 1030 | Int i, isReference; |
---|
| 1031 | |
---|
| 1032 | // loop through all pictures in the reference picture buffer |
---|
| 1033 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1034 | while ( iterPic != rcListPic.end()) |
---|
| 1035 | { |
---|
| 1036 | rpcPic = *(iterPic++); |
---|
| 1037 | |
---|
[446] | 1038 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
| 1039 | { |
---|
| 1040 | continue; |
---|
| 1041 | } |
---|
| 1042 | |
---|
[324] | 1043 | isReference = 0; |
---|
| 1044 | // loop through all pictures in the Reference Picture Set |
---|
| 1045 | // to see if the picture should be kept as reference picture |
---|
| 1046 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
| 1047 | { |
---|
| 1048 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
| 1049 | { |
---|
| 1050 | isReference = 1; |
---|
| 1051 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1052 | rpcPic->setIsLongTerm(0); |
---|
| 1053 | } |
---|
| 1054 | } |
---|
| 1055 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1056 | { |
---|
| 1057 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1058 | { |
---|
| 1059 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
| 1060 | { |
---|
| 1061 | isReference = 1; |
---|
| 1062 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1063 | } |
---|
| 1064 | } |
---|
| 1065 | else |
---|
| 1066 | { |
---|
| 1067 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) |
---|
| 1068 | { |
---|
| 1069 | isReference = 1; |
---|
| 1070 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
| 1071 | } |
---|
| 1072 | } |
---|
| 1073 | |
---|
| 1074 | } |
---|
| 1075 | // mark the picture as "unused for reference" if it is not in |
---|
| 1076 | // the Reference Picture Set |
---|
| 1077 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
| 1078 | { |
---|
| 1079 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
[446] | 1080 | rpcPic->setUsedByCurr(0); |
---|
[324] | 1081 | rpcPic->setIsLongTerm(0); |
---|
| 1082 | } |
---|
| 1083 | //check that pictures of higher temporal layers are not used |
---|
| 1084 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
| 1085 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
[446] | 1086 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
[324] | 1087 | { |
---|
| 1088 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
| 1089 | } |
---|
| 1090 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
| 1091 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
| 1092 | { |
---|
| 1093 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
| 1094 | } |
---|
| 1095 | } |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
| 1099 | */ |
---|
| 1100 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
| 1101 | { |
---|
| 1102 | TComPic* rpcPic; |
---|
[446] | 1103 | Int i, isAvailable; |
---|
[324] | 1104 | Int atLeastOneLost = 0; |
---|
| 1105 | Int atLeastOneRemoved = 0; |
---|
| 1106 | Int iPocLost = 0; |
---|
| 1107 | |
---|
| 1108 | // loop through all long-term pictures in the Reference Picture Set |
---|
| 1109 | // to see if the picture should be kept as reference picture |
---|
| 1110 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1111 | { |
---|
| 1112 | isAvailable = 0; |
---|
| 1113 | // loop through all pictures in the reference picture buffer |
---|
| 1114 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1115 | while ( iterPic != rcListPic.end()) |
---|
| 1116 | { |
---|
| 1117 | rpcPic = *(iterPic++); |
---|
| 1118 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
| 1119 | { |
---|
| 1120 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1121 | { |
---|
| 1122 | isAvailable = 1; |
---|
| 1123 | } |
---|
| 1124 | } |
---|
| 1125 | else |
---|
| 1126 | { |
---|
| 1127 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == pReferencePictureSet->getPOC(i)%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1128 | { |
---|
| 1129 | isAvailable = 1; |
---|
| 1130 | } |
---|
| 1131 | } |
---|
| 1132 | } |
---|
| 1133 | // if there was no such long-term check the short terms |
---|
| 1134 | if(!isAvailable) |
---|
| 1135 | { |
---|
| 1136 | iterPic = rcListPic.begin(); |
---|
| 1137 | while ( iterPic != rcListPic.end()) |
---|
| 1138 | { |
---|
| 1139 | rpcPic = *(iterPic++); |
---|
| 1140 | |
---|
[446] | 1141 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
| 1142 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
| 1143 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
| 1144 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
[324] | 1145 | { |
---|
[446] | 1146 | curPoc = curPoc % pocCycle; |
---|
| 1147 | refPoc = refPoc % pocCycle; |
---|
| 1148 | } |
---|
| 1149 | |
---|
| 1150 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
| 1151 | { |
---|
[324] | 1152 | isAvailable = 1; |
---|
| 1153 | rpcPic->setIsLongTerm(1); |
---|
| 1154 | break; |
---|
| 1155 | } |
---|
| 1156 | } |
---|
| 1157 | } |
---|
| 1158 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1159 | // but not available as reference picture |
---|
| 1160 | if(isAvailable == 0) |
---|
| 1161 | { |
---|
| 1162 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1163 | { |
---|
| 1164 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1165 | { |
---|
| 1166 | if(printErrors) |
---|
| 1167 | { |
---|
| 1168 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1169 | } |
---|
| 1170 | atLeastOneRemoved = 1; |
---|
| 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
| 1174 | if(printErrors) |
---|
| 1175 | { |
---|
| 1176 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1177 | } |
---|
| 1178 | atLeastOneLost = 1; |
---|
| 1179 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1180 | } |
---|
| 1181 | } |
---|
| 1182 | } |
---|
| 1183 | } |
---|
| 1184 | // loop through all short-term pictures in the Reference Picture Set |
---|
| 1185 | // to see if the picture should be kept as reference picture |
---|
| 1186 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
| 1187 | { |
---|
| 1188 | isAvailable = 0; |
---|
| 1189 | // loop through all pictures in the reference picture buffer |
---|
| 1190 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1191 | while ( iterPic != rcListPic.end()) |
---|
| 1192 | { |
---|
| 1193 | rpcPic = *(iterPic++); |
---|
| 1194 | |
---|
| 1195 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1196 | { |
---|
| 1197 | isAvailable = 1; |
---|
| 1198 | } |
---|
| 1199 | } |
---|
| 1200 | // report that a picture is lost if it is in the Reference Picture Set |
---|
| 1201 | // but not available as reference picture |
---|
| 1202 | if(isAvailable == 0) |
---|
| 1203 | { |
---|
| 1204 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
| 1205 | { |
---|
| 1206 | if(!pReferencePictureSet->getUsed(i) ) |
---|
| 1207 | { |
---|
| 1208 | if(printErrors) |
---|
[446] | 1209 | { |
---|
[324] | 1210 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[446] | 1211 | } |
---|
[324] | 1212 | atLeastOneRemoved = 1; |
---|
| 1213 | } |
---|
| 1214 | else |
---|
| 1215 | { |
---|
| 1216 | if(printErrors) |
---|
[446] | 1217 | { |
---|
[324] | 1218 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
[446] | 1219 | } |
---|
[324] | 1220 | atLeastOneLost = 1; |
---|
| 1221 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
| 1222 | } |
---|
| 1223 | } |
---|
| 1224 | } |
---|
| 1225 | } |
---|
| 1226 | if(atLeastOneLost) |
---|
| 1227 | { |
---|
| 1228 | return iPocLost+1; |
---|
| 1229 | } |
---|
| 1230 | if(atLeastOneRemoved) |
---|
| 1231 | { |
---|
| 1232 | return -2; |
---|
| 1233 | } |
---|
| 1234 | else |
---|
| 1235 | { |
---|
| 1236 | return 0; |
---|
| 1237 | } |
---|
| 1238 | } |
---|
| 1239 | |
---|
| 1240 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
| 1241 | */ |
---|
| 1242 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
| 1243 | { |
---|
| 1244 | TComPic* rpcPic; |
---|
| 1245 | Int i, j; |
---|
| 1246 | Int k = 0; |
---|
| 1247 | Int nrOfNegativePictures = 0; |
---|
| 1248 | Int nrOfPositivePictures = 0; |
---|
| 1249 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
| 1250 | |
---|
| 1251 | // loop through all pictures in the Reference Picture Set |
---|
| 1252 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
| 1253 | { |
---|
| 1254 | j = 0; |
---|
| 1255 | // loop through all pictures in the reference picture buffer |
---|
| 1256 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
| 1257 | while ( iterPic != rcListPic.end()) |
---|
| 1258 | { |
---|
| 1259 | j++; |
---|
| 1260 | rpcPic = *(iterPic++); |
---|
| 1261 | |
---|
| 1262 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
| 1263 | { |
---|
| 1264 | // This picture exists as a reference picture |
---|
| 1265 | // and should be added to the explicit Reference Picture Set |
---|
| 1266 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
| 1267 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
| 1268 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
| 1269 | { |
---|
| 1270 | nrOfNegativePictures++; |
---|
| 1271 | } |
---|
| 1272 | else |
---|
| 1273 | { |
---|
| 1274 | nrOfPositivePictures++; |
---|
| 1275 | } |
---|
| 1276 | k++; |
---|
| 1277 | } |
---|
| 1278 | } |
---|
| 1279 | } |
---|
| 1280 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
| 1281 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
| 1282 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
| 1283 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
| 1284 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
| 1285 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
| 1286 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
| 1287 | { |
---|
| 1288 | pcRPS->setInterRPSPrediction(false); |
---|
| 1289 | pcRPS->setNumRefIdc(0); |
---|
| 1290 | } |
---|
| 1291 | else |
---|
| 1292 | { |
---|
| 1293 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
| 1294 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
| 1295 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 1296 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
| 1297 | Int iNewIdc=0; |
---|
| 1298 | for(i=0; i<= iRefPics; i++) |
---|
| 1299 | { |
---|
| 1300 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
| 1301 | Int iRefIdc = 0; |
---|
| 1302 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
| 1303 | { |
---|
| 1304 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
| 1305 | { |
---|
| 1306 | if (pcRPS->getUsed(j)) |
---|
| 1307 | { |
---|
| 1308 | iRefIdc = 1; |
---|
| 1309 | } |
---|
| 1310 | else |
---|
| 1311 | { |
---|
| 1312 | iRefIdc = 2; |
---|
| 1313 | } |
---|
| 1314 | } |
---|
| 1315 | } |
---|
| 1316 | pcRPS->setRefIdc(i, iRefIdc); |
---|
| 1317 | iNewIdc++; |
---|
| 1318 | } |
---|
| 1319 | pcRPS->setInterRPSPrediction(true); |
---|
| 1320 | pcRPS->setNumRefIdc(iNewIdc); |
---|
| 1321 | pcRPS->setDeltaRPS(deltaRPS); |
---|
| 1322 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
| 1323 | } |
---|
| 1324 | |
---|
| 1325 | this->setRPS(pcRPS); |
---|
| 1326 | this->setRPSidx(-1); |
---|
| 1327 | } |
---|
| 1328 | |
---|
| 1329 | /** get AC and DC values for weighted pred |
---|
| 1330 | * \param *wp |
---|
| 1331 | * \returns Void |
---|
| 1332 | */ |
---|
| 1333 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
| 1334 | { |
---|
| 1335 | wp = m_weightACDCParam; |
---|
| 1336 | } |
---|
| 1337 | |
---|
| 1338 | /** init AC and DC values for weighted pred |
---|
| 1339 | * \returns Void |
---|
| 1340 | */ |
---|
| 1341 | Void TComSlice::initWpAcDcParam() |
---|
| 1342 | { |
---|
| 1343 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
| 1344 | { |
---|
| 1345 | m_weightACDCParam[iComp].iAC = 0; |
---|
| 1346 | m_weightACDCParam[iComp].iDC = 0; |
---|
| 1347 | } |
---|
| 1348 | } |
---|
| 1349 | |
---|
| 1350 | /** get WP tables for weighted pred |
---|
| 1351 | * \param RefPicList |
---|
| 1352 | * \param iRefIdx |
---|
| 1353 | * \param *&wpScalingParam |
---|
| 1354 | * \returns Void |
---|
| 1355 | */ |
---|
| 1356 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
| 1357 | { |
---|
| 1358 | wp = m_weightPredTable[e][iRefIdx]; |
---|
| 1359 | } |
---|
| 1360 | |
---|
| 1361 | /** reset Default WP tables settings : no weight. |
---|
| 1362 | * \param wpScalingParam |
---|
| 1363 | * \returns Void |
---|
| 1364 | */ |
---|
[446] | 1365 | Void TComSlice::resetWpScaling() |
---|
[324] | 1366 | { |
---|
| 1367 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1368 | { |
---|
| 1369 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1370 | { |
---|
| 1371 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1372 | { |
---|
[446] | 1373 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
[324] | 1374 | pwp->bPresentFlag = false; |
---|
| 1375 | pwp->uiLog2WeightDenom = 0; |
---|
| 1376 | pwp->uiLog2WeightDenom = 0; |
---|
| 1377 | pwp->iWeight = 1; |
---|
| 1378 | pwp->iOffset = 0; |
---|
| 1379 | } |
---|
| 1380 | } |
---|
| 1381 | } |
---|
| 1382 | } |
---|
| 1383 | |
---|
| 1384 | /** init WP table |
---|
| 1385 | * \returns Void |
---|
| 1386 | */ |
---|
| 1387 | Void TComSlice::initWpScaling() |
---|
| 1388 | { |
---|
| 1389 | for ( Int e=0 ; e<2 ; e++ ) |
---|
| 1390 | { |
---|
| 1391 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
| 1392 | { |
---|
| 1393 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
| 1394 | { |
---|
[446] | 1395 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
| 1396 | if ( !pwp->bPresentFlag ) |
---|
| 1397 | { |
---|
[324] | 1398 | // Inferring values not present : |
---|
| 1399 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
| 1400 | pwp->iOffset = 0; |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | pwp->w = pwp->iWeight; |
---|
| 1404 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
| 1405 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
| 1406 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
| 1407 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
| 1408 | } |
---|
| 1409 | } |
---|
| 1410 | } |
---|
| 1411 | } |
---|
| 1412 | |
---|
| 1413 | // ------------------------------------------------------------------------------------------------ |
---|
| 1414 | // Video parameter set (VPS) |
---|
| 1415 | // ------------------------------------------------------------------------------------------------ |
---|
| 1416 | TComVPS::TComVPS() |
---|
| 1417 | : m_VPSId ( 0) |
---|
| 1418 | , m_uiMaxTLayers ( 1) |
---|
| 1419 | , m_uiMaxLayers ( 1) |
---|
| 1420 | , m_bTemporalIdNestingFlag (false) |
---|
| 1421 | , m_numHrdParameters ( 0) |
---|
[368] | 1422 | #if H_MV |
---|
| 1423 | , m_maxNuhLayerId ( 0) |
---|
| 1424 | #else |
---|
[324] | 1425 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
[368] | 1426 | #endif |
---|
[324] | 1427 | , m_hrdParameters (NULL) |
---|
| 1428 | , m_hrdOpSetIdx (NULL) |
---|
| 1429 | , m_cprmsPresentFlag (NULL) |
---|
| 1430 | { |
---|
| 1431 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
| 1432 | { |
---|
| 1433 | m_numReorderPics[i] = 0; |
---|
[446] | 1434 | #if L0323_DPB |
---|
| 1435 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 1436 | #else |
---|
[324] | 1437 | m_uiMaxDecPicBuffering[i] = 0; |
---|
[446] | 1438 | #endif |
---|
[324] | 1439 | m_uiMaxLatencyIncrease[i] = 0; |
---|
| 1440 | } |
---|
[368] | 1441 | #if H_MV |
---|
| 1442 | m_avcBaseLayerFlag = false; |
---|
| 1443 | m_splittingFlag = false; |
---|
| 1444 | |
---|
| 1445 | for( Int i = 0; i < MAX_NUM_SCALABILITY_TYPES; i++ ) |
---|
| 1446 | { |
---|
| 1447 | m_scalabilityMask[i] = false; |
---|
| 1448 | m_dimensionIdLen [i] = -1; |
---|
| 1449 | } |
---|
| 1450 | |
---|
| 1451 | m_vpsNuhLayerIdPresentFlag = false; |
---|
| 1452 | m_numOutputLayerSets = 0; |
---|
| 1453 | |
---|
| 1454 | for( Int i = 0; i < MAX_VPS_OP_SETS_PLUS1; i++ ) |
---|
| 1455 | { |
---|
| 1456 | m_vpsProfilePresentFlag [i] = false; |
---|
| 1457 | m_profileLayerSetRefMinus1[i] = 0; |
---|
| 1458 | m_outputLayerSetIdx [i] = 0; |
---|
| 1459 | for( Int j = 0; j < MAX_VPS_NUH_LAYER_ID_PLUS1; j++ ) |
---|
| 1460 | { |
---|
| 1461 | m_outputLayerFlag[i][j] = false; |
---|
| 1462 | } |
---|
| 1463 | } |
---|
| 1464 | |
---|
| 1465 | for( Int i = 0; i < MAX_NUM_LAYER_IDS; i++ ) |
---|
| 1466 | { |
---|
| 1467 | m_layerIdInVps[i] = (i == 0 ) ? 0 : -1; |
---|
| 1468 | } |
---|
| 1469 | |
---|
| 1470 | for( Int i = 0; i < MAX_NUM_LAYERS; i++ ) |
---|
| 1471 | { |
---|
| 1472 | m_layerIdInNuh [i] = ( i == 0 ) ? 0 : -1; |
---|
| 1473 | m_numDirectRefLayers[i] = 0; |
---|
[446] | 1474 | #if H_3D |
---|
| 1475 | m_viewIndex [i] = -1; |
---|
| 1476 | #endif |
---|
[368] | 1477 | |
---|
| 1478 | for( Int j = 0; j < MAX_NUM_LAYERS; j++ ) |
---|
| 1479 | { |
---|
| 1480 | m_directDependencyFlag[i][j] = false; |
---|
| 1481 | m_refLayerId[i][j] = -1; |
---|
| 1482 | } |
---|
| 1483 | |
---|
| 1484 | for( Int j = 0; j < MAX_NUM_SCALABILITY_TYPES; j++ ) |
---|
| 1485 | { |
---|
| 1486 | m_dimensionId[i][j] = 0; |
---|
| 1487 | } |
---|
| 1488 | } |
---|
| 1489 | #endif |
---|
[324] | 1490 | } |
---|
| 1491 | |
---|
| 1492 | TComVPS::~TComVPS() |
---|
| 1493 | { |
---|
[446] | 1494 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
| 1495 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
| 1496 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
[324] | 1497 | } |
---|
| 1498 | |
---|
[368] | 1499 | #if H_MV |
---|
| 1500 | |
---|
| 1501 | Bool TComVPS::checkVPSExtensionSyntax() |
---|
| 1502 | { |
---|
| 1503 | // check splitting flag constraint |
---|
| 1504 | if ( getSplittingFlag() ) |
---|
| 1505 | { |
---|
| 1506 | // Derive dimBitOffset[j] |
---|
| 1507 | Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1]; |
---|
| 1508 | Int numScalabilityTypes = getNumScalabilityTypes(); |
---|
| 1509 | dimBitOffset[0] = 0; |
---|
| 1510 | |
---|
| 1511 | for (Int type = 1; type <= numScalabilityTypes; type++ ) |
---|
| 1512 | { |
---|
| 1513 | dimBitOffset[ type ] = 0; |
---|
| 1514 | for (Int dimIdx = 0; dimIdx <= type - 1; dimIdx++) |
---|
| 1515 | dimBitOffset[ type ] += ( getDimensionIdLen( dimIdx ) ); |
---|
| 1516 | } |
---|
| 1517 | |
---|
| 1518 | for (Int type = 0; type < getNumScalabilityTypes(); type++ ) |
---|
| 1519 | { |
---|
| 1520 | for( Int layer = 1; layer < getMaxLayers(); layer++ ) |
---|
| 1521 | { |
---|
| 1522 | assert( getDimensionId( layer, type ) == ( ( getLayerIdInNuh( layer ) & ( (1 << dimBitOffset[ type + 1 ] ) - 1) ) >> dimBitOffset[ type ] ) ); |
---|
| 1523 | }; |
---|
| 1524 | }; |
---|
| 1525 | } |
---|
| 1526 | |
---|
| 1527 | for( Int layer = 1; layer < getMaxLayers(); layer++ ) |
---|
| 1528 | { |
---|
| 1529 | // check layer_id_in_nuh constraint |
---|
| 1530 | assert( getLayerIdInNuh( layer ) > getLayerIdInNuh( layer -1 ) ); |
---|
| 1531 | } |
---|
| 1532 | return true; |
---|
| 1533 | } |
---|
| 1534 | |
---|
| 1535 | Int TComVPS::getNumScalabilityTypes() |
---|
| 1536 | { |
---|
| 1537 | return scalTypeToScalIdx( ScalabilityType(MAX_NUM_SCALABILITY_TYPES) ); |
---|
| 1538 | } |
---|
| 1539 | |
---|
| 1540 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
| 1541 | { |
---|
| 1542 | assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); |
---|
| 1543 | assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
| 1544 | |
---|
| 1545 | Int scalIdx = 0; |
---|
| 1546 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
| 1547 | { |
---|
| 1548 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
| 1549 | } |
---|
| 1550 | |
---|
| 1551 | return scalIdx; |
---|
| 1552 | } |
---|
| 1553 | |
---|
| 1554 | |
---|
| 1555 | |
---|
| 1556 | Void TComVPS::setScalabilityMask( UInt val ) |
---|
| 1557 | { |
---|
| 1558 | for ( Int scalType = 0; scalType < MAX_NUM_SCALABILITY_TYPES; scalType++ ) |
---|
[446] | 1559 | setScalabilityMask( scalType, ( val & (1 << scalType ) ) != 0 ); |
---|
[368] | 1560 | } |
---|
| 1561 | |
---|
| 1562 | Void TComVPS::calcIvRefLayers() |
---|
| 1563 | { |
---|
| 1564 | for( Int i = 1; i <= getMaxLayers(); i++ ) |
---|
| 1565 | { |
---|
| 1566 | m_numDirectRefLayers[ i ] = 0; |
---|
| 1567 | for( Int j = 0 ; j < i; j++ ) |
---|
| 1568 | if( m_directDependencyFlag[ i ][ j ]) |
---|
| 1569 | m_refLayerId[ i ][ m_numDirectRefLayers[ i ]++ ] = m_layerIdInNuh[ j ]; |
---|
| 1570 | } |
---|
| 1571 | } |
---|
| 1572 | |
---|
| 1573 | Int TComVPS::getRefLayerId( Int layerIdInVps, Int idx ) |
---|
| 1574 | { |
---|
| 1575 | assert( idx >= 0 && idx < m_numDirectRefLayers[layerIdInVps] ); |
---|
| 1576 | Int layerIdInNuh = m_refLayerId[ layerIdInVps ][ idx ]; |
---|
| 1577 | assert ( layerIdInNuh >= 0 ); |
---|
| 1578 | return layerIdInNuh; |
---|
| 1579 | } |
---|
| 1580 | |
---|
| 1581 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
| 1582 | { |
---|
[446] | 1583 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
[368] | 1584 | } |
---|
[438] | 1585 | |
---|
[446] | 1586 | #if H_3D |
---|
| 1587 | Void TComVPS::initViewIndex() |
---|
| 1588 | { |
---|
| 1589 | Int viewIdList [ MAX_NUM_LAYERS ]; // ed. should be changed to MAX_VIEW_ID |
---|
| 1590 | Int viewIndexList[ MAX_NUM_LAYERS ]; |
---|
| 1591 | Int numViewIds = 0; |
---|
| 1592 | |
---|
| 1593 | for ( Int i = 0 ; i < m_uiMaxLayers; i++ ) |
---|
| 1594 | { |
---|
| 1595 | Int currViewId = getViewId( i ); |
---|
| 1596 | |
---|
| 1597 | Bool viewIdInListFlag = false; |
---|
| 1598 | for ( Int j = 0; j < numViewIds; j ++ ) |
---|
| 1599 | { |
---|
| 1600 | viewIdInListFlag = viewIdInListFlag || ( currViewId == viewIdList[ j ] ); |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | if ( !viewIdInListFlag ) |
---|
| 1604 | { |
---|
| 1605 | viewIdList [ numViewIds ] = currViewId; |
---|
| 1606 | viewIndexList[ currViewId ] = numViewIds; |
---|
| 1607 | |
---|
| 1608 | numViewIds++; |
---|
| 1609 | } |
---|
| 1610 | |
---|
| 1611 | m_viewIndex[ i ] = viewIndexList[ currViewId ]; |
---|
| 1612 | } |
---|
| 1613 | } |
---|
| 1614 | |
---|
| 1615 | Int TComVPS::getLayerIdInNuh( Int viewIndex, Bool depthFlag ) |
---|
| 1616 | { |
---|
| 1617 | Int foundlayerId = -1; |
---|
| 1618 | |
---|
| 1619 | for (Int layer = 0 ; layer < m_uiMaxLayers; layer++ ) |
---|
| 1620 | { |
---|
| 1621 | if( ( getViewIndex( layer ) == viewIndex ) && ( getDepthId( layer ) == ( depthFlag ? 1 : 0 ) ) ) |
---|
| 1622 | { |
---|
| 1623 | foundlayerId = layer; |
---|
| 1624 | break; |
---|
| 1625 | } |
---|
| 1626 | } |
---|
| 1627 | assert( foundlayerId != -1 ); |
---|
| 1628 | |
---|
| 1629 | return getLayerIdInNuh( foundlayerId ); |
---|
| 1630 | } |
---|
| 1631 | #endif // H_3D |
---|
| 1632 | #endif // H_MV |
---|
| 1633 | |
---|
[324] | 1634 | // ------------------------------------------------------------------------------------------------ |
---|
| 1635 | // Sequence parameter set (SPS) |
---|
| 1636 | // ------------------------------------------------------------------------------------------------ |
---|
| 1637 | |
---|
| 1638 | TComSPS::TComSPS() |
---|
| 1639 | : m_SPSId ( 0) |
---|
| 1640 | , m_VPSId ( 0) |
---|
| 1641 | , m_chromaFormatIdc (CHROMA_420) |
---|
| 1642 | , m_uiMaxTLayers ( 1) |
---|
| 1643 | // Structure |
---|
| 1644 | , m_picWidthInLumaSamples (352) |
---|
| 1645 | , m_picHeightInLumaSamples (288) |
---|
[446] | 1646 | , m_log2MinCodingBlockSize ( 0) |
---|
| 1647 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
[324] | 1648 | , m_uiMaxCUWidth ( 32) |
---|
| 1649 | , m_uiMaxCUHeight ( 32) |
---|
| 1650 | , m_uiMaxCUDepth ( 3) |
---|
| 1651 | , m_bLongTermRefsPresent (false) |
---|
| 1652 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
| 1653 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
| 1654 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
| 1655 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
| 1656 | // Tool list |
---|
| 1657 | , m_usePCM (false) |
---|
| 1658 | , m_pcmLog2MaxSize ( 5) |
---|
| 1659 | , m_uiPCMLog2MinSize ( 7) |
---|
[446] | 1660 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
[324] | 1661 | , m_bUseLComb (false) |
---|
[446] | 1662 | #endif |
---|
[324] | 1663 | , m_bitDepthY ( 8) |
---|
| 1664 | , m_bitDepthC ( 8) |
---|
| 1665 | , m_qpBDOffsetY ( 0) |
---|
| 1666 | , m_qpBDOffsetC ( 0) |
---|
| 1667 | , m_useLossless (false) |
---|
| 1668 | , m_uiPCMBitDepthLuma ( 8) |
---|
| 1669 | , m_uiPCMBitDepthChroma ( 8) |
---|
| 1670 | , m_bPCMFilterDisableFlag (false) |
---|
| 1671 | , m_uiBitsForPOC ( 8) |
---|
| 1672 | , m_numLongTermRefPicSPS ( 0) |
---|
| 1673 | , m_uiMaxTrSize ( 32) |
---|
| 1674 | , m_bUseSAO (false) |
---|
| 1675 | , m_bTemporalIdNestingFlag (false) |
---|
| 1676 | , m_scalingListEnabledFlag (false) |
---|
| 1677 | , m_useStrongIntraSmoothing (false) |
---|
| 1678 | , m_vuiParametersPresentFlag (false) |
---|
| 1679 | , m_vuiParameters () |
---|
[446] | 1680 | #if H_MV |
---|
| 1681 | , m_interViewMvVertConstraintFlag (false) |
---|
| 1682 | #endif |
---|
| 1683 | #if H_3D |
---|
| 1684 | , m_bCamParInSliceHeader (false) |
---|
| 1685 | #endif |
---|
[324] | 1686 | { |
---|
| 1687 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
| 1688 | { |
---|
| 1689 | m_uiMaxLatencyIncrease[i] = 0; |
---|
[446] | 1690 | #if L0323_DPB |
---|
| 1691 | m_uiMaxDecPicBuffering[i] = 1; |
---|
| 1692 | #else |
---|
[324] | 1693 | m_uiMaxDecPicBuffering[i] = 0; |
---|
[446] | 1694 | #endif |
---|
[324] | 1695 | m_numReorderPics[i] = 0; |
---|
| 1696 | } |
---|
| 1697 | m_scalingList = new TComScalingList; |
---|
| 1698 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
| 1699 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
| 1700 | } |
---|
| 1701 | |
---|
| 1702 | TComSPS::~TComSPS() |
---|
| 1703 | { |
---|
| 1704 | delete m_scalingList; |
---|
| 1705 | m_RPSList.destroy(); |
---|
| 1706 | } |
---|
| 1707 | |
---|
| 1708 | Void TComSPS::createRPSList( Int numRPS ) |
---|
| 1709 | { |
---|
| 1710 | m_RPSList.destroy(); |
---|
| 1711 | m_RPSList.create(numRPS); |
---|
| 1712 | } |
---|
[446] | 1713 | |
---|
[324] | 1714 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
| 1715 | { |
---|
| 1716 | if( !getVuiParametersPresentFlag() ) |
---|
| 1717 | { |
---|
| 1718 | return; |
---|
| 1719 | } |
---|
| 1720 | |
---|
| 1721 | TComVUI *vui = getVuiParameters(); |
---|
| 1722 | TComHRD *hrd = vui->getHrdParameters(); |
---|
| 1723 | |
---|
| 1724 | #if L0043_TIMING_INFO |
---|
| 1725 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
| 1726 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
| 1727 | switch( frameRate ) |
---|
| 1728 | { |
---|
| 1729 | case 24: |
---|
| 1730 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 1731 | break; |
---|
| 1732 | case 25: |
---|
| 1733 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 1734 | break; |
---|
| 1735 | case 30: |
---|
| 1736 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 1737 | break; |
---|
| 1738 | case 50: |
---|
| 1739 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 1740 | break; |
---|
| 1741 | case 60: |
---|
| 1742 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
| 1743 | break; |
---|
| 1744 | default: |
---|
| 1745 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
| 1746 | break; |
---|
| 1747 | } |
---|
| 1748 | #else |
---|
| 1749 | hrd->setTimingInfoPresentFlag( true ); |
---|
| 1750 | switch( frameRate ) |
---|
| 1751 | { |
---|
| 1752 | case 24: |
---|
| 1753 | hrd->setNumUnitsInTick( 1125000 ); hrd->setTimeScale ( 27000000 ); |
---|
| 1754 | break; |
---|
| 1755 | case 25: |
---|
| 1756 | hrd->setNumUnitsInTick( 1080000 ); hrd->setTimeScale ( 27000000 ); |
---|
| 1757 | break; |
---|
| 1758 | case 30: |
---|
| 1759 | hrd->setNumUnitsInTick( 900900 ); hrd->setTimeScale ( 27000000 ); |
---|
| 1760 | break; |
---|
| 1761 | case 50: |
---|
| 1762 | hrd->setNumUnitsInTick( 540000 ); hrd->setTimeScale ( 27000000 ); |
---|
| 1763 | break; |
---|
| 1764 | case 60: |
---|
| 1765 | hrd->setNumUnitsInTick( 450450 ); hrd->setTimeScale ( 27000000 ); |
---|
| 1766 | break; |
---|
| 1767 | default: |
---|
| 1768 | hrd->setNumUnitsInTick( 1001 ); hrd->setTimeScale ( 60000 ); |
---|
| 1769 | break; |
---|
| 1770 | } |
---|
| 1771 | #endif |
---|
| 1772 | |
---|
| 1773 | Bool rateCnt = ( bitRate > 0 ); |
---|
| 1774 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
| 1775 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
| 1776 | |
---|
| 1777 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
| 1778 | |
---|
| 1779 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 1780 | { |
---|
| 1781 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
| 1782 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
| 1783 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
| 1784 | #if L0044_DU_DPB_OUTPUT_DELAY_HRD |
---|
| 1785 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
| 1786 | #endif |
---|
| 1787 | } |
---|
| 1788 | else |
---|
| 1789 | { |
---|
| 1790 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
| 1791 | } |
---|
| 1792 | |
---|
| 1793 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
| 1794 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 1795 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
| 1796 | |
---|
| 1797 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
| 1798 | if( randomAccess ) |
---|
| 1799 | { |
---|
| 1800 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
| 1801 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
| 1802 | } |
---|
| 1803 | else |
---|
| 1804 | { |
---|
| 1805 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
| 1806 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
| 1807 | } |
---|
| 1808 | |
---|
| 1809 | /* |
---|
| 1810 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
| 1811 | */ |
---|
| 1812 | Int i, j; |
---|
| 1813 | UInt birateValue, cpbSizeValue; |
---|
| 1814 | UInt ducpbSizeValue; |
---|
| 1815 | #if L0363_DU_BIT_RATE |
---|
| 1816 | UInt duBitRateValue = 0; |
---|
| 1817 | #endif |
---|
| 1818 | |
---|
| 1819 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
| 1820 | { |
---|
| 1821 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
| 1822 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
| 1823 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
| 1824 | hrd->setCpbCntMinus1( i, 0 ); |
---|
| 1825 | |
---|
| 1826 | birateValue = bitRate; |
---|
| 1827 | cpbSizeValue = bitRate; // 1 second |
---|
| 1828 | ducpbSizeValue = bitRate/numDU; |
---|
| 1829 | #if L0363_DU_BIT_RATE |
---|
| 1830 | duBitRateValue = bitRate; |
---|
| 1831 | #endif |
---|
| 1832 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
| 1833 | { |
---|
| 1834 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
| 1835 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
| 1836 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
| 1837 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
| 1838 | |
---|
| 1839 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
| 1840 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
| 1841 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
| 1842 | #if L0363_DU_BIT_RATE |
---|
| 1843 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
| 1844 | #endif |
---|
| 1845 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
| 1846 | } |
---|
| 1847 | } |
---|
| 1848 | } |
---|
| 1849 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
| 1850 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
| 1851 | |
---|
| 1852 | TComPPS::TComPPS() |
---|
| 1853 | : m_PPSId (0) |
---|
| 1854 | , m_SPSId (0) |
---|
| 1855 | , m_picInitQPMinus26 (0) |
---|
| 1856 | , m_useDQP (false) |
---|
| 1857 | , m_bConstrainedIntraPred (false) |
---|
| 1858 | , m_bSliceChromaQpFlag (false) |
---|
| 1859 | , m_pcSPS (NULL) |
---|
| 1860 | , m_uiMaxCuDQPDepth (0) |
---|
| 1861 | , m_uiMinCuDQPSize (0) |
---|
| 1862 | , m_chromaCbQpOffset (0) |
---|
| 1863 | , m_chromaCrQpOffset (0) |
---|
| 1864 | , m_numRefIdxL0DefaultActive (1) |
---|
| 1865 | , m_numRefIdxL1DefaultActive (1) |
---|
| 1866 | , m_TransquantBypassEnableFlag (false) |
---|
| 1867 | , m_useTransformSkip (false) |
---|
| 1868 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
| 1869 | , m_tilesEnabledFlag (false) |
---|
| 1870 | , m_entropyCodingSyncEnabledFlag (false) |
---|
| 1871 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
| 1872 | , m_uniformSpacingFlag (0) |
---|
| 1873 | , m_iNumColumnsMinus1 (0) |
---|
| 1874 | , m_puiColumnWidth (NULL) |
---|
| 1875 | , m_iNumRowsMinus1 (0) |
---|
| 1876 | , m_puiRowHeight (NULL) |
---|
| 1877 | , m_iNumSubstreams (1) |
---|
| 1878 | , m_signHideFlag(0) |
---|
| 1879 | , m_cabacInitPresentFlag (false) |
---|
| 1880 | , m_encCABACTableIdx (I_SLICE) |
---|
| 1881 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
| 1882 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
| 1883 | , m_listsModificationPresentFlag( 0) |
---|
| 1884 | , m_numExtraSliceHeaderBits(0) |
---|
| 1885 | { |
---|
| 1886 | m_scalingList = new TComScalingList; |
---|
| 1887 | } |
---|
| 1888 | |
---|
| 1889 | TComPPS::~TComPPS() |
---|
| 1890 | { |
---|
| 1891 | if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 1892 | { |
---|
| 1893 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
| 1894 | m_puiColumnWidth = NULL; |
---|
| 1895 | } |
---|
| 1896 | if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 ) |
---|
| 1897 | { |
---|
| 1898 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
| 1899 | m_puiRowHeight = NULL; |
---|
| 1900 | } |
---|
| 1901 | delete m_scalingList; |
---|
| 1902 | } |
---|
| 1903 | |
---|
[446] | 1904 | #if H_3D |
---|
| 1905 | Void |
---|
| 1906 | TComSPS::initCamParaSPS( UInt uiViewIndex, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
| 1907 | { |
---|
| 1908 | AOT( uiViewIndex != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
| 1909 | |
---|
| 1910 | m_uiCamParPrecision = ( uiViewIndex ? uiCamParPrecision : 0 ); |
---|
| 1911 | m_bCamParInSliceHeader = ( uiViewIndex ? bCamParSlice : false ); |
---|
| 1912 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
| 1913 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
| 1914 | |
---|
| 1915 | if( !m_bCamParInSliceHeader ) |
---|
| 1916 | { |
---|
| 1917 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ ) |
---|
| 1918 | { |
---|
| 1919 | m_aaiCodedScale [ 0 ][ uiBaseViewIndex ] = aaiScale [ uiBaseViewIndex ][ uiViewIndex ]; |
---|
| 1920 | m_aaiCodedScale [ 1 ][ uiBaseViewIndex ] = aaiScale [ uiViewIndex ][ uiBaseViewIndex ]; |
---|
| 1921 | m_aaiCodedOffset[ 0 ][ uiBaseViewIndex ] = aaiOffset[ uiBaseViewIndex ][ uiViewIndex ]; |
---|
| 1922 | m_aaiCodedOffset[ 1 ][ uiBaseViewIndex ] = aaiOffset[ uiViewIndex ][ uiBaseViewIndex ]; |
---|
| 1923 | } |
---|
| 1924 | } |
---|
| 1925 | } |
---|
| 1926 | #endif |
---|
| 1927 | |
---|
[324] | 1928 | TComReferencePictureSet::TComReferencePictureSet() |
---|
| 1929 | : m_numberOfPictures (0) |
---|
| 1930 | , m_numberOfNegativePictures (0) |
---|
| 1931 | , m_numberOfPositivePictures (0) |
---|
| 1932 | , m_numberOfLongtermPictures (0) |
---|
| 1933 | , m_interRPSPrediction (0) |
---|
| 1934 | , m_deltaRIdxMinus1 (0) |
---|
| 1935 | , m_deltaRPS (0) |
---|
| 1936 | , m_numRefIdc (0) |
---|
| 1937 | { |
---|
| 1938 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
| 1939 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
| 1940 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
| 1941 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
| 1942 | } |
---|
| 1943 | |
---|
| 1944 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
| 1945 | { |
---|
| 1946 | } |
---|
| 1947 | |
---|
| 1948 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
| 1949 | { |
---|
| 1950 | m_used[bufferNum] = used; |
---|
| 1951 | } |
---|
| 1952 | |
---|
| 1953 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
| 1954 | { |
---|
| 1955 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
| 1956 | } |
---|
| 1957 | |
---|
| 1958 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
| 1959 | { |
---|
| 1960 | m_numberOfPictures = numberOfPictures; |
---|
| 1961 | } |
---|
| 1962 | |
---|
| 1963 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
| 1964 | { |
---|
| 1965 | return m_used[bufferNum]; |
---|
| 1966 | } |
---|
| 1967 | |
---|
| 1968 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
| 1969 | { |
---|
| 1970 | return m_deltaPOC[bufferNum]; |
---|
| 1971 | } |
---|
| 1972 | |
---|
| 1973 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
| 1974 | { |
---|
| 1975 | return m_numberOfPictures; |
---|
| 1976 | } |
---|
| 1977 | |
---|
| 1978 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
| 1979 | { |
---|
| 1980 | return m_POC[bufferNum]; |
---|
| 1981 | } |
---|
[446] | 1982 | |
---|
[324] | 1983 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
| 1984 | { |
---|
| 1985 | m_POC[bufferNum] = POC; |
---|
| 1986 | } |
---|
[446] | 1987 | |
---|
[324] | 1988 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
| 1989 | { |
---|
| 1990 | return m_bCheckLTMSB[bufferNum]; |
---|
| 1991 | } |
---|
[446] | 1992 | |
---|
[324] | 1993 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
| 1994 | { |
---|
| 1995 | m_bCheckLTMSB[bufferNum] = b; |
---|
| 1996 | } |
---|
| 1997 | |
---|
| 1998 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
| 1999 | * \param uiBufferNum |
---|
| 2000 | * \param iRefIdc |
---|
| 2001 | * \returns Void |
---|
| 2002 | */ |
---|
| 2003 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
| 2004 | { |
---|
| 2005 | m_refIdc[bufferNum] = refIdc; |
---|
| 2006 | } |
---|
| 2007 | |
---|
| 2008 | /** get the reference idc value at uiBufferNum |
---|
| 2009 | * \param uiBufferNum |
---|
| 2010 | * \returns Int |
---|
| 2011 | */ |
---|
| 2012 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
| 2013 | { |
---|
| 2014 | return m_refIdc[bufferNum]; |
---|
| 2015 | } |
---|
| 2016 | |
---|
| 2017 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
| 2018 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
| 2019 | * +ve values are in increasing order. |
---|
| 2020 | * \returns Void |
---|
| 2021 | */ |
---|
| 2022 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
| 2023 | { |
---|
| 2024 | // sort in increasing order (smallest first) |
---|
| 2025 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
| 2026 | { |
---|
| 2027 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2028 | Bool used = getUsed(j); |
---|
| 2029 | for (Int k=j-1; k >= 0; k--) |
---|
| 2030 | { |
---|
| 2031 | Int temp = getDeltaPOC(k); |
---|
| 2032 | if (deltaPOC < temp) |
---|
| 2033 | { |
---|
| 2034 | setDeltaPOC(k+1, temp); |
---|
| 2035 | setUsed(k+1, getUsed(k)); |
---|
| 2036 | setDeltaPOC(k, deltaPOC); |
---|
| 2037 | setUsed(k, used); |
---|
| 2038 | } |
---|
| 2039 | } |
---|
| 2040 | } |
---|
| 2041 | // flip the negative values to largest first |
---|
| 2042 | Int numNegPics = getNumberOfNegativePictures(); |
---|
| 2043 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
| 2044 | { |
---|
| 2045 | Int deltaPOC = getDeltaPOC(j); |
---|
| 2046 | Bool used = getUsed(j); |
---|
| 2047 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
| 2048 | setUsed(j, getUsed(k)); |
---|
| 2049 | setDeltaPOC(k, deltaPOC); |
---|
| 2050 | setUsed(k, used); |
---|
| 2051 | } |
---|
| 2052 | } |
---|
| 2053 | |
---|
| 2054 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
| 2055 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
| 2056 | * \returns Void |
---|
| 2057 | */ |
---|
| 2058 | Void TComReferencePictureSet::printDeltaPOC() |
---|
| 2059 | { |
---|
| 2060 | printf("DeltaPOC = { "); |
---|
| 2061 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
| 2062 | { |
---|
| 2063 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
| 2064 | } |
---|
| 2065 | if (getInterRPSPrediction()) |
---|
| 2066 | { |
---|
| 2067 | printf("}, RefIdc = { "); |
---|
| 2068 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
| 2069 | { |
---|
| 2070 | printf("%d ", getRefIdc(j)); |
---|
| 2071 | } |
---|
| 2072 | } |
---|
| 2073 | printf("}\n"); |
---|
| 2074 | } |
---|
| 2075 | |
---|
| 2076 | TComRPSList::TComRPSList() |
---|
| 2077 | :m_referencePictureSets (NULL) |
---|
| 2078 | { |
---|
| 2079 | } |
---|
| 2080 | |
---|
| 2081 | TComRPSList::~TComRPSList() |
---|
| 2082 | { |
---|
| 2083 | } |
---|
| 2084 | |
---|
| 2085 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
| 2086 | { |
---|
| 2087 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2088 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
| 2089 | } |
---|
| 2090 | |
---|
| 2091 | Void TComRPSList::destroy() |
---|
| 2092 | { |
---|
| 2093 | if (m_referencePictureSets) |
---|
| 2094 | { |
---|
| 2095 | delete [] m_referencePictureSets; |
---|
| 2096 | } |
---|
| 2097 | m_numberOfReferencePictureSets = 0; |
---|
| 2098 | m_referencePictureSets = NULL; |
---|
| 2099 | } |
---|
| 2100 | |
---|
| 2101 | |
---|
| 2102 | |
---|
| 2103 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
| 2104 | { |
---|
| 2105 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
| 2106 | } |
---|
| 2107 | |
---|
| 2108 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
| 2109 | { |
---|
| 2110 | return m_numberOfReferencePictureSets; |
---|
| 2111 | } |
---|
| 2112 | |
---|
| 2113 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
| 2114 | { |
---|
| 2115 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
| 2116 | } |
---|
| 2117 | |
---|
| 2118 | TComRefPicListModification::TComRefPicListModification() |
---|
| 2119 | : m_bRefPicListModificationFlagL0 (false) |
---|
| 2120 | , m_bRefPicListModificationFlagL1 (false) |
---|
| 2121 | { |
---|
| 2122 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
| 2123 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
| 2124 | } |
---|
| 2125 | |
---|
| 2126 | TComRefPicListModification::~TComRefPicListModification() |
---|
| 2127 | { |
---|
| 2128 | } |
---|
| 2129 | |
---|
| 2130 | TComScalingList::TComScalingList() |
---|
| 2131 | { |
---|
| 2132 | m_useTransformSkip = false; |
---|
| 2133 | init(); |
---|
| 2134 | } |
---|
| 2135 | TComScalingList::~TComScalingList() |
---|
| 2136 | { |
---|
| 2137 | destroy(); |
---|
| 2138 | } |
---|
| 2139 | |
---|
| 2140 | /** set default quantization matrix to array |
---|
| 2141 | */ |
---|
| 2142 | Void TComSlice::setDefaultScalingList() |
---|
| 2143 | { |
---|
| 2144 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2145 | { |
---|
| 2146 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2147 | { |
---|
| 2148 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
| 2149 | } |
---|
| 2150 | } |
---|
| 2151 | } |
---|
| 2152 | /** check if use default quantization matrix |
---|
| 2153 | * \returns true if use default quantization matrix in all size |
---|
| 2154 | */ |
---|
| 2155 | Bool TComSlice::checkDefaultScalingList() |
---|
| 2156 | { |
---|
| 2157 | UInt defaultCounter=0; |
---|
| 2158 | |
---|
| 2159 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2160 | { |
---|
| 2161 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
| 2162 | { |
---|
| 2163 | 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 |
---|
| 2164 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
| 2165 | { |
---|
| 2166 | defaultCounter++; |
---|
| 2167 | } |
---|
| 2168 | } |
---|
| 2169 | } |
---|
| 2170 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
| 2171 | } |
---|
| 2172 | |
---|
[368] | 2173 | #if H_MV |
---|
| 2174 | Void TComSlice::createAndApplyIvReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer ) |
---|
| 2175 | { |
---|
| 2176 | refPicSetInterLayer.clear(); |
---|
| 2177 | |
---|
| 2178 | for( Int i = 0; i < getVPS()->getNumDirectRefLayers( getLayerIdInVps() ); i++ ) |
---|
| 2179 | { |
---|
| 2180 | Int layerIdRef = getVPS()->getRefLayerId( getLayerIdInVps(), i ); |
---|
| 2181 | TComPic* picRef = ivPicLists->getPic( layerIdRef, getPOC() ) ; |
---|
| 2182 | assert ( picRef != 0 ); |
---|
| 2183 | |
---|
| 2184 | picRef->getPicYuvRec()->extendPicBorder(); |
---|
| 2185 | picRef->setIsLongTerm( true ); |
---|
| 2186 | picRef->getSlice(0)->setReferenced( true ); |
---|
| 2187 | |
---|
| 2188 | refPicSetInterLayer.push_back( picRef ); |
---|
| 2189 | } |
---|
| 2190 | } |
---|
| 2191 | |
---|
| 2192 | Void TComSlice::markIvRefPicsAsShortTerm( std::vector<TComPic*> refPicSetInterLayer ) |
---|
| 2193 | { |
---|
| 2194 | // Mark as shortterm |
---|
| 2195 | for ( Int i = 0; i < refPicSetInterLayer.size(); i++ ) |
---|
| 2196 | { |
---|
| 2197 | refPicSetInterLayer[i]->setIsLongTerm( false ); |
---|
| 2198 | } |
---|
| 2199 | } |
---|
| 2200 | |
---|
| 2201 | Void TComSlice::markIvRefPicsAsUnused( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc ) |
---|
| 2202 | { |
---|
| 2203 | // Fill targetDecLayerIdSet with all layers if empty. |
---|
| 2204 | if (targetDecLayerIdSet.size() == 0 ) |
---|
| 2205 | { |
---|
| 2206 | for ( Int layerIdInVps = 0; layerIdInVps < vps->getMaxLayers(); layerIdInVps++ ) |
---|
| 2207 | { |
---|
| 2208 | targetDecLayerIdSet.push_back( vps->getLayerIdInNuh( layerIdInVps ) ); |
---|
| 2209 | } |
---|
| 2210 | } |
---|
| 2211 | |
---|
| 2212 | Int numTargetDecLayers = (Int) targetDecLayerIdSet.size(); |
---|
| 2213 | Int latestDecIdx; |
---|
| 2214 | for ( latestDecIdx = 0; latestDecIdx < numTargetDecLayers; latestDecIdx++) |
---|
| 2215 | { |
---|
| 2216 | if ( targetDecLayerIdSet[ latestDecIdx ] == curLayerId ) |
---|
| 2217 | break; |
---|
| 2218 | } |
---|
| 2219 | |
---|
| 2220 | for( Int i = 0; i <= latestDecIdx; i++ ) |
---|
| 2221 | { |
---|
| 2222 | if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ i ] ) ) |
---|
| 2223 | { |
---|
| 2224 | TComPic* pcPic = ivPicLists->getPic( targetDecLayerIdSet[ i ], curPoc ); |
---|
| 2225 | if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() ) |
---|
| 2226 | { |
---|
| 2227 | Bool remainingInterLayerReferencesFlag = false; |
---|
| 2228 | for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
| 2229 | { |
---|
| 2230 | TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS(); |
---|
| 2231 | if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) ) |
---|
| 2232 | { |
---|
| 2233 | Int targetDecLayerIdinVPS = vpsSlice->getLayerIdInVps( targetDecLayerIdSet[ j ] ); |
---|
| 2234 | for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdinVPS ); k++ ) |
---|
| 2235 | if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdinVPS, k ) ) |
---|
| 2236 | remainingInterLayerReferencesFlag = true; |
---|
| 2237 | } |
---|
| 2238 | } |
---|
| 2239 | if( !remainingInterLayerReferencesFlag ) |
---|
| 2240 | pcPic->getSlice(0)->setReferenced( false ); |
---|
| 2241 | } |
---|
| 2242 | } |
---|
| 2243 | } |
---|
| 2244 | } |
---|
| 2245 | |
---|
| 2246 | Void TComSlice::xPrintRefPicList() |
---|
| 2247 | { |
---|
| 2248 | for ( Int li = 0; li < 2; li++) |
---|
| 2249 | { |
---|
| 2250 | std::cout << std::endl << "RefPicListL" << li << ":" << std::endl; |
---|
| 2251 | for (Int rIdx = 0; rIdx <= (m_aiNumRefIdx[li]-1); rIdx ++) |
---|
| 2252 | { |
---|
| 2253 | if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true ); |
---|
| 2254 | |
---|
| 2255 | m_apcRefPicList[li][rIdx]->print( false ); |
---|
| 2256 | } |
---|
| 2257 | } |
---|
| 2258 | } |
---|
| 2259 | #endif |
---|
[324] | 2260 | /** get scaling matrix from RefMatrixID |
---|
| 2261 | * \param sizeId size index |
---|
| 2262 | * \param Index of input matrix |
---|
| 2263 | * \param Index of reference matrix |
---|
| 2264 | */ |
---|
| 2265 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
| 2266 | { |
---|
| 2267 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2268 | } |
---|
[446] | 2269 | |
---|
[324] | 2270 | /** parse syntax infomation |
---|
| 2271 | * \param pchFile syntax infomation |
---|
| 2272 | * \returns false if successful |
---|
| 2273 | */ |
---|
| 2274 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
| 2275 | { |
---|
| 2276 | FILE *fp; |
---|
| 2277 | Char line[1024]; |
---|
| 2278 | UInt sizeIdc,listIdc; |
---|
| 2279 | UInt i,size = 0; |
---|
| 2280 | Int *src=0,data; |
---|
| 2281 | Char *ret; |
---|
| 2282 | UInt retval; |
---|
| 2283 | |
---|
| 2284 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
| 2285 | { |
---|
| 2286 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
| 2287 | return true; |
---|
| 2288 | } |
---|
| 2289 | |
---|
| 2290 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
| 2291 | { |
---|
| 2292 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
| 2293 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
| 2294 | { |
---|
| 2295 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
| 2296 | |
---|
| 2297 | fseek(fp,0,0); |
---|
| 2298 | do |
---|
| 2299 | { |
---|
| 2300 | ret = fgets(line, 1024, fp); |
---|
| 2301 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2302 | { |
---|
| 2303 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2304 | return true; |
---|
| 2305 | } |
---|
| 2306 | } |
---|
| 2307 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
| 2308 | for (i=0; i<size; i++) |
---|
| 2309 | { |
---|
| 2310 | retval = fscanf(fp, "%d,", &data); |
---|
| 2311 | if (retval!=1) |
---|
| 2312 | { |
---|
| 2313 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2314 | return true; |
---|
| 2315 | } |
---|
| 2316 | src[i] = data; |
---|
| 2317 | } |
---|
| 2318 | //set DC value for default matrix check |
---|
| 2319 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
| 2320 | |
---|
| 2321 | if(sizeIdc > SCALING_LIST_8x8) |
---|
| 2322 | { |
---|
| 2323 | fseek(fp,0,0); |
---|
| 2324 | do |
---|
| 2325 | { |
---|
| 2326 | ret = fgets(line, 1024, fp); |
---|
| 2327 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
| 2328 | { |
---|
| 2329 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
| 2330 | return true; |
---|
| 2331 | } |
---|
| 2332 | } |
---|
| 2333 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
| 2334 | retval = fscanf(fp, "%d,", &data); |
---|
| 2335 | if (retval!=1) |
---|
| 2336 | { |
---|
| 2337 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
| 2338 | return true; |
---|
| 2339 | } |
---|
| 2340 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
| 2341 | setScalingListDC(sizeIdc,listIdc,data); |
---|
| 2342 | } |
---|
| 2343 | } |
---|
| 2344 | } |
---|
| 2345 | fclose(fp); |
---|
| 2346 | return false; |
---|
| 2347 | } |
---|
| 2348 | |
---|
| 2349 | /** initialization process of quantization matrix array |
---|
| 2350 | */ |
---|
| 2351 | Void TComScalingList::init() |
---|
| 2352 | { |
---|
| 2353 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2354 | { |
---|
| 2355 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2356 | { |
---|
| 2357 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
| 2358 | } |
---|
| 2359 | } |
---|
| 2360 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
| 2361 | } |
---|
[446] | 2362 | |
---|
[324] | 2363 | /** destroy quantization matrix array |
---|
| 2364 | */ |
---|
| 2365 | Void TComScalingList::destroy() |
---|
| 2366 | { |
---|
| 2367 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2368 | { |
---|
| 2369 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2370 | { |
---|
| 2371 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
| 2372 | } |
---|
| 2373 | } |
---|
| 2374 | } |
---|
[446] | 2375 | |
---|
[324] | 2376 | /** get default address of quantization matrix |
---|
| 2377 | * \param sizeId size index |
---|
| 2378 | * \param listId list index |
---|
| 2379 | * \returns pointer of quantization matrix |
---|
| 2380 | */ |
---|
| 2381 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
| 2382 | { |
---|
| 2383 | Int *src = 0; |
---|
| 2384 | switch(sizeId) |
---|
| 2385 | { |
---|
| 2386 | case SCALING_LIST_4x4: |
---|
| 2387 | src = g_quantTSDefault4x4; |
---|
| 2388 | break; |
---|
| 2389 | case SCALING_LIST_8x8: |
---|
| 2390 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2391 | break; |
---|
| 2392 | case SCALING_LIST_16x16: |
---|
| 2393 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2394 | break; |
---|
| 2395 | case SCALING_LIST_32x32: |
---|
| 2396 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
| 2397 | break; |
---|
| 2398 | default: |
---|
| 2399 | assert(0); |
---|
| 2400 | src = NULL; |
---|
| 2401 | break; |
---|
| 2402 | } |
---|
| 2403 | return src; |
---|
| 2404 | } |
---|
[446] | 2405 | |
---|
[324] | 2406 | /** process of default matrix |
---|
| 2407 | * \param sizeId size index |
---|
| 2408 | * \param Index of input matrix |
---|
| 2409 | */ |
---|
| 2410 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
| 2411 | { |
---|
| 2412 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
| 2413 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
| 2414 | } |
---|
[446] | 2415 | |
---|
[324] | 2416 | /** check DC value of matrix for default matrix signaling |
---|
| 2417 | */ |
---|
| 2418 | Void TComScalingList::checkDcOfMatrix() |
---|
| 2419 | { |
---|
| 2420 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2421 | { |
---|
| 2422 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2423 | { |
---|
| 2424 | //check default matrix? |
---|
| 2425 | if(getScalingListDC(sizeId,listId) == 0) |
---|
| 2426 | { |
---|
| 2427 | processDefaultMarix(sizeId, listId); |
---|
| 2428 | } |
---|
| 2429 | } |
---|
| 2430 | } |
---|
| 2431 | } |
---|
| 2432 | |
---|
| 2433 | ParameterSetManager::ParameterSetManager() |
---|
| 2434 | : m_vpsMap(MAX_NUM_VPS) |
---|
| 2435 | , m_spsMap(MAX_NUM_SPS) |
---|
| 2436 | , m_ppsMap(MAX_NUM_PPS) |
---|
| 2437 | , m_activeVPSId(-1) |
---|
| 2438 | , m_activeSPSId(-1) |
---|
| 2439 | , m_activePPSId(-1) |
---|
| 2440 | { |
---|
| 2441 | } |
---|
| 2442 | |
---|
| 2443 | |
---|
| 2444 | ParameterSetManager::~ParameterSetManager() |
---|
| 2445 | { |
---|
| 2446 | } |
---|
| 2447 | |
---|
| 2448 | //! activate a SPS from a active parameter sets SEI message |
---|
| 2449 | //! \returns true, if activation is successful |
---|
| 2450 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
| 2451 | { |
---|
| 2452 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2453 | if (sps) |
---|
| 2454 | { |
---|
| 2455 | Int vpsId = sps->getVPSId(); |
---|
| 2456 | if (m_vpsMap.getPS(vpsId)) |
---|
| 2457 | { |
---|
| 2458 | m_activeVPSId = vpsId; |
---|
| 2459 | m_activeSPSId = spsId; |
---|
| 2460 | return true; |
---|
| 2461 | } |
---|
| 2462 | else |
---|
| 2463 | { |
---|
| 2464 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
| 2465 | } |
---|
| 2466 | } |
---|
| 2467 | else |
---|
| 2468 | { |
---|
| 2469 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
| 2470 | } |
---|
| 2471 | return false; |
---|
| 2472 | } |
---|
| 2473 | |
---|
| 2474 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
| 2475 | //! \returns true, if activation is successful |
---|
[446] | 2476 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
[324] | 2477 | { |
---|
| 2478 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
| 2479 | if (pps) |
---|
| 2480 | { |
---|
| 2481 | Int spsId = pps->getSPSId(); |
---|
[368] | 2482 | #if H_MV |
---|
| 2483 | // active parameter sets per layer should be used here |
---|
| 2484 | #else |
---|
[446] | 2485 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
[324] | 2486 | { |
---|
[446] | 2487 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
[324] | 2488 | return false; |
---|
| 2489 | } |
---|
[368] | 2490 | #endif |
---|
[324] | 2491 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
| 2492 | if (sps) |
---|
| 2493 | { |
---|
| 2494 | Int vpsId = sps->getVPSId(); |
---|
[446] | 2495 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
[324] | 2496 | { |
---|
[446] | 2497 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
[324] | 2498 | return false; |
---|
| 2499 | } |
---|
| 2500 | if (m_vpsMap.getPS(vpsId)) |
---|
| 2501 | { |
---|
| 2502 | m_activePPSId = ppsId; |
---|
| 2503 | m_activeVPSId = vpsId; |
---|
| 2504 | m_activeSPSId = spsId; |
---|
| 2505 | return true; |
---|
| 2506 | } |
---|
| 2507 | else |
---|
| 2508 | { |
---|
| 2509 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
| 2510 | } |
---|
| 2511 | } |
---|
| 2512 | else |
---|
| 2513 | { |
---|
| 2514 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
| 2515 | } |
---|
| 2516 | } |
---|
| 2517 | else |
---|
| 2518 | { |
---|
| 2519 | printf("Warning: tried to activate non-existing PPS."); |
---|
| 2520 | } |
---|
| 2521 | return false; |
---|
| 2522 | } |
---|
| 2523 | |
---|
| 2524 | ProfileTierLevel::ProfileTierLevel() |
---|
| 2525 | : m_profileSpace (0) |
---|
| 2526 | , m_tierFlag (false) |
---|
| 2527 | , m_profileIdc (0) |
---|
| 2528 | , m_levelIdc (0) |
---|
| 2529 | #if L0046_CONSTRAINT_FLAGS |
---|
| 2530 | , m_progressiveSourceFlag (false) |
---|
| 2531 | , m_interlacedSourceFlag (false) |
---|
| 2532 | , m_nonPackedConstraintFlag(false) |
---|
| 2533 | , m_frameOnlyConstraintFlag(false) |
---|
| 2534 | #endif |
---|
| 2535 | { |
---|
| 2536 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
| 2537 | } |
---|
| 2538 | |
---|
| 2539 | TComPTL::TComPTL() |
---|
| 2540 | { |
---|
| 2541 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
| 2542 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
| 2543 | } |
---|
| 2544 | |
---|
[368] | 2545 | #if H_MV |
---|
| 2546 | Void TComPTL::copyLevelFrom( TComPTL* source ) |
---|
| 2547 | { |
---|
| 2548 | getGeneralPTL()->setLevelIdc( source->getGeneralPTL()->getLevelIdc() ); |
---|
| 2549 | for( Int subLayer = 0; subLayer < 6; subLayer++ ) |
---|
| 2550 | { |
---|
| 2551 | setSubLayerLevelPresentFlag( subLayer, source->getSubLayerLevelPresentFlag( subLayer ) ); |
---|
| 2552 | getSubLayerPTL( subLayer )->setLevelIdc( source->getSubLayerPTL( subLayer )->getLevelIdc() ); |
---|
| 2553 | } |
---|
| 2554 | } |
---|
| 2555 | #endif |
---|
[324] | 2556 | #if SIGNAL_BITRATE_PICRATE_IN_VPS |
---|
| 2557 | TComBitRatePicRateInfo::TComBitRatePicRateInfo() |
---|
| 2558 | { |
---|
| 2559 | ::memset(m_bitRateInfoPresentFlag, 0, sizeof(m_bitRateInfoPresentFlag)); |
---|
| 2560 | ::memset(m_picRateInfoPresentFlag, 0, sizeof(m_picRateInfoPresentFlag)); |
---|
| 2561 | ::memset(m_avgBitRate, 0, sizeof(m_avgBitRate)); |
---|
| 2562 | ::memset(m_maxBitRate, 0, sizeof(m_maxBitRate)); |
---|
| 2563 | ::memset(m_constantPicRateIdc, 0, sizeof(m_constantPicRateIdc)); |
---|
| 2564 | ::memset(m_avgPicRate, 0, sizeof(m_avgPicRate)); |
---|
| 2565 | } |
---|
| 2566 | #endif |
---|
| 2567 | //! \} |
---|