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