[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 |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, 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" |
---|
[1200] | 39 | #include "TLibCommon/TComTU.h" |
---|
| 40 | #include "TLibCommon/TComPrediction.h" |
---|
[2] | 41 | |
---|
[56] | 42 | //! \ingroup TLibDecoder |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
[2] | 45 | // ==================================================================================================================== |
---|
| 46 | // Constructor / destructor / create / destroy |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | |
---|
| 49 | TDecCu::TDecCu() |
---|
| 50 | { |
---|
[56] | 51 | m_ppcYuvResi = NULL; |
---|
| 52 | m_ppcYuvReco = NULL; |
---|
| 53 | m_ppcCU = NULL; |
---|
[833] | 54 | #if H_3D_DBBP |
---|
| 55 | m_ppcYuvRecoDBBP = NULL; |
---|
| 56 | #endif |
---|
[2] | 57 | } |
---|
| 58 | |
---|
| 59 | TDecCu::~TDecCu() |
---|
| 60 | { |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
| 64 | { |
---|
| 65 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
| 66 | m_pcTrQuant = pcTrQuant; |
---|
| 67 | m_pcPrediction = pcPrediction; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /** |
---|
[1200] | 71 | \param uiMaxDepth total number of allowable depth |
---|
| 72 | \param uiMaxWidth largest CU width |
---|
| 73 | \param uiMaxHeight largest CU height |
---|
| 74 | \param chromaFormatIDC chroma format |
---|
[2] | 75 | */ |
---|
[1200] | 76 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
---|
[2] | 77 | { |
---|
| 78 | m_uiMaxDepth = uiMaxDepth+1; |
---|
[1200] | 79 | |
---|
[56] | 80 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 81 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 82 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
[833] | 83 | #if H_3D_DBBP |
---|
| 84 | m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1]; |
---|
| 85 | #endif |
---|
[1200] | 86 | |
---|
[2] | 87 | UInt uiNumPartitions; |
---|
| 88 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 89 | { |
---|
| 90 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
| 91 | UInt uiWidth = uiMaxWidth >> ui; |
---|
| 92 | UInt uiHeight = uiMaxHeight >> ui; |
---|
[1200] | 93 | |
---|
| 94 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
| 95 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
| 96 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
[833] | 97 | #if H_3D_DBBP |
---|
| 98 | m_ppcYuvRecoDBBP[ui] = new TComYuv; m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight ); |
---|
| 99 | #endif |
---|
[1200] | 100 | } |
---|
| 101 | |
---|
[56] | 102 | m_bDecodeDQP = false; |
---|
[1200] | 103 | m_IsChromaQpAdjCoded = false; |
---|
[56] | 104 | |
---|
[2] | 105 | // initialize partition order. |
---|
| 106 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
| 107 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
| 108 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
[1200] | 109 | |
---|
[2] | 110 | // initialize conversion matrix from partition index to pel |
---|
| 111 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | Void TDecCu::destroy() |
---|
| 115 | { |
---|
| 116 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
| 117 | { |
---|
[56] | 118 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
| 119 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
| 120 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
[833] | 121 | #if H_3D_DBBP |
---|
| 122 | m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL; |
---|
| 123 | #endif |
---|
[2] | 124 | } |
---|
[1200] | 125 | |
---|
[56] | 126 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
| 127 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
| 128 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
[833] | 129 | #if H_3D_DBBP |
---|
| 130 | delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL; |
---|
| 131 | #endif |
---|
[2] | 132 | } |
---|
| 133 | |
---|
| 134 | // ==================================================================================================================== |
---|
| 135 | // Public member functions |
---|
| 136 | // ==================================================================================================================== |
---|
| 137 | |
---|
[1200] | 138 | /** |
---|
| 139 | Parse a CTU. |
---|
| 140 | \param pCtu [in/out] pointer to CTU data structure |
---|
| 141 | \param isLastCtuOfSliceSegment [out] true, if last CTU of the slice segment |
---|
[2] | 142 | */ |
---|
[1200] | 143 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
---|
[2] | 144 | { |
---|
[1200] | 145 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 146 | { |
---|
[56] | 147 | setdQPFlag(true); |
---|
[2] | 148 | } |
---|
[56] | 149 | |
---|
[1200] | 150 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
---|
| 151 | { |
---|
| 152 | setIsChromaQpAdjCoded(true); |
---|
| 153 | } |
---|
| 154 | |
---|
[2] | 155 | // start from the top level CU |
---|
[1200] | 156 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
---|
[2] | 157 | } |
---|
| 158 | |
---|
[1200] | 159 | /** |
---|
| 160 | Decoding process for a CTU. |
---|
| 161 | \param pCtu [in/out] pointer to CTU data structure |
---|
[2] | 162 | */ |
---|
[1200] | 163 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
---|
[2] | 164 | { |
---|
[773] | 165 | #if !H_3D_IV_MERGE |
---|
[1200] | 166 | xDecompressCU( pCtu, 0, 0 ); |
---|
[724] | 167 | #endif |
---|
[2] | 168 | } |
---|
| 169 | |
---|
| 170 | // ==================================================================================================================== |
---|
| 171 | // Protected member functions |
---|
| 172 | // ==================================================================================================================== |
---|
| 173 | |
---|
[1200] | 174 | //! decode end-of-slice flag |
---|
| 175 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
[608] | 176 | { |
---|
[1200] | 177 | UInt uiIsLastCtuOfSliceSegment; |
---|
[56] | 178 | |
---|
[1200] | 179 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
---|
[56] | 180 | { |
---|
[1200] | 181 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
---|
[56] | 182 | } |
---|
| 183 | else |
---|
| 184 | { |
---|
[1200] | 185 | uiIsLastCtuOfSliceSegment=0; |
---|
[56] | 186 | } |
---|
| 187 | |
---|
[1200] | 188 | return uiIsLastCtuOfSliceSegment>0; |
---|
[56] | 189 | } |
---|
| 190 | |
---|
[1200] | 191 | //! decode CU block recursively |
---|
| 192 | Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
[2] | 193 | { |
---|
[1200] | 194 | TComPic* pcPic = pcCU->getPic(); |
---|
| 195 | const TComSPS &sps = pcPic->getPicSym()->getSPS(); |
---|
| 196 | const TComPPS &pps = pcPic->getPicSym()->getPPS(); |
---|
| 197 | const UInt maxCuWidth = sps.getMaxCUWidth(); |
---|
| 198 | const UInt maxCuHeight= sps.getMaxCUHeight(); |
---|
| 199 | UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); |
---|
[2] | 200 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
[1200] | 201 | |
---|
| 202 | |
---|
[2] | 203 | Bool bBoundary = false; |
---|
| 204 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[1200] | 205 | UInt uiRPelX = uiLPelX + (maxCuWidth>>uiDepth) - 1; |
---|
[2] | 206 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
[1200] | 207 | UInt uiBPelY = uiTPelY + (maxCuHeight>>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) |
---|
[1200] | 212 | DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth) |
---|
[608] | 213 | DTRACE_CU("cqtDepth" , uiDepth) |
---|
| 214 | #endif |
---|
[833] | 215 | |
---|
[1200] | 216 | if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
[2] | 217 | { |
---|
[608] | 218 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 219 | } |
---|
| 220 | else |
---|
| 221 | { |
---|
| 222 | bBoundary = true; |
---|
| 223 | } |
---|
[1200] | 224 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
[2] | 225 | { |
---|
| 226 | UInt uiIdx = uiAbsPartIdx; |
---|
[1200] | 227 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
[56] | 228 | { |
---|
| 229 | setdQPFlag(true); |
---|
| 230 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 231 | } |
---|
| 232 | |
---|
[1200] | 233 | if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
| 234 | { |
---|
| 235 | setIsChromaQpAdjCoded(true); |
---|
| 236 | } |
---|
| 237 | |
---|
[2] | 238 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
| 239 | { |
---|
| 240 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 241 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
[1200] | 242 | |
---|
| 243 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
[56] | 244 | { |
---|
[1200] | 245 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
---|
[56] | 246 | } |
---|
[1200] | 247 | else |
---|
| 248 | { |
---|
| 249 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
| 250 | } |
---|
| 251 | |
---|
[2] | 252 | uiIdx += uiQNumParts; |
---|
| 253 | } |
---|
[1200] | 254 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
[56] | 255 | { |
---|
| 256 | if ( getdQPFlag() ) |
---|
| 257 | { |
---|
[1200] | 258 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
---|
[56] | 259 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 260 | } |
---|
| 261 | } |
---|
[2] | 262 | return; |
---|
| 263 | } |
---|
[1200] | 264 | |
---|
[608] | 265 | #if H_MV_ENC_DEC_TRAC |
---|
| 266 | DTRACE_CU_S("=========== coding_unit ===========\n") |
---|
[1179] | 267 | #if H_MV_ENC_DEC_TRAC |
---|
| 268 | #if ENC_DEC_TRACE |
---|
| 269 | stopAtPos ( pcCU->getSlice()->getPOC(), |
---|
| 270 | pcCU->getSlice()->getLayerId(), |
---|
| 271 | uiLPelX, |
---|
| 272 | uiTPelY, |
---|
| 273 | uiRPelX-uiLPelX+1, |
---|
| 274 | uiBPelY-uiTPelY+1); |
---|
[608] | 275 | #endif |
---|
[1179] | 276 | #endif |
---|
[833] | 277 | |
---|
[1179] | 278 | #endif |
---|
| 279 | |
---|
[1200] | 280 | if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
[56] | 281 | { |
---|
| 282 | setdQPFlag(true); |
---|
| 283 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
| 284 | } |
---|
[1210] | 285 | #if NH_3D_NBDV |
---|
[608] | 286 | DisInfo DvInfo; |
---|
| 287 | DvInfo.m_acNBDV.setZero(); |
---|
| 288 | DvInfo.m_aVIdxCan = 0; |
---|
| 289 | #if H_3D_NBDV_REF |
---|
| 290 | DvInfo.m_acDoNBDV.setZero(); |
---|
| 291 | #endif |
---|
| 292 | |
---|
[1200] | 293 | if(!pcCU->getSlice()->isIntra()) |
---|
[608] | 294 | { |
---|
| 295 | #if H_3D_ARP && H_3D_IV_MERGE |
---|
[1124] | 296 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() ) |
---|
[608] | 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 | { |
---|
[1210] | 309 | m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true); |
---|
| 310 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
[608] | 311 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
| 312 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
---|
| 313 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
---|
[1210] | 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); |
---|
[773] | 317 | #if H_3D_IV_MERGE |
---|
[724] | 318 | if( pcCU->getSlice()->getIsDepth()) |
---|
| 319 | { |
---|
[1179] | 320 | m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
---|
[724] | 321 | } |
---|
| 322 | else |
---|
| 323 | { |
---|
| 324 | #endif |
---|
[608] | 325 | #if H_3D_NBDV_REF |
---|
[1124] | 326 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() ) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
---|
[622] | 327 | { |
---|
[1179] | 328 | m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
---|
[622] | 329 | } |
---|
[608] | 330 | else |
---|
[56] | 331 | #endif |
---|
[622] | 332 | { |
---|
[1179] | 333 | m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
---|
[622] | 334 | } |
---|
[773] | 335 | #if H_3D_IV_MERGE |
---|
[724] | 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 |
---|
[608] | 348 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
---|
[1210] | 349 | m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth); |
---|
| 350 | m_ppcCU[uiDepth]->setWidth(0, cWidTemp); |
---|
| 351 | m_ppcCU[uiDepth]->setHeight(0, cHeightTemp); |
---|
[608] | 352 | } |
---|
| 353 | } |
---|
| 354 | #endif |
---|
[1200] | 355 | |
---|
| 356 | if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
[2] | 357 | { |
---|
[1200] | 358 | setIsChromaQpAdjCoded(true); |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | if (pps.getTransquantBypassEnableFlag()) |
---|
| 362 | { |
---|
[608] | 363 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 364 | } |
---|
[1200] | 365 | |
---|
[608] | 366 | // decode CU mode and the partition size |
---|
| 367 | if( !pcCU->getSlice()->isIntra()) |
---|
| 368 | { |
---|
[2] | 369 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 370 | } |
---|
[1200] | 371 | |
---|
| 372 | |
---|
[2] | 373 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
| 374 | { |
---|
[608] | 375 | #if H_MV_ENC_DEC_TRAC |
---|
| 376 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 377 | DTRACE_PU("x0", uiLPelX) |
---|
| 378 | DTRACE_PU("x1", uiTPelY) |
---|
| 379 | #endif |
---|
[2] | 380 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 381 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[608] | 382 | #if H_3D_IV_MERGE |
---|
| 383 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
[56] | 384 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 385 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 386 | #else |
---|
[2] | 387 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 388 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
[608] | 389 | #endif |
---|
[56] | 390 | Int numValidMergeCand = 0; |
---|
[608] | 391 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
[2] | 392 | { |
---|
| 393 | uhInterDirNeighbours[ui] = 0; |
---|
| 394 | } |
---|
[608] | 395 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
| 396 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
[724] | 397 | #if H_3D_ARP |
---|
| 398 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
| 399 | #endif |
---|
[833] | 400 | #if H_3D_IC |
---|
| 401 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 402 | #endif |
---|
[724] | 403 | |
---|
[608] | 404 | #if H_3D_VSP |
---|
| 405 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 406 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
[773] | 407 | #if H_3D_SPIVMP |
---|
[724] | 408 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 409 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 410 | TComMvField* pcMvFieldSP; |
---|
| 411 | UChar* puhInterDirSP; |
---|
| 412 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
| 413 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
| 414 | #endif |
---|
| 415 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
| 416 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[950] | 417 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
[773] | 418 | #if H_3D_SPIVMP |
---|
[950] | 419 | , pcMvFieldSP, puhInterDirSP |
---|
| 420 | #endif |
---|
[724] | 421 | , numValidMergeCand, uiMergeIndex ); |
---|
[950] | 422 | |
---|
| 423 | m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
| 424 | #if H_3D_SPIVMP |
---|
| 425 | , bSPIVMPFlag |
---|
| 426 | #endif |
---|
| 427 | , numValidMergeCand ); |
---|
[608] | 428 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
[443] | 429 | #else |
---|
[773] | 430 | #if H_3D |
---|
[724] | 431 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
[608] | 432 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[724] | 433 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 434 | #else |
---|
| 435 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[443] | 436 | #endif |
---|
[724] | 437 | #endif |
---|
[56] | 438 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
[833] | 439 | |
---|
[56] | 440 | TComMv cTmpMv( 0, 0 ); |
---|
| 441 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
[1200] | 442 | { |
---|
[56] | 443 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 444 | { |
---|
| 445 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 446 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
| 447 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 448 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
[884] | 449 | #if H_3D_VSP |
---|
[833] | 450 | if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 ) |
---|
| 451 | { |
---|
| 452 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
| 453 | { |
---|
| 454 | UInt dummy; |
---|
| 455 | Int vspSize; |
---|
| 456 | Int width, height; |
---|
| 457 | m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height ); |
---|
| 458 | m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
| 459 | pcCU->setVSPFlag( uiAbsPartIdx, vspSize ); |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | #endif |
---|
[622] | 463 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
| 464 | if ( g_decTraceMvFromMerge ) |
---|
| 465 | { |
---|
| 466 | if ( uiRefListIdx == 0 ) |
---|
| 467 | { |
---|
| 468 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
| 469 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
| 470 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
| 471 | } |
---|
| 472 | else |
---|
| 473 | { |
---|
| 474 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
| 475 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
| 476 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
| 477 | } |
---|
| 478 | } |
---|
| 479 | #endif |
---|
[56] | 480 | } |
---|
| 481 | } |
---|
[773] | 482 | #if H_3D_SPIVMP |
---|
[724] | 483 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
| 484 | if (bSPIVMPFlag[uiMergeIndex]) |
---|
| 485 | { |
---|
| 486 | UInt uiSPAddr; |
---|
| 487 | Int iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
| 488 | Int iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
| 489 | |
---|
| 490 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 491 | |
---|
| 492 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 493 | |
---|
| 494 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
| 495 | { |
---|
| 496 | pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
| 497 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
| 498 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
| 499 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
| 500 | } |
---|
| 501 | } |
---|
[735] | 502 | delete[] pcMvFieldSP; |
---|
| 503 | delete[] puhInterDirSP; |
---|
[724] | 504 | #endif |
---|
| 505 | |
---|
[1200] | 506 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[773] | 507 | #if H_3D_IV_MERGE |
---|
[724] | 508 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 509 | #endif |
---|
[1200] | 510 | |
---|
[2] | 511 | return; |
---|
| 512 | } |
---|
[1196] | 513 | #if H_3D |
---|
[1179] | 514 | m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 515 | if(!pcCU->getDISFlag(uiAbsPartIdx)) |
---|
| 516 | { |
---|
[1039] | 517 | #endif |
---|
[1200] | 518 | |
---|
[608] | 519 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 520 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 521 | |
---|
[56] | 522 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
| 523 | { |
---|
| 524 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 525 | |
---|
[56] | 526 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
[2] | 527 | { |
---|
[1179] | 528 | #if H_3D_DIM_SDC |
---|
| 529 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 530 | #endif |
---|
[1200] | 531 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[773] | 532 | #if H_3D_IV_MERGE |
---|
[724] | 533 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 534 | #endif |
---|
[56] | 535 | return; |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
| 540 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
[1179] | 541 | |
---|
[2] | 542 | // Coefficient decoding |
---|
[56] | 543 | Bool bCodeDQP = getdQPFlag(); |
---|
[1200] | 544 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
---|
| 545 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
---|
| 546 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
---|
[56] | 547 | setdQPFlag( bCodeDQP ); |
---|
[1196] | 548 | #if H_3D |
---|
[1179] | 549 | } |
---|
[1039] | 550 | #endif |
---|
[1200] | 551 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
[773] | 552 | #if H_3D_IV_MERGE |
---|
[724] | 553 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 554 | #endif |
---|
[2] | 555 | } |
---|
| 556 | |
---|
[1200] | 557 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
[56] | 558 | { |
---|
[608] | 559 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
[56] | 560 | { |
---|
[608] | 561 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
[56] | 562 | } |
---|
| 563 | |
---|
[1200] | 564 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
---|
| 565 | { |
---|
| 566 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
---|
| 567 | } |
---|
| 568 | |
---|
| 569 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
---|
[56] | 570 | } |
---|
| 571 | |
---|
[1200] | 572 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 573 | { |
---|
[1200] | 574 | TComPic* pcPic = pCtu->getPic(); |
---|
[773] | 575 | #if !H_3D_IV_MERGE |
---|
[1200] | 576 | TComSlice * pcSlice = pCtu->getSlice(); |
---|
| 577 | const TComSPS &sps=*(pcSlice->getSPS()); |
---|
| 578 | |
---|
[2] | 579 | Bool bBoundary = false; |
---|
[1200] | 580 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 581 | UInt uiRPelX = uiLPelX + (sps.getMaxCUWidth()>>uiDepth) - 1; |
---|
| 582 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
| 583 | UInt uiBPelY = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1; |
---|
[1196] | 584 | |
---|
[1200] | 585 | if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) ) |
---|
[2] | 586 | { |
---|
| 587 | bBoundary = true; |
---|
| 588 | } |
---|
[1196] | 589 | |
---|
[1200] | 590 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
[2] | 591 | { |
---|
| 592 | UInt uiNextDepth = uiDepth + 1; |
---|
[1200] | 593 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
---|
[2] | 594 | UInt uiIdx = uiAbsPartIdx; |
---|
| 595 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
| 596 | { |
---|
[1200] | 597 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
| 598 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
[1196] | 599 | |
---|
[1200] | 600 | if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
[56] | 601 | { |
---|
[1200] | 602 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
---|
[56] | 603 | } |
---|
[1196] | 604 | |
---|
[2] | 605 | uiIdx += uiQNumParts; |
---|
| 606 | } |
---|
| 607 | return; |
---|
| 608 | } |
---|
[1200] | 609 | #endif |
---|
[2] | 610 | // Residual reconstruction |
---|
| 611 | m_ppcYuvResi[uiDepth]->clear(); |
---|
[1196] | 612 | |
---|
[1200] | 613 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx ); |
---|
[872] | 614 | |
---|
[2] | 615 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
| 616 | { |
---|
[1200] | 617 | case MODE_INTER: |
---|
[833] | 618 | #if H_3D_DBBP |
---|
[1196] | 619 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
---|
| 620 | { |
---|
| 621 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 622 | } |
---|
| 623 | else |
---|
| 624 | { |
---|
[833] | 625 | #endif |
---|
[655] | 626 | #if H_3D_INTER_SDC |
---|
[833] | 627 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
---|
[608] | 628 | { |
---|
| 629 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
| 630 | } |
---|
| 631 | else |
---|
| 632 | { |
---|
| 633 | #endif |
---|
[1200] | 634 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
[655] | 635 | #if H_3D_INTER_SDC |
---|
[608] | 636 | } |
---|
| 637 | #endif |
---|
[833] | 638 | #if H_3D_DBBP |
---|
[1196] | 639 | } |
---|
[833] | 640 | #endif |
---|
[1200] | 641 | break; |
---|
| 642 | case MODE_INTRA: |
---|
[1196] | 643 | #if H_3D |
---|
| 644 | if( m_ppcCU[uiDepth]->getDISFlag(0) ) |
---|
| 645 | { |
---|
| 646 | xReconDIS( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
| 647 | } |
---|
[1179] | 648 | #if H_3D_DIM_SDC |
---|
[1196] | 649 | else if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
| 650 | { |
---|
| 651 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
| 652 | } |
---|
[1179] | 653 | #endif |
---|
[1196] | 654 | else |
---|
[1039] | 655 | #endif |
---|
[608] | 656 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
[1200] | 657 | break; |
---|
| 658 | default: |
---|
| 659 | assert(0); |
---|
| 660 | break; |
---|
[2] | 661 | } |
---|
[1200] | 662 | |
---|
| 663 | #if DEBUG_STRING |
---|
| 664 | const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); |
---|
| 665 | if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) |
---|
| 666 | { |
---|
| 667 | PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
| 668 | std::ostream &ss(std::cout); |
---|
| 669 | |
---|
| 670 | ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl; |
---|
| 671 | } |
---|
| 672 | #endif |
---|
| 673 | |
---|
[56] | 674 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
| 675 | { |
---|
[608] | 676 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
[56] | 677 | } |
---|
[1196] | 678 | |
---|
[2] | 679 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
| 680 | } |
---|
| 681 | |
---|
[608] | 682 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
[2] | 683 | { |
---|
[1200] | 684 | |
---|
[2] | 685 | // inter prediction |
---|
| 686 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
[1200] | 687 | |
---|
| 688 | #if DEBUG_STRING |
---|
| 689 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); |
---|
| 690 | if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) |
---|
| 691 | { |
---|
| 692 | printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
| 693 | } |
---|
| 694 | #endif |
---|
| 695 | |
---|
[2] | 696 | // inter recon |
---|
[1200] | 697 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
| 698 | |
---|
| 699 | #if DEBUG_STRING |
---|
| 700 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) |
---|
| 701 | { |
---|
| 702 | printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
| 703 | } |
---|
| 704 | #endif |
---|
| 705 | |
---|
[2] | 706 | // clip for only non-zero cbp case |
---|
[1200] | 707 | if ( pcCU->getQtRootCbf( 0) ) |
---|
[2] | 708 | { |
---|
[1200] | 709 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
[2] | 710 | } |
---|
| 711 | else |
---|
| 712 | { |
---|
[608] | 713 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 714 | } |
---|
[1200] | 715 | #if DEBUG_STRING |
---|
| 716 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) |
---|
| 717 | { |
---|
| 718 | printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
| 719 | } |
---|
| 720 | #endif |
---|
| 721 | |
---|
[608] | 722 | } |
---|
[1179] | 723 | |
---|
[1196] | 724 | #if H_3D |
---|
[1179] | 725 | Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 726 | { |
---|
| 727 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
| 728 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
| 729 | |
---|
| 730 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
| 731 | |
---|
| 732 | UInt uiStride = pcRecoYuv->getStride (); |
---|
| 733 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 734 | |
---|
| 735 | |
---|
| 736 | AOF( uiWidth == uiHeight ); |
---|
| 737 | AOF( uiAbsPartIdx == 0 ); |
---|
| 738 | |
---|
| 739 | Bool bAboveAvail = false; |
---|
| 740 | Bool bLeftAvail = false; |
---|
| 741 | pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); |
---|
| 742 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, |
---|
| 743 | m_pcPrediction->getPredicBuf (), |
---|
| 744 | m_pcPrediction->getPredicBufWidth (), |
---|
| 745 | m_pcPrediction->getPredicBufHeight (), |
---|
| 746 | bAboveAvail, bLeftAvail |
---|
| 747 | ); |
---|
| 748 | |
---|
| 749 | if ( pcCU->getDISType(uiAbsPartIdx) == 0 ) |
---|
| 750 | { |
---|
| 751 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), VER_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
| 752 | } |
---|
| 753 | else if ( pcCU->getDISType(uiAbsPartIdx) == 1 ) |
---|
| 754 | { |
---|
| 755 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), HOR_IDX, piReco, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
| 756 | } |
---|
| 757 | else if ( pcCU->getDISType(uiAbsPartIdx) == 2 ) |
---|
| 758 | { |
---|
| 759 | Pel pSingleDepth = 1 << ( g_bitDepthY - 1 ); |
---|
| 760 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 ); |
---|
| 761 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 762 | { |
---|
| 763 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 764 | { |
---|
| 765 | piReco[ uiX ] = pSingleDepth; |
---|
| 766 | } |
---|
| 767 | piReco+= uiStride; |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | else if ( pcCU->getDISType(uiAbsPartIdx) == 3 ) |
---|
| 771 | { |
---|
| 772 | Pel pSingleDepth = 1 << ( g_bitDepthY - 1 ); |
---|
| 773 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 ); |
---|
| 774 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 775 | { |
---|
| 776 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 777 | { |
---|
| 778 | piReco[ uiX ] = pSingleDepth; |
---|
| 779 | } |
---|
| 780 | piReco+= uiStride; |
---|
| 781 | } |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | // clear UV |
---|
| 785 | UInt uiStrideC = pcRecoYuv->getCStride(); |
---|
| 786 | Pel *pRecCb = pcRecoYuv->getCbAddr(); |
---|
| 787 | Pel *pRecCr = pcRecoYuv->getCrAddr(); |
---|
| 788 | |
---|
| 789 | for (Int y=0; y<uiHeight/2; y++) |
---|
| 790 | { |
---|
| 791 | for (Int x=0; x<uiWidth/2; x++) |
---|
| 792 | { |
---|
| 793 | pRecCb[x] = 1<<(g_bitDepthC-1); |
---|
| 794 | pRecCr[x] = 1<<(g_bitDepthC-1); |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | pRecCb += uiStrideC; |
---|
| 798 | pRecCr += uiStrideC; |
---|
| 799 | } |
---|
| 800 | } |
---|
[1039] | 801 | #endif |
---|
[655] | 802 | #if H_3D_INTER_SDC |
---|
[608] | 803 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 804 | { |
---|
| 805 | // inter prediction |
---|
| 806 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
| 807 | |
---|
| 808 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
| 809 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
| 810 | |
---|
| 811 | Pel *pResi; |
---|
| 812 | UInt uiPelX, uiPelY; |
---|
| 813 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
| 814 | |
---|
| 815 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
| 816 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
| 817 | { |
---|
| 818 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
[2] | 819 | { |
---|
[833] | 820 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
[2] | 821 | } |
---|
[608] | 822 | pResi += uiResiStride; |
---|
[2] | 823 | } |
---|
[608] | 824 | |
---|
| 825 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 826 | |
---|
| 827 | // clear UV |
---|
| 828 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
| 829 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
| 830 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
| 831 | |
---|
| 832 | for (Int y = 0; y < uiHeight/2; y++) |
---|
| 833 | { |
---|
| 834 | for (Int x = 0; x < uiWidth/2; x++) |
---|
| 835 | { |
---|
| 836 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
| 837 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | pRecCb += uiStrideC; |
---|
| 841 | pRecCr += uiStrideC; |
---|
| 842 | } |
---|
[2] | 843 | } |
---|
[608] | 844 | #endif |
---|
[2] | 845 | |
---|
[833] | 846 | #if H_3D_DBBP |
---|
| 847 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 848 | { |
---|
| 849 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
| 850 | AOF(!pcCU->getSlice()->isIntra()); |
---|
| 851 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
| 852 | |
---|
| 853 | // get collocated depth block |
---|
| 854 | UInt uiDepthStride = 0; |
---|
[1084] | 855 | #if H_3D_FCO |
---|
[1066] | 856 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
| 857 | #else |
---|
[833] | 858 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
[1066] | 859 | #endif |
---|
[833] | 860 | AOF( pDepthPels != NULL ); |
---|
| 861 | AOF( uiDepthStride != 0 ); |
---|
| 862 | |
---|
| 863 | // compute mask by segmenting depth block |
---|
| 864 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
[1179] | 865 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
---|
[833] | 866 | AOF(bValidMask); |
---|
| 867 | |
---|
[1196] | 868 | DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
[833] | 869 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
| 870 | |
---|
| 871 | // first, extract the two sets of motion parameters |
---|
| 872 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 873 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
| 874 | { |
---|
| 875 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
| 876 | |
---|
| 877 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
| 878 | |
---|
| 879 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 880 | { |
---|
| 881 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
| 882 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
| 883 | } |
---|
| 884 | |
---|
[950] | 885 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
---|
| 886 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
---|
| 887 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
---|
| 888 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
---|
[833] | 889 | } |
---|
| 890 | |
---|
| 891 | // do motion compensation for each segment as 2Nx2N |
---|
| 892 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 893 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
| 894 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
| 895 | { |
---|
| 896 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
[976] | 897 | |
---|
[833] | 898 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 899 | { |
---|
| 900 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
| 901 | |
---|
| 902 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
| 903 | } |
---|
| 904 | |
---|
| 905 | // inter prediction |
---|
| 906 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | // restore motion information in both segments again |
---|
| 910 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
| 911 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
| 912 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
| 913 | { |
---|
| 914 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
| 915 | |
---|
| 916 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
| 917 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
| 918 | |
---|
| 919 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 920 | { |
---|
| 921 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
| 922 | |
---|
| 923 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
| 924 | } |
---|
| 925 | } |
---|
| 926 | |
---|
| 927 | // reconstruct final prediction signal by combining both segments |
---|
[1039] | 928 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize); |
---|
[1084] | 929 | |
---|
[833] | 930 | // inter recon |
---|
| 931 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
| 932 | |
---|
| 933 | // clip for only non-zero cbp case |
---|
| 934 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
| 935 | { |
---|
| 936 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
| 937 | } |
---|
| 938 | else |
---|
| 939 | { |
---|
| 940 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
| 941 | } |
---|
| 942 | } |
---|
| 943 | #endif |
---|
| 944 | |
---|
[1200] | 945 | |
---|
[2] | 946 | Void |
---|
[1200] | 947 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
| 948 | TComYuv* pcPredYuv, |
---|
| 949 | TComYuv* pcResiYuv, |
---|
| 950 | const ComponentID compID, |
---|
| 951 | TComTU &rTu) |
---|
[2] | 952 | { |
---|
[1200] | 953 | if (!rTu.ProcessComponentSection(compID)) |
---|
| 954 | { |
---|
| 955 | return; |
---|
| 956 | } |
---|
| 957 | const Bool bIsLuma = isLuma(compID); |
---|
| 958 | |
---|
| 959 | |
---|
| 960 | TComDataCU *pcCU = rTu.getCU(); |
---|
| 961 | const TComSPS &sps=*(pcCU->getSlice()->getSPS()); |
---|
| 962 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
| 963 | |
---|
| 964 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
| 965 | const UInt uiWidth = tuRect.width; |
---|
| 966 | const UInt uiHeight = tuRect.height; |
---|
| 967 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
| 968 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 969 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
| 970 | |
---|
| 971 | if (uiWidth != uiHeight) |
---|
| 972 | { |
---|
| 973 | //------------------------------------------------ |
---|
| 974 | |
---|
| 975 | //split at current level if dividing into square sub-TUs |
---|
| 976 | |
---|
| 977 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
| 978 | |
---|
| 979 | //recurse further |
---|
| 980 | do |
---|
| 981 | { |
---|
| 982 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
| 983 | } while (subTURecurse.nextSection(rTu)); |
---|
| 984 | |
---|
| 985 | //------------------------------------------------ |
---|
| 986 | |
---|
| 987 | return; |
---|
| 988 | } |
---|
| 989 | |
---|
| 990 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
| 991 | const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); |
---|
| 992 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode; |
---|
| 993 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
| 994 | |
---|
[2] | 995 | //===== init availability pattern ===== |
---|
| 996 | Bool bAboveAvail = false; |
---|
| 997 | Bool bLeftAvail = false; |
---|
[1200] | 998 | |
---|
| 999 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
| 1000 | |
---|
| 1001 | #if DEBUG_STRING |
---|
| 1002 | std::ostream &ss(std::cout); |
---|
| 1003 | #endif |
---|
| 1004 | |
---|
| 1005 | DEBUG_STRING_NEW(sTemp) |
---|
| 1006 | m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
| 1007 | |
---|
| 1008 | |
---|
[56] | 1009 | //===== get prediction signal ===== |
---|
[608] | 1010 | #if H_3D_DIM |
---|
| 1011 | if( isDimMode( uiLumaPredMode ) ) |
---|
[2] | 1012 | { |
---|
[608] | 1013 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
| 1014 | } |
---|
[2] | 1015 | else |
---|
[56] | 1016 | { |
---|
[2] | 1017 | #endif |
---|
[1200] | 1018 | |
---|
| 1019 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions ); |
---|
[608] | 1020 | #if H_3D_DIM |
---|
[2] | 1021 | } |
---|
[56] | 1022 | #endif |
---|
[1200] | 1023 | |
---|
| 1024 | #if DEBUG_STRING |
---|
| 1025 | ss << sTemp; |
---|
| 1026 | #endif |
---|
| 1027 | |
---|
| 1028 | //===== inverse transform ===== |
---|
| 1029 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 1030 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
| 1031 | |
---|
| 1032 | const QpParam cQP(*pcCU, compID); |
---|
| 1033 | |
---|
| 1034 | |
---|
| 1035 | DEBUG_STRING_NEW(sDebug); |
---|
| 1036 | #if DEBUG_STRING |
---|
| 1037 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
| 1038 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
| 1039 | #endif |
---|
[884] | 1040 | #if H_3D |
---|
[872] | 1041 | Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
| 1042 | |
---|
| 1043 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
| 1044 | #else |
---|
[1200] | 1045 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
[872] | 1046 | #endif |
---|
| 1047 | { |
---|
[1200] | 1048 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
[2] | 1049 | } |
---|
[872] | 1050 | else |
---|
| 1051 | { |
---|
[1200] | 1052 | for (UInt y = 0; y < uiHeight; y++) |
---|
[872] | 1053 | { |
---|
[1200] | 1054 | for (UInt x = 0; x < uiWidth; x++) |
---|
[872] | 1055 | { |
---|
[1200] | 1056 | piResi[(y * uiStride) + x] = 0; |
---|
[872] | 1057 | } |
---|
| 1058 | } |
---|
| 1059 | } |
---|
[2] | 1060 | |
---|
[1200] | 1061 | #if DEBUG_STRING |
---|
| 1062 | if (psDebug) |
---|
[2] | 1063 | { |
---|
[1200] | 1064 | ss << (*psDebug); |
---|
[2] | 1065 | } |
---|
[1200] | 1066 | #endif |
---|
[1124] | 1067 | |
---|
[1200] | 1068 | //===== reconstruction ===== |
---|
| 1069 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
[1124] | 1070 | |
---|
[1200] | 1071 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
| 1072 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
| 1073 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
[1124] | 1074 | |
---|
[1200] | 1075 | Pel* pPred = piPred; |
---|
| 1076 | Pel* pResi = piResi; |
---|
| 1077 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
| 1078 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
[1124] | 1079 | |
---|
[56] | 1080 | |
---|
[1200] | 1081 | #if DEBUG_STRING |
---|
| 1082 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 1083 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 1084 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
| 1085 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
| 1086 | { |
---|
| 1087 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
| 1088 | } |
---|
| 1089 | #endif |
---|
[1124] | 1090 | |
---|
[1200] | 1091 | const Int clipbd = sps.getBitDepth(toChannelType(compID)); |
---|
| 1092 | #if O0043_BEST_EFFORT_DECODING |
---|
| 1093 | const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd; |
---|
| 1094 | #endif |
---|
| 1095 | |
---|
| 1096 | if( useCrossComponentPrediction ) |
---|
[2] | 1097 | { |
---|
[1200] | 1098 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
[2] | 1099 | } |
---|
| 1100 | |
---|
[1200] | 1101 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
[872] | 1102 | { |
---|
[1200] | 1103 | #if DEBUG_STRING |
---|
| 1104 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
[1124] | 1105 | { |
---|
[1200] | 1106 | ss << "###: "; |
---|
[1124] | 1107 | } |
---|
[1200] | 1108 | |
---|
| 1109 | if (bDebugPred) |
---|
[1124] | 1110 | { |
---|
[1200] | 1111 | ss << " - pred: "; |
---|
| 1112 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 1113 | { |
---|
| 1114 | ss << pPred[ uiX ] << ", "; |
---|
| 1115 | } |
---|
[1124] | 1116 | } |
---|
[1200] | 1117 | if (bDebugResi) |
---|
| 1118 | { |
---|
| 1119 | ss << " - resi: "; |
---|
| 1120 | } |
---|
| 1121 | #endif |
---|
[2] | 1122 | |
---|
[1200] | 1123 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[2] | 1124 | { |
---|
[1200] | 1125 | #if DEBUG_STRING |
---|
| 1126 | if (bDebugResi) |
---|
[1124] | 1127 | { |
---|
[1200] | 1128 | ss << pResi[ uiX ] << ", "; |
---|
[1124] | 1129 | } |
---|
[1200] | 1130 | #endif |
---|
| 1131 | #if O0043_BEST_EFFORT_DECODING |
---|
| 1132 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
| 1133 | #else |
---|
| 1134 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
| 1135 | #endif |
---|
| 1136 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
[2] | 1137 | } |
---|
[1200] | 1138 | #if DEBUG_STRING |
---|
| 1139 | if (bDebugReco) |
---|
[872] | 1140 | { |
---|
[1200] | 1141 | ss << " - reco: "; |
---|
| 1142 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[872] | 1143 | { |
---|
[1200] | 1144 | ss << pReco[ uiX ] << ", "; |
---|
[872] | 1145 | } |
---|
[1200] | 1146 | } |
---|
| 1147 | |
---|
| 1148 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
| 1149 | { |
---|
| 1150 | ss << "\n"; |
---|
| 1151 | } |
---|
| 1152 | #endif |
---|
| 1153 | pPred += uiStride; |
---|
| 1154 | pResi += uiStride; |
---|
| 1155 | pReco += uiStride; |
---|
| 1156 | pRecIPred += uiRecIPredStride; |
---|
[872] | 1157 | } |
---|
| 1158 | } |
---|
[1200] | 1159 | #if H_3D_DIM |
---|
| 1160 | mapDepthModeToIntraDir( uiChromaPredMode ); |
---|
| 1161 | #endif |
---|
[2] | 1162 | |
---|
| 1163 | |
---|
| 1164 | Void |
---|
[608] | 1165 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
[2] | 1166 | { |
---|
[56] | 1167 | if (pcCU->getIPCMFlag(0)) |
---|
| 1168 | { |
---|
[608] | 1169 | xReconPCM( pcCU, uiDepth ); |
---|
[56] | 1170 | return; |
---|
| 1171 | } |
---|
[1200] | 1172 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
| 1173 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
[2] | 1174 | { |
---|
[1200] | 1175 | const ChannelType chanType=ChannelType(chType); |
---|
| 1176 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
| 1177 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
[2] | 1178 | |
---|
[1200] | 1179 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
| 1180 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
| 1181 | |
---|
| 1182 | do |
---|
| 1183 | { |
---|
| 1184 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
| 1185 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
[2] | 1186 | } |
---|
| 1187 | } |
---|
| 1188 | |
---|
[608] | 1189 | #if H_3D_DIM_SDC |
---|
[189] | 1190 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1191 | { |
---|
| 1192 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
| 1193 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
[833] | 1194 | TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight ); |
---|
| 1195 | UInt numParts = 1; |
---|
| 1196 | UInt sdcDepth = 0; |
---|
| 1197 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
| 1198 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
| 1199 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
| 1200 | |
---|
| 1201 | UInt uiStride = 0; |
---|
| 1202 | Pel* piReco; |
---|
| 1203 | Pel* piPred; |
---|
| 1204 | Pel* piResi; |
---|
| 1205 | |
---|
| 1206 | UInt uiZOrder; |
---|
| 1207 | Pel* piRecIPred; |
---|
| 1208 | UInt uiRecIPredStride; |
---|
| 1209 | |
---|
| 1210 | UInt uiLumaPredMode = 0; |
---|
| 1211 | |
---|
| 1212 | if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) |
---|
| 1213 | { |
---|
| 1214 | numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
| 1215 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
| 1216 | uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
| 1217 | } |
---|
| 1218 | |
---|
[884] | 1219 | for ( Int i = 0; i < numParts; i++ ) |
---|
[833] | 1220 | { |
---|
| 1221 | uiStride = pcRecoYuv->getStride (); |
---|
| 1222 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 1223 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 1224 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
[884] | 1225 | |
---|
[833] | 1226 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 1227 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
| 1228 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
| 1229 | |
---|
| 1230 | uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
| 1231 | |
---|
| 1232 | AOF( uiWidth == uiHeight ); |
---|
[884] | 1233 | |
---|
| 1234 | //===== init availability pattern ===== |
---|
| 1235 | Bool bAboveAvail = false; |
---|
| 1236 | Bool bLeftAvail = false; |
---|
| 1237 | |
---|
| 1238 | pcCU->getPattern()->initPattern ( pcCU, sdcDepth, uiAbsPartIdx ); |
---|
| 1239 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
| 1240 | |
---|
| 1241 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
| 1242 | //===== get prediction signal ===== |
---|
| 1243 | if( isDimMode( uiLumaPredMode ) ) |
---|
| 1244 | { |
---|
| 1245 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation ); |
---|
| 1246 | Bool* dmm4PatternSplit = dmm4Segmentation->getPattern(); |
---|
| 1247 | Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern(); |
---|
| 1248 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
| 1249 | { |
---|
| 1250 | dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k]; |
---|
| 1251 | } |
---|
[833] | 1252 | } |
---|
[884] | 1253 | else |
---|
| 1254 | { |
---|
| 1255 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
| 1256 | } |
---|
| 1257 | |
---|
[833] | 1258 | if ( numParts > 1 ) |
---|
| 1259 | { |
---|
| 1260 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 1261 | { |
---|
| 1262 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 1263 | { |
---|
| 1264 | piReco [ uiX ] = ClipY( piPred[ uiX ] ); |
---|
| 1265 | piRecIPred [ uiX ] = piReco[ uiX ]; |
---|
| 1266 | } |
---|
| 1267 | piPred += uiStride; |
---|
| 1268 | piReco += uiStride; |
---|
| 1269 | piRecIPred += uiRecIPredStride; |
---|
| 1270 | } |
---|
| 1271 | } |
---|
| 1272 | uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 ); |
---|
| 1273 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
---|
| 1274 | } |
---|
| 1275 | uiAbsPartIdx = 0; |
---|
[189] | 1276 | |
---|
[833] | 1277 | if ( numParts > 1 ) |
---|
| 1278 | { |
---|
| 1279 | uiWidth = pcCU->getWidth( 0 ); |
---|
| 1280 | uiHeight = pcCU->getHeight( 0 ); |
---|
| 1281 | } |
---|
| 1282 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 1283 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 1284 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
| 1285 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 1286 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
| 1287 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
[189] | 1288 | // number of segments depends on prediction mode |
---|
[608] | 1289 | UInt uiNumSegments = 1; |
---|
[189] | 1290 | Bool* pbMask = NULL; |
---|
| 1291 | UInt uiMaskStride = 0; |
---|
| 1292 | |
---|
[608] | 1293 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
---|
[189] | 1294 | { |
---|
[608] | 1295 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
---|
[1039] | 1296 | |
---|
| 1297 | WedgeList* pacWedgeList = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
[189] | 1298 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
[1039] | 1299 | |
---|
[189] | 1300 | uiNumSegments = 2; |
---|
[1039] | 1301 | |
---|
| 1302 | pbMask = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern(); |
---|
| 1303 | uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride(); |
---|
[189] | 1304 | } |
---|
[833] | 1305 | if( getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
| 1306 | { |
---|
| 1307 | uiNumSegments = 2; |
---|
| 1308 | pbMask = dmm4SegmentationOrg->getPattern(); |
---|
| 1309 | uiMaskStride = dmm4SegmentationOrg->getStride(); |
---|
| 1310 | } |
---|
[189] | 1311 | // get DC prediction for each segment |
---|
| 1312 | Pel apDCPredValues[2]; |
---|
[950] | 1313 | if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
| 1314 | { |
---|
| 1315 | apDCPredValues[0] = pcCU->getDmmPredictor( 0 ); |
---|
| 1316 | apDCPredValues[1] = pcCU->getDmmPredictor( 1 ); |
---|
| 1317 | } |
---|
| 1318 | else |
---|
[976] | 1319 | { |
---|
| 1320 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
---|
| 1321 | } |
---|
[189] | 1322 | |
---|
| 1323 | // reconstruct residual based on mask + DC residuals |
---|
| 1324 | Pel apDCResiValues[2]; |
---|
[608] | 1325 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
[189] | 1326 | { |
---|
[608] | 1327 | #if H_3D_DIM_DLT |
---|
[758] | 1328 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
| 1329 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
| 1330 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
| 1331 | |
---|
[608] | 1332 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
| 1333 | #else |
---|
| 1334 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
[443] | 1335 | #endif |
---|
[189] | 1336 | } |
---|
| 1337 | |
---|
| 1338 | //===== reconstruction ===== |
---|
| 1339 | Bool*pMask = pbMask; |
---|
| 1340 | Pel* pPred = piPred; |
---|
| 1341 | Pel* pResi = piResi; |
---|
| 1342 | Pel* pReco = piReco; |
---|
| 1343 | Pel* pRecIPred = piRecIPred; |
---|
| 1344 | |
---|
| 1345 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
| 1346 | { |
---|
| 1347 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
| 1348 | { |
---|
| 1349 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
| 1350 | assert( ucSegment < uiNumSegments ); |
---|
| 1351 | |
---|
| 1352 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
| 1353 | |
---|
[608] | 1354 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
---|
[189] | 1355 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
| 1356 | } |
---|
| 1357 | pPred += uiStride; |
---|
| 1358 | pResi += uiStride; |
---|
| 1359 | pReco += uiStride; |
---|
| 1360 | pRecIPred += uiRecIPredStride; |
---|
| 1361 | pMask += uiMaskStride; |
---|
| 1362 | } |
---|
| 1363 | |
---|
| 1364 | // clear UV |
---|
| 1365 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
| 1366 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
| 1367 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
| 1368 | |
---|
| 1369 | for (Int y=0; y<uiHeight/2; y++) |
---|
| 1370 | { |
---|
| 1371 | for (Int x=0; x<uiWidth/2; x++) |
---|
| 1372 | { |
---|
[608] | 1373 | pRecCb[x] = 128; |
---|
| 1374 | pRecCr[x] = 128; |
---|
[189] | 1375 | } |
---|
| 1376 | |
---|
| 1377 | pRecCb += uiStrideC; |
---|
| 1378 | pRecCr += uiStrideC; |
---|
| 1379 | } |
---|
[833] | 1380 | dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg; |
---|
[189] | 1381 | } |
---|
| 1382 | #endif |
---|
| 1383 | |
---|
[1200] | 1384 | |
---|
| 1385 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
---|
[2] | 1386 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
| 1387 | * \param pcPredYuv pointer to prediction sample arrays |
---|
| 1388 | * \param pcResiYuv pointer to residue sample arrays |
---|
[1200] | 1389 | * \param chType texture channel type (luma/chroma) |
---|
| 1390 | * \param rTu reference to transform data |
---|
| 1391 | * |
---|
| 1392 | \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure |
---|
[2] | 1393 | */ |
---|
[1200] | 1394 | |
---|
[2] | 1395 | Void |
---|
[1200] | 1396 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
| 1397 | TComYuv* pcPredYuv, |
---|
| 1398 | TComYuv* pcResiYuv, |
---|
| 1399 | const ChannelType chType, |
---|
| 1400 | TComTU &rTu) |
---|
[2] | 1401 | { |
---|
[1200] | 1402 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
| 1403 | TComDataCU *pcCU = rTu.getCU(); |
---|
| 1404 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
[2] | 1405 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
| 1406 | if( uiTrMode == uiTrDepth ) |
---|
| 1407 | { |
---|
[1200] | 1408 | if (isLuma(chType)) |
---|
[2] | 1409 | { |
---|
[1200] | 1410 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
[2] | 1411 | } |
---|
[1200] | 1412 | else |
---|
| 1413 | { |
---|
| 1414 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
| 1415 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
| 1416 | { |
---|
| 1417 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
| 1418 | } |
---|
| 1419 | } |
---|
[2] | 1420 | } |
---|
| 1421 | else |
---|
| 1422 | { |
---|
[1200] | 1423 | TComTURecurse tuRecurseChild(rTu, false); |
---|
| 1424 | do |
---|
[2] | 1425 | { |
---|
[1200] | 1426 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
| 1427 | } while (tuRecurseChild.nextSection(rTu)); |
---|
[2] | 1428 | } |
---|
| 1429 | } |
---|
| 1430 | |
---|
| 1431 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
| 1432 | { |
---|
[1200] | 1433 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
| 1434 | |
---|
| 1435 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
| 1436 | |
---|
[2] | 1437 | return; |
---|
| 1438 | } |
---|
| 1439 | |
---|
[1200] | 1440 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
[2] | 1441 | { |
---|
[56] | 1442 | |
---|
[1200] | 1443 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
[56] | 1444 | |
---|
[1200] | 1445 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
| 1446 | { |
---|
| 1447 | const ComponentID compID=ComponentID(ch); |
---|
| 1448 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
[56] | 1449 | |
---|
[1200] | 1450 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
| 1451 | } |
---|
[56] | 1452 | |
---|
[1200] | 1453 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
[2] | 1454 | } |
---|
| 1455 | |
---|
[56] | 1456 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
| 1457 | * \param pcCU pointer to current CU |
---|
| 1458 | * \param uiPartIdx part index |
---|
| 1459 | * \param piPCM pointer to PCM code arrays |
---|
| 1460 | * \param piReco pointer to reconstructed sample arrays |
---|
| 1461 | * \param uiStride stride of reconstructed sample arrays |
---|
| 1462 | * \param uiWidth CU width |
---|
| 1463 | * \param uiHeight CU height |
---|
[1200] | 1464 | * \param compID colour component ID |
---|
[56] | 1465 | * \returns Void |
---|
| 1466 | */ |
---|
[1200] | 1467 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) |
---|
[56] | 1468 | { |
---|
[1200] | 1469 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
| 1470 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
| 1471 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
| 1472 | const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID)); |
---|
[56] | 1473 | |
---|
[1200] | 1474 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
[56] | 1475 | { |
---|
[1200] | 1476 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
[56] | 1477 | { |
---|
| 1478 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
| 1479 | piPicReco[uiX] = piReco[uiX]; |
---|
| 1480 | } |
---|
| 1481 | piPCM += uiWidth; |
---|
| 1482 | piReco += uiStride; |
---|
| 1483 | piPicReco += uiPicStride; |
---|
| 1484 | } |
---|
| 1485 | } |
---|
| 1486 | |
---|
| 1487 | /** Function for reconstructing a PCM mode CU. |
---|
| 1488 | * \param pcCU pointer to current CU |
---|
| 1489 | * \param uiDepth CU Depth |
---|
| 1490 | * \returns Void |
---|
| 1491 | */ |
---|
[608] | 1492 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
[56] | 1493 | { |
---|
[1200] | 1494 | const UInt maxCuWidth = pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
| 1495 | const UInt maxCuHeight = pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
| 1496 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
| 1497 | { |
---|
| 1498 | const ComponentID compID = ComponentID(ch); |
---|
| 1499 | const UInt width = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
| 1500 | const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
| 1501 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
| 1502 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
| 1503 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
| 1504 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
| 1505 | } |
---|
[56] | 1506 | } |
---|
| 1507 | |
---|
[1200] | 1508 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
| 1509 | * \param pCU pointer to current CU |
---|
| 1510 | * \param depth CU Depth |
---|
[56] | 1511 | */ |
---|
[608] | 1512 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
[56] | 1513 | { |
---|
[1200] | 1514 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
| 1515 | const UInt numValidComp = getNumberValidComponents(format); |
---|
| 1516 | const UInt maxCuWidth = pCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
| 1517 | const UInt maxCuHeight = pCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
[56] | 1518 | |
---|
[1200] | 1519 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
[56] | 1520 | { |
---|
[1200] | 1521 | const ComponentID component = ComponentID(componentIndex); |
---|
[56] | 1522 | |
---|
[1200] | 1523 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
---|
| 1524 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
---|
[56] | 1525 | |
---|
[1200] | 1526 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
| 1527 | Pel *destination = pCU->getPCMSample(component); |
---|
[56] | 1528 | |
---|
[1200] | 1529 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
[56] | 1530 | |
---|
[1200] | 1531 | for (Int line = 0; line < height; line++) |
---|
[56] | 1532 | { |
---|
[1200] | 1533 | for (Int column = 0; column < width; column++) |
---|
| 1534 | { |
---|
| 1535 | destination[column] = source[column]; |
---|
| 1536 | } |
---|
| 1537 | |
---|
| 1538 | source += sourceStride; |
---|
| 1539 | destination += width; |
---|
[56] | 1540 | } |
---|
| 1541 | } |
---|
| 1542 | } |
---|
| 1543 | |
---|
| 1544 | //! \} |
---|