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