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