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