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