source: 3DVCSoftware/branches/HTM-14.0-MV-draft-3/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1213

Last change on this file since 1213 was 1191, checked in by tech, 10 years ago

Removed 3D-HEVC.

  • Property svn:eol-style set to native
File size: 20.7 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license. 
5 *
6* Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     TDecEntropy.cpp
35    \brief    entropy decoder class
36*/
37
38#include "TDecEntropy.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43Void TDecEntropy::setEntropyDecoder         ( TDecEntropyIf* p )
44{
45  m_pcEntropyDecoderIf = p;
46}
47
48#include "TLibCommon/TComSampleAdaptiveOffset.h"
49
50Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
51{
52  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
53}
54
55
56Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
57{
58  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
59}
60
61/** decode merge flag
62 * \param pcSubCU
63 * \param uiAbsPartIdx
64 * \param uiDepth
65 * \param uiPUIdx
66 * \returns Void
67 */
68Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
69{ 
70  // at least one merge candidate exists
71  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
72}
73
74/** decode merge index
75 * \param pcCU
76 * \param uiPartIdx
77 * \param uiAbsPartIdx
78 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
79 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
80 * \param uiDepth
81 * \returns Void
82 */
83Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
84{
85  UInt uiMergeIndex = 0;
86  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
87  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
88}
89
90
91
92Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
93{
94  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
95}
96
97Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
98{
99  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
100}
101
102Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
103{
104  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
105}
106
107Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
108{
109  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
110  {
111    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
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 
135  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
136}
137
138Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
139{
140  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
141}
142
143Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
144{
145  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
146}
147
148/** decode motion information for every PU block.
149 * \param pcCU
150 * \param uiAbsPartIdx
151 * \param uiDepth
152 * \param pcSubCU
153 * \returns Void
154 */
155Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
156{
157  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
158  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
159  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
160
161  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
162  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
163  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
164  {
165    uhInterDirNeighbours[ui] = 0;
166  }
167  Int numValidMergeCand = 0;
168  Bool isMerged = false;
169
170  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
171  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
172  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
173  {
174#if H_MV_ENC_DEC_TRAC
175    DTRACE_PU_S("=========== prediction_unit ===========\n")
176    // ToDo:
177    //DTRACE_PU("x0", uiLPelX)
178    //DTRACE_PU("x1", uiTPelY)
179#endif
180    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
181    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
182    {
183      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
184      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
185      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
186      {
187        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
188        if ( !isMerged )
189        {
190          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
191          isMerged = true;
192        }
193        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
194      }
195      else
196      {
197        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
198        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
199      }
200      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
201
202      TComMv cTmpMv( 0, 0 );
203      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
204      {       
205        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
206        {
207          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
208          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
209          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
210          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
211        }
212      }
213    }
214    else
215    {
216      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
217      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
218      {       
219        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
220        {
221          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
222          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
223          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
224        }
225      }
226    }
227    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
228    {
229      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
230      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
231      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
232    }
233  }
234  return;
235}
236
237/** decode inter direction for a PU block
238 * \param pcCU
239 * \param uiAbsPartIdx
240 * \param uiDepth
241 * \param uiPartIdx
242 * \returns Void
243 */
244Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
245{
246  UInt uiInterDir;
247
248  if ( pcCU->getSlice()->isInterP() )
249  {
250    uiInterDir = 1;
251  }
252  else
253  {
254    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
255  }
256
257  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
258}
259
260Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
261{
262  Int iRefFrmIdx = 0;
263  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
264
265  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
266  {
267    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
268  }
269  else if ( !iParseRefFrmIdx )
270  {
271    iRefFrmIdx = NOT_VALID;
272  }
273  else
274  {
275    iRefFrmIdx = 0;
276  }
277
278  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
279  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
280}
281
282/** decode motion vector difference for a PU block
283 * \param pcCU
284 * \param uiAbsPartIdx
285 * \param uiDepth
286 * \param uiPartIdx
287 * \param eRefList
288 * \returns Void
289 */
290Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
291{
292  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
293  {
294    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
295  }
296}
297
298Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
299{
300  Int iMVPIdx = -1;
301
302  TComMv cZeroMv( 0, 0 );
303  TComMv cMv     = cZeroMv;
304  Int    iRefIdx = -1;
305
306  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
307  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
308
309  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
310  cMv = cZeroMv;
311
312  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
313  {
314    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
315#if H_MV_ENC_DEC_TRAC
316#if ENC_DEC_TRACE
317    if ( eRefList == REF_PIC_LIST_0 )
318    {
319      DTRACE_PU("mvp_l0_flag", iMVPIdx)
320    }
321    else
322    {
323      DTRACE_PU("mvp_l1_flag", iMVPIdx)
324    }
325#endif
326#endif
327  }
328  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
329  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
330  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
331  if ( iRefIdx >= 0 )
332  {
333    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
334    cMv += pcSubCUMvField->getMvd( uiPartAddr );
335  }
336
337  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
338  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
339}
340Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU)
341{
342
343#if H_MV_ENC_DEC_TRAC
344#if ENC_DEC_TRACE
345  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
346  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
347 
348  DTRACE_TU_S("=========== transform_tree ===========\n")
349  DTRACE_TU("x0", uiLPelX)
350  DTRACE_TU("x1", uiTPelY)
351  DTRACE_TU("log2TrafoSize", g_uiMaxCUWidth>>uiDepth)
352  DTRACE_TU("trafoDepth"  , uiDepth)
353#endif
354#endif
355
356  UInt uiSubdiv;
357  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
358
359  if(uiTrIdx==0)
360  {
361    m_bakAbsPartIdxCU = uiAbsPartIdx;
362  }
363  if( uiLog2TrafoSize == 2 )
364  {
365    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
366    if( ( uiAbsPartIdx % partNum ) == 0 )
367    {
368      m_uiBakAbsPartIdx   = uiAbsPartIdx;
369      m_uiBakChromaOffset = offsetChroma;
370    }
371  }
372  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
373  {
374    uiSubdiv = 1;
375  }
376  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
377  {
378    uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU);
379  }
380  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
381  {
382    uiSubdiv = 1;
383  }
384  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
385  {
386    uiSubdiv = 0;
387  }
388  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
389  {
390    uiSubdiv = 0;
391  }
392  else
393  {
394    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
395    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
396  }
397 
398  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
399  {
400    const Bool bFirstCbfOfCU = uiTrDepth == 0;
401    if( bFirstCbfOfCU )
402    {
403      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
404      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
405    }
406    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
407    {
408      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
409      {
410        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
411      }
412      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
413      {
414        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
415      }
416    }
417    else
418    {
419      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
420      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
421    }
422  }
423 
424  if( uiSubdiv )
425  {
426    UInt size;
427    width  >>= 1;
428    height >>= 1;
429    size = width*height;
430    uiTrIdx++;
431    ++uiDepth;
432    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
433    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
434    UInt uiYCbf = 0;
435    UInt uiUCbf = 0;
436    UInt uiVCbf = 0;
437   
438    for( Int i = 0; i < 4; i++ )
439    {
440      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU );
441      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
442      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
443      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
444      uiAbsPartIdx += uiQPartNum;
445      offsetLuma += size;  offsetChroma += (size>>2);
446    }
447   
448    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
449    {
450      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
451      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
452      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
453    }
454  }
455  else
456  {
457    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
458    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
459   
460#if !H_MV_ENC_DEC_TRAC
461    {
462      DTRACE_CABAC_VL( g_nSymbolCounter++ );
463      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
464      DTRACE_CABAC_V( uiAbsPartIdx );
465      DTRACE_CABAC_T( "\tdepth=" );
466      DTRACE_CABAC_V( uiDepth );
467      DTRACE_CABAC_T( "\ttrdepth=" );
468      DTRACE_CABAC_V( uiTrDepth );
469      DTRACE_CABAC_T( "\n" );
470    }
471#endif
472   
473    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
474    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
475    {
476      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
477    }
478    else
479    {
480      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
481    }
482
483
484    // transform_unit begin
485    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
486    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
487    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
488    if( uiLog2TrafoSize == 2 )
489    {
490      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
491      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
492      {
493        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
494        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
495      }
496    }
497    if ( cbfY || cbfU || cbfV )
498    {
499      // dQP: only for LCU
500      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
501      {
502        if ( bCodeDQP )
503        {
504          decodeQP( pcCU, m_bakAbsPartIdxCU);
505          bCodeDQP = false;
506        }
507      }
508    }
509    if( cbfY )
510    {
511      Int trWidth = width;
512      Int trHeight = height;
513      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
514    }
515    if( uiLog2TrafoSize > 2 )
516    {
517      Int trWidth = width >> 1;
518      Int trHeight = height >> 1;
519      if( cbfU )
520      {
521        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
522      }
523      if( cbfV )
524      {
525        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
526      }
527    }
528    else
529    {
530      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
531      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
532      {
533        Int trWidth = width;
534        Int trHeight = height;
535        if( cbfU )
536        {
537          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
538        }
539        if( cbfV )
540        {
541          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
542        }
543      }
544    }
545    // transform_unit end
546  }
547}
548
549Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
550{
551  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
552  {
553    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
554  }
555}
556
557
558/** decode coefficients
559 * \param pcCU
560 * \param uiAbsPartIdx
561 * \param uiDepth
562 * \param uiWidth
563 * \param uiHeight
564 * \returns Void
565 */
566Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
567{
568  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
569  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
570  UInt uiChromaOffset = uiLumaOffset>>2;
571
572  if( pcCU->isIntra(uiAbsPartIdx) )
573  {
574  }
575  else
576  {
577    UInt uiQtRootCbf = 1;
578    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
579    {
580      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
581    }
582    if ( !uiQtRootCbf )
583    {
584      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
585      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
586      return;
587    }
588   
589  }
590
591  Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
592
593  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU );
594}
595
596
597//! \}
Note: See TracBrowser for help on using the repository browser.