source: 3DVCSoftware/branches/HTM-3.0-LG/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1028

Last change on this file since 1028 was 62, checked in by lg, 13 years ago
  • Property svn:eol-style set to native
File size: 35.6 KB
RevLine 
[5]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
[56]4 * granted under this license. 
[5]5 *
[56]6 * Copyright (c) 2010-2012, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
34/** \file     TDecEntropy.cpp
35    \brief    entropy decoder class
36*/
37
38#include "TDecEntropy.h"
39
[56]40//! \ingroup TLibDecoder
41//! \{
42
[2]43Void TDecEntropy::setEntropyDecoder         ( TDecEntropyIf* p )
44{
45  m_pcEntropyDecoderIf = p;
46}
47
[56]48#include "TLibCommon/TComAdaptiveLoopFilter.h"
49#include "TLibCommon/TComSampleAdaptiveOffset.h"
[2]50
51Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
52{
53  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
54}
55
56/** decode merge flag
57 * \param pcSubCU
58 * \param uiAbsPartIdx
59 * \param uiDepth
60 * \param uiPUIdx
61 * \returns Void
62 */
63Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
64{ 
[56]65  // at least one merge candidate exists
66  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
[2]67}
68
69/** decode merge index
70 * \param pcCU
71 * \param uiPartIdx
72 * \param uiAbsPartIdx
73 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
74 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
75 * \param uiDepth
76 * \returns Void
77 */
78Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth )
79{
80  UInt uiMergeIndex = 0;
[56]81  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth );
[2]82  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
83}
84
[5]85#if HHI_INTER_VIEW_RESIDUAL_PRED
[2]86Void
87TDecEntropy::decodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx )
88{
89  Bool  bResPredAvailable   = false;
90  Bool  bResPredFlag        = false;
91
92  Bool  bResPredAllowed     =                    (!pcCU->getSlice()->getSPS()->isDepth                () );
93  bResPredAllowed           = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getViewId              () );
94  bResPredAllowed           = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getMultiviewResPredMode() );
95  bResPredAllowed           = bResPredAllowed && (!pcCU->isIntra           ( uiAbsPartIdx )              );
96
97  // check if supported
98  if( bResPredAllowed )
99  {
100    bResPredAvailable       = pcSubCU->getResidualSamples( uiPUIdx );
101  }
102
103  // read from bitstream
104  if( bResPredAvailable )
105  {
[62]106#if LG_RESTRICTEDRESPRED_M24766
107          Int iPUResiPredShift[4];
108          pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx);
109          if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0  || iPUResiPredShift[2] >= 0  || iPUResiPredShift[3] >= 0 )
110#endif
[2]111    m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth );
112  }
113
114  // set data
115  pcCU->setResPredAvailSubParts ( bResPredAvailable, uiAbsPartIdx, uiPUIdx, uiDepth );
116  pcCU->setResPredFlagSubParts  ( bResPredFlag,      uiAbsPartIdx, uiPUIdx, uiDepth );
117}
[5]118#endif
[2]119
120Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
121{
122  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
123}
124
125Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
126{
127  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
128}
129
130Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
131{
132  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
133}
134
135Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
136{
137  PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx );
138 
139  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
140  {
141    if( eMode == SIZE_NxN )                                         // if it is NxN size, encode 4 intra directions.
142    {
143      UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
144      // if it is NxN size, this size might be the smallest partition size.                                                         // if it is NxN size, this size might be the smallest partition size.
145      decodeIntraDirModeLuma( pcCU, uiAbsPartIdx,                  uiDepth+1 );
146      decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset,   uiDepth+1 );
147      decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 );
148      decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 );
149      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
150    }
151    else                                                                // if it is not NxN size, encode 1 intra directions
152    {
153      decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
154      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
155    }
156  }
157  else                                                                // if it is Inter mode, encode motion vector and reference index
158  {
[56]159    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
160  }
161}
[2]162
[56]163/** Parse I_PCM information.
164 * \param pcCU  pointer to CUpointer to CU
165 * \param uiAbsPartIdx CU index
166 * \param uiDepth CU depth
167 * \returns Void
168 */
169Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
170{
171  if(!pcCU->getSlice()->getSPS()->getUsePCM()
172    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
173    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
174  {
175    return;
[2]176  }
[56]177 
178  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
[2]179}
180
181Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
182{
183  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
184}
185
186Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
187{
188  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
189}
190
[56]191/** decode motion information for every PU block.
[2]192 * \param pcCU
193 * \param uiAbsPartIdx
194 * \param uiDepth
195 * \param pcSubCU
196 * \returns Void
197 */
198Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
199{
200  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
201  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
202  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
203
[56]204#if CU_BASED_MRG_CAND_LIST
205#if HHI_INTER_VIEW_MOTION_PRED
206  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
207  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
208  for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ui++ )
209#else
210  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
211  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
212  for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ )
213#endif
214  {
215    uhInterDirNeighbours[ui] = 0;
216  }
217  Int numValidMergeCand = 0;
218  bool isMerged = false;
219#endif
220
[2]221  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
222  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
223  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
224  {
[56]225#if !CU_BASED_MRG_CAND_LIST
226#if HHI_INTER_VIEW_MOTION_PRED
227    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
228    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
229    Int numValidMergeCand = 0;
230    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui )
231#else
[2]232    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
233    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
[56]234    Int numValidMergeCand = 0;
[2]235    for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui )
[56]236#endif
[2]237    {
238      uhInterDirNeighbours[ui] = 0;
239    }
240#endif
241    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
242    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
243    {
244      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
[56]245#if CU_BASED_MRG_CAND_LIST
246      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
247      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
[2]248      {
[56]249        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
250        if ( !isMerged )
[2]251        {
[56]252          pcSubCU->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
253          isMerged = true;
[2]254        }
[56]255        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
256      }
257      else
258      {
259#if SIMP_MRG_PRUN
260        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
261        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
262#else     
263        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
264        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
265#endif
266      }
267#else
268#if SIMP_MRG_PRUN       
269      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
270      pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
271#else     
272      pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
273      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
274#endif
275#endif
276      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
277
278      TComMv cTmpMv( 0, 0 );
279      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
280      {       
281        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
[2]282        {
[56]283          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
284          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
285          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
286          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
287
[2]288        }
289      }
[56]290    }
291    else
292    {
[2]293      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
294      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
295      {       
296        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
297        {
298          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
299          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
300          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
301        }
302      }
303    }
304  }
305  return;
306}
307
308/** decode inter direction for a PU block
309 * \param pcCU
310 * \param uiAbsPartIdx
311 * \param uiDepth
312 * \param uiPartIdx
313 * \returns Void
314 */
315Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
316{
317  UInt uiInterDir;
318
319  if ( pcCU->getSlice()->isInterP() )
320  {
321    uiInterDir = 1;
322  }
323  else
324  {
325    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
326  }
327
328  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
329}
330
331Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
332{
333  if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3)
334  {
335    if(eRefList == REF_PIC_LIST_1)
336    {
337      return;
338    }
339
340    Int iRefFrmIdx = 0;
341    Int iRefFrmIdxTemp;
342    UInt uiInterDir;
343    RefPicList eRefListTemp;
344
345    PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
346
347    if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 )
348    {
349      m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C );
[56]350    }
351    else
352    {
[2]353      iRefFrmIdx=0;
354    }
355    uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1;
356    iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx);
357    eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx);
358
[56]359    pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
[2]360
361    pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
362  }
363  else
364  {
[56]365    Int iRefFrmIdx = 0;
366    Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
[2]367
[56]368    if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
369    {
370      m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
371    }
372    else if ( !iParseRefFrmIdx )
373    {
374      iRefFrmIdx = NOT_VALID;
375    }
376    else
377    {
378      iRefFrmIdx = 0;
379    }
[2]380
[56]381    PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
382    pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
[2]383  }
384}
385
386/** decode motion vector difference for a PU block
387 * \param pcCU
388 * \param uiAbsPartIdx
389 * \param uiDepth
390 * \param uiPartIdx
391 * \param eRefList
392 * \returns Void
393 */
394Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
395{
396  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
397  {
398    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
399  }
400}
401
402Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
403{
[56]404  Int iMVPIdx = -1;
[2]405
406  TComMv cZeroMv( 0, 0 );
407  TComMv cMv     = cZeroMv;
408  Int    iRefIdx = -1;
409
410  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
411  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
412
413  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
414  cMv = cZeroMv;
[56]415
416  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
417  {
418#if HHI_INTER_VIEW_MOTION_PRED
419    const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcSubCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 );
420    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx, iNumAMVPCands );
421#else
422    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
423#endif
424  }
[2]425  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
426  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
427  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
428  if ( iRefIdx >= 0 )
429  {
430    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv);
431    cMv += pcSubCUMvField->getMvd( uiPartAddr );
432  }
433
434  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
[56]435  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
[2]436}
437
[56]438#if UNIFIED_TRANSFORM_TREE
439Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP )
440#else
441Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 )
442#endif
[2]443{
[56]444  UInt uiSubdiv;
445  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
446
447#if UNIFIED_TRANSFORM_TREE
448  if(uiTrIdx==0)
449  {
450    m_bakAbsPartIdxCU = uiAbsPartIdx;
451  }
452  if( uiLog2TrafoSize == 2 )
453  {
454    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
455    if( ( uiAbsPartIdx % partNum ) == 0 )
456    {
457      m_uiBakAbsPartIdx   = uiAbsPartIdx;
458      m_uiBakChromaOffset = offsetChroma;
459    }
460  }
461#endif // UNIFIED_TRANSFORM_TREE
462  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
463  {
464    uiSubdiv = 1;
465  }
466#if G519_TU_AMP_NSQT_HARMONIZATION
467  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
468#else
469  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
470#endif
471  {
472    uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));
473  }
474  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
475  {
476    uiSubdiv = 1;
477  }
478  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
479  {
480    uiSubdiv = 0;
481  }
482  else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
483  {
484    uiSubdiv = 0;
485  }
486  else
487  {
488    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
489    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth );
490  }
[2]491 
[56]492  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
[2]493 
[56]494  if( uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
[2]495  {
[56]496    const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0;
497    if( bFirstCbfOfCU )
[2]498    {
[56]499      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
500      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
[2]501    }
[56]502    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
[2]503    {
[56]504      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
[2]505      {
[56]506        if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
[2]507        {
[56]508          uiUCbfFront3++;
509          pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
510          //printf( " \nsave bits, U Cbf");
[2]511        }
[56]512        else
[2]513        {
[56]514          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
515          uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
[2]516        }
517      }
[56]518      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
[2]519      {
[56]520        if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
[2]521        {
[56]522          uiVCbfFront3++;
523          pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
524          //printf( " \nsave bits, V Cbf");
[2]525        }
[56]526        else
[2]527        {
[56]528          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
529          uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
[2]530        }
531      }
532    }
[56]533    else
[2]534    {
[56]535      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
536      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
537      if ( uiLog2TrafoSize == 2 )
[2]538      {
[56]539        uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth );
540        uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth );
[2]541      }
542    }
543  }
544 
[56]545  if( uiSubdiv )
[2]546  {
[56]547#if UNIFIED_TRANSFORM_TREE
548    UInt size;
549    width  >>= 1;
550    height >>= 1;
551    size = width*height;
552    uiTrIdx++;
553#endif
554    ++uiDepth;
555    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
556    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
557    UInt uiLumaTrMode, uiChromaTrMode;
558    pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode );
559    UInt uiYCbf = 0;
560    UInt uiUCbf = 0;
561    UInt uiVCbf = 0;
562   
563    UInt uiCurrentCbfY = 0;
564    UInt uiCurrentCbfU = 0;
565    UInt uiCurrentCbfV = 0;
566   
567    for( Int i = 0; i < 4; i++ )
[2]568    {
[56]569#if UNIFIED_TRANSFORM_TREE
570      UInt nsAddr = 0;
571      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 );
572      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP );
573#else
574      UInt nsAddr = 0;
575      nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 );
576      xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV );
577#endif
578      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
579      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode );
580      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode );
581      uiAbsPartIdx += uiQPartNum;
582#if UNIFIED_TRANSFORM_TREE
583      offsetLuma += size;  offsetChroma += (size>>2);
584#endif
[2]585    }
[56]586   
587    uiYCbfFront3 += uiCurrentCbfY;
588    uiUCbfFront3 += uiCurrentCbfU;
589    uiVCbfFront3 += uiCurrentCbfV;
590   
591    pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
592    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
593    {
594      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode;
595      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode;
596      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode;
597    }
[2]598  }
599  else
600  {
[56]601    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
602    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
603   
[2]604    {
[56]605      DTRACE_CABAC_VL( g_nSymbolCounter++ );
606      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
607      DTRACE_CABAC_V( uiAbsPartIdx );
608      DTRACE_CABAC_T( "\tdepth=" );
609      DTRACE_CABAC_V( uiDepth );
610      DTRACE_CABAC_T( "\ttrdepth=" );
611      DTRACE_CABAC_V( uiTrDepth );
612      DTRACE_CABAC_T( "\n" );
[2]613    }
[56]614   
615    UInt uiLumaTrMode, uiChromaTrMode;
616    pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
617    if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) )
[2]618    {
[56]619      pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode );
[2]620    }
[56]621    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
622    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
[2]623    {
[56]624      pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
[2]625    }
[56]626    else
[2]627    {
[56]628      const UInt uiLog2CUSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - pcCU->getDepth( uiAbsPartIdx );
629      if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0
630          && ( uiLog2CUSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() + 1 || uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) )
[2]631      {
[56]632        pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
633        //printf( " \nsave bits, Y Cbf");
634        uiYCbfFront3++;   
[2]635      }
[56]636      else
[2]637      {
[56]638        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth );
639        uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
[2]640      }
641    }
[56]642#if UNIFIED_TRANSFORM_TREE
643    // transform_unit begin
644    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
645    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
646    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
647    if( uiLog2TrafoSize == 2 )
[2]648    {
[56]649      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
650      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
[2]651      {
[56]652        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
653        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
[2]654      }
655    }
[56]656    if ( cbfY || cbfU || cbfV )
[2]657    {
[56]658      // dQP: only for LCU
659      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]660      {
[56]661        if ( bCodeDQP )
[2]662        {
[56]663          decodeQP( pcCU, m_bakAbsPartIdxCU);
664          bCodeDQP = false;
[2]665        }
666      }
667    }
[56]668    if( cbfY )
[2]669    {
[56]670      Int trWidth = width;
671      Int trHeight = height;
672      pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
673      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
[2]674    }
[56]675    if( uiLog2TrafoSize > 2 )
[2]676    {
[56]677      Int trWidth = width >> 1;
678      Int trHeight = height >> 1;
679      pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
680      if( cbfU )
[2]681      {
[56]682        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
[2]683      }
[56]684      if( cbfV )
[2]685      {
[56]686        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
[2]687      }
688    }
689    else
690    {
[56]691      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
692      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
[2]693      {
[56]694        Int trWidth = width;
695        Int trHeight = height;
696        pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight );
697        if( cbfU )
[2]698        {
[56]699          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
[2]700        }
[56]701        if( cbfV )
[2]702        {
[56]703          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
[2]704        }
705      }
706    }
[56]707    // transform_unit end
708#endif // UNIFIED_TRANSFORM_TREE
[2]709  }
710}
711
[56]712#if !UNIFIED_TRANSFORM_TREE
[2]713Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
714{
[56]715  DTRACE_CABAC_VL( g_nSymbolCounter++ )
[2]716  DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" )
717  DTRACE_CABAC_V( uiDepth )
718  DTRACE_CABAC_T( "\n" )
719  UInt temp = 0;
720  UInt temp1 = 0;
721  UInt temp2 = 0;
[56]722  xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 );
[2]723}
[56]724#endif // UNIFIED_TRANSFORM_TREE
[2]725
[56]726#if UNIFIED_TRANSFORM_TREE
727Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
728{
729  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
730  {
731    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
732  }
733}
734#else
[2]735Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
736{
[56]737  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]738  {
739    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth );
740  }
741}
[56]742#endif
[2]743
[56]744#if !UNIFIED_TRANSFORM_TREE
745Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP )
[2]746{
[56]747  UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;
748  UInt uiCbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx );
749  UInt uiCbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
750  UInt uiCbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
751  if( uiLog2TrSize == 2 )
752  {
753    UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
754    if( ( uiAbsPartIdx % uiQPDiv ) == 0 )
755    {
756      m_uiBakAbsPartIdx   = uiAbsPartIdx;
757      m_uiBakChromaOffset = uiChromaOffset;
758    }
759    else if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )
760    {
761      uiCbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
762      uiCbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
763    }
764  }
[2]765
[56]766  if ( uiCbfY || uiCbfU || uiCbfV )
[2]767  {
768    // dQP: only for LCU
[56]769    if ( pcCU->getSlice()->getPPS()->getUseDQP() )
[2]770    {
[56]771      if ( bCodeDQP )
[2]772      {
[56]773        decodeQP( pcCU, uiAbsPartIdx, uiDepth);
774        bCodeDQP = false;
[2]775      }
776    }   
777    UInt uiLumaTrMode, uiChromaTrMode;
778    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
[56]779    const UInt uiStopTrMode = uiLumaTrMode;
[2]780   
781    if( uiTrIdx == uiStopTrMode )
782    {
[56]783      if( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ) )
[2]784      {
[56]785        Int trWidth = uiWidth;
786        Int trHeight = uiHeight;
787        pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
788        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+uiLumaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
789      }
790     
791      uiWidth  >>= 1;
792      uiHeight >>= 1;
793
794      if( uiLog2TrSize == 2 )
795      {
[2]796        UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
[56]797        if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) )
[2]798        {
[56]799          uiWidth  <<= 1;
800          uiHeight <<= 1;
801          Int trWidth = uiWidth;
802          Int trHeight = uiHeight;
803          pcCU->getNSQTSize( uiTrIdx-1, uiAbsPartIdx, trWidth, trHeight );
804          if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )
805          {
806            m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
807          }
808          if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )
809          {
810            m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
811          }
[2]812        }
813      }
[56]814      else
815      {
816        Int trWidth = uiWidth;
817        Int trHeight = uiHeight;
818        pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
819        if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) )
820        {
821          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
822        }
823        if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) )
824        {
825          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
826        }
827      }
[2]828    }
829    else
830    {
831      {
[56]832        DTRACE_CABAC_VL( g_nSymbolCounter++ );
[2]833        DTRACE_CABAC_T( "\tgoing down\tdepth=" );
834        DTRACE_CABAC_V( uiDepth );
835        DTRACE_CABAC_T( "\ttridx=" );
836        DTRACE_CABAC_V( uiTrIdx );
837        DTRACE_CABAC_T( "\n" );
838      }
839      if( uiCurrTrIdx <= uiTrIdx )
[56]840      {
[2]841        assert(1);
[56]842      }
[2]843      UInt uiSize;
844      uiWidth  >>= 1;
845      uiHeight >>= 1;
846      uiSize = uiWidth*uiHeight;
847      uiDepth++;
848      uiTrIdx++;
849     
850      UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
851      UInt uiIdx      = uiAbsPartIdx;
852     
[56]853      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
854      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
855     
856      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
857      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
858     
859      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
860      uiLumaOffset += uiSize;  uiChromaOffset += (uiSize>>2);  uiIdx += uiQPartNum;
861     
862      xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP );
[2]863      {
[56]864        DTRACE_CABAC_VL( g_nSymbolCounter++ );
[2]865        DTRACE_CABAC_T( "\tgoing up\n" );
866      }
867    }
868  }
869}
[56]870#endif // !UNIFIED_TRANSFORM_TREE
[2]871
872/** decode coefficients
873 * \param pcCU
874 * \param uiAbsPartIdx
875 * \param uiDepth
876 * \param uiWidth
877 * \param uiHeight
878 * \returns Void
879 */
[56]880Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
[2]881{
882  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
883  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
884  UInt uiChromaOffset = uiLumaOffset>>2;
[56]885#if UNIFIED_TRANSFORM_TREE
886  UInt temp  = 0;
887  UInt temp1 = 0;
888  UInt temp2 = 0;
889#else
[2]890  UInt uiLumaTrMode, uiChromaTrMode;
[56]891#endif
[2]892 
893  if( pcCU->isIntra(uiAbsPartIdx) )
894  {
[56]895#if !UNIFIED_TRANSFORM_TREE
[2]896    decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );
897   
898    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode );
899   
[56]900#endif // !UNIFIED_TRANSFORM_TREE
[2]901  }
902  else
903  {
[56]904    UInt uiQtRootCbf = 1;
[5]905#if HHI_MPI
[56]906    if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N &&
907          ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) )
[2]908#else
[56]909    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
[2]910#endif
[56]911    {
[2]912      m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf );
913    }
[56]914    if ( !uiQtRootCbf )
915    {
916      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
917      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
918      pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth );
919      return;
920    }
[2]921   
[56]922#if !UNIFIED_TRANSFORM_TREE
[2]923    decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) );
924   
925    pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode );
[56]926#endif // !UNIFIED_TRANSFORM_TREE
[2]927  }
[56]928#if UNIFIED_TRANSFORM_TREE
929  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP );
930#else // UNIFIED_TRANSFORM_TREE
931  xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP );
932#endif // UNIFIED_TRANSFORM_TREE
[2]933}
934
[56]935//! \}
Note: See TracBrowser for help on using the repository browser.