[191] | 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 TDecCu.cpp |
---|
| 35 | \brief CU decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecCu.h" |
---|
| 39 | #if SVC_EXTENSION |
---|
| 40 | #include "TDecTop.h" |
---|
| 41 | #endif |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | //! \ingroup TLibDecoder |
---|
| 45 | //! \{ |
---|
| 46 | |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | // Constructor / destructor / create / destroy |
---|
| 49 | // ==================================================================================================================== |
---|
| 50 | |
---|
| 51 | TDecCu::TDecCu() |
---|
| 52 | { |
---|
| 53 | m_ppcYuvResi = NULL; |
---|
| 54 | m_ppcYuvReco = NULL; |
---|
| 55 | m_ppcCU = NULL; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | TDecCu::~TDecCu() |
---|
| 59 | { |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | #if SVC_EXTENSION |
---|
| 63 | Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId) |
---|
| 64 | { |
---|
| 65 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 66 | m_pcTrQuant = pcTrQuant; |
---|
| 67 | m_pcPrediction = pcPrediction; |
---|
| 68 | m_ppcTDecTop = ppcDecTop; |
---|
| 69 | m_layerId = layerId; |
---|
| 70 | |
---|
| 71 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 72 | { |
---|
| 73 | m_ppcCU [ui]->setLayerId(layerId); |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | #else |
---|
| 77 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
| 78 | { |
---|
| 79 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 80 | m_pcTrQuant = pcTrQuant; |
---|
| 81 | m_pcPrediction = pcPrediction; |
---|
| 82 | } |
---|
| 83 | #endif |
---|
| 84 | |
---|
| 85 | /** |
---|
| 86 | \param uiMaxDepth total number of allowable depth |
---|
| 87 | \param uiMaxWidth largest CU width |
---|
| 88 | \param uiMaxHeight largest CU height |
---|
| 89 | */ |
---|
| 90 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
| 91 | { |
---|
| 92 | m_uiMaxDepth = uiMaxDepth+1; |
---|
| 93 | |
---|
| 94 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 95 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 96 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
| 97 | |
---|
| 98 | UInt uiNumPartitions; |
---|
| 99 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 100 | { |
---|
| 101 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
| 102 | UInt uiWidth = uiMaxWidth >> ui; |
---|
| 103 | UInt uiHeight = uiMaxHeight >> ui; |
---|
| 104 | |
---|
| 105 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
| 106 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
| 107 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | m_bDecodeDQP = false; |
---|
| 111 | |
---|
| 112 | // initialize partition order. |
---|
| 113 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 114 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
| 115 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 116 | |
---|
| 117 | // initialize conversion matrix from partition index to pel |
---|
| 118 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | Void TDecCu::destroy() |
---|
| 122 | { |
---|
| 123 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 124 | { |
---|
| 125 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
| 126 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
| 127 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
| 131 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
| 132 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | // ==================================================================================================================== |
---|
| 136 | // Public member functions |
---|
| 137 | // ==================================================================================================================== |
---|
| 138 | |
---|
| 139 | /** \param pcCU pointer of CU data |
---|
| 140 | \param ruiIsLast last data? |
---|
| 141 | */ |
---|
| 142 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
| 143 | { |
---|
| 144 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 145 | { |
---|
| 146 | setdQPFlag(true); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | // start from the top level CU |
---|
| 150 | #if SVC_EXTENSION |
---|
| 151 | pcCU->setLayerId(m_layerId); |
---|
| 152 | #endif |
---|
| 153 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | /** \param pcCU pointer of CU data |
---|
| 157 | */ |
---|
| 158 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
| 159 | { |
---|
| 160 | xDecompressCU( pcCU, 0, 0 ); |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | // ==================================================================================================================== |
---|
| 164 | // Protected member functions |
---|
| 165 | // ==================================================================================================================== |
---|
| 166 | |
---|
| 167 | /**decode end-of-slice flag |
---|
| 168 | * \param pcCU |
---|
| 169 | * \param uiAbsPartIdx |
---|
| 170 | * \param uiDepth |
---|
| 171 | * \returns Bool |
---|
| 172 | */ |
---|
| 173 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
---|
| 174 | { |
---|
| 175 | UInt uiIsLast; |
---|
| 176 | TComPic* pcPic = pcCU->getPic(); |
---|
| 177 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
| 178 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 179 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
| 180 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
| 181 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
| 182 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 183 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 184 | |
---|
| 185 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
| 186 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
| 187 | { |
---|
| 188 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
| 189 | } |
---|
| 190 | else |
---|
| 191 | { |
---|
| 192 | uiIsLast=0; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | if(uiIsLast) |
---|
| 196 | { |
---|
| 197 | if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) |
---|
| 198 | { |
---|
| 199 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 200 | } |
---|
| 201 | else |
---|
| 202 | { |
---|
| 203 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 204 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 205 | } |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | return uiIsLast>0; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | /** decode CU block recursively |
---|
| 212 | * \param pcCU |
---|
| 213 | * \param uiAbsPartIdx |
---|
| 214 | * \param uiDepth |
---|
| 215 | * \returns Void |
---|
| 216 | */ |
---|
| 217 | |
---|
| 218 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
| 219 | { |
---|
| 220 | TComPic* pcPic = pcCU->getPic(); |
---|
| 221 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 222 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
| 223 | |
---|
| 224 | Bool bBoundary = false; |
---|
| 225 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 226 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 227 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 228 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 229 | |
---|
| 230 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 231 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
| 232 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 233 | { |
---|
| 234 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 235 | } |
---|
| 236 | else |
---|
| 237 | { |
---|
| 238 | bBoundary = true; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 242 | { |
---|
| 243 | UInt uiIdx = uiAbsPartIdx; |
---|
| 244 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 245 | { |
---|
| 246 | setdQPFlag(true); |
---|
| 247 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 251 | { |
---|
| 252 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 253 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 254 | |
---|
| 255 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
| 256 | if ( bSubInSlice ) |
---|
| 257 | { |
---|
| 258 | if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 259 | { |
---|
| 260 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
| 261 | } |
---|
| 262 | else |
---|
| 263 | { |
---|
| 264 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | uiIdx += uiQNumParts; |
---|
| 269 | } |
---|
| 270 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 271 | { |
---|
| 272 | if ( getdQPFlag() ) |
---|
| 273 | { |
---|
| 274 | UInt uiQPSrcPartIdx; |
---|
| 275 | if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
| 276 | { |
---|
| 277 | uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
| 278 | } |
---|
| 279 | else |
---|
| 280 | { |
---|
| 281 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
| 282 | } |
---|
| 283 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 284 | } |
---|
| 285 | } |
---|
| 286 | return; |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 290 | { |
---|
| 291 | setdQPFlag(true); |
---|
| 292 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 296 | { |
---|
| 297 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | // decode CU mode and the partition size |
---|
| 301 | if( !pcCU->getSlice()->isIntra()) |
---|
| 302 | { |
---|
| 303 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
| 307 | { |
---|
| 308 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 309 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
| 310 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 311 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 312 | Int numValidMergeCand = 0; |
---|
| 313 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 314 | { |
---|
| 315 | uhInterDirNeighbours[ui] = 0; |
---|
| 316 | } |
---|
| 317 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
| 318 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
| 319 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 320 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
| 321 | |
---|
| 322 | TComMv cTmpMv( 0, 0 ); |
---|
| 323 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 324 | { |
---|
| 325 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 326 | { |
---|
| 327 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 328 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 329 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 330 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
| 334 | return; |
---|
| 335 | } |
---|
| 336 | #if INTRA_BL |
---|
| 337 | m_pcEntropyDecoder->decodeIntraBLFlag( pcCU, uiAbsPartIdx, 0, uiDepth ); |
---|
| 338 | if ( pcCU->isIntraBL( uiAbsPartIdx ) ) |
---|
| 339 | { |
---|
| 340 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 341 | } |
---|
| 342 | else |
---|
| 343 | { |
---|
| 344 | #endif |
---|
| 345 | |
---|
| 346 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 347 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 348 | |
---|
| 349 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 350 | { |
---|
| 351 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 352 | |
---|
| 353 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
| 354 | { |
---|
| 355 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
| 356 | return; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | #if INTRA_BL |
---|
| 360 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 361 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
| 362 | } |
---|
| 363 | #endif |
---|
| 364 | |
---|
| 365 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 366 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 367 | |
---|
| 368 | #if !INTRA_BL |
---|
| 369 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 370 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
| 371 | #endif |
---|
| 372 | |
---|
| 373 | // Coefficient decoding |
---|
| 374 | Bool bCodeDQP = getdQPFlag(); |
---|
| 375 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
| 376 | setdQPFlag( bCodeDQP ); |
---|
| 377 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
| 381 | { |
---|
| 382 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 383 | { |
---|
| 384 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 391 | { |
---|
| 392 | TComPic* pcPic = pcCU->getPic(); |
---|
| 393 | |
---|
| 394 | Bool bBoundary = false; |
---|
| 395 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 396 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 397 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 398 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 399 | |
---|
| 400 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 401 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 402 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
| 403 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 404 | { |
---|
| 405 | bBoundary = true; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 409 | { |
---|
| 410 | UInt uiNextDepth = uiDepth + 1; |
---|
| 411 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
| 412 | UInt uiIdx = uiAbsPartIdx; |
---|
| 413 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
| 414 | { |
---|
| 415 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 416 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 417 | |
---|
| 418 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
---|
| 419 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 420 | { |
---|
| 421 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | uiIdx += uiQNumParts; |
---|
| 425 | } |
---|
| 426 | return; |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | // Residual reconstruction |
---|
| 430 | m_ppcYuvResi[uiDepth]->clear(); |
---|
| 431 | |
---|
| 432 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 433 | |
---|
| 434 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
| 435 | { |
---|
| 436 | case MODE_INTER: |
---|
| 437 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
| 438 | break; |
---|
| 439 | case MODE_INTRA: |
---|
| 440 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
| 441 | break; |
---|
| 442 | #if INTRA_BL |
---|
| 443 | case MODE_INTRA_BL: |
---|
| 444 | #if NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 445 | xReconIntraBL( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 446 | #else |
---|
| 447 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 448 | #endif |
---|
| 449 | break; |
---|
| 450 | #endif |
---|
| 451 | default: |
---|
| 452 | assert(0); |
---|
| 453 | break; |
---|
| 454 | } |
---|
| 455 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
| 456 | { |
---|
| 457 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 464 | { |
---|
| 465 | |
---|
| 466 | // inter prediction |
---|
| 467 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
| 468 | |
---|
| 469 | // inter recon |
---|
| 470 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
| 471 | |
---|
| 472 | // clip for only non-zero cbp case |
---|
| 473 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
| 474 | { |
---|
| 475 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 476 | } |
---|
| 477 | else |
---|
| 478 | { |
---|
| 479 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | Void |
---|
| 484 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
| 485 | UInt uiTrDepth, |
---|
| 486 | UInt uiAbsPartIdx, |
---|
| 487 | TComYuv* pcRecoYuv, |
---|
| 488 | TComYuv* pcPredYuv, |
---|
| 489 | TComYuv* pcResiYuv ) |
---|
| 490 | { |
---|
| 491 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
| 492 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
| 493 | UInt uiStride = pcRecoYuv->getStride (); |
---|
| 494 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 495 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 496 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 497 | |
---|
| 498 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
| 499 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 500 | |
---|
| 501 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
| 502 | |
---|
| 503 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 504 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
| 505 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
| 506 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
| 507 | //===== init availability pattern ===== |
---|
| 508 | Bool bAboveAvail = false; |
---|
| 509 | Bool bLeftAvail = false; |
---|
| 510 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 511 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 512 | m_pcPrediction->getPredicBuf (), |
---|
| 513 | m_pcPrediction->getPredicBufWidth (), |
---|
| 514 | m_pcPrediction->getPredicBufHeight (), |
---|
| 515 | bAboveAvail, bLeftAvail ); |
---|
| 516 | |
---|
| 517 | //===== get prediction signal ===== |
---|
| 518 | #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 519 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
| 520 | { |
---|
| 521 | pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride ); |
---|
| 522 | } |
---|
| 523 | else |
---|
| 524 | #endif |
---|
| 525 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
| 526 | |
---|
| 527 | //===== inverse transform ===== |
---|
| 528 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
| 529 | |
---|
| 530 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
| 531 | assert(scalingListType < 6); |
---|
| 532 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
| 533 | |
---|
| 534 | |
---|
| 535 | //===== reconstruction ===== |
---|
| 536 | Pel* pPred = piPred; |
---|
| 537 | Pel* pResi = piResi; |
---|
| 538 | Pel* pReco = piReco; |
---|
| 539 | Pel* pRecIPred = piRecIPred; |
---|
| 540 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 541 | { |
---|
| 542 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 543 | { |
---|
| 544 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 545 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 546 | } |
---|
| 547 | pPred += uiStride; |
---|
| 548 | pResi += uiStride; |
---|
| 549 | pReco += uiStride; |
---|
| 550 | pRecIPred += uiRecIPredStride; |
---|
| 551 | } |
---|
| 552 | } |
---|
| 553 | |
---|
| 554 | |
---|
| 555 | Void |
---|
| 556 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
| 557 | UInt uiTrDepth, |
---|
| 558 | UInt uiAbsPartIdx, |
---|
| 559 | TComYuv* pcRecoYuv, |
---|
| 560 | TComYuv* pcPredYuv, |
---|
| 561 | TComYuv* pcResiYuv, |
---|
| 562 | UInt uiChromaId ) |
---|
| 563 | { |
---|
| 564 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
| 565 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
| 566 | |
---|
| 567 | if( uiLog2TrSize == 2 ) |
---|
| 568 | { |
---|
| 569 | assert( uiTrDepth > 0 ); |
---|
| 570 | uiTrDepth--; |
---|
| 571 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
| 572 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
| 573 | if( !bFirstQ ) |
---|
| 574 | { |
---|
| 575 | return; |
---|
| 576 | } |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
| 580 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 581 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 582 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
| 583 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 584 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 585 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 586 | |
---|
| 587 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
| 588 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 589 | |
---|
| 590 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
| 591 | |
---|
| 592 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 593 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
| 594 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 595 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
| 596 | //===== init availability pattern ===== |
---|
| 597 | Bool bAboveAvail = false; |
---|
| 598 | Bool bLeftAvail = false; |
---|
| 599 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 600 | |
---|
| 601 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 602 | m_pcPrediction->getPredicBuf (), |
---|
| 603 | m_pcPrediction->getPredicBufWidth (), |
---|
| 604 | m_pcPrediction->getPredicBufHeight (), |
---|
| 605 | bAboveAvail, bLeftAvail ); |
---|
| 606 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
| 607 | |
---|
| 608 | //===== get prediction signal ===== |
---|
| 609 | #if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 610 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
| 611 | { |
---|
| 612 | pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId ); |
---|
| 613 | } |
---|
| 614 | else |
---|
| 615 | #endif |
---|
| 616 | { |
---|
| 617 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
| 618 | { |
---|
| 619 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
| 620 | } |
---|
| 621 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | //===== inverse transform ===== |
---|
| 625 | Int curChromaQpOffset; |
---|
| 626 | if(eText == TEXT_CHROMA_U) |
---|
| 627 | { |
---|
| 628 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
| 629 | } |
---|
| 630 | else |
---|
| 631 | { |
---|
| 632 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
| 633 | } |
---|
| 634 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 635 | |
---|
| 636 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
| 637 | assert(scalingListType < 6); |
---|
| 638 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
| 639 | |
---|
| 640 | //===== reconstruction ===== |
---|
| 641 | Pel* pPred = piPred; |
---|
| 642 | Pel* pResi = piResi; |
---|
| 643 | Pel* pReco = piReco; |
---|
| 644 | Pel* pRecIPred = piRecIPred; |
---|
| 645 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 646 | { |
---|
| 647 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 648 | { |
---|
| 649 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 650 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 651 | } |
---|
| 652 | pPred += uiStride; |
---|
| 653 | pResi += uiStride; |
---|
| 654 | pReco += uiStride; |
---|
| 655 | pRecIPred += uiRecIPredStride; |
---|
| 656 | } |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | |
---|
| 660 | Void |
---|
| 661 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 662 | { |
---|
| 663 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
| 664 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
| 665 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
| 666 | |
---|
| 667 | if (pcCU->getIPCMFlag(0)) |
---|
| 668 | { |
---|
| 669 | xReconPCM( pcCU, uiDepth ); |
---|
| 670 | return; |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 674 | { |
---|
| 675 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 679 | { |
---|
| 680 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | } |
---|
| 684 | |
---|
| 685 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
| 686 | * \param pcCU pointer of current CU |
---|
| 687 | * \param uiTrDepth current tranform split depth |
---|
| 688 | * \param uiAbsPartIdx part index |
---|
| 689 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 690 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 691 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 692 | * |
---|
| 693 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
| 694 | */ |
---|
| 695 | Void |
---|
| 696 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
| 697 | UInt uiTrDepth, |
---|
| 698 | UInt uiAbsPartIdx, |
---|
| 699 | TComYuv* pcRecoYuv, |
---|
| 700 | TComYuv* pcPredYuv, |
---|
| 701 | TComYuv* pcResiYuv ) |
---|
| 702 | { |
---|
| 703 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 704 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 705 | if( uiTrMode == uiTrDepth ) |
---|
| 706 | { |
---|
| 707 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 708 | } |
---|
| 709 | else |
---|
| 710 | { |
---|
| 711 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 712 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 713 | { |
---|
| 714 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 715 | } |
---|
| 716 | } |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
| 720 | * \param pcCU pointer of current CU |
---|
| 721 | * \param uiTrDepth current tranform split depth |
---|
| 722 | * \param uiAbsPartIdx part index |
---|
| 723 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 724 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 725 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 726 | * |
---|
| 727 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
| 728 | */ |
---|
| 729 | Void |
---|
| 730 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
| 731 | UInt uiTrDepth, |
---|
| 732 | UInt uiAbsPartIdx, |
---|
| 733 | TComYuv* pcRecoYuv, |
---|
| 734 | TComYuv* pcPredYuv, |
---|
| 735 | TComYuv* pcResiYuv ) |
---|
| 736 | { |
---|
| 737 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 738 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 739 | if( uiTrMode == uiTrDepth ) |
---|
| 740 | { |
---|
| 741 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 742 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 743 | } |
---|
| 744 | else |
---|
| 745 | { |
---|
| 746 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 747 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 748 | { |
---|
| 749 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 750 | } |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 755 | { |
---|
| 756 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 757 | |
---|
| 758 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
| 759 | |
---|
| 760 | return; |
---|
| 761 | } |
---|
| 762 | |
---|
| 763 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 764 | { |
---|
| 765 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 766 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 767 | TCoeff* piCoeff; |
---|
| 768 | |
---|
| 769 | Pel* pResi; |
---|
| 770 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 771 | |
---|
| 772 | // Y |
---|
| 773 | piCoeff = pcCU->getCoeffY(); |
---|
| 774 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
| 775 | |
---|
| 776 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
| 777 | |
---|
| 778 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 779 | |
---|
| 780 | // Cb and Cr |
---|
| 781 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
| 782 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 783 | |
---|
| 784 | uiWidth >>= 1; |
---|
| 785 | uiHeight >>= 1; |
---|
| 786 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
| 787 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 788 | |
---|
| 789 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
| 790 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 791 | |
---|
| 792 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
| 793 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
| 797 | * \param pcCU pointer to current CU |
---|
| 798 | * \param uiPartIdx part index |
---|
| 799 | * \param piPCM pointer to PCM code arrays |
---|
| 800 | * \param piReco pointer to reconstructed sample arrays |
---|
| 801 | * \param uiStride stride of reconstructed sample arrays |
---|
| 802 | * \param uiWidth CU width |
---|
| 803 | * \param uiHeight CU height |
---|
| 804 | * \param ttText texture component type |
---|
| 805 | * \returns Void |
---|
| 806 | */ |
---|
| 807 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
| 808 | { |
---|
| 809 | UInt uiX, uiY; |
---|
| 810 | Pel* piPicReco; |
---|
| 811 | UInt uiPicStride; |
---|
| 812 | UInt uiPcmLeftShiftBit; |
---|
| 813 | |
---|
| 814 | if( ttText == TEXT_LUMA ) |
---|
| 815 | { |
---|
| 816 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
| 817 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 818 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 819 | } |
---|
| 820 | else |
---|
| 821 | { |
---|
| 822 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 823 | |
---|
| 824 | if( ttText == TEXT_CHROMA_U ) |
---|
| 825 | { |
---|
| 826 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 827 | } |
---|
| 828 | else |
---|
| 829 | { |
---|
| 830 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 831 | } |
---|
| 832 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 833 | } |
---|
| 834 | |
---|
| 835 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 836 | { |
---|
| 837 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 838 | { |
---|
| 839 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
| 840 | piPicReco[uiX] = piReco[uiX]; |
---|
| 841 | } |
---|
| 842 | piPCM += uiWidth; |
---|
| 843 | piReco += uiStride; |
---|
| 844 | piPicReco += uiPicStride; |
---|
| 845 | } |
---|
| 846 | } |
---|
| 847 | |
---|
| 848 | /** Function for reconstructing a PCM mode CU. |
---|
| 849 | * \param pcCU pointer to current CU |
---|
| 850 | * \param uiDepth CU Depth |
---|
| 851 | * \returns Void |
---|
| 852 | */ |
---|
| 853 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 854 | { |
---|
| 855 | // Luma |
---|
| 856 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
| 857 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
| 858 | |
---|
| 859 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
| 860 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
| 861 | |
---|
| 862 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
| 863 | |
---|
| 864 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
| 865 | |
---|
| 866 | // Cb and Cr |
---|
| 867 | UInt uiCWidth = (uiWidth>>1); |
---|
| 868 | UInt uiCHeight = (uiHeight>>1); |
---|
| 869 | |
---|
| 870 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
| 871 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
| 872 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
| 873 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
| 874 | |
---|
| 875 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
| 876 | |
---|
| 877 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
| 878 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
| 879 | } |
---|
| 880 | |
---|
| 881 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
| 882 | * \param pcCU pointer to current CU |
---|
| 883 | * \param uiDepth CU Depth |
---|
| 884 | * \returns Void |
---|
| 885 | */ |
---|
| 886 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
| 887 | { |
---|
| 888 | // Luma |
---|
| 889 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
| 890 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
| 891 | |
---|
| 892 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
| 893 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
| 894 | |
---|
| 895 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
| 896 | |
---|
| 897 | for(Int y = 0; y < height; y++ ) |
---|
| 898 | { |
---|
| 899 | for(Int x = 0; x < width; x++ ) |
---|
| 900 | { |
---|
| 901 | pPcmY[x] = pRecoY[x]; |
---|
| 902 | } |
---|
| 903 | pPcmY += width; |
---|
| 904 | pRecoY += stride; |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | // Cb and Cr |
---|
| 908 | UInt widthC = (width>>1); |
---|
| 909 | UInt heightC = (height>>1); |
---|
| 910 | |
---|
| 911 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
| 912 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
| 913 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
| 914 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
| 915 | |
---|
| 916 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
| 917 | |
---|
| 918 | for(Int y = 0; y < heightC; y++ ) |
---|
| 919 | { |
---|
| 920 | for(Int x = 0; x < widthC; x++ ) |
---|
| 921 | { |
---|
| 922 | pPcmCb[x] = pRecoCb[x]; |
---|
| 923 | pPcmCr[x] = pRecoCr[x]; |
---|
| 924 | } |
---|
| 925 | pPcmCr += widthC; |
---|
| 926 | pPcmCb += widthC; |
---|
| 927 | pRecoCb += strideC; |
---|
| 928 | pRecoCr += strideC; |
---|
| 929 | } |
---|
| 930 | |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | #if NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
| 934 | Void |
---|
| 935 | TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 936 | { |
---|
[307] | 937 | m_ppcYuvReco[uiDepth]->copyFromPicLuma ( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0)); |
---|
| 938 | m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0); |
---|
| 939 | m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1); |
---|
[191] | 940 | |
---|
| 941 | // inter recon |
---|
| 942 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
| 943 | |
---|
| 944 | // clip for only non-zero cbp case |
---|
| 945 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
| 946 | { |
---|
| 947 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 948 | } |
---|
| 949 | else |
---|
| 950 | { |
---|
| 951 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 952 | } |
---|
| 953 | } |
---|
| 954 | #endif |
---|
| 955 | |
---|
| 956 | //! \} |
---|