| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2017, ITU/ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /** \file TDecCu.cpp |
|---|
| 35 | \brief CU decoder class |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | #include "TDecCu.h" |
|---|
| 39 | #include "TLibCommon/TComTU.h" |
|---|
| 40 | #include "TLibCommon/TComPrediction.h" |
|---|
| 41 | |
|---|
| 42 | //! \ingroup TLibDecoder |
|---|
| 43 | //! \{ |
|---|
| 44 | |
|---|
| 45 | // ==================================================================================================================== |
|---|
| 46 | // Constructor / destructor / create / destroy |
|---|
| 47 | // ==================================================================================================================== |
|---|
| 48 | |
|---|
| 49 | TDecCu::TDecCu() |
|---|
| 50 | { |
|---|
| 51 | m_ppcYuvResi = NULL; |
|---|
| 52 | m_ppcYuvReco = NULL; |
|---|
| 53 | m_ppcCU = NULL; |
|---|
| 54 | #if NH_3D |
|---|
| 55 | m_ppcYuvRecoDBBP = NULL; |
|---|
| 56 | #endif |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | TDecCu::~TDecCu() |
|---|
| 60 | { |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | #if MCTS_ENC_CHECK |
|---|
| 64 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, TDecConformanceCheck* pConformanceCheck) |
|---|
| 65 | #else |
|---|
| 66 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
|---|
| 67 | #endif |
|---|
| 68 | { |
|---|
| 69 | m_pcEntropyDecoder = pcEntropyDecoder; |
|---|
| 70 | m_pcTrQuant = pcTrQuant; |
|---|
| 71 | m_pcPrediction = pcPrediction; |
|---|
| 72 | #if MCTS_ENC_CHECK |
|---|
| 73 | m_pConformanceCheck = pConformanceCheck; |
|---|
| 74 | #endif |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | /** |
|---|
| 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 |
|---|
| 82 | */ |
|---|
| 83 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
|---|
| 84 | { |
|---|
| 85 | m_uiMaxDepth = uiMaxDepth+1; |
|---|
| 86 | |
|---|
| 87 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 88 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 89 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
|---|
| 90 | #if NH_3D |
|---|
| 91 | m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1]; |
|---|
| 92 | #endif |
|---|
| 93 | |
|---|
| 94 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
|---|
| 95 | { |
|---|
| 96 | UInt uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
|---|
| 97 | UInt uiWidth = uiMaxWidth >> ui; |
|---|
| 98 | UInt uiHeight = uiMaxHeight >> ui; |
|---|
| 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) ); |
|---|
| 111 | #if NH_3D |
|---|
| 112 | m_ppcYuvRecoDBBP[ui] = new TComYuv; m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
|---|
| 113 | #endif |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | m_bDecodeDQP = false; |
|---|
| 117 | m_IsChromaQpAdjCoded = false; |
|---|
| 118 | |
|---|
| 119 | // initialize partition order. |
|---|
| 120 | UInt* piTmp = &g_auiZscanToRaster[0]; |
|---|
| 121 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
|---|
| 122 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
|---|
| 123 | |
|---|
| 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 | { |
|---|
| 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; |
|---|
| 135 | #if NH_3D |
|---|
| 136 | m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL; |
|---|
| 137 | #endif |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
|---|
| 141 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
|---|
| 142 | delete [] m_ppcCU ; m_ppcCU = NULL; |
|---|
| 143 | #if NH_3D |
|---|
| 144 | delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL; |
|---|
| 145 | #endif |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | // ==================================================================================================================== |
|---|
| 149 | // Public member functions |
|---|
| 150 | // ==================================================================================================================== |
|---|
| 151 | |
|---|
| 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 |
|---|
| 156 | */ |
|---|
| 157 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
|---|
| 158 | { |
|---|
| 159 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
|---|
| 160 | { |
|---|
| 161 | setdQPFlag(true); |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
|---|
| 165 | { |
|---|
| 166 | setIsChromaQpAdjCoded(true); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | // start from the top level CU |
|---|
| 170 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | /** |
|---|
| 174 | Decoding process for a CTU. |
|---|
| 175 | \param pCtu [in/out] pointer to CTU data structure |
|---|
| 176 | */ |
|---|
| 177 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
|---|
| 178 | { |
|---|
| 179 | #if !NH_3D |
|---|
| 180 | xDecompressCU( pCtu, 0, 0 ); |
|---|
| 181 | #endif |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | // ==================================================================================================================== |
|---|
| 185 | // Protected member functions |
|---|
| 186 | // ==================================================================================================================== |
|---|
| 187 | |
|---|
| 188 | //! decode end-of-slice flag |
|---|
| 189 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
|---|
| 190 | { |
|---|
| 191 | UInt uiIsLastCtuOfSliceSegment; |
|---|
| 192 | |
|---|
| 193 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
|---|
| 194 | { |
|---|
| 195 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
|---|
| 196 | } |
|---|
| 197 | else |
|---|
| 198 | { |
|---|
| 199 | uiIsLastCtuOfSliceSegment=0; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | return uiIsLastCtuOfSliceSegment>0; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | //! decode CU block recursively |
|---|
| 206 | Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
|---|
| 207 | { |
|---|
| 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); |
|---|
| 214 | UInt uiQNumParts = uiCurNumParts>>2; |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | Bool bBoundary = false; |
|---|
| 218 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 219 | UInt uiRPelX = uiLPelX + (maxCuWidth>>uiDepth) - 1; |
|---|
| 220 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
|---|
| 221 | UInt uiBPelY = uiTPelY + (maxCuHeight>>uiDepth) - 1; |
|---|
| 222 | #if NH_MV_ENC_DEC_TRAC |
|---|
| 223 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
|---|
| 224 | DTRACE_CU("x0", uiLPelX) |
|---|
| 225 | DTRACE_CU("x1", uiTPelY) |
|---|
| 226 | DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth) |
|---|
| 227 | DTRACE_CU("cqtDepth" , uiDepth) |
|---|
| 228 | #endif |
|---|
| 229 | |
|---|
| 230 | if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) |
|---|
| 231 | { |
|---|
| 232 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 233 | } |
|---|
| 234 | else |
|---|
| 235 | { |
|---|
| 236 | bBoundary = true; |
|---|
| 237 | } |
|---|
| 238 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
|---|
| 239 | { |
|---|
| 240 | UInt uiIdx = uiAbsPartIdx; |
|---|
| 241 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
|---|
| 242 | { |
|---|
| 243 | setdQPFlag(true); |
|---|
| 244 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 248 | { |
|---|
| 249 | setIsChromaQpAdjCoded(true); |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 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] ]; |
|---|
| 256 | |
|---|
| 257 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
|---|
| 258 | { |
|---|
| 259 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
|---|
| 260 | } |
|---|
| 261 | else |
|---|
| 262 | { |
|---|
| 263 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | uiIdx += uiQNumParts; |
|---|
| 267 | } |
|---|
| 268 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
|---|
| 269 | { |
|---|
| 270 | if ( getdQPFlag() ) |
|---|
| 271 | { |
|---|
| 272 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
|---|
| 273 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | return; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | #if NH_MV_ENC_DEC_TRAC |
|---|
| 280 | DTRACE_CU_S("=========== coding_unit ===========\n") |
|---|
| 281 | #if NH_MV_ENC_DEC_TRAC |
|---|
| 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); |
|---|
| 289 | #endif |
|---|
| 290 | #endif |
|---|
| 291 | |
|---|
| 292 | #endif |
|---|
| 293 | |
|---|
| 294 | if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
|---|
| 295 | { |
|---|
| 296 | setdQPFlag(true); |
|---|
| 297 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
|---|
| 298 | } |
|---|
| 299 | #if NH_3D |
|---|
| 300 | DisInfo DvInfo; |
|---|
| 301 | DvInfo.m_acNBDV.setZero(); |
|---|
| 302 | DvInfo.m_aVIdxCan = 0; |
|---|
| 303 | DvInfo.m_acDoNBDV.setZero(); |
|---|
| 304 | |
|---|
| 305 | if(!pcCU->getSlice()->isIntra()) |
|---|
| 306 | { |
|---|
| 307 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() ) |
|---|
| 308 | { |
|---|
| 309 | m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true); |
|---|
| 310 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
|---|
| 311 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
|---|
| 312 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
|---|
| 313 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
|---|
| 314 | m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth)); |
|---|
| 315 | m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth)); |
|---|
| 316 | m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth); |
|---|
| 317 | if( pcCU->getSlice()->getIsDepth()) |
|---|
| 318 | { |
|---|
| 319 | m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
|---|
| 320 | } |
|---|
| 321 | else |
|---|
| 322 | { |
|---|
| 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 | } |
|---|
| 331 | } |
|---|
| 332 | #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC |
|---|
| 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 |
|---|
| 342 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
|---|
| 343 | m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth); |
|---|
| 344 | m_ppcCU[uiDepth]->setWidth(0, cWidTemp); |
|---|
| 345 | m_ppcCU[uiDepth]->setHeight(0, cHeightTemp); |
|---|
| 346 | } |
|---|
| 347 | } |
|---|
| 348 | #endif |
|---|
| 349 | |
|---|
| 350 | if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
|---|
| 351 | { |
|---|
| 352 | setIsChromaQpAdjCoded(true); |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | if (pps.getTransquantBypassEnabledFlag()) |
|---|
| 356 | { |
|---|
| 357 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | // decode CU mode and the partition size |
|---|
| 361 | if( !pcCU->getSlice()->isIntra()) |
|---|
| 362 | { |
|---|
| 363 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
|---|
| 368 | { |
|---|
| 369 | #if NH_MV_ENC_DEC_TRAC |
|---|
| 370 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
|---|
| 371 | DTRACE_PU("x0", uiLPelX) |
|---|
| 372 | DTRACE_PU("x1", uiTPelY) |
|---|
| 373 | #endif |
|---|
| 374 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
|---|
| 375 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
|---|
| 376 | #if NH_3D |
|---|
| 377 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
|---|
| 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 |
|---|
| 381 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
|---|
| 382 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
|---|
| 383 | #endif |
|---|
| 384 | Int numValidMergeCand = 0; |
|---|
| 385 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
|---|
| 386 | { |
|---|
| 387 | uhInterDirNeighbours[ui] = 0; |
|---|
| 388 | } |
|---|
| 389 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
|---|
| 390 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
|---|
| 391 | #if NH_3D |
|---|
| 392 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
|---|
| 393 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 394 | |
|---|
| 395 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
|---|
| 396 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
|---|
| 397 | |
|---|
| 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; |
|---|
| 402 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; |
|---|
| 403 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; |
|---|
| 404 | m_ppcCU[uiDepth]->initAvailableFlags(); |
|---|
| 405 | #endif |
|---|
| 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 |
|---|
| 416 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
|---|
| 417 | #endif |
|---|
| 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 ); |
|---|
| 421 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
|---|
| 422 | #endif |
|---|
| 423 | |
|---|
| 424 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
|---|
| 425 | |
|---|
| 426 | TComMv cTmpMv( 0, 0 ); |
|---|
| 427 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
|---|
| 428 | { |
|---|
| 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 ); |
|---|
| 435 | #if NH_3D |
|---|
| 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 |
|---|
| 449 | #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC |
|---|
| 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 |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | #if NH_3D |
|---|
| 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 | } |
|---|
| 487 | #if ENC_DEC_TRACE && NH_MV_ENC_DEC_TRAC |
|---|
| 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 |
|---|
| 520 | } |
|---|
| 521 | delete[] pcMvFieldSP; |
|---|
| 522 | delete[] puhInterDirSP; |
|---|
| 523 | #endif |
|---|
| 524 | |
|---|
| 525 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 526 | #if NH_3D |
|---|
| 527 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 528 | #endif |
|---|
| 529 | |
|---|
| 530 | return; |
|---|
| 531 | } |
|---|
| 532 | #if NH_3D |
|---|
| 533 | m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 534 | if(!pcCU->getDISFlag(uiAbsPartIdx)) |
|---|
| 535 | { |
|---|
| 536 | #endif |
|---|
| 537 | |
|---|
| 538 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 539 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 540 | |
|---|
| 541 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
|---|
| 542 | { |
|---|
| 543 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 544 | |
|---|
| 545 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
|---|
| 546 | { |
|---|
| 547 | #if NH_3D |
|---|
| 548 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 549 | #endif |
|---|
| 550 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 551 | #if NH_3D |
|---|
| 552 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 553 | #endif |
|---|
| 554 | return; |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
|---|
| 559 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
|---|
| 560 | |
|---|
| 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 |
|---|
| 568 | } |
|---|
| 569 | #endif |
|---|
| 570 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
|---|
| 571 | #if NH_3D |
|---|
| 572 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
|---|
| 573 | #endif |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
|---|
| 577 | { |
|---|
| 578 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
|---|
| 579 | { |
|---|
| 580 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
|---|
| 584 | { |
|---|
| 585 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 592 | { |
|---|
| 593 | TComPic* pcPic = pCtu->getPic(); |
|---|
| 594 | #if !NH_3D |
|---|
| 595 | TComSlice * pcSlice = pCtu->getSlice(); |
|---|
| 596 | const TComSPS &sps=*(pcSlice->getSPS()); |
|---|
| 597 | |
|---|
| 598 | Bool bBoundary = false; |
|---|
| 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; |
|---|
| 603 | |
|---|
| 604 | if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) ) |
|---|
| 605 | { |
|---|
| 606 | bBoundary = true; |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
|---|
| 610 | { |
|---|
| 611 | UInt uiNextDepth = uiDepth + 1; |
|---|
| 612 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
|---|
| 613 | UInt uiIdx = uiAbsPartIdx; |
|---|
| 614 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
|---|
| 615 | { |
|---|
| 616 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 617 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
|---|
| 618 | |
|---|
| 619 | if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
|---|
| 620 | { |
|---|
| 621 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | uiIdx += uiQNumParts; |
|---|
| 625 | } |
|---|
| 626 | return; |
|---|
| 627 | } |
|---|
| 628 | #endif |
|---|
| 629 | // Residual reconstruction |
|---|
| 630 | m_ppcYuvResi[uiDepth]->clear(); |
|---|
| 631 | |
|---|
| 632 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx ); |
|---|
| 633 | |
|---|
| 634 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
|---|
| 635 | { |
|---|
| 636 | case MODE_INTER: |
|---|
| 637 | #if NH_3D |
|---|
| 638 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
|---|
| 639 | { |
|---|
| 640 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
|---|
| 641 | } |
|---|
| 642 | else |
|---|
| 643 | { |
|---|
| 644 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
|---|
| 645 | { |
|---|
| 646 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
|---|
| 647 | } |
|---|
| 648 | else |
|---|
| 649 | { |
|---|
| 650 | #endif |
|---|
| 651 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
|---|
| 652 | #if NH_3D |
|---|
| 653 | } |
|---|
| 654 | } |
|---|
| 655 | #endif |
|---|
| 656 | break; |
|---|
| 657 | case MODE_INTRA: |
|---|
| 658 | #if NH_3D |
|---|
| 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 |
|---|
| 668 | #endif |
|---|
| 669 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
|---|
| 670 | break; |
|---|
| 671 | default: |
|---|
| 672 | assert(0); |
|---|
| 673 | break; |
|---|
| 674 | } |
|---|
| 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 | |
|---|
| 687 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
|---|
| 688 | { |
|---|
| 689 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
|---|
| 693 | } |
|---|
| 694 | |
|---|
| 695 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 696 | { |
|---|
| 697 | |
|---|
| 698 | // inter prediction |
|---|
| 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 |
|---|
| 705 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
|---|
| 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 | |
|---|
| 715 | // inter recon |
|---|
| 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 | |
|---|
| 725 | // clip for only non-zero cbp case |
|---|
| 726 | if ( pcCU->getQtRootCbf( 0) ) |
|---|
| 727 | { |
|---|
| 728 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
|---|
| 729 | } |
|---|
| 730 | else |
|---|
| 731 | { |
|---|
| 732 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
|---|
| 733 | } |
|---|
| 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 | |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | #if NH_3D |
|---|
| 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 | |
|---|
| 751 | UInt uiStride = pcRecoYuv->getStride (COMPONENT_Y); |
|---|
| 752 | Pel* piReco = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
|---|
| 753 | |
|---|
| 754 | |
|---|
| 755 | AOF( uiWidth == uiHeight ); |
|---|
| 756 | AOF( uiAbsPartIdx == 0 ); |
|---|
| 757 | |
|---|
| 758 | TComTURecurse rTu(pcCU, 0); |
|---|
| 759 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
|---|
| 760 | |
|---|
| 761 | DEBUG_STRING_NEW(sTemp) |
|---|
| 762 | if ( pcCU->getDISType(uiAbsPartIdx) == 0 ) |
|---|
| 763 | { |
|---|
| 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 ); |
|---|
| 767 | } |
|---|
| 768 | else if ( pcCU->getDISType(uiAbsPartIdx) == 1 ) |
|---|
| 769 | { |
|---|
| 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 ); |
|---|
| 773 | } |
|---|
| 774 | else if ( pcCU->getDISType(uiAbsPartIdx) == 2 ) |
|---|
| 775 | { |
|---|
| 776 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
|---|
| 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 | { |
|---|
| 789 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
|---|
| 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 |
|---|
| 802 | UInt uiStrideC = pcRecoYuv->getStride(COMPONENT_Cb); |
|---|
| 803 | Pel *pRecCb = pcRecoYuv->getAddr(COMPONENT_Cb); |
|---|
| 804 | Pel *pRecCr = pcRecoYuv->getAddr(COMPONENT_Cr); |
|---|
| 805 | |
|---|
| 806 | for (Int y=0; y<uiHeight/2; y++) |
|---|
| 807 | { |
|---|
| 808 | for (Int x=0; x<uiWidth/2; x++) |
|---|
| 809 | { |
|---|
| 810 | pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
|---|
| 811 | pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
|---|
| 812 | } |
|---|
| 813 | |
|---|
| 814 | pRecCb += uiStrideC; |
|---|
| 815 | pRecCr += uiStrideC; |
|---|
| 816 | } |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 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; |
|---|
| 829 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride( COMPONENT_Y ); |
|---|
| 830 | Int bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA); |
|---|
| 831 | |
|---|
| 832 | pResi = m_ppcYuvResi[uiDepth]->getAddr( COMPONENT_Y ); |
|---|
| 833 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
|---|
| 834 | { |
|---|
| 835 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
|---|
| 836 | { |
|---|
| 837 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
|---|
| 838 | } |
|---|
| 839 | pResi += uiResiStride; |
|---|
| 840 | } |
|---|
| 841 | |
|---|
| 842 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
|---|
| 843 | |
|---|
| 844 | // clear UV |
|---|
| 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 ); |
|---|
| 848 | |
|---|
| 849 | for (Int y = 0; y < uiHeight/2; y++) |
|---|
| 850 | { |
|---|
| 851 | for (Int x = 0; x < uiWidth/2; x++) |
|---|
| 852 | { |
|---|
| 853 | pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
|---|
| 854 | pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | pRecCb += uiStrideC; |
|---|
| 858 | pRecCr += uiStrideC; |
|---|
| 859 | } |
|---|
| 860 | } |
|---|
| 861 | |
|---|
| 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 | |
|---|
| 868 | Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
|---|
| 869 | |
|---|
| 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]; |
|---|
| 878 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
|---|
| 879 | AOF(bValidMask); |
|---|
| 880 | |
|---|
| 881 | DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
|---|
| 882 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
|---|
| 883 | |
|---|
| 884 | // first, extract the two sets of motion parameters |
|---|
| 885 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; |
|---|
| 886 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
|---|
| 887 | { |
|---|
| 888 | UInt uiPartAddr = uiSegment*uiPUOffset; |
|---|
| 889 | |
|---|
| 890 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
|---|
| 891 | assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2 ); // only uni-prediction allowed |
|---|
| 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 | } |
|---|
| 898 | |
|---|
| 899 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
|---|
| 900 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
|---|
| 901 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
|---|
| 902 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
|---|
| 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 ); |
|---|
| 911 | |
|---|
| 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 |
|---|
| 942 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY); |
|---|
| 943 | |
|---|
| 944 | // inter recon |
|---|
| 945 | xDecodeInterTexture( pcCU, uiDepth ); |
|---|
| 946 | |
|---|
| 947 | // clip for only non-zero cbp case |
|---|
| 948 | if ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) ) |
|---|
| 949 | { |
|---|
| 950 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
|---|
| 951 | } |
|---|
| 952 | else |
|---|
| 953 | { |
|---|
| 954 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
|---|
| 955 | } |
|---|
| 956 | } |
|---|
| 957 | #endif |
|---|
| 958 | |
|---|
| 959 | |
|---|
| 960 | Void |
|---|
| 961 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
|---|
| 962 | TComYuv* pcPredYuv, |
|---|
| 963 | TComYuv* pcResiYuv, |
|---|
| 964 | const ComponentID compID, |
|---|
| 965 | TComTU &rTu) |
|---|
| 966 | { |
|---|
| 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 | |
|---|
| 1009 | //===== init availability pattern ===== |
|---|
| 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 | |
|---|
| 1020 | //===== get prediction signal ===== |
|---|
| 1021 | #if NH_3D |
|---|
| 1022 | if( bIsLuma && isDmmMode( uiChFinalMode ) ) |
|---|
| 1023 | { |
|---|
| 1024 | m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight ); |
|---|
| 1025 | } |
|---|
| 1026 | else |
|---|
| 1027 | { |
|---|
| 1028 | #endif |
|---|
| 1029 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions ); |
|---|
| 1030 | #if NH_3D |
|---|
| 1031 | } |
|---|
| 1032 | #endif |
|---|
| 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 |
|---|
| 1050 | #if H_3D |
|---|
| 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()); |
|---|
| 1052 | |
|---|
| 1053 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
|---|
| 1054 | #else |
|---|
| 1055 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
|---|
| 1056 | #endif |
|---|
| 1057 | { |
|---|
| 1058 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
|---|
| 1059 | } |
|---|
| 1060 | else |
|---|
| 1061 | { |
|---|
| 1062 | for (UInt y = 0; y < uiHeight; y++) |
|---|
| 1063 | { |
|---|
| 1064 | for (UInt x = 0; x < uiWidth; x++) |
|---|
| 1065 | { |
|---|
| 1066 | piResi[(y * uiStride) + x] = 0; |
|---|
| 1067 | } |
|---|
| 1068 | } |
|---|
| 1069 | } |
|---|
| 1070 | |
|---|
| 1071 | #if DEBUG_STRING |
|---|
| 1072 | if (psDebug) |
|---|
| 1073 | { |
|---|
| 1074 | ss << (*psDebug); |
|---|
| 1075 | } |
|---|
| 1076 | #endif |
|---|
| 1077 | |
|---|
| 1078 | //===== reconstruction ===== |
|---|
| 1079 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
|---|
| 1080 | |
|---|
| 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 ); |
|---|
| 1084 | |
|---|
| 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 ); |
|---|
| 1089 | |
|---|
| 1090 | |
|---|
| 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 |
|---|
| 1100 | |
|---|
| 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 ) |
|---|
| 1107 | { |
|---|
| 1108 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
|---|
| 1109 | } |
|---|
| 1110 | |
|---|
| 1111 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1112 | { |
|---|
| 1113 | #if DEBUG_STRING |
|---|
| 1114 | if (bDebugPred || bDebugResi || bDebugReco) |
|---|
| 1115 | { |
|---|
| 1116 | ss << "###: "; |
|---|
| 1117 | } |
|---|
| 1118 | |
|---|
| 1119 | if (bDebugPred) |
|---|
| 1120 | { |
|---|
| 1121 | ss << " - pred: "; |
|---|
| 1122 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1123 | { |
|---|
| 1124 | ss << pPred[ uiX ] << ", "; |
|---|
| 1125 | } |
|---|
| 1126 | } |
|---|
| 1127 | if (bDebugResi) |
|---|
| 1128 | { |
|---|
| 1129 | ss << " - resi: "; |
|---|
| 1130 | } |
|---|
| 1131 | #endif |
|---|
| 1132 | |
|---|
| 1133 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1134 | { |
|---|
| 1135 | #if DEBUG_STRING |
|---|
| 1136 | if (bDebugResi) |
|---|
| 1137 | { |
|---|
| 1138 | ss << pResi[ uiX ] << ", "; |
|---|
| 1139 | } |
|---|
| 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 ]; |
|---|
| 1147 | } |
|---|
| 1148 | #if DEBUG_STRING |
|---|
| 1149 | if (bDebugReco) |
|---|
| 1150 | { |
|---|
| 1151 | ss << " - reco: "; |
|---|
| 1152 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 1153 | { |
|---|
| 1154 | ss << pReco[ uiX ] << ", "; |
|---|
| 1155 | } |
|---|
| 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; |
|---|
| 1167 | } |
|---|
| 1168 | } |
|---|
| 1169 | |
|---|
| 1170 | Void |
|---|
| 1171 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 1172 | { |
|---|
| 1173 | if (pcCU->getIPCMFlag(0)) |
|---|
| 1174 | { |
|---|
| 1175 | xReconPCM( pcCU, uiDepth ); |
|---|
| 1176 | return; |
|---|
| 1177 | } |
|---|
| 1178 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
|---|
| 1179 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
|---|
| 1180 | { |
|---|
| 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 ); |
|---|
| 1184 | |
|---|
| 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)); |
|---|
| 1192 | } |
|---|
| 1193 | } |
|---|
| 1194 | |
|---|
| 1195 | #if NH_3D |
|---|
| 1196 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 1197 | { |
|---|
| 1198 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
|---|
| 1199 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
|---|
| 1200 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
|---|
| 1201 | |
|---|
| 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(); |
|---|
| 1208 | |
|---|
| 1209 | UInt sdcDepth = 0; |
|---|
| 1210 | UInt uiStride; |
|---|
| 1211 | Pel* piReco; |
|---|
| 1212 | Pel* piPred; |
|---|
| 1213 | Pel* piResi; |
|---|
| 1214 | |
|---|
| 1215 | Pel* piRecIPred; |
|---|
| 1216 | UInt uiRecIPredStride; |
|---|
| 1217 | |
|---|
| 1218 | Pel apDCPredValues[2]; |
|---|
| 1219 | UInt uiNumSegments; |
|---|
| 1220 | |
|---|
| 1221 | Bool* pbMask = NULL; |
|---|
| 1222 | UInt uiMaskStride = 0; |
|---|
| 1223 | |
|---|
| 1224 | if( isDmmMode( uiLumaPredMode ) ) |
|---|
| 1225 | { |
|---|
| 1226 | assert( uiWidth == uiHeight ); |
|---|
| 1227 | assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE ); |
|---|
| 1228 | assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) ); |
|---|
| 1229 | |
|---|
| 1230 | uiNumSegments = 2; |
|---|
| 1231 | |
|---|
| 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 ); |
|---|
| 1236 | |
|---|
| 1237 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
|---|
| 1238 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
|---|
| 1239 | |
|---|
| 1240 | //===== init availability pattern ===== |
|---|
| 1241 | TComTURecurse tuRecurseCU(pcCU, 0); |
|---|
| 1242 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT); |
|---|
| 1243 | |
|---|
| 1244 | DEBUG_STRING_NEW(sTemp) |
|---|
| 1245 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) ); |
|---|
| 1246 | |
|---|
| 1247 | // get partition |
|---|
| 1248 | pbMask = new Bool[ uiWidth*uiHeight ]; |
|---|
| 1249 | uiMaskStride = uiWidth; |
|---|
| 1250 | switch( getDmmType( uiLumaPredMode ) ) |
|---|
| 1251 | { |
|---|
| 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); |
|---|
| 1255 | } |
|---|
| 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 | { |
|---|
| 1269 | |
|---|
| 1270 | uiNumSegments = 1; |
|---|
| 1271 | |
|---|
| 1272 | if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 ) |
|---|
| 1273 | { |
|---|
| 1274 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
|---|
| 1275 | } |
|---|
| 1276 | |
|---|
| 1277 | //===== loop over partitions ===== |
|---|
| 1278 | TComTURecurse tuRecurseCU(pcCU, 0); |
|---|
| 1279 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT); |
|---|
| 1280 | |
|---|
| 1281 | do |
|---|
| 1282 | { |
|---|
| 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 ===== |
|---|
| 1295 | DEBUG_STRING_NEW(sTemp) |
|---|
| 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++ ) |
|---|
| 1302 | { |
|---|
| 1303 | for( UInt uiX = 0; uiX < puRect.width; uiX++ ) |
|---|
| 1304 | { |
|---|
| 1305 | piPredTU [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY ); |
|---|
| 1306 | piRecIPredTU [ uiX ] = piPredTU[ uiX ]; |
|---|
| 1307 | } |
|---|
| 1308 | piPredTU += uiStrideTU; |
|---|
| 1309 | piRecIPredTU += uiRecIPredStrideTU; |
|---|
| 1310 | } |
|---|
| 1311 | |
|---|
| 1312 | |
|---|
| 1313 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
|---|
| 1314 | |
|---|
| 1315 | // reset to full block |
|---|
| 1316 | uiWidth = pcCU->getWidth( 0 ); |
|---|
| 1317 | uiHeight = pcCU->getHeight( 0 ); |
|---|
| 1318 | |
|---|
| 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 ); |
|---|
| 1326 | |
|---|
| 1327 | m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0; |
|---|
| 1328 | } |
|---|
| 1329 | |
|---|
| 1330 | // reconstruct residual based on mask + DC residuals |
|---|
| 1331 | Pel apDCResiValues[2]; |
|---|
| 1332 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
|---|
| 1333 | { |
|---|
| 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 | |
|---|
| 1338 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
|---|
| 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 | |
|---|
| 1357 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY ); |
|---|
| 1358 | pRecIPred[ uiX ] = pReco[ uiX ]; |
|---|
| 1359 | } |
|---|
| 1360 | pPred += uiStride; |
|---|
| 1361 | pResi += uiStride; |
|---|
| 1362 | pReco += uiStride; |
|---|
| 1363 | pRecIPred += uiRecIPredStride; |
|---|
| 1364 | pMask += uiMaskStride; |
|---|
| 1365 | } |
|---|
| 1366 | |
|---|
| 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 ); |
|---|
| 1371 | |
|---|
| 1372 | for (Int y=0; y<uiHeight/2; y++) |
|---|
| 1373 | { |
|---|
| 1374 | for (Int x=0; x<uiWidth/2; x++) |
|---|
| 1375 | { |
|---|
| 1376 | pRecCb[x] = 128; |
|---|
| 1377 | pRecCr[x] = 128; |
|---|
| 1378 | } |
|---|
| 1379 | |
|---|
| 1380 | pRecCb += uiStrideC; |
|---|
| 1381 | pRecCr += uiStrideC; |
|---|
| 1382 | } |
|---|
| 1383 | if( pbMask ) { delete[] pbMask; } |
|---|
| 1384 | } |
|---|
| 1385 | #endif |
|---|
| 1386 | |
|---|
| 1387 | |
|---|
| 1388 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
|---|
| 1389 | * \param pcRecoYuv pointer to reconstructed sample arrays |
|---|
| 1390 | * \param pcPredYuv pointer to prediction sample arrays |
|---|
| 1391 | * \param pcResiYuv pointer to residue sample arrays |
|---|
| 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 |
|---|
| 1396 | */ |
|---|
| 1397 | |
|---|
| 1398 | Void |
|---|
| 1399 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
|---|
| 1400 | TComYuv* pcPredYuv, |
|---|
| 1401 | TComYuv* pcResiYuv, |
|---|
| 1402 | const ChannelType chType, |
|---|
| 1403 | TComTU &rTu) |
|---|
| 1404 | { |
|---|
| 1405 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
|---|
| 1406 | TComDataCU *pcCU = rTu.getCU(); |
|---|
| 1407 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
|---|
| 1408 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
|---|
| 1409 | if( uiTrMode == uiTrDepth ) |
|---|
| 1410 | { |
|---|
| 1411 | if (isLuma(chType)) |
|---|
| 1412 | { |
|---|
| 1413 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
|---|
| 1414 | } |
|---|
| 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 | } |
|---|
| 1423 | } |
|---|
| 1424 | else |
|---|
| 1425 | { |
|---|
| 1426 | TComTURecurse tuRecurseChild(rTu, false); |
|---|
| 1427 | do |
|---|
| 1428 | { |
|---|
| 1429 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
|---|
| 1430 | } while (tuRecurseChild.nextSection(rTu)); |
|---|
| 1431 | } |
|---|
| 1432 | } |
|---|
| 1433 | |
|---|
| 1434 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
|---|
| 1435 | { |
|---|
| 1436 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
|---|
| 1437 | |
|---|
| 1438 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
|---|
| 1439 | |
|---|
| 1440 | return; |
|---|
| 1441 | } |
|---|
| 1442 | |
|---|
| 1443 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 1444 | { |
|---|
| 1445 | |
|---|
| 1446 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
|---|
| 1447 | |
|---|
| 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]) |
|---|
| 1452 | |
|---|
| 1453 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
|---|
| 1454 | } |
|---|
| 1455 | |
|---|
| 1456 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
|---|
| 1457 | } |
|---|
| 1458 | |
|---|
| 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 |
|---|
| 1467 | * \param compID colour component ID |
|---|
| 1468 | * \returns Void |
|---|
| 1469 | */ |
|---|
| 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) |
|---|
| 1471 | { |
|---|
| 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)); |
|---|
| 1476 | |
|---|
| 1477 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
|---|
| 1478 | { |
|---|
| 1479 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
|---|
| 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 | */ |
|---|
| 1495 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
|---|
| 1496 | { |
|---|
| 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 | } |
|---|
| 1509 | } |
|---|
| 1510 | |
|---|
| 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 |
|---|
| 1514 | */ |
|---|
| 1515 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
|---|
| 1516 | { |
|---|
| 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(); |
|---|
| 1521 | |
|---|
| 1522 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
|---|
| 1523 | { |
|---|
| 1524 | const ComponentID component = ComponentID(componentIndex); |
|---|
| 1525 | |
|---|
| 1526 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
|---|
| 1527 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
|---|
| 1528 | |
|---|
| 1529 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
|---|
| 1530 | Pel *destination = pCU->getPCMSample(component); |
|---|
| 1531 | |
|---|
| 1532 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
|---|
| 1533 | |
|---|
| 1534 | for (Int line = 0; line < height; line++) |
|---|
| 1535 | { |
|---|
| 1536 | for (Int column = 0; column < width; column++) |
|---|
| 1537 | { |
|---|
| 1538 | destination[column] = source[column]; |
|---|
| 1539 | } |
|---|
| 1540 | |
|---|
| 1541 | source += sourceStride; |
|---|
| 1542 | destination += width; |
|---|
| 1543 | } |
|---|
| 1544 | } |
|---|
| 1545 | } |
|---|
| 1546 | |
|---|
| 1547 | //! \} |
|---|