source: 3DVCSoftware/branches/HTM-14.1-update-dev4-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1262

Last change on this file since 1262 was 1262, checked in by qualcomm, 10 years ago
  1. enable ARP by NH_3D_ARP with simulation results included; 2. address Gerhard's comments on setBaseViewRefPicList; 3. align the software with the specification of checking the correct reference picture list proposed in JCT3V-F105
  • Property svn:eol-style set to native
File size: 37.4 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 NH_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 H_3D_IC
127Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
128{
129  pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
130
131  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
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
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  {
163    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
164#if H_3D_DIM_SDC
165    decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );
166    if(!pcCU->getSDCFlag(uiAbsPartIdx))
167#endif
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    }
179  }
180  else                                                                // if it is Inter mode, encode motion vector and reference index
181  {
182    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
183  }
184}
185
186/** Parse I_PCM information.
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;
199  }
200
201  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
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 );
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
223}
224
225
226/** decode motion information for every PU block.
227 * \param pcCU
228 * \param uiAbsPartIdx
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 ) );
237  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
238#if H_3D_IV_MERGE
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
245#if H_3D_SPIVMP
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()]; 
249#endif
250#if H_3D_IV_MERGE
251  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
252#endif
253  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
254  {
255    uhInterDirNeighbours[ui] = 0;
256  }
257  Int numValidMergeCand = 0;
258  Bool isMerged = false;
259
260  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
261  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
262#if NH_3D
263  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
264  {
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)
270#endif
271
272    ////// Parse PUs syntax
273    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
274    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
275    {
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#if NH_3D_DBBP
295  decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
296#endif
297  //decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
298
299#if NH_3D_ARP
300  decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
301#endif
302#if H_3D_IC
303  decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
304#endif
305
306  ////// Decode motion vectors
307  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
308  {
309    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
310    {
311      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
312#if NH_3D_DBBP
313      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
314#else
315      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
316#endif
317      {
318        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
319        if ( !isMerged )
320        {
321#if H_3D_VSP
322          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
323          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
324#if H_3D_SPIVMP
325          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
326#endif
327          pcSubCU->initAvailableFlags();
328          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
329          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
330#if H_3D_SPIVMP
331            , pcMvFieldSP, puhInterDirSP
332#endif
333            , numValidMergeCand );
334          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
335#if H_3D_SPIVMP
336            , bSPIVMPFlag
337#endif
338            , numValidMergeCand );
339          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
340
341#else
342#if H_3D
343          pcSubCU->initAvailableFlags();
344          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
345          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
346
347#else
348          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
349#endif
350#endif
351          isMerged = true;
352        }
353        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
354      }
355      else
356      {
357        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
358#if H_3D_VSP
359        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
360        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
361#if H_3D_SPIVMP
362        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
363#endif
364        pcSubCU->initAvailableFlags();
365        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
366        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
367#if H_3D_SPIVMP
368          , pcMvFieldSP, puhInterDirSP
369#endif
370          ,numValidMergeCand, uiMergeIndex );
371        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
372#if H_3D_SPIVMP
373          , bSPIVMPFlag
374#endif
375          ,numValidMergeCand );
376        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
377#else
378#if H_3D
379        pcSubCU->initAvailableFlags();
380        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
381        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
382#else
383        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
384#endif
385#endif
386      }
387      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
388
389      TComMv cTmpMv( 0, 0 );
390      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
391      {       
392        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
393        {
394          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
395          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
396          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
397          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
398#if H_3D_VSP
399#if NH_3D_DBBP
400          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
401#else
402          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
403#endif
404          {
405            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
406            {
407              UInt dummy;
408              Int vspSize;
409              Int width, height;
410              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
411              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
412              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
413            }
414          }
415#endif
416        }
417      }
418#if H_3D_SPIVMP
419      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
420      if (bSPIVMPFlag[uiMergeIndex] != 0)
421      {
422        Int iWidth, iHeight;
423        UInt uiIdx;
424        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
425
426        UInt uiSPAddr;
427
428        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
429
430        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
431
432        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
433        {
434          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
435          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
436          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
437          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
438        }
439      }
440#endif
441    }
442    else
443    {
444      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
445      {       
446        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
447        {
448          decodeMvsAMVP   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
449        }
450      }
451    }
452
453    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
454    {
455      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
456      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
457      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
458    }
459  }
460#else
461  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
462  {
463#if H_MV_ENC_DEC_TRAC
464    DTRACE_PU_S("=========== prediction_unit ===========\n")
465    // ToDo:
466    //DTRACE_PU("x0", uiLPelX)
467    //DTRACE_PU("x1", uiTPelY)
468#endif
469    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
470    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
471    {
472      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
473#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
474      if (bDebugPredEnabled)
475      {
476        std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
477        std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
478      }
479#endif
480
481      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
482      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
483      {
484        if ( !hasMergedCandList )
485        {
486          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
487          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
488          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
489          hasMergedCandList = true;
490        }
491      }
492      else
493      {
494        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
495        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
496      }
497
498      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
499
500      TComMv cTmpMv( 0, 0 );
501      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
502      {
503        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
504        {
505          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
506          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
507          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
508          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
509
510        }
511      }
512    }
513    else
514    {
515      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
516      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
517      {
518        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
519        {
520          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
521          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
522          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
523#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
524          if (bDebugPredEnabled)
525          {
526            std::cout << "refListIdx: " << uiRefListIdx << std::endl;
527            std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
528            std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
529            std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
530            std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
531          }
532#endif
533        }
534      }
535    }
536
537    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
538    {
539      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
540      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
541      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
542    }
543  }
544#endif
545#if H_3D_SPIVMP
546  delete[] pcMvFieldSP;
547  delete[] puhInterDirSP;
548#endif
549  return;
550}
551
552/** decode inter direction for a PU block
553 * \param pcCU
554 * \param uiAbsPartIdx
555 * \param uiDepth
556 * \param uiPartIdx
557 * \returns Void
558 */
559Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
560{
561  UInt uiInterDir;
562
563  if ( pcCU->getSlice()->isInterP() )
564  {
565    uiInterDir = 1;
566  }
567  else
568  {
569    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
570  }
571
572  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
573}
574
575Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
576{
577  Int iRefFrmIdx = 0;
578  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
579
580  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
581  {
582    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
583  }
584  else if ( !iParseRefFrmIdx )
585  {
586    iRefFrmIdx = NOT_VALID;
587  }
588  else
589  {
590    iRefFrmIdx = 0;
591  }
592
593  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
594  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
595}
596
597/** decode motion vector difference for a PU block
598 * \param pcCU
599 * \param uiAbsPartIdx
600 * \param uiDepth
601 * \param uiPartIdx
602 * \param eRefList
603 * \returns Void
604 */
605Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
606{
607  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
608  {
609    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
610  }
611}
612
613#if NH_3D
614Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
615{
616  Int iMVPIdx = -1;
617
618  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
619  {
620    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
621#if H_MV_ENC_DEC_TRAC
622#if ENC_DEC_TRACE
623    if ( eRefList == REF_PIC_LIST_0 )
624    {
625      DTRACE_PU("mvp_l0_flag", iMVPIdx)
626    }
627    else
628    {
629      DTRACE_PU("mvp_l1_flag", iMVPIdx)
630    }
631#endif
632#endif
633  }
634  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
635}
636
637Void TDecEntropy::decodeMvsAMVP( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
638{
639  TComMv cZeroMv( 0, 0 );
640  TComMv cMv     = cZeroMv;
641  Int    iRefIdx = -1;
642
643  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
644  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
645
646  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
647  cMv = cZeroMv;
648
649  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
650  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
651  if ( iRefIdx >= 0 )
652  {
653    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
654    cMv += pcSubCUMvField->getMvd( uiPartAddr );
655  }
656
657  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
658  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
659}
660#else
661Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
662{
663  Int iMVPIdx = -1;
664
665  TComMv cZeroMv( 0, 0 );
666  TComMv cMv     = cZeroMv;
667  Int    iRefIdx = -1;
668
669  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
670  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
671
672  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
673  cMv = cZeroMv;
674
675  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
676  {
677    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
678#if H_MV_ENC_DEC_TRAC
679#if ENC_DEC_TRACE
680    if ( eRefList == REF_PIC_LIST_0 )
681    {
682      DTRACE_PU("mvp_l0_flag", iMVPIdx)
683    }
684    else
685    {
686      DTRACE_PU("mvp_l1_flag", iMVPIdx)
687    }
688#endif
689#endif
690  }
691  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
692  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
693  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
694  if ( iRefIdx >= 0 )
695  {
696    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
697    cMv += pcSubCUMvField->getMvd( uiPartAddr );
698  }
699
700  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
701  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
702}
703#endif
704
705Void TDecEntropy::xDecodeTransform        ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU )
706{
707
708  TComDataCU *pcCU=rTu.getCU();
709  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
710  const UInt uiDepth=rTu.GetTransformDepthTotal();
711  const UInt uiTrDepth = rTu.GetTransformDepthRel();
712
713#if H_MV_ENC_DEC_TRAC
714#if ENC_DEC_TRACE
715  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
716  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
717
718  DTRACE_TU_S("=========== transform_tree ===========\n")
719  DTRACE_TU("x0", uiLPelX)
720  DTRACE_TU("x1", uiTPelY)
721 
722  DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth()  >> uiDepth )
723  DTRACE_TU("trafoDepth"  , uiDepth)
724#endif
725#endif
726
727  UInt uiSubdiv;
728  const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents();
729  const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat());
730
731  const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize();
732#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
733  if (bDebugRQT)
734  {
735    printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n",
736        rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber());
737    fflush(stdout);
738  }
739#endif
740
741  if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
742  {
743    uiSubdiv = 1;
744  }
745  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
746  {
747    uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU);
748  }
749  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
750  {
751    uiSubdiv = 1;
752  }
753  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
754  {
755    uiSubdiv = 0;
756  }
757  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
758  {
759    uiSubdiv = 0;
760  }
761  else
762  {
763    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
764    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
765  }
766
767  for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++)
768  {
769    const ComponentID compID=ComponentID(chan);
770    const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID);
771
772    const Bool bFirstCbfOfCU = uiTrDepth == 0;
773
774    if( bFirstCbfOfCU )
775    {
776      pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj);
777    }
778    if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) )
779    {
780      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) )
781      {
782        m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) );
783      }
784    }
785  }
786
787  if( uiSubdiv )
788  {
789    const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1);
790    UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0};
791
792    TComTURecurse tuRecurseChild(rTu, true);
793
794    do
795    {
796      xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU );
797      UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU();
798      for(UInt ch=0; ch<numValidComponent; ch++)
799      {
800        uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch),  uiTrDepth+1 );
801      }
802    } while (tuRecurseChild.nextSection(rTu) );
803
804    for(UInt ch=0; ch<numValidComponent; ch++)
805    {
806      UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx;
807      const UChar flag = uiYUVCbf[ch] << uiTrDepth;
808
809      for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
810      {
811        pBase[ui] |= flag;
812      }
813    }
814  }
815  else
816  {
817    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
818    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
819
820#if !H_MV_ENC_DEC_TRAC
821    {
822      DTRACE_CABAC_VL( g_nSymbolCounter++ );
823      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
824      DTRACE_CABAC_V( uiAbsPartIdx );
825      DTRACE_CABAC_T( "\tdepth=" );
826      DTRACE_CABAC_V( uiDepth );
827      DTRACE_CABAC_T( "\ttrdepth=" );
828      DTRACE_CABAC_V( uiTrDepth );
829      DTRACE_CABAC_T( "\n" );
830    }
831#endif
832
833    pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth );
834
835    if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) ))
836    {
837      pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth );
838    }
839    else
840    {
841      m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true );
842    }
843
844
845    // transform_unit begin
846    UInt cbf[MAX_NUM_COMPONENT]={0,0,0};
847    Bool validCbf       = false;
848    Bool validChromaCbf = false;
849    const UInt uiTrIdx = rTu.GetTransformDepthRel();
850
851    for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
852    {
853      const ComponentID compID = ComponentID(ch);
854
855      cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx );
856
857      if (cbf[compID] != 0)
858      {
859        validCbf = true;
860        if (isChroma(compID))
861        {
862          validChromaCbf = true;
863        }
864      }
865    }
866
867    if ( validCbf )
868    {
869
870      // dQP: only for CTU
871      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
872      {
873        if ( bCodeDQP )
874        {
875          const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU();
876          decodeQP( pcCU, uiAbsPartIdxCU);
877          bCodeDQP = false;
878        }
879      }
880
881      if ( pcCU->getSlice()->getUseChromaQpAdj() )
882      {
883        if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) )
884        {
885          decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() );
886          isChromaQpAdjCoded = false;
887        }
888      }
889
890      const UInt numValidComp=pcCU->getPic()->getNumberValidComponents();
891
892      for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++)
893      {
894        const ComponentID compID=ComponentID(ch);
895
896        if( rTu.ProcessComponentSection(compID) )
897        {
898#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
899          if (bDebugRQT)
900          {
901            printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1);
902          }
903#endif
904
905          if (rTu.getRect(compID).width != rTu.getRect(compID).height)
906          {
907            //code two sub-TUs
908            TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
909
910            do
911            {
912              const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1));
913
914              if (subTUCBF != 0)
915              {
916#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
917                if (bDebugRQT)
918                {
919                  printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1);
920                }
921#endif
922                m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID );
923              }
924            } while (subTUIterator.nextSection(rTu));
925          }
926          else
927          {
928            if(isChroma(compID) && (cbf[COMPONENT_Y] != 0))
929            {
930              m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID );
931            }
932
933            if(cbf[compID] != 0)
934            {
935              m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID );
936            }
937          }
938        }
939      }
940    }
941    // transform_unit end
942  }
943}
944
945Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
946{
947  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
948  {
949    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
950  }
951}
952
953Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx )
954{
955  if ( pcCU->getSlice()->getUseChromaQpAdj() )
956  {
957    m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
958  }
959}
960
961
962//! decode coefficients
963Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded )
964{
965#if H_3D_DIM_SDC
966  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
967  {
968    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
969    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
970    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
971    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
972    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
973}
974#if H_3D_INTER_SDC
975  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
976  {
977    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
978    assert( !pcCU->isIntra( uiAbsPartIdx) );
979    assert( pcCU->getSlice()->getIsDepth() );
980  }
981#endif
982  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
983  {
984    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
985    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
986 
987    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
988    {
989      for( Int iPart = 0; iPart < iPartNum; iPart++ )
990      {
991        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
992        {
993          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
994        }
995      }
996    }
997    else
998    {
999      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
1000      return;
1001    }
1002  }
1003#endif
1004
1005  if( pcCU->isIntra(uiAbsPartIdx) )
1006  {
1007  }
1008  else
1009  {
1010    UInt uiQtRootCbf = 1;
1011    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
1012    {
1013      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
1014    }
1015    if ( !uiQtRootCbf )
1016    {
1017      static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0};
1018      pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth );
1019      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
1020      return;
1021    }
1022
1023  }
1024
1025  TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth);
1026
1027#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
1028  if (bDebugRQT)
1029  {
1030    printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN);
1031  }
1032#endif
1033
1034  Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
1035 
1036  xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU );
1037}
1038
1039#if H_3D_INTER_SDC
1040Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1041{
1042  pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
1043  if ( pcCU->isSkipped( uiAbsPartIdx ) )
1044  {
1045    return; 
1046  }
1047
1048
1049  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || 
1050    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
1051  {
1052    return;
1053  }
1054
1055  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
1056  {
1057    return;
1058  }
1059
1060  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
1061  m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
1062}
1063#endif
1064#if NH_3D_DBBP
1065Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1066{
1067  if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
1068  {
1069    m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
1070  }
1071}
1072#endif
1073
1074
1075
1076//! \}
Note: See TracBrowser for help on using the repository browser.