source: 3DVCSoftware/branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1186

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

Clean up. Part 2.

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