[5] | 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-2011, 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 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 | */ |
---|
[2] | 33 | |
---|
| 34 | |
---|
[5] | 35 | |
---|
[2] | 36 | /** \file TDecCu.cpp |
---|
| 37 | \brief CU decoder class |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #include "TDecCu.h" |
---|
| 41 | |
---|
| 42 | // ==================================================================================================================== |
---|
| 43 | // Constructor / destructor / create / destroy |
---|
| 44 | // ==================================================================================================================== |
---|
| 45 | |
---|
| 46 | TDecCu::TDecCu() |
---|
| 47 | { |
---|
| 48 | m_ppcYuvResi = NULL; |
---|
| 49 | m_ppcYuvReco = NULL; |
---|
| 50 | m_ppcYuvResPred = NULL; |
---|
| 51 | m_ppcCU = NULL; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | TDecCu::~TDecCu() |
---|
| 55 | { |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
| 59 | { |
---|
| 60 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 61 | m_pcTrQuant = pcTrQuant; |
---|
| 62 | m_pcPrediction = pcPrediction; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | \param uiMaxDepth total number of allowable depth |
---|
| 67 | \param uiMaxWidth largest CU width |
---|
| 68 | \param uiMaxHeight largest CU height |
---|
| 69 | */ |
---|
| 70 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
| 71 | { |
---|
| 72 | m_uiMaxDepth = uiMaxDepth+1; |
---|
| 73 | |
---|
| 74 | m_ppcYuvResi = new TComYuv* [m_uiMaxDepth-1]; |
---|
| 75 | m_ppcYuvReco = new TComYuv* [m_uiMaxDepth-1]; |
---|
| 76 | m_ppcYuvResPred = new TComYuv* [m_uiMaxDepth-1]; |
---|
| 77 | m_ppcCU = new TComDataCU* [m_uiMaxDepth-1]; |
---|
| 78 | |
---|
| 79 | UInt uiNumPartitions; |
---|
| 80 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 81 | { |
---|
| 82 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
| 83 | UInt uiWidth = uiMaxWidth >> ui; |
---|
| 84 | UInt uiHeight = uiMaxHeight >> ui; |
---|
| 85 | |
---|
| 86 | m_ppcYuvResi [ui] = new TComYuv; m_ppcYuvResi [ui]->create( uiWidth, uiHeight ); |
---|
| 87 | m_ppcYuvReco [ui] = new TComYuv; m_ppcYuvReco [ui]->create( uiWidth, uiHeight ); |
---|
| 88 | m_ppcYuvResPred[ui] = new TComYuv; m_ppcYuvResPred[ui]->create( uiWidth, uiHeight ); |
---|
| 89 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true ); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | // initialize partition order. |
---|
| 93 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 94 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
| 95 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 96 | |
---|
| 97 | // initialize conversion matrix from partition index to pel |
---|
| 98 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | Void TDecCu::destroy() |
---|
| 102 | { |
---|
| 103 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 104 | { |
---|
| 105 | m_ppcYuvResi [ui]->destroy(); delete m_ppcYuvResi [ui]; m_ppcYuvResi [ui] = NULL; |
---|
| 106 | m_ppcYuvReco [ui]->destroy(); delete m_ppcYuvReco [ui]; m_ppcYuvReco [ui] = NULL; |
---|
| 107 | m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL; |
---|
| 108 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
| 112 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
| 113 | delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL; |
---|
| 114 | delete [] m_ppcCU; m_ppcCU = NULL; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | // ==================================================================================================================== |
---|
| 118 | // Public member functions |
---|
| 119 | // ==================================================================================================================== |
---|
| 120 | |
---|
| 121 | /** \param pcCU pointer of CU data |
---|
| 122 | \param ruiIsLast last data? |
---|
| 123 | */ |
---|
| 124 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
| 125 | { |
---|
| 126 | #if SNY_DQP |
---|
| 127 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
| 128 | { |
---|
| 129 | pcCU->setdQPFlag(true); |
---|
| 130 | } |
---|
| 131 | #endif//SNY_DQP |
---|
| 132 | // start from the top level CU |
---|
| 133 | xDecodeCU( pcCU, 0, 0 ); |
---|
| 134 | |
---|
| 135 | #if SNY_DQP |
---|
| 136 | // dQP: only for LCU |
---|
| 137 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
| 138 | { |
---|
| 139 | if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 ) |
---|
| 140 | { |
---|
| 141 | } |
---|
| 142 | else if ( pcCU->getdQPFlag())// non-skip |
---|
| 143 | { |
---|
| 144 | m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 ); |
---|
| 145 | pcCU->setdQPFlag(false); |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | #else |
---|
| 149 | // dQP: only for LCU |
---|
| 150 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
| 151 | { |
---|
| 152 | if ( pcCU->isSkipped( 0 ) && pcCU->getDepth( 0 ) == 0 ) |
---|
| 153 | { |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | m_pcEntropyDecoder->decodeQP( pcCU, 0, 0 ); |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | #endif//SNY_DQP |
---|
| 161 | |
---|
| 162 | //--- Read terminating bit --- |
---|
| 163 | m_pcEntropyDecoder->decodeTerminatingBit( ruiIsLast ); |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | /** \param pcCU pointer of CU data |
---|
| 167 | */ |
---|
| 168 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
| 169 | { |
---|
| 170 | xDecompressCU( pcCU, pcCU, 0, 0 ); |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | // ==================================================================================================================== |
---|
| 174 | // Protected member functions |
---|
| 175 | // ==================================================================================================================== |
---|
| 176 | |
---|
| 177 | /** decode CU block recursively |
---|
| 178 | * \param pcCU |
---|
| 179 | * \param uiAbsPartIdx |
---|
| 180 | * \param uiDepth |
---|
| 181 | * \returns Void |
---|
| 182 | */ |
---|
| 183 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 184 | { |
---|
| 185 | TComPic* pcPic = pcCU->getPic(); |
---|
| 186 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 187 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
| 188 | |
---|
| 189 | Bool bBoundary = false; |
---|
| 190 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 191 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 192 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 193 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 194 | |
---|
| 195 | if( ( uiRPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiBPelY < pcCU->getSlice()->getSPS()->getHeight() ) ) |
---|
| 196 | { |
---|
[5] | 197 | #if HHI_MPI |
---|
[2] | 198 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
[5] | 199 | #endif |
---|
[2] | 200 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 201 | } |
---|
| 202 | else |
---|
| 203 | { |
---|
| 204 | bBoundary = true; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 208 | { |
---|
| 209 | UInt uiIdx = uiAbsPartIdx; |
---|
| 210 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 211 | { |
---|
| 212 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 213 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 214 | |
---|
| 215 | if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) ) |
---|
| 216 | xDecodeCU( pcCU, uiIdx, uiDepth+1 ); |
---|
| 217 | |
---|
| 218 | uiIdx += uiQNumParts; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | return; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | #if TSB_ALF_HEADER |
---|
| 225 | #else |
---|
| 226 | m_pcEntropyDecoder->decodeAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 227 | #endif |
---|
| 228 | |
---|
| 229 | // decode CU mode and the partition size |
---|
[5] | 230 | #if HHI_MPI |
---|
[2] | 231 | if( !pcCU->getSlice()->isIntra() && pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
[5] | 232 | #else |
---|
| 233 | if( !pcCU->getSlice()->isIntra() ) |
---|
| 234 | #endif |
---|
[2] | 235 | { |
---|
| 236 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
| 241 | { |
---|
| 242 | #if HHI_MRG_SKIP |
---|
| 243 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 244 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
| 245 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 246 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 247 | UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand |
---|
| 248 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
| 249 | { |
---|
| 250 | uhInterDirNeighbours[ui] = 0; |
---|
| 251 | uiNeighbourCandIdx[ui] = 0; |
---|
| 252 | } |
---|
| 253 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx ); |
---|
| 254 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
| 255 | { |
---|
| 256 | pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiAbsPartIdx, 0, uiDepth ); |
---|
| 257 | } |
---|
| 258 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
| 259 | #else |
---|
| 260 | pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth); |
---|
| 261 | pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiAbsPartIdx, 0, uiDepth); |
---|
| 262 | |
---|
| 263 | pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth); |
---|
| 264 | pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiAbsPartIdx, 0, uiDepth); |
---|
| 265 | |
---|
| 266 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry ) |
---|
| 267 | { |
---|
| 268 | m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, m_ppcCU[uiDepth]); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry ) |
---|
| 272 | { |
---|
| 273 | m_pcEntropyDecoder->decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, m_ppcCU[uiDepth]); |
---|
| 274 | } |
---|
| 275 | #endif |
---|
[5] | 276 | #if HHI_MPI |
---|
[2] | 277 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
| 278 | { |
---|
| 279 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 280 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
| 281 | |
---|
| 282 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 283 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
| 284 | { |
---|
| 285 | const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
| 286 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP ); |
---|
| 287 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
| 288 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
| 289 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
| 290 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | #endif |
---|
| 294 | |
---|
[5] | 295 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 296 | m_pcEntropyDecoder->decodeResPredFlag( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
[5] | 297 | #endif |
---|
[2] | 298 | return; |
---|
| 299 | } |
---|
| 300 | |
---|
[5] | 301 | #if HHI_MPI |
---|
[2] | 302 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
| 303 | { |
---|
[5] | 304 | #endif |
---|
[2] | 305 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 306 | |
---|
| 307 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 308 | |
---|
| 309 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 310 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
| 311 | |
---|
[5] | 312 | #if HHI_MPI |
---|
[2] | 313 | if( !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 314 | { |
---|
| 315 | m_ppcCU[uiDepth] ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 316 | m_ppcCU[uiDepth] ->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[5] | 317 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 318 | m_pcEntropyDecoder->decodeResPredFlag ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
[5] | 319 | #endif |
---|
[2] | 320 | } |
---|
| 321 | |
---|
| 322 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
| 323 | { |
---|
| 324 | assert( pcCU->getZorderIdxInCU() == 0 ); |
---|
| 325 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 326 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
| 327 | |
---|
| 328 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 329 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
| 330 | { |
---|
| 331 | const UChar uhNewDepth = max( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
| 332 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER ); |
---|
| 333 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
| 334 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
| 335 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
| 336 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 340 | { |
---|
| 341 | UInt uiIdx = uiAbsPartIdx; |
---|
| 342 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 343 | { |
---|
| 344 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 345 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 346 | |
---|
| 347 | if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) ) |
---|
| 348 | xDecodeCU( pcCU, uiIdx, uiDepth+1 ); |
---|
| 349 | |
---|
| 350 | uiIdx += uiQNumParts; |
---|
| 351 | } |
---|
| 352 | return; |
---|
| 353 | } |
---|
| 354 | } |
---|
[5] | 355 | } |
---|
[2] | 356 | #endif |
---|
[5] | 357 | |
---|
[2] | 358 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 359 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 360 | |
---|
| 361 | // Coefficient decoding |
---|
| 362 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight ); |
---|
| 363 | |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 367 | { |
---|
| 368 | TComPic* pcPic = pcCU->getPic(); |
---|
| 369 | |
---|
| 370 | Bool bBoundary = false; |
---|
| 371 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 372 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 373 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 374 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 375 | |
---|
| 376 | if( ( uiRPelX >= pcCU->getSlice()->getSPS()->getWidth() ) || ( uiBPelY >= pcCU->getSlice()->getSPS()->getHeight() ) ) |
---|
| 377 | { |
---|
| 378 | bBoundary = true; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 382 | { |
---|
| 383 | UInt uiNextDepth = uiDepth + 1; |
---|
| 384 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
| 385 | UInt uiIdx = uiAbsPartIdx; |
---|
| 386 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
| 387 | { |
---|
| 388 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 389 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 390 | |
---|
| 391 | if( ( uiLPelX < pcCU->getSlice()->getSPS()->getWidth() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getHeight() ) ) |
---|
| 392 | xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth ); |
---|
| 393 | |
---|
| 394 | uiIdx += uiQNumParts; |
---|
| 395 | } |
---|
| 396 | return; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | // Residual reconstruction |
---|
| 400 | m_ppcYuvResi[uiDepth]->clear(); |
---|
| 401 | |
---|
| 402 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 403 | |
---|
| 404 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
| 405 | { |
---|
| 406 | case MODE_SKIP: |
---|
| 407 | case MODE_INTER: |
---|
| 408 | xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 409 | break; |
---|
| 410 | case MODE_INTRA: |
---|
| 411 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 412 | break; |
---|
| 413 | default: |
---|
| 414 | assert(0); |
---|
| 415 | break; |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 422 | { |
---|
[5] | 423 | #if HHI_MPI |
---|
[2] | 424 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
| 425 | pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth ); |
---|
| 426 | #endif |
---|
| 427 | |
---|
| 428 | // inter prediction |
---|
| 429 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
| 430 | |
---|
[5] | 431 | #if HHI_MPI |
---|
[2] | 432 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
| 433 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 434 | #endif |
---|
| 435 | |
---|
[5] | 436 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 437 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 438 | { |
---|
| 439 | AOF( pcCU->getResPredAvail( 0 ) ); |
---|
| 440 | Bool bOK = pcCU->getResidualSamples( 0, m_ppcYuvResPred[uiDepth] ); |
---|
| 441 | AOF( bOK ); |
---|
| 442 | m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 443 | } |
---|
[5] | 444 | #endif |
---|
| 445 | |
---|
[2] | 446 | // inter recon |
---|
| 447 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
| 448 | |
---|
| 449 | // clip for only non-zero cbp case |
---|
| 450 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
| 451 | { |
---|
| 452 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 453 | } |
---|
| 454 | else |
---|
| 455 | { |
---|
[5] | 456 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 457 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 458 | { |
---|
| 459 | m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 460 | } |
---|
[5] | 461 | #endif |
---|
[2] | 462 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | Void TDecCu::xDecodeIntraTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel* piReco, Pel* piPred, Pel* piResi, UInt uiStride, TCoeff* pCoeff, UInt uiWidth, UInt uiHeight, UInt uiCurrDepth ) |
---|
| 467 | { |
---|
| 468 | if( pcCU->getTransformIdx(0) == uiCurrDepth ) |
---|
| 469 | { |
---|
| 470 | UInt uiX, uiY; |
---|
| 471 | TComPattern* pcPattern = pcCU->getPattern(); |
---|
| 472 | UInt uiZorder = pcCU->getZorderIdxInCU()+uiPartIdx; |
---|
| 473 | Pel* pPred = piPred; |
---|
| 474 | Pel* pResi = piResi; |
---|
| 475 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), uiZorder); |
---|
| 476 | UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
| 477 | |
---|
| 478 | pcPattern->initPattern( pcCU, uiCurrDepth, uiPartIdx ); |
---|
| 479 | |
---|
| 480 | Bool bAboveAvail = false; |
---|
| 481 | Bool bLeftAvail = false; |
---|
| 482 | |
---|
| 483 | pcPattern->initAdiPattern(pcCU, uiPartIdx, uiCurrDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail); |
---|
| 484 | |
---|
| 485 | m_pcPrediction->predIntraLumaAng( pcPattern, pcCU->getLumaIntraDir(uiPartIdx), pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
| 486 | |
---|
| 487 | m_pcTrQuant->setQPforQuant( pcCU->getQP(uiPartIdx), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA ); |
---|
| 488 | #if INTRA_DST_TYPE_7 |
---|
| 489 | m_pcTrQuant->invtransformNxN(TEXT_LUMA, pcCU->getLumaIntraDir(uiPartIdx), pResi, uiStride, pCoeff, uiWidth, uiHeight ); |
---|
| 490 | #else |
---|
| 491 | m_pcTrQuant->invtransformNxN( pResi, uiStride, pCoeff, uiWidth, uiHeight ); |
---|
| 492 | #endif |
---|
| 493 | // Reconstruction |
---|
| 494 | { |
---|
| 495 | pResi = piResi; |
---|
| 496 | pPred = piPred; |
---|
| 497 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 498 | { |
---|
| 499 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 500 | { |
---|
| 501 | piReco [uiX] = Clip(pPred[uiX] + pResi[uiX]); |
---|
| 502 | piPicReco[uiX] = piReco[uiX]; |
---|
| 503 | } |
---|
| 504 | piReco += uiStride; |
---|
| 505 | pPred += uiStride; |
---|
| 506 | pResi += uiStride; |
---|
| 507 | piPicReco += uiPicStride; |
---|
| 508 | } |
---|
| 509 | } |
---|
| 510 | } |
---|
| 511 | else |
---|
| 512 | { |
---|
| 513 | uiCurrDepth++; |
---|
| 514 | uiWidth >>= 1; |
---|
| 515 | uiHeight >>= 1; |
---|
| 516 | UInt uiPartOffset = pcCU->getTotalNumPart()>>(uiCurrDepth<<1); |
---|
| 517 | UInt uiCoeffOffset = uiWidth * uiHeight; |
---|
| 518 | UInt uiPelOffset = uiHeight * uiStride; |
---|
| 519 | Pel* pResi = piResi; |
---|
| 520 | Pel* pReco = piReco; |
---|
| 521 | Pel* pPred = piPred; |
---|
| 522 | xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth ); |
---|
| 523 | uiPartIdx += uiPartOffset; |
---|
| 524 | pCoeff += uiCoeffOffset; |
---|
| 525 | pResi = piResi + uiWidth; |
---|
| 526 | pReco = piReco + uiWidth; |
---|
| 527 | pPred = piPred + uiWidth; |
---|
| 528 | xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth ); |
---|
| 529 | uiPartIdx += uiPartOffset; |
---|
| 530 | pCoeff += uiCoeffOffset; |
---|
| 531 | pResi = piResi + uiPelOffset; |
---|
| 532 | pReco = piReco + uiPelOffset; |
---|
| 533 | pPred = piPred + uiPelOffset; |
---|
| 534 | xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth ); |
---|
| 535 | uiPartIdx += uiPartOffset; |
---|
| 536 | pCoeff += uiCoeffOffset; |
---|
| 537 | pResi = piResi + uiPelOffset + uiWidth; |
---|
| 538 | pReco = piReco + uiPelOffset + uiWidth; |
---|
| 539 | pPred = piPred + uiPelOffset + uiWidth; |
---|
| 540 | xDecodeIntraTexture( pcCU, uiPartIdx, pReco, pPred, pResi, uiStride, pCoeff, uiWidth, uiHeight, uiCurrDepth ); |
---|
| 541 | } |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | // ADI chroma |
---|
| 545 | Void TDecCu::xRecurIntraInvTransChroma(TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piResi, Pel* piPred, Pel* piReco, UInt uiStride, TCoeff* piCoeff, UInt uiWidth, UInt uiHeight, UInt uiTrMode, UInt uiCurrTrMode, TextType eText ) |
---|
| 546 | { |
---|
| 547 | if( uiTrMode == uiCurrTrMode ) |
---|
| 548 | { |
---|
| 549 | UInt uiX, uiY; |
---|
| 550 | UInt uiZorder = pcCU->getZorderIdxInCU()+uiAbsPartIdx; |
---|
| 551 | Pel* pResi = piResi; |
---|
| 552 | Pel* pPred = piPred; |
---|
| 553 | Pel* piPicReco; |
---|
| 554 | if( eText == TEXT_CHROMA_U ) |
---|
| 555 | piPicReco= pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), uiZorder); |
---|
| 556 | else |
---|
| 557 | piPicReco= pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), uiZorder); |
---|
| 558 | |
---|
| 559 | UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 560 | |
---|
| 561 | pcCU->getPattern()->initPattern( pcCU, uiCurrTrMode, uiAbsPartIdx ); |
---|
| 562 | |
---|
| 563 | Bool bAboveAvail = false; |
---|
| 564 | Bool bLeftAvail = false; |
---|
| 565 | |
---|
| 566 | pcCU->getPattern()->initAdiPatternChroma(pcCU,uiAbsPartIdx, uiCurrTrMode, m_pcPrediction->getPredicBuf(),m_pcPrediction->getPredicBufWidth(),m_pcPrediction->getPredicBufHeight(),bAboveAvail,bLeftAvail); |
---|
| 567 | |
---|
| 568 | UInt uiModeL = pcCU->getLumaIntraDir(0); |
---|
| 569 | UInt uiMode = pcCU->getChromaIntraDir(0); |
---|
| 570 | |
---|
| 571 | if (uiMode==4) uiMode = uiModeL; |
---|
| 572 | |
---|
| 573 | Int* pPatChr; |
---|
| 574 | |
---|
| 575 | if (eText==TEXT_CHROMA_U) |
---|
| 576 | { |
---|
| 577 | pPatChr= pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ); |
---|
| 578 | } |
---|
| 579 | else // (eText==TEXT_CHROMA_V) |
---|
| 580 | { |
---|
| 581 | pPatChr= pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ); |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | m_pcPrediction-> predIntraChromaAng( pcCU->getPattern(), pPatChr, uiMode, pPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
| 585 | |
---|
| 586 | // Inverse Transform |
---|
| 587 | if( pcCU->getCbf(0, eText, uiCurrTrMode) ) |
---|
| 588 | { |
---|
| 589 | #if INTRA_DST_TYPE_7 |
---|
| 590 | m_pcTrQuant->invtransformNxN( eText, REG_DCT, pResi, uiStride, piCoeff, uiWidth, uiHeight); |
---|
| 591 | #else |
---|
| 592 | m_pcTrQuant->invtransformNxN( pResi, uiStride, piCoeff, uiWidth, uiHeight ); |
---|
| 593 | #endif |
---|
| 594 | } |
---|
| 595 | pResi = piResi; |
---|
| 596 | |
---|
| 597 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 598 | { |
---|
| 599 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 600 | { |
---|
| 601 | piReco [uiX] = Clip( pPred[uiX] + pResi[uiX] ); |
---|
| 602 | piPicReco[uiX] = piReco[uiX]; |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | pPred += uiStride; |
---|
| 606 | pResi += uiStride; |
---|
| 607 | piReco += uiStride; |
---|
| 608 | piPicReco += uiPicStride; |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | else |
---|
| 612 | { |
---|
| 613 | uiCurrTrMode++; |
---|
| 614 | uiWidth >>= 1; |
---|
| 615 | uiHeight >>= 1; |
---|
| 616 | UInt uiCoeffOffset = uiWidth*uiHeight; |
---|
| 617 | UInt uiPelOffset = uiHeight*uiStride; |
---|
| 618 | UInt uiPartOffst = pcCU->getTotalNumPart()>>(uiCurrTrMode<<1); |
---|
| 619 | Pel* pResi = piResi; |
---|
| 620 | Pel* pPred = piPred; |
---|
| 621 | Pel* pReco = piReco; |
---|
| 622 | xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText ); |
---|
| 623 | uiAbsPartIdx += uiPartOffst; |
---|
| 624 | piCoeff += uiCoeffOffset; |
---|
| 625 | pResi = piResi + uiWidth; pPred = piPred + uiWidth; pReco = piReco + uiWidth; |
---|
| 626 | xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText ); |
---|
| 627 | uiAbsPartIdx += uiPartOffst; |
---|
| 628 | piCoeff += uiCoeffOffset; |
---|
| 629 | pResi = piResi + uiPelOffset; pPred = piPred + uiPelOffset; pReco = piReco + uiPelOffset; |
---|
| 630 | xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText ); |
---|
| 631 | uiAbsPartIdx += uiPartOffst; |
---|
| 632 | piCoeff += uiCoeffOffset; |
---|
| 633 | pResi = piResi + uiPelOffset + uiWidth; pPred = piPred + uiPelOffset + uiWidth; pReco = piReco + uiPelOffset + uiWidth; |
---|
| 634 | xRecurIntraInvTransChroma( pcCU, uiAbsPartIdx, pResi, pPred, pReco, uiStride, piCoeff, uiWidth, uiHeight, uiTrMode, uiCurrTrMode, eText ); |
---|
| 635 | } |
---|
| 636 | } |
---|
| 637 | |
---|
| 638 | Void |
---|
| 639 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
| 640 | UInt uiTrDepth, |
---|
| 641 | UInt uiAbsPartIdx, |
---|
| 642 | TComYuv* pcRecoYuv, |
---|
| 643 | TComYuv* pcPredYuv, |
---|
| 644 | TComYuv* pcResiYuv ) |
---|
| 645 | { |
---|
| 646 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
| 647 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
| 648 | UInt uiStride = pcRecoYuv->getStride (); |
---|
| 649 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 650 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 651 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 652 | |
---|
| 653 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
| 654 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 655 | |
---|
| 656 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
| 657 | |
---|
| 658 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 659 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
| 660 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
| 661 | |
---|
| 662 | //===== init availability pattern ===== |
---|
| 663 | Bool bAboveAvail = false; |
---|
| 664 | Bool bLeftAvail = false; |
---|
| 665 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 666 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 667 | m_pcPrediction->getPredicBuf (), |
---|
| 668 | m_pcPrediction->getPredicBufWidth (), |
---|
| 669 | m_pcPrediction->getPredicBufHeight (), |
---|
| 670 | bAboveAvail, bLeftAvail ); |
---|
| 671 | |
---|
[5] | 672 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 673 | if( uiLumaPredMode > MAX_MODE_ID_INTRA_DIR ) |
---|
| 674 | { |
---|
| 675 | m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false ); |
---|
| 676 | } |
---|
| 677 | else |
---|
| 678 | #endif |
---|
| 679 | { |
---|
| 680 | //===== get prediction signal ===== |
---|
| 681 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
| 682 | } |
---|
| 683 | //===== inverse transform ===== |
---|
| 684 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA ); |
---|
| 685 | #if INTRA_DST_TYPE_7 |
---|
| 686 | m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight ); |
---|
| 687 | #else |
---|
| 688 | m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight ); |
---|
| 689 | #endif |
---|
| 690 | |
---|
| 691 | |
---|
| 692 | //===== reconstruction ===== |
---|
| 693 | { |
---|
| 694 | Pel* pPred = piPred; |
---|
| 695 | Pel* pResi = piResi; |
---|
| 696 | Pel* pReco = piReco; |
---|
| 697 | Pel* pRecIPred = piRecIPred; |
---|
| 698 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 699 | { |
---|
| 700 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 701 | { |
---|
| 702 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 703 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 704 | } |
---|
| 705 | pPred += uiStride; |
---|
| 706 | pResi += uiStride; |
---|
| 707 | pReco += uiStride; |
---|
| 708 | pRecIPred += uiRecIPredStride; |
---|
| 709 | } |
---|
| 710 | } |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | Void |
---|
| 715 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
| 716 | UInt uiTrDepth, |
---|
| 717 | UInt uiAbsPartIdx, |
---|
| 718 | TComYuv* pcRecoYuv, |
---|
| 719 | TComYuv* pcPredYuv, |
---|
| 720 | TComYuv* pcResiYuv, |
---|
| 721 | UInt uiChromaId ) |
---|
| 722 | { |
---|
| 723 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
| 724 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
| 725 | if( uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 726 | { |
---|
| 727 | assert( uiTrDepth > 0 ); |
---|
| 728 | uiTrDepth--; |
---|
| 729 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
| 730 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
| 731 | if( !bFirstQ ) |
---|
| 732 | { |
---|
| 733 | return; |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
| 738 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 739 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 740 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
| 741 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 742 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 743 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 744 | |
---|
| 745 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
| 746 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 747 | |
---|
| 748 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
| 749 | |
---|
| 750 | #if !LM_CHROMA |
---|
| 751 | if( uiChromaPredMode == 4 ) |
---|
| 752 | { |
---|
| 753 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
| 754 | } |
---|
| 755 | #endif |
---|
| 756 | |
---|
| 757 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 758 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
| 759 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 760 | |
---|
| 761 | //===== init availability pattern ===== |
---|
| 762 | Bool bAboveAvail = false; |
---|
| 763 | Bool bLeftAvail = false; |
---|
| 764 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 765 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 766 | m_pcPrediction->getPredicBuf (), |
---|
| 767 | m_pcPrediction->getPredicBufWidth (), |
---|
| 768 | m_pcPrediction->getPredicBufHeight (), |
---|
| 769 | bAboveAvail, bLeftAvail ); |
---|
| 770 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
| 771 | |
---|
| 772 | //===== get prediction signal ===== |
---|
| 773 | #if LM_CHROMA |
---|
| 774 | if(pcCU->getSlice()->getSPS()->getUseLMChroma() && uiChromaPredMode == 3) |
---|
| 775 | { |
---|
| 776 | m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId ); |
---|
| 777 | } |
---|
| 778 | else |
---|
| 779 | { |
---|
| 780 | if( uiChromaPredMode == 4 ) |
---|
| 781 | { |
---|
| 782 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
| 783 | } |
---|
| 784 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
| 785 | } |
---|
| 786 | #else // LM_CHROMA |
---|
| 787 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
| 788 | #endif |
---|
| 789 | |
---|
| 790 | //===== inverse transform ===== |
---|
| 791 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText ); |
---|
| 792 | #if INTRA_DST_TYPE_7 |
---|
| 793 | m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight ); |
---|
| 794 | #else |
---|
| 795 | m_pcTrQuant->invtransformNxN( piResi, uiStride, pcCoeff, uiWidth, uiHeight ); |
---|
| 796 | #endif |
---|
| 797 | |
---|
| 798 | //===== reconstruction ===== |
---|
| 799 | { |
---|
| 800 | Pel* pPred = piPred; |
---|
| 801 | Pel* pResi = piResi; |
---|
| 802 | Pel* pReco = piReco; |
---|
| 803 | Pel* pRecIPred = piRecIPred; |
---|
| 804 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 805 | { |
---|
| 806 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 807 | { |
---|
| 808 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 809 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 810 | } |
---|
| 811 | pPred += uiStride; |
---|
| 812 | pResi += uiStride; |
---|
| 813 | pReco += uiStride; |
---|
| 814 | pRecIPred += uiRecIPredStride; |
---|
| 815 | } |
---|
| 816 | } |
---|
| 817 | } |
---|
| 818 | |
---|
| 819 | Void |
---|
| 820 | TDecCu::xIntraRecQT( TComDataCU* pcCU, |
---|
| 821 | UInt uiTrDepth, |
---|
| 822 | UInt uiAbsPartIdx, |
---|
| 823 | TComYuv* pcRecoYuv, |
---|
| 824 | TComYuv* pcPredYuv, |
---|
| 825 | TComYuv* pcResiYuv ) |
---|
| 826 | { |
---|
| 827 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 828 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 829 | if( uiTrMode == uiTrDepth ) |
---|
| 830 | { |
---|
| 831 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 832 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 833 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 834 | } |
---|
| 835 | else |
---|
| 836 | { |
---|
| 837 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 838 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 839 | { |
---|
| 840 | xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 841 | } |
---|
| 842 | } |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | Void |
---|
| 846 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 847 | { |
---|
| 848 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
| 849 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
| 850 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
| 851 | |
---|
| 852 | #if LM_CHROMA |
---|
| 853 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 854 | { |
---|
| 855 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 859 | { |
---|
| 860 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 861 | } |
---|
| 862 | #else |
---|
| 863 | |
---|
| 864 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 865 | { |
---|
| 866 | xIntraRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 867 | } |
---|
| 868 | #endif |
---|
| 869 | |
---|
| 870 | } |
---|
| 871 | |
---|
| 872 | #if LM_CHROMA |
---|
| 873 | |
---|
| 874 | /** Funtion for deriving recontructed PU/CU Luma sample with QTree structure |
---|
| 875 | * \param pcCU pointer of current CU |
---|
| 876 | * \param uiTrDepth current tranform split depth |
---|
| 877 | * \param uiAbsPartIdx part index |
---|
| 878 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 879 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 880 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 881 | * |
---|
| 882 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
| 883 | */ |
---|
| 884 | Void |
---|
| 885 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
| 886 | UInt uiTrDepth, |
---|
| 887 | UInt uiAbsPartIdx, |
---|
| 888 | TComYuv* pcRecoYuv, |
---|
| 889 | TComYuv* pcPredYuv, |
---|
| 890 | TComYuv* pcResiYuv ) |
---|
| 891 | { |
---|
| 892 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 893 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 894 | if( uiTrMode == uiTrDepth ) |
---|
| 895 | { |
---|
| 896 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 897 | } |
---|
| 898 | else |
---|
| 899 | { |
---|
| 900 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 901 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 902 | { |
---|
| 903 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 904 | } |
---|
| 905 | } |
---|
| 906 | } |
---|
| 907 | |
---|
| 908 | /** Funtion for deriving recontructed PU/CU chroma samples with QTree structure |
---|
| 909 | * \param pcCU pointer of current CU |
---|
| 910 | * \param uiTrDepth current tranform split depth |
---|
| 911 | * \param uiAbsPartIdx part index |
---|
| 912 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 913 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 914 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 915 | * |
---|
| 916 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
| 917 | */ |
---|
| 918 | Void |
---|
| 919 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
| 920 | UInt uiTrDepth, |
---|
| 921 | UInt uiAbsPartIdx, |
---|
| 922 | TComYuv* pcRecoYuv, |
---|
| 923 | TComYuv* pcPredYuv, |
---|
| 924 | TComYuv* pcResiYuv ) |
---|
| 925 | { |
---|
| 926 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 927 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 928 | if( uiTrMode == uiTrDepth ) |
---|
| 929 | { |
---|
| 930 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 931 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 932 | } |
---|
| 933 | else |
---|
| 934 | { |
---|
| 935 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 936 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 937 | { |
---|
| 938 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 939 | } |
---|
| 940 | } |
---|
| 941 | } |
---|
| 942 | #endif |
---|
| 943 | |
---|
| 944 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 945 | { |
---|
| 946 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 947 | |
---|
| 948 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
| 949 | |
---|
| 950 | return; |
---|
| 951 | } |
---|
| 952 | |
---|
| 953 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 954 | { |
---|
| 955 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 956 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 957 | TCoeff* piCoeff; |
---|
| 958 | |
---|
| 959 | Pel* pResi; |
---|
| 960 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 961 | |
---|
| 962 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
| 963 | |
---|
| 964 | // Y |
---|
| 965 | piCoeff = pcCU->getCoeffY(); |
---|
| 966 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
| 967 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA ); |
---|
| 968 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
| 969 | |
---|
| 970 | // Cb and Cr |
---|
| 971 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA ); |
---|
| 972 | |
---|
| 973 | uiWidth >>= 1; |
---|
| 974 | uiHeight >>= 1; |
---|
| 975 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
| 976 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 977 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
| 978 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 979 | } |
---|
| 980 | |
---|