[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 | |
---|
| 74 | if (pcCU->isIntra(uiAbsPartIdx) || (pcCU->getSlice()->getViewId() == 0) || pcCU->getSlice()->getSPS()->isDepth()) |
---|
| 75 | { |
---|
| 76 | return; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | if(!pcCU->getSlice()->getApplyIC()) |
---|
| 80 | return; |
---|
| 81 | |
---|
| 82 | if(pcCU->isICFlagRequired(uiAbsPartIdx)) |
---|
| 83 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 84 | } |
---|
| 85 | #endif |
---|
[2] | 86 | /** decode merge index |
---|
| 87 | * \param pcCU |
---|
| 88 | * \param uiPartIdx |
---|
| 89 | * \param uiAbsPartIdx |
---|
| 90 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
| 91 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
| 92 | * \param uiDepth |
---|
| 93 | * \returns Void |
---|
| 94 | */ |
---|
| 95 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ) |
---|
| 96 | { |
---|
| 97 | UInt uiMergeIndex = 0; |
---|
[56] | 98 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
[2] | 99 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 100 | } |
---|
| 101 | |
---|
[5] | 102 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 103 | Void |
---|
| 104 | TDecEntropy::decodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ) |
---|
| 105 | { |
---|
| 106 | Bool bResPredAvailable = false; |
---|
| 107 | Bool bResPredFlag = false; |
---|
| 108 | |
---|
| 109 | Bool bResPredAllowed = (!pcCU->getSlice()->getSPS()->isDepth () ); |
---|
| 110 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getViewId () ); |
---|
| 111 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
| 112 | bResPredAllowed = bResPredAllowed && (!pcCU->isIntra ( uiAbsPartIdx ) ); |
---|
| 113 | |
---|
| 114 | // check if supported |
---|
| 115 | if( bResPredAllowed ) |
---|
| 116 | { |
---|
[77] | 117 | bResPredAvailable = pcSubCU->getResidualSamples( uiPUIdx |
---|
| 118 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
| 119 | , false |
---|
| 120 | #endif |
---|
| 121 | ); |
---|
[2] | 122 | } |
---|
| 123 | |
---|
| 124 | // read from bitstream |
---|
| 125 | if( bResPredAvailable ) |
---|
| 126 | { |
---|
[77] | 127 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
[100] | 128 | Int iPUResiPredShift[4]; |
---|
| 129 | pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx); |
---|
| 130 | if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0 || iPUResiPredShift[2] >= 0 || iPUResiPredShift[3] >= 0 ) |
---|
[77] | 131 | #endif |
---|
[2] | 132 | m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth ); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | // set data |
---|
| 136 | pcCU->setResPredAvailSubParts ( bResPredAvailable, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 137 | pcCU->setResPredFlagSubParts ( bResPredFlag, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
| 138 | } |
---|
[5] | 139 | #endif |
---|
[2] | 140 | |
---|
| 141 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 142 | { |
---|
| 143 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 147 | { |
---|
| 148 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[189] | 149 | |
---|
| 150 | #if RWTH_SDC_DLT_B0036 |
---|
| 151 | // if B-Slice, code SDC flag later |
---|
| 152 | if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->isDepth() ) |
---|
| 153 | { |
---|
| 154 | // decode SDC flag |
---|
| 155 | decodeSDCFlag(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 156 | } |
---|
| 157 | #endif |
---|
[2] | 158 | } |
---|
| 159 | |
---|
| 160 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 161 | { |
---|
[189] | 162 | #if RWTH_SDC_DLT_B0036 |
---|
| 163 | if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
| 164 | { |
---|
| 165 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 166 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 167 | return; |
---|
| 168 | } |
---|
| 169 | #endif |
---|
| 170 | |
---|
[2] | 171 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[189] | 172 | |
---|
| 173 | #if RWTH_SDC_DLT_B0036 |
---|
| 174 | if( pcCU->getSlice()->isInterB() && pcCU->getSlice()->getSPS()->isDepth() && pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 175 | { |
---|
| 176 | // decode SDC flag |
---|
| 177 | decodeSDCFlag(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 178 | |
---|
| 179 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
| 180 | { |
---|
| 181 | // part size is also known for SDC intra |
---|
| 182 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 183 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | #endif |
---|
[2] | 187 | } |
---|
| 188 | |
---|
| 189 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 190 | { |
---|
[189] | 191 | #if RWTH_SDC_DLT_B0036 |
---|
| 192 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
| 193 | { |
---|
| 194 | decodeSDCPredMode(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 195 | return; |
---|
| 196 | } |
---|
| 197 | #endif |
---|
| 198 | |
---|
[2] | 199 | PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 200 | |
---|
| 201 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
| 202 | { |
---|
| 203 | if( eMode == SIZE_NxN ) // if it is NxN size, encode 4 intra directions. |
---|
| 204 | { |
---|
| 205 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
| 206 | // 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. |
---|
| 207 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
| 208 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); |
---|
| 209 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); |
---|
| 210 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); |
---|
| 211 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 212 | } |
---|
| 213 | else // if it is not NxN size, encode 1 intra directions |
---|
| 214 | { |
---|
| 215 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 216 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | else // if it is Inter mode, encode motion vector and reference index |
---|
| 220 | { |
---|
[56] | 221 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
| 222 | } |
---|
| 223 | } |
---|
[2] | 224 | |
---|
[56] | 225 | /** Parse I_PCM information. |
---|
| 226 | * \param pcCU pointer to CUpointer to CU |
---|
| 227 | * \param uiAbsPartIdx CU index |
---|
| 228 | * \param uiDepth CU depth |
---|
| 229 | * \returns Void |
---|
| 230 | */ |
---|
| 231 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 232 | { |
---|
| 233 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
| 234 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
| 235 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
| 236 | { |
---|
| 237 | return; |
---|
[2] | 238 | } |
---|
[56] | 239 | |
---|
[189] | 240 | #if RWTH_SDC_DLT_B0036 |
---|
| 241 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
| 242 | { |
---|
| 243 | return; |
---|
| 244 | } |
---|
| 245 | #endif |
---|
| 246 | |
---|
[56] | 247 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
[2] | 248 | } |
---|
| 249 | |
---|
| 250 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 251 | { |
---|
| 252 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 256 | { |
---|
| 257 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 258 | } |
---|
| 259 | |
---|
[56] | 260 | /** decode motion information for every PU block. |
---|
[2] | 261 | * \param pcCU |
---|
| 262 | * \param uiAbsPartIdx |
---|
| 263 | * \param uiDepth |
---|
| 264 | * \param pcSubCU |
---|
| 265 | * \returns Void |
---|
| 266 | */ |
---|
| 267 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
| 268 | { |
---|
| 269 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 270 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
| 271 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
| 272 | |
---|
[56] | 273 | #if CU_BASED_MRG_CAND_LIST |
---|
| 274 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 275 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 276 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 277 | for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ui++ ) |
---|
| 278 | #else |
---|
| 279 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 280 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
| 281 | for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
| 282 | #endif |
---|
| 283 | { |
---|
| 284 | uhInterDirNeighbours[ui] = 0; |
---|
| 285 | } |
---|
| 286 | Int numValidMergeCand = 0; |
---|
| 287 | bool isMerged = false; |
---|
| 288 | #endif |
---|
| 289 | |
---|
[2] | 290 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
| 291 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
| 292 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
| 293 | { |
---|
[56] | 294 | #if !CU_BASED_MRG_CAND_LIST |
---|
| 295 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 296 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
| 297 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
| 298 | Int numValidMergeCand = 0; |
---|
| 299 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
| 300 | #else |
---|
[2] | 301 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
| 302 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
[56] | 303 | Int numValidMergeCand = 0; |
---|
[2] | 304 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
[56] | 305 | #endif |
---|
[2] | 306 | { |
---|
| 307 | uhInterDirNeighbours[ui] = 0; |
---|
| 308 | } |
---|
| 309 | #endif |
---|
| 310 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 311 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
| 312 | { |
---|
| 313 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
[56] | 314 | #if CU_BASED_MRG_CAND_LIST |
---|
| 315 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
| 316 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
[2] | 317 | { |
---|
[56] | 318 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
| 319 | if ( !isMerged ) |
---|
[2] | 320 | { |
---|
[56] | 321 | pcSubCU->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 322 | isMerged = true; |
---|
[2] | 323 | } |
---|
[56] | 324 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
| 325 | } |
---|
| 326 | else |
---|
| 327 | { |
---|
| 328 | #if SIMP_MRG_PRUN |
---|
| 329 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
| 330 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
| 331 | #else |
---|
| 332 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 333 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
| 334 | #endif |
---|
| 335 | } |
---|
| 336 | #else |
---|
| 337 | #if SIMP_MRG_PRUN |
---|
| 338 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
[231] | 339 | #if MERL_VSP_C0152 |
---|
| 340 | Int iVSPIndexTrue[3] = {-1, -1, -1}; |
---|
| 341 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, iVSPIndexTrue, uiMergeIndex ); |
---|
| 342 | |
---|
| 343 | if(pcCU->getTextureModeDepth( uiSubPartIdx ) == uiDepth)//MPI is used |
---|
| 344 | { |
---|
| 345 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 346 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 347 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
| 348 | { |
---|
| 349 | Int vspIdx = pcTextureCU->getVSPIndex( uiAbsPartIdx + ui); |
---|
| 350 | pcCU->setVSPIndex( uiAbsPartIdx + ui, vspIdx); |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | else // MPI not used |
---|
| 354 | { |
---|
| 355 | Int iVSPIdx = 0; |
---|
| 356 | Int numVspIdx; |
---|
| 357 | numVspIdx = 3; |
---|
| 358 | for (Int i = 0; i < numVspIdx; i++) |
---|
| 359 | { |
---|
| 360 | if (iVSPIndexTrue[i] == uiMergeIndex) |
---|
| 361 | { |
---|
| 362 | iVSPIdx = i+1; |
---|
| 363 | break; |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | pcCU->setVSPIndexSubParts( iVSPIdx, uiSubPartIdx, uiPartIdx, uiDepth ); //Initialize the VSP, may change later in get InterMergeCandidates() |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | #else |
---|
[56] | 370 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
[231] | 371 | #endif |
---|
[56] | 372 | #else |
---|
| 373 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
| 374 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
| 375 | #endif |
---|
| 376 | #endif |
---|
| 377 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
| 378 | |
---|
| 379 | TComMv cTmpMv( 0, 0 ); |
---|
| 380 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 381 | { |
---|
| 382 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
[2] | 383 | { |
---|
[56] | 384 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 385 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
| 386 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 387 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 388 | |
---|
[2] | 389 | } |
---|
| 390 | } |
---|
[56] | 391 | } |
---|
| 392 | else |
---|
| 393 | { |
---|
[2] | 394 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
| 395 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
| 396 | { |
---|
| 397 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
| 398 | { |
---|
| 399 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 400 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 401 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
| 402 | } |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | return; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | /** decode inter direction for a PU block |
---|
| 410 | * \param pcCU |
---|
| 411 | * \param uiAbsPartIdx |
---|
| 412 | * \param uiDepth |
---|
| 413 | * \param uiPartIdx |
---|
| 414 | * \returns Void |
---|
| 415 | */ |
---|
| 416 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
| 417 | { |
---|
| 418 | UInt uiInterDir; |
---|
| 419 | |
---|
| 420 | if ( pcCU->getSlice()->isInterP() ) |
---|
| 421 | { |
---|
| 422 | uiInterDir = 1; |
---|
| 423 | } |
---|
| 424 | else |
---|
| 425 | { |
---|
| 426 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 433 | { |
---|
| 434 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3) |
---|
| 435 | { |
---|
| 436 | if(eRefList == REF_PIC_LIST_1) |
---|
| 437 | { |
---|
| 438 | return; |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | Int iRefFrmIdx = 0; |
---|
| 442 | Int iRefFrmIdxTemp; |
---|
| 443 | UInt uiInterDir; |
---|
| 444 | RefPicList eRefListTemp; |
---|
| 445 | |
---|
| 446 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 447 | |
---|
| 448 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
| 449 | { |
---|
| 450 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
[56] | 451 | } |
---|
| 452 | else |
---|
| 453 | { |
---|
[2] | 454 | iRefFrmIdx=0; |
---|
| 455 | } |
---|
| 456 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
| 457 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
| 458 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
| 459 | |
---|
[56] | 460 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 461 | |
---|
| 462 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
| 463 | } |
---|
| 464 | else |
---|
| 465 | { |
---|
[56] | 466 | Int iRefFrmIdx = 0; |
---|
| 467 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
[2] | 468 | |
---|
[56] | 469 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
| 470 | { |
---|
| 471 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
| 472 | } |
---|
| 473 | else if ( !iParseRefFrmIdx ) |
---|
| 474 | { |
---|
| 475 | iRefFrmIdx = NOT_VALID; |
---|
| 476 | } |
---|
| 477 | else |
---|
| 478 | { |
---|
| 479 | iRefFrmIdx = 0; |
---|
| 480 | } |
---|
[2] | 481 | |
---|
[56] | 482 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
| 483 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
[2] | 484 | } |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | /** decode motion vector difference for a PU block |
---|
| 488 | * \param pcCU |
---|
| 489 | * \param uiAbsPartIdx |
---|
| 490 | * \param uiDepth |
---|
| 491 | * \param uiPartIdx |
---|
| 492 | * \param eRefList |
---|
| 493 | * \returns Void |
---|
| 494 | */ |
---|
| 495 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 496 | { |
---|
| 497 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
| 498 | { |
---|
| 499 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
| 504 | { |
---|
[56] | 505 | Int iMVPIdx = -1; |
---|
[2] | 506 | |
---|
| 507 | TComMv cZeroMv( 0, 0 ); |
---|
| 508 | TComMv cMv = cZeroMv; |
---|
| 509 | Int iRefIdx = -1; |
---|
| 510 | |
---|
| 511 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
| 512 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
| 513 | |
---|
| 514 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
| 515 | cMv = cZeroMv; |
---|
[56] | 516 | |
---|
| 517 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
| 518 | { |
---|
| 519 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
| 520 | const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcSubCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); |
---|
| 521 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx, iNumAMVPCands ); |
---|
| 522 | #else |
---|
| 523 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
| 524 | #endif |
---|
| 525 | } |
---|
[189] | 526 | #if SHARP_INTERVIEW_DECOUPLE_B0111 |
---|
| 527 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo, iMVPIdx); |
---|
| 528 | #else |
---|
[2] | 529 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
[189] | 530 | #endif |
---|
[2] | 531 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
| 532 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
| 533 | if ( iRefIdx >= 0 ) |
---|
| 534 | { |
---|
| 535 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
| 536 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
[56] | 540 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
[2] | 541 | } |
---|
| 542 | |
---|
[56] | 543 | #if UNIFIED_TRANSFORM_TREE |
---|
| 544 | 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 ) |
---|
| 545 | #else |
---|
| 546 | Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ) |
---|
| 547 | #endif |
---|
[2] | 548 | { |
---|
[56] | 549 | UInt uiSubdiv; |
---|
| 550 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
| 551 | |
---|
| 552 | #if UNIFIED_TRANSFORM_TREE |
---|
| 553 | if(uiTrIdx==0) |
---|
| 554 | { |
---|
| 555 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
| 556 | } |
---|
| 557 | if( uiLog2TrafoSize == 2 ) |
---|
| 558 | { |
---|
| 559 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 560 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
| 561 | { |
---|
| 562 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 563 | m_uiBakChromaOffset = offsetChroma; |
---|
| 564 | } |
---|
| 565 | } |
---|
| 566 | #endif // UNIFIED_TRANSFORM_TREE |
---|
| 567 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
| 568 | { |
---|
| 569 | uiSubdiv = 1; |
---|
| 570 | } |
---|
| 571 | #if G519_TU_AMP_NSQT_HARMONIZATION |
---|
| 572 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
| 573 | #else |
---|
| 574 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
| 575 | #endif |
---|
| 576 | { |
---|
| 577 | uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx)); |
---|
| 578 | } |
---|
| 579 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
| 580 | { |
---|
| 581 | uiSubdiv = 1; |
---|
| 582 | } |
---|
| 583 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
| 584 | { |
---|
| 585 | uiSubdiv = 0; |
---|
| 586 | } |
---|
| 587 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
| 588 | { |
---|
| 589 | uiSubdiv = 0; |
---|
| 590 | } |
---|
| 591 | else |
---|
| 592 | { |
---|
| 593 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
| 594 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth ); |
---|
| 595 | } |
---|
[2] | 596 | |
---|
[56] | 597 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
[2] | 598 | |
---|
[56] | 599 | if( uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
[2] | 600 | { |
---|
[56] | 601 | const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0; |
---|
| 602 | if( bFirstCbfOfCU ) |
---|
[2] | 603 | { |
---|
[56] | 604 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 605 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
[2] | 606 | } |
---|
[56] | 607 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
[2] | 608 | { |
---|
[56] | 609 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
[2] | 610 | { |
---|
[56] | 611 | if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
[2] | 612 | { |
---|
[56] | 613 | uiUCbfFront3++; |
---|
| 614 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 615 | //printf( " \nsave bits, U Cbf"); |
---|
[2] | 616 | } |
---|
[56] | 617 | else |
---|
[2] | 618 | { |
---|
[56] | 619 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
| 620 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
[2] | 621 | } |
---|
| 622 | } |
---|
[56] | 623 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
[2] | 624 | { |
---|
[56] | 625 | if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
[2] | 626 | { |
---|
[56] | 627 | uiVCbfFront3++; |
---|
| 628 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
| 629 | //printf( " \nsave bits, V Cbf"); |
---|
[2] | 630 | } |
---|
[56] | 631 | else |
---|
[2] | 632 | { |
---|
[56] | 633 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
| 634 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
[2] | 635 | } |
---|
| 636 | } |
---|
| 637 | } |
---|
[56] | 638 | else |
---|
[2] | 639 | { |
---|
[56] | 640 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
| 641 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
| 642 | if ( uiLog2TrafoSize == 2 ) |
---|
[2] | 643 | { |
---|
[56] | 644 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
| 645 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
[2] | 646 | } |
---|
| 647 | } |
---|
| 648 | } |
---|
| 649 | |
---|
[56] | 650 | if( uiSubdiv ) |
---|
[2] | 651 | { |
---|
[56] | 652 | #if UNIFIED_TRANSFORM_TREE |
---|
| 653 | UInt size; |
---|
| 654 | width >>= 1; |
---|
| 655 | height >>= 1; |
---|
| 656 | size = width*height; |
---|
| 657 | uiTrIdx++; |
---|
| 658 | #endif |
---|
| 659 | ++uiDepth; |
---|
| 660 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 661 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
| 662 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 663 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode ); |
---|
| 664 | UInt uiYCbf = 0; |
---|
| 665 | UInt uiUCbf = 0; |
---|
| 666 | UInt uiVCbf = 0; |
---|
| 667 | |
---|
| 668 | UInt uiCurrentCbfY = 0; |
---|
| 669 | UInt uiCurrentCbfU = 0; |
---|
| 670 | UInt uiCurrentCbfV = 0; |
---|
| 671 | |
---|
| 672 | for( Int i = 0; i < 4; i++ ) |
---|
[2] | 673 | { |
---|
[56] | 674 | #if UNIFIED_TRANSFORM_TREE |
---|
| 675 | UInt nsAddr = 0; |
---|
| 676 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 ); |
---|
| 677 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
| 678 | #else |
---|
| 679 | UInt nsAddr = 0; |
---|
| 680 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 ); |
---|
| 681 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV ); |
---|
| 682 | #endif |
---|
| 683 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
| 684 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode ); |
---|
| 685 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode ); |
---|
| 686 | uiAbsPartIdx += uiQPartNum; |
---|
| 687 | #if UNIFIED_TRANSFORM_TREE |
---|
| 688 | offsetLuma += size; offsetChroma += (size>>2); |
---|
| 689 | #endif |
---|
[2] | 690 | } |
---|
[56] | 691 | |
---|
| 692 | uiYCbfFront3 += uiCurrentCbfY; |
---|
| 693 | uiUCbfFront3 += uiCurrentCbfU; |
---|
| 694 | uiVCbfFront3 += uiCurrentCbfV; |
---|
| 695 | |
---|
| 696 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
| 697 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
| 698 | { |
---|
| 699 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode; |
---|
| 700 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode; |
---|
| 701 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode; |
---|
| 702 | } |
---|
[2] | 703 | } |
---|
| 704 | else |
---|
| 705 | { |
---|
[56] | 706 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 707 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
| 708 | |
---|
[2] | 709 | { |
---|
[56] | 710 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
| 711 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
| 712 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
| 713 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
| 714 | DTRACE_CABAC_V( uiDepth ); |
---|
| 715 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
| 716 | DTRACE_CABAC_V( uiTrDepth ); |
---|
| 717 | DTRACE_CABAC_T( "\n" ); |
---|
[2] | 718 | } |
---|
[56] | 719 | |
---|
| 720 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 721 | pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
| 722 | if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) ) |
---|
[2] | 723 | { |
---|
[56] | 724 | pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode ); |
---|
[2] | 725 | } |
---|
[56] | 726 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 727 | 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] | 728 | { |
---|
[56] | 729 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
[2] | 730 | } |
---|
[56] | 731 | else |
---|
[2] | 732 | { |
---|
[56] | 733 | const UInt uiLog2CUSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - pcCU->getDepth( uiAbsPartIdx ); |
---|
| 734 | if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 |
---|
| 735 | && ( uiLog2CUSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() + 1 || uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) ) |
---|
[2] | 736 | { |
---|
[56] | 737 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
| 738 | //printf( " \nsave bits, Y Cbf"); |
---|
| 739 | uiYCbfFront3++; |
---|
[2] | 740 | } |
---|
[56] | 741 | else |
---|
[2] | 742 | { |
---|
[56] | 743 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth ); |
---|
| 744 | uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
[2] | 745 | } |
---|
| 746 | } |
---|
[56] | 747 | #if UNIFIED_TRANSFORM_TREE |
---|
| 748 | // transform_unit begin |
---|
| 749 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
| 750 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 751 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 752 | if( uiLog2TrafoSize == 2 ) |
---|
[2] | 753 | { |
---|
[56] | 754 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 755 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 756 | { |
---|
[56] | 757 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 758 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
[2] | 759 | } |
---|
| 760 | } |
---|
[56] | 761 | if ( cbfY || cbfU || cbfV ) |
---|
[2] | 762 | { |
---|
[56] | 763 | // dQP: only for LCU |
---|
| 764 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 765 | { |
---|
[56] | 766 | if ( bCodeDQP ) |
---|
[2] | 767 | { |
---|
[56] | 768 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
| 769 | bCodeDQP = false; |
---|
[2] | 770 | } |
---|
| 771 | } |
---|
| 772 | } |
---|
[56] | 773 | if( cbfY ) |
---|
[2] | 774 | { |
---|
[56] | 775 | Int trWidth = width; |
---|
| 776 | Int trHeight = height; |
---|
| 777 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 778 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
[2] | 779 | } |
---|
[56] | 780 | if( uiLog2TrafoSize > 2 ) |
---|
[2] | 781 | { |
---|
[56] | 782 | Int trWidth = width >> 1; |
---|
| 783 | Int trHeight = height >> 1; |
---|
| 784 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 785 | if( cbfU ) |
---|
[2] | 786 | { |
---|
[56] | 787 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 788 | } |
---|
[56] | 789 | if( cbfV ) |
---|
[2] | 790 | { |
---|
[56] | 791 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 792 | } |
---|
| 793 | } |
---|
| 794 | else |
---|
| 795 | { |
---|
[56] | 796 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 797 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
[2] | 798 | { |
---|
[56] | 799 | Int trWidth = width; |
---|
| 800 | Int trHeight = height; |
---|
| 801 | pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 802 | if( cbfU ) |
---|
[2] | 803 | { |
---|
[56] | 804 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
[2] | 805 | } |
---|
[56] | 806 | if( cbfV ) |
---|
[2] | 807 | { |
---|
[56] | 808 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
[2] | 809 | } |
---|
| 810 | } |
---|
| 811 | } |
---|
[56] | 812 | // transform_unit end |
---|
| 813 | #endif // UNIFIED_TRANSFORM_TREE |
---|
[2] | 814 | } |
---|
| 815 | } |
---|
| 816 | |
---|
[56] | 817 | #if !UNIFIED_TRANSFORM_TREE |
---|
[2] | 818 | Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 819 | { |
---|
[56] | 820 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
[2] | 821 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
| 822 | DTRACE_CABAC_V( uiDepth ) |
---|
| 823 | DTRACE_CABAC_T( "\n" ) |
---|
| 824 | UInt temp = 0; |
---|
| 825 | UInt temp1 = 0; |
---|
| 826 | UInt temp2 = 0; |
---|
[56] | 827 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 ); |
---|
[2] | 828 | } |
---|
[56] | 829 | #endif // UNIFIED_TRANSFORM_TREE |
---|
[2] | 830 | |
---|
[56] | 831 | #if UNIFIED_TRANSFORM_TREE |
---|
| 832 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
| 833 | { |
---|
| 834 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
| 835 | { |
---|
| 836 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | #else |
---|
[2] | 840 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 841 | { |
---|
[56] | 842 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 843 | { |
---|
| 844 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 845 | } |
---|
| 846 | } |
---|
[56] | 847 | #endif |
---|
[2] | 848 | |
---|
[56] | 849 | #if !UNIFIED_TRANSFORM_TREE |
---|
| 850 | Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP ) |
---|
[2] | 851 | { |
---|
[56] | 852 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
| 853 | UInt uiCbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ); |
---|
| 854 | UInt uiCbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 855 | UInt uiCbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 856 | if( uiLog2TrSize == 2 ) |
---|
| 857 | { |
---|
| 858 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
| 859 | if( ( uiAbsPartIdx % uiQPDiv ) == 0 ) |
---|
| 860 | { |
---|
| 861 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
| 862 | m_uiBakChromaOffset = uiChromaOffset; |
---|
| 863 | } |
---|
| 864 | else if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) ) |
---|
| 865 | { |
---|
| 866 | uiCbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
| 867 | uiCbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
| 868 | } |
---|
| 869 | } |
---|
[2] | 870 | |
---|
[56] | 871 | if ( uiCbfY || uiCbfU || uiCbfV ) |
---|
[2] | 872 | { |
---|
| 873 | // dQP: only for LCU |
---|
[56] | 874 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
[2] | 875 | { |
---|
[56] | 876 | if ( bCodeDQP ) |
---|
[2] | 877 | { |
---|
[56] | 878 | decodeQP( pcCU, uiAbsPartIdx, uiDepth); |
---|
| 879 | bCodeDQP = false; |
---|
[2] | 880 | } |
---|
| 881 | } |
---|
| 882 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
| 883 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
[56] | 884 | const UInt uiStopTrMode = uiLumaTrMode; |
---|
[2] | 885 | |
---|
| 886 | if( uiTrIdx == uiStopTrMode ) |
---|
| 887 | { |
---|
[56] | 888 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ) ) |
---|
[2] | 889 | { |
---|
[56] | 890 | Int trWidth = uiWidth; |
---|
| 891 | Int trHeight = uiHeight; |
---|
| 892 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 893 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+uiLumaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
| 894 | } |
---|
| 895 | |
---|
| 896 | uiWidth >>= 1; |
---|
| 897 | uiHeight >>= 1; |
---|
| 898 | |
---|
| 899 | if( uiLog2TrSize == 2 ) |
---|
| 900 | { |
---|
[2] | 901 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
[56] | 902 | if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) ) |
---|
[2] | 903 | { |
---|
[56] | 904 | uiWidth <<= 1; |
---|
| 905 | uiHeight <<= 1; |
---|
| 906 | Int trWidth = uiWidth; |
---|
| 907 | Int trHeight = uiHeight; |
---|
| 908 | pcCU->getNSQTSize( uiTrIdx-1, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 909 | if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) ) |
---|
| 910 | { |
---|
| 911 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
| 912 | } |
---|
| 913 | if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) ) |
---|
| 914 | { |
---|
| 915 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
| 916 | } |
---|
[2] | 917 | } |
---|
| 918 | } |
---|
[56] | 919 | else |
---|
| 920 | { |
---|
| 921 | Int trWidth = uiWidth; |
---|
| 922 | Int trHeight = uiHeight; |
---|
| 923 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
| 924 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) ) |
---|
| 925 | { |
---|
| 926 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
| 927 | } |
---|
| 928 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) ) |
---|
| 929 | { |
---|
| 930 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
| 931 | } |
---|
| 932 | } |
---|
[2] | 933 | } |
---|
| 934 | else |
---|
| 935 | { |
---|
| 936 | { |
---|
[56] | 937 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 938 | DTRACE_CABAC_T( "\tgoing down\tdepth=" ); |
---|
| 939 | DTRACE_CABAC_V( uiDepth ); |
---|
| 940 | DTRACE_CABAC_T( "\ttridx=" ); |
---|
| 941 | DTRACE_CABAC_V( uiTrIdx ); |
---|
| 942 | DTRACE_CABAC_T( "\n" ); |
---|
| 943 | } |
---|
| 944 | if( uiCurrTrIdx <= uiTrIdx ) |
---|
[56] | 945 | { |
---|
[2] | 946 | assert(1); |
---|
[56] | 947 | } |
---|
[2] | 948 | UInt uiSize; |
---|
| 949 | uiWidth >>= 1; |
---|
| 950 | uiHeight >>= 1; |
---|
| 951 | uiSize = uiWidth*uiHeight; |
---|
| 952 | uiDepth++; |
---|
| 953 | uiTrIdx++; |
---|
| 954 | |
---|
| 955 | UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
| 956 | UInt uiIdx = uiAbsPartIdx; |
---|
| 957 | |
---|
[56] | 958 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
| 959 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
| 960 | |
---|
| 961 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
| 962 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
| 963 | |
---|
| 964 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
| 965 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
| 966 | |
---|
| 967 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
[2] | 968 | { |
---|
[56] | 969 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
[2] | 970 | DTRACE_CABAC_T( "\tgoing up\n" ); |
---|
| 971 | } |
---|
| 972 | } |
---|
| 973 | } |
---|
| 974 | } |
---|
[56] | 975 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
[2] | 976 | |
---|
| 977 | /** decode coefficients |
---|
| 978 | * \param pcCU |
---|
| 979 | * \param uiAbsPartIdx |
---|
| 980 | * \param uiDepth |
---|
| 981 | * \param uiWidth |
---|
| 982 | * \param uiHeight |
---|
| 983 | * \returns Void |
---|
| 984 | */ |
---|
[56] | 985 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
[2] | 986 | { |
---|
| 987 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
| 988 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
| 989 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
[56] | 990 | #if UNIFIED_TRANSFORM_TREE |
---|
| 991 | UInt temp = 0; |
---|
| 992 | UInt temp1 = 0; |
---|
| 993 | UInt temp2 = 0; |
---|
| 994 | #else |
---|
[2] | 995 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
[56] | 996 | #endif |
---|
[2] | 997 | |
---|
[189] | 998 | #if RWTH_SDC_DLT_B0036 |
---|
| 999 | if( pcCU->getSDCAvailable(uiAbsPartIdx) && pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
| 1000 | { |
---|
| 1001 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 1002 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
| 1003 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
| 1004 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
| 1005 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
| 1006 | |
---|
| 1007 | decodeSDCResidualData(pcCU, uiAbsPartIdx, uiDepth); |
---|
| 1008 | return; |
---|
| 1009 | } |
---|
| 1010 | #endif |
---|
| 1011 | |
---|
[2] | 1012 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
| 1013 | { |
---|
[56] | 1014 | #if !UNIFIED_TRANSFORM_TREE |
---|
[2] | 1015 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
| 1016 | |
---|
| 1017 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
| 1018 | |
---|
[56] | 1019 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
[2] | 1020 | } |
---|
| 1021 | else |
---|
| 1022 | { |
---|
[56] | 1023 | UInt uiQtRootCbf = 1; |
---|
[5] | 1024 | #if HHI_MPI |
---|
[56] | 1025 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && |
---|
| 1026 | ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) ) |
---|
[2] | 1027 | #else |
---|
[56] | 1028 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
[2] | 1029 | #endif |
---|
[56] | 1030 | { |
---|
[2] | 1031 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
| 1032 | } |
---|
[56] | 1033 | if ( !uiQtRootCbf ) |
---|
| 1034 | { |
---|
| 1035 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
| 1036 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
| 1037 | pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth ); |
---|
| 1038 | return; |
---|
| 1039 | } |
---|
[2] | 1040 | |
---|
[56] | 1041 | #if !UNIFIED_TRANSFORM_TREE |
---|
[2] | 1042 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
| 1043 | |
---|
| 1044 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
[56] | 1045 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
[2] | 1046 | } |
---|
[189] | 1047 | |
---|
| 1048 | #if FIX_MPI_B0065 |
---|
| 1049 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ) |
---|
| 1050 | { |
---|
| 1051 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
| 1052 | if( uiDepth == pcTextureCU->getDepth(uiAbsPartIdx)) |
---|
| 1053 | { |
---|
| 1054 | PartSize partSize = pcTextureCU->getPartitionSize(uiAbsPartIdx); |
---|
| 1055 | pcCU->setPartSizeSubParts( partSize, uiAbsPartIdx, uiDepth ); |
---|
| 1056 | } |
---|
| 1057 | else |
---|
| 1058 | { |
---|
| 1059 | pcCU->setPartSizeSubParts( SIZE_NxN, uiAbsPartIdx, uiDepth ); |
---|
| 1060 | } |
---|
| 1061 | } |
---|
| 1062 | #endif |
---|
| 1063 | |
---|
[56] | 1064 | #if UNIFIED_TRANSFORM_TREE |
---|
| 1065 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP ); |
---|
| 1066 | #else // UNIFIED_TRANSFORM_TREE |
---|
| 1067 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP ); |
---|
| 1068 | #endif // UNIFIED_TRANSFORM_TREE |
---|
[189] | 1069 | |
---|
| 1070 | #if FIX_MPI_B0065 |
---|
| 1071 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER && pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getMergeIndex( uiAbsPartIdx ) == 0 && pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N && pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ) |
---|
| 1072 | { |
---|
| 1073 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
| 1074 | } |
---|
| 1075 | #endif |
---|
[2] | 1076 | } |
---|
| 1077 | |
---|
[189] | 1078 | #if RWTH_SDC_DLT_B0036 |
---|
| 1079 | Void TDecEntropy::decodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1080 | { |
---|
| 1081 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 1082 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
| 1083 | |
---|
| 1084 | m_pcEntropyDecoderIf->parseSDCPredMode(pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 1085 | } |
---|
| 1086 | |
---|
| 1087 | Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1088 | { |
---|
| 1089 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 1090 | |
---|
| 1091 | m_pcEntropyDecoderIf->parseSDCFlag(pcCU, uiAbsPartIdx, uiDepth ); |
---|
| 1092 | } |
---|
| 1093 | |
---|
| 1094 | Void TDecEntropy::decodeSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1095 | { |
---|
| 1096 | assert( pcCU->getSlice()->getSPS()->isDepth() ); |
---|
| 1097 | assert( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
| 1098 | |
---|
| 1099 | // number of segments depends on prediction mode for INTRA |
---|
| 1100 | UInt uiNumSegments = 2; |
---|
| 1101 | UInt uiLumaPredMode = pcCU->getLumaIntraDir( uiAbsPartIdx ); |
---|
| 1102 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && (uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX) ) |
---|
| 1103 | uiNumSegments = 1; |
---|
| 1104 | |
---|
| 1105 | // decode residual data for each segment |
---|
| 1106 | for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ ) |
---|
| 1107 | m_pcEntropyDecoderIf->parseSDCResidualData(pcCU, uiAbsPartIdx, uiDepth, uiSeg); |
---|
| 1108 | } |
---|
| 1109 | #endif |
---|
| 1110 | |
---|
[56] | 1111 | //! \} |
---|