[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 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 TDecSlice.cpp |
---|
| 35 | \brief slice decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecSlice.h" |
---|
| 39 | |
---|
| 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
| 43 | #if SVC_EXTENSION |
---|
[906] | 44 | ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS); |
---|
| 45 | ParameterSetMap<TComSPS> ParameterSetManagerDecoder::m_spsBuffer(MAX_NUM_SPS); |
---|
| 46 | ParameterSetMap<TComPPS> ParameterSetManagerDecoder::m_ppsBuffer(MAX_NUM_PPS); |
---|
[313] | 47 | #endif |
---|
| 48 | |
---|
| 49 | ////////////////////////////////////////////////////////////////////// |
---|
| 50 | // Construction/Destruction |
---|
| 51 | ////////////////////////////////////////////////////////////////////// |
---|
| 52 | |
---|
| 53 | TDecSlice::TDecSlice() |
---|
| 54 | { |
---|
| 55 | m_pcBufferSbacDecoders = NULL; |
---|
| 56 | m_pcBufferBinCABACs = NULL; |
---|
| 57 | m_pcBufferLowLatSbacDecoders = NULL; |
---|
| 58 | m_pcBufferLowLatBinCABACs = NULL; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | TDecSlice::~TDecSlice() |
---|
| 62 | { |
---|
| 63 | for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++) |
---|
| 64 | { |
---|
| 65 | delete (*i); |
---|
| 66 | } |
---|
| 67 | CTXMem.clear(); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | Void TDecSlice::initCtxMem( UInt i ) |
---|
| 71 | { |
---|
| 72 | for (std::vector<TDecSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++) |
---|
| 73 | { |
---|
| 74 | delete (*j); |
---|
| 75 | } |
---|
| 76 | CTXMem.clear(); |
---|
| 77 | CTXMem.resize(i); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | Void TDecSlice::create() |
---|
| 81 | { |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | Void TDecSlice::destroy() |
---|
| 85 | { |
---|
| 86 | if ( m_pcBufferSbacDecoders ) |
---|
| 87 | { |
---|
| 88 | delete[] m_pcBufferSbacDecoders; |
---|
| 89 | m_pcBufferSbacDecoders = NULL; |
---|
| 90 | } |
---|
| 91 | if ( m_pcBufferBinCABACs ) |
---|
| 92 | { |
---|
| 93 | delete[] m_pcBufferBinCABACs; |
---|
| 94 | m_pcBufferBinCABACs = NULL; |
---|
| 95 | } |
---|
| 96 | if ( m_pcBufferLowLatSbacDecoders ) |
---|
| 97 | { |
---|
| 98 | delete[] m_pcBufferLowLatSbacDecoders; |
---|
| 99 | m_pcBufferLowLatSbacDecoders = NULL; |
---|
| 100 | } |
---|
| 101 | if ( m_pcBufferLowLatBinCABACs ) |
---|
| 102 | { |
---|
| 103 | delete[] m_pcBufferLowLatBinCABACs; |
---|
| 104 | m_pcBufferLowLatBinCABACs = NULL; |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | #if SVC_EXTENSION |
---|
[644] | 109 | Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder, UInt* saoMaxOffsetQVal) |
---|
[313] | 110 | { |
---|
| 111 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 112 | m_pcCuDecoder = pcCuDecoder; |
---|
[644] | 113 | m_saoMaxOffsetQVal = saoMaxOffsetQVal; |
---|
[313] | 114 | } |
---|
| 115 | #else |
---|
| 116 | Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder) |
---|
| 117 | { |
---|
| 118 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 119 | m_pcCuDecoder = pcCuDecoder; |
---|
| 120 | } |
---|
| 121 | #endif |
---|
| 122 | |
---|
| 123 | Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders) |
---|
| 124 | { |
---|
| 125 | TComDataCU* pcCU; |
---|
| 126 | UInt uiIsLast = 0; |
---|
| 127 | Int iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()); |
---|
| 128 | Int iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder); |
---|
| 129 | |
---|
| 130 | // decoder don't need prediction & residual frame buffer |
---|
| 131 | rpcPic->setPicYuvPred( 0 ); |
---|
| 132 | rpcPic->setPicYuvResi( 0 ); |
---|
| 133 | |
---|
| 134 | #if ENC_DEC_TRACE |
---|
| 135 | g_bJustDoIt = g_bEncDecTraceEnable; |
---|
| 136 | #endif |
---|
| 137 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 138 | DTRACE_CABAC_T( "\tPOC: " ); |
---|
| 139 | DTRACE_CABAC_V( rpcPic->getPOC() ); |
---|
| 140 | DTRACE_CABAC_T( "\n" ); |
---|
| 141 | |
---|
| 142 | #if ENC_DEC_TRACE |
---|
| 143 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 144 | #endif |
---|
| 145 | |
---|
| 146 | UInt uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; |
---|
| 147 | TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); |
---|
[906] | 148 | #if !WPP_FIX |
---|
[313] | 149 | Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
[906] | 150 | #endif |
---|
[313] | 151 | |
---|
| 152 | // delete decoders if already allocated in previous slice |
---|
| 153 | if (m_pcBufferSbacDecoders) |
---|
| 154 | { |
---|
| 155 | delete [] m_pcBufferSbacDecoders; |
---|
| 156 | } |
---|
| 157 | if (m_pcBufferBinCABACs) |
---|
| 158 | { |
---|
| 159 | delete [] m_pcBufferBinCABACs; |
---|
| 160 | } |
---|
| 161 | // allocate new decoders based on tile numbaer |
---|
| 162 | m_pcBufferSbacDecoders = new TDecSbac [uiTilesAcross]; |
---|
| 163 | m_pcBufferBinCABACs = new TDecBinCABAC[uiTilesAcross]; |
---|
| 164 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 165 | { |
---|
| 166 | m_pcBufferSbacDecoders[ui].init(&m_pcBufferBinCABACs[ui]); |
---|
| 167 | } |
---|
| 168 | //save init. state |
---|
| 169 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 170 | { |
---|
| 171 | m_pcBufferSbacDecoders[ui].load(pcSbacDecoder); |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | // free memory if already allocated in previous call |
---|
| 175 | if (m_pcBufferLowLatSbacDecoders) |
---|
| 176 | { |
---|
| 177 | delete [] m_pcBufferLowLatSbacDecoders; |
---|
| 178 | } |
---|
| 179 | if (m_pcBufferLowLatBinCABACs) |
---|
| 180 | { |
---|
| 181 | delete [] m_pcBufferLowLatBinCABACs; |
---|
| 182 | } |
---|
| 183 | m_pcBufferLowLatSbacDecoders = new TDecSbac [uiTilesAcross]; |
---|
| 184 | m_pcBufferLowLatBinCABACs = new TDecBinCABAC[uiTilesAcross]; |
---|
| 185 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 186 | { |
---|
| 187 | m_pcBufferLowLatSbacDecoders[ui].init(&m_pcBufferLowLatBinCABACs[ui]); |
---|
| 188 | } |
---|
| 189 | //save init. state |
---|
| 190 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 191 | { |
---|
| 192 | m_pcBufferLowLatSbacDecoders[ui].load(pcSbacDecoder); |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); |
---|
| 196 | //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); |
---|
[906] | 197 | |
---|
| 198 | #if WPP_FIX |
---|
| 199 | UInt uiTileCol; |
---|
| 200 | UInt uiTileLCUX; |
---|
| 201 | const Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); |
---|
| 202 | const UInt startTileIdx=rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr); |
---|
| 203 | TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(startTileIdx); |
---|
| 204 | UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); // Code tidy |
---|
| 205 | |
---|
| 206 | // The first LCU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForLCUAddr may be higher. |
---|
| 207 | // This calculates the common offset for all substreams in this slice. |
---|
| 208 | const UInt subStreamOffset=rpcPic->getSubstreamForLCUAddr(iStartCUAddr, true, pcSlice); |
---|
| 209 | #else |
---|
[313] | 210 | UInt uiCol=0, uiLin=0, uiSubStrm=0; |
---|
| 211 | |
---|
| 212 | UInt uiTileCol; |
---|
| 213 | UInt uiTileStartLCU; |
---|
| 214 | UInt uiTileLCUX; |
---|
| 215 | Int iNumSubstreamsPerTile = 1; // if independent. |
---|
| 216 | Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); |
---|
| 217 | uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); |
---|
[906] | 218 | #endif |
---|
[313] | 219 | if( depSliceSegmentsEnabled ) |
---|
| 220 | { |
---|
[906] | 221 | #if WPP_FIX |
---|
| 222 | if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && iStartCUAddr != uiTileStartLCU) // Code tidy // Is this a dependent slice segment and not the start of a tile? |
---|
| 223 | #else |
---|
[313] | 224 | if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && |
---|
| 225 | iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr()) |
---|
[906] | 226 | #endif |
---|
[313] | 227 | { |
---|
| 228 | if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 229 | { |
---|
[906] | 230 | #if WPP_FIX |
---|
| 231 | uiTileCol = startTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // Code tidy |
---|
| 232 | #else |
---|
[313] | 233 | uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); |
---|
[906] | 234 | #endif |
---|
[313] | 235 | m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1] );//2.LCU |
---|
[906] | 236 | #if WPP_FIX |
---|
| 237 | if ( pCurrentTile->getTileWidth() < 2) |
---|
| 238 | { |
---|
| 239 | CTXMem[0]->loadContexts(pcSbacDecoder); // If tile width is less than 2, need to ensure CTX states get initialised to un-adapted CABAC. Set here, to load a few lines later (!) |
---|
| 240 | } |
---|
| 241 | #else |
---|
[313] | 242 | if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) |
---|
| 243 | { |
---|
| 244 | uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
| 245 | uiCol = iStartCUAddr % uiWidthInLCUs; |
---|
| 246 | if(uiCol==uiTileLCUX) |
---|
| 247 | { |
---|
| 248 | CTXMem[0]->loadContexts(pcSbacDecoder); |
---|
| 249 | } |
---|
| 250 | } |
---|
[906] | 251 | #endif |
---|
[313] | 252 | } |
---|
| 253 | pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1 |
---|
[906] | 254 | #if WPP_FIX |
---|
| 255 | pcSbacDecoders[0].loadContexts(pcSbacDecoder); // The first substream used for the slice will always be 0. (The original code was equivalent) |
---|
| 256 | #else |
---|
[313] | 257 | pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder); |
---|
[906] | 258 | #endif |
---|
[313] | 259 | } |
---|
| 260 | else |
---|
| 261 | { |
---|
| 262 | if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 263 | { |
---|
| 264 | CTXMem[1]->loadContexts(pcSbacDecoder); |
---|
| 265 | } |
---|
| 266 | CTXMem[0]->loadContexts(pcSbacDecoder); |
---|
| 267 | } |
---|
| 268 | } |
---|
| 269 | for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) ) |
---|
| 270 | { |
---|
| 271 | pcCU = rpcPic->getCU( iCUAddr ); |
---|
| 272 | pcCU->initCU( rpcPic, iCUAddr ); |
---|
| 273 | uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? |
---|
| 274 | uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr(); |
---|
| 275 | uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
[906] | 276 | #if WPP_FIX |
---|
| 277 | UInt uiCol = iCUAddr % uiWidthInLCUs; |
---|
| 278 | UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(iCUAddr, true, pcSlice)-subStreamOffset; |
---|
| 279 | #else |
---|
[313] | 280 | uiCol = iCUAddr % uiWidthInLCUs; |
---|
| 281 | // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture. |
---|
| 282 | uiLin = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs); |
---|
[906] | 283 | #endif |
---|
[313] | 284 | // inherit from TR if necessary, select substream to use. |
---|
| 285 | if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) |
---|
| 286 | { |
---|
[906] | 287 | #if !WPP_FIX |
---|
[313] | 288 | // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. |
---|
| 289 | iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); |
---|
| 290 | uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile |
---|
| 291 | + uiLin%iNumSubstreamsPerTile; |
---|
[906] | 292 | #endif |
---|
[313] | 293 | m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); |
---|
| 294 | // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. |
---|
| 295 | if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())) |
---|
| 296 | { |
---|
| 297 | // We'll sync if the TR is available. |
---|
| 298 | TComDataCU *pcCUUp = pcCU->getCUAbove(); |
---|
| 299 | UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); |
---|
| 300 | TComDataCU *pcCUTR = NULL; |
---|
| 301 | if ( pcCUUp && ((iCUAddr%uiWidthInCU+1) < uiWidthInCU) ) |
---|
| 302 | { |
---|
| 303 | pcCUTR = rpcPic->getCU( iCUAddr - uiWidthInCU + 1 ); |
---|
| 304 | } |
---|
| 305 | UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); |
---|
| 306 | |
---|
| 307 | if ( (true/*bEnforceSliceRestriction*/ && |
---|
| 308 | ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || |
---|
| 309 | ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) || |
---|
| 310 | ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))) |
---|
| 311 | )) |
---|
| 312 | ) |
---|
| 313 | { |
---|
| 314 | // TR not available. |
---|
| 315 | } |
---|
| 316 | else |
---|
| 317 | { |
---|
| 318 | // TR is available, we use it. |
---|
| 319 | pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] ); |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders) |
---|
| 323 | } |
---|
[906] | 324 | #if !WPP_FIX |
---|
[313] | 325 | else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 ) |
---|
| 326 | { |
---|
| 327 | // Set variables to appropriate values to avoid later code change. |
---|
| 328 | iNumSubstreamsPerTile = 1; |
---|
| 329 | } |
---|
[906] | 330 | #endif |
---|
[313] | 331 | |
---|
| 332 | if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile. |
---|
| 333 | (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) |
---|
| 334 | && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU()) |
---|
| 335 | ) // !1st in frame && !1st in slice |
---|
| 336 | { |
---|
| 337 | if (pcSlice->getPPS()->getNumSubstreams() > 1) |
---|
| 338 | { |
---|
| 339 | // We're crossing into another tile, tiles are independent. |
---|
| 340 | // When tiles are independent, we have "substreams per tile". Each substream has already been terminated, and we no longer |
---|
| 341 | // have to perform it here. |
---|
| 342 | // For TILES_DECODER, there can be a header at the start of the 1st substream in a tile. These are read when the substreams |
---|
| 343 | // are extracted, not here. |
---|
| 344 | } |
---|
| 345 | else |
---|
| 346 | { |
---|
| 347 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 348 | if (pcSlice->getCabacInitFlag()) |
---|
| 349 | { |
---|
| 350 | switch (sliceType) |
---|
| 351 | { |
---|
| 352 | case P_SLICE: // change initialization table to B_SLICE intialization |
---|
| 353 | sliceType = B_SLICE; |
---|
| 354 | break; |
---|
| 355 | case B_SLICE: // change initialization table to P_SLICE intialization |
---|
| 356 | sliceType = P_SLICE; |
---|
| 357 | break; |
---|
| 358 | default : // should not occur |
---|
| 359 | assert(0); |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | m_pcEntropyDecoder->updateContextTables( sliceType, pcSlice->getSliceQp() ); |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | #if ENC_DEC_TRACE |
---|
| 368 | g_bJustDoIt = g_bEncDecTraceEnable; |
---|
| 369 | #endif |
---|
[540] | 370 | |
---|
| 371 | if ( pcSlice->getSPS()->getUseSAO() ) |
---|
| 372 | { |
---|
| 373 | SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[iCUAddr]; |
---|
| 374 | if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) |
---|
| 375 | { |
---|
| 376 | Bool sliceEnabled[NUM_SAO_COMPONENTS]; |
---|
| 377 | sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); |
---|
| 378 | sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); |
---|
| 379 | |
---|
| 380 | Bool leftMergeAvail = false; |
---|
| 381 | Bool aboveMergeAvail= false; |
---|
| 382 | |
---|
| 383 | //merge left condition |
---|
| 384 | Int rx = (iCUAddr % uiWidthInLCUs); |
---|
| 385 | if(rx > 0) |
---|
| 386 | { |
---|
| 387 | leftMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-1); |
---|
| 388 | } |
---|
| 389 | //merge up condition |
---|
| 390 | Int ry = (iCUAddr / uiWidthInLCUs); |
---|
| 391 | if(ry > 0) |
---|
| 392 | { |
---|
| 393 | aboveMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-uiWidthInLCUs); |
---|
| 394 | } |
---|
[644] | 395 | #if SVC_EXTENSION |
---|
| 396 | pcSbacDecoder->parseSAOBlkParam( saoblkParam, m_saoMaxOffsetQVal, sliceEnabled, leftMergeAvail, aboveMergeAvail); |
---|
| 397 | #else |
---|
[540] | 398 | pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail); |
---|
[644] | 399 | #endif |
---|
[540] | 400 | } |
---|
| 401 | else |
---|
| 402 | { |
---|
| 403 | saoblkParam[SAO_Y ].modeIdc = SAO_MODE_OFF; |
---|
| 404 | saoblkParam[SAO_Cb].modeIdc = SAO_MODE_OFF; |
---|
| 405 | saoblkParam[SAO_Cr].modeIdc = SAO_MODE_OFF; |
---|
| 406 | } |
---|
| 407 | } |
---|
| 408 | |
---|
[313] | 409 | m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); |
---|
| 410 | m_pcCuDecoder->decompressCU ( pcCU ); |
---|
| 411 | |
---|
| 412 | #if ENC_DEC_TRACE |
---|
| 413 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 414 | #endif |
---|
| 415 | pcSbacDecoders[uiSubStrm].load(pcSbacDecoder); |
---|
| 416 | |
---|
| 417 | if ( uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getRightEdgePosInCU() |
---|
| 418 | && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() |
---|
| 419 | && !uiIsLast ) |
---|
| 420 | { |
---|
| 421 | // Parse end_of_substream_one_bit for WPP case |
---|
| 422 | UInt binVal; |
---|
| 423 | pcSbacDecoder->parseTerminatingBit( binVal ); |
---|
| 424 | assert( binVal ); |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | //Store probabilities of second LCU in line into buffer |
---|
| 428 | if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ) |
---|
| 429 | { |
---|
| 430 | m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] ); |
---|
| 431 | } |
---|
| 432 | if( uiIsLast && depSliceSegmentsEnabled ) |
---|
| 433 | { |
---|
| 434 | if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 435 | { |
---|
| 436 | CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU |
---|
| 437 | } |
---|
| 438 | CTXMem[0]->loadContexts( pcSbacDecoder );//ctx end of dep.slice |
---|
| 439 | return; |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | ParameterSetManagerDecoder::ParameterSetManagerDecoder() |
---|
[906] | 445 | #if !SVC_EXTENSION |
---|
[313] | 446 | : m_vpsBuffer(MAX_NUM_VPS) |
---|
| 447 | , m_spsBuffer(MAX_NUM_SPS) |
---|
| 448 | , m_ppsBuffer(MAX_NUM_PPS) |
---|
| 449 | #endif |
---|
| 450 | { |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | ParameterSetManagerDecoder::~ParameterSetManagerDecoder() |
---|
| 454 | { |
---|
| 455 | |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | TComVPS* ParameterSetManagerDecoder::getPrefetchedVPS (Int vpsId) |
---|
| 459 | { |
---|
| 460 | if (m_vpsBuffer.getPS(vpsId) != NULL ) |
---|
| 461 | { |
---|
| 462 | return m_vpsBuffer.getPS(vpsId); |
---|
| 463 | } |
---|
| 464 | else |
---|
| 465 | { |
---|
| 466 | return getVPS(vpsId); |
---|
| 467 | } |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | |
---|
| 471 | TComSPS* ParameterSetManagerDecoder::getPrefetchedSPS (Int spsId) |
---|
| 472 | { |
---|
| 473 | if (m_spsBuffer.getPS(spsId) != NULL ) |
---|
| 474 | { |
---|
| 475 | return m_spsBuffer.getPS(spsId); |
---|
| 476 | } |
---|
| 477 | else |
---|
| 478 | { |
---|
| 479 | return getSPS(spsId); |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | TComPPS* ParameterSetManagerDecoder::getPrefetchedPPS (Int ppsId) |
---|
| 484 | { |
---|
| 485 | if (m_ppsBuffer.getPS(ppsId) != NULL ) |
---|
| 486 | { |
---|
| 487 | return m_ppsBuffer.getPS(ppsId); |
---|
| 488 | } |
---|
| 489 | else |
---|
| 490 | { |
---|
| 491 | return getPPS(ppsId); |
---|
| 492 | } |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | Void ParameterSetManagerDecoder::applyPrefetchedPS() |
---|
| 496 | { |
---|
| 497 | m_vpsMap.mergePSList(m_vpsBuffer); |
---|
| 498 | m_ppsMap.mergePSList(m_ppsBuffer); |
---|
| 499 | m_spsMap.mergePSList(m_spsBuffer); |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | //! \} |
---|