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

Last change on this file since 476 was 476, checked in by mediatek-htm, 11 years ago

Integration of 3D-HEVC merge related coding tools:
Inter-view motion merge candidate
HHI_INTER_VIEW_MOTION_PRED
SAIT_IMPROV_MOTION_PRED_M24829, improved inter-view motion vector prediction
QC_MRG_CANS_B0048 , JCT3V-B0048, B0086, B0069
OL_DISMV_POS_B0069 , different pos for disparity MV candidate, B0069
MTK_INTERVIEW_MERGE_A0049 , second part
QC_AMVP_MRG_UNIFY_IVCAN_C0051
TEXTURE MERGING CANDIDATE , JCT3V-C0137

Notes: Two configurations are added:
PredDepthMapGen : 1
MultiviewMvPred : 7

From: yiwen.chen@… (MediaTek)

  • Property svn:eol-style set to native
File size: 20.1 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    decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
110  }
111  else                                                                // if it is Inter mode, encode motion vector and reference index
112  {
113    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
114  }
115}
116
117/** Parse I_PCM information.
118 * \param pcCU  pointer to CUpointer to CU
119 * \param uiAbsPartIdx CU index
120 * \param uiDepth CU depth
121 * \returns Void
122 */
123Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
124{
125  if(!pcCU->getSlice()->getSPS()->getUsePCM()
126    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
127    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
128  {
129    return;
130  }
131 
132  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
133}
134
135Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
136{
137  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
138}
139
140Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
141{
142  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
143}
144
145/** decode motion information for every PU block.
146 * \param pcCU
147 * \param uiAbsPartIdx
148 * \param uiDepth
149 * \param pcSubCU
150 * \returns Void
151 */
152Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
153{
154  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
155  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
156  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
157
158#if H_3D_IV_MERGE
159  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
160  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
161#else
162  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
163  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
164#endif
165
166  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
167  {
168    uhInterDirNeighbours[ui] = 0;
169  }
170  Int numValidMergeCand = 0;
171  Bool isMerged = false;
172
173  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
174  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
175#if H_3D_IV_MERGE
176  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
177#endif
178  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
179  {
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  }
316  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
317  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
318  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
319  if ( iRefIdx >= 0 )
320  {
321    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
322    cMv += pcSubCUMvField->getMvd( uiPartAddr );
323  }
324
325  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
326  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
327}
328
329Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP)
330{
331  UInt uiSubdiv;
332  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
333
334  if(uiTrIdx==0)
335  {
336    m_bakAbsPartIdxCU = uiAbsPartIdx;
337  }
338  if( uiLog2TrafoSize == 2 )
339  {
340    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
341    if( ( uiAbsPartIdx % partNum ) == 0 )
342    {
343      m_uiBakAbsPartIdx   = uiAbsPartIdx;
344      m_uiBakChromaOffset = offsetChroma;
345    }
346  }
347  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
348  {
349    uiSubdiv = 1;
350  }
351  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
352  {
353    uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx));
354  }
355  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
356  {
357    uiSubdiv = 1;
358  }
359  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
360  {
361    uiSubdiv = 0;
362  }
363  else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) )
364  {
365    uiSubdiv = 0;
366  }
367  else
368  {
369    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
370    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
371  }
372 
373  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
374  {
375    const Bool bFirstCbfOfCU = uiTrDepth == 0;
376    if( bFirstCbfOfCU )
377    {
378      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
379      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
380    }
381    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
382    {
383      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
384      {
385        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
386      }
387      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
388      {
389        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
390      }
391    }
392    else
393    {
394      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
395      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
396    }
397  }
398 
399  if( uiSubdiv )
400  {
401    UInt size;
402    width  >>= 1;
403    height >>= 1;
404    size = width*height;
405    uiTrIdx++;
406    ++uiDepth;
407    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
408    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
409    UInt uiYCbf = 0;
410    UInt uiUCbf = 0;
411    UInt uiVCbf = 0;
412   
413    for( Int i = 0; i < 4; i++ )
414    {
415      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP );
416      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
417      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
418      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
419      uiAbsPartIdx += uiQPartNum;
420      offsetLuma += size;  offsetChroma += (size>>2);
421    }
422   
423    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
424    {
425      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
426      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
427      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
428    }
429  }
430  else
431  {
432    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
433    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
434   
435    {
436      DTRACE_CABAC_VL( g_nSymbolCounter++ );
437      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
438      DTRACE_CABAC_V( uiAbsPartIdx );
439      DTRACE_CABAC_T( "\tdepth=" );
440      DTRACE_CABAC_V( uiDepth );
441      DTRACE_CABAC_T( "\ttrdepth=" );
442      DTRACE_CABAC_V( uiTrDepth );
443      DTRACE_CABAC_T( "\n" );
444    }
445   
446    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
447    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
448    {
449      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
450    }
451    else
452    {
453      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
454    }
455
456
457    // transform_unit begin
458    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
459    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
460    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
461    if( uiLog2TrafoSize == 2 )
462    {
463      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
464      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
465      {
466        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
467        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
468      }
469    }
470    if ( cbfY || cbfU || cbfV )
471    {
472      // dQP: only for LCU
473      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
474      {
475        if ( bCodeDQP )
476        {
477          decodeQP( pcCU, m_bakAbsPartIdxCU);
478          bCodeDQP = false;
479        }
480      }
481    }
482    if( cbfY )
483    {
484      Int trWidth = width;
485      Int trHeight = height;
486      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
487    }
488    if( uiLog2TrafoSize > 2 )
489    {
490      Int trWidth = width >> 1;
491      Int trHeight = height >> 1;
492      if( cbfU )
493      {
494        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
495      }
496      if( cbfV )
497      {
498        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
499      }
500    }
501    else
502    {
503      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
504      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
505      {
506        Int trWidth = width;
507        Int trHeight = height;
508        if( cbfU )
509        {
510          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
511        }
512        if( cbfV )
513        {
514          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
515        }
516      }
517    }
518    // transform_unit end
519  }
520}
521
522Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
523{
524  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
525  {
526    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
527  }
528}
529
530
531/** decode coefficients
532 * \param pcCU
533 * \param uiAbsPartIdx
534 * \param uiDepth
535 * \param uiWidth
536 * \param uiHeight
537 * \returns Void
538 */
539Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
540{
541  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
542  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
543  UInt uiChromaOffset = uiLumaOffset>>2;
544 
545  if( pcCU->isIntra(uiAbsPartIdx) )
546  {
547  }
548  else
549  {
550    UInt uiQtRootCbf = 1;
551    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
552    {
553      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
554    }
555    if ( !uiQtRootCbf )
556    {
557      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
558      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
559      return;
560    }
561   
562  }
563  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP );
564}
565
566//! \}
Note: See TracBrowser for help on using the repository browser.