source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1200

Last change on this file since 1200 was 1200, checked in by tech, 9 years ago

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
  • Property svn:eol-style set to native
File size: 37.4 KB
RevLine 
[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
[1200]4 * granted under this license.
[5]5 *
[1200]6 * Copyright (c) 2010-2015, 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"
[1200]39#include "TLibCommon/TComTU.h"
40#include "TLibCommon/TComPrediction.h"
[2]41
[1200]42#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
43#include "../TLibCommon/Debug.h"
44static const Bool bDebugRQT = DebugOptionList::DebugRQT.getInt()!=0;
45static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0;
46#endif
47
[56]48//! \ingroup TLibDecoder
49//! \{
50
[2]51Void TDecEntropy::setEntropyDecoder         ( TDecEntropyIf* p )
52{
53  m_pcEntropyDecoderIf = p;
54}
55
[56]56#include "TLibCommon/TComSampleAdaptiveOffset.h"
[2]57
58Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
59{
60  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
61}
[1196]62#if H_3D
[1179]63Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
64{
65  if( !pcCU->getSlice()->getDepthIntraSkipFlag() )
66  {
67    return;
68  } 
69
70  m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth );
71}
[1039]72#endif
[1179]73
[608]74Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
75{
76  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
77}
78
[1200]79
[2]80/** decode merge flag
81 * \param pcSubCU
[1200]82 * \param uiAbsPartIdx
[2]83 * \param uiDepth
[1200]84 * \param uiPUIdx
[2]85 * \returns Void
86 */
87Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
[1200]88{
[56]89  // at least one merge candidate exists
90  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
[2]91}
92
93/** decode merge index
94 * \param pcCU
[1200]95 * \param uiPartIdx
96 * \param uiAbsPartIdx
[2]97 * \param uiDepth
98 * \returns Void
99 */
[608]100Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
[2]101{
102  UInt uiMergeIndex = 0;
[608]103  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
[2]104  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
105}
106
[608]107#if H_3D_ARP
108Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
[443]109{
[608]110  if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
111  {
[443]112    return;
[608]113  }
114
115  if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
116  {
117    pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth );
118  }
[443]119  else
[608]120  {
[443]121    m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth );
[608]122  }
[443]123}
124#endif
[608]125
126#if H_3D_IC
127Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
128{
129  pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
130
[833]131  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
[608]132  {
133    return;
134  }
135
136  if( !pcCU->getSlice()->getApplyIC() )
137    return;
138
139  if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
140    m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth );
141}
142#endif
143
[2]144Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
145{
146  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
147}
148
149Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
150{
151  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
152}
153
154Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
155{
156  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
157}
158
159Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
160{
161  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
162  {
[608]163    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
[1196]164#if H_3D_DIM_SDC
[1200]165    decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );
[608]166    if(!pcCU->getSDCFlag(uiAbsPartIdx))
[443]167#endif
[1200]168    if (pcCU->getPic()->getChromaFormat()!=CHROMA_400)
169    {
170      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
171      if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN)
172      {
173        UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
174        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset,   uiDepth+1 );
175        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 );
176        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 );
177      }
178    }
[2]179  }
180  else                                                                // if it is Inter mode, encode motion vector and reference index
181  {
[56]182    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
183  }
184}
[2]185
[1200]186/** Parse I_PCM information.
[56]187 * \param pcCU  pointer to CUpointer to CU
188 * \param uiAbsPartIdx CU index
189 * \param uiDepth CU depth
190 * \returns Void
191 */
192Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
193{
194  if(!pcCU->getSlice()->getSPS()->getUsePCM()
195    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
196    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
197  {
198    return;
[2]199  }
[1200]200
[56]201  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
[2]202}
203
204Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
205{
206  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
207}
208
209Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
210{
211  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
[1200]212#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
213  if (bDebugPredEnabled)
214  {
215    UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx);
216    if (cdir==36)
217    {
218      cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx);
219    }
220    printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx));
221  }
222#endif
[2]223}
224
[1200]225
[56]226/** decode motion information for every PU block.
[2]227 * \param pcCU
[1200]228 * \param uiAbsPartIdx
[2]229 * \param uiDepth
230 * \param pcSubCU
231 * \returns Void
232 */
233Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
234{
235  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
236  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
[1200]237  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
[608]238#if H_3D_IV_MERGE
[56]239  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
240  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
241#else
242  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
243  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
244#endif
[773]245#if H_3D_SPIVMP
[1196]246  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];     
247  TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
248  UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
[724]249#endif
[1200]250#if H_3D_IV_MERGE
251  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
252#endif
[608]253  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
[56]254  {
255    uhInterDirNeighbours[ui] = 0;
256  }
257  Int numValidMergeCand = 0;
[1200]258  Bool hasMergedCandList = false;
[56]259
[2]260  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
261  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
[1196]262#if H_3D
[2]263  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
264  {
[608]265#if H_MV_ENC_DEC_TRAC
266    DTRACE_PU_S("=========== prediction_unit ===========\n")
267    // ToDo:
268    //DTRACE_PU("x0", uiLPelX)
269    //DTRACE_PU("x1", uiTPelY)
[56]270#endif
[1179]271
272    ////// Parse PUs syntax
[2]273    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
274    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
275    {
[1179]276      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );     
277    }
278    else
279    {
280      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
281      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
282      {       
283        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
284        {
285          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
286          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
287          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
288        }
289      }
290    }
291  }
292
293  ////// Parse CUs extension syntax
294  decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); 
295  decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth ); 
296
297#if H_3D_ARP
298  decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
299#endif
300#if H_3D_IC
301  decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
302#endif
303
304  ////// Decode motion vectors
305  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
306  {
307    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
308    {
309      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
310#if H_3D_DBBP
311      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
312#else
313      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
314#endif
315      {
316        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
317        if ( !isMerged )
318        {
319#if H_3D_VSP
320          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
321          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
322#if H_3D_SPIVMP
323          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
324#endif
325          pcSubCU->initAvailableFlags();
326          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
327          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
328#if H_3D_SPIVMP
329            , pcMvFieldSP, puhInterDirSP
330#endif
331            , numValidMergeCand );
332          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
333#if H_3D_SPIVMP
334            , bSPIVMPFlag
335#endif
336            , numValidMergeCand );
337          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
338
339#else
340#if H_3D
341          pcSubCU->initAvailableFlags();
342          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
343          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
344
345#else
346          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
347#endif
348#endif
349          isMerged = true;
350        }
351        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
352      }
353      else
354      {
355        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
356#if H_3D_VSP
357        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
358        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
359#if H_3D_SPIVMP
360        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
361#endif
362        pcSubCU->initAvailableFlags();
363        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
364        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
365#if H_3D_SPIVMP
366          , pcMvFieldSP, puhInterDirSP
367#endif
368          ,numValidMergeCand, uiMergeIndex );
369        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
370#if H_3D_SPIVMP
371          , bSPIVMPFlag
372#endif
373          ,numValidMergeCand );
374        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
375#else
376#if H_3D
377        pcSubCU->initAvailableFlags();
378        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
379        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
380#else
381        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
382#endif
383#endif
384      }
385      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
386
387      TComMv cTmpMv( 0, 0 );
388      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
389      {       
390        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
391        {
392          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
393          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
394          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
395          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
396#if H_3D_VSP
397#if H_3D_DBBP
398          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
399#else
400          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
401#endif
402          {
403            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
404            {
405              UInt dummy;
406              Int vspSize;
407              Int width, height;
408              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
409              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
410              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
411            }
412          }
413#endif
414        }
415      }
416#if H_3D_SPIVMP
417      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
418      if (bSPIVMPFlag[uiMergeIndex] != 0)
419      {
420        Int iWidth, iHeight;
421        UInt uiIdx;
422        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
423
424        UInt uiSPAddr;
425
426        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
427
428        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
429
430        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
431        {
432          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
433          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
434          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
435          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
436        }
437      }
438#endif
439    }
440    else
441    {
442      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
443      {       
444        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
445        {
446          decodeMvsAMVP   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
447        }
448      }
449    }
450
451    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
452    {
453      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
454      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
455      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
456    }
457  }
458#else
459  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
460  {
461#if H_MV_ENC_DEC_TRAC
462    DTRACE_PU_S("=========== prediction_unit ===========\n")
463    // ToDo:
464    //DTRACE_PU("x0", uiLPelX)
465    //DTRACE_PU("x1", uiTPelY)
466#endif
467    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
468    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
469    {
[608]470      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
[1200]471#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
472      if (bDebugPredEnabled)
473      {
474        std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
475        std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
476      }
477#endif
478
[56]479      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
[1200]480      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
[2]481      {
[1200]482        if ( !hasMergedCandList )
[2]483        {
[1200]484          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
[608]485          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
[1200]486          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
487          hasMergedCandList = true;
[2]488        }
[56]489      }
490      else
491      {
[622]492        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
[724]493        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
[56]494      }
[1200]495
[56]496      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
[833]497
[56]498      TComMv cTmpMv( 0, 0 );
499      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
[1200]500      {
[56]501        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
[2]502        {
[56]503          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
504          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
505          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
506          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
[1200]507
[2]508        }
509      }
[56]510    }
511    else
512    {
[2]513      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
514      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
[1200]515      {
[2]516        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
517        {
518          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
519          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
520          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
[1200]521#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
522          if (bDebugPredEnabled)
523          {
524            std::cout << "refListIdx: " << uiRefListIdx << std::endl;
525            std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
526            std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
527            std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
528            std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
529          }
530#endif
[2]531        }
532      }
533    }
[1200]534
[608]535    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
536    {
537      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
538      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
539      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
540    }
[2]541  }
[1179]542#endif
[773]543#if H_3D_SPIVMP
[735]544  delete[] pcMvFieldSP;
545  delete[] puhInterDirSP;
[724]546#endif
[2]547  return;
548}
549
550/** decode inter direction for a PU block
551 * \param pcCU
[1200]552 * \param uiAbsPartIdx
[2]553 * \param uiDepth
[1200]554 * \param uiPartIdx
[2]555 * \returns Void
556 */
557Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
558{
559  UInt uiInterDir;
560
561  if ( pcCU->getSlice()->isInterP() )
562  {
563    uiInterDir = 1;
564  }
565  else
566  {
[608]567    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
[2]568  }
569
570  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
571}
572
573Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
574{
[608]575  Int iRefFrmIdx = 0;
576  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
577
578  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
[2]579  {
[608]580    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
[2]581  }
[608]582  else if ( !iParseRefFrmIdx )
583  {
584    iRefFrmIdx = NOT_VALID;
585  }
[2]586  else
587  {
[608]588    iRefFrmIdx = 0;
589  }
[2]590
[608]591  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
592  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
[2]593}
594
595/** decode motion vector difference for a PU block
596 * \param pcCU
[1200]597 * \param uiAbsPartIdx
[2]598 * \param uiDepth
599 * \param uiPartIdx
[1200]600 * \param eRefList
[2]601 * \returns Void
602 */
603Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
604{
605  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
606  {
607    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
608  }
609}
610
[1196]611#if H_3D
[2]612Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
613{
[56]614  Int iMVPIdx = -1;
[2]615
[1179]616  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
617  {
618    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
619#if H_MV_ENC_DEC_TRAC
620#if ENC_DEC_TRACE
621    if ( eRefList == REF_PIC_LIST_0 )
622    {
623      DTRACE_PU("mvp_l0_flag", iMVPIdx)
624    }
625    else
626    {
627      DTRACE_PU("mvp_l1_flag", iMVPIdx)
628    }
629#endif
630#endif
631  }
632  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
633}
634
635Void TDecEntropy::decodeMvsAMVP( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
636{
[2]637  TComMv cZeroMv( 0, 0 );
638  TComMv cMv     = cZeroMv;
639  Int    iRefIdx = -1;
640
641  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
642  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
643
644  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
645  cMv = cZeroMv;
[56]646
[1179]647  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
648  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
649  if ( iRefIdx >= 0 )
650  {
651    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
652    cMv += pcSubCUMvField->getMvd( uiPartAddr );
653  }
654
655  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
656  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
657}
658#else
659Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
660{
661  Int iMVPIdx = -1;
662
663  TComMv cZeroMv( 0, 0 );
664  TComMv cMv     = cZeroMv;
665  Int    iRefIdx = -1;
666
667  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
668  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
669
670  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
671  cMv = cZeroMv;
672
[608]673  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
[56]674  {
675    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
[608]676#if H_MV_ENC_DEC_TRAC
677#if ENC_DEC_TRACE
678    if ( eRefList == REF_PIC_LIST_0 )
679    {
680      DTRACE_PU("mvp_l0_flag", iMVPIdx)
681    }
682    else
683    {
684      DTRACE_PU("mvp_l1_flag", iMVPIdx)
685    }
[56]686#endif
[608]687#endif
[56]688  }
[2]689  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
690  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
691  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
692  if ( iRefIdx >= 0 )
693  {
[608]694    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
[2]695    cMv += pcSubCUMvField->getMvd( uiPartAddr );
696  }
697
698  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
[56]699  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
[2]700}
[1179]701#endif
[1196]702
[1200]703Void TDecEntropy::xDecodeTransform        ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU )
[2]704{
[1179]705
[1200]706  TComDataCU *pcCU=rTu.getCU();
707  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
708  const UInt uiDepth=rTu.GetTransformDepthTotal();
709  const UInt uiTrDepth = rTu.GetTransformDepthRel();
710
[1179]711#if H_MV_ENC_DEC_TRAC
712#if ENC_DEC_TRACE
713  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
714  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
[1200]715
[1179]716  DTRACE_TU_S("=========== transform_tree ===========\n")
717  DTRACE_TU("x0", uiLPelX)
718  DTRACE_TU("x1", uiTPelY)
[1200]719 
720  DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth()  >> uiDepth )
[1179]721  DTRACE_TU("trafoDepth"  , uiDepth)
722#endif
723#endif
724
[56]725  UInt uiSubdiv;
[1200]726  const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents();
727  const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat());
[56]728
[1200]729  const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize();
730#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
731  if (bDebugRQT)
[56]732  {
[1200]733    printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n",
734        rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber());
735    fflush(stdout);
[56]736  }
[1200]737#endif
738
739  if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
[56]740  {
741    uiSubdiv = 1;
742  }
[1200]743  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
[56]744  {
[1200]745    uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU);
[56]746  }
747  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
748  {
749    uiSubdiv = 1;
750  }
751  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
752  {
753    uiSubdiv = 0;
754  }
[872]755  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
[56]756  {
757    uiSubdiv = 0;
758  }
759  else
760  {
[872]761    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
[608]762    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
[56]763  }
[1200]764
765  for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++)
[2]766  {
[1200]767    const ComponentID compID=ComponentID(chan);
768    const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID);
769
[608]770    const Bool bFirstCbfOfCU = uiTrDepth == 0;
[1200]771
[56]772    if( bFirstCbfOfCU )
[2]773    {
[1200]774      pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj);
[2]775    }
[1200]776    if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) )
[2]777    {
[1200]778      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) )
[1179]779      {
[1200]780        m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) );
[2]781      }
[1179]782    }
[2]783  }
[1200]784
[56]785  if( uiSubdiv )
[2]786  {
[1200]787    const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1);
788    UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0};
789
790    TComTURecurse tuRecurseChild(rTu, true);
791
792    do
[2]793    {
[1200]794      xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU );
795      UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU();
796      for(UInt ch=0; ch<numValidComponent; ch++)
797      {
798        uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch),  uiTrDepth+1 );
799      }
800    } while (tuRecurseChild.nextSection(rTu) );
801
802    for(UInt ch=0; ch<numValidComponent; ch++)
[56]803    {
[1200]804      UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx;
805      const UChar flag = uiYUVCbf[ch] << uiTrDepth;
806
807      for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
808      {
809        pBase[ui] |= flag;
810      }
[56]811    }
[2]812  }
813  else
814  {
[56]815    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
816    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
[1200]817
[608]818#if !H_MV_ENC_DEC_TRAC
[2]819    {
[56]820      DTRACE_CABAC_VL( g_nSymbolCounter++ );
821      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
822      DTRACE_CABAC_V( uiAbsPartIdx );
823      DTRACE_CABAC_T( "\tdepth=" );
824      DTRACE_CABAC_V( uiDepth );
825      DTRACE_CABAC_T( "\ttrdepth=" );
826      DTRACE_CABAC_V( uiTrDepth );
827      DTRACE_CABAC_T( "\n" );
[2]828    }
[608]829#endif
[1200]830
831    pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth );
832
833    if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) ))
[2]834    {
[1200]835      pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth );
[2]836    }
[56]837    else
[2]838    {
[1200]839      m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true );
[2]840    }
[608]841
842
[56]843    // transform_unit begin
[1200]844    UInt cbf[MAX_NUM_COMPONENT]={0,0,0};
845    Bool validCbf       = false;
846    Bool validChromaCbf = false;
847    const UInt uiTrIdx = rTu.GetTransformDepthRel();
848
849    for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
[2]850    {
[1200]851      const ComponentID compID = ComponentID(ch);
852
853      cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx );
854
855      if (cbf[compID] != 0)
[2]856      {
[1200]857        validCbf = true;
858        if (isChroma(compID))
859        {
860          validChromaCbf = true;
861        }
[2]862      }
863    }
[1200]864
865    if ( validCbf )
[2]866    {
[1200]867
868      // dQP: only for CTU
[56]869      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]870      {
[56]871        if ( bCodeDQP )
[2]872        {
[1200]873          const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU();
874          decodeQP( pcCU, uiAbsPartIdxCU);
[56]875          bCodeDQP = false;
[2]876        }
877      }
[1200]878
879      if ( pcCU->getSlice()->getUseChromaQpAdj() )
[2]880      {
[1200]881        if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) )
882        {
883          decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() );
884          isChromaQpAdjCoded = false;
885        }
[2]886      }
[1200]887
888      const UInt numValidComp=pcCU->getPic()->getNumberValidComponents();
889
890      for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++)
[2]891      {
[1200]892        const ComponentID compID=ComponentID(ch);
893
894        if( rTu.ProcessComponentSection(compID) )
[2]895        {
[1200]896#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
897          if (bDebugRQT)
898          {
899            printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1);
900          }
901#endif
902
903          if (rTu.getRect(compID).width != rTu.getRect(compID).height)
904          {
905            //code two sub-TUs
906            TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
907
908            do
909            {
910              const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1));
911
912              if (subTUCBF != 0)
913              {
914#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
915                if (bDebugRQT)
916                {
917                  printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1);
918                }
919#endif
920                m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID );
921              }
922            } while (subTUIterator.nextSection(rTu));
923          }
924          else
925          {
926            if(isChroma(compID) && (cbf[COMPONENT_Y] != 0))
927            {
928              m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID );
929            }
930
931            if(cbf[compID] != 0)
932            {
933              m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID );
934            }
935          }
[2]936        }
937      }
938    }
[56]939    // transform_unit end
[2]940  }
941}
942
[56]943Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
944{
945  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
946  {
947    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
948  }
949}
[2]950
[1200]951Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx )
952{
953  if ( pcCU->getSlice()->getUseChromaQpAdj() )
954  {
955    m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
956  }
957}
[2]958
[1200]959
960//! decode coefficients
961Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded )
[2]962{
[833]963#if H_3D_DIM_SDC
964  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
965  {
966    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
967    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
968    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
969    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
970    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
[1200]971}
[833]972#if H_3D_INTER_SDC
973  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
974  {
975    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
976    assert( !pcCU->isIntra( uiAbsPartIdx) );
977    assert( pcCU->getSlice()->getIsDepth() );
978  }
979#endif
980  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
981  {
982    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
983    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
[2]984 
[833]985    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
986    {
987      for( Int iPart = 0; iPart < iPartNum; iPart++ )
988      {
989        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
990        {
991          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
992        }
993      }
994    }
995    else
996    {
997      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
998      return;
999    }
1000  }
[443]1001#endif
[608]1002
[2]1003  if( pcCU->isIntra(uiAbsPartIdx) )
1004  {
1005  }
1006  else
1007  {
[56]1008    UInt uiQtRootCbf = 1;
1009    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
1010    {
[608]1011      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
[2]1012    }
[56]1013    if ( !uiQtRootCbf )
1014    {
[1200]1015      static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0};
1016      pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth );
[56]1017      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
1018      return;
1019    }
[1200]1020
[2]1021  }
[872]1022
[1200]1023  TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth);
[872]1024
[1200]1025#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
1026  if (bDebugRQT)
1027  {
1028    printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN);
1029  }
1030#endif
1031
1032  Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
1033 
1034  xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU );
[608]1035}
[189]1036
[655]1037#if H_3D_INTER_SDC
[833]1038Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1039{
1040  pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
[1179]1041  if ( pcCU->isSkipped( uiAbsPartIdx ) )
1042  {
1043    return; 
1044  }
[833]1045
[1179]1046
[1124]1047  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || 
1048    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
[833]1049  {
1050    return;
1051  }
1052
1053  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
1054  {
1055    return;
1056  }
1057
1058  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
1059  m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
1060}
[189]1061#endif
[833]1062#if H_3D_DBBP
1063Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1064{
[1179]1065  if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
1066  {
1067    m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
1068  }
[833]1069}
1070#endif
[189]1071
[1200]1072
1073
[56]1074//! \}
Note: See TracBrowser for help on using the repository browser.