| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TDecCu.cpp |
|---|
| 35 | \brief CU decoder class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include "TDecCu.h" |
|---|
| 39 | #include "TLibCommon/TComTU.h" |
|---|
| 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 | } |
|---|
| 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 |
|---|
| 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 | */ |
|---|
| 98 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
|---|
| 99 | { |
|---|
| 100 | m_uiMaxDepth = uiMaxDepth+1; |
|---|
| 101 | |
|---|
| 102 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 103 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 104 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
|---|
| 105 | |
|---|
| 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; |
|---|
| 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) ); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | m_bDecodeDQP = false; |
|---|
| 119 | m_IsChromaQpAdjCoded = false; |
|---|
| 120 | |
|---|
| 121 | // initialize partition order. |
|---|
| 122 | UInt* piTmp = &g_auiZscanToRaster[0]; |
|---|
| 123 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
|---|
| 124 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
|---|
| 125 | |
|---|
| 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 | } |
|---|
| 138 | |
|---|
| 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 | */ |
|---|
| 151 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
|---|
| 152 | { |
|---|
| 153 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
|---|
| 154 | { |
|---|
| 155 | setdQPFlag(true); |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
|---|
| 159 | { |
|---|
| 160 | setIsChromaQpAdjCoded(true); |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | #if SVC_EXTENSION |
|---|
| 164 | pCtu->setLayerId(m_layerId); |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| 167 | // start from the top level CU |
|---|
| 168 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | /** \param pcCU pointer of CU data |
|---|
| 172 | */ |
|---|
| 173 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
|---|
| 174 | { |
|---|
| 175 | xDecompressCU( pCtu, 0, 0 ); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | // ==================================================================================================================== |
|---|
| 179 | // Protected member functions |
|---|
| 180 | // ==================================================================================================================== |
|---|
| 181 | |
|---|
| 182 | /**decode end-of-slice flag |
|---|
| 183 | * \param pcCU |
|---|
| 184 | * \param uiAbsPartIdx |
|---|
| 185 | * \param uiDepth |
|---|
| 186 | * \returns Bool |
|---|
| 187 | */ |
|---|
| 188 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
|---|
| 189 | { |
|---|
| 190 | UInt uiIsLastCtuOfSliceSegment; |
|---|
| 191 | |
|---|
| 192 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
|---|
| 193 | { |
|---|
| 194 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
|---|
| 195 | } |
|---|
| 196 | else |
|---|
| 197 | { |
|---|
| 198 | uiIsLastCtuOfSliceSegment=0; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | return uiIsLastCtuOfSliceSegment>0; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | /** decode CU block recursively |
|---|
| 205 | * \param pcCU |
|---|
| 206 | * \param uiAbsPartIdx |
|---|
| 207 | * \param uiDepth |
|---|
| 208 | * \returns Void |
|---|
| 209 | */ |
|---|
| 210 | |
|---|
| 211 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
|---|
| 212 | { |
|---|
| 213 | TComPic* pcPic = pcCU->getPic(); |
|---|
| 214 | UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); |
|---|
| 215 | UInt uiQNumParts = uiCurNumParts>>2; |
|---|
| 216 | |
|---|
| 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; |
|---|
| 222 | |
|---|
| 223 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
|---|
| 224 | #if REPN_FORMAT_IN_VPS |
|---|
| 225 | if( ( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
|---|
| 226 | #else |
|---|
| 227 | if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 228 | #endif |
|---|
| 229 | { |
|---|
| 230 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 231 | } |
|---|
| 232 | else |
|---|
| 233 | { |
|---|
| 234 | bBoundary = true; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 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 | |
|---|
| 246 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 247 | { |
|---|
| 248 | setIsChromaQpAdjCoded(true); |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 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] ]; |
|---|
| 255 | |
|---|
| 256 | #if REPN_FORMAT_IN_VPS |
|---|
| 257 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getPicHeightInLumaSamples() ) ) |
|---|
| 258 | #else |
|---|
| 259 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 260 | #endif |
|---|
| 261 | { |
|---|
| 262 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
|---|
| 263 | } |
|---|
| 264 | else |
|---|
| 265 | { |
|---|
| 266 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | uiIdx += uiQNumParts; |
|---|
| 270 | } |
|---|
| 271 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 272 | { |
|---|
| 273 | if ( getdQPFlag() ) |
|---|
| 274 | { |
|---|
| 275 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
|---|
| 276 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 277 | } |
|---|
| 278 | } |
|---|
| 279 | return; |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 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 | |
|---|
| 288 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 289 | { |
|---|
| 290 | setIsChromaQpAdjCoded(true); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
|---|
| 294 | { |
|---|
| 295 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | // decode CU mode and the partition size |
|---|
| 299 | if( !pcCU->getSlice()->isIntra()) |
|---|
| 300 | { |
|---|
| 301 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 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 | |
|---|
| 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++ ) |
|---|
| 340 | { |
|---|
| 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 | } |
|---|
| 349 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 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 | { |
|---|
| 362 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 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(); |
|---|
| 372 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
|---|
| 373 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
|---|
| 374 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
|---|
| 375 | setdQPFlag( bCodeDQP ); |
|---|
| 376 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
|---|
| 380 | { |
|---|
| 381 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 382 | { |
|---|
| 383 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
|---|
| 387 | { |
|---|
| 388 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 395 | { |
|---|
| 396 | TComPic* pcPic = pCtu->getPic(); |
|---|
| 397 | |
|---|
| 398 | Bool bBoundary = false; |
|---|
| 399 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 400 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
|---|
| 401 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 402 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
|---|
| 403 | |
|---|
| 404 | TComSlice * pcSlice = pCtu->getPic()->getSlice(pCtu->getPic()->getCurrSliceIdx()); |
|---|
| 405 | |
|---|
| 406 | #if REPN_FORMAT_IN_VPS |
|---|
| 407 | if( ( uiRPelX >= pcSlice->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getPicHeightInLumaSamples() ) ) |
|---|
| 408 | |
|---|
| 409 | #else |
|---|
| 410 | if( ( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 411 | #endif |
|---|
| 412 | { |
|---|
| 413 | bBoundary = true; |
|---|
| 414 | } |
|---|
| 415 | |
|---|
| 416 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
|---|
| 417 | { |
|---|
| 418 | UInt uiNextDepth = uiDepth + 1; |
|---|
| 419 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
|---|
| 420 | UInt uiIdx = uiAbsPartIdx; |
|---|
| 421 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
|---|
| 422 | { |
|---|
| 423 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 424 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 425 | |
|---|
| 426 | #if REPN_FORMAT_IN_VPS |
|---|
| 427 | if( ( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
|---|
| 428 | #else |
|---|
| 429 | if( ( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 430 | #endif |
|---|
| 431 | { |
|---|
| 432 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | uiIdx += uiQNumParts; |
|---|
| 436 | } |
|---|
| 437 | return; |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | // Residual reconstruction |
|---|
| 441 | m_ppcYuvResi[uiDepth]->clear(); |
|---|
| 442 | |
|---|
| 443 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx, uiDepth ); |
|---|
| 444 | |
|---|
| 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 | } |
|---|
| 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 | |
|---|
| 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 | #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 | |
|---|
| 488 | // inter recon |
|---|
| 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 | |
|---|
| 495 | // clip for only non-zero cbp case |
|---|
| 496 | if ( pcCU->getQtRootCbf( 0) ) |
|---|
| 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 | } |
|---|
| 504 | #ifdef DEBUG_STRING |
|---|
| 505 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
|---|
| 506 | #endif |
|---|
| 507 | |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | |
|---|
| 511 | Void |
|---|
| 512 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
|---|
| 513 | TComYuv* pcPredYuv, |
|---|
| 514 | TComYuv* pcResiYuv, |
|---|
| 515 | const ComponentID compID, |
|---|
| 516 | TComTU &rTu) |
|---|
| 517 | { |
|---|
| 518 | if (!rTu.ProcessComponentSection(compID)) return; |
|---|
| 519 | const Bool bIsLuma = isLuma(compID); |
|---|
| 520 | |
|---|
| 521 | |
|---|
| 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) |
|---|
| 533 | { |
|---|
| 534 | //------------------------------------------------ |
|---|
| 535 | |
|---|
| 536 | //split at current level if dividing into square sub-TUs |
|---|
| 537 | |
|---|
| 538 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
|---|
| 539 | |
|---|
| 540 | //recurse further |
|---|
| 541 | do |
|---|
| 542 | { |
|---|
| 543 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
|---|
| 544 | } |
|---|
| 545 | while (subTURecurse.nextSection(rTu)); |
|---|
| 546 | |
|---|
| 547 | //------------------------------------------------ |
|---|
| 548 | |
|---|
| 549 | return; |
|---|
| 550 | } |
|---|
| 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 | |
|---|
| 556 | //===== init availability pattern ===== |
|---|
| 557 | Bool bAboveAvail = false; |
|---|
| 558 | Bool bLeftAvail = false; |
|---|
| 559 | |
|---|
| 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 | |
|---|
| 570 | //===== get prediction signal ===== |
|---|
| 571 | |
|---|
| 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 | |
|---|
| 578 | //===== inverse transform ===== |
|---|
| 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) |
|---|
| 592 | { |
|---|
| 593 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
|---|
| 594 | } |
|---|
| 595 | else |
|---|
| 596 | { |
|---|
| 597 | for (UInt y = 0; y < uiHeight; y++) |
|---|
| 598 | for (UInt x = 0; x < uiWidth; x++) |
|---|
| 599 | { |
|---|
| 600 | piResi[(y * uiStride) + x] = 0; |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | #ifdef DEBUG_STRING |
|---|
| 605 | if (psDebug) |
|---|
| 606 | ss << (*psDebug); |
|---|
| 607 | #endif |
|---|
| 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; |
|---|
| 628 | #endif |
|---|
| 629 | |
|---|
| 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)]; |
|---|
| 634 | |
|---|
| 635 | if( useCrossComponentPrediction ) |
|---|
| 636 | { |
|---|
| 637 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
|---|
| 638 | } |
|---|
| 639 | |
|---|
| 640 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 641 | { |
|---|
| 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 | |
|---|
| 656 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 657 | { |
|---|
| 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 |
|---|
| 667 | pRecIPred[ uiX ] = pReco[ uiX ]; |
|---|
| 668 | } |
|---|
| 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 |
|---|
| 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 | } |
|---|
| 698 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
|---|
| 699 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
|---|
| 700 | { |
|---|
| 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 ); |
|---|
| 704 | |
|---|
| 705 | TComTURecurse tuRecurseCU(pcCU, 0); |
|---|
| 706 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
|---|
| 707 | |
|---|
| 708 | do |
|---|
| 709 | { |
|---|
| 710 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
|---|
| 711 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
|---|
| 712 | } |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | |
|---|
| 716 | |
|---|
| 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 |
|---|
| 724 | * |
|---|
| 725 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
|---|
| 726 | */ |
|---|
| 727 | |
|---|
| 728 | Void |
|---|
| 729 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
|---|
| 730 | TComYuv* pcPredYuv, |
|---|
| 731 | TComYuv* pcResiYuv, |
|---|
| 732 | const ChannelType chType, |
|---|
| 733 | TComTU &rTu) |
|---|
| 734 | { |
|---|
| 735 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
|---|
| 736 | TComDataCU *pcCU = rTu.getCU(); |
|---|
| 737 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
|---|
| 738 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
|---|
| 739 | if( uiTrMode == uiTrDepth ) |
|---|
| 740 | { |
|---|
| 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 | } |
|---|
| 751 | } |
|---|
| 752 | else |
|---|
| 753 | { |
|---|
| 754 | TComTURecurse tuRecurseChild(rTu, false); |
|---|
| 755 | do |
|---|
| 756 | { |
|---|
| 757 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
|---|
| 758 | } while (tuRecurseChild.nextSection(rTu)); |
|---|
| 759 | } |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
|---|
| 763 | { |
|---|
| 764 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
|---|
| 765 | |
|---|
| 766 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
|---|
| 767 | |
|---|
| 768 | return; |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 772 | { |
|---|
| 773 | |
|---|
| 774 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
|---|
| 775 | |
|---|
| 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]) |
|---|
| 780 | |
|---|
| 781 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
|---|
| 782 | } |
|---|
| 783 | |
|---|
| 784 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
|---|
| 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 | */ |
|---|
| 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) |
|---|
| 799 | { |
|---|
| 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)); |
|---|
| 803 | |
|---|
| 804 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 805 | { |
|---|
| 806 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 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 | { |
|---|
| 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 | } |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
|---|
| 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 | { |
|---|
| 843 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
|---|
| 844 | const UInt numValidComp=getNumberValidComponents(format); |
|---|
| 845 | |
|---|
| 846 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
|---|
| 847 | { |
|---|
| 848 | const ComponentID component = ComponentID(componentIndex); |
|---|
| 849 | |
|---|
| 850 | const UInt width = g_uiMaxCUWidth >> (depth + getComponentScaleX(component, format)); |
|---|
| 851 | const UInt height = g_uiMaxCUHeight >> (depth + getComponentScaleY(component, format)); |
|---|
| 852 | |
|---|
| 853 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
|---|
| 854 | Pel *destination = pCU->getPCMSample(component); |
|---|
| 855 | |
|---|
| 856 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
|---|
| 857 | |
|---|
| 858 | for (Int line = 0; line < height; line++) |
|---|
| 859 | { |
|---|
| 860 | for (Int column = 0; column < width; column++) |
|---|
| 861 | { |
|---|
| 862 | destination[column] = source[column]; |
|---|
| 863 | } |
|---|
| 864 | |
|---|
| 865 | source += sourceStride; |
|---|
| 866 | destination += width; |
|---|
| 867 | } |
|---|
| 868 | } |
|---|
| 869 | } |
|---|
| 870 | |
|---|
| 871 | //! \} |
|---|