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