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