[313] | 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 |
---|
[442] | 59 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
[313] | 60 | m_pocCRA = 0; |
---|
| 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 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
| 75 | #endif |
---|
| 76 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
| 77 | m_pBLSyntaxFile = NULL; |
---|
| 78 | #endif |
---|
[442] | 79 | m_prevSliceSkipped = false; |
---|
| 80 | m_skippedPOC = 0; |
---|
[313] | 81 | } |
---|
| 82 | |
---|
| 83 | TDecTop::~TDecTop() |
---|
| 84 | { |
---|
| 85 | #if ENC_DEC_TRACE |
---|
| 86 | fclose( g_hTrace ); |
---|
| 87 | #endif |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | Void TDecTop::create() |
---|
| 91 | { |
---|
| 92 | #if SVC_EXTENSION |
---|
| 93 | m_cGopDecoder.create( m_layerId ); |
---|
| 94 | #else |
---|
| 95 | m_cGopDecoder.create(); |
---|
| 96 | #endif |
---|
| 97 | m_apcSlicePilot = new TComSlice; |
---|
| 98 | m_uiSliceIdx = 0; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | Void TDecTop::destroy() |
---|
| 102 | { |
---|
| 103 | m_cGopDecoder.destroy(); |
---|
| 104 | |
---|
| 105 | delete m_apcSlicePilot; |
---|
| 106 | m_apcSlicePilot = NULL; |
---|
| 107 | |
---|
| 108 | m_cSliceDecoder.destroy(); |
---|
[442] | 109 | #if SVC_EXTENSION |
---|
[313] | 110 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
| 111 | { |
---|
| 112 | if(m_cIlpPic[i]) |
---|
| 113 | { |
---|
| 114 | m_cIlpPic[i]->destroy(); |
---|
| 115 | delete m_cIlpPic[i]; |
---|
| 116 | m_cIlpPic[i] = NULL; |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | #endif |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | Void TDecTop::init() |
---|
| 123 | { |
---|
| 124 | #if !SVC_EXTENSION |
---|
| 125 | // initialize ROM |
---|
| 126 | initROM(); |
---|
| 127 | #endif |
---|
| 128 | #if SVC_EXTENSION |
---|
| 129 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
| 130 | m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 131 | #else |
---|
| 132 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
| 133 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 134 | #endif |
---|
| 135 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 136 | } |
---|
| 137 | |
---|
[442] | 138 | #if SVC_EXTENSION |
---|
| 139 | #if !REPN_FORMAT_IN_VPS |
---|
[313] | 140 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
[442] | 141 | #else |
---|
| 142 | Void TDecTop::xInitILRP(TComSlice *slice) |
---|
| 143 | #endif |
---|
[313] | 144 | { |
---|
[442] | 145 | #if REPN_FORMAT_IN_VPS |
---|
| 146 | TComSPS* pcSPS = slice->getSPS(); |
---|
| 147 | Int bitDepthY = slice->getBitDepthY(); |
---|
| 148 | Int bitDepthC = slice->getBitDepthC(); |
---|
| 149 | Int picWidth = slice->getPicWidthInLumaSamples(); |
---|
| 150 | Int picHeight = slice->getPicHeightInLumaSamples(); |
---|
| 151 | #endif |
---|
[313] | 152 | if(m_layerId>0) |
---|
| 153 | { |
---|
[442] | 154 | #if REPN_FORMAT_IN_VPS |
---|
| 155 | g_bitDepthY = bitDepthY; |
---|
| 156 | g_bitDepthC = bitDepthC; |
---|
| 157 | #else |
---|
[313] | 158 | g_bitDepthY = pcSPS->getBitDepthY(); |
---|
| 159 | g_bitDepthC = pcSPS->getBitDepthC(); |
---|
[442] | 160 | #endif |
---|
[313] | 161 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
| 162 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
| 163 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
| 164 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 165 | |
---|
| 166 | Int numReorderPics[MAX_TLAYER]; |
---|
| 167 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
| 168 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 169 | |
---|
| 170 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
| 171 | { |
---|
| 172 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | if (m_cIlpPic[0] == NULL) |
---|
| 176 | { |
---|
| 177 | for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] |
---|
| 178 | { |
---|
| 179 | |
---|
| 180 | m_cIlpPic[j] = new TComPic; |
---|
[442] | 181 | #if REPN_FORMAT_IN_VPS |
---|
[313] | 182 | #if SVC_UPSAMPLING |
---|
[442] | 183 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
| 184 | #else |
---|
| 185 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 186 | #endif |
---|
| 187 | #else |
---|
| 188 | #if SVC_UPSAMPLING |
---|
[313] | 189 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
| 190 | #else |
---|
| 191 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 192 | #endif |
---|
[442] | 193 | #endif |
---|
[313] | 194 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
| 195 | { |
---|
| 196 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | } |
---|
| 202 | |
---|
[442] | 203 | |
---|
| 204 | |
---|
[313] | 205 | Void TDecTop::setILRPic(TComPic *pcPic) |
---|
| 206 | { |
---|
| 207 | for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) |
---|
| 208 | { |
---|
| 209 | Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); |
---|
| 210 | |
---|
| 211 | if(m_cIlpPic[refLayerIdc]) |
---|
| 212 | { |
---|
| 213 | m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec()); |
---|
| 214 | m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC()); |
---|
| 215 | m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId |
---|
| 216 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); |
---|
| 217 | m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
[442] | 218 | for (Int j=0; j<m_cIlpPic[refLayerIdc]->getPicSym()->getNumberOfCUsInFrame(); j++) // set reference CU layerId |
---|
| 219 | { |
---|
| 220 | m_cIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId(m_cIlpPic[refLayerIdc]->getLayerId()); |
---|
| 221 | } |
---|
[313] | 222 | } |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | #endif |
---|
| 226 | |
---|
| 227 | Void TDecTop::deletePicBuffer ( ) |
---|
| 228 | { |
---|
| 229 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 230 | Int iSize = Int( m_cListPic.size() ); |
---|
| 231 | |
---|
| 232 | for (Int i = 0; i < iSize; i++ ) |
---|
| 233 | { |
---|
| 234 | TComPic* pcPic = *(iterPic++); |
---|
| 235 | #if SVC_EXTENSION |
---|
| 236 | if( pcPic ) |
---|
| 237 | { |
---|
| 238 | pcPic->destroy(); |
---|
| 239 | |
---|
| 240 | delete pcPic; |
---|
| 241 | pcPic = NULL; |
---|
| 242 | } |
---|
| 243 | #else |
---|
| 244 | pcPic->destroy(); |
---|
| 245 | |
---|
| 246 | delete pcPic; |
---|
| 247 | pcPic = NULL; |
---|
| 248 | #endif |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | m_cSAO.destroy(); |
---|
| 252 | |
---|
| 253 | m_cLoopFilter. destroy(); |
---|
| 254 | |
---|
| 255 | #if !SVC_EXTENSION |
---|
| 256 | // destroy ROM |
---|
| 257 | destroyROM(); |
---|
| 258 | #endif |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
| 262 | { |
---|
| 263 | Int numReorderPics[MAX_TLAYER]; |
---|
| 264 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
| 265 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 266 | |
---|
| 267 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
| 268 | { |
---|
| 269 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[345] | 273 | |
---|
| 274 | #if SVC_EXTENSION |
---|
| 275 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
---|
| 276 | #endif |
---|
| 277 | |
---|
[313] | 278 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 279 | { |
---|
| 280 | rpcPic = new TComPic(); |
---|
| 281 | |
---|
| 282 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
| 283 | if(m_layerId > 0) |
---|
| 284 | { |
---|
| 285 | for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
| 286 | { |
---|
| 287 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); |
---|
| 288 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
| 289 | |
---|
| 290 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 291 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
---|
| 292 | #else |
---|
| 293 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 294 | #endif |
---|
| 295 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
| 296 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
[442] | 297 | #if REPN_FORMAT_IN_VPS |
---|
| 298 | if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
| 299 | #else |
---|
[313] | 300 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
[442] | 301 | #endif |
---|
[313] | 302 | { |
---|
| 303 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
| 304 | |
---|
| 305 | //only for scalable extension |
---|
[442] | 306 | #if SCALABILITY_MASK_E0104 |
---|
| 307 | assert( pcSlice->getVPS()->getScalabilityMask(2) == true ); |
---|
| 308 | #else |
---|
[313] | 309 | assert( pcSlice->getVPS()->getScalabilityMask(1) == true ); |
---|
[442] | 310 | #endif |
---|
[313] | 311 | } |
---|
| 312 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
[442] | 313 | #if SCALABILITY_MASK_E0104 |
---|
| 314 | if(pcSlice->getVPS()->getScalabilityMask(2)) |
---|
| 315 | #else |
---|
[313] | 316 | if(pcSlice->getVPS()->getScalabilityMask(1)) |
---|
[442] | 317 | #endif |
---|
[313] | 318 | { |
---|
| 319 | pcSlice->setPic(rpcPic); |
---|
| 320 | } |
---|
| 321 | #endif |
---|
| 322 | } |
---|
| 323 | } |
---|
| 324 | #endif |
---|
| 325 | |
---|
[442] | 326 | #if REPN_FORMAT_IN_VPS |
---|
[313] | 327 | #if SVC_UPSAMPLING |
---|
[442] | 328 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 329 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 330 | #else |
---|
| 331 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 332 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 333 | #endif |
---|
| 334 | #else |
---|
| 335 | #if SVC_UPSAMPLING |
---|
[313] | 336 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 337 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 338 | #else |
---|
| 339 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 340 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 341 | #endif |
---|
[442] | 342 | #endif |
---|
| 343 | |
---|
[313] | 344 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
| 345 | m_cListPic.pushBack( rpcPic ); |
---|
| 346 | |
---|
| 347 | return; |
---|
| 348 | } |
---|
| 349 | |
---|
| 350 | Bool bBufferIsAvailable = false; |
---|
| 351 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 352 | while (iterPic != m_cListPic.end()) |
---|
| 353 | { |
---|
| 354 | rpcPic = *(iterPic++); |
---|
| 355 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
| 356 | { |
---|
| 357 | rpcPic->setOutputMark(false); |
---|
| 358 | bBufferIsAvailable = true; |
---|
| 359 | break; |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 363 | { |
---|
| 364 | #if !SVC_EXTENSION |
---|
| 365 | rpcPic->setOutputMark(false); |
---|
| 366 | #endif |
---|
| 367 | rpcPic->setReconMark( false ); |
---|
| 368 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 369 | bBufferIsAvailable = true; |
---|
| 370 | break; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | if ( !bBufferIsAvailable ) |
---|
| 375 | { |
---|
| 376 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 377 | m_iMaxRefPicNum++; |
---|
| 378 | rpcPic = new TComPic(); |
---|
| 379 | m_cListPic.pushBack( rpcPic ); |
---|
| 380 | } |
---|
| 381 | rpcPic->destroy(); |
---|
| 382 | |
---|
[442] | 383 | #if REPN_FORMAT_IN_VPS |
---|
[313] | 384 | #if SVC_UPSAMPLING |
---|
[442] | 385 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 386 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 387 | |
---|
| 388 | #else |
---|
| 389 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 390 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 391 | #endif |
---|
| 392 | #else |
---|
| 393 | #if SVC_UPSAMPLING |
---|
[313] | 394 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 395 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
| 396 | |
---|
| 397 | #else |
---|
| 398 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 399 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 400 | #endif |
---|
[442] | 401 | #endif |
---|
[313] | 402 | rpcPic->getPicSym()->allocSaoParam(&m_cSAO); |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
| 406 | { |
---|
| 407 | if (!m_pcPic) |
---|
| 408 | { |
---|
| 409 | /* nothing to deblock */ |
---|
| 410 | return; |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | TComPic*& pcPic = m_pcPic; |
---|
| 414 | |
---|
| 415 | // Execute Deblock + Cleanup |
---|
| 416 | |
---|
| 417 | m_cGopDecoder.filterPicture(pcPic); |
---|
| 418 | |
---|
| 419 | #if SYNTAX_OUTPUT |
---|
| 420 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
| 421 | #endif |
---|
| 422 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
| 423 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
| 424 | rpcListPic = &m_cListPic; |
---|
| 425 | m_cCuDecoder.destroy(); |
---|
| 426 | m_bFirstSliceInPicture = true; |
---|
| 427 | |
---|
| 428 | return; |
---|
| 429 | } |
---|
| 430 | |
---|
[442] | 431 | #if EARLY_REF_PIC_MARKING |
---|
| 432 | Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) |
---|
| 433 | { |
---|
| 434 | UInt currTid = m_pcPic->getTLayer(); |
---|
| 435 | UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); |
---|
| 436 | UInt latestDecLayerId = m_layerId; |
---|
| 437 | UInt numTargetDecLayers = 0; |
---|
| 438 | Int targetDecLayerIdList[MAX_LAYERS]; |
---|
| 439 | UInt latestDecIdx = 0; |
---|
| 440 | TComSlice* pcSlice = m_pcPic->getSlice(0); |
---|
| 441 | |
---|
| 442 | if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer |
---|
| 443 | { |
---|
| 444 | return; |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture |
---|
| 448 | if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 449 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 450 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 451 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 452 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
| 453 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || |
---|
| 454 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || |
---|
| 455 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) |
---|
| 456 | { |
---|
| 457 | return; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers |
---|
| 461 | { |
---|
| 462 | return; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) |
---|
| 466 | { |
---|
| 467 | if ( latestDecLayerId == (*it) ) |
---|
| 468 | { |
---|
| 469 | latestDecIdx = numTargetDecLayers; |
---|
| 470 | } |
---|
| 471 | targetDecLayerIdList[numTargetDecLayers++] = (*it); |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | Int remainingInterLayerReferencesFlag = 0; |
---|
| 475 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) |
---|
| 476 | { |
---|
| 477 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
| 478 | { |
---|
| 479 | for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) |
---|
| 480 | { |
---|
| 481 | if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) |
---|
| 482 | { |
---|
| 483 | remainingInterLayerReferencesFlag = 1; |
---|
| 484 | } |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | if ( remainingInterLayerReferencesFlag == 0 ) |
---|
| 490 | { |
---|
| 491 | pcSlice->setReferenced(false); |
---|
| 492 | } |
---|
| 493 | } |
---|
| 494 | #endif |
---|
| 495 | |
---|
[313] | 496 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
| 497 | { |
---|
| 498 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 499 | TComSlice cFillSlice; |
---|
| 500 | #if SVC_EXTENSION |
---|
| 501 | cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
| 502 | cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
| 503 | cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
| 504 | cFillSlice.initSlice( m_layerId ); |
---|
| 505 | #else |
---|
| 506 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 507 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 508 | cFillSlice.initSlice(); |
---|
| 509 | #endif |
---|
| 510 | TComPic *cFillPic; |
---|
| 511 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
| 512 | #if SVC_EXTENSION |
---|
| 513 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() ); |
---|
| 514 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() ); |
---|
| 515 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() ); |
---|
| 516 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
| 517 | #else |
---|
| 518 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 519 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 520 | cFillPic->getSlice(0)->initSlice(); |
---|
| 521 | #endif |
---|
| 522 | |
---|
| 523 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 524 | Int closestPoc = 1000000; |
---|
| 525 | while ( iterPic != m_cListPic.end()) |
---|
| 526 | { |
---|
| 527 | TComPic * rpcPic = *(iterPic++); |
---|
| 528 | 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()) |
---|
| 529 | { |
---|
| 530 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | iterPic = m_cListPic.begin(); |
---|
| 534 | while ( iterPic != m_cListPic.end()) |
---|
| 535 | { |
---|
| 536 | TComPic *rpcPic = *(iterPic++); |
---|
| 537 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 538 | { |
---|
| 539 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 540 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
| 541 | break; |
---|
| 542 | } |
---|
| 543 | } |
---|
| 544 | cFillPic->setCurrSliceIdx(0); |
---|
| 545 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
| 546 | { |
---|
| 547 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
| 548 | } |
---|
| 549 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 550 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
| 551 | cFillPic->setReconMark(true); |
---|
| 552 | cFillPic->setOutputMark(true); |
---|
| 553 | if(m_pocRandomAccess == MAX_INT) |
---|
| 554 | { |
---|
| 555 | m_pocRandomAccess = iLostPoc; |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | |
---|
| 560 | Void TDecTop::xActivateParameterSets() |
---|
| 561 | { |
---|
| 562 | #if SVC_EXTENSION |
---|
| 563 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
| 564 | |
---|
| 565 | TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 566 | assert (pps != 0); |
---|
| 567 | |
---|
| 568 | TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId()); |
---|
| 569 | assert (sps != 0); |
---|
| 570 | |
---|
| 571 | if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) ) |
---|
| 572 | #else |
---|
| 573 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 574 | |
---|
| 575 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 576 | assert (pps != 0); |
---|
| 577 | |
---|
| 578 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
| 579 | assert (sps != 0); |
---|
| 580 | |
---|
| 581 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
| 582 | #endif |
---|
| 583 | { |
---|
| 584 | printf ("Parameter set activation failed!"); |
---|
| 585 | assert (0); |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 589 | { |
---|
| 590 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 591 | |
---|
| 592 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
| 593 | { |
---|
| 594 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 595 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 596 | { |
---|
| 597 | TDecSbac* ctx = NULL; |
---|
| 598 | ctx = new TDecSbac; |
---|
| 599 | ctx->init( &m_cBinCABAC ); |
---|
| 600 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 601 | } |
---|
| 602 | } |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | m_apcSlicePilot->setPPS(pps); |
---|
| 606 | m_apcSlicePilot->setSPS(sps); |
---|
| 607 | pps->setSPS(sps); |
---|
[442] | 608 | #if REPN_FORMAT_IN_VPS |
---|
[313] | 609 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
[442] | 610 | #else |
---|
| 611 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
| 612 | #endif |
---|
[313] | 613 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 614 | |
---|
[442] | 615 | #if REPN_FORMAT_IN_VPS |
---|
| 616 | g_bitDepthY = m_apcSlicePilot->getBitDepthY(); |
---|
| 617 | g_bitDepthC = m_apcSlicePilot->getBitDepthC(); |
---|
| 618 | #else |
---|
[313] | 619 | g_bitDepthY = sps->getBitDepthY(); |
---|
| 620 | g_bitDepthC = sps->getBitDepthC(); |
---|
[442] | 621 | #endif |
---|
[313] | 622 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
| 623 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
| 624 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
| 625 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
| 626 | |
---|
| 627 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
| 628 | { |
---|
| 629 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
| 633 | { |
---|
| 634 | sps->setAMPAcc( i, 0 ); |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | m_cSAO.destroy(); |
---|
[442] | 638 | #if REPN_FORMAT_IN_VPS |
---|
| 639 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
| 640 | #else |
---|
[313] | 641 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight() ); |
---|
[442] | 642 | #endif |
---|
[313] | 643 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | #if SVC_EXTENSION |
---|
[442] | 647 | #if POC_RESET_FLAG |
---|
| 648 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
| 649 | #else |
---|
[313] | 650 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
[442] | 651 | #endif |
---|
[313] | 652 | #else |
---|
| 653 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
| 654 | #endif |
---|
| 655 | { |
---|
| 656 | TComPic*& pcPic = m_pcPic; |
---|
| 657 | #if SVC_EXTENSION |
---|
| 658 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) ); |
---|
| 659 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
| 660 | #else |
---|
| 661 | m_apcSlicePilot->initSlice(); |
---|
| 662 | #endif |
---|
| 663 | |
---|
| 664 | if (m_bFirstSliceInPicture) |
---|
| 665 | { |
---|
| 666 | m_uiSliceIdx = 0; |
---|
| 667 | } |
---|
| 668 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 669 | if (!m_bFirstSliceInPicture) |
---|
| 670 | { |
---|
| 671 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 672 | } |
---|
| 673 | |
---|
| 674 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
| 675 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 676 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 677 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 678 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 679 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
| 680 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
| 681 | |
---|
| 682 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
| 683 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
| 684 | |
---|
[442] | 685 | #if SVC_EXTENSION |
---|
[313] | 686 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
| 687 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
---|
| 688 | #endif |
---|
[442] | 689 | #if M0457_COL_PICTURE_SIGNALING |
---|
[313] | 690 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
| 691 | #endif |
---|
| 692 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 693 | m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() ); |
---|
| 694 | #endif |
---|
| 695 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]); |
---|
| 696 | #else |
---|
| 697 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
| 698 | #endif |
---|
| 699 | |
---|
[442] | 700 | // set POC for dependent slices in skipped pictures |
---|
| 701 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
| 702 | { |
---|
| 703 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
| 704 | } |
---|
| 705 | |
---|
| 706 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
| 707 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
| 708 | |
---|
[313] | 709 | // Skip pictures due to random access |
---|
| 710 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 711 | { |
---|
[442] | 712 | m_prevSliceSkipped = true; |
---|
| 713 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[313] | 714 | return false; |
---|
| 715 | } |
---|
| 716 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 717 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 718 | { |
---|
[442] | 719 | m_prevSliceSkipped = true; |
---|
| 720 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[313] | 721 | return false; |
---|
| 722 | } |
---|
| 723 | |
---|
[442] | 724 | // clear previous slice skipped flag |
---|
| 725 | m_prevSliceSkipped = false; |
---|
| 726 | |
---|
[313] | 727 | // exit when a new picture is found |
---|
| 728 | #if SVC_EXTENSION |
---|
| 729 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
| 730 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
| 731 | { |
---|
| 732 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 733 | curLayerId = m_uiPrevLayerId; |
---|
| 734 | m_uiPrevLayerId = m_layerId; |
---|
| 735 | return true; |
---|
| 736 | } |
---|
| 737 | #else |
---|
| 738 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
| 739 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
| 740 | { |
---|
| 741 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
| 742 | } |
---|
| 743 | // exit when a new picture is found |
---|
| 744 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
| 745 | { |
---|
| 746 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 747 | { |
---|
| 748 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 749 | return true; |
---|
| 750 | } |
---|
| 751 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 752 | } |
---|
| 753 | #endif |
---|
| 754 | // actual decoding starts here |
---|
| 755 | xActivateParameterSets(); |
---|
[442] | 756 | #if 0 // N0147_IRAP_ALIGN_FLAG Disabled for now! |
---|
| 757 | //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 |
---|
| 758 | if(!m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
| 759 | { |
---|
| 760 | assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0); |
---|
| 761 | } |
---|
| 762 | //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 |
---|
| 763 | if( m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
| 764 | { |
---|
| 765 | assert( m_apcSlicePilot->getPocResetFlag() == 0); |
---|
| 766 | } |
---|
| 767 | #endif |
---|
[313] | 768 | |
---|
[442] | 769 | #if REPN_FORMAT_IN_VPS |
---|
| 770 | // Initialize ILRP if needed, only for the current layer |
---|
| 771 | // ILRP intialization should go along with activation of parameters sets, |
---|
| 772 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
| 773 | xInitILRP(m_apcSlicePilot); |
---|
| 774 | #endif |
---|
[313] | 775 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 776 | { |
---|
| 777 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 778 | #if SVC_EXTENSION |
---|
| 779 | curLayerId = m_layerId; |
---|
| 780 | m_uiPrevLayerId = m_layerId; |
---|
| 781 | #endif |
---|
| 782 | } |
---|
| 783 | m_bFirstSliceInSequence = false; |
---|
[442] | 784 | #if POC_RESET_FLAG |
---|
| 785 | // This operation would do the following: |
---|
| 786 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
| 787 | // 2. Update the value of m_pocCRA. |
---|
| 788 | // 3. Reset the POC values at the decoder for the current picture to be zero. |
---|
| 789 | // 4. update value of POCLastDisplay |
---|
| 790 | if( m_apcSlicePilot->getPocResetFlag() ) |
---|
| 791 | { |
---|
| 792 | if( m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
| 793 | { |
---|
| 794 | Int pocAdjustValue = m_apcSlicePilot->getPOC(); |
---|
| 795 | |
---|
| 796 | // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre |
---|
| 797 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 798 | |
---|
| 799 | // Iterate through all picture in DPB |
---|
| 800 | while( iterPic != m_cListPic.end() ) |
---|
| 801 | { |
---|
| 802 | TComPic *dpbPic = *iterPic; |
---|
| 803 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
| 804 | // needed for output, are in the same layer, and not the current picture. |
---|
| 805 | if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
---|
| 806 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
---|
| 807 | && ( dpbPic->getReconMark() ) |
---|
| 808 | ) |
---|
| 809 | { |
---|
| 810 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
| 811 | { |
---|
| 812 | |
---|
| 813 | TComSlice *slice = dpbPic->getSlice(i); |
---|
| 814 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
| 815 | slice->setPOC( slice->getPOC() - pocAdjustValue ); |
---|
| 816 | |
---|
| 817 | // Also adjust the POC value stored in the RPS of each such slice |
---|
| 818 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
| 819 | { |
---|
| 820 | rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); |
---|
| 821 | } |
---|
| 822 | // Also adjust the value of refPOC |
---|
| 823 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
| 824 | { |
---|
| 825 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
| 826 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
| 827 | { |
---|
| 828 | slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | iterPic++; |
---|
| 834 | } |
---|
| 835 | // Update the value of pocCRA |
---|
| 836 | m_pocCRA -= pocAdjustValue; |
---|
| 837 | // Update value of POCLastDisplay |
---|
| 838 | iPOCLastDisplay -= pocAdjustValue; |
---|
| 839 | } |
---|
| 840 | // Reset current poc for current slice and RPS |
---|
| 841 | m_apcSlicePilot->setPOC( 0 ); |
---|
| 842 | } |
---|
| 843 | #endif |
---|
| 844 | #if ALIGN_TSA_STSA_PICS |
---|
| 845 | if( m_apcSlicePilot->getLayerId() > 0 ) |
---|
| 846 | { |
---|
| 847 | // Check for TSA alignment |
---|
| 848 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 849 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R |
---|
| 850 | ) |
---|
| 851 | { |
---|
| 852 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
| 853 | { |
---|
| 854 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
| 855 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); |
---|
| 856 | if( refpicLayer ) |
---|
| 857 | { |
---|
| 858 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 859 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R ); // TSA pictures should be aligned among depenedent layers |
---|
| 860 | } |
---|
| 861 | } |
---|
| 862 | } |
---|
| 863 | // Check for STSA alignment |
---|
| 864 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 865 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R |
---|
| 866 | ) |
---|
| 867 | { |
---|
| 868 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
| 869 | { |
---|
| 870 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
| 871 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); // STSA pictures should be aligned among dependent layers |
---|
| 872 | if( refpicLayer ) |
---|
| 873 | |
---|
| 874 | { |
---|
| 875 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 876 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R ); |
---|
| 877 | } |
---|
| 878 | } |
---|
| 879 | } |
---|
| 880 | } |
---|
| 881 | #endif |
---|
[313] | 882 | //detect lost reference picture and insert copy of earlier frame. |
---|
| 883 | Int lostPoc; |
---|
| 884 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
| 885 | { |
---|
| 886 | xCreateLostPicture(lostPoc-1); |
---|
| 887 | } |
---|
| 888 | if (m_bFirstSliceInPicture) |
---|
| 889 | { |
---|
| 890 | #if AVC_BASE |
---|
| 891 | if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 892 | { |
---|
| 893 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
| 894 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
| 895 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
| 896 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
| 897 | |
---|
| 898 | if( pFile->good() ) |
---|
| 899 | { |
---|
| 900 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
| 901 | |
---|
| 902 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
| 903 | |
---|
| 904 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
| 905 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
| 906 | for( Int i = 0; i < uiHeight; i++ ) |
---|
| 907 | { |
---|
| 908 | for( Int j = 0; j < uiWidth; j++ ) |
---|
| 909 | { |
---|
| 910 | pPel[j] = pFile->get(); |
---|
| 911 | } |
---|
| 912 | pPel += uiStride; |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
| 916 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
| 917 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
| 918 | { |
---|
| 919 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
| 920 | { |
---|
| 921 | pPel[j] = pFile->get(); |
---|
| 922 | } |
---|
| 923 | pPel += uiStride; |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
| 927 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
| 928 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
| 929 | { |
---|
| 930 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
| 931 | { |
---|
| 932 | pPel[j] = pFile->get(); |
---|
| 933 | } |
---|
| 934 | pPel += uiStride; |
---|
| 935 | } |
---|
| 936 | } |
---|
| 937 | } |
---|
| 938 | #endif |
---|
| 939 | |
---|
| 940 | // Buffer initialize for prediction. |
---|
| 941 | m_cPrediction.initTempBuff(); |
---|
| 942 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
| 943 | // Get a new picture buffer |
---|
| 944 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
| 945 | |
---|
[442] | 946 | Bool isField = false; |
---|
| 947 | Bool isTff = false; |
---|
| 948 | |
---|
| 949 | if(!m_SEIs.empty()) |
---|
| 950 | { |
---|
| 951 | // Check if any new Picture Timing SEI has arrived |
---|
| 952 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
| 953 | if (pictureTimingSEIs.size()>0) |
---|
| 954 | { |
---|
| 955 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
| 956 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
---|
| 957 | isTff = (pictureTiming->m_picStruct == 1); |
---|
| 958 | } |
---|
| 959 | } |
---|
| 960 | |
---|
| 961 | //Set Field/Frame coding mode |
---|
| 962 | m_pcPic->setField(isField); |
---|
| 963 | m_pcPic->setTopField(isTff); |
---|
| 964 | |
---|
[313] | 965 | // transfer any SEI messages that have been received to the picture |
---|
| 966 | pcPic->setSEIs(m_SEIs); |
---|
| 967 | m_SEIs.clear(); |
---|
| 968 | |
---|
| 969 | // Recursive structure |
---|
| 970 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 971 | #if SVC_EXTENSION |
---|
| 972 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
| 973 | #else |
---|
| 974 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 975 | #endif |
---|
| 976 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
| 977 | |
---|
| 978 | m_cSliceDecoder.create(); |
---|
| 979 | } |
---|
| 980 | else |
---|
| 981 | { |
---|
| 982 | // Check if any new SEI has arrived |
---|
| 983 | if(!m_SEIs.empty()) |
---|
| 984 | { |
---|
| 985 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 986 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
| 987 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 988 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 989 | deleteSEIs(m_SEIs); |
---|
| 990 | } |
---|
| 991 | } |
---|
| 992 | |
---|
| 993 | // Set picture slice pointer |
---|
| 994 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 995 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
| 996 | |
---|
| 997 | UInt uiCummulativeTileWidth; |
---|
| 998 | UInt uiCummulativeTileHeight; |
---|
| 999 | UInt i, j, p; |
---|
| 1000 | |
---|
| 1001 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 1002 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 1003 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
| 1004 | |
---|
| 1005 | //create the TComTileArray |
---|
| 1006 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 1007 | |
---|
| 1008 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
| 1009 | { |
---|
| 1010 | //set the width for each tile |
---|
| 1011 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
| 1012 | { |
---|
| 1013 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 1014 | { |
---|
| 1015 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 1016 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 1017 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 1018 | } |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | //set the height for each tile |
---|
| 1022 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
| 1023 | { |
---|
| 1024 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
| 1025 | { |
---|
| 1026 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 1027 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 1028 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
| 1029 | } |
---|
| 1030 | } |
---|
| 1031 | } |
---|
| 1032 | else |
---|
| 1033 | { |
---|
| 1034 | //set the width for each tile |
---|
| 1035 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
| 1036 | { |
---|
| 1037 | uiCummulativeTileWidth = 0; |
---|
| 1038 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
| 1039 | { |
---|
| 1040 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 1041 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
| 1042 | } |
---|
| 1043 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 1044 | } |
---|
| 1045 | |
---|
| 1046 | //set the height for each tile |
---|
| 1047 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
| 1048 | { |
---|
| 1049 | uiCummulativeTileHeight = 0; |
---|
| 1050 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 1051 | { |
---|
| 1052 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 1053 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
| 1054 | } |
---|
| 1055 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
| 1056 | } |
---|
| 1057 | } |
---|
| 1058 | |
---|
| 1059 | pcPic->getPicSym()->xInitTiles(); |
---|
| 1060 | |
---|
| 1061 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 1062 | UInt uiEncCUAddr; |
---|
| 1063 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 1064 | { |
---|
| 1065 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 1066 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 1067 | } |
---|
| 1068 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 1069 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 1070 | |
---|
| 1071 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
| 1072 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
| 1073 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
| 1074 | if(pcSlice->isNextSlice()) |
---|
| 1075 | { |
---|
| 1076 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 1077 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 1078 | } |
---|
| 1079 | |
---|
| 1080 | if (m_bFirstSliceInPicture) |
---|
| 1081 | { |
---|
| 1082 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 1083 | { |
---|
| 1084 | pcPic->clearSliceBuffer(); |
---|
| 1085 | } |
---|
| 1086 | } |
---|
| 1087 | else |
---|
| 1088 | { |
---|
| 1089 | pcPic->allocateNewSlice(); |
---|
| 1090 | } |
---|
| 1091 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 1092 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 1093 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 1094 | |
---|
| 1095 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 1096 | |
---|
| 1097 | #if SVC_EXTENSION |
---|
| 1098 | pcPic->setLayerId(nalu.m_layerId); |
---|
| 1099 | pcSlice->setLayerId(nalu.m_layerId); |
---|
| 1100 | #endif |
---|
| 1101 | |
---|
| 1102 | if (bNextSlice) |
---|
| 1103 | { |
---|
[442] | 1104 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
[313] | 1105 | // Set reference list |
---|
[442] | 1106 | #if SVC_EXTENSION |
---|
[313] | 1107 | if (m_layerId == 0) |
---|
| 1108 | #endif |
---|
| 1109 | #if FIX1071 |
---|
| 1110 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
| 1111 | #else |
---|
| 1112 | pcSlice->setRefPicList( m_cListPic ); |
---|
| 1113 | #endif |
---|
| 1114 | |
---|
| 1115 | #if SVC_EXTENSION |
---|
| 1116 | if(m_layerId > 0) |
---|
| 1117 | { |
---|
| 1118 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1119 | { |
---|
| 1120 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
| 1121 | #if AVC_BASE |
---|
| 1122 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
| 1123 | { |
---|
| 1124 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
| 1125 | #if AVC_SYNTAX |
---|
| 1126 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
---|
| 1127 | if( pcSlice->getPOC() == 0 ) |
---|
| 1128 | { |
---|
| 1129 | // initialize partition order. |
---|
| 1130 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 1131 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
| 1132 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
| 1133 | } |
---|
| 1134 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
| 1135 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
| 1136 | #endif |
---|
| 1137 | } |
---|
| 1138 | else |
---|
| 1139 | { |
---|
| 1140 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1141 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
| 1142 | #else |
---|
| 1143 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 1144 | #endif |
---|
| 1145 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
| 1146 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
| 1147 | } |
---|
| 1148 | #else |
---|
| 1149 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1150 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
| 1151 | #else |
---|
| 1152 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
| 1153 | #endif |
---|
| 1154 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
| 1155 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
| 1156 | #endif |
---|
| 1157 | |
---|
| 1158 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 1159 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
| 1160 | |
---|
| 1161 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); |
---|
| 1162 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); |
---|
| 1163 | |
---|
| 1164 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
| 1165 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
| 1166 | #else |
---|
| 1167 | const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow(); |
---|
| 1168 | const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); |
---|
| 1169 | |
---|
| 1170 | Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); |
---|
| 1171 | Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); |
---|
| 1172 | |
---|
| 1173 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); |
---|
| 1174 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); |
---|
| 1175 | #endif |
---|
| 1176 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
| 1177 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
| 1178 | |
---|
| 1179 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
| 1180 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
| 1181 | |
---|
| 1182 | #if SVC_UPSAMPLING |
---|
| 1183 | if( pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
| 1184 | { |
---|
| 1185 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 1186 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) ); |
---|
| 1187 | #else |
---|
| 1188 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() ); |
---|
| 1189 | #endif |
---|
| 1190 | } |
---|
| 1191 | else |
---|
| 1192 | { |
---|
| 1193 | pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
| 1194 | } |
---|
| 1195 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
| 1196 | #endif |
---|
| 1197 | } |
---|
| 1198 | } |
---|
| 1199 | |
---|
| 1200 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
| 1201 | { |
---|
| 1202 | setILRPic(pcPic); |
---|
| 1203 | #if REF_IDX_MFM |
---|
| 1204 | #if M0457_COL_PICTURE_SIGNALING |
---|
| 1205 | if( pcSlice->getMFMEnabledFlag() ) |
---|
| 1206 | #else |
---|
| 1207 | if( pcSlice->getSPS()->getMFMEnabledFlag() ) |
---|
| 1208 | #endif |
---|
| 1209 | { |
---|
| 1210 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
[345] | 1211 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 1212 | pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); |
---|
| 1213 | #endif |
---|
| 1214 | } |
---|
| 1215 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
| 1216 | } |
---|
| 1217 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1218 | else if ( m_layerId > 0 ) |
---|
| 1219 | { |
---|
| 1220 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
| 1221 | } |
---|
| 1222 | #endif |
---|
| 1223 | #endif |
---|
| 1224 | |
---|
| 1225 | #endif //SVC_EXTENSION |
---|
| 1226 | |
---|
[442] | 1227 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 1228 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag()) |
---|
| 1229 | { |
---|
| 1230 | for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
| 1231 | { |
---|
| 1232 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
| 1233 | TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); |
---|
| 1234 | if(refpicLayer && pcSlice->isIRAP()) |
---|
| 1235 | { |
---|
| 1236 | assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType()); |
---|
| 1237 | } |
---|
| 1238 | } |
---|
| 1239 | } |
---|
| 1240 | #endif |
---|
| 1241 | |
---|
[313] | 1242 | // For generalized B |
---|
| 1243 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1244 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 1245 | { |
---|
| 1246 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1247 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
| 1248 | |
---|
| 1249 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 1250 | { |
---|
| 1251 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 1252 | } |
---|
| 1253 | } |
---|
| 1254 | if (!pcSlice->isIntra()) |
---|
| 1255 | { |
---|
| 1256 | Bool bLowDelay = true; |
---|
| 1257 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1258 | Int iRefIdx = 0; |
---|
| 1259 | |
---|
| 1260 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 1261 | { |
---|
| 1262 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1263 | { |
---|
| 1264 | bLowDelay = false; |
---|
| 1265 | } |
---|
| 1266 | } |
---|
| 1267 | if (pcSlice->isInterB()) |
---|
| 1268 | { |
---|
| 1269 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
| 1270 | { |
---|
| 1271 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1272 | { |
---|
| 1273 | bLowDelay = false; |
---|
| 1274 | } |
---|
| 1275 | } |
---|
| 1276 | } |
---|
| 1277 | |
---|
| 1278 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 1279 | } |
---|
| 1280 | |
---|
| 1281 | //--------------- |
---|
| 1282 | pcSlice->setRefPOCList(); |
---|
| 1283 | } |
---|
| 1284 | |
---|
| 1285 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 1286 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 1287 | { |
---|
[442] | 1288 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1289 | pcSlice->getSPS()->getScalingList()->setLayerId( m_layerId ); |
---|
| 1290 | #endif |
---|
| 1291 | |
---|
[313] | 1292 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
[442] | 1293 | |
---|
[313] | 1294 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
| 1295 | { |
---|
[442] | 1296 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1297 | pcSlice->getPPS()->getScalingList()->setLayerId( m_layerId ); |
---|
| 1298 | #endif |
---|
| 1299 | |
---|
[313] | 1300 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
| 1301 | } |
---|
| 1302 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
| 1303 | { |
---|
[442] | 1304 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1305 | pcSlice->setDefaultScalingList( m_layerId ); |
---|
| 1306 | #else |
---|
[313] | 1307 | pcSlice->setDefaultScalingList(); |
---|
[442] | 1308 | #endif |
---|
[313] | 1309 | } |
---|
| 1310 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
| 1311 | m_cTrQuant.setUseScalingList(true); |
---|
| 1312 | } |
---|
| 1313 | else |
---|
| 1314 | { |
---|
[442] | 1315 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1316 | m_cTrQuant.setFlatScalingList( m_layerId ); |
---|
| 1317 | #else |
---|
[313] | 1318 | m_cTrQuant.setFlatScalingList(); |
---|
[442] | 1319 | #endif |
---|
[313] | 1320 | m_cTrQuant.setUseScalingList(false); |
---|
| 1321 | } |
---|
| 1322 | |
---|
| 1323 | // Decode a picture |
---|
| 1324 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
| 1325 | |
---|
| 1326 | m_bFirstSliceInPicture = false; |
---|
| 1327 | m_uiSliceIdx++; |
---|
| 1328 | |
---|
| 1329 | return false; |
---|
| 1330 | } |
---|
| 1331 | |
---|
| 1332 | Void TDecTop::xDecodeVPS() |
---|
| 1333 | { |
---|
| 1334 | TComVPS* vps = new TComVPS(); |
---|
| 1335 | |
---|
| 1336 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 1337 | #if SVC_EXTENSION |
---|
| 1338 | m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps); |
---|
| 1339 | #else |
---|
| 1340 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
| 1341 | #endif |
---|
| 1342 | } |
---|
| 1343 | |
---|
| 1344 | Void TDecTop::xDecodeSPS() |
---|
| 1345 | { |
---|
| 1346 | TComSPS* sps = new TComSPS(); |
---|
| 1347 | #if SVC_EXTENSION |
---|
| 1348 | sps->setLayerId(m_layerId); |
---|
| 1349 | #endif |
---|
[442] | 1350 | |
---|
[313] | 1351 | #if SPS_SUB_LAYER_INFO |
---|
| 1352 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder[0] ); |
---|
| 1353 | #else |
---|
| 1354 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
| 1355 | #endif |
---|
| 1356 | #if SVC_EXTENSION |
---|
| 1357 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps); |
---|
| 1358 | #else |
---|
| 1359 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1360 | #endif |
---|
[442] | 1361 | #if SVC_EXTENSION |
---|
| 1362 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
---|
[313] | 1363 | if(m_numLayer>0) |
---|
| 1364 | { |
---|
| 1365 | xInitILRP(sps); |
---|
| 1366 | } |
---|
| 1367 | #endif |
---|
[442] | 1368 | #endif |
---|
[313] | 1369 | } |
---|
| 1370 | |
---|
| 1371 | Void TDecTop::xDecodePPS() |
---|
| 1372 | { |
---|
| 1373 | TComPPS* pps = new TComPPS(); |
---|
[442] | 1374 | |
---|
| 1375 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1376 | pps->setLayerId(m_layerId); |
---|
| 1377 | #endif |
---|
| 1378 | |
---|
[313] | 1379 | m_cEntropyDecoder.decodePPS( pps ); |
---|
| 1380 | #if SVC_EXTENSION |
---|
| 1381 | m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps ); |
---|
| 1382 | #else |
---|
| 1383 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
| 1384 | #endif |
---|
| 1385 | |
---|
| 1386 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 1387 | { |
---|
| 1388 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 1389 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 1390 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 1391 | { |
---|
| 1392 | TDecSbac* ctx = NULL; |
---|
| 1393 | ctx = new TDecSbac; |
---|
| 1394 | ctx->init( &m_cBinCABAC ); |
---|
| 1395 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 1396 | } |
---|
| 1397 | } |
---|
| 1398 | } |
---|
| 1399 | |
---|
| 1400 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
| 1401 | { |
---|
| 1402 | #if SVC_EXTENSION |
---|
| 1403 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 1404 | { |
---|
[442] | 1405 | #if RANDOM_ACCESS_SEI_FIX |
---|
| 1406 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
| 1407 | { |
---|
| 1408 | return; |
---|
| 1409 | } |
---|
| 1410 | #endif |
---|
[313] | 1411 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 1412 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1413 | #else |
---|
| 1414 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1415 | #endif |
---|
| 1416 | } |
---|
| 1417 | else |
---|
| 1418 | { |
---|
| 1419 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 1420 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1421 | #else |
---|
| 1422 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() ); |
---|
| 1423 | #endif |
---|
| 1424 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 1425 | if (activeParamSets.size()>0) |
---|
| 1426 | { |
---|
| 1427 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 1428 | m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS(); |
---|
| 1429 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
| 1430 | if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
| 1431 | { |
---|
| 1432 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 1433 | } |
---|
| 1434 | } |
---|
| 1435 | } |
---|
| 1436 | #else |
---|
| 1437 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 1438 | { |
---|
| 1439 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 1440 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1441 | #else |
---|
| 1442 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1443 | #endif |
---|
| 1444 | } |
---|
| 1445 | else |
---|
| 1446 | { |
---|
| 1447 | #if M0043_LAYERS_PRESENT_SEI |
---|
| 1448 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1449 | #else |
---|
| 1450 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
| 1451 | #endif |
---|
| 1452 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 1453 | if (activeParamSets.size()>0) |
---|
| 1454 | { |
---|
| 1455 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 1456 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 1457 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
| 1458 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
| 1459 | { |
---|
| 1460 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 1461 | } |
---|
| 1462 | } |
---|
| 1463 | } |
---|
| 1464 | #endif |
---|
| 1465 | } |
---|
| 1466 | |
---|
| 1467 | #if SVC_EXTENSION |
---|
| 1468 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
| 1469 | #else |
---|
| 1470 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1471 | #endif |
---|
| 1472 | { |
---|
| 1473 | // Initialize entropy decoder |
---|
| 1474 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1475 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
| 1476 | |
---|
| 1477 | switch (nalu.m_nalUnitType) |
---|
| 1478 | { |
---|
| 1479 | case NAL_UNIT_VPS: |
---|
[442] | 1480 | #if VPS_NUH_LAYER_ID |
---|
| 1481 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
| 1482 | #endif |
---|
[313] | 1483 | xDecodeVPS(); |
---|
| 1484 | #if AVC_BASE |
---|
| 1485 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 1486 | { |
---|
| 1487 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
| 1488 | { |
---|
| 1489 | printf( "Base layer YUV input reading error\n" ); |
---|
| 1490 | exit(EXIT_FAILURE); |
---|
| 1491 | } |
---|
| 1492 | #if AVC_SYNTAX |
---|
| 1493 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
| 1494 | { |
---|
| 1495 | printf( "Base layer syntax input reading error\n" ); |
---|
| 1496 | exit(EXIT_FAILURE); |
---|
| 1497 | } |
---|
| 1498 | #endif |
---|
| 1499 | } |
---|
| 1500 | else |
---|
| 1501 | { |
---|
| 1502 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
| 1503 | cListPic->clear(); |
---|
| 1504 | } |
---|
| 1505 | #endif |
---|
| 1506 | return false; |
---|
| 1507 | |
---|
| 1508 | case NAL_UNIT_SPS: |
---|
| 1509 | xDecodeSPS(); |
---|
| 1510 | #if AVC_BASE |
---|
| 1511 | if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
| 1512 | { |
---|
| 1513 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
| 1514 | if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
| 1515 | { |
---|
| 1516 | // using EL SPS with spsId = 1 |
---|
| 1517 | TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1); |
---|
| 1518 | Int numReorderPics[MAX_TLAYER]; |
---|
| 1519 | Window &conformanceWindow = sps->getConformanceWindow(); |
---|
| 1520 | Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
| 1521 | #if SVC_UPSAMPLING |
---|
| 1522 | #if AVC_SYNTAX |
---|
| 1523 | |
---|
| 1524 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true); |
---|
| 1525 | #else |
---|
| 1526 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
| 1527 | #endif |
---|
| 1528 | #else |
---|
| 1529 | pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
| 1530 | #endif |
---|
| 1531 | } |
---|
| 1532 | } |
---|
| 1533 | #endif |
---|
| 1534 | return false; |
---|
| 1535 | |
---|
| 1536 | case NAL_UNIT_PPS: |
---|
| 1537 | xDecodePPS(); |
---|
| 1538 | return false; |
---|
| 1539 | |
---|
| 1540 | case NAL_UNIT_PREFIX_SEI: |
---|
| 1541 | case NAL_UNIT_SUFFIX_SEI: |
---|
| 1542 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
| 1543 | return false; |
---|
| 1544 | |
---|
| 1545 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1546 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
| 1547 | case NAL_UNIT_CODED_SLICE_TLA_R: |
---|
| 1548 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1549 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1550 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1551 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1552 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1553 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1554 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1555 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
| 1556 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 1557 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1558 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1559 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1560 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 1561 | #if SVC_EXTENSION |
---|
| 1562 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
| 1563 | #else |
---|
| 1564 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
| 1565 | #endif |
---|
| 1566 | break; |
---|
| 1567 | default: |
---|
| 1568 | assert (1); |
---|
| 1569 | } |
---|
| 1570 | |
---|
| 1571 | return false; |
---|
| 1572 | } |
---|
| 1573 | |
---|
| 1574 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1575 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1576 | * \returns true if the picture should be skipped |
---|
| 1577 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1578 | * in decoding order and precede it in output order. |
---|
| 1579 | */ |
---|
| 1580 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
| 1581 | { |
---|
[442] | 1582 | 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) && |
---|
| 1583 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[313] | 1584 | { |
---|
| 1585 | iPOCLastDisplay++; |
---|
| 1586 | return true; |
---|
| 1587 | } |
---|
| 1588 | return false; |
---|
| 1589 | } |
---|
| 1590 | |
---|
| 1591 | /** Function for checking if picture should be skipped because of random access |
---|
| 1592 | * \param iSkipFrame skip frame counter |
---|
| 1593 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1594 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1595 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1596 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1597 | * It also checks the type of Nal unit type at the random access point. |
---|
| 1598 | * 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. |
---|
| 1599 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
| 1600 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1601 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
| 1602 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1603 | */ |
---|
| 1604 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1605 | { |
---|
| 1606 | if (iSkipFrame) |
---|
| 1607 | { |
---|
| 1608 | iSkipFrame--; // decrement the counter |
---|
| 1609 | return true; |
---|
| 1610 | } |
---|
| 1611 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
| 1612 | { |
---|
| 1613 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1614 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1615 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1616 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
| 1617 | { |
---|
| 1618 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1619 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
| 1620 | } |
---|
| 1621 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
| 1622 | { |
---|
| 1623 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1624 | } |
---|
| 1625 | else |
---|
| 1626 | { |
---|
| 1627 | static Bool warningMessage = false; |
---|
| 1628 | if(!warningMessage) |
---|
| 1629 | { |
---|
| 1630 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1631 | warningMessage = true; |
---|
| 1632 | } |
---|
| 1633 | return true; |
---|
| 1634 | } |
---|
| 1635 | } |
---|
| 1636 | // skip the reordered pictures, if necessary |
---|
| 1637 | 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)) |
---|
| 1638 | { |
---|
| 1639 | iPOCLastDisplay++; |
---|
| 1640 | return true; |
---|
| 1641 | } |
---|
| 1642 | // if we reach here, then the picture is not skipped. |
---|
| 1643 | return false; |
---|
| 1644 | } |
---|
| 1645 | |
---|
| 1646 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1647 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
---|
| 1648 | { |
---|
| 1649 | TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS(); |
---|
| 1650 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
| 1651 | { |
---|
| 1652 | return (TDecTop *)getLayerDec( 0 ); |
---|
| 1653 | } |
---|
| 1654 | |
---|
| 1655 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
| 1656 | } |
---|
| 1657 | #endif |
---|
| 1658 | |
---|
| 1659 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
| 1660 | |
---|
| 1661 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
---|
| 1662 | { |
---|
| 1663 | for(UInt layer = 0; layer < m_numLayer; layer++) |
---|
| 1664 | { |
---|
| 1665 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
---|
| 1666 | decTop->setNumSamplePredRefLayers(0); |
---|
| 1667 | decTop->setNumMotionPredRefLayers(0); |
---|
| 1668 | decTop->setNumDirectRefLayers(0); |
---|
| 1669 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
| 1670 | { |
---|
| 1671 | decTop->setSamplePredEnabledFlag(i, false); |
---|
| 1672 | decTop->setMotionPredEnabledFlag(i, false); |
---|
| 1673 | decTop->setSamplePredRefLayerId(i, 0); |
---|
| 1674 | decTop->setMotionPredRefLayerId(i, 0); |
---|
| 1675 | } |
---|
| 1676 | for(Int j = 0; j < layer; j++) |
---|
| 1677 | { |
---|
| 1678 | if (vps->getDirectDependencyFlag(layer, j)) |
---|
| 1679 | { |
---|
| 1680 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
---|
| 1681 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
| 1682 | |
---|
| 1683 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
---|
| 1684 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
---|
| 1685 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
| 1686 | |
---|
| 1687 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
---|
| 1688 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
---|
| 1689 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
| 1690 | } |
---|
| 1691 | } |
---|
| 1692 | } |
---|
| 1693 | for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ ) |
---|
| 1694 | { |
---|
| 1695 | Int iNuhLId = vps->getLayerIdInNuh(i); |
---|
| 1696 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
---|
| 1697 | for ( Int j = 0; j < i; j++ ) |
---|
| 1698 | { |
---|
| 1699 | if (decTop->getMotionPredEnabledFlag(j)) |
---|
| 1700 | { |
---|
| 1701 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
---|
| 1702 | } |
---|
| 1703 | if (decTop->getSamplePredEnabledFlag(j)) |
---|
| 1704 | { |
---|
| 1705 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
---|
| 1706 | } |
---|
| 1707 | } |
---|
| 1708 | } |
---|
| 1709 | } |
---|
| 1710 | |
---|
| 1711 | #endif |
---|
| 1712 | |
---|
[345] | 1713 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 1714 | TComPic* TDecTop::getMotionPredIlp(TComSlice* pcSlice) |
---|
| 1715 | { |
---|
| 1716 | TComPic* ilpPic = NULL; |
---|
| 1717 | Int activeMotionPredReflayerIdx = 0; |
---|
| 1718 | |
---|
| 1719 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1720 | { |
---|
| 1721 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
| 1722 | if( getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) ) |
---|
| 1723 | { |
---|
| 1724 | if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx()) |
---|
| 1725 | { |
---|
| 1726 | ilpPic = m_cIlpPic[refLayerIdc]; |
---|
| 1727 | break; |
---|
| 1728 | } |
---|
| 1729 | else |
---|
| 1730 | { |
---|
| 1731 | activeMotionPredReflayerIdx++; |
---|
| 1732 | } |
---|
| 1733 | } |
---|
| 1734 | } |
---|
| 1735 | |
---|
| 1736 | assert(ilpPic != NULL); |
---|
| 1737 | |
---|
| 1738 | return ilpPic; |
---|
| 1739 | } |
---|
| 1740 | #endif |
---|
| 1741 | |
---|
| 1742 | //! \} |
---|