source: 3DVCSoftware/trunk/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1196

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

Merged 14.0-dev0@1187.

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