source: 3DVCSoftware/branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.cpp @ 590

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