[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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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 TDecEntropy.cpp |
---|
| 35 | \brief entropy decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecEntropy.h" |
---|
| 39 | |
---|
[56] | 40 | //! \ingroup TLibDecoder |
---|
| 41 | //! \{ |
---|
| 42 | |
---|
[2] | 43 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
---|
| 44 | { |
---|
| 45 | m_pcEntropyDecoderIf = p; |
---|
| 46 | } |
---|
| 47 | |
---|
[56] | 48 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
[2] | 49 | |
---|
| 50 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 51 | { |
---|
| 52 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 53 | } |
---|
[1084] | 54 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 55 | Void TDecEntropy::decodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 56 | { |
---|
[1124] | 57 | if( !pcCU->getSlice()->getIntraSingleFlag() ) |
---|
| 58 | { |
---|
| 59 | return; |
---|
| 60 | } |
---|
| 61 | |
---|
[1039] | 62 | m_pcEntropyDecoderIf->parseSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 63 | } |
---|
| 64 | #endif |
---|
[608] | 65 | Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 66 | { |
---|
| 67 | m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 68 | } |
---|
| 69 | |
---|
[2] | 70 | /** decode merge flag |
---|
| 71 | * \param pcSubCU |
---|
| 72 | * \param uiAbsPartIdx |
---|
| 73 | * \param uiDepth |
---|
| 74 | * \param uiPUIdx |
---|
| 75 | * \returns Void |
---|
| 76 | */ |
---|
| 77 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
| 78 | { |
---|
[56] | 79 | // at least one merge candidate exists |
---|
| 80 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
[2] | 81 | } |
---|
| 82 | |
---|
| 83 | /** decode merge index |
---|
| 84 | * \param pcCU |
---|
| 85 | * \param uiPartIdx |
---|
| 86 | * \param uiAbsPartIdx |
---|
| 87 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
| 88 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
| 89 | * \param uiDepth |
---|
| 90 | * \returns Void |
---|
| 91 | */ |
---|
[608] | 92 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 93 | { |
---|
| 94 | UInt uiMergeIndex = 0; |
---|
[608] | 95 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex ); |
---|
[2] | 96 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 97 | } |
---|
| 98 | |
---|
[608] | 99 | #if H_3D_ARP |
---|
| 100 | Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[443] | 101 | { |
---|
[608] | 102 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
| 103 | { |
---|
[443] | 104 | return; |
---|
[608] | 105 | } |
---|
| 106 | |
---|
| 107 | if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
| 108 | { |
---|
| 109 | pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 110 | } |
---|
[443] | 111 | else |
---|
[608] | 112 | { |
---|
[443] | 113 | m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
[608] | 114 | } |
---|
[443] | 115 | } |
---|
| 116 | #endif |
---|
[608] | 117 | |
---|
| 118 | #if H_3D_IC |
---|
| 119 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 120 | { |
---|
| 121 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
---|
| 122 | |
---|
[833] | 123 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
---|
[608] | 124 | { |
---|
| 125 | return; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
| 129 | return; |
---|
| 130 | |
---|
| 131 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
| 132 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 133 | } |
---|
| 134 | #endif |
---|
| 135 | |
---|
[2] | 136 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 137 | { |
---|
| 138 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 142 | { |
---|
| 143 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 147 | { |
---|
| 148 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[833] | 149 | |
---|
| 150 | #if H_3D_DBBP |
---|
[1124] | 151 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() ) |
---|
[833] | 152 | { |
---|
| 153 | decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 154 | } |
---|
| 155 | #endif |
---|
[2] | 156 | } |
---|
| 157 | |
---|
| 158 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 159 | { |
---|
| 160 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 161 | { |
---|
[608] | 162 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 163 | #if H_3D_DIM_SDC |
---|
| 164 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
[443] | 165 | #endif |
---|
[608] | 166 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 167 | } |
---|
| 168 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 169 | { |
---|
[56] | 170 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
| 171 | } |
---|
| 172 | } |
---|
[2] | 173 | |
---|
[56] | 174 | /** Parse I_PCM information. |
---|
| 175 | * \param pcCU pointer to CUpointer to CU |
---|
| 176 | * \param uiAbsPartIdx CU index |
---|
| 177 | * \param uiDepth CU depth |
---|
| 178 | * \returns Void |
---|
| 179 | */ |
---|
| 180 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 181 | { |
---|
| 182 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
| 183 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
| 184 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
| 185 | { |
---|
| 186 | return; |
---|
[2] | 187 | } |
---|
[189] | 188 | |
---|
[56] | 189 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 190 | } |
---|
| 191 | |
---|
| 192 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 193 | { |
---|
| 194 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 198 | { |
---|
| 199 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 200 | } |
---|
| 201 | |
---|
[56] | 202 | /** decode motion information for every PU block. |
---|
[2] | 203 | * \param pcCU |
---|
| 204 | * \param uiAbsPartIdx |
---|
| 205 | * \param uiDepth |
---|
| 206 | * \param pcSubCU |
---|
| 207 | * \returns Void |
---|
| 208 | */ |
---|
| 209 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 210 | { |
---|
| 211 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 212 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 213 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 214 | |
---|
[608] | 215 | #if H_3D_IV_MERGE |
---|
[56] | 216 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 217 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 218 | #else |
---|
| 219 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 220 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 221 | #endif |
---|
[773] | 222 | #if H_3D_SPIVMP |
---|
[724] | 223 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 224 | TComMvField* pcMvFieldSP; |
---|
| 225 | UChar* puhInterDirSP; |
---|
| 226 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
| 227 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
| 228 | #endif |
---|
[608] | 229 | for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
[56] | 230 | { |
---|
| 231 | uhInterDirNeighbours[ui] = 0; |
---|
| 232 | } |
---|
| 233 | Int numValidMergeCand = 0; |
---|
[608] | 234 | Bool isMerged = false; |
---|
[56] | 235 | |
---|
[2] | 236 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 237 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
[608] | 238 | #if H_3D_IV_MERGE |
---|
| 239 | pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
| 240 | #endif |
---|
[2] | 241 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 242 | { |
---|
[608] | 243 | #if H_MV_ENC_DEC_TRAC |
---|
| 244 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
| 245 | // ToDo: |
---|
| 246 | //DTRACE_PU("x0", uiLPelX) |
---|
| 247 | //DTRACE_PU("x1", uiTPelY) |
---|
[56] | 248 | #endif |
---|
[2] | 249 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 250 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 251 | { |
---|
[608] | 252 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
---|
[56] | 253 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[724] | 254 | #if H_3D_ARP |
---|
| 255 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 256 | #endif |
---|
[833] | 257 | #if H_3D_IC |
---|
| 258 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 259 | #endif |
---|
| 260 | #if H_3D_DBBP |
---|
| 261 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false ) |
---|
| 262 | #else |
---|
[56] | 263 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
[833] | 264 | #endif |
---|
[2] | 265 | { |
---|
[56] | 266 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 267 | if ( !isMerged ) |
---|
[2] | 268 | { |
---|
[608] | 269 | #if H_3D_VSP |
---|
| 270 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 271 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
[773] | 272 | #if H_3D_SPIVMP |
---|
[724] | 273 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 274 | #endif |
---|
| 275 | pcSubCU->initAvailableFlags(); |
---|
| 276 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
[950] | 277 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
[773] | 278 | #if H_3D_SPIVMP |
---|
[950] | 279 | , pcMvFieldSP, puhInterDirSP |
---|
| 280 | #endif |
---|
[724] | 281 | , numValidMergeCand ); |
---|
[950] | 282 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
| 283 | #if H_3D_SPIVMP |
---|
| 284 | , bSPIVMPFlag |
---|
| 285 | #endif |
---|
| 286 | , numValidMergeCand ); |
---|
[608] | 287 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
[622] | 288 | |
---|
[608] | 289 | #else |
---|
[773] | 290 | #if H_3D |
---|
[724] | 291 | pcSubCU->initAvailableFlags(); |
---|
| 292 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
| 293 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 294 | |
---|
| 295 | #else |
---|
[608] | 296 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 297 | #endif |
---|
[724] | 298 | #endif |
---|
[56] | 299 | isMerged = true; |
---|
[2] | 300 | } |
---|
[56] | 301 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
| 302 | } |
---|
| 303 | else |
---|
| 304 | { |
---|
[622] | 305 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[608] | 306 | #if H_3D_VSP |
---|
| 307 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 308 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
[773] | 309 | #if H_3D_SPIVMP |
---|
[724] | 310 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
| 311 | #endif |
---|
| 312 | pcSubCU->initAvailableFlags(); |
---|
| 313 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[950] | 314 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours |
---|
[773] | 315 | #if H_3D_SPIVMP |
---|
[950] | 316 | , pcMvFieldSP, puhInterDirSP |
---|
| 317 | #endif |
---|
[724] | 318 | ,numValidMergeCand, uiMergeIndex ); |
---|
[950] | 319 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
| 320 | #if H_3D_SPIVMP |
---|
| 321 | , bSPIVMPFlag |
---|
| 322 | #endif |
---|
| 323 | ,numValidMergeCand ); |
---|
[608] | 324 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
[443] | 325 | #else |
---|
[773] | 326 | #if H_3D |
---|
[724] | 327 | pcSubCU->initAvailableFlags(); |
---|
[608] | 328 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[724] | 329 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 330 | #else |
---|
| 331 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[443] | 332 | #endif |
---|
[724] | 333 | #endif |
---|
[56] | 334 | } |
---|
| 335 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
[833] | 336 | |
---|
[56] | 337 | TComMv cTmpMv( 0, 0 ); |
---|
| 338 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 339 | { |
---|
| 340 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
[2] | 341 | { |
---|
[56] | 342 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 343 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 344 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 345 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
[884] | 346 | #if H_3D_VSP |
---|
[833] | 347 | #if H_3D_DBBP |
---|
| 348 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) ) |
---|
| 349 | #else |
---|
| 350 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 ) |
---|
| 351 | #endif |
---|
| 352 | { |
---|
| 353 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
| 354 | { |
---|
| 355 | UInt dummy; |
---|
| 356 | Int vspSize; |
---|
| 357 | Int width, height; |
---|
| 358 | pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 ); |
---|
| 359 | pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
| 360 | pcCU->setVSPFlag( uiSubPartIdx, vspSize ); |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | #endif |
---|
[2] | 364 | } |
---|
| 365 | } |
---|
[773] | 366 | #if H_3D_SPIVMP |
---|
[724] | 367 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 368 | if (bSPIVMPFlag[uiMergeIndex] != 0) |
---|
| 369 | { |
---|
| 370 | Int iWidth, iHeight; |
---|
| 371 | UInt uiIdx; |
---|
| 372 | pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true ); |
---|
| 373 | |
---|
| 374 | UInt uiSPAddr; |
---|
| 375 | |
---|
| 376 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
| 377 | |
---|
| 378 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
| 379 | |
---|
| 380 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
| 381 | { |
---|
| 382 | pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
| 383 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
| 384 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
| 385 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | #endif |
---|
[56] | 389 | } |
---|
| 390 | else |
---|
| 391 | { |
---|
[2] | 392 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 393 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 394 | { |
---|
| 395 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 396 | { |
---|
| 397 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 398 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 399 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 400 | } |
---|
| 401 | } |
---|
[724] | 402 | #if H_3D_ARP |
---|
| 403 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 404 | #endif |
---|
[833] | 405 | #if H_3D_IC |
---|
| 406 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 407 | #endif |
---|
[2] | 408 | } |
---|
[608] | 409 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
---|
| 410 | { |
---|
| 411 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 412 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
| 413 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 414 | } |
---|
[2] | 415 | } |
---|
[773] | 416 | #if H_3D_SPIVMP |
---|
[735] | 417 | delete[] pcMvFieldSP; |
---|
| 418 | delete[] puhInterDirSP; |
---|
[724] | 419 | #endif |
---|
[2] | 420 | return; |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | /** decode inter direction for a PU block |
---|
| 424 | * \param pcCU |
---|
| 425 | * \param uiAbsPartIdx |
---|
| 426 | * \param uiDepth |
---|
| 427 | * \param uiPartIdx |
---|
| 428 | * \returns Void |
---|
| 429 | */ |
---|
| 430 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
| 431 | { |
---|
| 432 | UInt uiInterDir; |
---|
| 433 | |
---|
| 434 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 435 | { |
---|
| 436 | uiInterDir = 1; |
---|
| 437 | } |
---|
| 438 | else |
---|
| 439 | { |
---|
[608] | 440 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx ); |
---|
[2] | 441 | } |
---|
| 442 | |
---|
| 443 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 447 | { |
---|
[608] | 448 | Int iRefFrmIdx = 0; |
---|
| 449 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
| 450 | |
---|
| 451 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
[2] | 452 | { |
---|
[608] | 453 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList ); |
---|
[2] | 454 | } |
---|
[608] | 455 | else if ( !iParseRefFrmIdx ) |
---|
| 456 | { |
---|
| 457 | iRefFrmIdx = NOT_VALID; |
---|
| 458 | } |
---|
[2] | 459 | else |
---|
| 460 | { |
---|
[608] | 461 | iRefFrmIdx = 0; |
---|
| 462 | } |
---|
[2] | 463 | |
---|
[608] | 464 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 465 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 466 | } |
---|
| 467 | |
---|
| 468 | /** decode motion vector difference for a PU block |
---|
| 469 | * \param pcCU |
---|
| 470 | * \param uiAbsPartIdx |
---|
| 471 | * \param uiDepth |
---|
| 472 | * \param uiPartIdx |
---|
| 473 | * \param eRefList |
---|
| 474 | * \returns Void |
---|
| 475 | */ |
---|
| 476 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 477 | { |
---|
| 478 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 479 | { |
---|
| 480 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 485 | { |
---|
[56] | 486 | Int iMVPIdx = -1; |
---|
[2] | 487 | |
---|
| 488 | TComMv cZeroMv( 0, 0 ); |
---|
| 489 | TComMv cMv = cZeroMv; |
---|
| 490 | Int iRefIdx = -1; |
---|
| 491 | |
---|
| 492 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 493 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 494 | |
---|
| 495 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 496 | cMv = cZeroMv; |
---|
[56] | 497 | |
---|
[608] | 498 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
---|
[56] | 499 | { |
---|
| 500 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
[608] | 501 | #if H_MV_ENC_DEC_TRAC |
---|
| 502 | #if ENC_DEC_TRACE |
---|
| 503 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
| 504 | { |
---|
| 505 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
---|
| 506 | } |
---|
| 507 | else |
---|
| 508 | { |
---|
| 509 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
---|
| 510 | } |
---|
[56] | 511 | #endif |
---|
[608] | 512 | #endif |
---|
[56] | 513 | } |
---|
[2] | 514 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
| 515 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 516 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 517 | if ( iRefIdx >= 0 ) |
---|
| 518 | { |
---|
[608] | 519 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
---|
[2] | 520 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
[56] | 524 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
[2] | 525 | } |
---|
| 526 | |
---|
[872] | 527 | Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU) |
---|
[2] | 528 | { |
---|
[56] | 529 | UInt uiSubdiv; |
---|
| 530 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
| 531 | |
---|
| 532 | if(uiTrIdx==0) |
---|
| 533 | { |
---|
| 534 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
| 535 | } |
---|
| 536 | if( uiLog2TrafoSize == 2 ) |
---|
| 537 | { |
---|
| 538 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 539 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
| 540 | { |
---|
| 541 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 542 | m_uiBakChromaOffset = offsetChroma; |
---|
| 543 | } |
---|
| 544 | } |
---|
| 545 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 546 | { |
---|
| 547 | uiSubdiv = 1; |
---|
| 548 | } |
---|
| 549 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
| 550 | { |
---|
[872] | 551 | uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU); |
---|
[56] | 552 | } |
---|
| 553 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 554 | { |
---|
| 555 | uiSubdiv = 1; |
---|
| 556 | } |
---|
| 557 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 558 | { |
---|
| 559 | uiSubdiv = 0; |
---|
| 560 | } |
---|
[872] | 561 | else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU ) |
---|
[56] | 562 | { |
---|
| 563 | uiSubdiv = 0; |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
[872] | 567 | assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU ); |
---|
[608] | 568 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
[56] | 569 | } |
---|
[2] | 570 | |
---|
[56] | 571 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
[2] | 572 | { |
---|
[608] | 573 | const Bool bFirstCbfOfCU = uiTrDepth == 0; |
---|
[56] | 574 | if( bFirstCbfOfCU ) |
---|
[2] | 575 | { |
---|
[56] | 576 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 577 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 578 | } |
---|
[56] | 579 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
[2] | 580 | { |
---|
[56] | 581 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
[2] | 582 | { |
---|
[608] | 583 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
[2] | 584 | } |
---|
[56] | 585 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
[2] | 586 | { |
---|
[608] | 587 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
[2] | 588 | } |
---|
| 589 | } |
---|
[56] | 590 | else |
---|
[2] | 591 | { |
---|
[56] | 592 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 593 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 594 | } |
---|
| 595 | } |
---|
| 596 | |
---|
[56] | 597 | if( uiSubdiv ) |
---|
[2] | 598 | { |
---|
[56] | 599 | UInt size; |
---|
| 600 | width >>= 1; |
---|
| 601 | height >>= 1; |
---|
| 602 | size = width*height; |
---|
| 603 | uiTrIdx++; |
---|
| 604 | ++uiDepth; |
---|
| 605 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 606 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
| 607 | UInt uiYCbf = 0; |
---|
| 608 | UInt uiUCbf = 0; |
---|
| 609 | UInt uiVCbf = 0; |
---|
| 610 | |
---|
| 611 | for( Int i = 0; i < 4; i++ ) |
---|
[2] | 612 | { |
---|
[872] | 613 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU ); |
---|
[608] | 614 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); |
---|
| 615 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); |
---|
| 616 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 ); |
---|
[56] | 617 | uiAbsPartIdx += uiQPartNum; |
---|
| 618 | offsetLuma += size; offsetChroma += (size>>2); |
---|
[2] | 619 | } |
---|
[56] | 620 | |
---|
| 621 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
| 622 | { |
---|
[608] | 623 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth; |
---|
| 624 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth; |
---|
| 625 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth; |
---|
[56] | 626 | } |
---|
[2] | 627 | } |
---|
| 628 | else |
---|
| 629 | { |
---|
[56] | 630 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 631 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 632 | |
---|
[608] | 633 | #if !H_MV_ENC_DEC_TRAC |
---|
[2] | 634 | { |
---|
[56] | 635 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 636 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 637 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 638 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 639 | DTRACE_CABAC_V( uiDepth ); |
---|
| 640 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 641 | DTRACE_CABAC_V( uiTrDepth ); |
---|
| 642 | DTRACE_CABAC_T( "\n" ); |
---|
[2] | 643 | } |
---|
[608] | 644 | #endif |
---|
[56] | 645 | |
---|
| 646 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 647 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
[2] | 648 | { |
---|
[608] | 649 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
[2] | 650 | } |
---|
[56] | 651 | else |
---|
[2] | 652 | { |
---|
[608] | 653 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth ); |
---|
[2] | 654 | } |
---|
[608] | 655 | |
---|
| 656 | |
---|
[56] | 657 | // transform_unit begin |
---|
| 658 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
| 659 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 660 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 661 | if( uiLog2TrafoSize == 2 ) |
---|
[2] | 662 | { |
---|
[56] | 663 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 664 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 665 | { |
---|
[56] | 666 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 667 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
[2] | 668 | } |
---|
| 669 | } |
---|
[56] | 670 | if ( cbfY || cbfU || cbfV ) |
---|
[2] | 671 | { |
---|
[56] | 672 | // dQP: only for LCU |
---|
| 673 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 674 | { |
---|
[56] | 675 | if ( bCodeDQP ) |
---|
[2] | 676 | { |
---|
[56] | 677 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
| 678 | bCodeDQP = false; |
---|
[2] | 679 | } |
---|
| 680 | } |
---|
| 681 | } |
---|
[56] | 682 | if( cbfY ) |
---|
[2] | 683 | { |
---|
[56] | 684 | Int trWidth = width; |
---|
| 685 | Int trHeight = height; |
---|
| 686 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
[2] | 687 | } |
---|
[56] | 688 | if( uiLog2TrafoSize > 2 ) |
---|
[2] | 689 | { |
---|
[56] | 690 | Int trWidth = width >> 1; |
---|
| 691 | Int trHeight = height >> 1; |
---|
| 692 | if( cbfU ) |
---|
[2] | 693 | { |
---|
[56] | 694 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 695 | } |
---|
[56] | 696 | if( cbfV ) |
---|
[2] | 697 | { |
---|
[56] | 698 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 699 | } |
---|
| 700 | } |
---|
| 701 | else |
---|
| 702 | { |
---|
[56] | 703 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 704 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 705 | { |
---|
[56] | 706 | Int trWidth = width; |
---|
| 707 | Int trHeight = height; |
---|
| 708 | if( cbfU ) |
---|
[2] | 709 | { |
---|
[56] | 710 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 711 | } |
---|
[56] | 712 | if( cbfV ) |
---|
[2] | 713 | { |
---|
[56] | 714 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 715 | } |
---|
| 716 | } |
---|
| 717 | } |
---|
[56] | 718 | // transform_unit end |
---|
[2] | 719 | } |
---|
| 720 | } |
---|
| 721 | |
---|
[56] | 722 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 723 | { |
---|
| 724 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 725 | { |
---|
| 726 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 727 | } |
---|
| 728 | } |
---|
[2] | 729 | |
---|
| 730 | |
---|
| 731 | /** decode coefficients |
---|
| 732 | * \param pcCU |
---|
| 733 | * \param uiAbsPartIdx |
---|
| 734 | * \param uiDepth |
---|
| 735 | * \param uiWidth |
---|
| 736 | * \param uiHeight |
---|
| 737 | * \returns Void |
---|
| 738 | */ |
---|
[56] | 739 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
[2] | 740 | { |
---|
| 741 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 742 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 743 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[833] | 744 | #if H_3D_DIM_SDC |
---|
| 745 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) ) |
---|
| 746 | { |
---|
| 747 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 748 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
| 749 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
| 750 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
| 751 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | #if H_3D_INTER_SDC |
---|
| 755 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) ) |
---|
| 756 | { |
---|
| 757 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
| 758 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
| 759 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
| 760 | } |
---|
| 761 | #endif |
---|
| 762 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
---|
| 763 | { |
---|
| 764 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
---|
| 765 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
---|
[2] | 766 | |
---|
[833] | 767 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
| 768 | { |
---|
| 769 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
---|
| 770 | { |
---|
| 771 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
---|
| 772 | { |
---|
| 773 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ); |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | } |
---|
| 777 | else |
---|
| 778 | { |
---|
| 779 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 780 | return; |
---|
| 781 | } |
---|
| 782 | } |
---|
[443] | 783 | #endif |
---|
[608] | 784 | |
---|
[2] | 785 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 786 | { |
---|
| 787 | } |
---|
| 788 | else |
---|
| 789 | { |
---|
[56] | 790 | UInt uiQtRootCbf = 1; |
---|
| 791 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
| 792 | { |
---|
[608] | 793 | m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf ); |
---|
[2] | 794 | } |
---|
[56] | 795 | if ( !uiQtRootCbf ) |
---|
| 796 | { |
---|
| 797 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
| 798 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 799 | return; |
---|
| 800 | } |
---|
[2] | 801 | |
---|
| 802 | } |
---|
[872] | 803 | |
---|
| 804 | Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); |
---|
| 805 | |
---|
| 806 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU ); |
---|
[608] | 807 | } |
---|
[189] | 808 | |
---|
[655] | 809 | #if H_3D_INTER_SDC |
---|
[833] | 810 | Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 811 | { |
---|
| 812 | pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth ); |
---|
| 813 | |
---|
[1124] | 814 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || |
---|
| 815 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) ) |
---|
[833] | 816 | { |
---|
| 817 | return; |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
| 821 | { |
---|
| 822 | return; |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
---|
| 826 | m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 827 | } |
---|
[189] | 828 | #endif |
---|
[833] | 829 | #if H_3D_DBBP |
---|
| 830 | Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 831 | { |
---|
| 832 | m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 833 | } |
---|
| 834 | #endif |
---|
[189] | 835 | |
---|
[56] | 836 | //! \} |
---|