source: 3DVCSoftware/branches/HTM-14.1-update-dev2-Sharp/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1225

Last change on this file since 1225 was 1225, checked in by sharpjp-htm, 9 years ago

Migration of illumination compensation(NH_3D_IC) and small fix(H_MV_ENC_DEC_TRAC_FIX)

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