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

Last change on this file since 464 was 464, checked in by zhang, 11 years ago

Implementation of ARP from QC

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