[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file 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 | |
---|
[595] | 534 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) |
---|
| 535 | { |
---|
[313] | 536 | //===== inverse transform ===== |
---|
[442] | 537 | #if REPN_FORMAT_IN_VPS |
---|
| 538 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); |
---|
| 539 | #else |
---|
[313] | 540 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
[442] | 541 | #endif |
---|
[313] | 542 | |
---|
| 543 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
[595] | 544 | assert(scalingListType < SCALING_LIST_NUM); |
---|
[313] | 545 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
| 546 | |
---|
| 547 | |
---|
| 548 | //===== reconstruction ===== |
---|
| 549 | Pel* pPred = piPred; |
---|
| 550 | Pel* pResi = piResi; |
---|
| 551 | Pel* pReco = piReco; |
---|
| 552 | Pel* pRecIPred = piRecIPred; |
---|
| 553 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 554 | { |
---|
| 555 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 556 | { |
---|
| 557 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 558 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 559 | } |
---|
| 560 | pPred += uiStride; |
---|
| 561 | pResi += uiStride; |
---|
| 562 | pReco += uiStride; |
---|
| 563 | pRecIPred += uiRecIPredStride; |
---|
| 564 | } |
---|
[595] | 565 | } |
---|
| 566 | else |
---|
| 567 | { |
---|
| 568 | //===== reconstruction ===== |
---|
| 569 | Pel* pPred = piPred; |
---|
| 570 | Pel* pReco = piReco; |
---|
| 571 | Pel* pRecIPred = piRecIPred; |
---|
| 572 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
| 573 | { |
---|
| 574 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
| 575 | { |
---|
| 576 | pReco [ x ] = pPred[ x ]; |
---|
| 577 | pRecIPred[ x ] = pReco[ x ]; |
---|
| 578 | } |
---|
| 579 | pPred += uiStride; |
---|
| 580 | pReco += uiStride; |
---|
| 581 | pRecIPred += uiRecIPredStride; |
---|
| 582 | } |
---|
| 583 | } |
---|
[313] | 584 | } |
---|
| 585 | |
---|
| 586 | |
---|
| 587 | Void |
---|
| 588 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
| 589 | UInt uiTrDepth, |
---|
| 590 | UInt uiAbsPartIdx, |
---|
| 591 | TComYuv* pcRecoYuv, |
---|
| 592 | TComYuv* pcPredYuv, |
---|
| 593 | TComYuv* pcResiYuv, |
---|
| 594 | UInt uiChromaId ) |
---|
| 595 | { |
---|
| 596 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
| 597 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
| 598 | |
---|
| 599 | if( uiLog2TrSize == 2 ) |
---|
| 600 | { |
---|
| 601 | assert( uiTrDepth > 0 ); |
---|
| 602 | uiTrDepth--; |
---|
| 603 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
| 604 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
| 605 | if( !bFirstQ ) |
---|
| 606 | { |
---|
| 607 | return; |
---|
| 608 | } |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
| 612 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 613 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 614 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
| 615 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 616 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 617 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 618 | |
---|
| 619 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
| 620 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 621 | |
---|
| 622 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
| 623 | |
---|
| 624 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 625 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
| 626 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 627 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
| 628 | //===== init availability pattern ===== |
---|
| 629 | Bool bAboveAvail = false; |
---|
| 630 | Bool bLeftAvail = false; |
---|
| 631 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 632 | |
---|
| 633 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 634 | m_pcPrediction->getPredicBuf (), |
---|
| 635 | m_pcPrediction->getPredicBufWidth (), |
---|
| 636 | m_pcPrediction->getPredicBufHeight (), |
---|
| 637 | bAboveAvail, bLeftAvail ); |
---|
| 638 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
| 639 | |
---|
| 640 | //===== get prediction signal ===== |
---|
[345] | 641 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
[313] | 642 | { |
---|
[345] | 643 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
[313] | 644 | } |
---|
[345] | 645 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
[313] | 646 | |
---|
[595] | 647 | if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) ) |
---|
| 648 | { |
---|
[313] | 649 | //===== inverse transform ===== |
---|
| 650 | Int curChromaQpOffset; |
---|
| 651 | if(eText == TEXT_CHROMA_U) |
---|
| 652 | { |
---|
| 653 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
| 654 | } |
---|
| 655 | else |
---|
| 656 | { |
---|
| 657 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
| 658 | } |
---|
[494] | 659 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 660 | // Bug-fix |
---|
| 661 | #if REPN_FORMAT_IN_VPS |
---|
| 662 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 663 | #else |
---|
[313] | 664 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
[494] | 665 | #endif |
---|
| 666 | #else |
---|
| 667 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 668 | #endif |
---|
[313] | 669 | |
---|
| 670 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
[595] | 671 | assert(scalingListType < SCALING_LIST_NUM); |
---|
[313] | 672 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
| 673 | |
---|
| 674 | //===== reconstruction ===== |
---|
| 675 | Pel* pPred = piPred; |
---|
| 676 | Pel* pResi = piResi; |
---|
| 677 | Pel* pReco = piReco; |
---|
| 678 | Pel* pRecIPred = piRecIPred; |
---|
| 679 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 680 | { |
---|
| 681 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 682 | { |
---|
| 683 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 684 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 685 | } |
---|
| 686 | pPred += uiStride; |
---|
| 687 | pResi += uiStride; |
---|
| 688 | pReco += uiStride; |
---|
| 689 | pRecIPred += uiRecIPredStride; |
---|
| 690 | } |
---|
[595] | 691 | } |
---|
| 692 | else |
---|
| 693 | { |
---|
| 694 | //===== reconstruction ===== |
---|
| 695 | Pel* pPred = piPred; |
---|
| 696 | Pel* pReco = piReco; |
---|
| 697 | Pel* pRecIPred = piRecIPred; |
---|
| 698 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
| 699 | { |
---|
| 700 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
| 701 | { |
---|
| 702 | pReco [ x ] = pPred[ x ]; |
---|
| 703 | pRecIPred[ x ] = pReco[ x ]; |
---|
| 704 | } |
---|
| 705 | pPred += uiStride; |
---|
| 706 | pReco += uiStride; |
---|
| 707 | pRecIPred += uiRecIPredStride; |
---|
| 708 | } |
---|
| 709 | } |
---|
[313] | 710 | } |
---|
| 711 | |
---|
| 712 | |
---|
| 713 | Void |
---|
| 714 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 715 | { |
---|
| 716 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
| 717 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
| 718 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
| 719 | |
---|
| 720 | if (pcCU->getIPCMFlag(0)) |
---|
| 721 | { |
---|
| 722 | xReconPCM( pcCU, uiDepth ); |
---|
| 723 | return; |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 727 | { |
---|
| 728 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 732 | { |
---|
| 733 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
| 739 | * \param pcCU pointer of current CU |
---|
| 740 | * \param uiTrDepth current tranform split depth |
---|
| 741 | * \param uiAbsPartIdx part index |
---|
| 742 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 743 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 744 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 745 | * |
---|
| 746 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
| 747 | */ |
---|
| 748 | Void |
---|
| 749 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
| 750 | UInt uiTrDepth, |
---|
| 751 | UInt uiAbsPartIdx, |
---|
| 752 | TComYuv* pcRecoYuv, |
---|
| 753 | TComYuv* pcPredYuv, |
---|
| 754 | TComYuv* pcResiYuv ) |
---|
| 755 | { |
---|
| 756 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 757 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 758 | if( uiTrMode == uiTrDepth ) |
---|
| 759 | { |
---|
| 760 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 761 | } |
---|
| 762 | else |
---|
| 763 | { |
---|
| 764 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 765 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 766 | { |
---|
| 767 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
| 773 | * \param pcCU pointer of current CU |
---|
| 774 | * \param uiTrDepth current tranform split depth |
---|
| 775 | * \param uiAbsPartIdx part index |
---|
| 776 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 777 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 778 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 779 | * |
---|
| 780 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
| 781 | */ |
---|
| 782 | Void |
---|
| 783 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
| 784 | UInt uiTrDepth, |
---|
| 785 | UInt uiAbsPartIdx, |
---|
| 786 | TComYuv* pcRecoYuv, |
---|
| 787 | TComYuv* pcPredYuv, |
---|
| 788 | TComYuv* pcResiYuv ) |
---|
| 789 | { |
---|
| 790 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 791 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 792 | if( uiTrMode == uiTrDepth ) |
---|
| 793 | { |
---|
| 794 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 795 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 796 | } |
---|
| 797 | else |
---|
| 798 | { |
---|
| 799 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 800 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 801 | { |
---|
| 802 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 808 | { |
---|
| 809 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 810 | |
---|
| 811 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
| 812 | |
---|
| 813 | return; |
---|
| 814 | } |
---|
| 815 | |
---|
| 816 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 817 | { |
---|
| 818 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 819 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 820 | TCoeff* piCoeff; |
---|
| 821 | |
---|
| 822 | Pel* pResi; |
---|
| 823 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 824 | |
---|
| 825 | // Y |
---|
| 826 | piCoeff = pcCU->getCoeffY(); |
---|
| 827 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
| 828 | |
---|
[442] | 829 | #if REPN_FORMAT_IN_VPS |
---|
| 830 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); |
---|
| 831 | #else |
---|
[313] | 832 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
[442] | 833 | #endif |
---|
[313] | 834 | |
---|
| 835 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 836 | |
---|
| 837 | // Cb and Cr |
---|
| 838 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
[494] | 839 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 840 | // Bug-fix |
---|
| 841 | #if REPN_FORMAT_IN_VPS |
---|
| 842 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 843 | #else |
---|
[313] | 844 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
[494] | 845 | #endif |
---|
| 846 | #else |
---|
| 847 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 848 | #endif |
---|
[313] | 849 | |
---|
| 850 | uiWidth >>= 1; |
---|
| 851 | uiHeight >>= 1; |
---|
| 852 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
| 853 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 854 | |
---|
| 855 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
[494] | 856 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 857 | // Bug-fix |
---|
| 858 | #if REPN_FORMAT_IN_VPS |
---|
| 859 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 860 | #else |
---|
[313] | 861 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
[494] | 862 | #endif |
---|
| 863 | #else |
---|
| 864 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
| 865 | #endif |
---|
[313] | 866 | |
---|
| 867 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
| 868 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
| 872 | * \param pcCU pointer to current CU |
---|
| 873 | * \param uiPartIdx part index |
---|
| 874 | * \param piPCM pointer to PCM code arrays |
---|
| 875 | * \param piReco pointer to reconstructed sample arrays |
---|
| 876 | * \param uiStride stride of reconstructed sample arrays |
---|
| 877 | * \param uiWidth CU width |
---|
| 878 | * \param uiHeight CU height |
---|
| 879 | * \param ttText texture component type |
---|
| 880 | * \returns Void |
---|
| 881 | */ |
---|
| 882 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
| 883 | { |
---|
| 884 | UInt uiX, uiY; |
---|
| 885 | Pel* piPicReco; |
---|
| 886 | UInt uiPicStride; |
---|
| 887 | UInt uiPcmLeftShiftBit; |
---|
| 888 | |
---|
| 889 | if( ttText == TEXT_LUMA ) |
---|
| 890 | { |
---|
| 891 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
| 892 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 893 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 894 | } |
---|
| 895 | else |
---|
| 896 | { |
---|
| 897 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 898 | |
---|
| 899 | if( ttText == TEXT_CHROMA_U ) |
---|
| 900 | { |
---|
| 901 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 902 | } |
---|
| 903 | else |
---|
| 904 | { |
---|
| 905 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 906 | } |
---|
| 907 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 908 | } |
---|
| 909 | |
---|
| 910 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 911 | { |
---|
| 912 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 913 | { |
---|
| 914 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
| 915 | piPicReco[uiX] = piReco[uiX]; |
---|
| 916 | } |
---|
| 917 | piPCM += uiWidth; |
---|
| 918 | piReco += uiStride; |
---|
| 919 | piPicReco += uiPicStride; |
---|
| 920 | } |
---|
| 921 | } |
---|
| 922 | |
---|
| 923 | /** Function for reconstructing a PCM mode CU. |
---|
| 924 | * \param pcCU pointer to current CU |
---|
| 925 | * \param uiDepth CU Depth |
---|
| 926 | * \returns Void |
---|
| 927 | */ |
---|
| 928 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 929 | { |
---|
| 930 | // Luma |
---|
| 931 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
| 932 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
| 933 | |
---|
| 934 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
| 935 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
| 936 | |
---|
| 937 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
| 938 | |
---|
| 939 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
| 940 | |
---|
| 941 | // Cb and Cr |
---|
| 942 | UInt uiCWidth = (uiWidth>>1); |
---|
| 943 | UInt uiCHeight = (uiHeight>>1); |
---|
| 944 | |
---|
| 945 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
| 946 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
| 947 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
| 948 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
| 949 | |
---|
| 950 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
| 951 | |
---|
| 952 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
| 953 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
| 957 | * \param pcCU pointer to current CU |
---|
| 958 | * \param uiDepth CU Depth |
---|
| 959 | * \returns Void |
---|
| 960 | */ |
---|
| 961 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
| 962 | { |
---|
| 963 | // Luma |
---|
| 964 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
| 965 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
| 966 | |
---|
| 967 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
| 968 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
| 969 | |
---|
| 970 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
| 971 | |
---|
| 972 | for(Int y = 0; y < height; y++ ) |
---|
| 973 | { |
---|
| 974 | for(Int x = 0; x < width; x++ ) |
---|
| 975 | { |
---|
| 976 | pPcmY[x] = pRecoY[x]; |
---|
| 977 | } |
---|
| 978 | pPcmY += width; |
---|
| 979 | pRecoY += stride; |
---|
| 980 | } |
---|
| 981 | |
---|
| 982 | // Cb and Cr |
---|
| 983 | UInt widthC = (width>>1); |
---|
| 984 | UInt heightC = (height>>1); |
---|
| 985 | |
---|
| 986 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
| 987 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
| 988 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
| 989 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
| 990 | |
---|
| 991 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
| 992 | |
---|
| 993 | for(Int y = 0; y < heightC; y++ ) |
---|
| 994 | { |
---|
| 995 | for(Int x = 0; x < widthC; x++ ) |
---|
| 996 | { |
---|
| 997 | pPcmCb[x] = pRecoCb[x]; |
---|
| 998 | pPcmCr[x] = pRecoCr[x]; |
---|
| 999 | } |
---|
| 1000 | pPcmCr += widthC; |
---|
| 1001 | pPcmCb += widthC; |
---|
| 1002 | pRecoCb += strideC; |
---|
| 1003 | pRecoCr += strideC; |
---|
| 1004 | } |
---|
| 1005 | |
---|
| 1006 | } |
---|
[540] | 1007 | |
---|
[313] | 1008 | //! \} |
---|