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