[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "NALread.h" |
---|
[2] | 39 | #include "TDecTop.h" |
---|
| 40 | |
---|
[608] | 41 | #if H_MV |
---|
| 42 | ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder; |
---|
| 43 | #endif |
---|
[56] | 44 | //! \ingroup TLibDecoder |
---|
| 45 | //! \{ |
---|
[2] | 46 | |
---|
| 47 | TDecTop::TDecTop() |
---|
| 48 | { |
---|
[56] | 49 | m_pcPic = 0; |
---|
[2] | 50 | m_iMaxRefPicNum = 0; |
---|
| 51 | #if ENC_DEC_TRACE |
---|
[608] | 52 | #if H_MV |
---|
| 53 | if ( g_hTrace == NULL ) |
---|
| 54 | { |
---|
| 55 | #endif |
---|
| 56 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
[2] | 57 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 58 | g_nSymbolCounter = 0; |
---|
[608] | 59 | #if H_MV |
---|
| 60 | } |
---|
[2] | 61 | #endif |
---|
[608] | 62 | #endif |
---|
[655] | 63 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
[56] | 64 | m_pocCRA = 0; |
---|
[608] | 65 | m_pocRandomAccess = MAX_INT; |
---|
[56] | 66 | m_prevPOC = MAX_INT; |
---|
[2] | 67 | m_bFirstSliceInPicture = true; |
---|
| 68 | m_bFirstSliceInSequence = true; |
---|
[655] | 69 | m_prevSliceSkipped = false; |
---|
| 70 | m_skippedPOC = 0; |
---|
[964] | 71 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 72 | m_bFirstSliceInBitstream = true; |
---|
| 73 | m_lastPOCNoOutputPriorPics = -1; |
---|
| 74 | m_craNoRaslOutputFlag = false; |
---|
| 75 | m_isNoOutputPriorPics = false; |
---|
| 76 | #endif |
---|
[976] | 77 | #if H_MV |
---|
[964] | 78 | m_isLastNALWasEos = false; |
---|
[608] | 79 | m_layerId = 0; |
---|
| 80 | m_viewId = 0; |
---|
[976] | 81 | #if H_MV |
---|
[964] | 82 | m_targetOptLayerSetIdx = -1; |
---|
[608] | 83 | #endif |
---|
[964] | 84 | #endif |
---|
[2] | 85 | } |
---|
| 86 | |
---|
| 87 | TDecTop::~TDecTop() |
---|
| 88 | { |
---|
| 89 | #if ENC_DEC_TRACE |
---|
[608] | 90 | fclose( g_hTrace ); |
---|
[2] | 91 | #endif |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | Void TDecTop::create() |
---|
| 95 | { |
---|
| 96 | m_cGopDecoder.create(); |
---|
| 97 | m_apcSlicePilot = new TComSlice; |
---|
[608] | 98 | m_uiSliceIdx = 0; |
---|
[2] | 99 | } |
---|
| 100 | |
---|
| 101 | Void TDecTop::destroy() |
---|
| 102 | { |
---|
| 103 | m_cGopDecoder.destroy(); |
---|
[56] | 104 | |
---|
[2] | 105 | delete m_apcSlicePilot; |
---|
| 106 | m_apcSlicePilot = NULL; |
---|
[56] | 107 | |
---|
[2] | 108 | m_cSliceDecoder.destroy(); |
---|
| 109 | } |
---|
| 110 | |
---|
[608] | 111 | Void TDecTop::init() |
---|
[2] | 112 | { |
---|
| 113 | // initialize ROM |
---|
[608] | 114 | #if !H_MV |
---|
[56] | 115 | initROM(); |
---|
[5] | 116 | #endif |
---|
[608] | 117 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO ); |
---|
[2] | 118 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 119 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | Void TDecTop::deletePicBuffer ( ) |
---|
| 123 | { |
---|
| 124 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 125 | Int iSize = Int( m_cListPic.size() ); |
---|
[56] | 126 | |
---|
[2] | 127 | for (Int i = 0; i < iSize; i++ ) |
---|
| 128 | { |
---|
[608] | 129 | TComPic* pcPic = *(iterPic++); |
---|
| 130 | #if H_MV |
---|
| 131 | if( pcPic ) |
---|
[56] | 132 | { |
---|
[608] | 133 | #endif |
---|
| 134 | pcPic->destroy(); |
---|
[56] | 135 | |
---|
[608] | 136 | delete pcPic; |
---|
| 137 | pcPic = NULL; |
---|
| 138 | #if H_MV |
---|
[56] | 139 | } |
---|
[608] | 140 | #endif |
---|
[2] | 141 | } |
---|
[56] | 142 | |
---|
[2] | 143 | m_cSAO.destroy(); |
---|
[56] | 144 | |
---|
[2] | 145 | m_cLoopFilter. destroy(); |
---|
[56] | 146 | |
---|
[608] | 147 | #if !H_MV |
---|
[2] | 148 | // destroy ROM |
---|
[608] | 149 | destroyROM(); |
---|
| 150 | #endif |
---|
[2] | 151 | } |
---|
| 152 | |
---|
[608] | 153 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
[56] | 154 | { |
---|
[608] | 155 | Int numReorderPics[MAX_TLAYER]; |
---|
| 156 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
| 157 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
[56] | 158 | |
---|
[622] | 159 | #if H_MV |
---|
| 160 | assert( conformanceWindow .getScaledFlag() ); |
---|
| 161 | assert( defaultDisplayWindow.getScaledFlag() ); |
---|
| 162 | #endif |
---|
[608] | 163 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
[56] | 164 | { |
---|
[884] | 165 | #if H_MV |
---|
[872] | 166 | numReorderPics[temporalLayer] = ( getLayerId() == 0 ) ? pcSlice->getSPS()->getNumReorderPics(temporalLayer) : pcSlice->getVPS()->getNumReorderPics(temporalLayer); |
---|
| 167 | #else |
---|
[608] | 168 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
[872] | 169 | #endif |
---|
[56] | 170 | } |
---|
[884] | 171 | #if H_MV |
---|
[872] | 172 | if ( getLayerId() == 0 ) |
---|
| 173 | { |
---|
| 174 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); |
---|
| 175 | } |
---|
| 176 | else |
---|
| 177 | { |
---|
| 178 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); |
---|
| 179 | #if H_MV_HLS7_GEN |
---|
| 180 | TComVPS* vps = pcSlice->getVPS(); |
---|
| 181 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
[964] | 182 | Int lsIdx = vps->olsIdxToLsIdx( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec? |
---|
[872] | 183 | Int layerIdx = vps->getIdxInLayerSet ( lsIdx, getLayerId() ); |
---|
| 184 | Int subDpbIdx = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); |
---|
| 185 | m_iMaxRefPicNum = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ; |
---|
| 186 | #endif |
---|
| 187 | } |
---|
| 188 | #else |
---|
[608] | 189 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[872] | 190 | #endif |
---|
[2] | 191 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 192 | { |
---|
[56] | 193 | rpcPic = new TComPic(); |
---|
| 194 | |
---|
[608] | 195 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 196 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
[2] | 197 | m_cListPic.pushBack( rpcPic ); |
---|
[56] | 198 | |
---|
[2] | 199 | return; |
---|
| 200 | } |
---|
[56] | 201 | |
---|
[2] | 202 | Bool bBufferIsAvailable = false; |
---|
| 203 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 204 | while (iterPic != m_cListPic.end()) |
---|
| 205 | { |
---|
| 206 | rpcPic = *(iterPic++); |
---|
[56] | 207 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 208 | { |
---|
[56] | 209 | rpcPic->setOutputMark(false); |
---|
[976] | 210 | #if H_MV |
---|
[964] | 211 | rpcPic->setPicOutputFlag(false); |
---|
| 212 | #endif |
---|
[2] | 213 | bBufferIsAvailable = true; |
---|
| 214 | break; |
---|
| 215 | } |
---|
[56] | 216 | |
---|
| 217 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 218 | { |
---|
| 219 | rpcPic->setOutputMark(false); |
---|
[976] | 220 | #if H_MV |
---|
[964] | 221 | rpcPic->setPicOutputFlag(false); |
---|
| 222 | #endif |
---|
[56] | 223 | rpcPic->setReconMark( false ); |
---|
| 224 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 225 | bBufferIsAvailable = true; |
---|
| 226 | break; |
---|
| 227 | } |
---|
[2] | 228 | } |
---|
[56] | 229 | |
---|
[2] | 230 | if ( !bBufferIsAvailable ) |
---|
| 231 | { |
---|
[56] | 232 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 233 | m_iMaxRefPicNum++; |
---|
| 234 | rpcPic = new TComPic(); |
---|
| 235 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 236 | } |
---|
[608] | 237 | rpcPic->destroy(); |
---|
| 238 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 239 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
[2] | 240 | } |
---|
| 241 | |
---|
[608] | 242 | #if H_MV |
---|
| 243 | Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet ) |
---|
| 244 | #else |
---|
| 245 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
| 246 | #endif |
---|
[56] | 247 | { |
---|
| 248 | if (!m_pcPic) |
---|
| 249 | { |
---|
| 250 | /* nothing to deblock */ |
---|
| 251 | return; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | TComPic*& pcPic = m_pcPic; |
---|
[2] | 255 | |
---|
[608] | 256 | // Execute Deblock + Cleanup |
---|
[56] | 257 | |
---|
[608] | 258 | m_cGopDecoder.filterPicture(pcPic); |
---|
[56] | 259 | |
---|
| 260 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
[608] | 261 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
[56] | 262 | rpcListPic = &m_cListPic; |
---|
| 263 | m_cCuDecoder.destroy(); |
---|
[608] | 264 | #if H_MV |
---|
[622] | 265 | TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
[608] | 266 | TComSlice::markCurrPic( pcPic ); |
---|
| 267 | #endif |
---|
[56] | 268 | m_bFirstSliceInPicture = true; |
---|
| 269 | |
---|
| 270 | return; |
---|
| 271 | } |
---|
| 272 | |
---|
[964] | 273 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 274 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic) |
---|
| 275 | { |
---|
| 276 | if (!rpcListPic || !m_isNoOutputPriorPics) return; |
---|
| 277 | |
---|
| 278 | TComList<TComPic*>::iterator iterPic = rpcListPic->begin(); |
---|
| 279 | |
---|
| 280 | while (iterPic != rpcListPic->end()) |
---|
| 281 | { |
---|
| 282 | TComPic*& pcPicTmp = *(iterPic++); |
---|
| 283 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
| 284 | { |
---|
| 285 | pcPicTmp->setOutputMark(false); |
---|
[976] | 286 | #if H_MV |
---|
[964] | 287 | pcPicTmp->setPicOutputFlag(false); |
---|
| 288 | #endif |
---|
| 289 | } |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | #endif |
---|
| 293 | |
---|
[56] | 294 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
[2] | 295 | { |
---|
[56] | 296 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 297 | TComSlice cFillSlice; |
---|
| 298 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 299 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 300 | cFillSlice.initSlice(); |
---|
| 301 | TComPic *cFillPic; |
---|
| 302 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
| 303 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 304 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 305 | cFillPic->getSlice(0)->initSlice(); |
---|
| 306 | |
---|
| 307 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 308 | Int closestPoc = 1000000; |
---|
| 309 | while ( iterPic != m_cListPic.end()) |
---|
[2] | 310 | { |
---|
[56] | 311 | TComPic * rpcPic = *(iterPic++); |
---|
| 312 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
[2] | 313 | { |
---|
[56] | 314 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | iterPic = m_cListPic.begin(); |
---|
| 318 | while ( iterPic != m_cListPic.end()) |
---|
| 319 | { |
---|
| 320 | TComPic *rpcPic = *(iterPic++); |
---|
| 321 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 322 | { |
---|
| 323 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 324 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
[2] | 325 | break; |
---|
| 326 | } |
---|
| 327 | } |
---|
[56] | 328 | cFillPic->setCurrSliceIdx(0); |
---|
| 329 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
[2] | 330 | { |
---|
[56] | 331 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
[2] | 332 | } |
---|
[56] | 333 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 334 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
| 335 | cFillPic->setReconMark(true); |
---|
| 336 | cFillPic->setOutputMark(true); |
---|
| 337 | if(m_pocRandomAccess == MAX_INT) |
---|
| 338 | { |
---|
| 339 | m_pocRandomAccess = iLostPoc; |
---|
| 340 | } |
---|
[2] | 341 | } |
---|
| 342 | |
---|
[56] | 343 | |
---|
| 344 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 345 | { |
---|
[56] | 346 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
[608] | 347 | |
---|
[56] | 348 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 349 | assert (pps != 0); |
---|
| 350 | |
---|
| 351 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
| 352 | assert (sps != 0); |
---|
[608] | 353 | |
---|
[622] | 354 | #if H_MV |
---|
| 355 | TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 356 | assert (vps != 0); |
---|
[964] | 357 | if (!m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) ) |
---|
[622] | 358 | #else |
---|
[608] | 359 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
[622] | 360 | #endif |
---|
[608] | 361 | { |
---|
| 362 | printf ("Parameter set activation failed!"); |
---|
| 363 | assert (0); |
---|
| 364 | } |
---|
| 365 | |
---|
[976] | 366 | #if H_MV |
---|
[964] | 367 | sps->inferSpsMaxDecPicBufferingMinus1( vps, m_targetOptLayerSetIdx, getLayerId(), false ); |
---|
[1066] | 368 | #if !H_MV_HLS10_ADD_LAYERSETS |
---|
[964] | 369 | vps->inferDbpSizeLayerSetZero( sps, false ); |
---|
[1066] | 370 | #endif |
---|
[964] | 371 | // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0 |
---|
| 372 | if ( vps->getVpsNumRepFormatsMinus1() == 0 ) |
---|
| 373 | { |
---|
| 374 | //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0. |
---|
| 375 | assert( sps->getUpdateRepFormatFlag() == false ); |
---|
| 376 | } |
---|
| 377 | sps->checkRpsMaxNumPics( vps, getLayerId() ); |
---|
[1066] | 378 | #if H_MV_HLS10_MULTILAYERSPS |
---|
| 379 | |
---|
| 380 | if( sps->getLayerId() != 0 ) |
---|
| 381 | { |
---|
| 382 | sps->inferSpsMaxSubLayersMinus1( true, vps ); |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | #if H_MV_HLS10_MULTILAYERSPS |
---|
| 386 | // It is a requirement of bitstream conformance that, when the SPS is referred to by |
---|
| 387 | // any current picture that belongs to an independent non-base layer, the value of |
---|
| 388 | // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0. |
---|
| 389 | |
---|
| 390 | if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 ) |
---|
| 391 | { |
---|
| 392 | assert( sps->getMultiLayerExtSpsFlag() == 0 ); |
---|
| 393 | } |
---|
| 394 | #endif |
---|
| 395 | |
---|
| 396 | if( sps->getMultiLayerExtSpsFlag() ) |
---|
| 397 | { |
---|
| 398 | sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true ); |
---|
| 399 | } |
---|
| 400 | #else |
---|
[964] | 401 | if( m_layerId > 0 ) |
---|
| 402 | { |
---|
| 403 | sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true ); |
---|
| 404 | } |
---|
| 405 | #endif |
---|
[1066] | 406 | #endif |
---|
[964] | 407 | |
---|
[608] | 408 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 409 | { |
---|
| 410 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 411 | |
---|
| 412 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
| 413 | { |
---|
| 414 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 415 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 416 | { |
---|
| 417 | TDecSbac* ctx = NULL; |
---|
| 418 | ctx = new TDecSbac; |
---|
| 419 | ctx->init( &m_cBinCABAC ); |
---|
| 420 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | |
---|
[56] | 425 | m_apcSlicePilot->setPPS(pps); |
---|
| 426 | m_apcSlicePilot->setSPS(sps); |
---|
[608] | 427 | #if H_MV |
---|
[622] | 428 | m_apcSlicePilot->setVPS(vps); |
---|
[1066] | 429 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
[738] | 430 | // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
[1066] | 431 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
| 432 | // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
| 433 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
| 434 | #else |
---|
| 435 | // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
[738] | 436 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
| 437 | // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
| 438 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
[1066] | 439 | #endif |
---|
[622] | 440 | sps->inferRepFormat ( vps , m_layerId ); |
---|
| 441 | sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
[1066] | 442 | |
---|
[210] | 443 | #endif |
---|
[56] | 444 | pps->setSPS(sps); |
---|
[608] | 445 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
[56] | 446 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 447 | |
---|
[608] | 448 | g_bitDepthY = sps->getBitDepthY(); |
---|
| 449 | g_bitDepthC = sps->getBitDepthC(); |
---|
| 450 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
| 451 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
| 452 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
| 453 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
| 454 | |
---|
| 455 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
[2] | 456 | { |
---|
[56] | 457 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
[2] | 458 | } |
---|
[56] | 459 | |
---|
[608] | 460 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
[56] | 461 | { |
---|
| 462 | sps->setAMPAcc( i, 0 ); |
---|
| 463 | } |
---|
| 464 | |
---|
[608] | 465 | m_cSAO.destroy(); |
---|
[872] | 466 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
---|
[608] | 467 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
[2] | 468 | } |
---|
[56] | 469 | |
---|
[608] | 470 | #if H_MV |
---|
[738] | 471 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
[608] | 472 | { |
---|
| 473 | assert( nalu.m_layerId == m_layerId ); |
---|
| 474 | #else |
---|
[56] | 475 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
[2] | 476 | { |
---|
[608] | 477 | #endif |
---|
[2] | 478 | TComPic*& pcPic = m_pcPic; |
---|
[56] | 479 | m_apcSlicePilot->initSlice(); |
---|
[2] | 480 | |
---|
[56] | 481 | if (m_bFirstSliceInPicture) |
---|
[2] | 482 | { |
---|
[56] | 483 | m_uiSliceIdx = 0; |
---|
[2] | 484 | } |
---|
[872] | 485 | else |
---|
[56] | 486 | { |
---|
| 487 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 488 | } |
---|
[872] | 489 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
[2] | 490 | |
---|
[56] | 491 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
[608] | 492 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 493 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 494 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 495 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 496 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
| 497 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
| 498 | |
---|
| 499 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
[56] | 500 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[42] | 501 | |
---|
[608] | 502 | #if H_MV |
---|
[622] | 503 | m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); |
---|
[608] | 504 | m_apcSlicePilot->setLayerId( nalu.m_layerId ); |
---|
[964] | 505 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_targetOptLayerSetIdx ); |
---|
| 506 | #endif |
---|
[655] | 507 | // set POC for dependent slices in skipped pictures |
---|
| 508 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
| 509 | { |
---|
| 510 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
| 514 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
| 515 | |
---|
[608] | 516 | #if H_MV |
---|
| 517 | TComVPS* vps = m_apcSlicePilot->getVPS(); |
---|
[622] | 518 | Int layerId = nalu.m_layerId; |
---|
| 519 | setViewId ( vps->getViewId ( layerId ) ); |
---|
| 520 | #endif |
---|
[738] | 521 | |
---|
[964] | 522 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 523 | //For inference of NoOutputOfPriorPicsFlag |
---|
| 524 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
| 525 | { |
---|
| 526 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
| 527 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
| 528 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
| 529 | { |
---|
| 530 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
| 531 | } |
---|
| 532 | //the inference for NoOutputPriorPicsFlag |
---|
| 533 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
| 534 | { |
---|
| 535 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 536 | { |
---|
| 537 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | else |
---|
| 541 | { |
---|
| 542 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 546 | { |
---|
| 547 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
| 548 | } |
---|
| 549 | } |
---|
| 550 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
| 551 | { |
---|
| 552 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
| 553 | m_isNoOutputPriorPics = true; |
---|
| 554 | } |
---|
| 555 | else |
---|
| 556 | { |
---|
| 557 | m_isNoOutputPriorPics = false; |
---|
| 558 | } |
---|
| 559 | |
---|
| 560 | //For inference of PicOutputFlag |
---|
| 561 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 562 | { |
---|
| 563 | if ( m_craNoRaslOutputFlag ) |
---|
| 564 | { |
---|
| 565 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
| 566 | } |
---|
| 567 | } |
---|
| 568 | #endif |
---|
| 569 | |
---|
| 570 | #if FIX_POC_CRA_NORASL_OUTPUT |
---|
| 571 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
| 572 | { |
---|
| 573 | Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
| 574 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
| 575 | } |
---|
| 576 | #endif |
---|
[773] | 577 | #if H_MV |
---|
[738] | 578 | xCeckNoClrasOutput(); |
---|
| 579 | #endif |
---|
[608] | 580 | // Skip pictures due to random access |
---|
| 581 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
[56] | 582 | { |
---|
[655] | 583 | m_prevSliceSkipped = true; |
---|
| 584 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[773] | 585 | #if H_MV |
---|
| 586 | sliceSkippedFlag = true; |
---|
[738] | 587 | #endif |
---|
[608] | 588 | return false; |
---|
[56] | 589 | } |
---|
[608] | 590 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 591 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 592 | { |
---|
[655] | 593 | m_prevSliceSkipped = true; |
---|
| 594 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[773] | 595 | #if H_MV |
---|
| 596 | sliceSkippedFlag = true; |
---|
[738] | 597 | #endif |
---|
[608] | 598 | return false; |
---|
| 599 | } |
---|
| 600 | |
---|
[655] | 601 | // clear previous slice skipped flag |
---|
| 602 | m_prevSliceSkipped = false; |
---|
| 603 | |
---|
[608] | 604 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
[964] | 605 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0)) |
---|
[608] | 606 | { |
---|
| 607 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
[56] | 608 | } |
---|
| 609 | // exit when a new picture is found |
---|
[608] | 610 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
[56] | 611 | { |
---|
| 612 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 613 | { |
---|
| 614 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 615 | return true; |
---|
| 616 | } |
---|
| 617 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 618 | } |
---|
[608] | 619 | #if H_MV |
---|
| 620 | if ( newLayerFlag ) |
---|
| 621 | { |
---|
| 622 | return false; |
---|
| 623 | } |
---|
| 624 | #if ENC_DEC_TRACE |
---|
| 625 | #if H_MV_ENC_DEC_TRAC |
---|
| 626 | // parse remainder of SH |
---|
| 627 | g_disableHLSTrace = false; |
---|
| 628 | #endif |
---|
| 629 | #endif |
---|
| 630 | #endif |
---|
[56] | 631 | // actual decoding starts here |
---|
[622] | 632 | #if H_MV |
---|
| 633 | // This part needs further testing ! |
---|
| 634 | if ( m_apcSlicePilot->getPocResetFlag() ) |
---|
| 635 | { |
---|
| 636 | xResetPocInPicBuffer(); |
---|
| 637 | } |
---|
| 638 | #endif |
---|
[1066] | 639 | |
---|
| 640 | #if I0044_SLICE_TMVP |
---|
| 641 | if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 ) |
---|
| 642 | { |
---|
| 643 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
| 644 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
| 645 | while( iterRefPic != m_cListPic.end() ) |
---|
| 646 | { |
---|
| 647 | TComPic *refPic = *iterRefPic; |
---|
| 648 | if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() ) |
---|
| 649 | { |
---|
| 650 | for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
| 651 | { |
---|
| 652 | |
---|
| 653 | TComSlice *refSlice = refPic->getSlice(i); |
---|
| 654 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
| 655 | } |
---|
| 656 | } |
---|
| 657 | iterRefPic++; |
---|
| 658 | } |
---|
| 659 | } |
---|
| 660 | m_apcSlicePilot->setAvailableForTMVPRefFlag( true ); |
---|
| 661 | #endif |
---|
| 662 | |
---|
[56] | 663 | xActivateParameterSets(); |
---|
| 664 | |
---|
| 665 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 666 | { |
---|
| 667 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 668 | } |
---|
| 669 | m_bFirstSliceInSequence = false; |
---|
[964] | 670 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 671 | m_bFirstSliceInBitstream = false; |
---|
| 672 | #endif |
---|
[56] | 673 | //detect lost reference picture and insert copy of earlier frame. |
---|
[608] | 674 | Int lostPoc; |
---|
| 675 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
[56] | 676 | { |
---|
[608] | 677 | xCreateLostPicture(lostPoc-1); |
---|
[56] | 678 | } |
---|
[2] | 679 | if (m_bFirstSliceInPicture) |
---|
| 680 | { |
---|
[56] | 681 | // Buffer initialize for prediction. |
---|
| 682 | m_cPrediction.initTempBuff(); |
---|
| 683 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
[608] | 684 | #if H_MV |
---|
[622] | 685 | m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
[608] | 686 | #endif |
---|
[56] | 687 | // Get a new picture buffer |
---|
| 688 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
[2] | 689 | |
---|
[655] | 690 | Bool isField = false; |
---|
| 691 | Bool isTff = false; |
---|
| 692 | |
---|
| 693 | if(!m_SEIs.empty()) |
---|
| 694 | { |
---|
| 695 | // Check if any new Picture Timing SEI has arrived |
---|
| 696 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
| 697 | if (pictureTimingSEIs.size()>0) |
---|
| 698 | { |
---|
| 699 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
| 700 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
---|
| 701 | isTff = (pictureTiming->m_picStruct == 1); |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | //Set Field/Frame coding mode |
---|
| 706 | m_pcPic->setField(isField); |
---|
| 707 | m_pcPic->setTopField(isTff); |
---|
| 708 | |
---|
[608] | 709 | // transfer any SEI messages that have been received to the picture |
---|
[56] | 710 | pcPic->setSEIs(m_SEIs); |
---|
[608] | 711 | m_SEIs.clear(); |
---|
[42] | 712 | |
---|
[56] | 713 | // Recursive structure |
---|
| 714 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 715 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 716 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
[42] | 717 | |
---|
[608] | 718 | m_cSliceDecoder.create(); |
---|
| 719 | } |
---|
| 720 | else |
---|
| 721 | { |
---|
| 722 | // Check if any new SEI has arrived |
---|
| 723 | if(!m_SEIs.empty()) |
---|
[56] | 724 | { |
---|
[608] | 725 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 726 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
| 727 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 728 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 729 | deleteSEIs(m_SEIs); |
---|
[56] | 730 | } |
---|
| 731 | } |
---|
[608] | 732 | |
---|
[56] | 733 | // Set picture slice pointer |
---|
| 734 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 735 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
[2] | 736 | |
---|
[56] | 737 | UInt uiCummulativeTileWidth; |
---|
| 738 | UInt uiCummulativeTileHeight; |
---|
| 739 | UInt i, j, p; |
---|
| 740 | |
---|
[608] | 741 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 742 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 743 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
[2] | 744 | |
---|
[608] | 745 | //create the TComTileArray |
---|
| 746 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 747 | |
---|
| 748 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
[56] | 749 | { |
---|
[608] | 750 | //set the width for each tile |
---|
| 751 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[56] | 752 | { |
---|
[608] | 753 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
[2] | 754 | { |
---|
[608] | 755 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 756 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 757 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
[2] | 758 | } |
---|
[608] | 759 | } |
---|
[2] | 760 | |
---|
[608] | 761 | //set the height for each tile |
---|
| 762 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 763 | { |
---|
[608] | 764 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
[2] | 765 | { |
---|
[608] | 766 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 767 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 768 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
[2] | 769 | } |
---|
[56] | 770 | } |
---|
| 771 | } |
---|
| 772 | else |
---|
| 773 | { |
---|
[608] | 774 | //set the width for each tile |
---|
| 775 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
[56] | 776 | { |
---|
[608] | 777 | uiCummulativeTileWidth = 0; |
---|
| 778 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
[2] | 779 | { |
---|
[608] | 780 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 781 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
[2] | 782 | } |
---|
[608] | 783 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 784 | } |
---|
[56] | 785 | |
---|
[608] | 786 | //set the height for each tile |
---|
| 787 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
[56] | 788 | { |
---|
[608] | 789 | uiCummulativeTileHeight = 0; |
---|
| 790 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 791 | { |
---|
| 792 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 793 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
[56] | 794 | } |
---|
[608] | 795 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
[56] | 796 | } |
---|
| 797 | } |
---|
[2] | 798 | |
---|
[56] | 799 | pcPic->getPicSym()->xInitTiles(); |
---|
[2] | 800 | |
---|
[56] | 801 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 802 | UInt uiEncCUAddr; |
---|
| 803 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 804 | { |
---|
| 805 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 806 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 807 | } |
---|
| 808 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 809 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 810 | |
---|
[608] | 811 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
| 812 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
| 813 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
[56] | 814 | if(pcSlice->isNextSlice()) |
---|
| 815 | { |
---|
| 816 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 817 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | if (m_bFirstSliceInPicture) |
---|
| 821 | { |
---|
| 822 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 823 | { |
---|
| 824 | pcPic->clearSliceBuffer(); |
---|
| 825 | } |
---|
| 826 | } |
---|
| 827 | else |
---|
| 828 | { |
---|
| 829 | pcPic->allocateNewSlice(); |
---|
| 830 | } |
---|
| 831 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 832 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 833 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 834 | |
---|
| 835 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 836 | |
---|
[608] | 837 | #if H_MV |
---|
| 838 | pcPic->setLayerId( nalu.m_layerId ); |
---|
| 839 | pcPic->setViewId ( getViewId() ); |
---|
| 840 | #endif |
---|
[56] | 841 | if (bNextSlice) |
---|
| 842 | { |
---|
[655] | 843 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
[608] | 844 | // Set reference list |
---|
| 845 | #if H_MV |
---|
[622] | 846 | std::vector< TComPic* > tempRefPicLists[2]; |
---|
| 847 | std::vector< Bool > usedAsLongTerm [2]; |
---|
| 848 | Int numPocTotalCurr; |
---|
| 849 | |
---|
| 850 | pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr); |
---|
| 851 | pcSlice->setRefPicList ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); |
---|
[77] | 852 | #else |
---|
[608] | 853 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
[21] | 854 | #endif |
---|
| 855 | |
---|
[56] | 856 | // For generalized B |
---|
[1066] | 857 | #if I0044_SLICE_TMVP |
---|
| 858 | if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) |
---|
| 859 | { |
---|
| 860 | TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx()); |
---|
| 861 | |
---|
| 862 | assert ( refPic ); |
---|
| 863 | assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true ); |
---|
| 864 | } |
---|
| 865 | #endif |
---|
| 866 | |
---|
| 867 | // For generalized B |
---|
[56] | 868 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 869 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 870 | { |
---|
| 871 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 872 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
[2] | 873 | |
---|
[56] | 874 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 875 | { |
---|
| 876 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 877 | } |
---|
| 878 | } |
---|
[608] | 879 | if (!pcSlice->isIntra()) |
---|
[56] | 880 | { |
---|
| 881 | Bool bLowDelay = true; |
---|
| 882 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 883 | Int iRefIdx = 0; |
---|
| 884 | |
---|
| 885 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 886 | { |
---|
| 887 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[21] | 888 | { |
---|
[56] | 889 | bLowDelay = false; |
---|
[21] | 890 | } |
---|
[2] | 891 | } |
---|
[608] | 892 | if (pcSlice->isInterB()) |
---|
[56] | 893 | { |
---|
[608] | 894 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
[56] | 895 | { |
---|
[608] | 896 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 897 | { |
---|
| 898 | bLowDelay = false; |
---|
| 899 | } |
---|
| 900 | } |
---|
[56] | 901 | } |
---|
[2] | 902 | |
---|
[56] | 903 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 904 | } |
---|
| 905 | |
---|
| 906 | //--------------- |
---|
[608] | 907 | pcSlice->setRefPOCList(); |
---|
[56] | 908 | } |
---|
| 909 | |
---|
| 910 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 911 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 912 | { |
---|
[608] | 913 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
| 914 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
[56] | 915 | { |
---|
[608] | 916 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
[56] | 917 | } |
---|
[608] | 918 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
| 919 | { |
---|
| 920 | pcSlice->setDefaultScalingList(); |
---|
| 921 | } |
---|
| 922 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
[56] | 923 | m_cTrQuant.setUseScalingList(true); |
---|
| 924 | } |
---|
| 925 | else |
---|
| 926 | { |
---|
| 927 | m_cTrQuant.setFlatScalingList(); |
---|
| 928 | m_cTrQuant.setUseScalingList(false); |
---|
| 929 | } |
---|
[2] | 930 | |
---|
[724] | 931 | |
---|
[56] | 932 | // Decode a picture |
---|
[608] | 933 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
[56] | 934 | m_bFirstSliceInPicture = false; |
---|
| 935 | m_uiSliceIdx++; |
---|
| 936 | |
---|
| 937 | return false; |
---|
| 938 | } |
---|
| 939 | |
---|
[77] | 940 | Void TDecTop::xDecodeVPS() |
---|
| 941 | { |
---|
| 942 | TComVPS* vps = new TComVPS(); |
---|
| 943 | |
---|
| 944 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 945 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
| 946 | } |
---|
[56] | 947 | |
---|
| 948 | Void TDecTop::xDecodeSPS() |
---|
| 949 | { |
---|
| 950 | TComSPS* sps = new TComSPS(); |
---|
[608] | 951 | #if H_MV |
---|
| 952 | sps->setLayerId( getLayerId() ); |
---|
| 953 | #endif |
---|
[56] | 954 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
| 955 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 956 | } |
---|
[2] | 957 | |
---|
[56] | 958 | Void TDecTop::xDecodePPS() |
---|
| 959 | { |
---|
| 960 | TComPPS* pps = new TComPPS(); |
---|
[622] | 961 | #if H_MV |
---|
| 962 | pps->setLayerId( getLayerId() ); |
---|
| 963 | #endif |
---|
[608] | 964 | m_cEntropyDecoder.decodePPS( pps ); |
---|
[56] | 965 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
| 966 | } |
---|
[2] | 967 | |
---|
[608] | 968 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
[56] | 969 | { |
---|
[608] | 970 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 971 | { |
---|
[622] | 972 | #if H_MV |
---|
| 973 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) ); |
---|
| 974 | #else |
---|
[608] | 975 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
[622] | 976 | #endif |
---|
[608] | 977 | } |
---|
| 978 | else |
---|
| 979 | { |
---|
[622] | 980 | #if H_MV |
---|
| 981 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) ); |
---|
| 982 | #else |
---|
[608] | 983 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
[622] | 984 | #endif |
---|
[608] | 985 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 986 | if (activeParamSets.size()>0) |
---|
| 987 | { |
---|
| 988 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 989 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
[964] | 990 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
[622] | 991 | #if H_MV |
---|
[964] | 992 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0], m_layerId )) |
---|
[622] | 993 | #else |
---|
[964] | 994 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] )) |
---|
[622] | 995 | #endif |
---|
[608] | 996 | { |
---|
| 997 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 998 | } |
---|
| 999 | } |
---|
| 1000 | } |
---|
[56] | 1001 | } |
---|
[2] | 1002 | |
---|
[608] | 1003 | #if H_MV |
---|
[738] | 1004 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
| 1005 | #else |
---|
[56] | 1006 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
[608] | 1007 | #endif |
---|
[56] | 1008 | { |
---|
| 1009 | // Initialize entropy decoder |
---|
| 1010 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1011 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
[2] | 1012 | |
---|
[56] | 1013 | switch (nalu.m_nalUnitType) |
---|
| 1014 | { |
---|
[77] | 1015 | case NAL_UNIT_VPS: |
---|
| 1016 | xDecodeVPS(); |
---|
[976] | 1017 | #if H_MV |
---|
[964] | 1018 | m_isLastNALWasEos = false; |
---|
| 1019 | #endif |
---|
[77] | 1020 | return false; |
---|
[608] | 1021 | |
---|
[56] | 1022 | case NAL_UNIT_SPS: |
---|
| 1023 | xDecodeSPS(); |
---|
| 1024 | return false; |
---|
| 1025 | |
---|
| 1026 | case NAL_UNIT_PPS: |
---|
| 1027 | xDecodePPS(); |
---|
| 1028 | return false; |
---|
[608] | 1029 | |
---|
| 1030 | case NAL_UNIT_PREFIX_SEI: |
---|
| 1031 | case NAL_UNIT_SUFFIX_SEI: |
---|
[976] | 1032 | #if H_MV |
---|
[964] | 1033 | if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI ) |
---|
| 1034 | { |
---|
| 1035 | assert( m_isLastNALWasEos == false ); |
---|
| 1036 | } |
---|
| 1037 | #endif |
---|
[608] | 1038 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
[56] | 1039 | return false; |
---|
| 1040 | |
---|
[608] | 1041 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1042 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[872] | 1043 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[608] | 1044 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1045 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1046 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1047 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1048 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1049 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1050 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1051 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
[56] | 1052 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
[608] | 1053 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1054 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1055 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1056 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
[976] | 1057 | #if H_MV |
---|
[964] | 1058 | if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 1059 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 1060 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 1061 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1062 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ) |
---|
| 1063 | { |
---|
| 1064 | assert( m_isLastNALWasEos == false ); |
---|
| 1065 | } |
---|
| 1066 | else |
---|
| 1067 | { |
---|
| 1068 | m_isLastNALWasEos = false; |
---|
| 1069 | } |
---|
[976] | 1070 | |
---|
[738] | 1071 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag ); |
---|
| 1072 | #else |
---|
[56] | 1073 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[608] | 1074 | #endif |
---|
[2] | 1075 | break; |
---|
[872] | 1076 | case NAL_UNIT_EOS: |
---|
[976] | 1077 | #if H_MV |
---|
[964] | 1078 | assert( m_isLastNALWasEos == false ); |
---|
| 1079 | //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything. |
---|
| 1080 | if (nalu.m_layerId > 0) |
---|
| 1081 | { |
---|
| 1082 | printf( "\nThis bitstream has EOS with non-zero layer id.\n" ); |
---|
| 1083 | return false; |
---|
| 1084 | } |
---|
| 1085 | m_isLastNALWasEos = true; |
---|
| 1086 | #endif |
---|
[872] | 1087 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
| 1088 | m_pocCRA = 0; |
---|
| 1089 | m_pocRandomAccess = MAX_INT; |
---|
| 1090 | m_prevPOC = MAX_INT; |
---|
| 1091 | m_bFirstSliceInPicture = true; |
---|
| 1092 | m_bFirstSliceInSequence = true; |
---|
| 1093 | m_prevSliceSkipped = false; |
---|
| 1094 | m_skippedPOC = 0; |
---|
| 1095 | return false; |
---|
| 1096 | |
---|
| 1097 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
| 1098 | // TODO: process AU delimiter |
---|
| 1099 | return false; |
---|
| 1100 | |
---|
| 1101 | case NAL_UNIT_EOB: |
---|
| 1102 | return false; |
---|
| 1103 | |
---|
[964] | 1104 | case NAL_UNIT_FILLER_DATA: |
---|
| 1105 | #if H_MV |
---|
| 1106 | assert( m_isLastNALWasEos == false ); |
---|
| 1107 | #endif |
---|
| 1108 | return false; |
---|
[872] | 1109 | |
---|
| 1110 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
| 1111 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
| 1112 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
| 1113 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
| 1114 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
| 1115 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
| 1116 | |
---|
| 1117 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
| 1118 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
| 1119 | |
---|
| 1120 | case NAL_UNIT_RESERVED_VCL24: |
---|
| 1121 | case NAL_UNIT_RESERVED_VCL25: |
---|
| 1122 | case NAL_UNIT_RESERVED_VCL26: |
---|
| 1123 | case NAL_UNIT_RESERVED_VCL27: |
---|
| 1124 | case NAL_UNIT_RESERVED_VCL28: |
---|
| 1125 | case NAL_UNIT_RESERVED_VCL29: |
---|
| 1126 | case NAL_UNIT_RESERVED_VCL30: |
---|
| 1127 | case NAL_UNIT_RESERVED_VCL31: |
---|
| 1128 | |
---|
| 1129 | case NAL_UNIT_RESERVED_NVCL41: |
---|
| 1130 | case NAL_UNIT_RESERVED_NVCL42: |
---|
| 1131 | case NAL_UNIT_RESERVED_NVCL43: |
---|
| 1132 | case NAL_UNIT_RESERVED_NVCL44: |
---|
| 1133 | case NAL_UNIT_RESERVED_NVCL45: |
---|
| 1134 | case NAL_UNIT_RESERVED_NVCL46: |
---|
| 1135 | case NAL_UNIT_RESERVED_NVCL47: |
---|
| 1136 | case NAL_UNIT_UNSPECIFIED_48: |
---|
| 1137 | case NAL_UNIT_UNSPECIFIED_49: |
---|
| 1138 | case NAL_UNIT_UNSPECIFIED_50: |
---|
| 1139 | case NAL_UNIT_UNSPECIFIED_51: |
---|
| 1140 | case NAL_UNIT_UNSPECIFIED_52: |
---|
| 1141 | case NAL_UNIT_UNSPECIFIED_53: |
---|
| 1142 | case NAL_UNIT_UNSPECIFIED_54: |
---|
| 1143 | case NAL_UNIT_UNSPECIFIED_55: |
---|
| 1144 | case NAL_UNIT_UNSPECIFIED_56: |
---|
| 1145 | case NAL_UNIT_UNSPECIFIED_57: |
---|
| 1146 | case NAL_UNIT_UNSPECIFIED_58: |
---|
| 1147 | case NAL_UNIT_UNSPECIFIED_59: |
---|
| 1148 | case NAL_UNIT_UNSPECIFIED_60: |
---|
| 1149 | case NAL_UNIT_UNSPECIFIED_61: |
---|
| 1150 | case NAL_UNIT_UNSPECIFIED_62: |
---|
| 1151 | case NAL_UNIT_UNSPECIFIED_63: |
---|
[2] | 1152 | default: |
---|
[872] | 1153 | assert (0); |
---|
[2] | 1154 | } |
---|
| 1155 | |
---|
| 1156 | return false; |
---|
| 1157 | } |
---|
| 1158 | |
---|
[608] | 1159 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1160 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1161 | * \returns true if the picture should be skipped |
---|
| 1162 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1163 | * in decoding order and precede it in output order. |
---|
| 1164 | */ |
---|
| 1165 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
[210] | 1166 | { |
---|
[655] | 1167 | if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && |
---|
| 1168 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[608] | 1169 | { |
---|
| 1170 | iPOCLastDisplay++; |
---|
| 1171 | return true; |
---|
| 1172 | } |
---|
| 1173 | return false; |
---|
[210] | 1174 | } |
---|
| 1175 | |
---|
[2] | 1176 | /** Function for checking if picture should be skipped because of random access |
---|
| 1177 | * \param iSkipFrame skip frame counter |
---|
| 1178 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1179 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1180 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1181 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1182 | * It also checks the type of Nal unit type at the random access point. |
---|
[608] | 1183 | * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped. |
---|
[2] | 1184 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[608] | 1185 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1186 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
[2] | 1187 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1188 | */ |
---|
| 1189 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1190 | { |
---|
[56] | 1191 | if (iSkipFrame) |
---|
[2] | 1192 | { |
---|
| 1193 | iSkipFrame--; // decrement the counter |
---|
| 1194 | return true; |
---|
| 1195 | } |
---|
[773] | 1196 | #if H_MV |
---|
[738] | 1197 | else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
| 1198 | #else |
---|
[56] | 1199 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[738] | 1200 | #endif |
---|
[2] | 1201 | { |
---|
[608] | 1202 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1203 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1204 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1205 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
[2] | 1206 | { |
---|
[738] | 1207 | |
---|
[773] | 1208 | #if H_MV |
---|
[738] | 1209 | if ( xAllRefLayersInitilized() ) |
---|
| 1210 | { |
---|
| 1211 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
| 1212 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
| 1213 | } |
---|
| 1214 | else |
---|
| 1215 | { |
---|
| 1216 | return true; |
---|
| 1217 | } |
---|
| 1218 | #else |
---|
[608] | 1219 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1220 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
[738] | 1221 | #endif |
---|
[2] | 1222 | } |
---|
[608] | 1223 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
[2] | 1224 | { |
---|
[773] | 1225 | #if H_MV |
---|
[738] | 1226 | if ( xAllRefLayersInitilized() ) |
---|
| 1227 | { |
---|
| 1228 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
[773] | 1229 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1230 | } |
---|
| 1231 | else |
---|
| 1232 | { |
---|
[738] | 1233 | return true; |
---|
| 1234 | } |
---|
| 1235 | #else |
---|
| 1236 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1237 | #endif |
---|
| 1238 | } |
---|
| 1239 | else |
---|
| 1240 | { |
---|
[773] | 1241 | #if H_MV |
---|
[738] | 1242 | static Bool warningMessage[MAX_NUM_LAYERS]; |
---|
| 1243 | static Bool warningInitFlag = false; |
---|
| 1244 | |
---|
| 1245 | if (!warningInitFlag) |
---|
| 1246 | { |
---|
| 1247 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
| 1248 | { |
---|
| 1249 | warningMessage[i] = true; |
---|
| 1250 | } |
---|
| 1251 | warningInitFlag = true; |
---|
| 1252 | } |
---|
| 1253 | |
---|
| 1254 | if ( warningMessage[getLayerId()] ) |
---|
| 1255 | { |
---|
| 1256 | printf("\nLayer%3d No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); |
---|
| 1257 | warningMessage[m_layerId] = false; |
---|
| 1258 | } |
---|
| 1259 | #else |
---|
[608] | 1260 | static Bool warningMessage = false; |
---|
[56] | 1261 | if(!warningMessage) |
---|
| 1262 | { |
---|
| 1263 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1264 | warningMessage = true; |
---|
| 1265 | } |
---|
[738] | 1266 | #endif |
---|
[56] | 1267 | return true; |
---|
[2] | 1268 | } |
---|
| 1269 | } |
---|
[608] | 1270 | // skip the reordered pictures, if necessary |
---|
| 1271 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[2] | 1272 | { |
---|
| 1273 | iPOCLastDisplay++; |
---|
| 1274 | return true; |
---|
| 1275 | } |
---|
[773] | 1276 | #if H_MV |
---|
[738] | 1277 | return !m_layerInitilizedFlag[ getLayerId() ]; |
---|
| 1278 | #else |
---|
[2] | 1279 | // if we reach here, then the picture is not skipped. |
---|
[56] | 1280 | return false; |
---|
[738] | 1281 | #endif |
---|
[2] | 1282 | } |
---|
[56] | 1283 | |
---|
[608] | 1284 | #if H_MV |
---|
| 1285 | TComPic* TDecTop::getPic( Int poc ) |
---|
[56] | 1286 | { |
---|
[608] | 1287 | xGetPic( m_layerId, poc ); |
---|
| 1288 | TComList<TComPic*>* listPic = getListPic(); |
---|
| 1289 | TComPic* pcPic = NULL; |
---|
| 1290 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
---|
| 1291 | { |
---|
| 1292 | if( (*it)->getPOC() == poc ) |
---|
| 1293 | { |
---|
| 1294 | pcPic = *it ; |
---|
| 1295 | break ; |
---|
| 1296 | } |
---|
| 1297 | } |
---|
| 1298 | return pcPic; |
---|
[56] | 1299 | } |
---|
[2] | 1300 | |
---|
[608] | 1301 | TComPic* TDecTop::xGetPic( Int layerId, Int poc ) |
---|
| 1302 | { |
---|
| 1303 | return m_ivPicLists->getPic( layerId, poc ) ; |
---|
| 1304 | } |
---|
| 1305 | |
---|
[622] | 1306 | Void TDecTop::xResetPocInPicBuffer() |
---|
| 1307 | { |
---|
| 1308 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 1309 | while (iterPic != m_cListPic.end()) |
---|
| 1310 | { |
---|
| 1311 | TComPic* pic = *(iterPic++); |
---|
| 1312 | if ( pic->getReconMark() ) |
---|
| 1313 | { |
---|
| 1314 | for( Int i = 0; i < pic->getNumAllocatedSlice(); i++) |
---|
| 1315 | { |
---|
| 1316 | TComSlice* slice = pic->getSlice( i ); |
---|
| 1317 | slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() ); |
---|
| 1318 | } |
---|
| 1319 | } |
---|
| 1320 | } |
---|
| 1321 | } |
---|
[738] | 1322 | |
---|
[773] | 1323 | #if H_MV |
---|
[738] | 1324 | Void TDecTop::xCeckNoClrasOutput() |
---|
| 1325 | { |
---|
| 1326 | // This part needs further testing! |
---|
| 1327 | if ( getLayerId() == 0 ) |
---|
| 1328 | { |
---|
| 1329 | NalUnitType nut = m_apcSlicePilot->getNalUnitType(); |
---|
| 1330 | |
---|
| 1331 | Bool isBLA = ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
| 1332 | Bool isIDR = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); |
---|
| 1333 | Bool noClrasOutputFlag = isBLA || ( isIDR && m_apcSlicePilot->getCrossLayerBlaFlag() ); |
---|
| 1334 | |
---|
| 1335 | if ( noClrasOutputFlag ) |
---|
| 1336 | { |
---|
| 1337 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
| 1338 | { |
---|
| 1339 | m_layerInitilizedFlag[i] = false; |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | } |
---|
| 1343 | } |
---|
| 1344 | |
---|
| 1345 | Bool TDecTop::xAllRefLayersInitilized() |
---|
| 1346 | { |
---|
| 1347 | Bool allRefLayersInitilizedFlag = true; |
---|
| 1348 | TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); |
---|
| 1349 | for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId() ); i++ ) |
---|
| 1350 | { |
---|
[1066] | 1351 | #if H_MV_HLS10_REF_PRED_LAYERS |
---|
| 1352 | Int refLayerId = vps->getIdDirectRefLayer( m_layerId, i ); |
---|
| 1353 | #else |
---|
[738] | 1354 | Int refLayerId = vps->getRefLayerId( m_layerId, i ); |
---|
[1066] | 1355 | #endif |
---|
[738] | 1356 | allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | return allRefLayersInitilizedFlag; |
---|
| 1360 | } |
---|
[608] | 1361 | #endif |
---|
[738] | 1362 | #endif |
---|
[56] | 1363 | //! \} |
---|