[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TDecSlice.cpp |
---|
| 35 | \brief slice decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecSlice.h" |
---|
| 39 | |
---|
| 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
| 43 | #if SVC_EXTENSION |
---|
| 44 | ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS); |
---|
| 45 | #endif |
---|
| 46 | |
---|
| 47 | ////////////////////////////////////////////////////////////////////// |
---|
| 48 | // Construction/Destruction |
---|
| 49 | ////////////////////////////////////////////////////////////////////// |
---|
| 50 | |
---|
| 51 | TDecSlice::TDecSlice() |
---|
| 52 | { |
---|
| 53 | m_pcBufferSbacDecoders = NULL; |
---|
| 54 | m_pcBufferBinCABACs = NULL; |
---|
| 55 | m_pcBufferLowLatSbacDecoders = NULL; |
---|
| 56 | m_pcBufferLowLatBinCABACs = NULL; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | TDecSlice::~TDecSlice() |
---|
| 60 | { |
---|
| 61 | for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++) |
---|
| 62 | { |
---|
| 63 | delete (*i); |
---|
| 64 | } |
---|
| 65 | CTXMem.clear(); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | Void TDecSlice::initCtxMem( UInt i ) |
---|
| 69 | { |
---|
| 70 | for (std::vector<TDecSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++) |
---|
| 71 | { |
---|
| 72 | delete (*j); |
---|
| 73 | } |
---|
| 74 | CTXMem.clear(); |
---|
| 75 | CTXMem.resize(i); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | Void TDecSlice::create() |
---|
| 79 | { |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | Void TDecSlice::destroy() |
---|
| 83 | { |
---|
| 84 | if ( m_pcBufferSbacDecoders ) |
---|
| 85 | { |
---|
| 86 | delete[] m_pcBufferSbacDecoders; |
---|
| 87 | m_pcBufferSbacDecoders = NULL; |
---|
| 88 | } |
---|
| 89 | if ( m_pcBufferBinCABACs ) |
---|
| 90 | { |
---|
| 91 | delete[] m_pcBufferBinCABACs; |
---|
| 92 | m_pcBufferBinCABACs = NULL; |
---|
| 93 | } |
---|
| 94 | if ( m_pcBufferLowLatSbacDecoders ) |
---|
| 95 | { |
---|
| 96 | delete[] m_pcBufferLowLatSbacDecoders; |
---|
| 97 | m_pcBufferLowLatSbacDecoders = NULL; |
---|
| 98 | } |
---|
| 99 | if ( m_pcBufferLowLatBinCABACs ) |
---|
| 100 | { |
---|
| 101 | delete[] m_pcBufferLowLatBinCABACs; |
---|
| 102 | m_pcBufferLowLatBinCABACs = NULL; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | #if SVC_EXTENSION |
---|
| 107 | Void TDecSlice::init(TDecTop** ppcDecTop,TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder) |
---|
| 108 | { |
---|
| 109 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 110 | m_pcCuDecoder = pcCuDecoder; |
---|
| 111 | m_ppcTDecTop = ppcDecTop; |
---|
| 112 | } |
---|
| 113 | #else |
---|
| 114 | Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder) |
---|
| 115 | { |
---|
| 116 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 117 | m_pcCuDecoder = pcCuDecoder; |
---|
| 118 | } |
---|
| 119 | #endif |
---|
| 120 | |
---|
| 121 | Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders) |
---|
| 122 | { |
---|
| 123 | TComDataCU* pcCU; |
---|
| 124 | UInt uiIsLast = 0; |
---|
| 125 | Int iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()); |
---|
| 126 | Int iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder); |
---|
| 127 | |
---|
| 128 | // decoder don't need prediction & residual frame buffer |
---|
| 129 | rpcPic->setPicYuvPred( 0 ); |
---|
| 130 | rpcPic->setPicYuvResi( 0 ); |
---|
| 131 | |
---|
| 132 | #if ENC_DEC_TRACE |
---|
| 133 | g_bJustDoIt = g_bEncDecTraceEnable; |
---|
| 134 | #endif |
---|
| 135 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 136 | DTRACE_CABAC_T( "\tPOC: " ); |
---|
| 137 | DTRACE_CABAC_V( rpcPic->getPOC() ); |
---|
| 138 | DTRACE_CABAC_T( "\n" ); |
---|
| 139 | |
---|
| 140 | #if ENC_DEC_TRACE |
---|
| 141 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 142 | #endif |
---|
| 143 | |
---|
| 144 | UInt uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; |
---|
| 145 | TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); |
---|
| 146 | Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
| 147 | |
---|
| 148 | // delete decoders if already allocated in previous slice |
---|
| 149 | if (m_pcBufferSbacDecoders) |
---|
| 150 | { |
---|
| 151 | delete [] m_pcBufferSbacDecoders; |
---|
| 152 | } |
---|
| 153 | if (m_pcBufferBinCABACs) |
---|
| 154 | { |
---|
| 155 | delete [] m_pcBufferBinCABACs; |
---|
| 156 | } |
---|
| 157 | // allocate new decoders based on tile numbaer |
---|
| 158 | m_pcBufferSbacDecoders = new TDecSbac [uiTilesAcross]; |
---|
| 159 | m_pcBufferBinCABACs = new TDecBinCABAC[uiTilesAcross]; |
---|
| 160 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 161 | { |
---|
| 162 | m_pcBufferSbacDecoders[ui].init(&m_pcBufferBinCABACs[ui]); |
---|
| 163 | } |
---|
| 164 | //save init. state |
---|
| 165 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 166 | { |
---|
| 167 | m_pcBufferSbacDecoders[ui].load(pcSbacDecoder); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | // free memory if already allocated in previous call |
---|
| 171 | if (m_pcBufferLowLatSbacDecoders) |
---|
| 172 | { |
---|
| 173 | delete [] m_pcBufferLowLatSbacDecoders; |
---|
| 174 | } |
---|
| 175 | if (m_pcBufferLowLatBinCABACs) |
---|
| 176 | { |
---|
| 177 | delete [] m_pcBufferLowLatBinCABACs; |
---|
| 178 | } |
---|
| 179 | m_pcBufferLowLatSbacDecoders = new TDecSbac [uiTilesAcross]; |
---|
| 180 | m_pcBufferLowLatBinCABACs = new TDecBinCABAC[uiTilesAcross]; |
---|
| 181 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 182 | { |
---|
| 183 | m_pcBufferLowLatSbacDecoders[ui].init(&m_pcBufferLowLatBinCABACs[ui]); |
---|
| 184 | } |
---|
| 185 | //save init. state |
---|
| 186 | for (UInt ui = 0; ui < uiTilesAcross; ui++) |
---|
| 187 | { |
---|
| 188 | m_pcBufferLowLatSbacDecoders[ui].load(pcSbacDecoder); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); |
---|
| 192 | //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); |
---|
| 193 | UInt uiCol=0, uiLin=0, uiSubStrm=0; |
---|
| 194 | |
---|
| 195 | UInt uiTileCol; |
---|
| 196 | UInt uiTileStartLCU; |
---|
| 197 | UInt uiTileLCUX; |
---|
| 198 | Int iNumSubstreamsPerTile = 1; // if independent. |
---|
| 199 | Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); |
---|
| 200 | uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); |
---|
| 201 | if( depSliceSegmentsEnabled ) |
---|
| 202 | { |
---|
| 203 | if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && |
---|
| 204 | iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr()) |
---|
| 205 | { |
---|
| 206 | if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 207 | { |
---|
| 208 | uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); |
---|
| 209 | m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1] );//2.LCU |
---|
| 210 | if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) |
---|
| 211 | { |
---|
| 212 | uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
| 213 | uiCol = iStartCUAddr % uiWidthInLCUs; |
---|
| 214 | if(uiCol==uiTileLCUX) |
---|
| 215 | { |
---|
| 216 | CTXMem[0]->loadContexts(pcSbacDecoder); |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1 |
---|
| 221 | pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder); |
---|
| 222 | } |
---|
| 223 | else |
---|
| 224 | { |
---|
| 225 | if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 226 | { |
---|
| 227 | CTXMem[1]->loadContexts(pcSbacDecoder); |
---|
| 228 | } |
---|
| 229 | CTXMem[0]->loadContexts(pcSbacDecoder); |
---|
| 230 | } |
---|
| 231 | } |
---|
| 232 | for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) ) |
---|
| 233 | { |
---|
| 234 | pcCU = rpcPic->getCU( iCUAddr ); |
---|
| 235 | pcCU->initCU( rpcPic, iCUAddr ); |
---|
| 236 | uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? |
---|
| 237 | uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr(); |
---|
| 238 | uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; |
---|
| 239 | uiCol = iCUAddr % uiWidthInLCUs; |
---|
| 240 | // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture. |
---|
| 241 | uiLin = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs); |
---|
| 242 | // inherit from TR if necessary, select substream to use. |
---|
| 243 | if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) |
---|
| 244 | { |
---|
| 245 | // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. |
---|
| 246 | iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); |
---|
| 247 | uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile |
---|
| 248 | + uiLin%iNumSubstreamsPerTile; |
---|
| 249 | m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); |
---|
| 250 | // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. |
---|
| 251 | if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())) |
---|
| 252 | { |
---|
| 253 | // We'll sync if the TR is available. |
---|
| 254 | TComDataCU *pcCUUp = pcCU->getCUAbove(); |
---|
| 255 | UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); |
---|
| 256 | TComDataCU *pcCUTR = NULL; |
---|
| 257 | if ( pcCUUp && ((iCUAddr%uiWidthInCU+1) < uiWidthInCU) ) |
---|
| 258 | { |
---|
| 259 | pcCUTR = rpcPic->getCU( iCUAddr - uiWidthInCU + 1 ); |
---|
| 260 | } |
---|
| 261 | UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); |
---|
| 262 | |
---|
| 263 | if ( (true/*bEnforceSliceRestriction*/ && |
---|
| 264 | ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || |
---|
| 265 | ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) || |
---|
| 266 | ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))) |
---|
| 267 | )) |
---|
| 268 | ) |
---|
| 269 | { |
---|
| 270 | // TR not available. |
---|
| 271 | } |
---|
| 272 | else |
---|
| 273 | { |
---|
| 274 | // TR is available, we use it. |
---|
| 275 | pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] ); |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders) |
---|
| 279 | } |
---|
| 280 | else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 ) |
---|
| 281 | { |
---|
| 282 | // Set variables to appropriate values to avoid later code change. |
---|
| 283 | iNumSubstreamsPerTile = 1; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile. |
---|
| 287 | (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) |
---|
| 288 | && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU()) |
---|
| 289 | ) // !1st in frame && !1st in slice |
---|
| 290 | { |
---|
| 291 | if (pcSlice->getPPS()->getNumSubstreams() > 1) |
---|
| 292 | { |
---|
| 293 | // We're crossing into another tile, tiles are independent. |
---|
| 294 | // When tiles are independent, we have "substreams per tile". Each substream has already been terminated, and we no longer |
---|
| 295 | // have to perform it here. |
---|
| 296 | // For TILES_DECODER, there can be a header at the start of the 1st substream in a tile. These are read when the substreams |
---|
| 297 | // are extracted, not here. |
---|
| 298 | } |
---|
| 299 | else |
---|
| 300 | { |
---|
| 301 | SliceType sliceType = pcSlice->getSliceType(); |
---|
| 302 | if (pcSlice->getCabacInitFlag()) |
---|
| 303 | { |
---|
| 304 | switch (sliceType) |
---|
| 305 | { |
---|
| 306 | case P_SLICE: // change initialization table to B_SLICE intialization |
---|
| 307 | sliceType = B_SLICE; |
---|
| 308 | break; |
---|
| 309 | case B_SLICE: // change initialization table to P_SLICE intialization |
---|
| 310 | sliceType = P_SLICE; |
---|
| 311 | break; |
---|
| 312 | default : // should not occur |
---|
| 313 | assert(0); |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | m_pcEntropyDecoder->updateContextTables( sliceType, pcSlice->getSliceQp() ); |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | #if ENC_DEC_TRACE |
---|
| 322 | g_bJustDoIt = g_bEncDecTraceEnable; |
---|
| 323 | #endif |
---|
[532] | 324 | |
---|
| 325 | #if HM_CLEANUP_SAO |
---|
| 326 | if ( pcSlice->getSPS()->getUseSAO() ) |
---|
| 327 | { |
---|
| 328 | SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[iCUAddr]; |
---|
| 329 | if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) |
---|
| 330 | { |
---|
| 331 | Bool sliceEnabled[NUM_SAO_COMPONENTS]; |
---|
| 332 | sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); |
---|
| 333 | sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); |
---|
| 334 | |
---|
| 335 | Bool leftMergeAvail = false; |
---|
| 336 | Bool aboveMergeAvail= false; |
---|
| 337 | |
---|
| 338 | //merge left condition |
---|
| 339 | Int rx = (iCUAddr % uiWidthInLCUs); |
---|
| 340 | if(rx > 0) |
---|
| 341 | { |
---|
| 342 | leftMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-1); |
---|
| 343 | } |
---|
| 344 | //merge up condition |
---|
| 345 | Int ry = (iCUAddr / uiWidthInLCUs); |
---|
| 346 | if(ry > 0) |
---|
| 347 | { |
---|
| 348 | aboveMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-uiWidthInLCUs); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail); |
---|
| 352 | } |
---|
| 353 | else |
---|
| 354 | { |
---|
| 355 | saoblkParam[SAO_Y ].modeIdc = SAO_MODE_OFF; |
---|
| 356 | saoblkParam[SAO_Cb].modeIdc = SAO_MODE_OFF; |
---|
| 357 | saoblkParam[SAO_Cr].modeIdc = SAO_MODE_OFF; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | #else |
---|
[313] | 361 | if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) ) |
---|
| 362 | { |
---|
| 363 | SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam(); |
---|
| 364 | saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag(); |
---|
| 365 | if (iCUAddr == iStartCUAddr) |
---|
| 366 | { |
---|
| 367 | saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma(); |
---|
| 368 | } |
---|
| 369 | Int numCuInWidth = saoParam->numCuInWidth; |
---|
| 370 | Int cuAddrInSlice = iCUAddr - rpcPic->getPicSym()->getCUOrderMap(pcSlice->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU()); |
---|
| 371 | Int cuAddrUpInSlice = cuAddrInSlice - numCuInWidth; |
---|
| 372 | Int rx = iCUAddr % numCuInWidth; |
---|
| 373 | Int ry = iCUAddr / numCuInWidth; |
---|
| 374 | Int allowMergeLeft = 1; |
---|
| 375 | Int allowMergeUp = 1; |
---|
| 376 | if (rx!=0) |
---|
| 377 | { |
---|
| 378 | if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-1) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)) |
---|
| 379 | { |
---|
| 380 | allowMergeLeft = 0; |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | if (ry!=0) |
---|
| 384 | { |
---|
| 385 | if (rpcPic->getPicSym()->getTileIdxMap(iCUAddr-numCuInWidth) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)) |
---|
| 386 | { |
---|
| 387 | allowMergeUp = 0; |
---|
| 388 | } |
---|
| 389 | } |
---|
| 390 | pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp); |
---|
| 391 | } |
---|
| 392 | else if ( pcSlice->getSPS()->getUseSAO() ) |
---|
| 393 | { |
---|
| 394 | Int addr = pcCU->getAddr(); |
---|
| 395 | SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam(); |
---|
| 396 | for (Int cIdx=0; cIdx<3; cIdx++) |
---|
| 397 | { |
---|
| 398 | SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]); |
---|
| 399 | if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma())) |
---|
| 400 | { |
---|
| 401 | saoLcuParam->mergeUpFlag = 0; |
---|
| 402 | saoLcuParam->mergeLeftFlag = 0; |
---|
| 403 | saoLcuParam->subTypeIdx = 0; |
---|
| 404 | saoLcuParam->typeIdx = -1; |
---|
| 405 | saoLcuParam->offset[0] = 0; |
---|
| 406 | saoLcuParam->offset[1] = 0; |
---|
| 407 | saoLcuParam->offset[2] = 0; |
---|
| 408 | saoLcuParam->offset[3] = 0; |
---|
| 409 | } |
---|
| 410 | } |
---|
| 411 | } |
---|
[532] | 412 | #endif |
---|
| 413 | |
---|
[313] | 414 | m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); |
---|
| 415 | m_pcCuDecoder->decompressCU ( pcCU ); |
---|
| 416 | |
---|
| 417 | #if ENC_DEC_TRACE |
---|
| 418 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 419 | #endif |
---|
| 420 | pcSbacDecoders[uiSubStrm].load(pcSbacDecoder); |
---|
| 421 | |
---|
| 422 | if ( uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getRightEdgePosInCU() |
---|
| 423 | && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() |
---|
| 424 | && !uiIsLast ) |
---|
| 425 | { |
---|
| 426 | // Parse end_of_substream_one_bit for WPP case |
---|
| 427 | UInt binVal; |
---|
| 428 | pcSbacDecoder->parseTerminatingBit( binVal ); |
---|
| 429 | assert( binVal ); |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | //Store probabilities of second LCU in line into buffer |
---|
| 433 | if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ) |
---|
| 434 | { |
---|
| 435 | m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] ); |
---|
| 436 | } |
---|
| 437 | if( uiIsLast && depSliceSegmentsEnabled ) |
---|
| 438 | { |
---|
| 439 | if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
| 440 | { |
---|
| 441 | CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU |
---|
| 442 | } |
---|
| 443 | CTXMem[0]->loadContexts( pcSbacDecoder );//ctx end of dep.slice |
---|
| 444 | return; |
---|
| 445 | } |
---|
| 446 | } |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | ParameterSetManagerDecoder::ParameterSetManagerDecoder() |
---|
| 450 | #if SVC_EXTENSION |
---|
| 451 | : m_spsBuffer(MAX_NUM_SPS) |
---|
| 452 | , m_ppsBuffer(MAX_NUM_PPS) |
---|
| 453 | #else |
---|
| 454 | : m_vpsBuffer(MAX_NUM_VPS) |
---|
| 455 | , m_spsBuffer(MAX_NUM_SPS) |
---|
| 456 | , m_ppsBuffer(MAX_NUM_PPS) |
---|
| 457 | #endif |
---|
| 458 | { |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | ParameterSetManagerDecoder::~ParameterSetManagerDecoder() |
---|
| 462 | { |
---|
| 463 | |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | TComVPS* ParameterSetManagerDecoder::getPrefetchedVPS (Int vpsId) |
---|
| 467 | { |
---|
| 468 | if (m_vpsBuffer.getPS(vpsId) != NULL ) |
---|
| 469 | { |
---|
| 470 | return m_vpsBuffer.getPS(vpsId); |
---|
| 471 | } |
---|
| 472 | else |
---|
| 473 | { |
---|
| 474 | return getVPS(vpsId); |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | |
---|
| 479 | TComSPS* ParameterSetManagerDecoder::getPrefetchedSPS (Int spsId) |
---|
| 480 | { |
---|
| 481 | if (m_spsBuffer.getPS(spsId) != NULL ) |
---|
| 482 | { |
---|
| 483 | return m_spsBuffer.getPS(spsId); |
---|
| 484 | } |
---|
| 485 | else |
---|
| 486 | { |
---|
| 487 | return getSPS(spsId); |
---|
| 488 | } |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | TComPPS* ParameterSetManagerDecoder::getPrefetchedPPS (Int ppsId) |
---|
| 492 | { |
---|
| 493 | if (m_ppsBuffer.getPS(ppsId) != NULL ) |
---|
| 494 | { |
---|
| 495 | return m_ppsBuffer.getPS(ppsId); |
---|
| 496 | } |
---|
| 497 | else |
---|
| 498 | { |
---|
| 499 | return getPPS(ppsId); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | Void ParameterSetManagerDecoder::applyPrefetchedPS() |
---|
| 504 | { |
---|
| 505 | m_vpsMap.mergePSList(m_vpsBuffer); |
---|
| 506 | m_ppsMap.mergePSList(m_ppsBuffer); |
---|
| 507 | m_spsMap.mergePSList(m_spsBuffer); |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | //! \} |
---|