source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1200

Last change on this file since 1200 was 1200, checked in by tech, 9 years ago

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
  • Property svn:eol-style set to native
File size: 37.4 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#include "TLibCommon/TComTU.h"
40#include "TLibCommon/TComPrediction.h"
41
42#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
43#include "../TLibCommon/Debug.h"
44static const Bool bDebugRQT = DebugOptionList::DebugRQT.getInt()!=0;
45static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0;
46#endif
47
48//! \ingroup TLibDecoder
49//! \{
50
51Void TDecEntropy::setEntropyDecoder         ( TDecEntropyIf* p )
52{
53  m_pcEntropyDecoderIf = p;
54}
55
56#include "TLibCommon/TComSampleAdaptiveOffset.h"
57
58Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
59{
60  m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
61}
62#if H_3D
63Void TDecEntropy::decodeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
64{
65  if( !pcCU->getSlice()->getDepthIntraSkipFlag() )
66  {
67    return;
68  } 
69
70  m_pcEntropyDecoderIf->parseDIS( pcCU, uiAbsPartIdx, uiDepth );
71}
72#endif
73
74Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
75{
76  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
77}
78
79
80/** decode merge flag
81 * \param pcSubCU
82 * \param uiAbsPartIdx
83 * \param uiDepth
84 * \param uiPUIdx
85 * \returns Void
86 */
87Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
88{
89  // at least one merge candidate exists
90  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
91}
92
93/** decode merge index
94 * \param pcCU
95 * \param uiPartIdx
96 * \param uiAbsPartIdx
97 * \param uiDepth
98 * \returns Void
99 */
100Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
101{
102  UInt uiMergeIndex = 0;
103  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
104  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
105}
106
107#if H_3D_ARP
108Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
109{
110  if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
111  {
112    return;
113  }
114
115  if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
116  {
117    pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth );
118  }
119  else
120  {
121    m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth );
122  }
123}
124#endif
125
126#if H_3D_IC
127Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
128{
129  pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
130
131  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
132  {
133    return;
134  }
135
136  if( !pcCU->getSlice()->getApplyIC() )
137    return;
138
139  if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
140    m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth );
141}
142#endif
143
144Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
145{
146  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
147}
148
149Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
150{
151  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
152}
153
154Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
155{
156  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
157}
158
159Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
160{
161  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
162  {
163    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
164#if H_3D_DIM_SDC
165    decodeSDCFlag   ( pcCU, uiAbsPartIdx, uiDepth );
166    if(!pcCU->getSDCFlag(uiAbsPartIdx))
167#endif
168    if (pcCU->getPic()->getChromaFormat()!=CHROMA_400)
169    {
170      decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
171      if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN)
172      {
173        UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2;
174        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset,   uiDepth+1 );
175        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 );
176        decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 );
177      }
178    }
179  }
180  else                                                                // if it is Inter mode, encode motion vector and reference index
181  {
182    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
183  }
184}
185
186/** Parse I_PCM information.
187 * \param pcCU  pointer to CUpointer to CU
188 * \param uiAbsPartIdx CU index
189 * \param uiDepth CU depth
190 * \returns Void
191 */
192Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
193{
194  if(!pcCU->getSlice()->getSPS()->getUsePCM()
195    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
196    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
197  {
198    return;
199  }
200
201  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
202}
203
204Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
205{
206  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
207}
208
209Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
210{
211  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
212#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
213  if (bDebugPredEnabled)
214  {
215    UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx);
216    if (cdir==36)
217    {
218      cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx);
219    }
220    printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx));
221  }
222#endif
223}
224
225
226/** decode motion information for every PU block.
227 * \param pcCU
228 * \param uiAbsPartIdx
229 * \param uiDepth
230 * \param pcSubCU
231 * \returns Void
232 */
233Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
234{
235  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
236  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
237  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
238#if H_3D_IV_MERGE
239  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
240  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
241#else
242  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
243  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
244#endif
245#if H_3D_SPIVMP
246  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];     
247  TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
248  UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
249#endif
250#if H_3D_IV_MERGE
251  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
252#endif
253  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
254  {
255    uhInterDirNeighbours[ui] = 0;
256  }
257  Int numValidMergeCand = 0;
258  Bool hasMergedCandList = false;
259
260  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
261  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
262#if H_3D
263  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
264  {
265#if H_MV_ENC_DEC_TRAC
266    DTRACE_PU_S("=========== prediction_unit ===========\n")
267    // ToDo:
268    //DTRACE_PU("x0", uiLPelX)
269    //DTRACE_PU("x1", uiTPelY)
270#endif
271
272    ////// Parse PUs syntax
273    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
274    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
275    {
276      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );     
277    }
278    else
279    {
280      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
281      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
282      {       
283        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
284        {
285          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
286          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
287          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
288        }
289      }
290    }
291  }
292
293  ////// Parse CUs extension syntax
294  decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); 
295  decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth ); 
296
297#if H_3D_ARP
298  decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
299#endif
300#if H_3D_IC
301  decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
302#endif
303
304  ////// Decode motion vectors
305  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
306  {
307    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
308    {
309      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
310#if H_3D_DBBP
311      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
312#else
313      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
314#endif
315      {
316        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
317        if ( !isMerged )
318        {
319#if H_3D_VSP
320          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
321          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
322#if H_3D_SPIVMP
323          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
324#endif
325          pcSubCU->initAvailableFlags();
326          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
327          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
328#if H_3D_SPIVMP
329            , pcMvFieldSP, puhInterDirSP
330#endif
331            , numValidMergeCand );
332          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
333#if H_3D_SPIVMP
334            , bSPIVMPFlag
335#endif
336            , numValidMergeCand );
337          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
338
339#else
340#if H_3D
341          pcSubCU->initAvailableFlags();
342          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
343          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
344
345#else
346          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
347#endif
348#endif
349          isMerged = true;
350        }
351        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
352      }
353      else
354      {
355        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
356#if H_3D_VSP
357        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
358        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
359#if H_3D_SPIVMP
360        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
361#endif
362        pcSubCU->initAvailableFlags();
363        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
364        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
365#if H_3D_SPIVMP
366          , pcMvFieldSP, puhInterDirSP
367#endif
368          ,numValidMergeCand, uiMergeIndex );
369        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
370#if H_3D_SPIVMP
371          , bSPIVMPFlag
372#endif
373          ,numValidMergeCand );
374        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
375#else
376#if H_3D
377        pcSubCU->initAvailableFlags();
378        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
379        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
380#else
381        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
382#endif
383#endif
384      }
385      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
386
387      TComMv cTmpMv( 0, 0 );
388      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
389      {       
390        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
391        {
392          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
393          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
394          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
395          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
396#if H_3D_VSP
397#if H_3D_DBBP
398          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
399#else
400          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
401#endif
402          {
403            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
404            {
405              UInt dummy;
406              Int vspSize;
407              Int width, height;
408              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
409              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
410              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
411            }
412          }
413#endif
414        }
415      }
416#if H_3D_SPIVMP
417      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
418      if (bSPIVMPFlag[uiMergeIndex] != 0)
419      {
420        Int iWidth, iHeight;
421        UInt uiIdx;
422        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
423
424        UInt uiSPAddr;
425
426        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
427
428        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
429
430        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
431        {
432          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
433          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
434          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
435          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
436        }
437      }
438#endif
439    }
440    else
441    {
442      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
443      {       
444        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
445        {
446          decodeMvsAMVP   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
447        }
448      }
449    }
450
451    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
452    {
453      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
454      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
455      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
456    }
457  }
458#else
459  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
460  {
461#if H_MV_ENC_DEC_TRAC
462    DTRACE_PU_S("=========== prediction_unit ===========\n")
463    // ToDo:
464    //DTRACE_PU("x0", uiLPelX)
465    //DTRACE_PU("x1", uiTPelY)
466#endif
467    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
468    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
469    {
470      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
471#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
472      if (bDebugPredEnabled)
473      {
474        std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx;
475        std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl;
476      }
477#endif
478
479      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
480      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 )
481      {
482        if ( !hasMergedCandList )
483        {
484          pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
485          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
486          pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
487          hasMergedCandList = true;
488        }
489      }
490      else
491      {
492        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
493        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
494      }
495
496      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
497
498      TComMv cTmpMv( 0, 0 );
499      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
500      {
501        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
502        {
503          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
504          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
505          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
506          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
507
508        }
509      }
510    }
511    else
512    {
513      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
514      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
515      {
516        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
517        {
518          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
519          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
520          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
521#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
522          if (bDebugPredEnabled)
523          {
524            std::cout << "refListIdx: " << uiRefListIdx << std::endl;
525            std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl;
526            std::cout << "MVD vertical:   " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl;
527            std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl;
528            std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl;
529          }
530#endif
531        }
532      }
533    }
534
535    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
536    {
537      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
538      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
539      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
540    }
541  }
542#endif
543#if H_3D_SPIVMP
544  delete[] pcMvFieldSP;
545  delete[] puhInterDirSP;
546#endif
547  return;
548}
549
550/** decode inter direction for a PU block
551 * \param pcCU
552 * \param uiAbsPartIdx
553 * \param uiDepth
554 * \param uiPartIdx
555 * \returns Void
556 */
557Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
558{
559  UInt uiInterDir;
560
561  if ( pcCU->getSlice()->isInterP() )
562  {
563    uiInterDir = 1;
564  }
565  else
566  {
567    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
568  }
569
570  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
571}
572
573Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
574{
575  Int iRefFrmIdx = 0;
576  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
577
578  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
579  {
580    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
581  }
582  else if ( !iParseRefFrmIdx )
583  {
584    iRefFrmIdx = NOT_VALID;
585  }
586  else
587  {
588    iRefFrmIdx = 0;
589  }
590
591  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
592  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
593}
594
595/** decode motion vector difference for a PU block
596 * \param pcCU
597 * \param uiAbsPartIdx
598 * \param uiDepth
599 * \param uiPartIdx
600 * \param eRefList
601 * \returns Void
602 */
603Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
604{
605  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
606  {
607    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
608  }
609}
610
611#if H_3D
612Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
613{
614  Int iMVPIdx = -1;
615
616  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
617  {
618    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
619#if H_MV_ENC_DEC_TRAC
620#if ENC_DEC_TRACE
621    if ( eRefList == REF_PIC_LIST_0 )
622    {
623      DTRACE_PU("mvp_l0_flag", iMVPIdx)
624    }
625    else
626    {
627      DTRACE_PU("mvp_l1_flag", iMVPIdx)
628    }
629#endif
630#endif
631  }
632  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
633}
634
635Void TDecEntropy::decodeMvsAMVP( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
636{
637  TComMv cZeroMv( 0, 0 );
638  TComMv cMv     = cZeroMv;
639  Int    iRefIdx = -1;
640
641  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
642  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
643
644  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
645  cMv = cZeroMv;
646
647  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
648  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
649  if ( iRefIdx >= 0 )
650  {
651    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
652    cMv += pcSubCUMvField->getMvd( uiPartAddr );
653  }
654
655  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
656  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
657}
658#else
659Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
660{
661  Int iMVPIdx = -1;
662
663  TComMv cZeroMv( 0, 0 );
664  TComMv cMv     = cZeroMv;
665  Int    iRefIdx = -1;
666
667  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
668  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
669
670  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
671  cMv = cZeroMv;
672
673  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
674  {
675    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
676#if H_MV_ENC_DEC_TRAC
677#if ENC_DEC_TRACE
678    if ( eRefList == REF_PIC_LIST_0 )
679    {
680      DTRACE_PU("mvp_l0_flag", iMVPIdx)
681    }
682    else
683    {
684      DTRACE_PU("mvp_l1_flag", iMVPIdx)
685    }
686#endif
687#endif
688  }
689  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
690  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
691  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
692  if ( iRefIdx >= 0 )
693  {
694    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
695    cMv += pcSubCUMvField->getMvd( uiPartAddr );
696  }
697
698  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
699  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
700}
701#endif
702
703Void TDecEntropy::xDecodeTransform        ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU )
704{
705
706  TComDataCU *pcCU=rTu.getCU();
707  const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU();
708  const UInt uiDepth=rTu.GetTransformDepthTotal();
709  const UInt uiTrDepth = rTu.GetTransformDepthRel();
710
711#if H_MV_ENC_DEC_TRAC
712#if ENC_DEC_TRACE
713  UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
714  UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
715
716  DTRACE_TU_S("=========== transform_tree ===========\n")
717  DTRACE_TU("x0", uiLPelX)
718  DTRACE_TU("x1", uiTPelY)
719 
720  DTRACE_TU("log2TrafoSize", pcCU->getSlice()->getSPS()->getMaxCUWidth()  >> uiDepth )
721  DTRACE_TU("trafoDepth"  , uiDepth)
722#endif
723#endif
724
725  UInt uiSubdiv;
726  const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents();
727  const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat());
728
729  const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize();
730#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
731  if (bDebugRQT)
732  {
733    printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n",
734        rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber());
735    fflush(stdout);
736  }
737#endif
738
739  if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
740  {
741    uiSubdiv = 1;
742  }
743  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
744  {
745    uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU);
746  }
747  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
748  {
749    uiSubdiv = 1;
750  }
751  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
752  {
753    uiSubdiv = 0;
754  }
755  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
756  {
757    uiSubdiv = 0;
758  }
759  else
760  {
761    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
762    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
763  }
764
765  for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++)
766  {
767    const ComponentID compID=ComponentID(chan);
768    const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID);
769
770    const Bool bFirstCbfOfCU = uiTrDepth == 0;
771
772    if( bFirstCbfOfCU )
773    {
774      pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj);
775    }
776    if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) )
777    {
778      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) )
779      {
780        m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) );
781      }
782    }
783  }
784
785  if( uiSubdiv )
786  {
787    const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1);
788    UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0};
789
790    TComTURecurse tuRecurseChild(rTu, true);
791
792    do
793    {
794      xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU );
795      UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU();
796      for(UInt ch=0; ch<numValidComponent; ch++)
797      {
798        uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch),  uiTrDepth+1 );
799      }
800    } while (tuRecurseChild.nextSection(rTu) );
801
802    for(UInt ch=0; ch<numValidComponent; ch++)
803    {
804      UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx;
805      const UChar flag = uiYUVCbf[ch] << uiTrDepth;
806
807      for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
808      {
809        pBase[ui] |= flag;
810      }
811    }
812  }
813  else
814  {
815    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
816    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
817
818#if !H_MV_ENC_DEC_TRAC
819    {
820      DTRACE_CABAC_VL( g_nSymbolCounter++ );
821      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
822      DTRACE_CABAC_V( uiAbsPartIdx );
823      DTRACE_CABAC_T( "\tdepth=" );
824      DTRACE_CABAC_V( uiDepth );
825      DTRACE_CABAC_T( "\ttrdepth=" );
826      DTRACE_CABAC_V( uiTrDepth );
827      DTRACE_CABAC_T( "\n" );
828    }
829#endif
830
831    pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth );
832
833    if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) ))
834    {
835      pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth );
836    }
837    else
838    {
839      m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true );
840    }
841
842
843    // transform_unit begin
844    UInt cbf[MAX_NUM_COMPONENT]={0,0,0};
845    Bool validCbf       = false;
846    Bool validChromaCbf = false;
847    const UInt uiTrIdx = rTu.GetTransformDepthRel();
848
849    for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++)
850    {
851      const ComponentID compID = ComponentID(ch);
852
853      cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx );
854
855      if (cbf[compID] != 0)
856      {
857        validCbf = true;
858        if (isChroma(compID))
859        {
860          validChromaCbf = true;
861        }
862      }
863    }
864
865    if ( validCbf )
866    {
867
868      // dQP: only for CTU
869      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
870      {
871        if ( bCodeDQP )
872        {
873          const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU();
874          decodeQP( pcCU, uiAbsPartIdxCU);
875          bCodeDQP = false;
876        }
877      }
878
879      if ( pcCU->getSlice()->getUseChromaQpAdj() )
880      {
881        if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) )
882        {
883          decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() );
884          isChromaQpAdjCoded = false;
885        }
886      }
887
888      const UInt numValidComp=pcCU->getPic()->getNumberValidComponents();
889
890      for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++)
891      {
892        const ComponentID compID=ComponentID(ch);
893
894        if( rTu.ProcessComponentSection(compID) )
895        {
896#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
897          if (bDebugRQT)
898          {
899            printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1);
900          }
901#endif
902
903          if (rTu.getRect(compID).width != rTu.getRect(compID).height)
904          {
905            //code two sub-TUs
906            TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID);
907
908            do
909            {
910              const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1));
911
912              if (subTUCBF != 0)
913              {
914#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
915                if (bDebugRQT)
916                {
917                  printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1);
918                }
919#endif
920                m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID );
921              }
922            } while (subTUIterator.nextSection(rTu));
923          }
924          else
925          {
926            if(isChroma(compID) && (cbf[COMPONENT_Y] != 0))
927            {
928              m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID );
929            }
930
931            if(cbf[compID] != 0)
932            {
933              m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID );
934            }
935          }
936        }
937      }
938    }
939    // transform_unit end
940  }
941}
942
943Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
944{
945  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
946  {
947    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
948  }
949}
950
951Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx )
952{
953  if ( pcCU->getSlice()->getUseChromaQpAdj() )
954  {
955    m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
956  }
957}
958
959
960//! decode coefficients
961Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded )
962{
963#if H_3D_DIM_SDC
964  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
965  {
966    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
967    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
968    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
969    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
970    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
971}
972#if H_3D_INTER_SDC
973  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
974  {
975    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
976    assert( !pcCU->isIntra( uiAbsPartIdx) );
977    assert( pcCU->getSlice()->getIsDepth() );
978  }
979#endif
980  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
981  {
982    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
983    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
984 
985    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
986    {
987      for( Int iPart = 0; iPart < iPartNum; iPart++ )
988      {
989        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
990        {
991          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
992        }
993      }
994    }
995    else
996    {
997      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
998      return;
999    }
1000  }
1001#endif
1002
1003  if( pcCU->isIntra(uiAbsPartIdx) )
1004  {
1005  }
1006  else
1007  {
1008    UInt uiQtRootCbf = 1;
1009    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
1010    {
1011      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
1012    }
1013    if ( !uiQtRootCbf )
1014    {
1015      static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0};
1016      pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth );
1017      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
1018      return;
1019    }
1020
1021  }
1022
1023  TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth);
1024
1025#if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST
1026  if (bDebugRQT)
1027  {
1028    printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN);
1029  }
1030#endif
1031
1032  Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
1033 
1034  xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU );
1035}
1036
1037#if H_3D_INTER_SDC
1038Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1039{
1040  pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
1041  if ( pcCU->isSkipped( uiAbsPartIdx ) )
1042  {
1043    return; 
1044  }
1045
1046
1047  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || 
1048    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
1049  {
1050    return;
1051  }
1052
1053  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
1054  {
1055    return;
1056  }
1057
1058  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
1059  m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
1060}
1061#endif
1062#if H_3D_DBBP
1063Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1064{
1065  if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
1066  {
1067    m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
1068  }
1069}
1070#endif
1071
1072
1073
1074//! \}
Note: See TracBrowser for help on using the repository browser.