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