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