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