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