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