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