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