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