[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | /** \file TDecCu.cpp |
---|
| 35 | \brief CU decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecCu.h" |
---|
| 39 | |
---|
[56] | 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
[2] | 43 | // ==================================================================================================================== |
---|
| 44 | // Constructor / destructor / create / destroy |
---|
| 45 | // ==================================================================================================================== |
---|
| 46 | |
---|
| 47 | TDecCu::TDecCu() |
---|
| 48 | { |
---|
[56] | 49 | m_ppcYuvResi = NULL; |
---|
| 50 | m_ppcYuvReco = NULL; |
---|
| 51 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 52 | m_ppcYuvResPred = NULL; |
---|
[56] | 53 | #endif |
---|
| 54 | m_ppcCU = NULL; |
---|
[2] | 55 | } |
---|
| 56 | |
---|
| 57 | TDecCu::~TDecCu() |
---|
| 58 | { |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
| 62 | { |
---|
| 63 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 64 | m_pcTrQuant = pcTrQuant; |
---|
| 65 | m_pcPrediction = pcPrediction; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | \param uiMaxDepth total number of allowable depth |
---|
| 70 | \param uiMaxWidth largest CU width |
---|
| 71 | \param uiMaxHeight largest CU height |
---|
| 72 | */ |
---|
| 73 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
| 74 | { |
---|
| 75 | m_uiMaxDepth = uiMaxDepth+1; |
---|
| 76 | |
---|
[56] | 77 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 78 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 79 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 80 | m_ppcYuvResPred = new TComYuv* [m_uiMaxDepth-1]; |
---|
| 81 | #endif |
---|
| 82 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
[2] | 83 | |
---|
| 84 | UInt uiNumPartitions; |
---|
| 85 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 86 | { |
---|
| 87 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
| 88 | UInt uiWidth = uiMaxWidth >> ui; |
---|
| 89 | UInt uiHeight = uiMaxHeight >> ui; |
---|
| 90 | |
---|
[56] | 91 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
| 92 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
| 93 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 94 | m_ppcYuvResPred[ui] = new TComYuv; m_ppcYuvResPred[ui]->create( uiWidth, uiHeight ); |
---|
[56] | 95 | #endif |
---|
| 96 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
[2] | 97 | } |
---|
| 98 | |
---|
[56] | 99 | m_bDecodeDQP = false; |
---|
| 100 | |
---|
[2] | 101 | // initialize partition order. |
---|
| 102 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 103 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
| 104 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 105 | |
---|
| 106 | // initialize conversion matrix from partition index to pel |
---|
| 107 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
[56] | 108 | initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
[2] | 109 | } |
---|
| 110 | |
---|
| 111 | Void TDecCu::destroy() |
---|
| 112 | { |
---|
| 113 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 114 | { |
---|
[56] | 115 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
| 116 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
| 117 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 118 | m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL; |
---|
[56] | 119 | #endif |
---|
| 120 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
[2] | 121 | } |
---|
| 122 | |
---|
[56] | 123 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
| 124 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
| 125 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 126 | delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL; |
---|
[56] | 127 | #endif |
---|
| 128 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
[2] | 129 | } |
---|
| 130 | |
---|
| 131 | // ==================================================================================================================== |
---|
| 132 | // Public member functions |
---|
| 133 | // ==================================================================================================================== |
---|
| 134 | |
---|
| 135 | /** \param pcCU pointer of CU data |
---|
| 136 | \param ruiIsLast last data? |
---|
| 137 | */ |
---|
| 138 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
| 139 | { |
---|
[56] | 140 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 141 | { |
---|
[56] | 142 | setdQPFlag(true); |
---|
[2] | 143 | } |
---|
[56] | 144 | |
---|
| 145 | #if BURST_IPCM |
---|
| 146 | pcCU->setNumSucIPCM(0); |
---|
| 147 | #endif |
---|
| 148 | |
---|
[2] | 149 | // start from the top level CU |
---|
[56] | 150 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
[2] | 151 | } |
---|
| 152 | |
---|
| 153 | /** \param pcCU pointer of CU data |
---|
| 154 | */ |
---|
| 155 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
| 156 | { |
---|
| 157 | xDecompressCU( pcCU, pcCU, 0, 0 ); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | // ==================================================================================================================== |
---|
| 161 | // Protected member functions |
---|
| 162 | // ==================================================================================================================== |
---|
| 163 | |
---|
[56] | 164 | /**decode end-of-slice flag |
---|
| 165 | * \param pcCU |
---|
| 166 | * \param uiAbsPartIdx |
---|
| 167 | * \param uiDepth |
---|
| 168 | * \returns Bool |
---|
| 169 | */ |
---|
| 170 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) { |
---|
| 171 | UInt uiIsLast; |
---|
| 172 | TComPic* pcPic = pcCU->getPic(); |
---|
| 173 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
| 174 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 175 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
| 176 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
| 177 | UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); |
---|
| 178 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 179 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 180 | |
---|
| 181 | #if HHI_MPI |
---|
| 182 | const UInt uiCUWidth = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUWidth>>uiDepth : pcCU->getWidth (uiAbsPartIdx); |
---|
| 183 | const UInt uiCUHeight = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUHeight>>uiDepth : pcCU->getHeight(uiAbsPartIdx); |
---|
| 184 | if(((uiPosX+uiCUWidth)%uiGranularityWidth==0||(uiPosX+uiCUWidth==uiWidth)) |
---|
| 185 | &&((uiPosY+uiCUHeight)%uiGranularityWidth==0||(uiPosY+uiCUHeight==uiHeight))) |
---|
| 186 | #else |
---|
| 187 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
| 188 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
| 189 | #endif |
---|
| 190 | { |
---|
| 191 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
| 192 | } |
---|
| 193 | else |
---|
| 194 | { |
---|
| 195 | uiIsLast=0; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | if(uiIsLast) |
---|
| 199 | { |
---|
| 200 | if(pcSlice->isNextEntropySlice()&&!pcSlice->isNextSlice()) |
---|
| 201 | { |
---|
| 202 | pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 203 | } |
---|
| 204 | else |
---|
| 205 | { |
---|
| 206 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 207 | pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
| 208 | } |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | return uiIsLast>0; |
---|
| 212 | } |
---|
| 213 | |
---|
[2] | 214 | /** decode CU block recursively |
---|
| 215 | * \param pcCU |
---|
| 216 | * \param uiAbsPartIdx |
---|
| 217 | * \param uiDepth |
---|
| 218 | * \returns Void |
---|
| 219 | */ |
---|
[56] | 220 | |
---|
| 221 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
[2] | 222 | { |
---|
| 223 | TComPic* pcPic = pcCU->getPic(); |
---|
| 224 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 225 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
| 226 | |
---|
| 227 | Bool bBoundary = false; |
---|
| 228 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 229 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 230 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 231 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
[56] | 232 | |
---|
| 233 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 234 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr(); |
---|
| 235 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 236 | { |
---|
[56] | 237 | #if BURST_IPCM |
---|
| 238 | if(pcCU->getNumSucIPCM() == 0) |
---|
| 239 | { |
---|
[5] | 240 | #if HHI_MPI |
---|
[56] | 241 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
| 242 | #endif |
---|
| 243 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 244 | } |
---|
| 245 | else |
---|
| 246 | { |
---|
| 247 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
| 248 | } |
---|
| 249 | #else |
---|
| 250 | #if HHI_MPI |
---|
[2] | 251 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
[5] | 252 | #endif |
---|
[56] | 253 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 254 | #endif |
---|
[2] | 255 | } |
---|
| 256 | else |
---|
| 257 | { |
---|
| 258 | bBoundary = true; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 262 | { |
---|
| 263 | UInt uiIdx = uiAbsPartIdx; |
---|
[56] | 264 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 265 | { |
---|
| 266 | setdQPFlag(true); |
---|
| 267 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 268 | } |
---|
| 269 | |
---|
[2] | 270 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 271 | { |
---|
| 272 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 273 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 274 | |
---|
[56] | 275 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr(); |
---|
| 276 | if ( bSubInSlice ) |
---|
| 277 | { |
---|
| 278 | if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 279 | { |
---|
| 280 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
| 281 | } |
---|
| 282 | else |
---|
| 283 | { |
---|
| 284 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | if(ruiIsLast) |
---|
| 288 | { |
---|
| 289 | break; |
---|
| 290 | } |
---|
[2] | 291 | |
---|
| 292 | uiIdx += uiQNumParts; |
---|
| 293 | } |
---|
[56] | 294 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 295 | { |
---|
| 296 | if ( getdQPFlag() ) |
---|
| 297 | { |
---|
| 298 | UInt uiQPSrcPartIdx; |
---|
| 299 | if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
| 300 | { |
---|
| 301 | uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
| 302 | } |
---|
| 303 | else |
---|
| 304 | { |
---|
| 305 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
| 306 | } |
---|
| 307 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 308 | } |
---|
| 309 | } |
---|
[2] | 310 | return; |
---|
| 311 | } |
---|
| 312 | |
---|
[56] | 313 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 314 | { |
---|
| 315 | setdQPFlag(true); |
---|
| 316 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 317 | } |
---|
| 318 | |
---|
[2] | 319 | // decode CU mode and the partition size |
---|
[56] | 320 | #if BURST_IPCM |
---|
| 321 | if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 ) |
---|
[5] | 322 | #else |
---|
| 323 | if( !pcCU->getSlice()->isIntra() ) |
---|
| 324 | #endif |
---|
[56] | 325 | #if HHI_MPI |
---|
| 326 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
| 327 | #endif |
---|
[2] | 328 | { |
---|
| 329 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 330 | } |
---|
[56] | 331 | |
---|
[2] | 332 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
| 333 | { |
---|
| 334 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 335 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[56] | 336 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 337 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 338 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 339 | Int numValidMergeCand = 0; |
---|
| 340 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
| 341 | #else |
---|
[2] | 342 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 343 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
[56] | 344 | Int numValidMergeCand = 0; |
---|
[2] | 345 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
[56] | 346 | #endif |
---|
[2] | 347 | { |
---|
| 348 | uhInterDirNeighbours[ui] = 0; |
---|
| 349 | } |
---|
| 350 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
[5] | 351 | #if HHI_MPI |
---|
[2] | 352 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
| 353 | { |
---|
| 354 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 355 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
| 356 | |
---|
| 357 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 358 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
| 359 | { |
---|
[56] | 360 | const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
[2] | 361 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP ); |
---|
| 362 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
| 363 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
| 364 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
| 365 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
| 366 | } |
---|
| 367 | } |
---|
[56] | 368 | else |
---|
| 369 | { |
---|
[2] | 370 | #endif |
---|
[56] | 371 | #if SIMP_MRG_PRUN |
---|
| 372 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
| 373 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 374 | #else |
---|
| 375 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 376 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
| 377 | #endif |
---|
| 378 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
| 379 | |
---|
| 380 | TComMv cTmpMv( 0, 0 ); |
---|
| 381 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 382 | { |
---|
| 383 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 384 | { |
---|
| 385 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 386 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 387 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 388 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 389 | } |
---|
| 390 | } |
---|
| 391 | #if HHI_MPI |
---|
| 392 | } |
---|
| 393 | #endif |
---|
[5] | 394 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 395 | m_pcEntropyDecoder->decodeResPredFlag( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
[5] | 396 | #endif |
---|
[56] | 397 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
[2] | 398 | return; |
---|
| 399 | } |
---|
| 400 | |
---|
[5] | 401 | #if HHI_MPI |
---|
[2] | 402 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
| 403 | { |
---|
[5] | 404 | #endif |
---|
[56] | 405 | #if BURST_IPCM |
---|
| 406 | if( pcCU->getNumSucIPCM() == 0 ) |
---|
| 407 | { |
---|
[2] | 408 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 409 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[56] | 410 | } |
---|
| 411 | else |
---|
| 412 | { |
---|
| 413 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
| 414 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 415 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 416 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
| 417 | } |
---|
| 418 | #else |
---|
| 419 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 420 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 421 | #endif |
---|
[2] | 422 | |
---|
[56] | 423 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 424 | { |
---|
| 425 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 426 | |
---|
[56] | 427 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
[2] | 428 | { |
---|
[56] | 429 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
| 430 | return; |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | #if ! HHI_MPI |
---|
| 435 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 436 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 437 | #endif |
---|
| 438 | |
---|
| 439 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 440 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
| 441 | |
---|
[5] | 442 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[56] | 443 | if( !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 444 | { |
---|
| 445 | m_pcEntropyDecoder->decodeResPredFlag ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
| 446 | } |
---|
[5] | 447 | #endif |
---|
[2] | 448 | |
---|
[56] | 449 | #if HHI_MPI |
---|
[2] | 450 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
| 451 | { |
---|
| 452 | assert( pcCU->getZorderIdxInCU() == 0 ); |
---|
| 453 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 454 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
| 455 | |
---|
| 456 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 457 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
| 458 | { |
---|
[56] | 459 | const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
[2] | 460 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER ); |
---|
| 461 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
| 462 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
| 463 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
| 464 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 468 | { |
---|
| 469 | UInt uiIdx = uiAbsPartIdx; |
---|
[56] | 470 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 471 | { |
---|
| 472 | setdQPFlag(true); |
---|
| 473 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 474 | } |
---|
| 475 | |
---|
[2] | 476 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 477 | { |
---|
| 478 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 479 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 480 | |
---|
[56] | 481 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr(); |
---|
| 482 | if ( bSubInSlice ) |
---|
| 483 | { |
---|
| 484 | if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 485 | { |
---|
| 486 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
| 487 | } |
---|
| 488 | else |
---|
| 489 | { |
---|
| 490 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | if(ruiIsLast) |
---|
| 494 | { |
---|
| 495 | break; |
---|
| 496 | } |
---|
[2] | 497 | uiIdx += uiQNumParts; |
---|
| 498 | } |
---|
[56] | 499 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 500 | { |
---|
| 501 | if ( getdQPFlag() ) |
---|
| 502 | { |
---|
| 503 | UInt uiQPSrcPartIdx; |
---|
| 504 | if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
| 505 | { |
---|
| 506 | uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
| 507 | } |
---|
| 508 | else |
---|
| 509 | { |
---|
| 510 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
| 511 | } |
---|
| 512 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 513 | } |
---|
| 514 | } |
---|
[2] | 515 | return; |
---|
| 516 | } |
---|
| 517 | } |
---|
[5] | 518 | } |
---|
| 519 | |
---|
[2] | 520 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 521 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
[56] | 522 | #endif |
---|
| 523 | |
---|
[2] | 524 | // Coefficient decoding |
---|
[56] | 525 | Bool bCodeDQP = getdQPFlag(); |
---|
| 526 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
| 527 | setdQPFlag( bCodeDQP ); |
---|
| 528 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
[2] | 529 | } |
---|
| 530 | |
---|
[56] | 531 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
| 532 | { |
---|
| 533 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
| 534 | { |
---|
| 535 | if( getdQPFlag() ) |
---|
| 536 | { |
---|
| 537 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | #if BURST_IPCM |
---|
| 542 | if( pcCU->getNumSucIPCM() > 0 ) |
---|
| 543 | { |
---|
| 544 | ruiIsLast = 0; |
---|
| 545 | return; |
---|
| 546 | } |
---|
| 547 | #endif |
---|
| 548 | |
---|
| 549 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
| 550 | } |
---|
| 551 | |
---|
[2] | 552 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 553 | { |
---|
| 554 | TComPic* pcPic = pcCU->getPic(); |
---|
| 555 | |
---|
| 556 | Bool bBoundary = false; |
---|
| 557 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 558 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
| 559 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 560 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
| 561 | |
---|
[56] | 562 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
| 563 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
| 564 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr(); |
---|
| 565 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
[2] | 566 | { |
---|
| 567 | bBoundary = true; |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
| 571 | { |
---|
| 572 | UInt uiNextDepth = uiDepth + 1; |
---|
| 573 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
| 574 | UInt uiIdx = uiAbsPartIdx; |
---|
| 575 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
| 576 | { |
---|
| 577 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 578 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 579 | |
---|
[56] | 580 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getEntropySliceCurEndCUAddr()); |
---|
| 581 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
| 582 | { |
---|
[2] | 583 | xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth ); |
---|
[56] | 584 | } |
---|
[2] | 585 | |
---|
| 586 | uiIdx += uiQNumParts; |
---|
| 587 | } |
---|
| 588 | return; |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | // Residual reconstruction |
---|
| 592 | m_ppcYuvResi[uiDepth]->clear(); |
---|
| 593 | |
---|
| 594 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 595 | |
---|
| 596 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
| 597 | { |
---|
| 598 | case MODE_SKIP: |
---|
| 599 | case MODE_INTER: |
---|
| 600 | xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 601 | break; |
---|
| 602 | case MODE_INTRA: |
---|
| 603 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 604 | break; |
---|
| 605 | default: |
---|
| 606 | assert(0); |
---|
| 607 | break; |
---|
| 608 | } |
---|
[56] | 609 | #if LOSSLESS_CODING |
---|
| 610 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
| 611 | { |
---|
| 612 | xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth); |
---|
| 613 | } |
---|
| 614 | #endif |
---|
[2] | 615 | |
---|
| 616 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 620 | { |
---|
[5] | 621 | #if HHI_MPI |
---|
[171] | 622 | #if FIX_MPI_B0065 |
---|
[2] | 623 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
[171] | 624 | { |
---|
| 625 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 626 | if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx)) |
---|
| 627 | { |
---|
| 628 | PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx); |
---|
| 629 | pcCU->setPartSizeSubParts( partSize, 0, uiDepth ); |
---|
| 630 | } |
---|
| 631 | else |
---|
| 632 | { |
---|
| 633 | pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth ); |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | #else |
---|
| 637 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
[2] | 638 | pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth ); |
---|
| 639 | #endif |
---|
[171] | 640 | #endif |
---|
[2] | 641 | |
---|
| 642 | // inter prediction |
---|
| 643 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
| 644 | |
---|
[5] | 645 | #if HHI_MPI |
---|
[2] | 646 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
| 647 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 648 | #endif |
---|
[56] | 649 | |
---|
[5] | 650 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 651 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 652 | { |
---|
| 653 | AOF( pcCU->getResPredAvail( 0 ) ); |
---|
[77] | 654 | Bool bOK = pcCU->getResidualSamples( 0, |
---|
| 655 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 656 | true, |
---|
| 657 | #endif |
---|
| 658 | m_ppcYuvResPred[uiDepth] ); |
---|
[2] | 659 | AOF( bOK ); |
---|
[77] | 660 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
[100] | 661 | Int iPUResiPredShift[4]; |
---|
| 662 | pcCU->getPUResiPredShift(iPUResiPredShift, 0); |
---|
| 663 | m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 664 | #else |
---|
[2] | 665 | m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
[77] | 666 | #endif |
---|
[2] | 667 | } |
---|
[5] | 668 | #endif |
---|
| 669 | |
---|
[2] | 670 | // inter recon |
---|
| 671 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
| 672 | |
---|
| 673 | // clip for only non-zero cbp case |
---|
| 674 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
| 675 | { |
---|
| 676 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 677 | } |
---|
| 678 | else |
---|
| 679 | { |
---|
[5] | 680 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 681 | if( pcCU->getResPredFlag( 0 ) ) |
---|
| 682 | { |
---|
| 683 | m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
| 684 | } |
---|
[5] | 685 | #endif |
---|
[2] | 686 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 687 | } |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | Void |
---|
| 691 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
| 692 | UInt uiTrDepth, |
---|
| 693 | UInt uiAbsPartIdx, |
---|
| 694 | TComYuv* pcRecoYuv, |
---|
| 695 | TComYuv* pcPredYuv, |
---|
| 696 | TComYuv* pcResiYuv ) |
---|
| 697 | { |
---|
| 698 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
| 699 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
| 700 | UInt uiStride = pcRecoYuv->getStride (); |
---|
| 701 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 702 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 703 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 704 | |
---|
| 705 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
| 706 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 707 | |
---|
| 708 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
| 709 | |
---|
| 710 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 711 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
| 712 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
| 713 | |
---|
| 714 | //===== init availability pattern ===== |
---|
| 715 | Bool bAboveAvail = false; |
---|
| 716 | Bool bLeftAvail = false; |
---|
| 717 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
| 718 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 719 | m_pcPrediction->getPredicBuf (), |
---|
| 720 | m_pcPrediction->getPredicBufWidth (), |
---|
| 721 | m_pcPrediction->getPredicBufHeight (), |
---|
| 722 | bAboveAvail, bLeftAvail ); |
---|
[100] | 723 | #if LGE_EDGE_INTRA |
---|
| 724 | if( uiLumaPredMode >= EDGE_INTRA_IDX ) |
---|
| 725 | { |
---|
| 726 | m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride |
---|
| 727 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
| 728 | , uiLumaPredMode == EDGE_INTRA_DELTA_IDX |
---|
| 729 | #endif |
---|
| 730 | ); |
---|
| 731 | } |
---|
| 732 | else |
---|
| 733 | #endif |
---|
[2] | 734 | |
---|
[56] | 735 | //===== get prediction signal ===== |
---|
[5] | 736 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[56] | 737 | if( uiLumaPredMode >= NUM_INTRA_MODE ) |
---|
[2] | 738 | { |
---|
| 739 | m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false ); |
---|
| 740 | } |
---|
| 741 | else |
---|
[56] | 742 | { |
---|
[2] | 743 | #endif |
---|
| 744 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
[56] | 745 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
[2] | 746 | } |
---|
[56] | 747 | #endif |
---|
| 748 | |
---|
[2] | 749 | //===== inverse transform ===== |
---|
[56] | 750 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 751 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
[2] | 752 | #else |
---|
[56] | 753 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 ); |
---|
| 754 | #endif |
---|
[2] | 755 | |
---|
[56] | 756 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
| 757 | assert(scalingListType < 6); |
---|
| 758 | #if LOSSLESS_CODING |
---|
| 759 | m_pcTrQuant->invtransformNxN( pcCU, TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
| 760 | #else |
---|
| 761 | m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
| 762 | #endif |
---|
| 763 | |
---|
[2] | 764 | |
---|
| 765 | //===== reconstruction ===== |
---|
[56] | 766 | Pel* pPred = piPred; |
---|
| 767 | Pel* pResi = piResi; |
---|
| 768 | Pel* pReco = piReco; |
---|
| 769 | Pel* pRecIPred = piRecIPred; |
---|
| 770 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
[2] | 771 | { |
---|
[56] | 772 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[2] | 773 | { |
---|
[56] | 774 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 775 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
[2] | 776 | } |
---|
[56] | 777 | pPred += uiStride; |
---|
| 778 | pResi += uiStride; |
---|
| 779 | pReco += uiStride; |
---|
| 780 | pRecIPred += uiRecIPredStride; |
---|
[2] | 781 | } |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | |
---|
| 785 | Void |
---|
| 786 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
| 787 | UInt uiTrDepth, |
---|
| 788 | UInt uiAbsPartIdx, |
---|
| 789 | TComYuv* pcRecoYuv, |
---|
| 790 | TComYuv* pcPredYuv, |
---|
| 791 | TComYuv* pcResiYuv, |
---|
| 792 | UInt uiChromaId ) |
---|
| 793 | { |
---|
| 794 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
| 795 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
[56] | 796 | |
---|
| 797 | if( uiLog2TrSize == 2 ) |
---|
[2] | 798 | { |
---|
| 799 | assert( uiTrDepth > 0 ); |
---|
| 800 | uiTrDepth--; |
---|
| 801 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
| 802 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
| 803 | if( !bFirstQ ) |
---|
| 804 | { |
---|
| 805 | return; |
---|
| 806 | } |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
| 810 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 811 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
| 812 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
| 813 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 814 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 815 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
| 816 | |
---|
| 817 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
| 818 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 819 | |
---|
| 820 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
| 821 | |
---|
| 822 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 823 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
| 824 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 825 | |
---|
| 826 | //===== init availability pattern ===== |
---|
| 827 | Bool bAboveAvail = false; |
---|
| 828 | Bool bLeftAvail = false; |
---|
| 829 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
[56] | 830 | |
---|
| 831 | if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 ) |
---|
| 832 | { |
---|
| 833 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 834 | m_pcPrediction->getPredicBuf (), |
---|
| 835 | m_pcPrediction->getPredicBufWidth (), |
---|
| 836 | m_pcPrediction->getPredicBufHeight (), |
---|
| 837 | bAboveAvail, bLeftAvail, |
---|
| 838 | true ); |
---|
| 839 | |
---|
| 840 | m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight ); |
---|
| 841 | } |
---|
| 842 | |
---|
[2] | 843 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
| 844 | m_pcPrediction->getPredicBuf (), |
---|
| 845 | m_pcPrediction->getPredicBufWidth (), |
---|
| 846 | m_pcPrediction->getPredicBufHeight (), |
---|
| 847 | bAboveAvail, bLeftAvail ); |
---|
| 848 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
| 849 | |
---|
| 850 | //===== get prediction signal ===== |
---|
[56] | 851 | if( uiChromaPredMode == LM_CHROMA_IDX ) |
---|
[2] | 852 | { |
---|
[56] | 853 | m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId ); |
---|
[2] | 854 | } |
---|
| 855 | else |
---|
| 856 | { |
---|
[56] | 857 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
[2] | 858 | { |
---|
[56] | 859 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
| 860 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 861 | mapDMMtoIntraMode( uiChromaPredMode ); |
---|
| 862 | #endif |
---|
[2] | 863 | } |
---|
[56] | 864 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
[2] | 865 | } |
---|
| 866 | |
---|
| 867 | //===== inverse transform ===== |
---|
[56] | 868 | if(eText == TEXT_CHROMA_U) |
---|
| 869 | { |
---|
| 870 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 871 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
[2] | 872 | #else |
---|
[56] | 873 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
[2] | 874 | #endif |
---|
[56] | 875 | } |
---|
| 876 | else |
---|
| 877 | { |
---|
| 878 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 879 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
| 880 | #else |
---|
| 881 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
| 882 | #endif |
---|
| 883 | } |
---|
[2] | 884 | |
---|
[56] | 885 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
| 886 | assert(scalingListType < 6); |
---|
| 887 | #if LOSSLESS_CODING |
---|
| 888 | m_pcTrQuant->invtransformNxN( pcCU, eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
| 889 | #else |
---|
| 890 | m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
| 891 | #endif |
---|
| 892 | |
---|
[2] | 893 | //===== reconstruction ===== |
---|
[56] | 894 | Pel* pPred = piPred; |
---|
| 895 | Pel* pResi = piResi; |
---|
| 896 | Pel* pReco = piReco; |
---|
| 897 | Pel* pRecIPred = piRecIPred; |
---|
| 898 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
[2] | 899 | { |
---|
[56] | 900 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[2] | 901 | { |
---|
[56] | 902 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
| 903 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
[2] | 904 | } |
---|
[56] | 905 | pPred += uiStride; |
---|
| 906 | pResi += uiStride; |
---|
| 907 | pReco += uiStride; |
---|
| 908 | pRecIPred += uiRecIPredStride; |
---|
[2] | 909 | } |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | Void |
---|
| 913 | TDecCu::xIntraRecQT( TComDataCU* pcCU, |
---|
| 914 | UInt uiTrDepth, |
---|
| 915 | UInt uiAbsPartIdx, |
---|
| 916 | TComYuv* pcRecoYuv, |
---|
| 917 | TComYuv* pcPredYuv, |
---|
| 918 | TComYuv* pcResiYuv ) |
---|
| 919 | { |
---|
| 920 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 921 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 922 | if( uiTrMode == uiTrDepth ) |
---|
| 923 | { |
---|
| 924 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 925 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 926 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 927 | } |
---|
| 928 | else |
---|
| 929 | { |
---|
| 930 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 931 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 932 | { |
---|
| 933 | xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 934 | } |
---|
| 935 | } |
---|
| 936 | } |
---|
| 937 | |
---|
| 938 | Void |
---|
| 939 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 940 | { |
---|
| 941 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
| 942 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
| 943 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
| 944 | |
---|
[56] | 945 | if (pcCU->getIPCMFlag(0)) |
---|
| 946 | { |
---|
| 947 | xReconPCM( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 948 | return; |
---|
| 949 | } |
---|
| 950 | |
---|
[2] | 951 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 952 | { |
---|
| 953 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
| 957 | { |
---|
| 958 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
| 959 | } |
---|
| 960 | |
---|
| 961 | } |
---|
| 962 | |
---|
[56] | 963 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
[2] | 964 | * \param pcCU pointer of current CU |
---|
| 965 | * \param uiTrDepth current tranform split depth |
---|
| 966 | * \param uiAbsPartIdx part index |
---|
| 967 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 968 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 969 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 970 | * |
---|
| 971 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
| 972 | */ |
---|
| 973 | Void |
---|
| 974 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
| 975 | UInt uiTrDepth, |
---|
| 976 | UInt uiAbsPartIdx, |
---|
| 977 | TComYuv* pcRecoYuv, |
---|
| 978 | TComYuv* pcPredYuv, |
---|
| 979 | TComYuv* pcResiYuv ) |
---|
| 980 | { |
---|
| 981 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 982 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 983 | if( uiTrMode == uiTrDepth ) |
---|
| 984 | { |
---|
| 985 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 986 | } |
---|
| 987 | else |
---|
| 988 | { |
---|
| 989 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 990 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 991 | { |
---|
| 992 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 993 | } |
---|
| 994 | } |
---|
| 995 | } |
---|
| 996 | |
---|
[56] | 997 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
[2] | 998 | * \param pcCU pointer of current CU |
---|
| 999 | * \param uiTrDepth current tranform split depth |
---|
| 1000 | * \param uiAbsPartIdx part index |
---|
| 1001 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 1002 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 1003 | * \param pcResiYuv pointer to residue sample arrays |
---|
| 1004 | * |
---|
| 1005 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
| 1006 | */ |
---|
| 1007 | Void |
---|
| 1008 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
| 1009 | UInt uiTrDepth, |
---|
| 1010 | UInt uiAbsPartIdx, |
---|
| 1011 | TComYuv* pcRecoYuv, |
---|
| 1012 | TComYuv* pcPredYuv, |
---|
| 1013 | TComYuv* pcResiYuv ) |
---|
| 1014 | { |
---|
| 1015 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
| 1016 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 1017 | if( uiTrMode == uiTrDepth ) |
---|
| 1018 | { |
---|
| 1019 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
| 1020 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
| 1021 | } |
---|
| 1022 | else |
---|
| 1023 | { |
---|
| 1024 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
| 1025 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
| 1026 | { |
---|
| 1027 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
| 1028 | } |
---|
| 1029 | } |
---|
| 1030 | } |
---|
| 1031 | |
---|
| 1032 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 1033 | { |
---|
| 1034 | UInt uiCUAddr = pcCU->getAddr(); |
---|
| 1035 | |
---|
| 1036 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
| 1037 | |
---|
| 1038 | return; |
---|
| 1039 | } |
---|
| 1040 | |
---|
| 1041 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1042 | { |
---|
| 1043 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
| 1044 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
| 1045 | TCoeff* piCoeff; |
---|
| 1046 | |
---|
| 1047 | Pel* pResi; |
---|
| 1048 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 1049 | |
---|
| 1050 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
| 1051 | |
---|
| 1052 | // Y |
---|
| 1053 | piCoeff = pcCU->getCoeffY(); |
---|
| 1054 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
[56] | 1055 | |
---|
| 1056 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1057 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
| 1058 | #else |
---|
| 1059 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 ); |
---|
| 1060 | #endif |
---|
| 1061 | |
---|
[2] | 1062 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
| 1063 | |
---|
| 1064 | // Cb and Cr |
---|
[56] | 1065 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1066 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
| 1067 | #else |
---|
| 1068 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
| 1069 | #endif |
---|
| 1070 | |
---|
[2] | 1071 | uiWidth >>= 1; |
---|
| 1072 | uiHeight >>= 1; |
---|
| 1073 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
| 1074 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
[56] | 1075 | |
---|
| 1076 | #if H0736_AVC_STYLE_QP_RANGE |
---|
| 1077 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
| 1078 | #else |
---|
| 1079 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
| 1080 | #endif |
---|
| 1081 | |
---|
[2] | 1082 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
| 1083 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
| 1084 | } |
---|
| 1085 | |
---|
[56] | 1086 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
| 1087 | * \param pcCU pointer to current CU |
---|
| 1088 | * \param uiPartIdx part index |
---|
| 1089 | * \param piPCM pointer to PCM code arrays |
---|
| 1090 | * \param piReco pointer to reconstructed sample arrays |
---|
| 1091 | * \param uiStride stride of reconstructed sample arrays |
---|
| 1092 | * \param uiWidth CU width |
---|
| 1093 | * \param uiHeight CU height |
---|
| 1094 | * \param ttText texture component type |
---|
| 1095 | * \returns Void |
---|
| 1096 | */ |
---|
| 1097 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
| 1098 | { |
---|
| 1099 | UInt uiX, uiY; |
---|
| 1100 | Pel* piPicReco; |
---|
| 1101 | UInt uiPicStride; |
---|
| 1102 | UInt uiPcmLeftShiftBit; |
---|
| 1103 | |
---|
| 1104 | if( ttText == TEXT_LUMA ) |
---|
| 1105 | { |
---|
| 1106 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
| 1107 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 1108 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
| 1109 | } |
---|
| 1110 | else |
---|
| 1111 | { |
---|
| 1112 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
| 1113 | |
---|
| 1114 | if( ttText == TEXT_CHROMA_U ) |
---|
| 1115 | { |
---|
| 1116 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 1117 | } |
---|
| 1118 | else |
---|
| 1119 | { |
---|
| 1120 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
| 1121 | } |
---|
| 1122 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
| 1123 | } |
---|
| 1124 | |
---|
| 1125 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 1126 | { |
---|
| 1127 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 1128 | { |
---|
| 1129 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
| 1130 | piPicReco[uiX] = piReco[uiX]; |
---|
| 1131 | } |
---|
| 1132 | piPCM += uiWidth; |
---|
| 1133 | piReco += uiStride; |
---|
| 1134 | piPicReco += uiPicStride; |
---|
| 1135 | } |
---|
| 1136 | } |
---|
| 1137 | |
---|
| 1138 | /** Function for reconstructing a PCM mode CU. |
---|
| 1139 | * \param pcCU pointer to current CU |
---|
| 1140 | * \param uiAbsPartIdx CU index |
---|
| 1141 | * \param uiDepth CU Depth |
---|
| 1142 | * \returns Void |
---|
| 1143 | */ |
---|
| 1144 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1145 | { |
---|
| 1146 | // Luma |
---|
| 1147 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
| 1148 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
| 1149 | |
---|
| 1150 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
| 1151 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
| 1152 | |
---|
| 1153 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
| 1154 | |
---|
| 1155 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
| 1156 | |
---|
| 1157 | // Cb and Cr |
---|
| 1158 | UInt uiCWidth = (uiWidth>>1); |
---|
| 1159 | UInt uiCHeight = (uiHeight>>1); |
---|
| 1160 | |
---|
| 1161 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
| 1162 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
| 1163 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
| 1164 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
| 1165 | |
---|
| 1166 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
| 1167 | |
---|
| 1168 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
| 1169 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
| 1170 | } |
---|
| 1171 | |
---|
| 1172 | #if LOSSLESS_CODING |
---|
| 1173 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
| 1174 | * \param pcCU pointer to current CU |
---|
| 1175 | * \param uiAbsPartIdx CU index |
---|
| 1176 | * \param uiDepth CU Depth |
---|
| 1177 | * \returns Void |
---|
| 1178 | */ |
---|
| 1179 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth) |
---|
| 1180 | { |
---|
| 1181 | // Luma |
---|
| 1182 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
| 1183 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
| 1184 | |
---|
| 1185 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
| 1186 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
| 1187 | |
---|
| 1188 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
| 1189 | |
---|
| 1190 | for(Int y = 0; y < height; y++ ) |
---|
| 1191 | { |
---|
| 1192 | for(Int x = 0; x < width; x++ ) |
---|
| 1193 | { |
---|
| 1194 | pPcmY[x] = pRecoY[x]; |
---|
| 1195 | } |
---|
| 1196 | pPcmY += width; |
---|
| 1197 | pRecoY += stride; |
---|
| 1198 | } |
---|
| 1199 | |
---|
| 1200 | // Cb and Cr |
---|
| 1201 | UInt widthC = (width>>1); |
---|
| 1202 | UInt heightC = (height>>1); |
---|
| 1203 | |
---|
| 1204 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
| 1205 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
| 1206 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
| 1207 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
| 1208 | |
---|
| 1209 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
| 1210 | |
---|
| 1211 | for(Int y = 0; y < heightC; y++ ) |
---|
| 1212 | { |
---|
| 1213 | for(Int x = 0; x < widthC; x++ ) |
---|
| 1214 | { |
---|
| 1215 | pPcmCb[x] = pRecoCb[x]; |
---|
| 1216 | pPcmCr[x] = pRecoCr[x]; |
---|
| 1217 | } |
---|
| 1218 | pPcmCr += widthC; |
---|
| 1219 | pPcmCb += widthC; |
---|
| 1220 | pRecoCb += strideC; |
---|
| 1221 | pRecoCr += strideC; |
---|
| 1222 | } |
---|
| 1223 | |
---|
| 1224 | } |
---|
| 1225 | #endif |
---|
| 1226 | |
---|
| 1227 | //! \} |
---|