source: 3DVCSoftware/branches/HTM-13.1-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1176

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

Fix for disabling colour components for depth.

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