| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TDecCu.cpp |
|---|
| 35 | \brief CU decoder class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include "TDecCu.h" |
|---|
| 39 | |
|---|
| 40 | //! \ingroup TLibDecoder |
|---|
| 41 | //! \{ |
|---|
| 42 | |
|---|
| 43 | // ==================================================================================================================== |
|---|
| 44 | // Constructor / destructor / create / destroy |
|---|
| 45 | // ==================================================================================================================== |
|---|
| 46 | |
|---|
| 47 | TDecCu::TDecCu() |
|---|
| 48 | { |
|---|
| 49 | m_ppcYuvResi = NULL; |
|---|
| 50 | m_ppcYuvReco = NULL; |
|---|
| 51 | m_ppcCU = NULL; |
|---|
| 52 | #if H_3D_DBBP |
|---|
| 53 | m_ppcYuvRecoDBBP = NULL; |
|---|
| 54 | #endif |
|---|
| 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 | |
|---|
| 77 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 78 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 79 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
|---|
| 80 | #if H_3D_DBBP |
|---|
| 81 | m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 82 | #endif |
|---|
| 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 | |
|---|
| 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 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
|---|
| 94 | #if H_3D_DBBP |
|---|
| 95 | m_ppcYuvRecoDBBP[ui] = new TComYuv; m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight ); |
|---|
| 96 | #endif |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | m_bDecodeDQP = false; |
|---|
| 100 | |
|---|
| 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 ); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | Void TDecCu::destroy() |
|---|
| 111 | { |
|---|
| 112 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
|---|
| 113 | { |
|---|
| 114 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
|---|
| 115 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
|---|
| 116 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
|---|
| 117 | #if H_3D_DBBP |
|---|
| 118 | m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL; |
|---|
| 119 | #endif |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
|---|
| 123 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
|---|
| 124 | delete [] m_ppcCU ; m_ppcCU = NULL; |
|---|
| 125 | #if H_3D_DBBP |
|---|
| 126 | delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL; |
|---|
| 127 | #endif |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | // ==================================================================================================================== |
|---|
| 131 | // Public member functions |
|---|
| 132 | // ==================================================================================================================== |
|---|
| 133 | |
|---|
| 134 | /** \param pcCU pointer of CU data |
|---|
| 135 | \param ruiIsLast last data? |
|---|
| 136 | */ |
|---|
| 137 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
|---|
| 138 | { |
|---|
| 139 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
|---|
| 140 | { |
|---|
| 141 | setdQPFlag(true); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | // start from the top level CU |
|---|
| 145 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | /** \param pcCU pointer of CU data |
|---|
| 149 | */ |
|---|
| 150 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
|---|
| 151 | { |
|---|
| 152 | #if !H_3D_IV_MERGE |
|---|
| 153 | xDecompressCU( pcCU, 0, 0 ); |
|---|
| 154 | #endif |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | // ==================================================================================================================== |
|---|
| 158 | // Protected member functions |
|---|
| 159 | // ==================================================================================================================== |
|---|
| 160 | |
|---|
| 161 | /**decode end-of-slice flag |
|---|
| 162 | * \param pcCU |
|---|
| 163 | * \param uiAbsPartIdx |
|---|
| 164 | * \param uiDepth |
|---|
| 165 | * \returns Bool |
|---|
| 166 | */ |
|---|
| 167 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
|---|
| 168 | { |
|---|
| 169 | UInt uiIsLast; |
|---|
| 170 | TComPic* pcPic = pcCU->getPic(); |
|---|
| 171 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
|---|
| 172 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
|---|
| 173 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
|---|
| 174 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
|---|
| 175 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
|---|
| 176 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 177 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 178 | |
|---|
| 179 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
|---|
| 180 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
|---|
| 181 | { |
|---|
| 182 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
|---|
| 183 | } |
|---|
| 184 | else |
|---|
| 185 | { |
|---|
| 186 | uiIsLast=0; |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | if(uiIsLast) |
|---|
| 190 | { |
|---|
| 191 | if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) |
|---|
| 192 | { |
|---|
| 193 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
|---|
| 194 | } |
|---|
| 195 | else |
|---|
| 196 | { |
|---|
| 197 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
|---|
| 198 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | return uiIsLast>0; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | /** decode CU block recursively |
|---|
| 206 | * \param pcCU |
|---|
| 207 | * \param uiAbsPartIdx |
|---|
| 208 | * \param uiDepth |
|---|
| 209 | * \returns Void |
|---|
| 210 | */ |
|---|
| 211 | |
|---|
| 212 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
|---|
| 213 | { |
|---|
| 214 | TComPic* pcPic = pcCU->getPic(); |
|---|
| 215 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
|---|
| 216 | UInt uiQNumParts = uiCurNumParts>>2; |
|---|
| 217 | |
|---|
| 218 | Bool bBoundary = false; |
|---|
| 219 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 220 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
|---|
| 221 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 222 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
|---|
| 223 | #if H_MV_ENC_DEC_TRAC |
|---|
| 224 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
|---|
| 225 | DTRACE_CU("x0", uiLPelX) |
|---|
| 226 | DTRACE_CU("x1", uiTPelY) |
|---|
| 227 | DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth) |
|---|
| 228 | DTRACE_CU("cqtDepth" , uiDepth) |
|---|
| 229 | #endif |
|---|
| 230 | |
|---|
| 231 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
|---|
| 232 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
|---|
| 233 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 234 | { |
|---|
| 235 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 236 | } |
|---|
| 237 | else |
|---|
| 238 | { |
|---|
| 239 | bBoundary = true; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
|---|
| 243 | { |
|---|
| 244 | UInt uiIdx = uiAbsPartIdx; |
|---|
| 245 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 246 | { |
|---|
| 247 | setdQPFlag(true); |
|---|
| 248 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
|---|
| 252 | { |
|---|
| 253 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 254 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 255 | |
|---|
| 256 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); |
|---|
| 257 | if ( bSubInSlice ) |
|---|
| 258 | { |
|---|
| 259 | if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 260 | { |
|---|
| 261 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
|---|
| 262 | } |
|---|
| 263 | else |
|---|
| 264 | { |
|---|
| 265 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
|---|
| 266 | } |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | uiIdx += uiQNumParts; |
|---|
| 270 | } |
|---|
| 271 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 272 | { |
|---|
| 273 | if ( getdQPFlag() ) |
|---|
| 274 | { |
|---|
| 275 | UInt uiQPSrcPartIdx; |
|---|
| 276 | if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
|---|
| 277 | { |
|---|
| 278 | uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); |
|---|
| 279 | } |
|---|
| 280 | else |
|---|
| 281 | { |
|---|
| 282 | uiQPSrcPartIdx = uiAbsPartIdx; |
|---|
| 283 | } |
|---|
| 284 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 285 | } |
|---|
| 286 | } |
|---|
| 287 | return; |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | #if H_MV_ENC_DEC_TRAC |
|---|
| 291 | DTRACE_CU_S("=========== coding_unit ===========\n") |
|---|
| 292 | #endif |
|---|
| 293 | |
|---|
| 294 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 295 | { |
|---|
| 296 | setdQPFlag(true); |
|---|
| 297 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 298 | } |
|---|
| 299 | #if H_3D_NBDV |
|---|
| 300 | DisInfo DvInfo; |
|---|
| 301 | DvInfo.bDV = false; |
|---|
| 302 | DvInfo.m_acNBDV.setZero(); |
|---|
| 303 | DvInfo.m_aVIdxCan = 0; |
|---|
| 304 | #if H_3D_NBDV_REF |
|---|
| 305 | DvInfo.m_acDoNBDV.setZero(); |
|---|
| 306 | #endif |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | if(!pcCU->getSlice()->isIntra()) |
|---|
| 310 | { |
|---|
| 311 | #if H_3D_ARP && H_3D_IV_MERGE |
|---|
| 312 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() ) |
|---|
| 313 | #else |
|---|
| 314 | #if H_3D_ARP |
|---|
| 315 | if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) ) |
|---|
| 316 | #else |
|---|
| 317 | #if H_3D_IV_MERGE |
|---|
| 318 | if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) ) |
|---|
| 319 | #else |
|---|
| 320 | if (0) |
|---|
| 321 | #endif |
|---|
| 322 | #endif |
|---|
| 323 | #endif |
|---|
| 324 | { |
|---|
| 325 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true ); |
|---|
| 326 | m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
|---|
| 327 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
|---|
| 328 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
|---|
| 329 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
|---|
| 330 | m_ppcCU[uiDepth]->setWidth ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth) ); |
|---|
| 331 | m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth) ); |
|---|
| 332 | m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
|---|
| 333 | #if H_3D_IV_MERGE |
|---|
| 334 | if( pcCU->getSlice()->getIsDepth()) |
|---|
| 335 | { |
|---|
| 336 | DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
|---|
| 337 | } |
|---|
| 338 | else |
|---|
| 339 | { |
|---|
| 340 | #endif |
|---|
| 341 | #if H_3D_NBDV_REF |
|---|
| 342 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() ) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
|---|
| 343 | { |
|---|
| 344 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
|---|
| 345 | } |
|---|
| 346 | else |
|---|
| 347 | #endif |
|---|
| 348 | { |
|---|
| 349 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
|---|
| 350 | } |
|---|
| 351 | #if H_3D_IV_MERGE |
|---|
| 352 | } |
|---|
| 353 | #endif |
|---|
| 354 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
|---|
| 355 | if ( g_decTraceDispDer ) |
|---|
| 356 | { |
|---|
| 357 | DTRACE_CU( "RefViewIdx", DvInfo.m_aVIdxCan ); |
|---|
| 358 | DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() ); |
|---|
| 359 | DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() ); |
|---|
| 360 | DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() ); |
|---|
| 361 | DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() ); |
|---|
| 362 | } |
|---|
| 363 | #endif |
|---|
| 364 | |
|---|
| 365 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
|---|
| 366 | m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
|---|
| 367 | m_ppcCU[uiDepth]->setWidth ( 0, cWidTemp ); |
|---|
| 368 | m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp ); |
|---|
| 369 | } |
|---|
| 370 | } |
|---|
| 371 | #endif |
|---|
| 372 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
|---|
| 373 | { |
|---|
| 374 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | // decode CU mode and the partition size |
|---|
| 378 | if( !pcCU->getSlice()->isIntra()) |
|---|
| 379 | { |
|---|
| 380 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
|---|
| 384 | { |
|---|
| 385 | #if H_MV_ENC_DEC_TRAC |
|---|
| 386 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
|---|
| 387 | DTRACE_PU("x0", uiLPelX) |
|---|
| 388 | DTRACE_PU("x1", uiTPelY) |
|---|
| 389 | #endif |
|---|
| 390 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
|---|
| 391 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
|---|
| 392 | #if H_3D_IV_MERGE |
|---|
| 393 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
|---|
| 394 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
|---|
| 395 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 396 | #else |
|---|
| 397 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
|---|
| 398 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
|---|
| 399 | #endif |
|---|
| 400 | Int numValidMergeCand = 0; |
|---|
| 401 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
|---|
| 402 | { |
|---|
| 403 | uhInterDirNeighbours[ui] = 0; |
|---|
| 404 | } |
|---|
| 405 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
|---|
| 406 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
|---|
| 407 | #if H_3D_ARP |
|---|
| 408 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
|---|
| 409 | #endif |
|---|
| 410 | #if H_3D_IC |
|---|
| 411 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 412 | #endif |
|---|
| 413 | |
|---|
| 414 | #if H_3D_VSP |
|---|
| 415 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 416 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 417 | #if H_3D_SPIVMP |
|---|
| 418 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 419 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 420 | TComMvField* pcMvFieldSP; |
|---|
| 421 | UChar* puhInterDirSP; |
|---|
| 422 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
|---|
| 423 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
|---|
| 424 | #endif |
|---|
| 425 | m_ppcCU[uiDepth]->initAvailableFlags(); |
|---|
| 426 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 427 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
|---|
| 428 | #if H_3D_SPIVMP |
|---|
| 429 | , pcMvFieldSP, puhInterDirSP |
|---|
| 430 | #endif |
|---|
| 431 | , numValidMergeCand, uiMergeIndex ); |
|---|
| 432 | |
|---|
| 433 | m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
|---|
| 434 | #if H_3D_SPIVMP |
|---|
| 435 | , bSPIVMPFlag |
|---|
| 436 | #endif |
|---|
| 437 | , numValidMergeCand ); |
|---|
| 438 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
|---|
| 439 | #else |
|---|
| 440 | #if H_3D |
|---|
| 441 | m_ppcCU[uiDepth]->initAvailableFlags(); |
|---|
| 442 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 443 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 444 | #else |
|---|
| 445 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 446 | #endif |
|---|
| 447 | #endif |
|---|
| 448 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
|---|
| 449 | |
|---|
| 450 | TComMv cTmpMv( 0, 0 ); |
|---|
| 451 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 452 | { |
|---|
| 453 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
|---|
| 454 | { |
|---|
| 455 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
|---|
| 456 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
|---|
| 457 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
|---|
| 458 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
|---|
| 459 | #if H_3D_VSP |
|---|
| 460 | if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 ) |
|---|
| 461 | { |
|---|
| 462 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
|---|
| 463 | { |
|---|
| 464 | UInt dummy; |
|---|
| 465 | Int vspSize; |
|---|
| 466 | Int width, height; |
|---|
| 467 | m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height ); |
|---|
| 468 | m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
|---|
| 469 | pcCU->setVSPFlag( uiAbsPartIdx, vspSize ); |
|---|
| 470 | } |
|---|
| 471 | } |
|---|
| 472 | #endif |
|---|
| 473 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
|---|
| 474 | if ( g_decTraceMvFromMerge ) |
|---|
| 475 | { |
|---|
| 476 | if ( uiRefListIdx == 0 ) |
|---|
| 477 | { |
|---|
| 478 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
|---|
| 479 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
|---|
| 480 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
|---|
| 481 | } |
|---|
| 482 | else |
|---|
| 483 | { |
|---|
| 484 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
|---|
| 485 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
|---|
| 486 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
|---|
| 487 | } |
|---|
| 488 | } |
|---|
| 489 | #endif |
|---|
| 490 | } |
|---|
| 491 | } |
|---|
| 492 | #if H_3D_SPIVMP |
|---|
| 493 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
|---|
| 494 | if (bSPIVMPFlag[uiMergeIndex]) |
|---|
| 495 | { |
|---|
| 496 | UInt uiSPAddr; |
|---|
| 497 | Int iWidth = pcCU->getWidth(uiAbsPartIdx); |
|---|
| 498 | Int iHeight = pcCU->getHeight(uiAbsPartIdx); |
|---|
| 499 | |
|---|
| 500 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
|---|
| 501 | |
|---|
| 502 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
|---|
| 503 | |
|---|
| 504 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
|---|
| 505 | { |
|---|
| 506 | pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
|---|
| 507 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
|---|
| 508 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
|---|
| 509 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
|---|
| 510 | } |
|---|
| 511 | } |
|---|
| 512 | delete[] pcMvFieldSP; |
|---|
| 513 | delete[] puhInterDirSP; |
|---|
| 514 | #endif |
|---|
| 515 | |
|---|
| 516 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
|---|
| 517 | #if H_3D_IV_MERGE |
|---|
| 518 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 519 | #endif |
|---|
| 520 | return; |
|---|
| 521 | } |
|---|
| 522 | #if H_3D_SINGLE_DEPTH |
|---|
| 523 | m_pcEntropyDecoder->decodeSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 524 | if(!pcCU->getSingleDepthFlag(uiAbsPartIdx)) |
|---|
| 525 | { |
|---|
| 526 | #endif |
|---|
| 527 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 528 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 529 | |
|---|
| 530 | #if H_3D_DIM_SDC |
|---|
| 531 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 532 | #endif |
|---|
| 533 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
|---|
| 534 | { |
|---|
| 535 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 536 | |
|---|
| 537 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
|---|
| 538 | { |
|---|
| 539 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
|---|
| 540 | #if H_3D_IV_MERGE |
|---|
| 541 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 542 | #endif |
|---|
| 543 | return; |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
|---|
| 548 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
|---|
| 549 | |
|---|
| 550 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
|---|
| 551 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
|---|
| 552 | // Coefficient decoding |
|---|
| 553 | Bool bCodeDQP = getdQPFlag(); |
|---|
| 554 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
|---|
| 555 | setdQPFlag( bCodeDQP ); |
|---|
| 556 | #if H_3D_SINGLE_DEPTH |
|---|
| 557 | } |
|---|
| 558 | #endif |
|---|
| 559 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
|---|
| 560 | #if H_3D_IV_MERGE |
|---|
| 561 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 562 | #endif |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
|---|
| 566 | { |
|---|
| 567 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 568 | { |
|---|
| 569 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
|---|
| 570 | } |
|---|
| 571 | |
|---|
| 572 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
|---|
| 573 | } |
|---|
| 574 | |
|---|
| 575 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 576 | { |
|---|
| 577 | TComPic* pcPic = pcCU->getPic(); |
|---|
| 578 | #if !H_3D_IV_MERGE |
|---|
| 579 | Bool bBoundary = false; |
|---|
| 580 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 581 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
|---|
| 582 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 583 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
|---|
| 584 | |
|---|
| 585 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
|---|
| 586 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
|---|
| 587 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
|---|
| 588 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 589 | { |
|---|
| 590 | bBoundary = true; |
|---|
| 591 | } |
|---|
| 592 | |
|---|
| 593 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
|---|
| 594 | { |
|---|
| 595 | UInt uiNextDepth = uiDepth + 1; |
|---|
| 596 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
|---|
| 597 | UInt uiIdx = uiAbsPartIdx; |
|---|
| 598 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
|---|
| 599 | { |
|---|
| 600 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 601 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 602 | |
|---|
| 603 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
|---|
| 604 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
|---|
| 605 | { |
|---|
| 606 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | uiIdx += uiQNumParts; |
|---|
| 610 | } |
|---|
| 611 | return; |
|---|
| 612 | } |
|---|
| 613 | #endif |
|---|
| 614 | // Residual reconstruction |
|---|
| 615 | m_ppcYuvResi[uiDepth]->clear(); |
|---|
| 616 | |
|---|
| 617 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 618 | |
|---|
| 619 | #if H_MV_ENC_DEC_TRAC |
|---|
| 620 | #if ENC_DEC_TRACE |
|---|
| 621 | stopAtPos ( m_ppcCU[uiDepth]->getSlice()->getPOC(), |
|---|
| 622 | m_ppcCU[uiDepth]->getSlice()->getLayerId(), |
|---|
| 623 | m_ppcCU[uiDepth]->getCUPelX(), |
|---|
| 624 | m_ppcCU[uiDepth]->getCUPelY(), |
|---|
| 625 | m_ppcCU[uiDepth]->getWidth(0), |
|---|
| 626 | m_ppcCU[uiDepth]->getHeight(0) ); |
|---|
| 627 | #endif |
|---|
| 628 | #endif |
|---|
| 629 | |
|---|
| 630 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
|---|
| 631 | { |
|---|
| 632 | case MODE_INTER: |
|---|
| 633 | #if H_3D_DBBP |
|---|
| 634 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
|---|
| 635 | { |
|---|
| 636 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
|---|
| 637 | } |
|---|
| 638 | else |
|---|
| 639 | { |
|---|
| 640 | #endif |
|---|
| 641 | #if H_3D_INTER_SDC |
|---|
| 642 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
|---|
| 643 | { |
|---|
| 644 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
|---|
| 645 | } |
|---|
| 646 | else |
|---|
| 647 | { |
|---|
| 648 | #endif |
|---|
| 649 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
|---|
| 650 | #if H_3D_INTER_SDC |
|---|
| 651 | } |
|---|
| 652 | #endif |
|---|
| 653 | #if H_3D_DBBP |
|---|
| 654 | } |
|---|
| 655 | #endif |
|---|
| 656 | break; |
|---|
| 657 | case MODE_INTRA: |
|---|
| 658 | #if H_3D_SINGLE_DEPTH |
|---|
| 659 | if( m_ppcCU[uiDepth]->getSingleDepthFlag(0) ) |
|---|
| 660 | xReconIntraSingleDepth( m_ppcCU[uiDepth], 0, uiDepth ); |
|---|
| 661 | #if H_3D_DIM_SDC |
|---|
| 662 | else if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
|---|
| 663 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
|---|
| 664 | #endif |
|---|
| 665 | else |
|---|
| 666 | #else |
|---|
| 667 | #if H_3D_DIM_SDC |
|---|
| 668 | if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
|---|
| 669 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
|---|
| 670 | else |
|---|
| 671 | #endif |
|---|
| 672 | #endif |
|---|
| 673 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
|---|
| 674 | break; |
|---|
| 675 | default: |
|---|
| 676 | assert(0); |
|---|
| 677 | break; |
|---|
| 678 | } |
|---|
| 679 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
|---|
| 680 | { |
|---|
| 681 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
|---|
| 682 | } |
|---|
| 683 | |
|---|
| 684 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 688 | { |
|---|
| 689 | |
|---|
| 690 | // inter prediction |
|---|
| 691 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
|---|
| 692 | |
|---|
| 693 | // inter recon |
|---|
| 694 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
|---|
| 695 | |
|---|
| 696 | // clip for only non-zero cbp case |
|---|
| 697 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
|---|
| 698 | { |
|---|
| 699 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
|---|
| 700 | } |
|---|
| 701 | else |
|---|
| 702 | { |
|---|
| 703 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
|---|
| 704 | } |
|---|
| 705 | } |
|---|
| 706 | #if H_3D_SINGLE_DEPTH |
|---|
| 707 | Void TDecCu::xReconIntraSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 708 | { |
|---|
| 709 | UInt uiWidth = pcCU->getWidth ( 0 ); |
|---|
| 710 | UInt uiHeight = pcCU->getHeight ( 0 ); |
|---|
| 711 | |
|---|
| 712 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
|---|
| 713 | |
|---|
| 714 | UInt uiStride = pcRecoYuv->getStride (); |
|---|
| 715 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 716 | |
|---|
| 717 | |
|---|
| 718 | AOF( uiWidth == uiHeight ); |
|---|
| 719 | AOF( uiAbsPartIdx == 0 ); |
|---|
| 720 | |
|---|
| 721 | //construction of depth candidates |
|---|
| 722 | Pel testDepth; |
|---|
| 723 | Pel DepthNeighbours[2]; |
|---|
| 724 | Int index =0; |
|---|
| 725 | for( Int i = 0; (i < 2) && (index<SINGLE_DEPTH_MODE_CAND_LIST_SIZE) ; i++ ) |
|---|
| 726 | { |
|---|
| 727 | if(!pcCU->getNeighDepth (0, uiAbsPartIdx, &testDepth, i)) |
|---|
| 728 | { |
|---|
| 729 | continue; |
|---|
| 730 | } |
|---|
| 731 | DepthNeighbours[index]=testDepth; |
|---|
| 732 | index++; |
|---|
| 733 | } |
|---|
| 734 | |
|---|
| 735 | if(index==0) |
|---|
| 736 | { |
|---|
| 737 | DepthNeighbours[index]=1<<(g_bitDepthY-1); |
|---|
| 738 | index++; |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | if(index==1) |
|---|
| 742 | { |
|---|
| 743 | DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 ); |
|---|
| 744 | index++; |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 748 | { |
|---|
| 749 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 750 | { |
|---|
| 751 | piReco[ uiX ] =DepthNeighbours[(Int)pcCU->getSingleDepthValue(uiAbsPartIdx)]; |
|---|
| 752 | } |
|---|
| 753 | piReco += uiStride; |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | // clear UV |
|---|
| 757 | UInt uiStrideC = pcRecoYuv->getCStride(); |
|---|
| 758 | Pel *pRecCb = pcRecoYuv->getCbAddr(); |
|---|
| 759 | Pel *pRecCr = pcRecoYuv->getCrAddr(); |
|---|
| 760 | |
|---|
| 761 | for (Int y=0; y<uiHeight/2; y++) |
|---|
| 762 | { |
|---|
| 763 | for (Int x=0; x<uiWidth/2; x++) |
|---|
| 764 | { |
|---|
| 765 | pRecCb[x] = 1<<(g_bitDepthC-1); |
|---|
| 766 | pRecCr[x] = 1<<(g_bitDepthC-1); |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | pRecCb += uiStrideC; |
|---|
| 770 | pRecCr += uiStrideC; |
|---|
| 771 | } |
|---|
| 772 | } |
|---|
| 773 | #endif |
|---|
| 774 | #if H_3D_INTER_SDC |
|---|
| 775 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 776 | { |
|---|
| 777 | // inter prediction |
|---|
| 778 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
|---|
| 779 | |
|---|
| 780 | UInt uiWidth = pcCU->getWidth ( 0 ); |
|---|
| 781 | UInt uiHeight = pcCU->getHeight( 0 ); |
|---|
| 782 | |
|---|
| 783 | Pel *pResi; |
|---|
| 784 | UInt uiPelX, uiPelY; |
|---|
| 785 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
|---|
| 786 | |
|---|
| 787 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
|---|
| 788 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
|---|
| 789 | { |
|---|
| 790 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 791 | { |
|---|
| 792 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
|---|
| 793 | } |
|---|
| 794 | pResi += uiResiStride; |
|---|
| 795 | } |
|---|
| 796 | |
|---|
| 797 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
|---|
| 798 | |
|---|
| 799 | // clear UV |
|---|
| 800 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
|---|
| 801 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
|---|
| 802 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
|---|
| 803 | |
|---|
| 804 | for (Int y = 0; y < uiHeight/2; y++) |
|---|
| 805 | { |
|---|
| 806 | for (Int x = 0; x < uiWidth/2; x++) |
|---|
| 807 | { |
|---|
| 808 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
|---|
| 809 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | pRecCb += uiStrideC; |
|---|
| 813 | pRecCr += uiStrideC; |
|---|
| 814 | } |
|---|
| 815 | } |
|---|
| 816 | #endif |
|---|
| 817 | |
|---|
| 818 | #if H_3D_DBBP |
|---|
| 819 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 820 | { |
|---|
| 821 | AOF(!pcCU->getSlice()->getIsDepth()); |
|---|
| 822 | AOF(!pcCU->getSlice()->isIntra()); |
|---|
| 823 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
|---|
| 824 | |
|---|
| 825 | // get collocated depth block |
|---|
| 826 | UInt uiDepthStride = 0; |
|---|
| 827 | #if H_3D_FCO |
|---|
| 828 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
|---|
| 829 | #else |
|---|
| 830 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
|---|
| 831 | #endif |
|---|
| 832 | AOF( pDepthPels != NULL ); |
|---|
| 833 | AOF( uiDepthStride != 0 ); |
|---|
| 834 | |
|---|
| 835 | // compute mask by segmenting depth block |
|---|
| 836 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
|---|
| 837 | #if HS_DBBP_CLEAN_K0048 |
|---|
| 838 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
|---|
| 839 | #else |
|---|
| 840 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask); |
|---|
| 841 | #endif |
|---|
| 842 | AOF(bValidMask); |
|---|
| 843 | |
|---|
| 844 | DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
|---|
| 845 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
|---|
| 846 | |
|---|
| 847 | // first, extract the two sets of motion parameters |
|---|
| 848 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
|---|
| 849 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
|---|
| 850 | { |
|---|
| 851 | UInt uiPartAddr = uiSegment*uiPUOffset; |
|---|
| 852 | |
|---|
| 853 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
|---|
| 854 | |
|---|
| 855 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 856 | { |
|---|
| 857 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
|---|
| 858 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
|---|
| 859 | } |
|---|
| 860 | |
|---|
| 861 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
|---|
| 862 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
|---|
| 863 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
|---|
| 864 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
|---|
| 865 | } |
|---|
| 866 | |
|---|
| 867 | // do motion compensation for each segment as 2Nx2N |
|---|
| 868 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
|---|
| 869 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
|---|
| 870 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
|---|
| 871 | { |
|---|
| 872 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
|---|
| 873 | |
|---|
| 874 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 875 | { |
|---|
| 876 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
|---|
| 877 | |
|---|
| 878 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
|---|
| 879 | } |
|---|
| 880 | |
|---|
| 881 | // inter prediction |
|---|
| 882 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
|---|
| 883 | } |
|---|
| 884 | |
|---|
| 885 | // restore motion information in both segments again |
|---|
| 886 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
|---|
| 887 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
|---|
| 888 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
|---|
| 889 | { |
|---|
| 890 | UInt uiPartAddr = uiSegment*uiPUOffset; |
|---|
| 891 | |
|---|
| 892 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
|---|
| 893 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
|---|
| 894 | |
|---|
| 895 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 896 | { |
|---|
| 897 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
|---|
| 898 | |
|---|
| 899 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
|---|
| 900 | } |
|---|
| 901 | } |
|---|
| 902 | |
|---|
| 903 | // reconstruct final prediction signal by combining both segments |
|---|
| 904 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize); |
|---|
| 905 | |
|---|
| 906 | // inter recon |
|---|
| 907 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
|---|
| 908 | |
|---|
| 909 | // clip for only non-zero cbp case |
|---|
| 910 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
|---|
| 911 | { |
|---|
| 912 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
|---|
| 913 | } |
|---|
| 914 | else |
|---|
| 915 | { |
|---|
| 916 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
|---|
| 917 | } |
|---|
| 918 | } |
|---|
| 919 | #endif |
|---|
| 920 | |
|---|
| 921 | Void |
|---|
| 922 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
|---|
| 923 | UInt uiTrDepth, |
|---|
| 924 | UInt uiAbsPartIdx, |
|---|
| 925 | TComYuv* pcRecoYuv, |
|---|
| 926 | TComYuv* pcPredYuv, |
|---|
| 927 | TComYuv* pcResiYuv ) |
|---|
| 928 | { |
|---|
| 929 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
|---|
| 930 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
|---|
| 931 | UInt uiStride = pcRecoYuv->getStride (); |
|---|
| 932 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 933 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 934 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 935 | |
|---|
| 936 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
|---|
| 937 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
|---|
| 938 | |
|---|
| 939 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
|---|
| 940 | |
|---|
| 941 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
|---|
| 942 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
|---|
| 943 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
|---|
| 944 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
|---|
| 945 | //===== init availability pattern ===== |
|---|
| 946 | Bool bAboveAvail = false; |
|---|
| 947 | Bool bLeftAvail = false; |
|---|
| 948 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
|---|
| 949 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
|---|
| 950 | m_pcPrediction->getPredicBuf (), |
|---|
| 951 | m_pcPrediction->getPredicBufWidth (), |
|---|
| 952 | m_pcPrediction->getPredicBufHeight (), |
|---|
| 953 | bAboveAvail, bLeftAvail ); |
|---|
| 954 | |
|---|
| 955 | //===== get prediction signal ===== |
|---|
| 956 | #if H_3D_DIM |
|---|
| 957 | if( isDimMode( uiLumaPredMode ) ) |
|---|
| 958 | { |
|---|
| 959 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
|---|
| 960 | } |
|---|
| 961 | else |
|---|
| 962 | { |
|---|
| 963 | #endif |
|---|
| 964 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
|---|
| 965 | #if H_3D_DIM |
|---|
| 966 | } |
|---|
| 967 | #endif |
|---|
| 968 | |
|---|
| 969 | #if H_3D |
|---|
| 970 | Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
|---|
| 971 | |
|---|
| 972 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
|---|
| 973 | #else |
|---|
| 974 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) |
|---|
| 975 | #endif |
|---|
| 976 | { |
|---|
| 977 | //===== inverse transform ===== |
|---|
| 978 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
|---|
| 979 | |
|---|
| 980 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
|---|
| 981 | assert(scalingListType < SCALING_LIST_NUM); |
|---|
| 982 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
|---|
| 983 | |
|---|
| 984 | |
|---|
| 985 | //===== reconstruction ===== |
|---|
| 986 | Pel* pPred = piPred; |
|---|
| 987 | Pel* pResi = piResi; |
|---|
| 988 | Pel* pReco = piReco; |
|---|
| 989 | Pel* pRecIPred = piRecIPred; |
|---|
| 990 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 991 | { |
|---|
| 992 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 993 | { |
|---|
| 994 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
|---|
| 995 | pRecIPred[ uiX ] = pReco[ uiX ]; |
|---|
| 996 | } |
|---|
| 997 | pPred += uiStride; |
|---|
| 998 | pResi += uiStride; |
|---|
| 999 | pReco += uiStride; |
|---|
| 1000 | pRecIPred += uiRecIPredStride; |
|---|
| 1001 | } |
|---|
| 1002 | } |
|---|
| 1003 | else |
|---|
| 1004 | { |
|---|
| 1005 | //===== reconstruction ===== |
|---|
| 1006 | Pel* pPred = piPred; |
|---|
| 1007 | Pel* pReco = piReco; |
|---|
| 1008 | Pel* pRecIPred = piRecIPred; |
|---|
| 1009 | for ( Int y = 0; y < uiHeight; y++ ) |
|---|
| 1010 | { |
|---|
| 1011 | for ( Int x = 0; x < uiWidth; x++ ) |
|---|
| 1012 | { |
|---|
| 1013 | pReco [ x ] = pPred[ x ]; |
|---|
| 1014 | pRecIPred[ x ] = pReco[ x ]; |
|---|
| 1015 | } |
|---|
| 1016 | pPred += uiStride; |
|---|
| 1017 | pReco += uiStride; |
|---|
| 1018 | pRecIPred += uiRecIPredStride; |
|---|
| 1019 | } |
|---|
| 1020 | } |
|---|
| 1021 | } |
|---|
| 1022 | |
|---|
| 1023 | |
|---|
| 1024 | Void |
|---|
| 1025 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
|---|
| 1026 | UInt uiTrDepth, |
|---|
| 1027 | UInt uiAbsPartIdx, |
|---|
| 1028 | TComYuv* pcRecoYuv, |
|---|
| 1029 | TComYuv* pcPredYuv, |
|---|
| 1030 | TComYuv* pcResiYuv, |
|---|
| 1031 | UInt uiChromaId ) |
|---|
| 1032 | { |
|---|
| 1033 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
|---|
| 1034 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
|---|
| 1035 | |
|---|
| 1036 | if( uiLog2TrSize == 2 ) |
|---|
| 1037 | { |
|---|
| 1038 | assert( uiTrDepth > 0 ); |
|---|
| 1039 | uiTrDepth--; |
|---|
| 1040 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
|---|
| 1041 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
|---|
| 1042 | if( !bFirstQ ) |
|---|
| 1043 | { |
|---|
| 1044 | return; |
|---|
| 1045 | } |
|---|
| 1046 | } |
|---|
| 1047 | |
|---|
| 1048 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
|---|
| 1049 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
|---|
| 1050 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
|---|
| 1051 | UInt uiStride = pcRecoYuv->getCStride (); |
|---|
| 1052 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
|---|
| 1053 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
|---|
| 1054 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
|---|
| 1055 | |
|---|
| 1056 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
|---|
| 1057 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
|---|
| 1058 | |
|---|
| 1059 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
|---|
| 1060 | |
|---|
| 1061 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
|---|
| 1062 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
|---|
| 1063 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
|---|
| 1064 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
|---|
| 1065 | //===== init availability pattern ===== |
|---|
| 1066 | Bool bAboveAvail = false; |
|---|
| 1067 | Bool bLeftAvail = false; |
|---|
| 1068 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
|---|
| 1069 | |
|---|
| 1070 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
|---|
| 1071 | m_pcPrediction->getPredicBuf (), |
|---|
| 1072 | m_pcPrediction->getPredicBufWidth (), |
|---|
| 1073 | m_pcPrediction->getPredicBufHeight (), |
|---|
| 1074 | bAboveAvail, bLeftAvail ); |
|---|
| 1075 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
|---|
| 1076 | |
|---|
| 1077 | //===== get prediction signal ===== |
|---|
| 1078 | { |
|---|
| 1079 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
|---|
| 1080 | { |
|---|
| 1081 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
|---|
| 1082 | #if H_3D_DIM |
|---|
| 1083 | mapDepthModeToIntraDir( uiChromaPredMode ); |
|---|
| 1084 | #endif |
|---|
| 1085 | } |
|---|
| 1086 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
|---|
| 1087 | } |
|---|
| 1088 | |
|---|
| 1089 | if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) ) |
|---|
| 1090 | { |
|---|
| 1091 | //===== inverse transform ===== |
|---|
| 1092 | Int curChromaQpOffset; |
|---|
| 1093 | if(eText == TEXT_CHROMA_U) |
|---|
| 1094 | { |
|---|
| 1095 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
|---|
| 1096 | } |
|---|
| 1097 | else |
|---|
| 1098 | { |
|---|
| 1099 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
|---|
| 1100 | } |
|---|
| 1101 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
|---|
| 1102 | |
|---|
| 1103 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
|---|
| 1104 | assert(scalingListType < SCALING_LIST_NUM); |
|---|
| 1105 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
|---|
| 1106 | |
|---|
| 1107 | //===== reconstruction ===== |
|---|
| 1108 | Pel* pPred = piPred; |
|---|
| 1109 | Pel* pResi = piResi; |
|---|
| 1110 | Pel* pReco = piReco; |
|---|
| 1111 | Pel* pRecIPred = piRecIPred; |
|---|
| 1112 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1113 | { |
|---|
| 1114 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1115 | { |
|---|
| 1116 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
|---|
| 1117 | pRecIPred[ uiX ] = pReco[ uiX ]; |
|---|
| 1118 | } |
|---|
| 1119 | pPred += uiStride; |
|---|
| 1120 | pResi += uiStride; |
|---|
| 1121 | pReco += uiStride; |
|---|
| 1122 | pRecIPred += uiRecIPredStride; |
|---|
| 1123 | } |
|---|
| 1124 | } |
|---|
| 1125 | else |
|---|
| 1126 | { |
|---|
| 1127 | //===== reconstruction ===== |
|---|
| 1128 | Pel* pPred = piPred; |
|---|
| 1129 | Pel* pReco = piReco; |
|---|
| 1130 | Pel* pRecIPred = piRecIPred; |
|---|
| 1131 | for ( Int y = 0; y < uiHeight; y++ ) |
|---|
| 1132 | { |
|---|
| 1133 | for ( Int x = 0; x < uiWidth; x++ ) |
|---|
| 1134 | { |
|---|
| 1135 | pReco [ x ] = pPred[ x ]; |
|---|
| 1136 | pRecIPred[ x ] = pReco[ x ]; |
|---|
| 1137 | } |
|---|
| 1138 | pPred += uiStride; |
|---|
| 1139 | pReco += uiStride; |
|---|
| 1140 | pRecIPred += uiRecIPredStride; |
|---|
| 1141 | } |
|---|
| 1142 | } |
|---|
| 1143 | } |
|---|
| 1144 | |
|---|
| 1145 | |
|---|
| 1146 | Void |
|---|
| 1147 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 1148 | { |
|---|
| 1149 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
|---|
| 1150 | UInt uiNumPart = pcCU->getNumPartitions(); |
|---|
| 1151 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
|---|
| 1152 | |
|---|
| 1153 | if (pcCU->getIPCMFlag(0)) |
|---|
| 1154 | { |
|---|
| 1155 | xReconPCM( pcCU, uiDepth ); |
|---|
| 1156 | return; |
|---|
| 1157 | } |
|---|
| 1158 | |
|---|
| 1159 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
|---|
| 1160 | { |
|---|
| 1161 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
|---|
| 1162 | } |
|---|
| 1163 | |
|---|
| 1164 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
|---|
| 1165 | { |
|---|
| 1166 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
|---|
| 1167 | } |
|---|
| 1168 | |
|---|
| 1169 | } |
|---|
| 1170 | |
|---|
| 1171 | #if H_3D_DIM_SDC |
|---|
| 1172 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1173 | { |
|---|
| 1174 | UInt uiWidth = pcCU->getWidth ( 0 ); |
|---|
| 1175 | UInt uiHeight = pcCU->getHeight ( 0 ); |
|---|
| 1176 | TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight ); |
|---|
| 1177 | UInt numParts = 1; |
|---|
| 1178 | UInt sdcDepth = 0; |
|---|
| 1179 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
|---|
| 1180 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
|---|
| 1181 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
|---|
| 1182 | |
|---|
| 1183 | UInt uiStride = 0; |
|---|
| 1184 | Pel* piReco; |
|---|
| 1185 | Pel* piPred; |
|---|
| 1186 | Pel* piResi; |
|---|
| 1187 | |
|---|
| 1188 | UInt uiZOrder; |
|---|
| 1189 | Pel* piRecIPred; |
|---|
| 1190 | UInt uiRecIPredStride; |
|---|
| 1191 | |
|---|
| 1192 | UInt uiLumaPredMode = 0; |
|---|
| 1193 | |
|---|
| 1194 | if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) |
|---|
| 1195 | { |
|---|
| 1196 | numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
|---|
| 1197 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
|---|
| 1198 | uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
|---|
| 1199 | } |
|---|
| 1200 | |
|---|
| 1201 | for ( Int i = 0; i < numParts; i++ ) |
|---|
| 1202 | { |
|---|
| 1203 | uiStride = pcRecoYuv->getStride (); |
|---|
| 1204 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1205 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1206 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1207 | |
|---|
| 1208 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
|---|
| 1209 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
|---|
| 1210 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
|---|
| 1211 | |
|---|
| 1212 | uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
|---|
| 1213 | |
|---|
| 1214 | AOF( uiWidth == uiHeight ); |
|---|
| 1215 | |
|---|
| 1216 | //===== init availability pattern ===== |
|---|
| 1217 | Bool bAboveAvail = false; |
|---|
| 1218 | Bool bLeftAvail = false; |
|---|
| 1219 | |
|---|
| 1220 | pcCU->getPattern()->initPattern ( pcCU, sdcDepth, uiAbsPartIdx ); |
|---|
| 1221 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
|---|
| 1222 | |
|---|
| 1223 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
|---|
| 1224 | //===== get prediction signal ===== |
|---|
| 1225 | if( isDimMode( uiLumaPredMode ) ) |
|---|
| 1226 | { |
|---|
| 1227 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation ); |
|---|
| 1228 | Bool* dmm4PatternSplit = dmm4Segmentation->getPattern(); |
|---|
| 1229 | Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern(); |
|---|
| 1230 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
|---|
| 1231 | { |
|---|
| 1232 | dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k]; |
|---|
| 1233 | } |
|---|
| 1234 | } |
|---|
| 1235 | else |
|---|
| 1236 | { |
|---|
| 1237 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | if ( numParts > 1 ) |
|---|
| 1241 | { |
|---|
| 1242 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1243 | { |
|---|
| 1244 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1245 | { |
|---|
| 1246 | piReco [ uiX ] = ClipY( piPred[ uiX ] ); |
|---|
| 1247 | piRecIPred [ uiX ] = piReco[ uiX ]; |
|---|
| 1248 | } |
|---|
| 1249 | piPred += uiStride; |
|---|
| 1250 | piReco += uiStride; |
|---|
| 1251 | piRecIPred += uiRecIPredStride; |
|---|
| 1252 | } |
|---|
| 1253 | } |
|---|
| 1254 | uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 ); |
|---|
| 1255 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
|---|
| 1256 | } |
|---|
| 1257 | uiAbsPartIdx = 0; |
|---|
| 1258 | |
|---|
| 1259 | if ( numParts > 1 ) |
|---|
| 1260 | { |
|---|
| 1261 | uiWidth = pcCU->getWidth( 0 ); |
|---|
| 1262 | uiHeight = pcCU->getHeight( 0 ); |
|---|
| 1263 | } |
|---|
| 1264 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1265 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1266 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
|---|
| 1267 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
|---|
| 1268 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
|---|
| 1269 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
|---|
| 1270 | // number of segments depends on prediction mode |
|---|
| 1271 | UInt uiNumSegments = 1; |
|---|
| 1272 | Bool* pbMask = NULL; |
|---|
| 1273 | UInt uiMaskStride = 0; |
|---|
| 1274 | |
|---|
| 1275 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
|---|
| 1276 | { |
|---|
| 1277 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
|---|
| 1278 | |
|---|
| 1279 | WedgeList* pacWedgeList = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
|---|
| 1280 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
|---|
| 1281 | |
|---|
| 1282 | uiNumSegments = 2; |
|---|
| 1283 | |
|---|
| 1284 | pbMask = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern(); |
|---|
| 1285 | uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride(); |
|---|
| 1286 | } |
|---|
| 1287 | if( getDimType( uiLumaPredMode ) == DMM4_IDX ) |
|---|
| 1288 | { |
|---|
| 1289 | uiNumSegments = 2; |
|---|
| 1290 | pbMask = dmm4SegmentationOrg->getPattern(); |
|---|
| 1291 | uiMaskStride = dmm4SegmentationOrg->getStride(); |
|---|
| 1292 | } |
|---|
| 1293 | // get DC prediction for each segment |
|---|
| 1294 | Pel apDCPredValues[2]; |
|---|
| 1295 | if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX ) |
|---|
| 1296 | { |
|---|
| 1297 | apDCPredValues[0] = pcCU->getDmmPredictor( 0 ); |
|---|
| 1298 | apDCPredValues[1] = pcCU->getDmmPredictor( 1 ); |
|---|
| 1299 | } |
|---|
| 1300 | else |
|---|
| 1301 | { |
|---|
| 1302 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
|---|
| 1303 | } |
|---|
| 1304 | |
|---|
| 1305 | // reconstruct residual based on mask + DC residuals |
|---|
| 1306 | Pel apDCResiValues[2]; |
|---|
| 1307 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
|---|
| 1308 | { |
|---|
| 1309 | #if H_3D_DIM_DLT |
|---|
| 1310 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
|---|
| 1311 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
|---|
| 1312 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
|---|
| 1313 | |
|---|
| 1314 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
|---|
| 1315 | #else |
|---|
| 1316 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
|---|
| 1317 | #endif |
|---|
| 1318 | } |
|---|
| 1319 | |
|---|
| 1320 | //===== reconstruction ===== |
|---|
| 1321 | Bool*pMask = pbMask; |
|---|
| 1322 | Pel* pPred = piPred; |
|---|
| 1323 | Pel* pResi = piResi; |
|---|
| 1324 | Pel* pReco = piReco; |
|---|
| 1325 | Pel* pRecIPred = piRecIPred; |
|---|
| 1326 | |
|---|
| 1327 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1328 | { |
|---|
| 1329 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1330 | { |
|---|
| 1331 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
|---|
| 1332 | assert( ucSegment < uiNumSegments ); |
|---|
| 1333 | |
|---|
| 1334 | Pel pResiDC = apDCResiValues[ucSegment]; |
|---|
| 1335 | |
|---|
| 1336 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
|---|
| 1337 | pRecIPred[ uiX ] = pReco[ uiX ]; |
|---|
| 1338 | } |
|---|
| 1339 | pPred += uiStride; |
|---|
| 1340 | pResi += uiStride; |
|---|
| 1341 | pReco += uiStride; |
|---|
| 1342 | pRecIPred += uiRecIPredStride; |
|---|
| 1343 | pMask += uiMaskStride; |
|---|
| 1344 | } |
|---|
| 1345 | |
|---|
| 1346 | // clear UV |
|---|
| 1347 | UInt uiStrideC = pcPredYuv->getCStride(); |
|---|
| 1348 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
|---|
| 1349 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
|---|
| 1350 | |
|---|
| 1351 | for (Int y=0; y<uiHeight/2; y++) |
|---|
| 1352 | { |
|---|
| 1353 | for (Int x=0; x<uiWidth/2; x++) |
|---|
| 1354 | { |
|---|
| 1355 | pRecCb[x] = 128; |
|---|
| 1356 | pRecCr[x] = 128; |
|---|
| 1357 | } |
|---|
| 1358 | |
|---|
| 1359 | pRecCb += uiStrideC; |
|---|
| 1360 | pRecCr += uiStrideC; |
|---|
| 1361 | } |
|---|
| 1362 | dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg; |
|---|
| 1363 | } |
|---|
| 1364 | #endif |
|---|
| 1365 | |
|---|
| 1366 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
|---|
| 1367 | * \param pcCU pointer of current CU |
|---|
| 1368 | * \param uiTrDepth current tranform split depth |
|---|
| 1369 | * \param uiAbsPartIdx part index |
|---|
| 1370 | * \param pcRecoYuv pointer to reconstructed sample arrays |
|---|
| 1371 | * \param pcPredYuv pointer to prediction sample arrays |
|---|
| 1372 | * \param pcResiYuv pointer to residue sample arrays |
|---|
| 1373 | * |
|---|
| 1374 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
|---|
| 1375 | */ |
|---|
| 1376 | Void |
|---|
| 1377 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
|---|
| 1378 | UInt uiTrDepth, |
|---|
| 1379 | UInt uiAbsPartIdx, |
|---|
| 1380 | TComYuv* pcRecoYuv, |
|---|
| 1381 | TComYuv* pcPredYuv, |
|---|
| 1382 | TComYuv* pcResiYuv ) |
|---|
| 1383 | { |
|---|
| 1384 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
|---|
| 1385 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
|---|
| 1386 | if( uiTrMode == uiTrDepth ) |
|---|
| 1387 | { |
|---|
| 1388 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
|---|
| 1389 | } |
|---|
| 1390 | else |
|---|
| 1391 | { |
|---|
| 1392 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
|---|
| 1393 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
|---|
| 1394 | { |
|---|
| 1395 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
|---|
| 1396 | } |
|---|
| 1397 | } |
|---|
| 1398 | } |
|---|
| 1399 | |
|---|
| 1400 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
|---|
| 1401 | * \param pcCU pointer of current CU |
|---|
| 1402 | * \param uiTrDepth current tranform split depth |
|---|
| 1403 | * \param uiAbsPartIdx part index |
|---|
| 1404 | * \param pcRecoYuv pointer to reconstructed sample arrays |
|---|
| 1405 | * \param pcPredYuv pointer to prediction sample arrays |
|---|
| 1406 | * \param pcResiYuv pointer to residue sample arrays |
|---|
| 1407 | * |
|---|
| 1408 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
|---|
| 1409 | */ |
|---|
| 1410 | Void |
|---|
| 1411 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
|---|
| 1412 | UInt uiTrDepth, |
|---|
| 1413 | UInt uiAbsPartIdx, |
|---|
| 1414 | TComYuv* pcRecoYuv, |
|---|
| 1415 | TComYuv* pcPredYuv, |
|---|
| 1416 | TComYuv* pcResiYuv ) |
|---|
| 1417 | { |
|---|
| 1418 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
|---|
| 1419 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
|---|
| 1420 | if( uiTrMode == uiTrDepth ) |
|---|
| 1421 | { |
|---|
| 1422 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
|---|
| 1423 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
|---|
| 1424 | } |
|---|
| 1425 | else |
|---|
| 1426 | { |
|---|
| 1427 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
|---|
| 1428 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
|---|
| 1429 | { |
|---|
| 1430 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
|---|
| 1431 | } |
|---|
| 1432 | } |
|---|
| 1433 | } |
|---|
| 1434 | |
|---|
| 1435 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
|---|
| 1436 | { |
|---|
| 1437 | UInt uiCUAddr = pcCU->getAddr(); |
|---|
| 1438 | |
|---|
| 1439 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
|---|
| 1440 | |
|---|
| 1441 | return; |
|---|
| 1442 | } |
|---|
| 1443 | |
|---|
| 1444 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1445 | { |
|---|
| 1446 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
|---|
| 1447 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
|---|
| 1448 | TCoeff* piCoeff; |
|---|
| 1449 | |
|---|
| 1450 | Pel* pResi; |
|---|
| 1451 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
|---|
| 1452 | |
|---|
| 1453 | // Y |
|---|
| 1454 | piCoeff = pcCU->getCoeffY(); |
|---|
| 1455 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
|---|
| 1456 | |
|---|
| 1457 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
|---|
| 1458 | |
|---|
| 1459 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
|---|
| 1460 | |
|---|
| 1461 | // Cb and Cr |
|---|
| 1462 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
|---|
| 1463 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
|---|
| 1464 | |
|---|
| 1465 | uiWidth >>= 1; |
|---|
| 1466 | uiHeight >>= 1; |
|---|
| 1467 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
|---|
| 1468 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
|---|
| 1469 | |
|---|
| 1470 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
|---|
| 1471 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
|---|
| 1472 | |
|---|
| 1473 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
|---|
| 1474 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
|---|
| 1475 | } |
|---|
| 1476 | |
|---|
| 1477 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
|---|
| 1478 | * \param pcCU pointer to current CU |
|---|
| 1479 | * \param uiPartIdx part index |
|---|
| 1480 | * \param piPCM pointer to PCM code arrays |
|---|
| 1481 | * \param piReco pointer to reconstructed sample arrays |
|---|
| 1482 | * \param uiStride stride of reconstructed sample arrays |
|---|
| 1483 | * \param uiWidth CU width |
|---|
| 1484 | * \param uiHeight CU height |
|---|
| 1485 | * \param ttText texture component type |
|---|
| 1486 | * \returns Void |
|---|
| 1487 | */ |
|---|
| 1488 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
|---|
| 1489 | { |
|---|
| 1490 | UInt uiX, uiY; |
|---|
| 1491 | Pel* piPicReco; |
|---|
| 1492 | UInt uiPicStride; |
|---|
| 1493 | UInt uiPcmLeftShiftBit; |
|---|
| 1494 | |
|---|
| 1495 | if( ttText == TEXT_LUMA ) |
|---|
| 1496 | { |
|---|
| 1497 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
|---|
| 1498 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
|---|
| 1499 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
|---|
| 1500 | } |
|---|
| 1501 | else |
|---|
| 1502 | { |
|---|
| 1503 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
|---|
| 1504 | |
|---|
| 1505 | if( ttText == TEXT_CHROMA_U ) |
|---|
| 1506 | { |
|---|
| 1507 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
|---|
| 1508 | } |
|---|
| 1509 | else |
|---|
| 1510 | { |
|---|
| 1511 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
|---|
| 1512 | } |
|---|
| 1513 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
|---|
| 1514 | } |
|---|
| 1515 | |
|---|
| 1516 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1517 | { |
|---|
| 1518 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1519 | { |
|---|
| 1520 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
|---|
| 1521 | piPicReco[uiX] = piReco[uiX]; |
|---|
| 1522 | } |
|---|
| 1523 | piPCM += uiWidth; |
|---|
| 1524 | piReco += uiStride; |
|---|
| 1525 | piPicReco += uiPicStride; |
|---|
| 1526 | } |
|---|
| 1527 | } |
|---|
| 1528 | |
|---|
| 1529 | /** Function for reconstructing a PCM mode CU. |
|---|
| 1530 | * \param pcCU pointer to current CU |
|---|
| 1531 | * \param uiDepth CU Depth |
|---|
| 1532 | * \returns Void |
|---|
| 1533 | */ |
|---|
| 1534 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 1535 | { |
|---|
| 1536 | // Luma |
|---|
| 1537 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
|---|
| 1538 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
|---|
| 1539 | |
|---|
| 1540 | Pel* piPcmY = pcCU->getPCMSampleY(); |
|---|
| 1541 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
|---|
| 1542 | |
|---|
| 1543 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
|---|
| 1544 | |
|---|
| 1545 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
|---|
| 1546 | |
|---|
| 1547 | // Cb and Cr |
|---|
| 1548 | UInt uiCWidth = (uiWidth>>1); |
|---|
| 1549 | UInt uiCHeight = (uiHeight>>1); |
|---|
| 1550 | |
|---|
| 1551 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
|---|
| 1552 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
|---|
| 1553 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
|---|
| 1554 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
|---|
| 1555 | |
|---|
| 1556 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
|---|
| 1557 | |
|---|
| 1558 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
|---|
| 1559 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
|---|
| 1560 | } |
|---|
| 1561 | |
|---|
| 1562 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
|---|
| 1563 | * \param pcCU pointer to current CU |
|---|
| 1564 | * \param uiDepth CU Depth |
|---|
| 1565 | * \returns Void |
|---|
| 1566 | */ |
|---|
| 1567 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
|---|
| 1568 | { |
|---|
| 1569 | // Luma |
|---|
| 1570 | UInt width = (g_uiMaxCUWidth >> depth); |
|---|
| 1571 | UInt height = (g_uiMaxCUHeight >> depth); |
|---|
| 1572 | |
|---|
| 1573 | Pel* pPcmY = pCU->getPCMSampleY(); |
|---|
| 1574 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
|---|
| 1575 | |
|---|
| 1576 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
|---|
| 1577 | |
|---|
| 1578 | for(Int y = 0; y < height; y++ ) |
|---|
| 1579 | { |
|---|
| 1580 | for(Int x = 0; x < width; x++ ) |
|---|
| 1581 | { |
|---|
| 1582 | pPcmY[x] = pRecoY[x]; |
|---|
| 1583 | } |
|---|
| 1584 | pPcmY += width; |
|---|
| 1585 | pRecoY += stride; |
|---|
| 1586 | } |
|---|
| 1587 | |
|---|
| 1588 | // Cb and Cr |
|---|
| 1589 | UInt widthC = (width>>1); |
|---|
| 1590 | UInt heightC = (height>>1); |
|---|
| 1591 | |
|---|
| 1592 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
|---|
| 1593 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
|---|
| 1594 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
|---|
| 1595 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
|---|
| 1596 | |
|---|
| 1597 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
|---|
| 1598 | |
|---|
| 1599 | for(Int y = 0; y < heightC; y++ ) |
|---|
| 1600 | { |
|---|
| 1601 | for(Int x = 0; x < widthC; x++ ) |
|---|
| 1602 | { |
|---|
| 1603 | pPcmCb[x] = pRecoCb[x]; |
|---|
| 1604 | pPcmCr[x] = pRecoCr[x]; |
|---|
| 1605 | } |
|---|
| 1606 | pPcmCr += widthC; |
|---|
| 1607 | pPcmCb += widthC; |
|---|
| 1608 | pRecoCb += strideC; |
|---|
| 1609 | pRecoCr += strideC; |
|---|
| 1610 | } |
|---|
| 1611 | |
|---|
| 1612 | } |
|---|
| 1613 | |
|---|
| 1614 | //! \} |
|---|