| 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-2014, 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 | #if SETTING_NO_OUT_PIC_PRIOR |
|---|
| 82 | m_bFirstSliceInBitstream = true; |
|---|
| 83 | m_lastPOCNoOutputPriorPics = -1; |
|---|
| 84 | m_craNoRaslOutputFlag = false; |
|---|
| 85 | m_isNoOutputPriorPics = false; |
|---|
| 86 | #endif |
|---|
| 87 | #if NO_CLRAS_OUTPUT_FLAG |
|---|
| 88 | m_noClrasOutputFlag = false; |
|---|
| 89 | m_layerInitializedFlag = false; |
|---|
| 90 | m_firstPicInLayerDecodedFlag = false; |
|---|
| 91 | #endif |
|---|
| 92 | #if RESOLUTION_BASED_DPB |
|---|
| 93 | m_subDpbIdx = -1; |
|---|
| 94 | #endif |
|---|
| 95 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 96 | m_pColorMappedPic = NULL; |
|---|
| 97 | #endif |
|---|
| 98 | |
|---|
| 99 | #if Q0074_SEI_COLOR_MAPPING |
|---|
| 100 | m_ColorMapping = new TDecColorMapping(); |
|---|
| 101 | #endif |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | TDecTop::~TDecTop() |
|---|
| 105 | { |
|---|
| 106 | #if ENC_DEC_TRACE |
|---|
| 107 | fclose( g_hTrace ); |
|---|
| 108 | #endif |
|---|
| 109 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 110 | if(m_pColorMappedPic) |
|---|
| 111 | { |
|---|
| 112 | m_pColorMappedPic->destroy(); |
|---|
| 113 | delete m_pColorMappedPic; |
|---|
| 114 | m_pColorMappedPic = NULL; |
|---|
| 115 | } |
|---|
| 116 | #endif |
|---|
| 117 | #if Q0074_SEI_COLOR_MAPPING |
|---|
| 118 | if ( m_ColorMapping ) delete m_ColorMapping; |
|---|
| 119 | #endif |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | Void TDecTop::create() |
|---|
| 123 | { |
|---|
| 124 | #if SVC_EXTENSION |
|---|
| 125 | m_cGopDecoder.create( m_layerId ); |
|---|
| 126 | #else |
|---|
| 127 | m_cGopDecoder.create(); |
|---|
| 128 | #endif |
|---|
| 129 | m_apcSlicePilot = new TComSlice; |
|---|
| 130 | m_uiSliceIdx = 0; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | Void TDecTop::destroy() |
|---|
| 134 | { |
|---|
| 135 | m_cGopDecoder.destroy(); |
|---|
| 136 | |
|---|
| 137 | delete m_apcSlicePilot; |
|---|
| 138 | m_apcSlicePilot = NULL; |
|---|
| 139 | |
|---|
| 140 | m_cSliceDecoder.destroy(); |
|---|
| 141 | #if SVC_EXTENSION |
|---|
| 142 | for(Int i=0; i<MAX_NUM_REF; i++) |
|---|
| 143 | { |
|---|
| 144 | if(m_cIlpPic[i]) |
|---|
| 145 | { |
|---|
| 146 | m_cIlpPic[i]->destroy(); |
|---|
| 147 | delete m_cIlpPic[i]; |
|---|
| 148 | m_cIlpPic[i] = NULL; |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | #endif |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | Void TDecTop::init() |
|---|
| 155 | { |
|---|
| 156 | #if !SVC_EXTENSION |
|---|
| 157 | // initialize ROM |
|---|
| 158 | initROM(); |
|---|
| 159 | #endif |
|---|
| 160 | #if SVC_EXTENSION |
|---|
| 161 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
|---|
| 162 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() ); |
|---|
| 163 | #else |
|---|
| 164 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
|---|
| 165 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
|---|
| 166 | #endif |
|---|
| 167 | m_cEntropyDecoder.init(&m_cPrediction); |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | #if SVC_EXTENSION |
|---|
| 171 | #if !REPN_FORMAT_IN_VPS |
|---|
| 172 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
|---|
| 173 | #else |
|---|
| 174 | Void TDecTop::xInitILRP(TComSlice *slice) |
|---|
| 175 | #endif |
|---|
| 176 | { |
|---|
| 177 | #if REPN_FORMAT_IN_VPS |
|---|
| 178 | TComSPS* pcSPS = slice->getSPS(); |
|---|
| 179 | Int bitDepthY = slice->getBitDepthY(); |
|---|
| 180 | Int bitDepthC = slice->getBitDepthC(); |
|---|
| 181 | Int picWidth = slice->getPicWidthInLumaSamples(); |
|---|
| 182 | Int picHeight = slice->getPicHeightInLumaSamples(); |
|---|
| 183 | #endif |
|---|
| 184 | if(m_layerId>0) |
|---|
| 185 | { |
|---|
| 186 | #if REPN_FORMAT_IN_VPS |
|---|
| 187 | g_bitDepthY = bitDepthY; |
|---|
| 188 | g_bitDepthC = bitDepthC; |
|---|
| 189 | #else |
|---|
| 190 | g_bitDepthY = pcSPS->getBitDepthY(); |
|---|
| 191 | g_bitDepthC = pcSPS->getBitDepthC(); |
|---|
| 192 | #endif |
|---|
| 193 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
|---|
| 194 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
|---|
| 195 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
|---|
| 196 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
|---|
| 197 | |
|---|
| 198 | Int numReorderPics[MAX_TLAYER]; |
|---|
| 199 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
|---|
| 200 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
|---|
| 201 | |
|---|
| 202 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
|---|
| 203 | { |
|---|
| 204 | #if USE_DPB_SIZE_TABLE |
|---|
| 205 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
|---|
| 206 | { |
|---|
| 207 | assert( this->getLayerId() == 0 ); |
|---|
| 208 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
|---|
| 209 | } |
|---|
| 210 | else |
|---|
| 211 | { |
|---|
| 212 | TComVPS *vps = slice->getVPS(); |
|---|
| 213 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
|---|
| 214 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
|---|
| 215 | } |
|---|
| 216 | #else |
|---|
| 217 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
|---|
| 218 | #endif |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | if (m_cIlpPic[0] == NULL) |
|---|
| 222 | { |
|---|
| 223 | for (Int j=0; j < m_numDirectRefLayers; j++) |
|---|
| 224 | { |
|---|
| 225 | |
|---|
| 226 | m_cIlpPic[j] = new TComPic; |
|---|
| 227 | #if AUXILIARY_PICTURES |
|---|
| 228 | #if REPN_FORMAT_IN_VPS |
|---|
| 229 | #if SVC_UPSAMPLING |
|---|
| 230 | m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
|---|
| 231 | #else |
|---|
| 232 | m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 233 | #endif |
|---|
| 234 | #else |
|---|
| 235 | #if SVC_UPSAMPLING |
|---|
| 236 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
|---|
| 237 | #else |
|---|
| 238 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 239 | #endif |
|---|
| 240 | #endif |
|---|
| 241 | #else |
|---|
| 242 | #if REPN_FORMAT_IN_VPS |
|---|
| 243 | #if SVC_UPSAMPLING |
|---|
| 244 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
|---|
| 245 | #else |
|---|
| 246 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 247 | #endif |
|---|
| 248 | #else |
|---|
| 249 | #if SVC_UPSAMPLING |
|---|
| 250 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
|---|
| 251 | #else |
|---|
| 252 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 253 | #endif |
|---|
| 254 | #endif |
|---|
| 255 | #endif |
|---|
| 256 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
|---|
| 257 | { |
|---|
| 258 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | } |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | #endif |
|---|
| 265 | |
|---|
| 266 | Void TDecTop::deletePicBuffer ( ) |
|---|
| 267 | { |
|---|
| 268 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 269 | Int iSize = Int( m_cListPic.size() ); |
|---|
| 270 | |
|---|
| 271 | for (Int i = 0; i < iSize; i++ ) |
|---|
| 272 | { |
|---|
| 273 | TComPic* pcPic = *(iterPic++); |
|---|
| 274 | #if SVC_EXTENSION |
|---|
| 275 | if( pcPic ) |
|---|
| 276 | { |
|---|
| 277 | pcPic->destroy(); |
|---|
| 278 | |
|---|
| 279 | delete pcPic; |
|---|
| 280 | pcPic = NULL; |
|---|
| 281 | } |
|---|
| 282 | #else |
|---|
| 283 | pcPic->destroy(); |
|---|
| 284 | |
|---|
| 285 | delete pcPic; |
|---|
| 286 | pcPic = NULL; |
|---|
| 287 | #endif |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | m_cSAO.destroy(); |
|---|
| 291 | |
|---|
| 292 | m_cLoopFilter. destroy(); |
|---|
| 293 | |
|---|
| 294 | #if !SVC_EXTENSION |
|---|
| 295 | // destroy ROM |
|---|
| 296 | destroyROM(); |
|---|
| 297 | #endif |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
|---|
| 301 | { |
|---|
| 302 | Int numReorderPics[MAX_TLAYER]; |
|---|
| 303 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
|---|
| 304 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
|---|
| 305 | |
|---|
| 306 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
|---|
| 307 | { |
|---|
| 308 | #if USE_DPB_SIZE_TABLE |
|---|
| 309 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
|---|
| 310 | { |
|---|
| 311 | assert( this->getLayerId() == 0 ); |
|---|
| 312 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
|---|
| 313 | } |
|---|
| 314 | else |
|---|
| 315 | { |
|---|
| 316 | TComVPS *vps = pcSlice->getVPS(); |
|---|
| 317 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
|---|
| 318 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
|---|
| 319 | } |
|---|
| 320 | #else |
|---|
| 321 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
|---|
| 322 | #endif |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | #if USE_DPB_SIZE_TABLE |
|---|
| 326 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
|---|
| 327 | { |
|---|
| 328 | assert( this->getLayerId() == 0 ); |
|---|
| 329 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
|---|
| 330 | } |
|---|
| 331 | else |
|---|
| 332 | { |
|---|
| 333 | #if RESOLUTION_BASED_DPB |
|---|
| 334 | Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
|---|
| 335 | Int layerIdx = pcSlice->getVPS()->findLayerIdxInLayerSet( layerSetIdxForOutputLayerSet, pcSlice->getLayerId() ); assert( layerIdx != -1 ); |
|---|
| 336 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
|---|
| 337 | #else |
|---|
| 338 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
|---|
| 339 | #endif |
|---|
| 340 | } |
|---|
| 341 | #else |
|---|
| 342 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
|---|
| 343 | #endif |
|---|
| 344 | |
|---|
| 345 | #if SVC_EXTENSION |
|---|
| 346 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
|---|
| 347 | #endif |
|---|
| 348 | |
|---|
| 349 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
|---|
| 350 | { |
|---|
| 351 | rpcPic = new TComPic(); |
|---|
| 352 | |
|---|
| 353 | #if SVC_EXTENSION //Temporal solution, should be modified |
|---|
| 354 | if(m_layerId > 0) |
|---|
| 355 | { |
|---|
| 356 | for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) |
|---|
| 357 | { |
|---|
| 358 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 359 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
|---|
| 360 | #else |
|---|
| 361 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); |
|---|
| 362 | #endif |
|---|
| 363 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
|---|
| 364 | |
|---|
| 365 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 366 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
|---|
| 367 | #else |
|---|
| 368 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
|---|
| 369 | #endif |
|---|
| 370 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
|---|
| 371 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
|---|
| 372 | #if REPN_FORMAT_IN_VPS |
|---|
| 373 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
|---|
| 374 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i); |
|---|
| 375 | Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); |
|---|
| 376 | |
|---|
| 377 | if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths |
|---|
| 378 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 379 | || pcSlice->getPPS()->getCGSFlag() > 0 |
|---|
| 380 | #endif |
|---|
| 381 | #if LAYER_CTB |
|---|
| 382 | || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth() |
|---|
| 383 | #endif |
|---|
| 384 | ) |
|---|
| 385 | #else |
|---|
| 386 | if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets ) |
|---|
| 387 | #endif |
|---|
| 388 | #else |
|---|
| 389 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets ) |
|---|
| 390 | #endif |
|---|
| 391 | { |
|---|
| 392 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
|---|
| 393 | |
|---|
| 394 | //only for scalable extension |
|---|
| 395 | #if SCALABILITY_MASK_E0104 |
|---|
| 396 | assert( pcSlice->getVPS()->getScalabilityMask(2) == true ); |
|---|
| 397 | #else |
|---|
| 398 | assert( pcSlice->getVPS()->getScalabilityMask(1) == true ); |
|---|
| 399 | #endif |
|---|
| 400 | } |
|---|
| 401 | } |
|---|
| 402 | } |
|---|
| 403 | #endif |
|---|
| 404 | |
|---|
| 405 | #if AUXILIARY_PICTURES |
|---|
| 406 | #if REPN_FORMAT_IN_VPS |
|---|
| 407 | #if SVC_UPSAMPLING |
|---|
| 408 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 409 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 410 | #else |
|---|
| 411 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 412 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 413 | #endif |
|---|
| 414 | #else |
|---|
| 415 | #if SVC_UPSAMPLING |
|---|
| 416 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 417 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 418 | #else |
|---|
| 419 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 420 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 421 | #endif |
|---|
| 422 | #endif |
|---|
| 423 | #else |
|---|
| 424 | #if REPN_FORMAT_IN_VPS |
|---|
| 425 | #if SVC_UPSAMPLING |
|---|
| 426 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 427 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 428 | #else |
|---|
| 429 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 430 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 431 | #endif |
|---|
| 432 | #else |
|---|
| 433 | #if SVC_UPSAMPLING |
|---|
| 434 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 435 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 436 | #else |
|---|
| 437 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 438 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 439 | #endif |
|---|
| 440 | #endif |
|---|
| 441 | #endif |
|---|
| 442 | m_cListPic.pushBack( rpcPic ); |
|---|
| 443 | |
|---|
| 444 | return; |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | Bool bBufferIsAvailable = false; |
|---|
| 448 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 449 | while (iterPic != m_cListPic.end()) |
|---|
| 450 | { |
|---|
| 451 | rpcPic = *(iterPic++); |
|---|
| 452 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
|---|
| 453 | { |
|---|
| 454 | rpcPic->setOutputMark(false); |
|---|
| 455 | bBufferIsAvailable = true; |
|---|
| 456 | break; |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
|---|
| 460 | { |
|---|
| 461 | #if !SVC_EXTENSION |
|---|
| 462 | rpcPic->setOutputMark(false); |
|---|
| 463 | #endif |
|---|
| 464 | rpcPic->setReconMark( false ); |
|---|
| 465 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
|---|
| 466 | bBufferIsAvailable = true; |
|---|
| 467 | break; |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | if ( !bBufferIsAvailable ) |
|---|
| 472 | { |
|---|
| 473 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
|---|
| 474 | m_iMaxRefPicNum++; |
|---|
| 475 | rpcPic = new TComPic(); |
|---|
| 476 | m_cListPic.pushBack( rpcPic ); |
|---|
| 477 | } |
|---|
| 478 | rpcPic->destroy(); |
|---|
| 479 | |
|---|
| 480 | #if AUXILIARY_PICTURES |
|---|
| 481 | #if REPN_FORMAT_IN_VPS |
|---|
| 482 | #if SVC_UPSAMPLING |
|---|
| 483 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 484 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 485 | |
|---|
| 486 | #else |
|---|
| 487 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 488 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 489 | #endif |
|---|
| 490 | #else |
|---|
| 491 | #if SVC_UPSAMPLING |
|---|
| 492 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 493 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 494 | |
|---|
| 495 | #else |
|---|
| 496 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 497 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 498 | #endif |
|---|
| 499 | #endif |
|---|
| 500 | #else |
|---|
| 501 | #if REPN_FORMAT_IN_VPS |
|---|
| 502 | #if SVC_UPSAMPLING |
|---|
| 503 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 504 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 505 | |
|---|
| 506 | #else |
|---|
| 507 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 508 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 509 | #endif |
|---|
| 510 | #else |
|---|
| 511 | #if SVC_UPSAMPLING |
|---|
| 512 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 513 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
|---|
| 514 | |
|---|
| 515 | #else |
|---|
| 516 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
|---|
| 517 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 518 | #endif |
|---|
| 519 | #endif |
|---|
| 520 | #endif |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
|---|
| 524 | { |
|---|
| 525 | if (!m_pcPic) |
|---|
| 526 | { |
|---|
| 527 | /* nothing to deblock */ |
|---|
| 528 | return; |
|---|
| 529 | } |
|---|
| 530 | |
|---|
| 531 | TComPic*& pcPic = m_pcPic; |
|---|
| 532 | |
|---|
| 533 | // Execute Deblock + Cleanup |
|---|
| 534 | m_cGopDecoder.filterPicture(pcPic); |
|---|
| 535 | |
|---|
| 536 | #if SYNTAX_OUTPUT |
|---|
| 537 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
|---|
| 538 | #endif |
|---|
| 539 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
|---|
| 540 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
|---|
| 541 | rpcListPic = &m_cListPic; |
|---|
| 542 | m_cCuDecoder.destroy(); |
|---|
| 543 | m_bFirstSliceInPicture = true; |
|---|
| 544 | |
|---|
| 545 | return; |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | #if SETTING_NO_OUT_PIC_PRIOR |
|---|
| 549 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic) |
|---|
| 550 | { |
|---|
| 551 | if (!rpcListPic || !m_isNoOutputPriorPics) return; |
|---|
| 552 | |
|---|
| 553 | TComList<TComPic*>::iterator iterPic = rpcListPic->begin(); |
|---|
| 554 | |
|---|
| 555 | while (iterPic != rpcListPic->end()) |
|---|
| 556 | { |
|---|
| 557 | TComPic*& pcPicTmp = *(iterPic++); |
|---|
| 558 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
|---|
| 559 | { |
|---|
| 560 | pcPicTmp->setOutputMark(false); |
|---|
| 561 | } |
|---|
| 562 | } |
|---|
| 563 | } |
|---|
| 564 | #endif |
|---|
| 565 | |
|---|
| 566 | #if EARLY_REF_PIC_MARKING |
|---|
| 567 | Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) |
|---|
| 568 | { |
|---|
| 569 | UInt currTid = m_pcPic->getTLayer(); |
|---|
| 570 | UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); |
|---|
| 571 | UInt latestDecLayerId = m_layerId; |
|---|
| 572 | UInt numTargetDecLayers = 0; |
|---|
| 573 | Int targetDecLayerIdList[MAX_LAYERS]; |
|---|
| 574 | UInt latestDecIdx = 0; |
|---|
| 575 | TComSlice* pcSlice = m_pcPic->getSlice(0); |
|---|
| 576 | |
|---|
| 577 | if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer |
|---|
| 578 | { |
|---|
| 579 | return; |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture |
|---|
| 583 | if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
|---|
| 584 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
|---|
| 585 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
|---|
| 586 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
|---|
| 587 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || |
|---|
| 588 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || |
|---|
| 589 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || |
|---|
| 590 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) |
|---|
| 591 | { |
|---|
| 592 | return; |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers |
|---|
| 596 | { |
|---|
| 597 | return; |
|---|
| 598 | } |
|---|
| 599 | |
|---|
| 600 | for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) |
|---|
| 601 | { |
|---|
| 602 | if ( latestDecLayerId == (*it) ) |
|---|
| 603 | { |
|---|
| 604 | latestDecIdx = numTargetDecLayers; |
|---|
| 605 | } |
|---|
| 606 | targetDecLayerIdList[numTargetDecLayers++] = (*it); |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | Int remainingInterLayerReferencesFlag = 0; |
|---|
| 610 | #if O0225_MAX_TID_FOR_REF_LAYERS |
|---|
| 611 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
|---|
| 612 | { |
|---|
| 613 | Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); |
|---|
| 614 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) |
|---|
| 615 | { |
|---|
| 616 | #else |
|---|
| 617 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) |
|---|
| 618 | { |
|---|
| 619 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
|---|
| 620 | { |
|---|
| 621 | #endif |
|---|
| 622 | for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) |
|---|
| 623 | { |
|---|
| 624 | if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) |
|---|
| 625 | { |
|---|
| 626 | remainingInterLayerReferencesFlag = 1; |
|---|
| 627 | } |
|---|
| 628 | } |
|---|
| 629 | } |
|---|
| 630 | } |
|---|
| 631 | |
|---|
| 632 | if ( remainingInterLayerReferencesFlag == 0 ) |
|---|
| 633 | { |
|---|
| 634 | pcSlice->setReferenced(false); |
|---|
| 635 | } |
|---|
| 636 | } |
|---|
| 637 | #endif |
|---|
| 638 | |
|---|
| 639 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
|---|
| 640 | { |
|---|
| 641 | printf("\ninserting lost poc : %d\n",iLostPoc); |
|---|
| 642 | TComSlice cFillSlice; |
|---|
| 643 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
|---|
| 644 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
|---|
| 645 | #if SVC_EXTENSION |
|---|
| 646 | cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
|---|
| 647 | cFillSlice.initSlice( m_layerId ); |
|---|
| 648 | #else |
|---|
| 649 | cFillSlice.initSlice(); |
|---|
| 650 | #endif |
|---|
| 651 | TComPic *cFillPic; |
|---|
| 652 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
|---|
| 653 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
|---|
| 654 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
|---|
| 655 | #if SVC_EXTENSION |
|---|
| 656 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
|---|
| 657 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
|---|
| 658 | #else |
|---|
| 659 | cFillPic->getSlice(0)->initSlice(); |
|---|
| 660 | #endif |
|---|
| 661 | |
|---|
| 662 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 663 | Int closestPoc = 1000000; |
|---|
| 664 | while ( iterPic != m_cListPic.end()) |
|---|
| 665 | { |
|---|
| 666 | TComPic * rpcPic = *(iterPic++); |
|---|
| 667 | 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()) |
|---|
| 668 | { |
|---|
| 669 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
|---|
| 670 | } |
|---|
| 671 | } |
|---|
| 672 | iterPic = m_cListPic.begin(); |
|---|
| 673 | while ( iterPic != m_cListPic.end()) |
|---|
| 674 | { |
|---|
| 675 | TComPic *rpcPic = *(iterPic++); |
|---|
| 676 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
|---|
| 677 | { |
|---|
| 678 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
|---|
| 679 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
|---|
| 680 | break; |
|---|
| 681 | } |
|---|
| 682 | } |
|---|
| 683 | cFillPic->setCurrSliceIdx(0); |
|---|
| 684 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
|---|
| 685 | { |
|---|
| 686 | cFillPic->getCU(i)->initCU(cFillPic,i); |
|---|
| 687 | } |
|---|
| 688 | cFillPic->getSlice(0)->setReferenced(true); |
|---|
| 689 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
|---|
| 690 | cFillPic->setReconMark(true); |
|---|
| 691 | cFillPic->setOutputMark(true); |
|---|
| 692 | if(m_pocRandomAccess == MAX_INT) |
|---|
| 693 | { |
|---|
| 694 | m_pocRandomAccess = iLostPoc; |
|---|
| 695 | } |
|---|
| 696 | } |
|---|
| 697 | |
|---|
| 698 | |
|---|
| 699 | Void TDecTop::xActivateParameterSets() |
|---|
| 700 | { |
|---|
| 701 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
|---|
| 702 | |
|---|
| 703 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
|---|
| 704 | assert (pps != 0); |
|---|
| 705 | |
|---|
| 706 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
|---|
| 707 | assert (sps != 0); |
|---|
| 708 | |
|---|
| 709 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
|---|
| 710 | { |
|---|
| 711 | printf ("Parameter set activation failed!"); |
|---|
| 712 | assert (0); |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | #if SCALINGLIST_INFERRING |
|---|
| 716 | // scaling list settings and checks |
|---|
| 717 | TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS(); |
|---|
| 718 | TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS(); |
|---|
| 719 | TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS(); |
|---|
| 720 | |
|---|
| 721 | if( activeSPS->getInferScalingListFlag() ) |
|---|
| 722 | { |
|---|
| 723 | UInt refLayerId = activeSPS->getScalingListRefLayerId(); |
|---|
| 724 | TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); |
|---|
| 725 | |
|---|
| 726 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
|---|
| 727 | if( activeVPS->getAvcBaseLayerFlag() ) |
|---|
| 728 | { |
|---|
| 729 | assert( refLayerId > 0 ); |
|---|
| 730 | } |
|---|
| 731 | |
|---|
| 732 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
|---|
| 733 | // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id |
|---|
| 734 | assert( refSps->getInferScalingListFlag() == false ); |
|---|
| 735 | |
|---|
| 736 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
|---|
| 737 | // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
|---|
| 738 | assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true ); |
|---|
| 739 | |
|---|
| 740 | if( activeSPS->getScalingList() != refSps->getScalingList() ) |
|---|
| 741 | { |
|---|
| 742 | // delete created instance of scaling list since it will be inferred |
|---|
| 743 | delete activeSPS->getScalingList(); |
|---|
| 744 | |
|---|
| 745 | // infer scaling list |
|---|
| 746 | activeSPS->setScalingList( refSps->getScalingList() ); |
|---|
| 747 | } |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | if( activePPS->getInferScalingListFlag() ) |
|---|
| 751 | { |
|---|
| 752 | UInt refLayerId = activePPS->getScalingListRefLayerId(); |
|---|
| 753 | TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); |
|---|
| 754 | |
|---|
| 755 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
|---|
| 756 | if( activeVPS->getAvcBaseLayerFlag() ) |
|---|
| 757 | { |
|---|
| 758 | assert( refLayerId > 0 ); |
|---|
| 759 | } |
|---|
| 760 | |
|---|
| 761 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
|---|
| 762 | // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id |
|---|
| 763 | assert( refPps->getInferScalingListFlag() == false ); |
|---|
| 764 | |
|---|
| 765 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
|---|
| 766 | // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
|---|
| 767 | assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true ); |
|---|
| 768 | |
|---|
| 769 | if( activePPS->getScalingList() != refPps->getScalingList() ) |
|---|
| 770 | { |
|---|
| 771 | // delete created instance of scaling list since it will be inferred |
|---|
| 772 | delete activePPS->getScalingList(); |
|---|
| 773 | |
|---|
| 774 | // infer scaling list |
|---|
| 775 | activePPS->setScalingList( refPps->getScalingList() ); |
|---|
| 776 | } |
|---|
| 777 | |
|---|
| 778 | } |
|---|
| 779 | #endif |
|---|
| 780 | |
|---|
| 781 | #if AVC_BASE |
|---|
| 782 | if( activeVPS->getAvcBaseLayerFlag() ) |
|---|
| 783 | { |
|---|
| 784 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
|---|
| 785 | if( m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
|---|
| 786 | { |
|---|
| 787 | UInt refLayerId = 0; |
|---|
| 788 | RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) ); |
|---|
| 789 | |
|---|
| 790 | Int numReorderPics[MAX_TLAYER]; |
|---|
| 791 | Window conformanceWindow; |
|---|
| 792 | Window defaultDisplayWindow; |
|---|
| 793 | |
|---|
| 794 | #if AUXILIARY_PICTURES |
|---|
| 795 | #if SVC_UPSAMPLING |
|---|
| 796 | #if AVC_SYNTAX |
|---|
| 797 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true); |
|---|
| 798 | #else |
|---|
| 799 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
|---|
| 800 | #endif |
|---|
| 801 | #else |
|---|
| 802 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 803 | #endif |
|---|
| 804 | #else |
|---|
| 805 | #if SVC_UPSAMPLING |
|---|
| 806 | #if AVC_SYNTAX |
|---|
| 807 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true); |
|---|
| 808 | #else |
|---|
| 809 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
|---|
| 810 | #endif |
|---|
| 811 | #else |
|---|
| 812 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
|---|
| 813 | #endif |
|---|
| 814 | #endif |
|---|
| 815 | // it is needed where the VPS is accessed through the slice |
|---|
| 816 | pBLPic->getSlice(0)->setVPS( activeVPS ); |
|---|
| 817 | |
|---|
| 818 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
|---|
| 819 | g_bitDepthYLayer[0] = repFormat->getBitDepthVpsLuma(); |
|---|
| 820 | g_bitDepthCLayer[0] = repFormat->getBitDepthVpsChroma(); |
|---|
| 821 | #endif |
|---|
| 822 | } |
|---|
| 823 | } |
|---|
| 824 | #endif |
|---|
| 825 | |
|---|
| 826 | #if P0312_VERT_PHASE_ADJ |
|---|
| 827 | if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) |
|---|
| 828 | { |
|---|
| 829 | for(Int i = 0; i < activeSPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 830 | { |
|---|
| 831 | UInt scaledRefLayerId = activeSPS->getScaledRefLayerId(i); |
|---|
| 832 | if( activeSPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) ) |
|---|
| 833 | { |
|---|
| 834 | printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId ); |
|---|
| 835 | break; |
|---|
| 836 | } |
|---|
| 837 | } |
|---|
| 838 | } |
|---|
| 839 | #endif |
|---|
| 840 | |
|---|
| 841 | #if SPS_DPB_PARAMS |
|---|
| 842 | if( m_layerId > 0 ) |
|---|
| 843 | { |
|---|
| 844 | // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1. |
|---|
| 845 | sps->setMaxTLayers( activeVPS->getMaxTLayers() ); |
|---|
| 846 | |
|---|
| 847 | // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag |
|---|
| 848 | sps->setTemporalIdNestingFlag( activeVPS->getTemporalNestingFlag() ); |
|---|
| 849 | |
|---|
| 850 | // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0, |
|---|
| 851 | // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS. |
|---|
| 852 | for(UInt i=0; i < sps->getMaxTLayers(); i++) |
|---|
| 853 | { |
|---|
| 854 | // to avoid compiler warning "array subscript is above array bounds" |
|---|
| 855 | assert( i < MAX_TLAYER ); |
|---|
| 856 | |
|---|
| 857 | sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i); |
|---|
| 858 | } |
|---|
| 859 | } |
|---|
| 860 | #endif |
|---|
| 861 | |
|---|
| 862 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
|---|
| 863 | { |
|---|
| 864 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
|---|
| 865 | |
|---|
| 866 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
|---|
| 867 | { |
|---|
| 868 | m_cSliceDecoder.initCtxMem(NumCtx); |
|---|
| 869 | for ( UInt st = 0; st < NumCtx; st++ ) |
|---|
| 870 | { |
|---|
| 871 | TDecSbac* ctx = NULL; |
|---|
| 872 | ctx = new TDecSbac; |
|---|
| 873 | ctx->init( &m_cBinCABAC ); |
|---|
| 874 | m_cSliceDecoder.setCtxMem( ctx, st ); |
|---|
| 875 | } |
|---|
| 876 | } |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | m_apcSlicePilot->setPPS(pps); |
|---|
| 880 | m_apcSlicePilot->setSPS(sps); |
|---|
| 881 | pps->setSPS(sps); |
|---|
| 882 | #if REPN_FORMAT_IN_VPS |
|---|
| 883 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
|---|
| 884 | #else |
|---|
| 885 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
|---|
| 886 | #endif |
|---|
| 887 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
|---|
| 888 | |
|---|
| 889 | #if REPN_FORMAT_IN_VPS |
|---|
| 890 | g_bitDepthY = m_apcSlicePilot->getBitDepthY(); |
|---|
| 891 | g_bitDepthC = m_apcSlicePilot->getBitDepthC(); |
|---|
| 892 | #else |
|---|
| 893 | g_bitDepthY = sps->getBitDepthY(); |
|---|
| 894 | g_bitDepthC = sps->getBitDepthC(); |
|---|
| 895 | #endif |
|---|
| 896 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
|---|
| 897 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
|---|
| 898 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
|---|
| 899 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
|---|
| 900 | |
|---|
| 901 | #if Q0074_SEI_COLOR_MAPPING |
|---|
| 902 | for(Int compID=0; compID<3; compID++) |
|---|
| 903 | { |
|---|
| 904 | m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID ); |
|---|
| 905 | } |
|---|
| 906 | #endif |
|---|
| 907 | |
|---|
| 908 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
|---|
| 909 | { |
|---|
| 910 | sps->setAMPAcc( i, sps->getUseAMP() ); |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
|---|
| 914 | { |
|---|
| 915 | sps->setAMPAcc( i, 0 ); |
|---|
| 916 | } |
|---|
| 917 | |
|---|
| 918 | m_cSAO.destroy(); |
|---|
| 919 | #if REPN_FORMAT_IN_VPS |
|---|
| 920 | #if AUXILIARY_PICTURES |
|---|
| 921 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
|---|
| 922 | #else |
|---|
| 923 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
|---|
| 924 | #endif |
|---|
| 925 | #else |
|---|
| 926 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
|---|
| 927 | #endif |
|---|
| 928 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | #if SVC_EXTENSION |
|---|
| 932 | #if POC_RESET_FLAG |
|---|
| 933 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
|---|
| 934 | #else |
|---|
| 935 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
|---|
| 936 | #endif |
|---|
| 937 | #else |
|---|
| 938 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
|---|
| 939 | #endif |
|---|
| 940 | { |
|---|
| 941 | TComPic*& pcPic = m_pcPic; |
|---|
| 942 | #if SVC_EXTENSION |
|---|
| 943 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); |
|---|
| 944 | #if OUTPUT_LAYER_SET_INDEX |
|---|
| 945 | // Following check should go wherever the VPS is activated |
|---|
| 946 | checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS()); |
|---|
| 947 | #endif |
|---|
| 948 | #if RESOLUTION_BASED_DPB |
|---|
| 949 | // Following assignment should go wherever a new VPS is activated |
|---|
| 950 | assignSubDpbs(m_apcSlicePilot->getVPS()); |
|---|
| 951 | #endif |
|---|
| 952 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
|---|
| 953 | #else //SVC_EXTENSION |
|---|
| 954 | m_apcSlicePilot->initSlice(); |
|---|
| 955 | #endif |
|---|
| 956 | |
|---|
| 957 | if (m_bFirstSliceInPicture) |
|---|
| 958 | { |
|---|
| 959 | m_uiSliceIdx = 0; |
|---|
| 960 | } |
|---|
| 961 | else |
|---|
| 962 | { |
|---|
| 963 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
|---|
| 964 | } |
|---|
| 965 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
|---|
| 966 | |
|---|
| 967 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
|---|
| 968 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
|---|
| 969 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
|---|
| 970 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
|---|
| 971 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
|---|
| 972 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
|---|
| 973 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
|---|
| 974 | |
|---|
| 975 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
|---|
| 976 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
|---|
| 977 | |
|---|
| 978 | #if SVC_EXTENSION |
|---|
| 979 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 980 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
|---|
| 981 | #endif |
|---|
| 982 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
|---|
| 983 | #endif |
|---|
| 984 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
|---|
| 985 | |
|---|
| 986 | // set POC for dependent slices in skipped pictures |
|---|
| 987 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
|---|
| 988 | { |
|---|
| 989 | m_apcSlicePilot->setPOC(m_skippedPOC); |
|---|
| 990 | } |
|---|
| 991 | |
|---|
| 992 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
|---|
| 993 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
|---|
| 994 | |
|---|
| 995 | #if SETTING_NO_OUT_PIC_PRIOR |
|---|
| 996 | //For inference of NoOutputOfPriorPicsFlag |
|---|
| 997 | if (m_apcSlicePilot->getRapPicFlag()) |
|---|
| 998 | { |
|---|
| 999 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
|---|
| 1000 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
|---|
| 1001 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
|---|
| 1002 | { |
|---|
| 1003 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
|---|
| 1004 | } |
|---|
| 1005 | //the inference for NoOutputPriorPicsFlag |
|---|
| 1006 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
|---|
| 1007 | { |
|---|
| 1008 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
|---|
| 1009 | { |
|---|
| 1010 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
|---|
| 1011 | } |
|---|
| 1012 | } |
|---|
| 1013 | else |
|---|
| 1014 | { |
|---|
| 1015 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
|---|
| 1016 | } |
|---|
| 1017 | |
|---|
| 1018 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
|---|
| 1019 | { |
|---|
| 1020 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
|---|
| 1021 | } |
|---|
| 1022 | } |
|---|
| 1023 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
|---|
| 1024 | { |
|---|
| 1025 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
|---|
| 1026 | m_isNoOutputPriorPics = true; |
|---|
| 1027 | } |
|---|
| 1028 | else |
|---|
| 1029 | { |
|---|
| 1030 | m_isNoOutputPriorPics = false; |
|---|
| 1031 | } |
|---|
| 1032 | |
|---|
| 1033 | //For inference of PicOutputFlag |
|---|
| 1034 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
|---|
| 1035 | { |
|---|
| 1036 | if ( m_craNoRaslOutputFlag ) |
|---|
| 1037 | { |
|---|
| 1038 | m_apcSlicePilot->setPicOutputFlag(false); |
|---|
| 1039 | } |
|---|
| 1040 | } |
|---|
| 1041 | #endif |
|---|
| 1042 | |
|---|
| 1043 | #if FIX_POC_CRA_NORASL_OUTPUT |
|---|
| 1044 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
|---|
| 1045 | { |
|---|
| 1046 | Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
|---|
| 1047 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
|---|
| 1048 | } |
|---|
| 1049 | #endif |
|---|
| 1050 | |
|---|
| 1051 | // Skip pictures due to random access |
|---|
| 1052 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
|---|
| 1053 | { |
|---|
| 1054 | m_prevSliceSkipped = true; |
|---|
| 1055 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1056 | return false; |
|---|
| 1057 | } |
|---|
| 1058 | // Skip TFD pictures associated with BLA/BLANT pictures |
|---|
| 1059 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
|---|
| 1060 | { |
|---|
| 1061 | m_prevSliceSkipped = true; |
|---|
| 1062 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1063 | return false; |
|---|
| 1064 | } |
|---|
| 1065 | |
|---|
| 1066 | // clear previous slice skipped flag |
|---|
| 1067 | m_prevSliceSkipped = false; |
|---|
| 1068 | |
|---|
| 1069 | // exit when a new picture is found |
|---|
| 1070 | #if SVC_EXTENSION |
|---|
| 1071 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
|---|
| 1072 | |
|---|
| 1073 | #if NO_OUTPUT_OF_PRIOR_PICS |
|---|
| 1074 | #if NO_CLRAS_OUTPUT_FLAG |
|---|
| 1075 | if (m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() ) |
|---|
| 1076 | { |
|---|
| 1077 | if (m_bFirstSliceInSequence) |
|---|
| 1078 | { |
|---|
| 1079 | setNoClrasOutputFlag(true); |
|---|
| 1080 | } |
|---|
| 1081 | else if ( m_apcSlicePilot->getBlaPicFlag() ) |
|---|
| 1082 | { |
|---|
| 1083 | setNoClrasOutputFlag(true); |
|---|
| 1084 | } |
|---|
| 1085 | #if O0149_CROSS_LAYER_BLA_FLAG |
|---|
| 1086 | else if (m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag()) |
|---|
| 1087 | { |
|---|
| 1088 | setNoClrasOutputFlag(true); |
|---|
| 1089 | } |
|---|
| 1090 | #endif |
|---|
| 1091 | else |
|---|
| 1092 | { |
|---|
| 1093 | setNoClrasOutputFlag(false); |
|---|
| 1094 | } |
|---|
| 1095 | } |
|---|
| 1096 | else |
|---|
| 1097 | { |
|---|
| 1098 | setNoClrasOutputFlag(false); |
|---|
| 1099 | } |
|---|
| 1100 | |
|---|
| 1101 | m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag ); |
|---|
| 1102 | #endif |
|---|
| 1103 | |
|---|
| 1104 | // Derive the value of NoOutputOfPriorPicsFlag |
|---|
| 1105 | if( bNewPOC || m_layerId!=m_uiPrevLayerId ) // i.e. new coded picture |
|---|
| 1106 | { |
|---|
| 1107 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() ) |
|---|
| 1108 | { |
|---|
| 1109 | this->setNoOutputPriorPicsFlag( true ); |
|---|
| 1110 | } |
|---|
| 1111 | else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() ) |
|---|
| 1112 | { |
|---|
| 1113 | this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() ); |
|---|
| 1114 | } |
|---|
| 1115 | else |
|---|
| 1116 | { |
|---|
| 1117 | if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() ) |
|---|
| 1118 | { |
|---|
| 1119 | this->setNoOutputPriorPicsFlag( true ); |
|---|
| 1120 | } |
|---|
| 1121 | } |
|---|
| 1122 | } |
|---|
| 1123 | #endif |
|---|
| 1124 | |
|---|
| 1125 | #if ALIGNED_BUMPING |
|---|
| 1126 | if (bNewPOC || m_layerId!=m_uiPrevLayerId) |
|---|
| 1127 | { |
|---|
| 1128 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
|---|
| 1129 | } |
|---|
| 1130 | #endif |
|---|
| 1131 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
|---|
| 1132 | { |
|---|
| 1133 | m_prevPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1134 | curLayerId = m_uiPrevLayerId; |
|---|
| 1135 | m_uiPrevLayerId = m_layerId; |
|---|
| 1136 | return true; |
|---|
| 1137 | } |
|---|
| 1138 | #else |
|---|
| 1139 | //we should only get a different poc for a new picture (with CTU address==0) |
|---|
| 1140 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0)) |
|---|
| 1141 | { |
|---|
| 1142 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
|---|
| 1143 | } |
|---|
| 1144 | // exit when a new picture is found |
|---|
| 1145 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
|---|
| 1146 | { |
|---|
| 1147 | if (m_prevPOC >= m_pocRandomAccess) |
|---|
| 1148 | { |
|---|
| 1149 | m_prevPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1150 | return true; |
|---|
| 1151 | } |
|---|
| 1152 | m_prevPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1153 | } |
|---|
| 1154 | #endif |
|---|
| 1155 | // actual decoding starts here |
|---|
| 1156 | xActivateParameterSets(); |
|---|
| 1157 | #if !O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS && N0147_IRAP_ALIGN_FLAG |
|---|
| 1158 | //Note setting O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS to 0 may cause decoder to crash. |
|---|
| 1159 | //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 |
|---|
| 1160 | if(!m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
|---|
| 1161 | { |
|---|
| 1162 | assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0); |
|---|
| 1163 | } |
|---|
| 1164 | //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 |
|---|
| 1165 | if( m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
|---|
| 1166 | { |
|---|
| 1167 | assert( m_apcSlicePilot->getPocResetFlag() == 0); |
|---|
| 1168 | } |
|---|
| 1169 | #endif |
|---|
| 1170 | #if REPN_FORMAT_IN_VPS |
|---|
| 1171 | // Initialize ILRP if needed, only for the current layer |
|---|
| 1172 | // ILRP intialization should go along with activation of parameters sets, |
|---|
| 1173 | // although activation of parameter sets itself need not be done for each and every slice!!! |
|---|
| 1174 | xInitILRP(m_apcSlicePilot); |
|---|
| 1175 | #endif |
|---|
| 1176 | if (m_apcSlicePilot->isNextSlice()) |
|---|
| 1177 | { |
|---|
| 1178 | m_prevPOC = m_apcSlicePilot->getPOC(); |
|---|
| 1179 | #if SVC_EXTENSION |
|---|
| 1180 | curLayerId = m_layerId; |
|---|
| 1181 | m_uiPrevLayerId = m_layerId; |
|---|
| 1182 | #endif |
|---|
| 1183 | } |
|---|
| 1184 | m_bFirstSliceInSequence = false; |
|---|
| 1185 | #if SETTING_NO_OUT_PIC_PRIOR |
|---|
| 1186 | m_bFirstSliceInBitstream = false; |
|---|
| 1187 | #endif |
|---|
| 1188 | #if POC_RESET_FLAG |
|---|
| 1189 | // This operation would do the following: |
|---|
| 1190 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
|---|
| 1191 | // 2. Update the value of m_pocCRA. |
|---|
| 1192 | // 3. Reset the POC values at the decoder for the current picture to be zero. |
|---|
| 1193 | // 4. update value of POCLastDisplay |
|---|
| 1194 | if( m_apcSlicePilot->getPocResetFlag() ) |
|---|
| 1195 | { |
|---|
| 1196 | if( m_apcSlicePilot->getSliceIdx() == 0 ) |
|---|
| 1197 | { |
|---|
| 1198 | Int pocAdjustValue = m_apcSlicePilot->getPOC(); |
|---|
| 1199 | |
|---|
| 1200 | #if PREVTID0_POC_RESET |
|---|
| 1201 | m_apcSlicePilot->adjustPrevTid0POC(pocAdjustValue); |
|---|
| 1202 | #endif |
|---|
| 1203 | // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre |
|---|
| 1204 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
|---|
| 1205 | |
|---|
| 1206 | // Iterate through all picture in DPB |
|---|
| 1207 | while( iterPic != m_cListPic.end() ) |
|---|
| 1208 | { |
|---|
| 1209 | TComPic *dpbPic = *iterPic; |
|---|
| 1210 | // Check if the picture pointed to by iterPic is either used for reference or |
|---|
| 1211 | // needed for output, are in the same layer, and not the current picture. |
|---|
| 1212 | if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
|---|
| 1213 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
|---|
| 1214 | && ( dpbPic->getReconMark() ) |
|---|
| 1215 | ) |
|---|
| 1216 | { |
|---|
| 1217 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
|---|
| 1218 | { |
|---|
| 1219 | |
|---|
| 1220 | TComSlice *slice = dpbPic->getSlice(i); |
|---|
| 1221 | TComReferencePictureSet *rps = slice->getRPS(); |
|---|
| 1222 | slice->setPOC( slice->getPOC() - pocAdjustValue ); |
|---|
| 1223 | |
|---|
| 1224 | // Also adjust the POC value stored in the RPS of each such slice |
|---|
| 1225 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
|---|
| 1226 | { |
|---|
| 1227 | rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); |
|---|
| 1228 | } |
|---|
| 1229 | // Also adjust the value of refPOC |
|---|
| 1230 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
|---|
| 1231 | { |
|---|
| 1232 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
|---|
| 1233 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
|---|
| 1234 | { |
|---|
| 1235 | slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | } |
|---|
| 1239 | } |
|---|
| 1240 | iterPic++; |
|---|
| 1241 | } |
|---|
| 1242 | // Update the value of pocCRA |
|---|
| 1243 | m_pocCRA -= pocAdjustValue; |
|---|
| 1244 | // Update value of POCLastDisplay |
|---|
| 1245 | iPOCLastDisplay -= pocAdjustValue; |
|---|
| 1246 | } |
|---|
| 1247 | // Reset current poc for current slice and RPS |
|---|
| 1248 | m_apcSlicePilot->setPOC( 0 ); |
|---|
| 1249 | } |
|---|
| 1250 | #endif |
|---|
| 1251 | #if ALIGN_TSA_STSA_PICS |
|---|
| 1252 | if( m_apcSlicePilot->getLayerId() > 0 ) |
|---|
| 1253 | { |
|---|
| 1254 | // Check for TSA alignment |
|---|
| 1255 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
|---|
| 1256 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R |
|---|
| 1257 | ) |
|---|
| 1258 | { |
|---|
| 1259 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
|---|
| 1260 | { |
|---|
| 1261 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
|---|
| 1262 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); |
|---|
| 1263 | if( refpicLayer ) |
|---|
| 1264 | { |
|---|
| 1265 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
|---|
| 1266 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R ); // TSA pictures should be aligned among depenedent layers |
|---|
| 1267 | } |
|---|
| 1268 | } |
|---|
| 1269 | } |
|---|
| 1270 | // Check for STSA alignment |
|---|
| 1271 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
|---|
| 1272 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R |
|---|
| 1273 | ) |
|---|
| 1274 | { |
|---|
| 1275 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
|---|
| 1276 | { |
|---|
| 1277 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
|---|
| 1278 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); // STSA pictures should be aligned among dependent layers |
|---|
| 1279 | if( refpicLayer ) |
|---|
| 1280 | |
|---|
| 1281 | { |
|---|
| 1282 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
|---|
| 1283 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R ); |
|---|
| 1284 | } |
|---|
| 1285 | } |
|---|
| 1286 | } |
|---|
| 1287 | } |
|---|
| 1288 | #endif |
|---|
| 1289 | //detect lost reference picture and insert copy of earlier frame. |
|---|
| 1290 | Int lostPoc; |
|---|
| 1291 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
|---|
| 1292 | { |
|---|
| 1293 | xCreateLostPicture(lostPoc-1); |
|---|
| 1294 | } |
|---|
| 1295 | if (m_bFirstSliceInPicture) |
|---|
| 1296 | { |
|---|
| 1297 | #if AVC_BASE |
|---|
| 1298 | if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
|---|
| 1299 | { |
|---|
| 1300 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
|---|
| 1301 | pBLPic->getSlice(0)->setReferenced(true); |
|---|
| 1302 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
|---|
| 1303 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
|---|
| 1304 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
|---|
| 1305 | |
|---|
| 1306 | if( pFile->good() ) |
|---|
| 1307 | { |
|---|
| 1308 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
|---|
| 1309 | |
|---|
| 1310 | pFile->seekg((UInt)uiPos, ios::beg ); |
|---|
| 1311 | |
|---|
| 1312 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
|---|
| 1313 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
|---|
| 1314 | for( Int i = 0; i < uiHeight; i++ ) |
|---|
| 1315 | { |
|---|
| 1316 | for( Int j = 0; j < uiWidth; j++ ) |
|---|
| 1317 | { |
|---|
| 1318 | pPel[j] = pFile->get(); |
|---|
| 1319 | } |
|---|
| 1320 | pPel += uiStride; |
|---|
| 1321 | } |
|---|
| 1322 | |
|---|
| 1323 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
|---|
| 1324 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
|---|
| 1325 | for( Int i = 0; i < uiHeight/2; i++ ) |
|---|
| 1326 | { |
|---|
| 1327 | for( Int j = 0; j < uiWidth/2; j++ ) |
|---|
| 1328 | { |
|---|
| 1329 | pPel[j] = pFile->get(); |
|---|
| 1330 | } |
|---|
| 1331 | pPel += uiStride; |
|---|
| 1332 | } |
|---|
| 1333 | |
|---|
| 1334 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
|---|
| 1335 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
|---|
| 1336 | for( Int i = 0; i < uiHeight/2; i++ ) |
|---|
| 1337 | { |
|---|
| 1338 | for( Int j = 0; j < uiWidth/2; j++ ) |
|---|
| 1339 | { |
|---|
| 1340 | pPel[j] = pFile->get(); |
|---|
| 1341 | } |
|---|
| 1342 | pPel += uiStride; |
|---|
| 1343 | } |
|---|
| 1344 | } |
|---|
| 1345 | } |
|---|
| 1346 | #endif |
|---|
| 1347 | |
|---|
| 1348 | #if NO_OUTPUT_OF_PRIOR_PICS |
|---|
| 1349 | if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() ) |
|---|
| 1350 | { |
|---|
| 1351 | for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++) |
|---|
| 1352 | { |
|---|
| 1353 | m_ppcTDecTop[i]->setLayerInitializedFlag(false); |
|---|
| 1354 | m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false); |
|---|
| 1355 | } |
|---|
| 1356 | } |
|---|
| 1357 | #endif |
|---|
| 1358 | // Buffer initialize for prediction. |
|---|
| 1359 | m_cPrediction.initTempBuff(); |
|---|
| 1360 | #if ALIGNED_BUMPING |
|---|
| 1361 | m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); |
|---|
| 1362 | #else |
|---|
| 1363 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
|---|
| 1364 | #endif |
|---|
| 1365 | // Get a new picture buffer |
|---|
| 1366 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
|---|
| 1367 | |
|---|
| 1368 | Bool isField = false; |
|---|
| 1369 | Bool isTff = false; |
|---|
| 1370 | |
|---|
| 1371 | if(!m_SEIs.empty()) |
|---|
| 1372 | { |
|---|
| 1373 | // Check if any new Picture Timing SEI has arrived |
|---|
| 1374 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
|---|
| 1375 | if (pictureTimingSEIs.size()>0) |
|---|
| 1376 | { |
|---|
| 1377 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
|---|
| 1378 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
|---|
| 1379 | isTff = (pictureTiming->m_picStruct == 1); |
|---|
| 1380 | } |
|---|
| 1381 | } |
|---|
| 1382 | |
|---|
| 1383 | //Set Field/Frame coding mode |
|---|
| 1384 | m_pcPic->setField(isField); |
|---|
| 1385 | m_pcPic->setTopField(isTff); |
|---|
| 1386 | |
|---|
| 1387 | // transfer any SEI messages that have been received to the picture |
|---|
| 1388 | pcPic->setSEIs(m_SEIs); |
|---|
| 1389 | m_SEIs.clear(); |
|---|
| 1390 | |
|---|
| 1391 | // Recursive structure |
|---|
| 1392 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
|---|
| 1393 | #if SVC_EXTENSION |
|---|
| 1394 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
|---|
| 1395 | #else |
|---|
| 1396 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
|---|
| 1397 | #endif |
|---|
| 1398 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
|---|
| 1399 | |
|---|
| 1400 | m_cSliceDecoder.create(); |
|---|
| 1401 | } |
|---|
| 1402 | else |
|---|
| 1403 | { |
|---|
| 1404 | // Check if any new SEI has arrived |
|---|
| 1405 | if(!m_SEIs.empty()) |
|---|
| 1406 | { |
|---|
| 1407 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
|---|
| 1408 | SEIMessages &picSEI = pcPic->getSEIs(); |
|---|
| 1409 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
|---|
| 1410 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
|---|
| 1411 | deleteSEIs(m_SEIs); |
|---|
| 1412 | } |
|---|
| 1413 | } |
|---|
| 1414 | |
|---|
| 1415 | // Set picture slice pointer |
|---|
| 1416 | TComSlice* pcSlice = m_apcSlicePilot; |
|---|
| 1417 | Bool bNextSlice = pcSlice->isNextSlice(); |
|---|
| 1418 | |
|---|
| 1419 | UInt uiCummulativeTileWidth; |
|---|
| 1420 | UInt uiCummulativeTileHeight; |
|---|
| 1421 | UInt i, j, p; |
|---|
| 1422 | |
|---|
| 1423 | //set NumColumnsMins1 and NumRowsMinus1 |
|---|
| 1424 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
|---|
| 1425 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
|---|
| 1426 | |
|---|
| 1427 | //create the TComTileArray |
|---|
| 1428 | pcPic->getPicSym()->xCreateTComTileArray(); |
|---|
| 1429 | |
|---|
| 1430 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
|---|
| 1431 | { |
|---|
| 1432 | //set the width for each tile |
|---|
| 1433 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
|---|
| 1434 | { |
|---|
| 1435 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
|---|
| 1436 | { |
|---|
| 1437 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
|---|
| 1438 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
|---|
| 1439 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
|---|
| 1440 | } |
|---|
| 1441 | } |
|---|
| 1442 | |
|---|
| 1443 | //set the height for each tile |
|---|
| 1444 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
|---|
| 1445 | { |
|---|
| 1446 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
|---|
| 1447 | { |
|---|
| 1448 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
|---|
| 1449 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
|---|
| 1450 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
|---|
| 1451 | } |
|---|
| 1452 | } |
|---|
| 1453 | } |
|---|
| 1454 | else |
|---|
| 1455 | { |
|---|
| 1456 | //set the width for each tile |
|---|
| 1457 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
|---|
| 1458 | { |
|---|
| 1459 | uiCummulativeTileWidth = 0; |
|---|
| 1460 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
|---|
| 1461 | { |
|---|
| 1462 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
|---|
| 1463 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
|---|
| 1464 | } |
|---|
| 1465 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
|---|
| 1466 | } |
|---|
| 1467 | |
|---|
| 1468 | //set the height for each tile |
|---|
| 1469 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
|---|
| 1470 | { |
|---|
| 1471 | uiCummulativeTileHeight = 0; |
|---|
| 1472 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
|---|
| 1473 | { |
|---|
| 1474 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
|---|
| 1475 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
|---|
| 1476 | } |
|---|
| 1477 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
|---|
| 1478 | } |
|---|
| 1479 | } |
|---|
| 1480 | |
|---|
| 1481 | pcPic->getPicSym()->xInitTiles(); |
|---|
| 1482 | |
|---|
| 1483 | //generate the Coding Order Map and Inverse Coding Order Map |
|---|
| 1484 | UInt uiEncCUAddr; |
|---|
| 1485 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
|---|
| 1486 | { |
|---|
| 1487 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
|---|
| 1488 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
|---|
| 1489 | } |
|---|
| 1490 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
|---|
| 1491 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
|---|
| 1492 | |
|---|
| 1493 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
|---|
| 1494 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
|---|
| 1495 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
|---|
| 1496 | if(pcSlice->isNextSlice()) |
|---|
| 1497 | { |
|---|
| 1498 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
|---|
| 1499 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
|---|
| 1500 | } |
|---|
| 1501 | |
|---|
| 1502 | if (m_bFirstSliceInPicture) |
|---|
| 1503 | { |
|---|
| 1504 | if(pcPic->getNumAllocatedSlice() != 1) |
|---|
| 1505 | { |
|---|
| 1506 | pcPic->clearSliceBuffer(); |
|---|
| 1507 | } |
|---|
| 1508 | } |
|---|
| 1509 | else |
|---|
| 1510 | { |
|---|
| 1511 | pcPic->allocateNewSlice(); |
|---|
| 1512 | } |
|---|
| 1513 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
|---|
| 1514 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
|---|
| 1515 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
|---|
| 1516 | |
|---|
| 1517 | pcPic->setTLayer(nalu.m_temporalId); |
|---|
| 1518 | |
|---|
| 1519 | #if SVC_EXTENSION |
|---|
| 1520 | pcPic->setLayerId(nalu.m_layerId); |
|---|
| 1521 | pcSlice->setLayerId(nalu.m_layerId); |
|---|
| 1522 | pcSlice->setPic(pcPic); |
|---|
| 1523 | #endif |
|---|
| 1524 | |
|---|
| 1525 | if (bNextSlice) |
|---|
| 1526 | { |
|---|
| 1527 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
|---|
| 1528 | // Set reference list |
|---|
| 1529 | #if SVC_EXTENSION |
|---|
| 1530 | if (m_layerId == 0) |
|---|
| 1531 | #endif |
|---|
| 1532 | pcSlice->setRefPicList( m_cListPic, true ); |
|---|
| 1533 | |
|---|
| 1534 | #if SVC_EXTENSION |
|---|
| 1535 | // Create upsampling reference layer pictures for all possible dependent layers and do it only once for the first slice. |
|---|
| 1536 | // Other slices might choose which reference pictures to be used for inter-layer prediction |
|---|
| 1537 | if( m_layerId > 0 && m_uiSliceIdx == 0 ) |
|---|
| 1538 | { |
|---|
| 1539 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 1540 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
|---|
| 1541 | #endif |
|---|
| 1542 | for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
|---|
| 1543 | { |
|---|
| 1544 | UInt refLayerIdc = i; |
|---|
| 1545 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc); |
|---|
| 1546 | #if AVC_BASE |
|---|
| 1547 | if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
|---|
| 1548 | { |
|---|
| 1549 | TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); |
|---|
| 1550 | |
|---|
| 1551 | if( pic ) |
|---|
| 1552 | { |
|---|
| 1553 | pcSlice->setBaseColPic ( refLayerIdc, pic ); |
|---|
| 1554 | } |
|---|
| 1555 | else |
|---|
| 1556 | { |
|---|
| 1557 | continue; |
|---|
| 1558 | } |
|---|
| 1559 | #if AVC_SYNTAX |
|---|
| 1560 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
|---|
| 1561 | if( pcSlice->getPOC() == 0 ) |
|---|
| 1562 | { |
|---|
| 1563 | // initialize partition order. |
|---|
| 1564 | UInt* piTmp = &g_auiZscanToRaster[0]; |
|---|
| 1565 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
|---|
| 1566 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
|---|
| 1567 | } |
|---|
| 1568 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
|---|
| 1569 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
|---|
| 1570 | #endif |
|---|
| 1571 | } |
|---|
| 1572 | else |
|---|
| 1573 | { |
|---|
| 1574 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 1575 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
|---|
| 1576 | #else |
|---|
| 1577 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
|---|
| 1578 | #endif |
|---|
| 1579 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
|---|
| 1580 | if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) ) |
|---|
| 1581 | { |
|---|
| 1582 | continue; |
|---|
| 1583 | } |
|---|
| 1584 | } |
|---|
| 1585 | #else |
|---|
| 1586 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 1587 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
|---|
| 1588 | #else |
|---|
| 1589 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
|---|
| 1590 | #endif |
|---|
| 1591 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
|---|
| 1592 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
|---|
| 1593 | #endif |
|---|
| 1594 | |
|---|
| 1595 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 1596 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId); |
|---|
| 1597 | #else |
|---|
| 1598 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
|---|
| 1599 | #endif |
|---|
| 1600 | |
|---|
| 1601 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); |
|---|
| 1602 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); |
|---|
| 1603 | #if Q0200_CONFORMANCE_BL_SIZE |
|---|
| 1604 | Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc(); |
|---|
| 1605 | const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow(); |
|---|
| 1606 | widthBL -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc ); |
|---|
| 1607 | heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc ); |
|---|
| 1608 | #endif |
|---|
| 1609 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
|---|
| 1610 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
|---|
| 1611 | |
|---|
| 1612 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
|---|
| 1613 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
|---|
| 1614 | |
|---|
| 1615 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
|---|
| 1616 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
|---|
| 1617 | |
|---|
| 1618 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1619 | TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); |
|---|
| 1620 | if( pcSlice->getPPS()->getCGSFlag() ) |
|---|
| 1621 | { |
|---|
| 1622 | if(!m_pColorMappedPic) |
|---|
| 1623 | { |
|---|
| 1624 | initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)); |
|---|
| 1625 | } |
|---|
| 1626 | m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pColorMappedPic ); |
|---|
| 1627 | pBaseColRec = m_pColorMappedPic; |
|---|
| 1628 | } |
|---|
| 1629 | #endif |
|---|
| 1630 | #if SVC_UPSAMPLING |
|---|
| 1631 | if( pcPic->isSpatialEnhLayer(refLayerIdc) ) |
|---|
| 1632 | { |
|---|
| 1633 | // check for the sample prediction picture type |
|---|
| 1634 | if( m_ppcTDecTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) ) |
|---|
| 1635 | { |
|---|
| 1636 | #if O0215_PHASE_ALIGNMENT |
|---|
| 1637 | #if O0194_JOINT_US_BITSHIFT |
|---|
| 1638 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1639 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
|---|
| 1640 | #else |
|---|
| 1641 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
|---|
| 1642 | #endif |
|---|
| 1643 | #else |
|---|
| 1644 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1645 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); |
|---|
| 1646 | #else |
|---|
| 1647 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); |
|---|
| 1648 | #endif |
|---|
| 1649 | #endif |
|---|
| 1650 | #else |
|---|
| 1651 | #if O0194_JOINT_US_BITSHIFT |
|---|
| 1652 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1653 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); |
|---|
| 1654 | #else |
|---|
| 1655 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); |
|---|
| 1656 | #endif |
|---|
| 1657 | #else |
|---|
| 1658 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1659 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); |
|---|
| 1660 | #else |
|---|
| 1661 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); |
|---|
| 1662 | #endif |
|---|
| 1663 | #endif |
|---|
| 1664 | #endif |
|---|
| 1665 | } |
|---|
| 1666 | } |
|---|
| 1667 | else |
|---|
| 1668 | { |
|---|
| 1669 | pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
|---|
| 1670 | } |
|---|
| 1671 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
|---|
| 1672 | #endif |
|---|
| 1673 | } |
|---|
| 1674 | } |
|---|
| 1675 | |
|---|
| 1676 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
|---|
| 1677 | { |
|---|
| 1678 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 1679 | { |
|---|
| 1680 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
|---|
| 1681 | #if AVC_BASE |
|---|
| 1682 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
|---|
| 1683 | { |
|---|
| 1684 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
|---|
| 1685 | #if AVC_SYNTAX |
|---|
| 1686 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
|---|
| 1687 | if( pcSlice->getPOC() == 0 ) |
|---|
| 1688 | { |
|---|
| 1689 | // initialize partition order. |
|---|
| 1690 | UInt* piTmp = &g_auiZscanToRaster[0]; |
|---|
| 1691 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
|---|
| 1692 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
|---|
| 1693 | } |
|---|
| 1694 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
|---|
| 1695 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
|---|
| 1696 | #endif |
|---|
| 1697 | } |
|---|
| 1698 | else |
|---|
| 1699 | { |
|---|
| 1700 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 1701 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
|---|
| 1702 | #else |
|---|
| 1703 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
|---|
| 1704 | #endif |
|---|
| 1705 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
|---|
| 1706 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
|---|
| 1707 | } |
|---|
| 1708 | #else |
|---|
| 1709 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 1710 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
|---|
| 1711 | #else |
|---|
| 1712 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
|---|
| 1713 | #endif |
|---|
| 1714 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
|---|
| 1715 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
|---|
| 1716 | #endif |
|---|
| 1717 | |
|---|
| 1718 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
|---|
| 1719 | } |
|---|
| 1720 | |
|---|
| 1721 | pcSlice->setILRPic( m_cIlpPic ); |
|---|
| 1722 | |
|---|
| 1723 | #if REF_IDX_MFM |
|---|
| 1724 | if( pcSlice->getMFMEnabledFlag() ) |
|---|
| 1725 | { |
|---|
| 1726 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
|---|
| 1727 | } |
|---|
| 1728 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
|---|
| 1729 | } |
|---|
| 1730 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 1731 | else if ( m_layerId > 0 ) |
|---|
| 1732 | { |
|---|
| 1733 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
|---|
| 1734 | } |
|---|
| 1735 | #endif |
|---|
| 1736 | #if MFM_ENCCONSTRAINT |
|---|
| 1737 | if( pcSlice->getMFMEnabledFlag() ) |
|---|
| 1738 | { |
|---|
| 1739 | TComPic* refPic = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() ); |
|---|
| 1740 | |
|---|
| 1741 | assert( refPic ); |
|---|
| 1742 | |
|---|
| 1743 | Int refLayerId = refPic->getLayerId(); |
|---|
| 1744 | |
|---|
| 1745 | if( refLayerId != pcSlice->getLayerId() ) |
|---|
| 1746 | { |
|---|
| 1747 | TComPic* pColBasePic = pcSlice->getBaseColPic( *m_ppcTDecTop[refLayerId]->getListPic() ); |
|---|
| 1748 | assert( pColBasePic->checkSameRefInfo() == true ); |
|---|
| 1749 | } |
|---|
| 1750 | } |
|---|
| 1751 | #endif |
|---|
| 1752 | #endif |
|---|
| 1753 | |
|---|
| 1754 | #if N0147_IRAP_ALIGN_FLAG |
|---|
| 1755 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() ) |
|---|
| 1756 | { |
|---|
| 1757 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 1758 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
|---|
| 1759 | #endif |
|---|
| 1760 | for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
|---|
| 1761 | { |
|---|
| 1762 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
|---|
| 1763 | TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); |
|---|
| 1764 | if(refpicLayer && pcSlice->isIRAP()) |
|---|
| 1765 | { |
|---|
| 1766 | assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType()); |
|---|
| 1767 | } |
|---|
| 1768 | } |
|---|
| 1769 | } |
|---|
| 1770 | #endif |
|---|
| 1771 | |
|---|
| 1772 | if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) |
|---|
| 1773 | { |
|---|
| 1774 | TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx()); |
|---|
| 1775 | |
|---|
| 1776 | assert( refPic ); |
|---|
| 1777 | |
|---|
| 1778 | // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, |
|---|
| 1779 | // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture. |
|---|
| 1780 | if( refPic->isILR(pcSlice->getLayerId()) ) |
|---|
| 1781 | { |
|---|
| 1782 | assert( m_ppcTDecTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) ); |
|---|
| 1783 | } |
|---|
| 1784 | } |
|---|
| 1785 | #endif //SVC_EXTENSION |
|---|
| 1786 | |
|---|
| 1787 | // For generalized B |
|---|
| 1788 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
|---|
| 1789 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
|---|
| 1790 | { |
|---|
| 1791 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
|---|
| 1792 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
|---|
| 1793 | |
|---|
| 1794 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
|---|
| 1795 | { |
|---|
| 1796 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
|---|
| 1797 | } |
|---|
| 1798 | } |
|---|
| 1799 | if (!pcSlice->isIntra()) |
|---|
| 1800 | { |
|---|
| 1801 | Bool bLowDelay = true; |
|---|
| 1802 | Int iCurrPOC = pcSlice->getPOC(); |
|---|
| 1803 | Int iRefIdx = 0; |
|---|
| 1804 | |
|---|
| 1805 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
|---|
| 1806 | { |
|---|
| 1807 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
|---|
| 1808 | { |
|---|
| 1809 | bLowDelay = false; |
|---|
| 1810 | } |
|---|
| 1811 | } |
|---|
| 1812 | if (pcSlice->isInterB()) |
|---|
| 1813 | { |
|---|
| 1814 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
|---|
| 1815 | { |
|---|
| 1816 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
|---|
| 1817 | { |
|---|
| 1818 | bLowDelay = false; |
|---|
| 1819 | } |
|---|
| 1820 | } |
|---|
| 1821 | } |
|---|
| 1822 | |
|---|
| 1823 | pcSlice->setCheckLDC(bLowDelay); |
|---|
| 1824 | } |
|---|
| 1825 | |
|---|
| 1826 | //--------------- |
|---|
| 1827 | pcSlice->setRefPOCList(); |
|---|
| 1828 | } |
|---|
| 1829 | |
|---|
| 1830 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
|---|
| 1831 | if(pcSlice->getSPS()->getScalingListFlag()) |
|---|
| 1832 | { |
|---|
| 1833 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
|---|
| 1834 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
|---|
| 1835 | { |
|---|
| 1836 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
|---|
| 1837 | } |
|---|
| 1838 | #if SCALINGLIST_INFERRING |
|---|
| 1839 | if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) ) |
|---|
| 1840 | #endif |
|---|
| 1841 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
|---|
| 1842 | { |
|---|
| 1843 | pcSlice->setDefaultScalingList(); |
|---|
| 1844 | } |
|---|
| 1845 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
|---|
| 1846 | m_cTrQuant.setUseScalingList(true); |
|---|
| 1847 | } |
|---|
| 1848 | else |
|---|
| 1849 | { |
|---|
| 1850 | m_cTrQuant.setFlatScalingList(); |
|---|
| 1851 | m_cTrQuant.setUseScalingList(false); |
|---|
| 1852 | } |
|---|
| 1853 | |
|---|
| 1854 | // Decode a picture |
|---|
| 1855 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
|---|
| 1856 | |
|---|
| 1857 | m_bFirstSliceInPicture = false; |
|---|
| 1858 | m_uiSliceIdx++; |
|---|
| 1859 | |
|---|
| 1860 | return false; |
|---|
| 1861 | } |
|---|
| 1862 | |
|---|
| 1863 | Void TDecTop::xDecodeVPS() |
|---|
| 1864 | { |
|---|
| 1865 | TComVPS* vps = new TComVPS(); |
|---|
| 1866 | |
|---|
| 1867 | m_cEntropyDecoder.decodeVPS( vps ); |
|---|
| 1868 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
|---|
| 1869 | } |
|---|
| 1870 | |
|---|
| 1871 | Void TDecTop::xDecodeSPS() |
|---|
| 1872 | { |
|---|
| 1873 | TComSPS* sps = new TComSPS(); |
|---|
| 1874 | #if SVC_EXTENSION |
|---|
| 1875 | sps->setLayerId(m_layerId); |
|---|
| 1876 | #if SPS_DPB_PARAMS |
|---|
| 1877 | m_cEntropyDecoder.decodeSPS( sps ); // it should be removed after macro clean up |
|---|
| 1878 | #else |
|---|
| 1879 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder ); |
|---|
| 1880 | #endif |
|---|
| 1881 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
|---|
| 1882 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
|---|
| 1883 | if(m_numLayer>0) |
|---|
| 1884 | { |
|---|
| 1885 | xInitILRP(sps); |
|---|
| 1886 | } |
|---|
| 1887 | #endif |
|---|
| 1888 | #else //SVC_EXTENSION |
|---|
| 1889 | m_cEntropyDecoder.decodeSPS( sps ); |
|---|
| 1890 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
|---|
| 1891 | #endif //SVC_EXTENSION |
|---|
| 1892 | } |
|---|
| 1893 | |
|---|
| 1894 | Void TDecTop::xDecodePPS( |
|---|
| 1895 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1896 | TCom3DAsymLUT * pc3DAsymLUT |
|---|
| 1897 | #endif |
|---|
| 1898 | ) |
|---|
| 1899 | { |
|---|
| 1900 | TComPPS* pps = new TComPPS(); |
|---|
| 1901 | |
|---|
| 1902 | #if SCALINGLIST_INFERRING |
|---|
| 1903 | pps->setLayerId( m_layerId ); |
|---|
| 1904 | #endif |
|---|
| 1905 | |
|---|
| 1906 | m_cEntropyDecoder.decodePPS( pps |
|---|
| 1907 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 1908 | , pc3DAsymLUT , m_layerId |
|---|
| 1909 | #endif |
|---|
| 1910 | ); |
|---|
| 1911 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
|---|
| 1912 | |
|---|
| 1913 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
|---|
| 1914 | { |
|---|
| 1915 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
|---|
| 1916 | m_cSliceDecoder.initCtxMem(NumCtx); |
|---|
| 1917 | for ( UInt st = 0; st < NumCtx; st++ ) |
|---|
| 1918 | { |
|---|
| 1919 | TDecSbac* ctx = NULL; |
|---|
| 1920 | ctx = new TDecSbac; |
|---|
| 1921 | ctx->init( &m_cBinCABAC ); |
|---|
| 1922 | m_cSliceDecoder.setCtxMem( ctx, st ); |
|---|
| 1923 | } |
|---|
| 1924 | } |
|---|
| 1925 | } |
|---|
| 1926 | |
|---|
| 1927 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
|---|
| 1928 | { |
|---|
| 1929 | #if SVC_EXTENSION |
|---|
| 1930 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
|---|
| 1931 | { |
|---|
| 1932 | #if RANDOM_ACCESS_SEI_FIX |
|---|
| 1933 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
|---|
| 1934 | { |
|---|
| 1935 | return; |
|---|
| 1936 | } |
|---|
| 1937 | #endif |
|---|
| 1938 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1939 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1940 | #else |
|---|
| 1941 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1942 | #endif |
|---|
| 1943 | } |
|---|
| 1944 | else |
|---|
| 1945 | { |
|---|
| 1946 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1947 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1948 | #else |
|---|
| 1949 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1950 | #endif |
|---|
| 1951 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
|---|
| 1952 | if (activeParamSets.size()>0) |
|---|
| 1953 | { |
|---|
| 1954 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
|---|
| 1955 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
|---|
| 1956 | assert(seiAps->activeSeqParameterSetId.size()>0); |
|---|
| 1957 | if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) |
|---|
| 1958 | { |
|---|
| 1959 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
|---|
| 1960 | } |
|---|
| 1961 | } |
|---|
| 1962 | #if Q0074_SEI_COLOR_MAPPING |
|---|
| 1963 | m_ColorMapping->setColorMapping( m_SEIs ); |
|---|
| 1964 | #endif |
|---|
| 1965 | } |
|---|
| 1966 | #else |
|---|
| 1967 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
|---|
| 1968 | { |
|---|
| 1969 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1970 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1971 | #else |
|---|
| 1972 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1973 | #endif |
|---|
| 1974 | } |
|---|
| 1975 | else |
|---|
| 1976 | { |
|---|
| 1977 | #if LAYERS_NOT_PRESENT_SEI |
|---|
| 1978 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1979 | #else |
|---|
| 1980 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
|---|
| 1981 | #endif |
|---|
| 1982 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
|---|
| 1983 | if (activeParamSets.size()>0) |
|---|
| 1984 | { |
|---|
| 1985 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
|---|
| 1986 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
|---|
| 1987 | assert(seiAps->activeSeqParameterSetId.size()>0); |
|---|
| 1988 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] )) |
|---|
| 1989 | { |
|---|
| 1990 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
|---|
| 1991 | } |
|---|
| 1992 | } |
|---|
| 1993 | } |
|---|
| 1994 | #endif |
|---|
| 1995 | } |
|---|
| 1996 | |
|---|
| 1997 | #if SVC_EXTENSION |
|---|
| 1998 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
|---|
| 1999 | #else |
|---|
| 2000 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
|---|
| 2001 | #endif |
|---|
| 2002 | { |
|---|
| 2003 | // Initialize entropy decoder |
|---|
| 2004 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
|---|
| 2005 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
|---|
| 2006 | |
|---|
| 2007 | #if O0137_MAX_LAYERID |
|---|
| 2008 | // ignore any NAL units with nuh_layer_id == 63 |
|---|
| 2009 | if (nalu.m_layerId == 63 ) |
|---|
| 2010 | { |
|---|
| 2011 | return false; |
|---|
| 2012 | } |
|---|
| 2013 | #endif |
|---|
| 2014 | switch (nalu.m_nalUnitType) |
|---|
| 2015 | { |
|---|
| 2016 | case NAL_UNIT_VPS: |
|---|
| 2017 | #if VPS_NUH_LAYER_ID |
|---|
| 2018 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
|---|
| 2019 | #endif |
|---|
| 2020 | xDecodeVPS(); |
|---|
| 2021 | #if AVC_BASE |
|---|
| 2022 | if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
|---|
| 2023 | { |
|---|
| 2024 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
|---|
| 2025 | { |
|---|
| 2026 | printf( "Base layer YUV input reading error\n" ); |
|---|
| 2027 | exit(EXIT_FAILURE); |
|---|
| 2028 | } |
|---|
| 2029 | #if AVC_SYNTAX |
|---|
| 2030 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
|---|
| 2031 | { |
|---|
| 2032 | printf( "Base layer syntax input reading error\n" ); |
|---|
| 2033 | exit(EXIT_FAILURE); |
|---|
| 2034 | } |
|---|
| 2035 | #endif |
|---|
| 2036 | } |
|---|
| 2037 | else |
|---|
| 2038 | { |
|---|
| 2039 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
|---|
| 2040 | cListPic->clear(); |
|---|
| 2041 | } |
|---|
| 2042 | #endif |
|---|
| 2043 | return false; |
|---|
| 2044 | |
|---|
| 2045 | case NAL_UNIT_SPS: |
|---|
| 2046 | xDecodeSPS(); |
|---|
| 2047 | return false; |
|---|
| 2048 | |
|---|
| 2049 | case NAL_UNIT_PPS: |
|---|
| 2050 | xDecodePPS( |
|---|
| 2051 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 2052 | &m_c3DAsymLUTPPS |
|---|
| 2053 | #endif |
|---|
| 2054 | ); |
|---|
| 2055 | return false; |
|---|
| 2056 | |
|---|
| 2057 | case NAL_UNIT_PREFIX_SEI: |
|---|
| 2058 | case NAL_UNIT_SUFFIX_SEI: |
|---|
| 2059 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
|---|
| 2060 | return false; |
|---|
| 2061 | |
|---|
| 2062 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
|---|
| 2063 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
|---|
| 2064 | case NAL_UNIT_CODED_SLICE_TSA_R: |
|---|
| 2065 | case NAL_UNIT_CODED_SLICE_TSA_N: |
|---|
| 2066 | case NAL_UNIT_CODED_SLICE_STSA_R: |
|---|
| 2067 | case NAL_UNIT_CODED_SLICE_STSA_N: |
|---|
| 2068 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
|---|
| 2069 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
|---|
| 2070 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
|---|
| 2071 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
|---|
| 2072 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
|---|
| 2073 | case NAL_UNIT_CODED_SLICE_CRA: |
|---|
| 2074 | case NAL_UNIT_CODED_SLICE_RADL_N: |
|---|
| 2075 | case NAL_UNIT_CODED_SLICE_RADL_R: |
|---|
| 2076 | case NAL_UNIT_CODED_SLICE_RASL_N: |
|---|
| 2077 | case NAL_UNIT_CODED_SLICE_RASL_R: |
|---|
| 2078 | #if SVC_EXTENSION |
|---|
| 2079 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
|---|
| 2080 | #else |
|---|
| 2081 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
|---|
| 2082 | #endif |
|---|
| 2083 | break; |
|---|
| 2084 | |
|---|
| 2085 | case NAL_UNIT_EOS: |
|---|
| 2086 | m_associatedIRAPType = NAL_UNIT_INVALID; |
|---|
| 2087 | m_pocCRA = 0; |
|---|
| 2088 | m_pocRandomAccess = MAX_INT; |
|---|
| 2089 | m_prevPOC = MAX_INT; |
|---|
| 2090 | m_bFirstSliceInPicture = true; |
|---|
| 2091 | m_bFirstSliceInSequence = true; |
|---|
| 2092 | m_prevSliceSkipped = false; |
|---|
| 2093 | m_skippedPOC = 0; |
|---|
| 2094 | return false; |
|---|
| 2095 | |
|---|
| 2096 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
|---|
| 2097 | // TODO: process AU delimiter |
|---|
| 2098 | return false; |
|---|
| 2099 | |
|---|
| 2100 | case NAL_UNIT_EOB: |
|---|
| 2101 | #if P0130_EOB |
|---|
| 2102 | //Check layer id of the nalu. if it is not 0, give a warning message. |
|---|
| 2103 | if (nalu.m_layerId > 0) |
|---|
| 2104 | { |
|---|
| 2105 | printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" ); |
|---|
| 2106 | } |
|---|
| 2107 | #endif |
|---|
| 2108 | return false; |
|---|
| 2109 | |
|---|
| 2110 | case NAL_UNIT_FILLER_DATA: |
|---|
| 2111 | return false; |
|---|
| 2112 | |
|---|
| 2113 | case NAL_UNIT_RESERVED_VCL_N10: |
|---|
| 2114 | case NAL_UNIT_RESERVED_VCL_R11: |
|---|
| 2115 | case NAL_UNIT_RESERVED_VCL_N12: |
|---|
| 2116 | case NAL_UNIT_RESERVED_VCL_R13: |
|---|
| 2117 | case NAL_UNIT_RESERVED_VCL_N14: |
|---|
| 2118 | case NAL_UNIT_RESERVED_VCL_R15: |
|---|
| 2119 | |
|---|
| 2120 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
|---|
| 2121 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
|---|
| 2122 | |
|---|
| 2123 | case NAL_UNIT_RESERVED_VCL24: |
|---|
| 2124 | case NAL_UNIT_RESERVED_VCL25: |
|---|
| 2125 | case NAL_UNIT_RESERVED_VCL26: |
|---|
| 2126 | case NAL_UNIT_RESERVED_VCL27: |
|---|
| 2127 | case NAL_UNIT_RESERVED_VCL28: |
|---|
| 2128 | case NAL_UNIT_RESERVED_VCL29: |
|---|
| 2129 | case NAL_UNIT_RESERVED_VCL30: |
|---|
| 2130 | case NAL_UNIT_RESERVED_VCL31: |
|---|
| 2131 | |
|---|
| 2132 | case NAL_UNIT_RESERVED_NVCL41: |
|---|
| 2133 | case NAL_UNIT_RESERVED_NVCL42: |
|---|
| 2134 | case NAL_UNIT_RESERVED_NVCL43: |
|---|
| 2135 | case NAL_UNIT_RESERVED_NVCL44: |
|---|
| 2136 | case NAL_UNIT_RESERVED_NVCL45: |
|---|
| 2137 | case NAL_UNIT_RESERVED_NVCL46: |
|---|
| 2138 | case NAL_UNIT_RESERVED_NVCL47: |
|---|
| 2139 | case NAL_UNIT_UNSPECIFIED_48: |
|---|
| 2140 | case NAL_UNIT_UNSPECIFIED_49: |
|---|
| 2141 | case NAL_UNIT_UNSPECIFIED_50: |
|---|
| 2142 | case NAL_UNIT_UNSPECIFIED_51: |
|---|
| 2143 | case NAL_UNIT_UNSPECIFIED_52: |
|---|
| 2144 | case NAL_UNIT_UNSPECIFIED_53: |
|---|
| 2145 | case NAL_UNIT_UNSPECIFIED_54: |
|---|
| 2146 | case NAL_UNIT_UNSPECIFIED_55: |
|---|
| 2147 | case NAL_UNIT_UNSPECIFIED_56: |
|---|
| 2148 | case NAL_UNIT_UNSPECIFIED_57: |
|---|
| 2149 | case NAL_UNIT_UNSPECIFIED_58: |
|---|
| 2150 | case NAL_UNIT_UNSPECIFIED_59: |
|---|
| 2151 | case NAL_UNIT_UNSPECIFIED_60: |
|---|
| 2152 | case NAL_UNIT_UNSPECIFIED_61: |
|---|
| 2153 | case NAL_UNIT_UNSPECIFIED_62: |
|---|
| 2154 | case NAL_UNIT_UNSPECIFIED_63: |
|---|
| 2155 | |
|---|
| 2156 | default: |
|---|
| 2157 | assert (0); |
|---|
| 2158 | } |
|---|
| 2159 | |
|---|
| 2160 | return false; |
|---|
| 2161 | } |
|---|
| 2162 | |
|---|
| 2163 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
|---|
| 2164 | * \param iPOCLastDisplay POC of last picture displayed |
|---|
| 2165 | * \returns true if the picture should be skipped |
|---|
| 2166 | * This function skips all TFD pictures that follow a BLA picture |
|---|
| 2167 | * in decoding order and precede it in output order. |
|---|
| 2168 | */ |
|---|
| 2169 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
|---|
| 2170 | { |
|---|
| 2171 | 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) && |
|---|
| 2172 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
|---|
| 2173 | { |
|---|
| 2174 | iPOCLastDisplay++; |
|---|
| 2175 | return true; |
|---|
| 2176 | } |
|---|
| 2177 | return false; |
|---|
| 2178 | } |
|---|
| 2179 | |
|---|
| 2180 | /** Function for checking if picture should be skipped because of random access |
|---|
| 2181 | * \param iSkipFrame skip frame counter |
|---|
| 2182 | * \param iPOCLastDisplay POC of last picture displayed |
|---|
| 2183 | * \returns true if the picture shold be skipped in the random access. |
|---|
| 2184 | * This function checks the skipping of pictures in the case of -s option random access. |
|---|
| 2185 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
|---|
| 2186 | * It also checks the type of Nal unit type at the random access point. |
|---|
| 2187 | * 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. |
|---|
| 2188 | * If the random access point is IDR all pictures after the random access point are decoded. |
|---|
| 2189 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
|---|
| 2190 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
|---|
| 2191 | * access point there is no guarantee that the decoder will not crash. |
|---|
| 2192 | */ |
|---|
| 2193 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
|---|
| 2194 | { |
|---|
| 2195 | if (iSkipFrame) |
|---|
| 2196 | { |
|---|
| 2197 | iSkipFrame--; // decrement the counter |
|---|
| 2198 | return true; |
|---|
| 2199 | } |
|---|
| 2200 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
|---|
| 2201 | { |
|---|
| 2202 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
|---|
| 2203 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
|---|
| 2204 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
|---|
| 2205 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
|---|
| 2206 | { |
|---|
| 2207 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
|---|
| 2208 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
|---|
| 2209 | } |
|---|
| 2210 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
|---|
| 2211 | { |
|---|
| 2212 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
|---|
| 2213 | } |
|---|
| 2214 | else |
|---|
| 2215 | { |
|---|
| 2216 | static Bool warningMessage = false; |
|---|
| 2217 | if(!warningMessage) |
|---|
| 2218 | { |
|---|
| 2219 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
|---|
| 2220 | warningMessage = true; |
|---|
| 2221 | } |
|---|
| 2222 | return true; |
|---|
| 2223 | } |
|---|
| 2224 | } |
|---|
| 2225 | // skip the reordered pictures, if necessary |
|---|
| 2226 | 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)) |
|---|
| 2227 | { |
|---|
| 2228 | iPOCLastDisplay++; |
|---|
| 2229 | return true; |
|---|
| 2230 | } |
|---|
| 2231 | // if we reach here, then the picture is not skipped. |
|---|
| 2232 | return false; |
|---|
| 2233 | } |
|---|
| 2234 | |
|---|
| 2235 | #if SVC_EXTENSION |
|---|
| 2236 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 2237 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
|---|
| 2238 | { |
|---|
| 2239 | TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS(); |
|---|
| 2240 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
|---|
| 2241 | { |
|---|
| 2242 | return (TDecTop *)getLayerDec( 0 ); |
|---|
| 2243 | } |
|---|
| 2244 | |
|---|
| 2245 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
|---|
| 2246 | } |
|---|
| 2247 | #endif |
|---|
| 2248 | |
|---|
| 2249 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 2250 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
|---|
| 2251 | { |
|---|
| 2252 | for(UInt layer = 0; layer < m_numLayer; layer++) |
|---|
| 2253 | { |
|---|
| 2254 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
|---|
| 2255 | decTop->setNumSamplePredRefLayers(0); |
|---|
| 2256 | decTop->setNumMotionPredRefLayers(0); |
|---|
| 2257 | decTop->setNumDirectRefLayers(0); |
|---|
| 2258 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
|---|
| 2259 | { |
|---|
| 2260 | decTop->setSamplePredEnabledFlag(i, false); |
|---|
| 2261 | decTop->setMotionPredEnabledFlag(i, false); |
|---|
| 2262 | decTop->setSamplePredRefLayerId(i, 0); |
|---|
| 2263 | decTop->setMotionPredRefLayerId(i, 0); |
|---|
| 2264 | } |
|---|
| 2265 | for(Int j = 0; j < layer; j++) |
|---|
| 2266 | { |
|---|
| 2267 | if (vps->getDirectDependencyFlag(layer, j)) |
|---|
| 2268 | { |
|---|
| 2269 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
|---|
| 2270 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
|---|
| 2271 | |
|---|
| 2272 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
|---|
| 2273 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
|---|
| 2274 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
|---|
| 2275 | |
|---|
| 2276 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
|---|
| 2277 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
|---|
| 2278 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
|---|
| 2279 | } |
|---|
| 2280 | } |
|---|
| 2281 | } |
|---|
| 2282 | for( Int i = 1; i < m_numLayer; i++ ) |
|---|
| 2283 | { |
|---|
| 2284 | Int mIdx = 0, sIdx = 0; |
|---|
| 2285 | Int iNuhLId = vps->getLayerIdInNuh(i); |
|---|
| 2286 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
|---|
| 2287 | for ( Int j = 0; j < i; j++ ) |
|---|
| 2288 | { |
|---|
| 2289 | if (decTop->getMotionPredEnabledFlag(j)) |
|---|
| 2290 | { |
|---|
| 2291 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
|---|
| 2292 | } |
|---|
| 2293 | if (decTop->getSamplePredEnabledFlag(j)) |
|---|
| 2294 | { |
|---|
| 2295 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
|---|
| 2296 | } |
|---|
| 2297 | } |
|---|
| 2298 | } |
|---|
| 2299 | } |
|---|
| 2300 | |
|---|
| 2301 | #endif |
|---|
| 2302 | |
|---|
| 2303 | #if OUTPUT_LAYER_SET_INDEX |
|---|
| 2304 | Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps) |
|---|
| 2305 | { |
|---|
| 2306 | CommonDecoderParams* params = this->getCommonDecoderParams(); |
|---|
| 2307 | |
|---|
| 2308 | assert( params->getTargetLayerId() < vps->getMaxLayers() ); |
|---|
| 2309 | |
|---|
| 2310 | if( params->getValueCheckedFlag() ) |
|---|
| 2311 | { |
|---|
| 2312 | return; // Already checked |
|---|
| 2313 | } |
|---|
| 2314 | if( params->getTargetOutputLayerSetIdx() == -1 ) // Output layer set index not specified |
|---|
| 2315 | { |
|---|
| 2316 | Bool layerSetMatchFound = false; |
|---|
| 2317 | // Output layer set index not assigned. |
|---|
| 2318 | // Based on the value of targetLayerId, check if any of the output layer matches |
|---|
| 2319 | // Currently, the target layer ID in the encoder assumes that all the layers are decoded |
|---|
| 2320 | // Check if any of the output layer sets match this description |
|---|
| 2321 | for(Int i = 0; i < vps->getNumOutputLayerSets(); i++) |
|---|
| 2322 | { |
|---|
| 2323 | Bool layerSetMatchFlag = true; |
|---|
| 2324 | Int layerSetIdx = vps->getOutputLayerSetIdx( i ); |
|---|
| 2325 | if( vps->getNumLayersInIdList( layerSetIdx ) == params->getTargetLayerId() + 1 ) |
|---|
| 2326 | { |
|---|
| 2327 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
|---|
| 2328 | { |
|---|
| 2329 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
|---|
| 2330 | { |
|---|
| 2331 | layerSetMatchFlag = false; |
|---|
| 2332 | break; |
|---|
| 2333 | } |
|---|
| 2334 | } |
|---|
| 2335 | } |
|---|
| 2336 | else |
|---|
| 2337 | { |
|---|
| 2338 | layerSetMatchFlag = false; |
|---|
| 2339 | } |
|---|
| 2340 | |
|---|
| 2341 | if( layerSetMatchFlag ) // Potential output layer set candidate found |
|---|
| 2342 | { |
|---|
| 2343 | // If target dec layer ID list is also included - check if they match |
|---|
| 2344 | if( params->getTargetDecLayerIdSet() ) |
|---|
| 2345 | { |
|---|
| 2346 | if( params->getTargetDecLayerIdSet()->size() ) |
|---|
| 2347 | { |
|---|
| 2348 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
|---|
| 2349 | { |
|---|
| 2350 | if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j ))) |
|---|
| 2351 | { |
|---|
| 2352 | layerSetMatchFlag = false; |
|---|
| 2353 | } |
|---|
| 2354 | } |
|---|
| 2355 | } |
|---|
| 2356 | } |
|---|
| 2357 | if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present |
|---|
| 2358 | { |
|---|
| 2359 | // Match found |
|---|
| 2360 | layerSetMatchFound = true; |
|---|
| 2361 | params->setTargetOutputLayerSetIdx( i ); |
|---|
| 2362 | params->setValueCheckedFlag( true ); |
|---|
| 2363 | break; |
|---|
| 2364 | } |
|---|
| 2365 | } |
|---|
| 2366 | } |
|---|
| 2367 | assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist |
|---|
| 2368 | } |
|---|
| 2369 | else // Output layer set index is assigned - check if the values match |
|---|
| 2370 | { |
|---|
| 2371 | // Check if the target decoded layer is the highest layer in the list |
|---|
| 2372 | assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() ); |
|---|
| 2373 | Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() ); // Index to the layer set |
|---|
| 2374 | assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); |
|---|
| 2375 | |
|---|
| 2376 | Bool layerSetMatchFlag = true; |
|---|
| 2377 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
|---|
| 2378 | { |
|---|
| 2379 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
|---|
| 2380 | { |
|---|
| 2381 | layerSetMatchFlag = false; |
|---|
| 2382 | break; |
|---|
| 2383 | } |
|---|
| 2384 | } |
|---|
| 2385 | |
|---|
| 2386 | assert(layerSetMatchFlag); // Signaled output layer set index does not match targetOutputLayerId. |
|---|
| 2387 | |
|---|
| 2388 | // Check if the targetdeclayerIdlist matches the output layer set |
|---|
| 2389 | if( params->getTargetDecLayerIdSet() ) |
|---|
| 2390 | { |
|---|
| 2391 | if( params->getTargetDecLayerIdSet()->size() ) |
|---|
| 2392 | { |
|---|
| 2393 | for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++) |
|---|
| 2394 | { |
|---|
| 2395 | assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i ))); |
|---|
| 2396 | } |
|---|
| 2397 | } |
|---|
| 2398 | } |
|---|
| 2399 | params->setValueCheckedFlag( true ); |
|---|
| 2400 | |
|---|
| 2401 | } |
|---|
| 2402 | } |
|---|
| 2403 | #endif |
|---|
| 2404 | #if RESOLUTION_BASED_DPB |
|---|
| 2405 | Void TDecTop::assignSubDpbs(TComVPS *vps) |
|---|
| 2406 | { |
|---|
| 2407 | if( m_subDpbIdx == -1 ) // Sub-DPB index is not already assigned |
|---|
| 2408 | { |
|---|
| 2409 | Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
|---|
| 2410 | |
|---|
| 2411 | Int layerIdx = vps->findLayerIdxInLayerSet( lsIdx, getLayerId() ); |
|---|
| 2412 | assert( layerIdx != -1 ); // Current layer should be found in the layer set. |
|---|
| 2413 | |
|---|
| 2414 | // Copy from the active VPS based on the layer ID. |
|---|
| 2415 | m_subDpbIdx = vps->getSubDpbAssigned( lsIdx, layerIdx ); |
|---|
| 2416 | } |
|---|
| 2417 | } |
|---|
| 2418 | #endif |
|---|
| 2419 | |
|---|
| 2420 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 2421 | Void TDecTop::initAsymLut(TComSlice *pcSlice) |
|---|
| 2422 | { |
|---|
| 2423 | if(m_layerId>0) |
|---|
| 2424 | { |
|---|
| 2425 | if(!m_pColorMappedPic) |
|---|
| 2426 | { |
|---|
| 2427 | Int picWidth = pcSlice->getPicWidthInLumaSamples(); |
|---|
| 2428 | Int picHeight = pcSlice->getPicHeightInLumaSamples(); |
|---|
| 2429 | m_pColorMappedPic = new TComPicYuv; |
|---|
| 2430 | m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); |
|---|
| 2431 | } |
|---|
| 2432 | } |
|---|
| 2433 | } |
|---|
| 2434 | #endif |
|---|
| 2435 | |
|---|
| 2436 | #endif //SVC_EXTENSION |
|---|
| 2437 | |
|---|
| 2438 | #if Q0074_SEI_COLOR_MAPPING |
|---|
| 2439 | TDecColorMapping::TDecColorMapping() |
|---|
| 2440 | { |
|---|
| 2441 | m_pcColorMappingPic[0] = NULL; |
|---|
| 2442 | m_pcColorMappingPic[1] = NULL; |
|---|
| 2443 | |
|---|
| 2444 | m_colorMapCancelFlag = true; |
|---|
| 2445 | |
|---|
| 2446 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2447 | { |
|---|
| 2448 | m_lut1d_computed[i] = false; |
|---|
| 2449 | m_lut1d_input[i] = NULL; |
|---|
| 2450 | m_coded_input_pivot_value[i] = NULL; |
|---|
| 2451 | m_target_input_pivot_value[i] = NULL; |
|---|
| 2452 | } |
|---|
| 2453 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2454 | { |
|---|
| 2455 | m_lut1d_output[i] = NULL; |
|---|
| 2456 | m_coded_output_pivot_value[i] = NULL; |
|---|
| 2457 | m_target_output_pivot_value[i] = NULL; |
|---|
| 2458 | } |
|---|
| 2459 | } |
|---|
| 2460 | |
|---|
| 2461 | TDecColorMapping::~TDecColorMapping() |
|---|
| 2462 | { |
|---|
| 2463 | if ( m_pcColorMappingPic[0] ) delete m_pcColorMappingPic[0]; |
|---|
| 2464 | if ( m_pcColorMappingPic[1] ) delete m_pcColorMappingPic[1]; |
|---|
| 2465 | |
|---|
| 2466 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2467 | { |
|---|
| 2468 | if ( m_lut1d_input[i] ) delete m_lut1d_input[i]; |
|---|
| 2469 | if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i]; |
|---|
| 2470 | if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i]; |
|---|
| 2471 | } |
|---|
| 2472 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2473 | { |
|---|
| 2474 | if ( m_lut1d_output[i] ) delete m_lut1d_output[i]; |
|---|
| 2475 | if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i]; |
|---|
| 2476 | if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i]; |
|---|
| 2477 | } |
|---|
| 2478 | } |
|---|
| 2479 | |
|---|
| 2480 | Void TDecColorMapping::setColorMapping( SEIMessages m_SEIs ) |
|---|
| 2481 | { |
|---|
| 2482 | SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ; |
|---|
| 2483 | SEIColorMappingInfo *seiColorMappingInfo = NULL; |
|---|
| 2484 | if (colorMappingInfo.size() !=0) |
|---|
| 2485 | { |
|---|
| 2486 | seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin()); |
|---|
| 2487 | |
|---|
| 2488 | m_colorMapId = seiColorMappingInfo->m_colorMapId; |
|---|
| 2489 | m_colorMapCancelFlag = seiColorMappingInfo->m_colorMapCancelFlag; |
|---|
| 2490 | if( !m_colorMapCancelFlag ) |
|---|
| 2491 | { |
|---|
| 2492 | m_colorMapPersistenceFlag = seiColorMappingInfo->m_colorMapPersistenceFlag; |
|---|
| 2493 | m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag; |
|---|
| 2494 | m_colorMap_video_full_range_flag = seiColorMappingInfo->m_colorMap_video_full_range_flag; |
|---|
| 2495 | m_colorMap_primaries = seiColorMappingInfo->m_colorMap_primaries; |
|---|
| 2496 | m_colorMap_transfer_characteristics = seiColorMappingInfo->m_colorMap_transfer_characteristics; |
|---|
| 2497 | m_colorMap_matrix_coeffs = seiColorMappingInfo->m_colorMap_matrix_coeffs; |
|---|
| 2498 | m_colorMapModelId = seiColorMappingInfo->m_colorMapModelId; |
|---|
| 2499 | |
|---|
| 2500 | m_colour_map_coded_data_bit_depth = seiColorMappingInfo->m_colour_map_coded_data_bit_depth; |
|---|
| 2501 | m_colour_map_target_bit_depth = seiColorMappingInfo->m_colour_map_target_bit_depth; |
|---|
| 2502 | |
|---|
| 2503 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2504 | { |
|---|
| 2505 | m_num_input_pivots[i] = seiColorMappingInfo->m_num_input_pivots[i]; |
|---|
| 2506 | if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i]; |
|---|
| 2507 | if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i]; |
|---|
| 2508 | m_coded_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ]; |
|---|
| 2509 | m_target_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ]; |
|---|
| 2510 | for( Int j=0 ; j<m_num_input_pivots[i] ; j++ ) |
|---|
| 2511 | { |
|---|
| 2512 | m_coded_input_pivot_value[i][j] = seiColorMappingInfo->m_coded_input_pivot_value[i][j]; |
|---|
| 2513 | m_target_input_pivot_value[i][j] = seiColorMappingInfo->m_target_input_pivot_value[i][j]; |
|---|
| 2514 | } |
|---|
| 2515 | } |
|---|
| 2516 | |
|---|
| 2517 | m_matrix_flag = seiColorMappingInfo->m_matrix_flag; |
|---|
| 2518 | m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ; |
|---|
| 2519 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2520 | { |
|---|
| 2521 | for( Int j=0 ; j<3 ; j++ ) |
|---|
| 2522 | { |
|---|
| 2523 | m_matrix_coef[i][j] = seiColorMappingInfo->m_matrix_coef[i][j]; |
|---|
| 2524 | } |
|---|
| 2525 | } |
|---|
| 2526 | |
|---|
| 2527 | for( Int i=0 ; i<3 ; i++ ) |
|---|
| 2528 | { |
|---|
| 2529 | m_num_output_pivots[i] = seiColorMappingInfo->m_num_output_pivots[i]; |
|---|
| 2530 | if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i]; |
|---|
| 2531 | if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i]; |
|---|
| 2532 | m_coded_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ]; |
|---|
| 2533 | m_target_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ]; |
|---|
| 2534 | for( Int j=0 ; j<m_num_output_pivots[i] ; j++ ) |
|---|
| 2535 | { |
|---|
| 2536 | m_coded_output_pivot_value[i][j] = seiColorMappingInfo->m_coded_output_pivot_value[i][j]; |
|---|
| 2537 | m_target_output_pivot_value[i][j] = seiColorMappingInfo->m_target_output_pivot_value[i][j]; |
|---|
| 2538 | } |
|---|
| 2539 | } |
|---|
| 2540 | |
|---|
| 2541 | memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) ); |
|---|
| 2542 | } |
|---|
| 2543 | } |
|---|
| 2544 | |
|---|
| 2545 | } |
|---|
| 2546 | |
|---|
| 2547 | Void TDecColorMapping::setColorMapping( Int bitDepth, Int iComp ) |
|---|
| 2548 | { |
|---|
| 2549 | if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] ) |
|---|
| 2550 | { |
|---|
| 2551 | |
|---|
| 2552 | if ( m_lut1d_input[iComp] ) delete m_lut1d_input[iComp]; |
|---|
| 2553 | if ( m_lut1d_output[iComp] ) delete m_lut1d_output[iComp]; |
|---|
| 2554 | |
|---|
| 2555 | m_lut1d_input[iComp] = new Int[ 1 << bitDepth ]; |
|---|
| 2556 | m_lut1d_output[iComp] = new Int[ 1 << bitDepth ]; |
|---|
| 2557 | |
|---|
| 2558 | Int iShift = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0); |
|---|
| 2559 | Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth); |
|---|
| 2560 | |
|---|
| 2561 | for( Int k=0 ; k<(1<<bitDepth) ; k++ ) |
|---|
| 2562 | { |
|---|
| 2563 | Int iSample = k << iShift ; |
|---|
| 2564 | if( m_num_input_pivots[iComp] > 1 ) |
|---|
| 2565 | { |
|---|
| 2566 | for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ ) |
|---|
| 2567 | { |
|---|
| 2568 | Int iCodedPrev = m_coded_input_pivot_value[iComp][iPivot] << iShiftPivot; |
|---|
| 2569 | Int iCodedNext = m_coded_input_pivot_value[iComp][iPivot+1] << iShiftPivot; |
|---|
| 2570 | Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot] << iShiftPivot; |
|---|
| 2571 | Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1] << iShiftPivot; |
|---|
| 2572 | if ( iCodedPrev <= iSample && iSample < iCodedNext ) |
|---|
| 2573 | { |
|---|
| 2574 | Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ; |
|---|
| 2575 | m_lut1d_input[iComp][k] = (Int)( 0.5 + fInterpol ); |
|---|
| 2576 | iPivot = m_num_input_pivots[iComp]; // stop |
|---|
| 2577 | } |
|---|
| 2578 | } |
|---|
| 2579 | } |
|---|
| 2580 | else |
|---|
| 2581 | { |
|---|
| 2582 | m_lut1d_input[iComp][k] = k; |
|---|
| 2583 | } |
|---|
| 2584 | } |
|---|
| 2585 | |
|---|
| 2586 | iShift = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) ); |
|---|
| 2587 | Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ; |
|---|
| 2588 | iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ; |
|---|
| 2589 | for( Int k=0 ; k<(1<<bitDepth) ; k++ ) |
|---|
| 2590 | { |
|---|
| 2591 | Int iSample = k << iShift; |
|---|
| 2592 | if ( m_num_output_pivots[iComp]>1 ) |
|---|
| 2593 | { |
|---|
| 2594 | for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ ) |
|---|
| 2595 | { |
|---|
| 2596 | Int iCodedPrev = m_coded_output_pivot_value[iComp][iPivot] << iShiftPivot; |
|---|
| 2597 | Int iCodedNext = m_coded_output_pivot_value[iComp][iPivot+1] << iShiftPivot; |
|---|
| 2598 | Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot] << iShiftPivot; |
|---|
| 2599 | Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1] << iShiftPivot; |
|---|
| 2600 | if ( iCodedPrev <= iSample && iSample < iCodedNext ) |
|---|
| 2601 | { |
|---|
| 2602 | Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ; |
|---|
| 2603 | m_lut1d_output[iComp][k] = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ; |
|---|
| 2604 | iPivot = m_num_output_pivots[iComp]; // stop |
|---|
| 2605 | } |
|---|
| 2606 | } |
|---|
| 2607 | } |
|---|
| 2608 | else |
|---|
| 2609 | { |
|---|
| 2610 | m_lut1d_output[iComp][k] = k; |
|---|
| 2611 | } |
|---|
| 2612 | } |
|---|
| 2613 | |
|---|
| 2614 | m_lut1d_computed[iComp] = true; |
|---|
| 2615 | } |
|---|
| 2616 | |
|---|
| 2617 | } |
|---|
| 2618 | |
|---|
| 2619 | TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId ) |
|---|
| 2620 | { |
|---|
| 2621 | if( !m_colorMapCancelFlag ) |
|---|
| 2622 | { |
|---|
| 2623 | if( !m_pcColorMappingPic[iTop] ) |
|---|
| 2624 | { |
|---|
| 2625 | m_pcColorMappingPic[iTop] = new TComPicYuv; |
|---|
| 2626 | #if SVC_EXTENSION |
|---|
| 2627 | m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
|---|
| 2628 | #else |
|---|
| 2629 | m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
|---|
| 2630 | #endif |
|---|
| 2631 | } |
|---|
| 2632 | |
|---|
| 2633 | Int iHeight = pPicYuvRec->getHeight(); |
|---|
| 2634 | Int iWidth = pPicYuvRec->getWidth(); |
|---|
| 2635 | Int iStride = pPicYuvRec->getStride(); |
|---|
| 2636 | Int iCStride = pPicYuvRec->getCStride(); |
|---|
| 2637 | |
|---|
| 2638 | Pel* Lum0 = pPicYuvRec->getLumaAddr(); |
|---|
| 2639 | Pel* Cb0 = pPicYuvRec->getCbAddr(); |
|---|
| 2640 | Pel* Cr0 = pPicYuvRec->getCrAddr(); |
|---|
| 2641 | Pel* Lum1 = m_pcColorMappingPic[iTop]->getLumaAddr(); |
|---|
| 2642 | Pel* Cb1 = m_pcColorMappingPic[iTop]->getCbAddr(); |
|---|
| 2643 | Pel* Cr1 = m_pcColorMappingPic[iTop]->getCrAddr(); |
|---|
| 2644 | |
|---|
| 2645 | #if SVC_EXTENSION |
|---|
| 2646 | Int bitDepthY = g_bitDepthYLayer[curlayerId]; |
|---|
| 2647 | Int bitDepthC = g_bitDepthCLayer[curlayerId]; |
|---|
| 2648 | |
|---|
| 2649 | assert( g_bitDepthY == bitDepthY ); |
|---|
| 2650 | assert( g_bitDepthC == bitDepthC ); |
|---|
| 2651 | #else |
|---|
| 2652 | Int bitDepthY = g_bitDepthY; |
|---|
| 2653 | Int bitDepthC = g_bitDepthC; |
|---|
| 2654 | #endif |
|---|
| 2655 | |
|---|
| 2656 | Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ; |
|---|
| 2657 | Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ; |
|---|
| 2658 | Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1)); |
|---|
| 2659 | Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1)); |
|---|
| 2660 | |
|---|
| 2661 | Int cShift = 1 ; |
|---|
| 2662 | |
|---|
| 2663 | //Pel* LumPrev0 = Lum0; |
|---|
| 2664 | for( Int y = 0; y < iHeight ; y++ ) |
|---|
| 2665 | { |
|---|
| 2666 | Bool bDoChroma = (y % 2); |
|---|
| 2667 | for( Int x = 0; x < iWidth ; x++ ) |
|---|
| 2668 | { |
|---|
| 2669 | Int s1Y = m_lut1d_input[0][ Lum0[x] ]; |
|---|
| 2670 | Int s1U = m_lut1d_input[1][ Cb0[x>>1] ]; |
|---|
| 2671 | Int s1V = m_lut1d_input[2][ Cr0[x>>1] ]; |
|---|
| 2672 | |
|---|
| 2673 | Int s2Y, s2U, s2V; |
|---|
| 2674 | if( m_matrix_flag ) |
|---|
| 2675 | { |
|---|
| 2676 | s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift ); |
|---|
| 2677 | //s2Y = ClipBD( s2Y , bitDepthY ); |
|---|
| 2678 | s2Y = ClipY( s2Y ); |
|---|
| 2679 | Lum1[x] = m_lut1d_output[0][ s2Y ]; |
|---|
| 2680 | } |
|---|
| 2681 | else |
|---|
| 2682 | { |
|---|
| 2683 | s1Y = ( s1Y + offsetY ) >> iYShift ; |
|---|
| 2684 | //s1Y = ClipBD( s1Y , bitDepthY ); |
|---|
| 2685 | s1Y = ClipY( s1Y ); |
|---|
| 2686 | Lum1[x] = m_lut1d_output[0][ s1Y ]; |
|---|
| 2687 | } |
|---|
| 2688 | |
|---|
| 2689 | if( bDoChroma && (x%2) ) |
|---|
| 2690 | { |
|---|
| 2691 | if( m_matrix_flag ) |
|---|
| 2692 | { |
|---|
| 2693 | //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ; |
|---|
| 2694 | //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ; |
|---|
| 2695 | s1Y = m_lut1d_input[0][ Lum0[x] ]; |
|---|
| 2696 | |
|---|
| 2697 | s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ; |
|---|
| 2698 | s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ; |
|---|
| 2699 | //s2U = ClipBD( s2U , bitDepthC ); |
|---|
| 2700 | //s2V = ClipBD( s2V , bitDepthC ); |
|---|
| 2701 | s2U = ClipC( s2U ); |
|---|
| 2702 | s2V = ClipC( s2V ); |
|---|
| 2703 | Cb1[x>>cShift] = m_lut1d_output[1][ s2U ]; |
|---|
| 2704 | Cr1[x>>cShift] = m_lut1d_output[2][ s2V ]; |
|---|
| 2705 | } |
|---|
| 2706 | else |
|---|
| 2707 | { |
|---|
| 2708 | s1U = ( s1U + offsetC ) >> iCShift ; |
|---|
| 2709 | s1V = ( s1V + offsetC ) >> iCShift ; |
|---|
| 2710 | //s1U = ClipBD( s1U , bitDepthC ); |
|---|
| 2711 | //s1V = ClipBD( s1V , bitDepthC ); |
|---|
| 2712 | s1U = ClipC( s1U ); |
|---|
| 2713 | s1V = ClipC( s1V ); |
|---|
| 2714 | Cb1[x>>cShift] = m_lut1d_output[1][ s1U ]; |
|---|
| 2715 | Cr1[x>>cShift] = m_lut1d_output[2][ s1V ]; |
|---|
| 2716 | } |
|---|
| 2717 | } |
|---|
| 2718 | |
|---|
| 2719 | } |
|---|
| 2720 | |
|---|
| 2721 | //LumPrev0 = Lum0; |
|---|
| 2722 | Lum0 += iStride; |
|---|
| 2723 | Lum1 += iStride; |
|---|
| 2724 | if( bDoChroma ) |
|---|
| 2725 | { |
|---|
| 2726 | Cb0 += iCStride; |
|---|
| 2727 | Cr0 += iCStride; |
|---|
| 2728 | Cb1 += iCStride; |
|---|
| 2729 | Cr1 += iCStride; |
|---|
| 2730 | } |
|---|
| 2731 | } |
|---|
| 2732 | |
|---|
| 2733 | return m_pcColorMappingPic[iTop]; |
|---|
| 2734 | } |
|---|
| 2735 | |
|---|
| 2736 | return pPicYuvRec; |
|---|
| 2737 | } |
|---|
| 2738 | #endif |
|---|
| 2739 | |
|---|
| 2740 | //! \} |
|---|