source: 3DVCSoftware/branches/HTM-12.1-MV-draft-1/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1342

Last change on this file since 1342 was 1072, checked in by tech, 11 years ago

Removed 3D-HEVC related integrations.

  • 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-2014, 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}
54Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
55{
56  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
57}
58
59/** decode merge flag
60 * \param pcSubCU
61 * \param uiAbsPartIdx
62 * \param uiDepth
63 * \param uiPUIdx
64 * \returns Void
65 */
66Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
67{ 
68  // at least one merge candidate exists
69  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
70}
71
72/** decode merge index
73 * \param pcCU
74 * \param uiPartIdx
75 * \param uiAbsPartIdx
76 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
77 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
78 * \param uiDepth
79 * \returns Void
80 */
81Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
82{
83  UInt uiMergeIndex = 0;
84  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
85  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
86}
87
88
89
90Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
91{
92  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
93}
94
95Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
96{
97  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
98}
99
100Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
101{
102  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
103 
104}
105
106Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
107{
108  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
109  {
110    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
111    decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
112  }
113  else                                                                // if it is Inter mode, encode motion vector and reference index
114  {
115    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
116  }
117}
118
119/** Parse I_PCM information.
120 * \param pcCU  pointer to CUpointer to CU
121 * \param uiAbsPartIdx CU index
122 * \param uiDepth CU depth
123 * \returns Void
124 */
125Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
126{
127  if(!pcCU->getSlice()->getSPS()->getUsePCM()
128    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
129    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
130  {
131    return;
132  }
133 
134  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
135}
136
137Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
138{
139  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
140}
141
142Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
143{
144  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
145}
146
147/** decode motion information for every PU block.
148 * \param pcCU
149 * \param uiAbsPartIdx
150 * \param uiDepth
151 * \param pcSubCU
152 * \returns Void
153 */
154Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
155{
156  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
157  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
158  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
159
160  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
161  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
162  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
163  {
164    uhInterDirNeighbours[ui] = 0;
165  }
166  Int numValidMergeCand = 0;
167  Bool isMerged = false;
168
169  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
170  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
171  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
172  {
173#if H_MV_ENC_DEC_TRAC
174    DTRACE_PU_S("=========== prediction_unit ===========\n")
175    // ToDo:
176    //DTRACE_PU("x0", uiLPelX)
177    //DTRACE_PU("x1", uiTPelY)
178#endif
179    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
180    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
181    {
182      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
183      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
184      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
185      {
186        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
187        if ( !isMerged )
188        {
189          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
190          isMerged = true;
191        }
192        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
193      }
194      else
195      {
196        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
197        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
198      }
199      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
200
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}
340
341Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU)
342{
343  UInt uiSubdiv;
344  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
345
346  if(uiTrIdx==0)
347  {
348    m_bakAbsPartIdxCU = uiAbsPartIdx;
349  }
350  if( uiLog2TrafoSize == 2 )
351  {
352    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
353    if( ( uiAbsPartIdx % partNum ) == 0 )
354    {
355      m_uiBakAbsPartIdx   = uiAbsPartIdx;
356      m_uiBakChromaOffset = offsetChroma;
357    }
358  }
359  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
360  {
361    uiSubdiv = 1;
362  }
363  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
364  {
365    uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU);
366  }
367  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
368  {
369    uiSubdiv = 1;
370  }
371  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
372  {
373    uiSubdiv = 0;
374  }
375  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
376  {
377    uiSubdiv = 0;
378  }
379  else
380  {
381    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
382    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
383  }
384 
385  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
386  {
387    const Bool bFirstCbfOfCU = uiTrDepth == 0;
388    if( bFirstCbfOfCU )
389    {
390      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
391      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
392    }
393    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
394    {
395      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
396      {
397        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
398      }
399      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
400      {
401        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
402      }
403    }
404    else
405    {
406      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
407      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
408    }
409  }
410 
411  if( uiSubdiv )
412  {
413    UInt size;
414    width  >>= 1;
415    height >>= 1;
416    size = width*height;
417    uiTrIdx++;
418    ++uiDepth;
419    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
420    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
421    UInt uiYCbf = 0;
422    UInt uiUCbf = 0;
423    UInt uiVCbf = 0;
424   
425    for( Int i = 0; i < 4; i++ )
426    {
427      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU );
428      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
429      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
430      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
431      uiAbsPartIdx += uiQPartNum;
432      offsetLuma += size;  offsetChroma += (size>>2);
433    }
434   
435    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
436    {
437      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
438      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
439      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
440    }
441  }
442  else
443  {
444    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
445    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
446   
447#if !H_MV_ENC_DEC_TRAC
448    {
449      DTRACE_CABAC_VL( g_nSymbolCounter++ );
450      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
451      DTRACE_CABAC_V( uiAbsPartIdx );
452      DTRACE_CABAC_T( "\tdepth=" );
453      DTRACE_CABAC_V( uiDepth );
454      DTRACE_CABAC_T( "\ttrdepth=" );
455      DTRACE_CABAC_V( uiTrDepth );
456      DTRACE_CABAC_T( "\n" );
457    }
458#endif
459   
460    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
461    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
462    {
463      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
464    }
465    else
466    {
467      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
468    }
469
470
471    // transform_unit begin
472    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
473    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
474    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
475    if( uiLog2TrafoSize == 2 )
476    {
477      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
478      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
479      {
480        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
481        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
482      }
483    }
484    if ( cbfY || cbfU || cbfV )
485    {
486      // dQP: only for LCU
487      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
488      {
489        if ( bCodeDQP )
490        {
491          decodeQP( pcCU, m_bakAbsPartIdxCU);
492          bCodeDQP = false;
493        }
494      }
495    }
496    if( cbfY )
497    {
498      Int trWidth = width;
499      Int trHeight = height;
500      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
501    }
502    if( uiLog2TrafoSize > 2 )
503    {
504      Int trWidth = width >> 1;
505      Int trHeight = height >> 1;
506      if( cbfU )
507      {
508        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
509      }
510      if( cbfV )
511      {
512        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
513      }
514    }
515    else
516    {
517      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
518      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
519      {
520        Int trWidth = width;
521        Int trHeight = height;
522        if( cbfU )
523        {
524          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
525        }
526        if( cbfV )
527        {
528          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
529        }
530      }
531    }
532    // transform_unit end
533  }
534}
535
536Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
537{
538  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
539  {
540    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
541  }
542}
543
544
545/** decode coefficients
546 * \param pcCU
547 * \param uiAbsPartIdx
548 * \param uiDepth
549 * \param uiWidth
550 * \param uiHeight
551 * \returns Void
552 */
553Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
554{
555  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
556  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
557  UInt uiChromaOffset = uiLumaOffset>>2;
558
559  if( pcCU->isIntra(uiAbsPartIdx) )
560  {
561  }
562  else
563  {
564    UInt uiQtRootCbf = 1;
565    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
566    {
567      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
568    }
569    if ( !uiQtRootCbf )
570    {
571      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
572      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
573      return;
574    }
575   
576  }
577
578  Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
579
580  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU );
581}
582
583
584//! \}
Note: See TracBrowser for help on using the repository browser.