source: 3DVCSoftware/branches/HTM-DEV-0.3-dev1/source/Lib/TLibDecoder/TDecEntropy.cpp @ 467

Last change on this file since 467 was 467, checked in by rwth, 11 years ago

Integration of depth intra methods in macro H_3D_DIM, including:

  • Simplified Depth Coding (SDC) in H_3D_DIM_SDC
  • Depth Lookup Table (DLT) in H_3D_DIM_DLT
  • Property svn:eol-style set to native
File size: 20.3 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6 * Copyright (c) 2010-2013, 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
55Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
56{
57  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
58}
59
60/** decode merge flag
61 * \param pcSubCU
62 * \param uiAbsPartIdx
63 * \param uiDepth
64 * \param uiPUIdx
65 * \returns Void
66 */
67Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
68{ 
69  // at least one merge candidate exists
70  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
71}
72
73/** decode merge index
74 * \param pcCU
75 * \param uiPartIdx
76 * \param uiAbsPartIdx
77 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
78 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
79 * \param uiDepth
80 * \returns Void
81 */
82Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
83{
84  UInt uiMergeIndex = 0;
85  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
86  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
87}
88
89Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
90{
91  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
92}
93
94Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
95{
96  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
97}
98
99Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
100{
101  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
102}
103
104Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
105{
106  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
107  {
108    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
109#if H_3D_DIM_SDC
110    if(!pcCU->getSDCFlag(uiAbsPartIdx))
111#endif
112      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
113  }
114  else                                                                // if it is Inter mode, encode motion vector and reference index
115  {
116    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
117  }
118}
119
120/** Parse I_PCM information.
121 * \param pcCU  pointer to CUpointer to CU
122 * \param uiAbsPartIdx CU index
123 * \param uiDepth CU depth
124 * \returns Void
125 */
126Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
127{
128  if(!pcCU->getSlice()->getSPS()->getUsePCM()
129    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
130    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
131  {
132    return;
133  }
134#if H_3D_DIM_SDC
135  if( pcCU->getSDCFlag(uiAbsPartIdx) )
136  {
137    return;
138  }
139#endif
140 
141  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
142}
143
144Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
145{
146  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
147}
148
149Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
150{
151  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
152}
153
154/** decode motion information for every PU block.
155 * \param pcCU
156 * \param uiAbsPartIdx
157 * \param uiDepth
158 * \param pcSubCU
159 * \returns Void
160 */
161Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
162{
163  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
164  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
165  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
166
167  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
168  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
169
170  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
171  {
172    uhInterDirNeighbours[ui] = 0;
173  }
174  Int numValidMergeCand = 0;
175  Bool isMerged = false;
176
177  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
178  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
179  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
180  {
181    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
182    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
183    {
184      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
185      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
186      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
187      {
188        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
189        if ( !isMerged )
190        {
191          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
192          isMerged = true;
193        }
194        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
195      }
196      else
197      {
198        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
199        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
200      }
201      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
202
203      TComMv cTmpMv( 0, 0 );
204      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
205      {       
206        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
207        {
208          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
209          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
210          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
211          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
212        }
213      }
214    }
215    else
216    {
217      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
218      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
219      {       
220        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
221        {
222          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
223          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
224          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
225        }
226      }
227    }
228    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
229    {
230      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
231      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
232      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
233    }
234  }
235  return;
236}
237
238/** decode inter direction for a PU block
239 * \param pcCU
240 * \param uiAbsPartIdx
241 * \param uiDepth
242 * \param uiPartIdx
243 * \returns Void
244 */
245Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
246{
247  UInt uiInterDir;
248
249  if ( pcCU->getSlice()->isInterP() )
250  {
251    uiInterDir = 1;
252  }
253  else
254  {
255    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
256  }
257
258  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
259}
260
261Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
262{
263  Int iRefFrmIdx = 0;
264  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
265
266  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
267  {
268    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
269  }
270  else if ( !iParseRefFrmIdx )
271  {
272    iRefFrmIdx = NOT_VALID;
273  }
274  else
275  {
276    iRefFrmIdx = 0;
277  }
278
279  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
280  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
281}
282
283/** decode motion vector difference for a PU block
284 * \param pcCU
285 * \param uiAbsPartIdx
286 * \param uiDepth
287 * \param uiPartIdx
288 * \param eRefList
289 * \returns Void
290 */
291Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
292{
293  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
294  {
295    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
296  }
297}
298
299Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
300{
301  Int iMVPIdx = -1;
302
303  TComMv cZeroMv( 0, 0 );
304  TComMv cMv     = cZeroMv;
305  Int    iRefIdx = -1;
306
307  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
308  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
309
310  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
311  cMv = cZeroMv;
312
313  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
314  {
315    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
316  }
317  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
318  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
319  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
320  if ( iRefIdx >= 0 )
321  {
322    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
323    cMv += pcSubCUMvField->getMvd( uiPartAddr );
324  }
325
326  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
327  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
328}
329
330Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP)
331{
332  UInt uiSubdiv;
333  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
334
335  if(uiTrIdx==0)
336  {
337    m_bakAbsPartIdxCU = uiAbsPartIdx;
338  }
339  if( uiLog2TrafoSize == 2 )
340  {
341    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
342    if( ( uiAbsPartIdx % partNum ) == 0 )
343    {
344      m_uiBakAbsPartIdx   = uiAbsPartIdx;
345      m_uiBakChromaOffset = offsetChroma;
346    }
347  }
348  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
349  {
350    uiSubdiv = 1;
351  }
352  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
353  {
354    uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));
355  }
356  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
357  {
358    uiSubdiv = 1;
359  }
360  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
361  {
362    uiSubdiv = 0;
363  }
364  else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
365  {
366    uiSubdiv = 0;
367  }
368  else
369  {
370    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
371    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
372  }
373 
374  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
375  {
376    const Bool bFirstCbfOfCU = uiTrDepth == 0;
377    if( bFirstCbfOfCU )
378    {
379      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
380      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
381    }
382    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
383    {
384      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
385      {
386        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
387      }
388      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
389      {
390        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
391      }
392    }
393    else
394    {
395      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
396      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
397    }
398  }
399 
400  if( uiSubdiv )
401  {
402    UInt size;
403    width  >>= 1;
404    height >>= 1;
405    size = width*height;
406    uiTrIdx++;
407    ++uiDepth;
408    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
409    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
410    UInt uiYCbf = 0;
411    UInt uiUCbf = 0;
412    UInt uiVCbf = 0;
413   
414    for( Int i = 0; i < 4; i++ )
415    {
416      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP );
417      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
418      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
419      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
420      uiAbsPartIdx += uiQPartNum;
421      offsetLuma += size;  offsetChroma += (size>>2);
422    }
423   
424    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
425    {
426      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
427      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
428      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
429    }
430  }
431  else
432  {
433    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
434    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
435   
436    {
437      DTRACE_CABAC_VL( g_nSymbolCounter++ );
438      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
439      DTRACE_CABAC_V( uiAbsPartIdx );
440      DTRACE_CABAC_T( "\tdepth=" );
441      DTRACE_CABAC_V( uiDepth );
442      DTRACE_CABAC_T( "\ttrdepth=" );
443      DTRACE_CABAC_V( uiTrDepth );
444      DTRACE_CABAC_T( "\n" );
445    }
446   
447    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
448    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
449    {
450      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
451    }
452    else
453    {
454      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
455    }
456
457
458    // transform_unit begin
459    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
460    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
461    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
462    if( uiLog2TrafoSize == 2 )
463    {
464      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
465      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
466      {
467        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
468        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
469      }
470    }
471    if ( cbfY || cbfU || cbfV )
472    {
473      // dQP: only for LCU
474      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
475      {
476        if ( bCodeDQP )
477        {
478          decodeQP( pcCU, m_bakAbsPartIdxCU);
479          bCodeDQP = false;
480        }
481      }
482    }
483    if( cbfY )
484    {
485      Int trWidth = width;
486      Int trHeight = height;
487      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
488    }
489    if( uiLog2TrafoSize > 2 )
490    {
491      Int trWidth = width >> 1;
492      Int trHeight = height >> 1;
493      if( cbfU )
494      {
495        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
496      }
497      if( cbfV )
498      {
499        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
500      }
501    }
502    else
503    {
504      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
505      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
506      {
507        Int trWidth = width;
508        Int trHeight = height;
509        if( cbfU )
510        {
511          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
512        }
513        if( cbfV )
514        {
515          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
516        }
517      }
518    }
519    // transform_unit end
520  }
521}
522
523Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
524{
525  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
526  {
527    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
528  }
529}
530
531
532/** decode coefficients
533 * \param pcCU
534 * \param uiAbsPartIdx
535 * \param uiDepth
536 * \param uiWidth
537 * \param uiHeight
538 * \returns Void
539 */
540Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
541{
542  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
543  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
544  UInt uiChromaOffset = uiLumaOffset>>2;
545 
546#if H_3D_DIM_SDC
547  if( pcCU->getSDCFlag( uiAbsPartIdx ) )
548  {
549    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
550    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
551    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
552    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
553    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
554    return;
555  }
556#endif
557 
558  if( pcCU->isIntra(uiAbsPartIdx) )
559  {
560  }
561  else
562  {
563    UInt uiQtRootCbf = 1;
564    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
565    {
566      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
567    }
568    if ( !uiQtRootCbf )
569    {
570      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
571      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
572      return;
573    }
574   
575  }
576  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP );
577}
578
579//! \}
Note: See TracBrowser for help on using the repository browser.