[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 |
---|
[916] | 4 | * granted under this license. |
---|
[313] | 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" |
---|
[916] | 39 | #include "TLibCommon/TComTU.h" |
---|
[313] | 40 | #if SVC_EXTENSION |
---|
| 41 | #include "TDecTop.h" |
---|
| 42 | #endif |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | //! \ingroup TLibDecoder |
---|
| 46 | //! \{ |
---|
| 47 | |
---|
| 48 | // ==================================================================================================================== |
---|
| 49 | // Constructor / destructor / create / destroy |
---|
| 50 | // ==================================================================================================================== |
---|
| 51 | |
---|
| 52 | TDecCu::TDecCu() |
---|
| 53 | { |
---|
| 54 | m_ppcYuvResi = NULL; |
---|
| 55 | m_ppcYuvReco = NULL; |
---|
| 56 | m_ppcCU = NULL; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | TDecCu::~TDecCu() |
---|
| 60 | { |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | #if SVC_EXTENSION |
---|
| 64 | Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId) |
---|
| 65 | { |
---|
| 66 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 67 | m_pcTrQuant = pcTrQuant; |
---|
| 68 | m_pcPrediction = pcPrediction; |
---|
| 69 | m_ppcTDecTop = ppcDecTop; |
---|
| 70 | m_layerId = layerId; |
---|
| 71 | |
---|
| 72 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 73 | { |
---|
| 74 | m_ppcCU [ui]->setLayerId(layerId); |
---|
| 75 | } |
---|
[713] | 76 | |
---|
| 77 | #if LAYER_CTB |
---|
| 78 | memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) ); |
---|
| 79 | memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) ); |
---|
| 80 | memcpy(g_auiLayerRasterToPelX[m_layerId], g_auiRasterToPelX, sizeof( g_auiRasterToPelX ) ); |
---|
| 81 | memcpy(g_auiLayerRasterToPelY[m_layerId], g_auiRasterToPelY, sizeof( g_auiRasterToPelY ) ); |
---|
| 82 | #endif |
---|
[313] | 83 | } |
---|
| 84 | #else |
---|
| 85 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
| 86 | { |
---|
| 87 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 88 | m_pcTrQuant = pcTrQuant; |
---|
| 89 | m_pcPrediction = pcPrediction; |
---|
| 90 | } |
---|
| 91 | #endif |
---|
| 92 | |
---|
| 93 | /** |
---|
| 94 | \param uiMaxDepth total number of allowable depth |
---|
| 95 | \param uiMaxWidth largest CU width |
---|
| 96 | \param uiMaxHeight largest CU height |
---|
| 97 | */ |
---|
[916] | 98 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
---|
[313] | 99 | { |
---|
| 100 | m_uiMaxDepth = uiMaxDepth+1; |
---|
[916] | 101 | |
---|
[313] | 102 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 103 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 104 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
[916] | 105 | |
---|
[313] | 106 | UInt uiNumPartitions; |
---|
| 107 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 108 | { |
---|
| 109 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
| 110 | UInt uiWidth = uiMaxWidth >> ui; |
---|
| 111 | UInt uiHeight = uiMaxHeight >> ui; |
---|
[916] | 112 | |
---|
| 113 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
| 114 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
| 115 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
[313] | 116 | } |
---|
[916] | 117 | |
---|
[313] | 118 | m_bDecodeDQP = false; |
---|
[916] | 119 | m_IsChromaQpAdjCoded = false; |
---|
[313] | 120 | |
---|
| 121 | // initialize partition order. |
---|
| 122 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 123 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
| 124 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
[916] | 125 | |
---|
[313] | 126 | // initialize conversion matrix from partition index to pel |
---|
| 127 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | Void TDecCu::destroy() |
---|
| 131 | { |
---|
| 132 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 133 | { |
---|
| 134 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
| 135 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
| 136 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
| 137 | } |
---|
[916] | 138 | |
---|
[313] | 139 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
| 140 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
| 141 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | // ==================================================================================================================== |
---|
| 145 | // Public member functions |
---|
| 146 | // ==================================================================================================================== |
---|
| 147 | |
---|
| 148 | /** \param pcCU pointer of CU data |
---|
| 149 | \param ruiIsLast last data? |
---|
| 150 | */ |
---|
[916] | 151 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
---|
[313] | 152 | { |
---|
[916] | 153 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
---|
[313] | 154 | { |
---|
| 155 | setdQPFlag(true); |
---|
| 156 | } |
---|
| 157 | |
---|
[916] | 158 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
---|
| 159 | { |
---|
| 160 | setIsChromaQpAdjCoded(true); |
---|
| 161 | } |
---|
| 162 | |
---|
[313] | 163 | #if SVC_EXTENSION |
---|
[916] | 164 | pCtu->setLayerId(m_layerId); |
---|
[313] | 165 | #endif |
---|
[916] | 166 | |
---|
| 167 | // start from the top level CU |
---|
| 168 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
---|
[313] | 169 | } |
---|
| 170 | |
---|
| 171 | /** \param pcCU pointer of CU data |
---|
| 172 | */ |
---|
[916] | 173 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
---|
[313] | 174 | { |
---|
[916] | 175 | xDecompressCU( pCtu, 0, 0 ); |
---|
[313] | 176 | } |
---|
| 177 | |
---|
| 178 | // ==================================================================================================================== |
---|
| 179 | // Protected member functions |
---|
| 180 | // ==================================================================================================================== |
---|
| 181 | |
---|
| 182 | /**decode end-of-slice flag |
---|
| 183 | * \param pcCU |
---|
[916] | 184 | * \param uiAbsPartIdx |
---|
| 185 | * \param uiDepth |
---|
[313] | 186 | * \returns Bool |
---|
| 187 | */ |
---|
[916] | 188 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[313] | 189 | { |
---|
[916] | 190 | UInt uiIsLastCtuOfSliceSegment; |
---|
[313] | 191 | |
---|
[916] | 192 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
---|
[313] | 193 | { |
---|
[916] | 194 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
---|
[313] | 195 | } |
---|
| 196 | else |
---|
| 197 | { |
---|
[916] | 198 | uiIsLastCtuOfSliceSegment=0; |
---|
[313] | 199 | } |
---|
| 200 | |
---|
[916] | 201 | return uiIsLastCtuOfSliceSegment>0; |
---|
[313] | 202 | } |
---|
| 203 | |
---|
| 204 | /** decode CU block recursively |
---|
| 205 | * \param pcCU |
---|
[916] | 206 | * \param uiAbsPartIdx |
---|
| 207 | * \param uiDepth |
---|
[313] | 208 | * \returns Void |
---|
| 209 | */ |
---|
| 210 | |
---|
[916] | 211 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
[313] | 212 | { |
---|
| 213 | TComPic* pcPic = pcCU->getPic(); |
---|
[916] | 214 | UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); |
---|
[313] | 215 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
[916] | 216 | |
---|
[313] | 217 | Bool bBoundary = false; |
---|
| 218 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 219 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 220 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 221 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
[916] | 222 | |
---|
[313] | 223 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
[442] | 224 | #if REPN_FORMAT_IN_VPS |
---|
[926] | 225 | if( ( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
---|
[442] | 226 | #else |
---|
[916] | 227 | if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[442] | 228 | #endif |
---|
[313] | 229 | { |
---|
| 230 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 231 | } |
---|
| 232 | else |
---|
| 233 | { |
---|
| 234 | bBoundary = true; |
---|
| 235 | } |
---|
[916] | 236 | |
---|
[313] | 237 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 238 | { |
---|
| 239 | UInt uiIdx = uiAbsPartIdx; |
---|
| 240 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 241 | { |
---|
| 242 | setdQPFlag(true); |
---|
| 243 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 244 | } |
---|
| 245 | |
---|
[916] | 246 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
| 247 | { |
---|
| 248 | setIsChromaQpAdjCoded(true); |
---|
| 249 | } |
---|
| 250 | |
---|
[313] | 251 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 252 | { |
---|
| 253 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 254 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
[916] | 255 | |
---|
[442] | 256 | #if REPN_FORMAT_IN_VPS |
---|
[916] | 257 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getPicHeightInLumaSamples() ) ) |
---|
[442] | 258 | #else |
---|
[916] | 259 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[442] | 260 | #endif |
---|
[916] | 261 | { |
---|
| 262 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
---|
[313] | 263 | } |
---|
[916] | 264 | else |
---|
| 265 | { |
---|
| 266 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
| 267 | } |
---|
| 268 | |
---|
[313] | 269 | uiIdx += uiQNumParts; |
---|
| 270 | } |
---|
| 271 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 272 | { |
---|
| 273 | if ( getdQPFlag() ) |
---|
| 274 | { |
---|
[916] | 275 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
---|
[313] | 276 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | return; |
---|
| 280 | } |
---|
[916] | 281 | |
---|
[313] | 282 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 283 | { |
---|
| 284 | setdQPFlag(true); |
---|
| 285 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 286 | } |
---|
| 287 | |
---|
[916] | 288 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
| 289 | { |
---|
| 290 | setIsChromaQpAdjCoded(true); |
---|
| 291 | } |
---|
| 292 | |
---|
[313] | 293 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
| 294 | { |
---|
| 295 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 296 | } |
---|
[916] | 297 | |
---|
[313] | 298 | // decode CU mode and the partition size |
---|
| 299 | if( !pcCU->getSlice()->isIntra()) |
---|
| 300 | { |
---|
| 301 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 302 | } |
---|
| 303 | |
---|
[540] | 304 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 305 | if (pcCU->getSlice()->getVPS()->getHigherLayerIrapSkipFlag() && pcCU->getSlice()->getVPS()->getSingleLayerForNonIrapFlag() && pcCU->getLayerId() > 0) |
---|
| 306 | { |
---|
| 307 | Bool lowerLayerExist = false; |
---|
| 308 | for(int i=0;i<pcCU->getLayerId();i++) |
---|
| 309 | { |
---|
| 310 | if(pcCU->getSlice()->getBaseColPic(pcCU->getSlice()->getInterLayerPredLayerIdc(i))) |
---|
| 311 | { |
---|
| 312 | lowerLayerExist = true; |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | if(lowerLayerExist) |
---|
| 316 | { |
---|
| 317 | assert(pcCU->isSkipped(uiAbsPartIdx)); |
---|
| 318 | } |
---|
| 319 | } |
---|
| 320 | #endif |
---|
| 321 | |
---|
[313] | 322 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
| 323 | { |
---|
| 324 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 325 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
| 326 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 327 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 328 | Int numValidMergeCand = 0; |
---|
| 329 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
| 330 | { |
---|
| 331 | uhInterDirNeighbours[ui] = 0; |
---|
| 332 | } |
---|
| 333 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
| 334 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
| 335 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 336 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
| 337 | |
---|
| 338 | TComMv cTmpMv( 0, 0 ); |
---|
| 339 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
[916] | 340 | { |
---|
[313] | 341 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 342 | { |
---|
| 343 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 344 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 345 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 346 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 347 | } |
---|
| 348 | } |
---|
[916] | 349 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[313] | 350 | return; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 354 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 355 | |
---|
| 356 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 357 | { |
---|
| 358 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 359 | |
---|
| 360 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
| 361 | { |
---|
[916] | 362 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[313] | 363 | return; |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 368 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
| 369 | |
---|
| 370 | // Coefficient decoding |
---|
| 371 | Bool bCodeDQP = getdQPFlag(); |
---|
[916] | 372 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
---|
| 373 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
---|
| 374 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
---|
[313] | 375 | setdQPFlag( bCodeDQP ); |
---|
[916] | 376 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[313] | 377 | } |
---|
| 378 | |
---|
[916] | 379 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
[313] | 380 | { |
---|
| 381 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 382 | { |
---|
| 383 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
| 384 | } |
---|
| 385 | |
---|
[916] | 386 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
---|
| 387 | { |
---|
| 388 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
---|
[313] | 392 | } |
---|
| 393 | |
---|
[916] | 394 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[313] | 395 | { |
---|
[916] | 396 | TComPic* pcPic = pCtu->getPic(); |
---|
| 397 | |
---|
[313] | 398 | Bool bBoundary = false; |
---|
[916] | 399 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[313] | 400 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
[916] | 401 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[313] | 402 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
[916] | 403 | |
---|
| 404 | TComSlice * pcSlice = pCtu->getPic()->getSlice(pCtu->getPic()->getCurrSliceIdx()); |
---|
| 405 | |
---|
[442] | 406 | #if REPN_FORMAT_IN_VPS |
---|
[916] | 407 | if( ( uiRPelX >= pcSlice->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getPicHeightInLumaSamples() ) ) |
---|
| 408 | |
---|
[442] | 409 | #else |
---|
[916] | 410 | if( ( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[442] | 411 | #endif |
---|
[313] | 412 | { |
---|
| 413 | bBoundary = true; |
---|
| 414 | } |
---|
[916] | 415 | |
---|
| 416 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
[313] | 417 | { |
---|
| 418 | UInt uiNextDepth = uiDepth + 1; |
---|
[916] | 419 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
---|
[313] | 420 | UInt uiIdx = uiAbsPartIdx; |
---|
| 421 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
| 422 | { |
---|
[916] | 423 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 424 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 425 | |
---|
[442] | 426 | #if REPN_FORMAT_IN_VPS |
---|
[916] | 427 | if( ( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
---|
[442] | 428 | #else |
---|
[916] | 429 | if( ( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[442] | 430 | #endif |
---|
[313] | 431 | { |
---|
[916] | 432 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
---|
[313] | 433 | } |
---|
[916] | 434 | |
---|
[313] | 435 | uiIdx += uiQNumParts; |
---|
| 436 | } |
---|
| 437 | return; |
---|
| 438 | } |
---|
[916] | 439 | |
---|
[313] | 440 | // Residual reconstruction |
---|
| 441 | m_ppcYuvResi[uiDepth]->clear(); |
---|
[916] | 442 | |
---|
| 443 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx, uiDepth ); |
---|
| 444 | |
---|
[313] | 445 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
| 446 | { |
---|
| 447 | case MODE_INTER: |
---|
| 448 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
| 449 | break; |
---|
| 450 | case MODE_INTRA: |
---|
| 451 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
| 452 | break; |
---|
| 453 | default: |
---|
| 454 | assert(0); |
---|
| 455 | break; |
---|
| 456 | } |
---|
[916] | 457 | |
---|
| 458 | #ifdef DEBUG_STRING |
---|
| 459 | const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); |
---|
| 460 | if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) |
---|
| 461 | { |
---|
| 462 | PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
| 463 | std::ostream &ss(std::cout); |
---|
| 464 | |
---|
| 465 | ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl; |
---|
| 466 | } |
---|
| 467 | #endif |
---|
| 468 | |
---|
[313] | 469 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
| 470 | { |
---|
| 471 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
| 472 | } |
---|
[916] | 473 | |
---|
[313] | 474 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 478 | { |
---|
[916] | 479 | |
---|
[313] | 480 | // inter prediction |
---|
| 481 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
[916] | 482 | |
---|
| 483 | #ifdef DEBUG_STRING |
---|
| 484 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); |
---|
| 485 | if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
| 486 | #endif |
---|
| 487 | |
---|
[313] | 488 | // inter recon |
---|
[916] | 489 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
| 490 | |
---|
| 491 | #ifdef DEBUG_STRING |
---|
| 492 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
| 493 | #endif |
---|
| 494 | |
---|
[313] | 495 | // clip for only non-zero cbp case |
---|
[916] | 496 | if ( pcCU->getQtRootCbf( 0) ) |
---|
[313] | 497 | { |
---|
| 498 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 499 | } |
---|
| 500 | else |
---|
| 501 | { |
---|
| 502 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 503 | } |
---|
[916] | 504 | #ifdef DEBUG_STRING |
---|
| 505 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
| 506 | #endif |
---|
| 507 | |
---|
[313] | 508 | } |
---|
| 509 | |
---|
[916] | 510 | |
---|
[313] | 511 | Void |
---|
[916] | 512 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
| 513 | TComYuv* pcPredYuv, |
---|
| 514 | TComYuv* pcResiYuv, |
---|
| 515 | const ComponentID compID, |
---|
| 516 | TComTU &rTu) |
---|
[313] | 517 | { |
---|
[916] | 518 | if (!rTu.ProcessComponentSection(compID)) return; |
---|
| 519 | const Bool bIsLuma = isLuma(compID); |
---|
[313] | 520 | |
---|
| 521 | |
---|
[916] | 522 | TComDataCU *pcCU = rTu.getCU(); |
---|
| 523 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
| 524 | |
---|
| 525 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
| 526 | const UInt uiWidth = tuRect.width; |
---|
| 527 | const UInt uiHeight = tuRect.height; |
---|
| 528 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
| 529 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 530 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
| 531 | |
---|
| 532 | if (uiWidth != uiHeight) |
---|
[313] | 533 | { |
---|
[916] | 534 | //------------------------------------------------ |
---|
[313] | 535 | |
---|
[916] | 536 | //split at current level if dividing into square sub-TUs |
---|
[313] | 537 | |
---|
[916] | 538 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
[313] | 539 | |
---|
[916] | 540 | //recurse further |
---|
| 541 | do |
---|
[313] | 542 | { |
---|
[916] | 543 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
[313] | 544 | } |
---|
[916] | 545 | while (subTURecurse.nextSection(rTu)); |
---|
| 546 | |
---|
| 547 | //------------------------------------------------ |
---|
| 548 | |
---|
| 549 | return; |
---|
[313] | 550 | } |
---|
[916] | 551 | |
---|
| 552 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
| 553 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt)) : uiChPredMode; |
---|
| 554 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
| 555 | |
---|
[313] | 556 | //===== init availability pattern ===== |
---|
| 557 | Bool bAboveAvail = false; |
---|
| 558 | Bool bLeftAvail = false; |
---|
| 559 | |
---|
[916] | 560 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing()); |
---|
| 561 | |
---|
| 562 | #ifdef DEBUG_STRING |
---|
| 563 | std::ostream &ss(std::cout); |
---|
| 564 | #endif |
---|
| 565 | |
---|
| 566 | DEBUG_STRING_NEW(sTemp) |
---|
| 567 | m_pcPrediction->initAdiPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
| 568 | |
---|
| 569 | |
---|
[313] | 570 | //===== get prediction signal ===== |
---|
| 571 | |
---|
[916] | 572 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions ); |
---|
| 573 | |
---|
| 574 | #ifdef DEBUG_STRING |
---|
| 575 | ss << sTemp; |
---|
| 576 | #endif |
---|
| 577 | |
---|
[313] | 578 | //===== inverse transform ===== |
---|
[916] | 579 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 580 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 581 | |
---|
| 582 | const QpParam cQP(*pcCU, compID); |
---|
| 583 | |
---|
| 584 | |
---|
| 585 | DEBUG_STRING_NEW(sDebug); |
---|
| 586 | #ifdef DEBUG_STRING |
---|
| 587 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
| 588 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
| 589 | #endif |
---|
| 590 | |
---|
| 591 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
[313] | 592 | { |
---|
[916] | 593 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
[313] | 594 | } |
---|
| 595 | else |
---|
| 596 | { |
---|
[916] | 597 | for (UInt y = 0; y < uiHeight; y++) |
---|
| 598 | for (UInt x = 0; x < uiWidth; x++) |
---|
| 599 | { |
---|
| 600 | piResi[(y * uiStride) + x] = 0; |
---|
| 601 | } |
---|
[313] | 602 | } |
---|
[916] | 603 | |
---|
| 604 | #ifdef DEBUG_STRING |
---|
| 605 | if (psDebug) |
---|
| 606 | ss << (*psDebug); |
---|
[494] | 607 | #endif |
---|
[916] | 608 | |
---|
| 609 | //===== reconstruction ===== |
---|
| 610 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
| 611 | |
---|
| 612 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
| 613 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
| 614 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
| 615 | |
---|
| 616 | Pel* pPred = piPred; |
---|
| 617 | Pel* pResi = piResi; |
---|
| 618 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 619 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
| 620 | |
---|
| 621 | |
---|
| 622 | #ifdef DEBUG_STRING |
---|
| 623 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 624 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 625 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 626 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
| 627 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
[494] | 628 | #endif |
---|
[313] | 629 | |
---|
[916] | 630 | #if O0043_BEST_EFFORT_DECODING |
---|
| 631 | const Int bitDepthDelta = g_bitDepthInStream[toChannelType(compID)] - g_bitDepth[toChannelType(compID)]; |
---|
| 632 | #endif |
---|
| 633 | const Int clipbd = g_bitDepth[toChannelType(compID)]; |
---|
[313] | 634 | |
---|
[916] | 635 | if( useCrossComponentPrediction ) |
---|
| 636 | { |
---|
| 637 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
| 638 | } |
---|
| 639 | |
---|
[313] | 640 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 641 | { |
---|
[916] | 642 | #ifdef DEBUG_STRING |
---|
| 643 | if (bDebugPred || bDebugResi || bDebugReco) ss << "###: "; |
---|
| 644 | |
---|
| 645 | if (bDebugPred) |
---|
| 646 | { |
---|
| 647 | ss << " - pred: "; |
---|
| 648 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 649 | { |
---|
| 650 | ss << pPred[ uiX ] << ", "; |
---|
| 651 | } |
---|
| 652 | } |
---|
| 653 | if (bDebugResi) ss << " - resi: "; |
---|
| 654 | #endif |
---|
| 655 | |
---|
[313] | 656 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 657 | { |
---|
[916] | 658 | #ifdef DEBUG_STRING |
---|
| 659 | if (bDebugResi) |
---|
| 660 | ss << pResi[ uiX ] << ", "; |
---|
| 661 | #endif |
---|
| 662 | #if O0043_BEST_EFFORT_DECODING |
---|
| 663 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
| 664 | #else |
---|
| 665 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
| 666 | #endif |
---|
[313] | 667 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 668 | } |
---|
[916] | 669 | #ifdef DEBUG_STRING |
---|
| 670 | if (bDebugReco) |
---|
| 671 | { |
---|
| 672 | ss << " - reco: "; |
---|
| 673 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 674 | { |
---|
| 675 | ss << pReco[ uiX ] << ", "; |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
| 680 | ss << "\n"; |
---|
| 681 | #endif |
---|
[313] | 682 | pPred += uiStride; |
---|
| 683 | pResi += uiStride; |
---|
| 684 | pReco += uiStride; |
---|
| 685 | pRecIPred += uiRecIPredStride; |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | |
---|
| 690 | Void |
---|
| 691 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 692 | { |
---|
| 693 | if (pcCU->getIPCMFlag(0)) |
---|
| 694 | { |
---|
| 695 | xReconPCM( pcCU, uiDepth ); |
---|
| 696 | return; |
---|
| 697 | } |
---|
[916] | 698 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
| 699 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
[313] | 700 | { |
---|
[916] | 701 | const ChannelType chanType=ChannelType(chType); |
---|
| 702 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
| 703 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
[313] | 704 | |
---|
[916] | 705 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
| 706 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
[313] | 707 | |
---|
[916] | 708 | do |
---|
[313] | 709 | { |
---|
[916] | 710 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
| 711 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
[313] | 712 | } |
---|
| 713 | } |
---|
| 714 | |
---|
[916] | 715 | |
---|
| 716 | |
---|
[313] | 717 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
| 718 | * \param pcCU pointer of current CU |
---|
| 719 | * \param uiTrDepth current tranform split depth |
---|
| 720 | * \param uiAbsPartIdx part index |
---|
| 721 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 722 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 723 | * \param pcResiYuv pointer to residue sample arrays |
---|
[916] | 724 | * |
---|
[313] | 725 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
| 726 | */ |
---|
[916] | 727 | |
---|
[313] | 728 | Void |
---|
[916] | 729 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
| 730 | TComYuv* pcPredYuv, |
---|
| 731 | TComYuv* pcResiYuv, |
---|
| 732 | const ChannelType chType, |
---|
| 733 | TComTU &rTu) |
---|
[313] | 734 | { |
---|
[916] | 735 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
| 736 | TComDataCU *pcCU = rTu.getCU(); |
---|
| 737 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
[313] | 738 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 739 | if( uiTrMode == uiTrDepth ) |
---|
| 740 | { |
---|
[916] | 741 | if (isLuma(chType)) |
---|
| 742 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
| 743 | else |
---|
| 744 | { |
---|
| 745 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
| 746 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
| 747 | { |
---|
| 748 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
| 749 | } |
---|
| 750 | } |
---|
[313] | 751 | } |
---|
| 752 | else |
---|
| 753 | { |
---|
[916] | 754 | TComTURecurse tuRecurseChild(rTu, false); |
---|
| 755 | do |
---|
[313] | 756 | { |
---|
[916] | 757 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
| 758 | } while (tuRecurseChild.nextSection(rTu)); |
---|
[313] | 759 | } |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 763 | { |
---|
[916] | 764 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
| 765 | |
---|
| 766 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
| 767 | |
---|
[313] | 768 | return; |
---|
| 769 | } |
---|
| 770 | |
---|
[916] | 771 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
[313] | 772 | { |
---|
| 773 | |
---|
[916] | 774 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
[313] | 775 | |
---|
[916] | 776 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
| 777 | { |
---|
| 778 | const ComponentID compID=ComponentID(ch); |
---|
| 779 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
[313] | 780 | |
---|
[916] | 781 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
| 782 | } |
---|
[313] | 783 | |
---|
[916] | 784 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
[313] | 785 | } |
---|
| 786 | |
---|
| 787 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
| 788 | * \param pcCU pointer to current CU |
---|
| 789 | * \param uiPartIdx part index |
---|
| 790 | * \param piPCM pointer to PCM code arrays |
---|
| 791 | * \param piReco pointer to reconstructed sample arrays |
---|
| 792 | * \param uiStride stride of reconstructed sample arrays |
---|
| 793 | * \param uiWidth CU width |
---|
| 794 | * \param uiHeight CU height |
---|
| 795 | * \param ttText texture component type |
---|
| 796 | * \returns Void |
---|
| 797 | */ |
---|
[916] | 798 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) |
---|
[313] | 799 | { |
---|
[916] | 800 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
| 801 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
| 802 | const UInt uiPcmLeftShiftBit = g_bitDepth[toChannelType(compID)] - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); |
---|
[313] | 803 | |
---|
[916] | 804 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
[313] | 805 | { |
---|
[916] | 806 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[313] | 807 | { |
---|
| 808 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
| 809 | piPicReco[uiX] = piReco[uiX]; |
---|
| 810 | } |
---|
| 811 | piPCM += uiWidth; |
---|
| 812 | piReco += uiStride; |
---|
| 813 | piPicReco += uiPicStride; |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | /** Function for reconstructing a PCM mode CU. |
---|
| 818 | * \param pcCU pointer to current CU |
---|
| 819 | * \param uiDepth CU Depth |
---|
| 820 | * \returns Void |
---|
| 821 | */ |
---|
| 822 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
| 823 | { |
---|
[916] | 824 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
| 825 | { |
---|
| 826 | const ComponentID compID = ComponentID(ch); |
---|
| 827 | const UInt width = (g_uiMaxCUWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
| 828 | const UInt height = (g_uiMaxCUHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
| 829 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
| 830 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
| 831 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
| 832 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
| 833 | } |
---|
[313] | 834 | } |
---|
| 835 | |
---|
[916] | 836 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
[313] | 837 | * \param pcCU pointer to current CU |
---|
| 838 | * \param uiDepth CU Depth |
---|
| 839 | * \returns Void |
---|
| 840 | */ |
---|
| 841 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
| 842 | { |
---|
[916] | 843 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
| 844 | const UInt numValidComp=getNumberValidComponents(format); |
---|
[313] | 845 | |
---|
[916] | 846 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
[313] | 847 | { |
---|
[916] | 848 | const ComponentID component = ComponentID(componentIndex); |
---|
[313] | 849 | |
---|
[916] | 850 | const UInt width = g_uiMaxCUWidth >> (depth + getComponentScaleX(component, format)); |
---|
| 851 | const UInt height = g_uiMaxCUHeight >> (depth + getComponentScaleY(component, format)); |
---|
[313] | 852 | |
---|
[916] | 853 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
| 854 | Pel *destination = pCU->getPCMSample(component); |
---|
[313] | 855 | |
---|
[916] | 856 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
[313] | 857 | |
---|
[916] | 858 | for (Int line = 0; line < height; line++) |
---|
[313] | 859 | { |
---|
[916] | 860 | for (Int column = 0; column < width; column++) |
---|
| 861 | { |
---|
| 862 | destination[column] = source[column]; |
---|
| 863 | } |
---|
| 864 | |
---|
| 865 | source += sourceStride; |
---|
| 866 | destination += width; |
---|
[313] | 867 | } |
---|
| 868 | } |
---|
| 869 | } |
---|
[540] | 870 | |
---|
[313] | 871 | //! \} |
---|