[191] | 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 TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "NALread.h" |
---|
| 39 | #include "TDecTop.h" |
---|
| 40 | |
---|
| 41 | #if SVC_EXTENSION |
---|
| 42 | UInt TDecTop::m_prevPOC = MAX_UINT; |
---|
| 43 | UInt TDecTop::m_uiPrevLayerId = MAX_UINT; |
---|
| 44 | Bool TDecTop::m_bFirstSliceInSequence = true; |
---|
| 45 | #endif |
---|
| 46 | |
---|
| 47 | //! \ingroup TLibDecoder |
---|
| 48 | //! \{ |
---|
| 49 | |
---|
| 50 | TDecTop::TDecTop() |
---|
| 51 | { |
---|
| 52 | m_pcPic = 0; |
---|
| 53 | m_iMaxRefPicNum = 0; |
---|
| 54 | #if ENC_DEC_TRACE |
---|
| 55 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
| 56 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 57 | g_nSymbolCounter = 0; |
---|
| 58 | #endif |
---|
| 59 | m_pocCRA = 0; |
---|
| 60 | m_prevRAPisBLA = false; |
---|
| 61 | m_pocRandomAccess = MAX_INT; |
---|
| 62 | #if !SVC_EXTENSION |
---|
| 63 | m_prevPOC = MAX_INT; |
---|
| 64 | #endif |
---|
| 65 | m_bFirstSliceInPicture = true; |
---|
| 66 | #if !SVC_EXTENSION |
---|
| 67 | m_bFirstSliceInSequence = true; |
---|
| 68 | #endif |
---|
| 69 | #if SVC_EXTENSION |
---|
| 70 | m_layerId = 0; |
---|
| 71 | #if AVC_BASE |
---|
| 72 | m_pBLReconFile = NULL; |
---|
| 73 | #endif |
---|
| 74 | #endif |
---|
| 75 | #if REF_IDX_FRAMEWORK |
---|
| 76 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
| 77 | #endif |
---|
| 78 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
| 79 | m_pBLSyntaxFile = NULL; |
---|
| 80 | #endif |
---|
| 81 | |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | TDecTop::~TDecTop() |
---|
| 85 | { |
---|
| 86 | #if ENC_DEC_TRACE |
---|
| 87 | fclose( g_hTrace ); |
---|
| 88 | #endif |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | Void TDecTop::create() |
---|
| 92 | { |
---|
| 93 | #if SVC_EXTENSION |
---|
| 94 | m_cGopDecoder.create( m_layerId ); |
---|
| 95 | #else |
---|
| 96 | m_cGopDecoder.create(); |
---|
| 97 | #endif |
---|
| 98 | m_apcSlicePilot = new TComSlice; |
---|
| 99 | m_uiSliceIdx = 0; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | Void TDecTop::destroy() |
---|
| 103 | { |
---|
| 104 | m_cGopDecoder.destroy(); |
---|
| 105 | |
---|
| 106 | delete m_apcSlicePilot; |
---|
| 107 | m_apcSlicePilot = NULL; |
---|
| 108 | |
---|
| 109 | m_cSliceDecoder.destroy(); |
---|
| 110 | #if REF_IDX_FRAMEWORK |
---|
| 111 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
| 112 | { |
---|
| 113 | if(m_cIlpPic[i]) |
---|
| 114 | { |
---|
| 115 | m_cIlpPic[i]->destroy(); |
---|
| 116 | delete m_cIlpPic[i]; |
---|
| 117 | m_cIlpPic[i] = NULL; |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | #endif |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | Void TDecTop::init() |
---|
| 124 | { |
---|
| 125 | #if !SVC_EXTENSION |
---|
| 126 | // initialize ROM |
---|
| 127 | initROM(); |
---|
| 128 | #endif |
---|
| 129 | #if SVC_EXTENSION |
---|
| 130 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
| 131 | m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 132 | #else |
---|
| 133 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
| 134 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 135 | #endif |
---|
| 136 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | #if REF_IDX_FRAMEWORK |
---|
| 140 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
| 141 | { |
---|
| 142 | if(m_layerId>0) |
---|
| 143 | { |
---|
| 144 | g_bitDepthY = pcSPS->getBitDepthY(); |
---|
| 145 | g_bitDepthC = pcSPS->getBitDepthC(); |
---|
| 146 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
| 147 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
| 148 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
| 149 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 150 | |
---|
| 151 | Int numReorderPics[MAX_TLAYER]; |
---|
| 152 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
| 153 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 154 | |
---|
| 155 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
| 156 | { |
---|
| 157 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | if (m_cIlpPic[0] == NULL) |
---|
| 161 | { |
---|
| 162 | for (Int j=0; j< 1/*MAX_NUM_REF*/; j++) // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
| 163 | { |
---|
| 164 | |
---|
| 165 | m_cIlpPic[j] = new TComPic; |
---|
| 166 | #if SVC_UPSAMPLING |
---|
| 167 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
| 168 | #else |
---|
| 169 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 170 | #endif |
---|
| 171 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
| 172 | { |
---|
| 173 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | Void TDecTop::setILRPic(TComPic *pcPic) |
---|
| 181 | { |
---|
| 182 | if(m_cIlpPic[0]) |
---|
| 183 | { |
---|
| 184 | m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec()); |
---|
| 185 | m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC()); |
---|
| 186 | m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId |
---|
| 187 | m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false); |
---|
| 188 | m_cIlpPic[0]->getPicYuvRec()->extendPicBorder(); |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | #endif |
---|
| 192 | |
---|
| 193 | Void TDecTop::deletePicBuffer ( ) |
---|
| 194 | { |
---|
| 195 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 196 | Int iSize = Int( m_cListPic.size() ); |
---|
| 197 | |
---|
| 198 | for (Int i = 0; i < iSize; i++ ) |
---|
| 199 | { |
---|
| 200 | TComPic* pcPic = *(iterPic++); |
---|
| 201 | #if SVC_EXTENSION |
---|
| 202 | if( pcPic ) |
---|
| 203 | { |
---|
| 204 | pcPic->destroy(); |
---|
| 205 | |
---|
| 206 | delete pcPic; |
---|
| 207 | pcPic = NULL; |
---|
| 208 | } |
---|
| 209 | #else |
---|
| 210 | pcPic->destroy(); |
---|
| 211 | |
---|
| 212 | delete pcPic; |
---|
| 213 | pcPic = NULL; |
---|
| 214 | #endif |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | m_cSAO.destroy(); |
---|
| 218 | |
---|
| 219 | m_cLoopFilter. destroy(); |
---|
| 220 | |
---|
| 221 | #if !SVC_EXTENSION |
---|
| 222 | // destroy ROM |
---|
| 223 | destroyROM(); |
---|
| 224 | #endif |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
| 228 | { |
---|
| 229 | Int numReorderPics[MAX_TLAYER]; |
---|
| 230 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
| 231 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 232 | |
---|
| 233 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
| 234 | { |
---|
| 235 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | #if L0323_DPB |
---|
| 239 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
| 240 | #else |
---|
| 241 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded |
---|
| 242 | #endif |
---|
| 243 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 244 | { |
---|
| 245 | rpcPic = new TComPic(); |
---|
| 246 | |
---|
| 247 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 248 | if(m_layerId > 0) |
---|
| 249 | { |
---|
| 250 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
| 251 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
| 252 | #else |
---|
| 253 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 254 | #endif |
---|
| 255 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
| 256 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
| 257 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() ) |
---|
| 258 | { |
---|
| 259 | rpcPic->setSpatialEnhLayerFlag( true ); |
---|
| 260 | } |
---|
| 261 | } |
---|
| 262 | #endif |
---|
| 263 | |
---|
| 264 | #if SVC_UPSAMPLING |
---|
| 265 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 266 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 267 | #else |
---|
| 268 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 269 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 270 | #endif |
---|
| 271 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
| 272 | m_cListPic.pushBack( rpcPic ); |
---|
| 273 | |
---|
| 274 | return; |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | Bool bBufferIsAvailable = false; |
---|
| 278 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 279 | while (iterPic != m_cListPic.end()) |
---|
| 280 | { |
---|
| 281 | rpcPic = *(iterPic++); |
---|
| 282 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
| 283 | { |
---|
| 284 | rpcPic->setOutputMark(false); |
---|
| 285 | bBufferIsAvailable = true; |
---|
| 286 | break; |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 290 | { |
---|
| 291 | #if !SVC_EXTENSION |
---|
| 292 | rpcPic->setOutputMark(false); |
---|
| 293 | #endif |
---|
| 294 | rpcPic->setReconMark( false ); |
---|
| 295 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 296 | bBufferIsAvailable = true; |
---|
| 297 | break; |
---|
| 298 | } |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | if ( !bBufferIsAvailable ) |
---|
| 302 | { |
---|
| 303 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 304 | m_iMaxRefPicNum++; |
---|
| 305 | rpcPic = new TComPic(); |
---|
| 306 | m_cListPic.pushBack( rpcPic ); |
---|
| 307 | } |
---|
| 308 | rpcPic->destroy(); |
---|
| 309 | |
---|
| 310 | #if SVC_UPSAMPLING |
---|
| 311 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 312 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 313 | |
---|
| 314 | #else |
---|
| 315 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 316 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 317 | #endif |
---|
| 318 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
| 322 | { |
---|
| 323 | if (!m_pcPic) |
---|
| 324 | { |
---|
| 325 | /* nothing to deblock */ |
---|
| 326 | return; |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | TComPic*& pcPic = m_pcPic; |
---|
| 330 | |
---|
| 331 | // Execute Deblock + Cleanup |
---|
| 332 | |
---|
| 333 | m_cGopDecoder.filterPicture(pcPic); |
---|
| 334 | |
---|
| 335 | #if SYNTAX_OUTPUT |
---|
| 336 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
| 337 | #endif |
---|
| 338 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
| 339 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
| 340 | rpcListPic = &m_cListPic; |
---|
| 341 | m_cCuDecoder.destroy(); |
---|
| 342 | m_bFirstSliceInPicture = true; |
---|
| 343 | |
---|
| 344 | return; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
| 348 | { |
---|
| 349 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 350 | TComSlice cFillSlice; |
---|
| 351 | #if SVC_EXTENSION |
---|
| 352 | cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
| 353 | cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
| 354 | cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
| 355 | cFillSlice.initSlice( m_layerId ); |
---|
| 356 | #else |
---|
| 357 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 358 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 359 | cFillSlice.initSlice(); |
---|
| 360 | #endif |
---|
| 361 | TComPic *cFillPic; |
---|
| 362 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
| 363 | #if SVC_EXTENSION |
---|
| 364 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
| 365 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
| 366 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
| 367 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
| 368 | #else |
---|
| 369 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 370 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 371 | cFillPic->getSlice(0)->initSlice(); |
---|
| 372 | #endif |
---|
| 373 | |
---|
| 374 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 375 | Int closestPoc = 1000000; |
---|
| 376 | while ( iterPic != m_cListPic.end()) |
---|
| 377 | { |
---|
| 378 | TComPic * rpcPic = *(iterPic++); |
---|
| 379 | 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()) |
---|
| 380 | { |
---|
| 381 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | iterPic = m_cListPic.begin(); |
---|
| 385 | while ( iterPic != m_cListPic.end()) |
---|
| 386 | { |
---|
| 387 | TComPic *rpcPic = *(iterPic++); |
---|
| 388 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 389 | { |
---|
| 390 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 391 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
| 392 | break; |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | cFillPic->setCurrSliceIdx(0); |
---|
| 396 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
| 397 | { |
---|
| 398 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
| 399 | } |
---|
| 400 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 401 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
| 402 | cFillPic->setReconMark(true); |
---|
| 403 | cFillPic->setOutputMark(true); |
---|
| 404 | if(m_pocRandomAccess == MAX_INT) |
---|
| 405 | { |
---|
| 406 | m_pocRandomAccess = iLostPoc; |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | Void TDecTop::xActivateParameterSets() |
---|
| 412 | { |
---|
| 413 | #if SVC_EXTENSION |
---|
| 414 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
| 415 | |
---|
| 416 | TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 417 | assert (pps != 0); |
---|
| 418 | |
---|
| 419 | TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId()); |
---|
| 420 | assert (sps != 0); |
---|
| 421 | |
---|
| 422 | if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) ) |
---|
| 423 | #else |
---|
| 424 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 425 | |
---|
| 426 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 427 | assert (pps != 0); |
---|
| 428 | |
---|
| 429 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
| 430 | assert (sps != 0); |
---|
| 431 | |
---|
| 432 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
| 433 | #endif |
---|
| 434 | { |
---|
| 435 | printf ("Parameter set activation failed!"); |
---|
| 436 | assert (0); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 440 | { |
---|
| 441 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 442 | |
---|
| 443 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
| 444 | { |
---|
| 445 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 446 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 447 | { |
---|
| 448 | TDecSbac* ctx = NULL; |
---|
| 449 | ctx = new TDecSbac; |
---|
| 450 | ctx->init( &m_cBinCABAC ); |
---|
| 451 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | m_apcSlicePilot->setPPS(pps); |
---|
| 457 | m_apcSlicePilot->setSPS(sps); |
---|
| 458 | |
---|
| 459 | pps->setSPS(sps); |
---|
| 460 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
| 461 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 462 | |
---|
| 463 | g_bitDepthY = sps->getBitDepthY(); |
---|
| 464 | g_bitDepthC = sps->getBitDepthC(); |
---|
| 465 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
| 466 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
| 467 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
| 468 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
| 469 | |
---|
| 470 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
| 471 | { |
---|
| 472 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
| 476 | { |
---|
| 477 | sps->setAMPAcc( i, 0 ); |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | m_cSAO.destroy(); |
---|
| 481 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
| 482 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | #if SVC_EXTENSION |
---|
| 486 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
| 487 | #else |
---|
| 488 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
| 489 | #endif |
---|
| 490 | { |
---|
| 491 | TComPic*& pcPic = m_pcPic; |
---|
| 492 | #if SVC_EXTENSION |
---|
| 493 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); |
---|
| 494 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
| 495 | #else |
---|
| 496 | m_apcSlicePilot->initSlice(); |
---|
| 497 | #endif |
---|
| 498 | |
---|
| 499 | if (m_bFirstSliceInPicture) |
---|
| 500 | { |
---|
| 501 | m_uiSliceIdx = 0; |
---|
| 502 | } |
---|
| 503 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 504 | if (!m_bFirstSliceInPicture) |
---|
| 505 | { |
---|
| 506 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
| 510 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 511 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 512 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 513 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 514 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
| 515 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
| 516 | |
---|
| 517 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
| 518 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
| 519 | |
---|
| 520 | #if SVC_EXTENSION |
---|
| 521 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); |
---|
| 522 | #else |
---|
| 523 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
| 524 | #endif |
---|
| 525 | |
---|
| 526 | // Skip pictures due to random access |
---|
| 527 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 528 | { |
---|
| 529 | return false; |
---|
| 530 | } |
---|
| 531 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 532 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 533 | { |
---|
| 534 | return false; |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | // exit when a new picture is found |
---|
| 538 | #if SVC_EXTENSION |
---|
| 539 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
| 540 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
| 541 | { |
---|
| 542 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 543 | curLayerId = m_uiPrevLayerId; |
---|
| 544 | m_uiPrevLayerId = m_layerId; |
---|
| 545 | return true; |
---|
| 546 | } |
---|
| 547 | #else |
---|
| 548 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
| 549 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
| 550 | { |
---|
| 551 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
| 552 | } |
---|
| 553 | // exit when a new picture is found |
---|
| 554 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
| 555 | { |
---|
| 556 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 557 | { |
---|
| 558 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 559 | return true; |
---|
| 560 | } |
---|
| 561 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 562 | } |
---|
| 563 | #endif |
---|
| 564 | // actual decoding starts here |
---|
| 565 | xActivateParameterSets(); |
---|
| 566 | |
---|
| 567 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 568 | { |
---|
| 569 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 570 | #if SVC_EXTENSION |
---|
| 571 | curLayerId = m_layerId; |
---|
| 572 | m_uiPrevLayerId = m_layerId; |
---|
| 573 | #endif |
---|
| 574 | } |
---|
| 575 | m_bFirstSliceInSequence = false; |
---|
| 576 | //detect lost reference picture and insert copy of earlier frame. |
---|
| 577 | Int lostPoc; |
---|
| 578 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
| 579 | { |
---|
| 580 | xCreateLostPicture(lostPoc-1); |
---|
| 581 | } |
---|
| 582 | if (m_bFirstSliceInPicture) |
---|
| 583 | { |
---|
| 584 | #if AVC_BASE |
---|
| 585 | if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 586 | { |
---|
| 587 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
| 588 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
| 589 | #if ILP_DECODED_PICTURE |
---|
| 590 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
| 591 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
| 592 | #else |
---|
| 593 | const Window &conf = pBLPic->getConformanceWindow(); |
---|
| 594 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset(); |
---|
| 595 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset(); |
---|
| 596 | #endif |
---|
| 597 | |
---|
| 598 | if( pFile->good() ) |
---|
| 599 | { |
---|
| 600 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
| 601 | |
---|
| 602 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
| 603 | |
---|
| 604 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
| 605 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
| 606 | for( Int i = 0; i < uiHeight; i++ ) |
---|
| 607 | { |
---|
| 608 | for( Int j = 0; j < uiWidth; j++ ) |
---|
| 609 | { |
---|
| 610 | pPel[j] = pFile->get(); |
---|
| 611 | } |
---|
| 612 | pPel += uiStride; |
---|
| 613 | } |
---|
| 614 | |
---|
| 615 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
| 616 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
| 617 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
| 618 | { |
---|
| 619 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
| 620 | { |
---|
| 621 | pPel[j] = pFile->get(); |
---|
| 622 | } |
---|
| 623 | pPel += uiStride; |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
| 627 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
| 628 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
| 629 | { |
---|
| 630 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
| 631 | { |
---|
| 632 | pPel[j] = pFile->get(); |
---|
| 633 | } |
---|
| 634 | pPel += uiStride; |
---|
| 635 | } |
---|
| 636 | } |
---|
| 637 | } |
---|
| 638 | #endif |
---|
| 639 | |
---|
| 640 | // Buffer initialize for prediction. |
---|
| 641 | m_cPrediction.initTempBuff(); |
---|
| 642 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
| 643 | // Get a new picture buffer |
---|
| 644 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
| 645 | |
---|
| 646 | // transfer any SEI messages that have been received to the picture |
---|
| 647 | pcPic->setSEIs(m_SEIs); |
---|
| 648 | m_SEIs.clear(); |
---|
| 649 | |
---|
| 650 | // Recursive structure |
---|
| 651 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 652 | #if SVC_EXTENSION |
---|
| 653 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
| 654 | #else |
---|
| 655 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 656 | #endif |
---|
| 657 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
| 658 | |
---|
| 659 | m_cSliceDecoder.create(); |
---|
| 660 | } |
---|
| 661 | else |
---|
| 662 | { |
---|
| 663 | // Check if any new SEI has arrived |
---|
| 664 | if(!m_SEIs.empty()) |
---|
| 665 | { |
---|
| 666 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 667 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
| 668 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 669 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 670 | deleteSEIs(m_SEIs); |
---|
| 671 | } |
---|
| 672 | } |
---|
| 673 | |
---|
| 674 | // Set picture slice pointer |
---|
| 675 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 676 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
| 677 | |
---|
| 678 | UInt uiCummulativeTileWidth; |
---|
| 679 | UInt uiCummulativeTileHeight; |
---|
| 680 | UInt i, j, p; |
---|
| 681 | |
---|
| 682 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 683 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 684 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
| 685 | |
---|
| 686 | //create the TComTileArray |
---|
| 687 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 688 | |
---|
| 689 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
| 690 | { |
---|
| 691 | //set the width for each tile |
---|
| 692 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
| 693 | { |
---|
| 694 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 695 | { |
---|
| 696 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 697 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 698 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 699 | } |
---|
| 700 | } |
---|
| 701 | |
---|
| 702 | //set the height for each tile |
---|
| 703 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
| 704 | { |
---|
| 705 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
| 706 | { |
---|
| 707 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 708 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 709 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | else |
---|
| 714 | { |
---|
| 715 | //set the width for each tile |
---|
| 716 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
| 717 | { |
---|
| 718 | uiCummulativeTileWidth = 0; |
---|
| 719 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
| 720 | { |
---|
| 721 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 722 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
| 723 | } |
---|
| 724 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | //set the height for each tile |
---|
| 728 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
| 729 | { |
---|
| 730 | uiCummulativeTileHeight = 0; |
---|
| 731 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 732 | { |
---|
| 733 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 734 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
| 735 | } |
---|
| 736 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
| 737 | } |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | pcPic->getPicSym()->xInitTiles(); |
---|
| 741 | |
---|
| 742 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 743 | UInt uiEncCUAddr; |
---|
| 744 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 745 | { |
---|
| 746 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 747 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 748 | } |
---|
| 749 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 750 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 751 | |
---|
| 752 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
| 753 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
| 754 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
| 755 | if(pcSlice->isNextSlice()) |
---|
| 756 | { |
---|
| 757 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 758 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 759 | } |
---|
| 760 | |
---|
| 761 | if (m_bFirstSliceInPicture) |
---|
| 762 | { |
---|
| 763 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 764 | { |
---|
| 765 | pcPic->clearSliceBuffer(); |
---|
| 766 | } |
---|
| 767 | } |
---|
| 768 | else |
---|
| 769 | { |
---|
| 770 | pcPic->allocateNewSlice(); |
---|
| 771 | } |
---|
| 772 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 773 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 774 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 775 | |
---|
| 776 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 777 | |
---|
| 778 | #if SVC_EXTENSION |
---|
| 779 | pcPic->setLayerId(nalu.m_layerId); |
---|
| 780 | pcSlice->setLayerId(nalu.m_layerId); |
---|
| 781 | #endif |
---|
| 782 | |
---|
| 783 | if (bNextSlice) |
---|
| 784 | { |
---|
| 785 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic ); |
---|
| 786 | // Set reference list |
---|
| 787 | #if REF_IDX_FRAMEWORK |
---|
| 788 | if (m_layerId == 0) |
---|
| 789 | #endif |
---|
| 790 | #if FIX1071 |
---|
| 791 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
| 792 | #else |
---|
| 793 | pcSlice->setRefPicList( m_cListPic ); |
---|
| 794 | #endif |
---|
| 795 | |
---|
| 796 | #if SVC_EXTENSION |
---|
| 797 | if(m_layerId > 0) |
---|
| 798 | { |
---|
| 799 | #if AVC_BASE |
---|
| 800 | if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
| 801 | { |
---|
| 802 | pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
| 803 | #if AVC_SYNTAX |
---|
| 804 | TComPic* pBLPic = pcSlice->getBaseColPic(); |
---|
| 805 | if( pcSlice->getPOC() == 0 ) |
---|
| 806 | { |
---|
| 807 | // initialize partition order. |
---|
| 808 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 809 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
| 810 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
| 811 | } |
---|
| 812 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
| 813 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
| 814 | #endif |
---|
| 815 | } |
---|
| 816 | else |
---|
| 817 | { |
---|
| 818 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
| 819 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
| 820 | #else |
---|
| 821 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 822 | #endif |
---|
| 823 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
| 824 | pcSlice->setBaseColPic ( *cListPic, m_layerId ); |
---|
| 825 | } |
---|
| 826 | #else |
---|
| 827 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
| 828 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId ); |
---|
| 829 | #else |
---|
| 830 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 831 | #endif |
---|
| 832 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
| 833 | pcSlice->setBaseColPic ( *cListPic, m_layerId ); |
---|
| 834 | #endif |
---|
| 835 | #if SVC_UPSAMPLING |
---|
| 836 | if ( pcPic->isSpatialEnhLayer()) |
---|
| 837 | { |
---|
| 838 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 839 | m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() ); |
---|
| 840 | #else |
---|
| 841 | m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() ); |
---|
| 842 | #endif |
---|
| 843 | } |
---|
| 844 | else |
---|
| 845 | { |
---|
| 846 | pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() ); |
---|
| 847 | } |
---|
| 848 | pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() ); |
---|
| 849 | #endif |
---|
| 850 | } |
---|
| 851 | |
---|
| 852 | #if REF_IDX_FRAMEWORK |
---|
| 853 | if(m_layerId > 0) |
---|
| 854 | { |
---|
| 855 | setILRPic(pcPic); |
---|
| 856 | #if REF_IDX_MFM |
---|
| 857 | if( pcSlice->getSPS()->getMFMEnabledFlag() ) |
---|
| 858 | { |
---|
| 859 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
| 860 | } |
---|
| 861 | #endif |
---|
| 862 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
| 863 | } |
---|
| 864 | #endif |
---|
| 865 | |
---|
| 866 | #endif //SVC_EXTENSION |
---|
| 867 | |
---|
| 868 | // For generalized B |
---|
| 869 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 870 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 871 | { |
---|
| 872 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 873 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
| 874 | |
---|
| 875 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 876 | { |
---|
| 877 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 878 | } |
---|
| 879 | } |
---|
| 880 | if (!pcSlice->isIntra()) |
---|
| 881 | { |
---|
| 882 | Bool bLowDelay = true; |
---|
| 883 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 884 | Int iRefIdx = 0; |
---|
| 885 | |
---|
| 886 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 887 | { |
---|
| 888 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 889 | { |
---|
| 890 | bLowDelay = false; |
---|
| 891 | } |
---|
| 892 | } |
---|
| 893 | if (pcSlice->isInterB()) |
---|
| 894 | { |
---|
| 895 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
| 896 | { |
---|
| 897 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 898 | { |
---|
| 899 | bLowDelay = false; |
---|
| 900 | } |
---|
| 901 | } |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | //--------------- |
---|
| 908 | pcSlice->setRefPOCList(); |
---|
| 909 | #if !L0034_COMBINED_LIST_CLEANUP |
---|
| 910 | pcSlice->setNoBackPredFlag( false ); |
---|
| 911 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 912 | { |
---|
| 913 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
| 914 | { |
---|
| 915 | pcSlice->setNoBackPredFlag( true ); |
---|
| 916 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
| 917 | { |
---|
| 918 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
| 919 | { |
---|
| 920 | pcSlice->setNoBackPredFlag( false ); |
---|
| 921 | break; |
---|
| 922 | } |
---|
| 923 | } |
---|
| 924 | } |
---|
| 925 | } |
---|
| 926 | #endif |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 930 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 931 | { |
---|
| 932 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
| 933 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
| 934 | { |
---|
| 935 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
| 936 | } |
---|
| 937 | pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip()); |
---|
| 938 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
| 939 | { |
---|
| 940 | pcSlice->setDefaultScalingList(); |
---|
| 941 | } |
---|
| 942 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
| 943 | m_cTrQuant.setUseScalingList(true); |
---|
| 944 | } |
---|
| 945 | else |
---|
| 946 | { |
---|
| 947 | m_cTrQuant.setFlatScalingList(); |
---|
| 948 | m_cTrQuant.setUseScalingList(false); |
---|
| 949 | } |
---|
| 950 | |
---|
[189] | 951 | #if SIMPLIFIED_MV_POS_SCALING |
---|
| 952 | if (m_layerId > 0) |
---|
| 953 | { |
---|
[191] | 954 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 955 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(); |
---|
| 956 | |
---|
| 957 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth(); |
---|
| 958 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight(); |
---|
| 959 | |
---|
| 960 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
| 961 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
[189] | 962 | #else |
---|
[191] | 963 | const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
| 964 | const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 965 | |
---|
| 966 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 967 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 968 | |
---|
| 969 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 970 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
[189] | 971 | #endif |
---|
| 972 | g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
| 973 | g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
| 974 | |
---|
| 975 | g_posScalingFactor[m_layerId][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
| 976 | g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
| 977 | } |
---|
| 978 | #endif |
---|
[191] | 979 | |
---|
| 980 | // Decode a picture |
---|
| 981 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
| 982 | |
---|
| 983 | m_bFirstSliceInPicture = false; |
---|
| 984 | m_uiSliceIdx++; |
---|
| 985 | |
---|
| 986 | return false; |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | Void TDecTop::xDecodeVPS() |
---|
| 990 | { |
---|
| 991 | TComVPS* vps = new TComVPS(); |
---|
| 992 | |
---|
| 993 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 994 | #if SVC_EXTENSION |
---|
| 995 | m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps); |
---|
| 996 | #else |
---|
| 997 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
| 998 | #endif |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | Void TDecTop::xDecodeSPS() |
---|
| 1002 | { |
---|
| 1003 | TComSPS* sps = new TComSPS(); |
---|
| 1004 | #if SVC_EXTENSION |
---|
| 1005 | sps->setLayerId(m_layerId); |
---|
| 1006 | #endif |
---|
| 1007 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
| 1008 | #if SVC_EXTENSION |
---|
| 1009 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps); |
---|
| 1010 | #else |
---|
| 1011 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1012 | #endif |
---|
| 1013 | #if REF_IDX_FRAMEWORK |
---|
| 1014 | if(m_numLayer>0) |
---|
| 1015 | { |
---|
| 1016 | xInitILRP(sps); |
---|
| 1017 | } |
---|
| 1018 | #endif |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | Void TDecTop::xDecodePPS() |
---|
| 1022 | { |
---|
| 1023 | TComPPS* pps = new TComPPS(); |
---|
| 1024 | m_cEntropyDecoder.decodePPS( pps ); |
---|
| 1025 | #if SVC_EXTENSION |
---|
| 1026 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps ); |
---|
| 1027 | #else |
---|
| 1028 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
| 1029 | #endif |
---|
| 1030 | |
---|
| 1031 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 1032 | { |
---|
| 1033 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 1034 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 1035 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 1036 | { |
---|
| 1037 | TDecSbac* ctx = NULL; |
---|
| 1038 | ctx = new TDecSbac; |
---|
| 1039 | ctx->init( &m_cBinCABAC ); |
---|
| 1040 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 1041 | } |
---|
| 1042 | } |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
| 1046 | { |
---|
| 1047 | #if SVC_EXTENSION |
---|
| 1048 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 1049 | { |
---|
| 1050 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1051 | } |
---|
| 1052 | else |
---|
| 1053 | { |
---|
| 1054 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1055 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 1056 | if (activeParamSets.size()>0) |
---|
| 1057 | { |
---|
| 1058 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 1059 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
| 1060 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
| 1061 | if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
| 1062 | { |
---|
| 1063 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 1064 | } |
---|
| 1065 | } |
---|
| 1066 | } |
---|
| 1067 | #else |
---|
| 1068 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 1069 | { |
---|
| 1070 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1071 | } |
---|
| 1072 | else |
---|
| 1073 | { |
---|
| 1074 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1075 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 1076 | if (activeParamSets.size()>0) |
---|
| 1077 | { |
---|
| 1078 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 1079 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 1080 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
| 1081 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
| 1082 | { |
---|
| 1083 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 1084 | } |
---|
| 1085 | } |
---|
| 1086 | } |
---|
| 1087 | #endif |
---|
| 1088 | } |
---|
| 1089 | |
---|
| 1090 | #if SVC_EXTENSION |
---|
| 1091 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
| 1092 | #else |
---|
| 1093 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1094 | #endif |
---|
| 1095 | { |
---|
| 1096 | // Initialize entropy decoder |
---|
| 1097 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1098 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
| 1099 | |
---|
| 1100 | switch (nalu.m_nalUnitType) |
---|
| 1101 | { |
---|
| 1102 | case NAL_UNIT_VPS: |
---|
| 1103 | xDecodeVPS(); |
---|
| 1104 | #if AVC_BASE |
---|
| 1105 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 1106 | { |
---|
| 1107 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
| 1108 | { |
---|
| 1109 | printf( "Base layer YUV input reading error\n" ); |
---|
| 1110 | exit(EXIT_FAILURE); |
---|
| 1111 | } |
---|
| 1112 | #if AVC_SYNTAX |
---|
| 1113 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
| 1114 | { |
---|
| 1115 | printf( "Base layer syntax input reading error\n" ); |
---|
| 1116 | exit(EXIT_FAILURE); |
---|
| 1117 | } |
---|
| 1118 | #endif |
---|
| 1119 | } |
---|
| 1120 | else |
---|
| 1121 | { |
---|
| 1122 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
| 1123 | cListPic->clear(); |
---|
| 1124 | } |
---|
| 1125 | #endif |
---|
| 1126 | return false; |
---|
| 1127 | |
---|
| 1128 | case NAL_UNIT_SPS: |
---|
| 1129 | xDecodeSPS(); |
---|
| 1130 | #if AVC_BASE |
---|
| 1131 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 1132 | { |
---|
| 1133 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
| 1134 | if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
| 1135 | { |
---|
[200] | 1136 | // using EL SPS with spsId = 1 |
---|
| 1137 | TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1); |
---|
[191] | 1138 | Int numReorderPics[MAX_TLAYER]; |
---|
| 1139 | Window &conformanceWindow = sps->getConformanceWindow(); |
---|
| 1140 | Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 1141 | #if SVC_UPSAMPLING |
---|
| 1142 | #if AVC_SYNTAX |
---|
| 1143 | |
---|
| 1144 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true); |
---|
| 1145 | #else |
---|
| 1146 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
| 1147 | #endif |
---|
| 1148 | #else |
---|
| 1149 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 1150 | #endif |
---|
| 1151 | } |
---|
| 1152 | } |
---|
| 1153 | #endif |
---|
| 1154 | return false; |
---|
| 1155 | |
---|
| 1156 | case NAL_UNIT_PPS: |
---|
| 1157 | xDecodePPS(); |
---|
| 1158 | return false; |
---|
| 1159 | |
---|
| 1160 | case NAL_UNIT_PREFIX_SEI: |
---|
| 1161 | case NAL_UNIT_SUFFIX_SEI: |
---|
| 1162 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
| 1163 | return false; |
---|
| 1164 | |
---|
| 1165 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1166 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
| 1167 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
| 1168 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1169 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1170 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1171 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1172 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1173 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1174 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1175 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
| 1176 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 1177 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1178 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1179 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1180 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 1181 | #if SVC_EXTENSION |
---|
| 1182 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
| 1183 | #else |
---|
| 1184 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
| 1185 | #endif |
---|
| 1186 | break; |
---|
| 1187 | default: |
---|
| 1188 | assert (1); |
---|
| 1189 | } |
---|
| 1190 | |
---|
| 1191 | return false; |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1195 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1196 | * \returns true if the picture should be skipped |
---|
| 1197 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1198 | * in decoding order and precede it in output order. |
---|
| 1199 | */ |
---|
| 1200 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
| 1201 | { |
---|
| 1202 | if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
| 1203 | { |
---|
| 1204 | iPOCLastDisplay++; |
---|
| 1205 | return true; |
---|
| 1206 | } |
---|
| 1207 | return false; |
---|
| 1208 | } |
---|
| 1209 | |
---|
| 1210 | /** Function for checking if picture should be skipped because of random access |
---|
| 1211 | * \param iSkipFrame skip frame counter |
---|
| 1212 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1213 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1214 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1215 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1216 | * It also checks the type of Nal unit type at the random access point. |
---|
| 1217 | * 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. |
---|
| 1218 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
| 1219 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1220 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
| 1221 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1222 | */ |
---|
| 1223 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1224 | { |
---|
| 1225 | if (iSkipFrame) |
---|
| 1226 | { |
---|
| 1227 | iSkipFrame--; // decrement the counter |
---|
| 1228 | return true; |
---|
| 1229 | } |
---|
| 1230 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
| 1231 | { |
---|
| 1232 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1233 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1234 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1235 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
| 1236 | { |
---|
| 1237 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1238 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
| 1239 | } |
---|
| 1240 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
| 1241 | { |
---|
| 1242 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1243 | } |
---|
| 1244 | else |
---|
| 1245 | { |
---|
| 1246 | static Bool warningMessage = false; |
---|
| 1247 | if(!warningMessage) |
---|
| 1248 | { |
---|
| 1249 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1250 | warningMessage = true; |
---|
| 1251 | } |
---|
| 1252 | return true; |
---|
| 1253 | } |
---|
| 1254 | } |
---|
| 1255 | // skip the reordered pictures, if necessary |
---|
| 1256 | 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)) |
---|
| 1257 | { |
---|
| 1258 | iPOCLastDisplay++; |
---|
| 1259 | return true; |
---|
| 1260 | } |
---|
| 1261 | // if we reach here, then the picture is not skipped. |
---|
| 1262 | return false; |
---|
| 1263 | } |
---|
| 1264 | |
---|
| 1265 | #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE |
---|
| 1266 | TDecTop* TDecTop::getRefLayerDec( UInt layerId ) |
---|
| 1267 | { |
---|
| 1268 | TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS(); |
---|
[189] | 1269 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
| 1270 | { |
---|
| 1271 | #if ZERO_NUM_DIRECT_LAYERS |
---|
| 1272 | return (TDecTop *)getLayerDec( 0 ); |
---|
| 1273 | #else |
---|
| 1274 | return NULL; |
---|
| 1275 | #endif |
---|
[191] | 1276 | } |
---|
| 1277 | |
---|
| 1278 | // currently only one reference layer is supported |
---|
| 1279 | assert( vps->getNumDirectRefLayers( m_layerId ) == 1 ); |
---|
| 1280 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1281 | assert( vps->getMaxOneActiveRefLayerFlag() == 1 ); |
---|
| 1282 | #endif |
---|
| 1283 | |
---|
| 1284 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, 0 ) ); |
---|
| 1285 | } |
---|
| 1286 | #endif |
---|
| 1287 | |
---|
| 1288 | //! \} |
---|