source: 3DVCSoftware/branches/HTM-12.2-dev2-HHI/source/Lib/TLibDecoder/TDecEntropy.cpp @ 1106

Last change on this file since 1106 was 1106, checked in by tech, 9 years ago
  • HHI_TOOL_PARAMETERS_I2_J0107: Tool parameters moved to SPS and combined with dependency flags
  • Related update of cfg files.
  • Property svn:eol-style set to native
File size: 30.8 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}
54#if H_3D_SINGLE_DEPTH
55Void TDecEntropy::decodeSingleDepthMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
56{
57  if ( !pcCU->getSlice()->getIsDepth() )
58  {
59    return;
60  }
61  if(!pcCU->getSlice()->getApplySingleDepthMode())
62  {
63     return;
64  }
65  m_pcEntropyDecoderIf->parseSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth );
66}
67#endif
68Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
69{
70  m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
71}
72
73/** decode merge flag
74 * \param pcSubCU
75 * \param uiAbsPartIdx
76 * \param uiDepth
77 * \param uiPUIdx
78 * \returns Void
79 */
80Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
81{ 
82  // at least one merge candidate exists
83  m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx );
84}
85
86/** decode merge index
87 * \param pcCU
88 * \param uiPartIdx
89 * \param uiAbsPartIdx
90 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours
91 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours
92 * \param uiDepth
93 * \returns Void
94 */
95Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
96{
97  UInt uiMergeIndex = 0;
98  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
99  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
100}
101
102#if H_3D_ARP
103Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
104{
105  if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) )
106  {
107    return;
108  }
109
110  if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
111  {
112    pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth );
113  }
114  else
115  {
116    m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth );
117  }
118}
119#endif
120
121#if H_3D_IC
122Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
123{
124  pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
125
126  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
127  {
128    return;
129  }
130
131  if( !pcCU->getSlice()->getApplyIC() )
132    return;
133
134  if( pcCU->isICFlagRequired( uiAbsPartIdx ) )
135    m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth );
136}
137#endif
138
139Void TDecEntropy::decodeSplitFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
140{
141  m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
142}
143
144Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
145{
146  m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
147}
148
149Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
150{
151  m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
152 
153#if H_3D_DBBP
154#if SEC_DBBP_VIEW_REF_CHECK_J0037
155  #if HHI_TOOL_PARAMETERS_I2_J0107
156if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
157#else
158if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 && pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
159#endif
160#else
161  if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && pcCU->getWidth(uiAbsPartIdx) > 8 )
162#endif
163  {
164    decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth);
165  }
166#endif
167}
168
169Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
170{
171  if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
172  {
173    decodeIntraDirModeLuma  ( pcCU, uiAbsPartIdx, uiDepth );
174#if H_3D_DIM_SDC
175    if(!pcCU->getSDCFlag(uiAbsPartIdx))
176#endif
177    decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth );
178  }
179  else                                                                // if it is Inter mode, encode motion vector and reference index
180  {
181    decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU );
182  }
183}
184
185/** Parse I_PCM information.
186 * \param pcCU  pointer to CUpointer to CU
187 * \param uiAbsPartIdx CU index
188 * \param uiDepth CU depth
189 * \returns Void
190 */
191Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
192{
193  if(!pcCU->getSlice()->getSPS()->getUsePCM()
194    || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize())
195    || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) )
196  {
197    return;
198  }
199 
200  m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
201}
202
203Void TDecEntropy::decodeIntraDirModeLuma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
204{
205  m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth );
206}
207
208Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
209{
210  m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth );
211}
212
213/** decode motion information for every PU block.
214 * \param pcCU
215 * \param uiAbsPartIdx
216 * \param uiDepth
217 * \param pcSubCU
218 * \returns Void
219 */
220Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
221{
222  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
223  UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
224  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
225
226#if H_3D_IV_MERGE
227  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
228  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
229#else
230  TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
231  UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
232#endif
233#if H_3D_SPIVMP
234  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
235  TComMvField*  pcMvFieldSP;
236  UChar* puhInterDirSP;
237  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
238  puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
239#endif
240  for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
241  {
242    uhInterDirNeighbours[ui] = 0;
243  }
244  Int numValidMergeCand = 0;
245  Bool isMerged = false;
246
247  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
248  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
249#if H_3D_IV_MERGE
250  pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
251#endif
252  for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
253  {
254#if H_MV_ENC_DEC_TRAC
255    DTRACE_PU_S("=========== prediction_unit ===========\n")
256    // ToDo:
257    //DTRACE_PU("x0", uiLPelX)
258    //DTRACE_PU("x1", uiTPelY)
259#endif
260    decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
261    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
262    {
263      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
264      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
265#if H_3D_ARP
266      decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
267#endif
268#if H_3D_IC
269      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
270#endif
271#if H_3D_DBBP
272      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
273#else
274      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
275#endif
276      {
277        pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
278        if ( !isMerged )
279        {
280#if H_3D_VSP
281          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
282          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
283#if H_3D_SPIVMP
284          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
285#endif
286          pcSubCU->initAvailableFlags();
287          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
288          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
289#if H_3D_SPIVMP
290            , pcMvFieldSP, puhInterDirSP
291#endif
292            , numValidMergeCand );
293          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
294#if H_3D_SPIVMP
295            , bSPIVMPFlag
296#endif
297            , numValidMergeCand );
298          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
299
300#else
301#if H_3D
302          pcSubCU->initAvailableFlags();
303          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
304          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
305
306#else
307          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
308#endif
309#endif
310          isMerged = true;
311        }
312        pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth );
313      }
314      else
315      {
316        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
317#if H_3D_VSP
318        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
319        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
320#if H_3D_SPIVMP
321        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
322#endif
323        pcSubCU->initAvailableFlags();
324        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
325        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
326#if H_3D_SPIVMP
327          , pcMvFieldSP, puhInterDirSP
328#endif
329          ,numValidMergeCand, uiMergeIndex );
330        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
331#if H_3D_SPIVMP
332          , bSPIVMPFlag
333#endif
334          ,numValidMergeCand );
335        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
336#else
337#if H_3D
338        pcSubCU->initAvailableFlags();
339        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
340        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
341#else
342        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
343#endif
344#endif
345      }
346      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
347#if !LGE_DDD_REMOVAL_J0042_J0030
348#if H_3D_DDD
349      if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() )
350      {
351          assert( pcCU->getSlice()->getViewIndex() != 0 );
352          pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth );
353          pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth );
354      }
355      else
356      {
357          pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth );
358      }
359#endif
360#endif
361
362      TComMv cTmpMv( 0, 0 );
363      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
364      {       
365        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
366        {
367          pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
368          pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth);
369          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
370          pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
371#if H_3D_VSP
372#if H_3D_DBBP
373          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
374#else
375          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
376#endif
377          {
378            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
379            {
380              UInt dummy;
381              Int vspSize;
382              Int width, height;
383              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
384              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
385              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
386            }
387          }
388#endif
389        }
390      }
391#if H_3D_SPIVMP
392      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 
393      if (bSPIVMPFlag[uiMergeIndex] != 0)
394      {
395        Int iWidth, iHeight;
396        UInt uiIdx;
397        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
398
399        UInt uiSPAddr;
400
401        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
402
403        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
404
405        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
406        {
407          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
408          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
409          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
410          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
411        }
412      }
413#endif
414    }
415    else
416    {
417      decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx );
418      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
419      {       
420        if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
421        {
422          decodeRefFrmIdxPU( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
423          decodeMvdPU      ( pcCU,    uiSubPartIdx,              uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
424          decodeMVPIdxPU   ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) );
425        }
426      }
427#if H_3D_ARP
428      decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
429#endif
430#if H_3D_IC
431      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
432#endif
433    }
434    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
435    {
436      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
437      pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx);
438      pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth);
439    }
440  }
441#if H_3D_SPIVMP
442  delete[] pcMvFieldSP;
443  delete[] puhInterDirSP;
444#endif
445  return;
446}
447
448/** decode inter direction for a PU block
449 * \param pcCU
450 * \param uiAbsPartIdx
451 * \param uiDepth
452 * \param uiPartIdx
453 * \returns Void
454 */
455Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx )
456{
457  UInt uiInterDir;
458
459  if ( pcCU->getSlice()->isInterP() )
460  {
461    uiInterDir = 1;
462  }
463  else
464  {
465    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
466  }
467
468  pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth );
469}
470
471Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
472{
473  Int iRefFrmIdx = 0;
474  Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList );
475
476  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
477  {
478    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
479  }
480  else if ( !iParseRefFrmIdx )
481  {
482    iRefFrmIdx = NOT_VALID;
483  }
484  else
485  {
486    iRefFrmIdx = 0;
487  }
488
489  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
490  pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx );
491}
492
493/** decode motion vector difference for a PU block
494 * \param pcCU
495 * \param uiAbsPartIdx
496 * \param uiDepth
497 * \param uiPartIdx
498 * \param eRefList
499 * \returns Void
500 */
501Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
502{
503  if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) )
504  {
505    m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList );
506  }
507}
508
509Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
510{
511  Int iMVPIdx = -1;
512
513  TComMv cZeroMv( 0, 0 );
514  TComMv cMv     = cZeroMv;
515  Int    iRefIdx = -1;
516
517  TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList );
518  AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo();
519
520  iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr);
521  cMv = cZeroMv;
522
523  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
524  {
525    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
526#if H_MV_ENC_DEC_TRAC
527#if ENC_DEC_TRACE
528    if ( eRefList == REF_PIC_LIST_0 )
529    {
530      DTRACE_PU("mvp_l0_flag", iMVPIdx)
531    }
532    else
533    {
534      DTRACE_PU("mvp_l1_flag", iMVPIdx)
535    }
536#endif
537#endif
538  }
539  pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo);
540  pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth);
541  pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth );
542  if ( iRefIdx >= 0 )
543  {
544    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
545    cMv += pcSubCUMvField->getMvd( uiPartAddr );
546  }
547
548  PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr );
549  pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx);
550}
551
552Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU)
553{
554  UInt uiSubdiv;
555  const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth;
556
557  if(uiTrIdx==0)
558  {
559    m_bakAbsPartIdxCU = uiAbsPartIdx;
560  }
561  if( uiLog2TrafoSize == 2 )
562  {
563    UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
564    if( ( uiAbsPartIdx % partNum ) == 0 )
565    {
566      m_uiBakAbsPartIdx   = uiAbsPartIdx;
567      m_uiBakChromaOffset = offsetChroma;
568    }
569  }
570  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
571  {
572    uiSubdiv = 1;
573  }
574  else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )
575  {
576    uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU);
577  }
578  else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() )
579  {
580    uiSubdiv = 1;
581  }
582  else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
583  {
584    uiSubdiv = 0;
585  }
586  else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU )
587  {
588    uiSubdiv = 0;
589  }
590  else
591  {
592    assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU );
593    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
594  }
595 
596  const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx );
597  {
598    const Bool bFirstCbfOfCU = uiTrDepth == 0;
599    if( bFirstCbfOfCU )
600    {
601      pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
602      pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
603    }
604    if( bFirstCbfOfCU || uiLog2TrafoSize > 2 )
605    {
606      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
607      {
608        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
609      }
610      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
611      {
612        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
613      }
614    }
615    else
616    {
617      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth );
618      pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth );
619    }
620  }
621 
622  if( uiSubdiv )
623  {
624    UInt size;
625    width  >>= 1;
626    height >>= 1;
627    size = width*height;
628    uiTrIdx++;
629    ++uiDepth;
630    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
631    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
632    UInt uiYCbf = 0;
633    UInt uiUCbf = 0;
634    UInt uiVCbf = 0;
635   
636    for( Int i = 0; i < 4; i++ )
637    {
638      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU );
639      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
640      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
641      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
642      uiAbsPartIdx += uiQPartNum;
643      offsetLuma += size;  offsetChroma += (size>>2);
644    }
645   
646    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
647    {
648      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
649      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
650      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
651    }
652  }
653  else
654  {
655    assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) );
656    pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth );
657   
658#if !H_MV_ENC_DEC_TRAC
659    {
660      DTRACE_CABAC_VL( g_nSymbolCounter++ );
661      DTRACE_CABAC_T( "\tTrIdx: abspart=" );
662      DTRACE_CABAC_V( uiAbsPartIdx );
663      DTRACE_CABAC_T( "\tdepth=" );
664      DTRACE_CABAC_V( uiDepth );
665      DTRACE_CABAC_T( "\ttrdepth=" );
666      DTRACE_CABAC_V( uiTrDepth );
667      DTRACE_CABAC_T( "\n" );
668    }
669#endif
670   
671    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
672    if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
673    {
674      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
675    }
676    else
677    {
678      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
679    }
680
681
682    // transform_unit begin
683    UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA    , uiTrIdx );
684    UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
685    UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
686    if( uiLog2TrafoSize == 2 )
687    {
688      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
689      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
690      {
691        cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx );
692        cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx );
693      }
694    }
695    if ( cbfY || cbfU || cbfV )
696    {
697      // dQP: only for LCU
698      if ( pcCU->getSlice()->getPPS()->getUseDQP() )
699      {
700        if ( bCodeDQP )
701        {
702          decodeQP( pcCU, m_bakAbsPartIdxCU);
703          bCodeDQP = false;
704        }
705      }
706    }
707    if( cbfY )
708    {
709      Int trWidth = width;
710      Int trHeight = height;
711      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
712    }
713    if( uiLog2TrafoSize > 2 )
714    {
715      Int trWidth = width >> 1;
716      Int trHeight = height >> 1;
717      if( cbfU )
718      {
719        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
720      }
721      if( cbfV )
722      {
723        m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
724      }
725    }
726    else
727    {
728      UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
729      if( ( uiAbsPartIdx % partNum ) == (partNum - 1) )
730      {
731        Int trWidth = width;
732        Int trHeight = height;
733        if( cbfU )
734        {
735          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U );
736        }
737        if( cbfV )
738        {
739          m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V );
740        }
741      }
742    }
743    // transform_unit end
744  }
745}
746
747Void TDecEntropy::decodeQP          ( TComDataCU* pcCU, UInt uiAbsPartIdx )
748{
749  if ( pcCU->getSlice()->getPPS()->getUseDQP() )
750  {
751    m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) );
752  }
753}
754
755
756/** decode coefficients
757 * \param pcCU
758 * \param uiAbsPartIdx
759 * \param uiDepth
760 * \param uiWidth
761 * \param uiHeight
762 * \returns Void
763 */
764Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP )
765{
766  UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
767  UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
768  UInt uiChromaOffset = uiLumaOffset>>2;
769#if H_3D_DIM_SDC
770  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
771  {
772    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
773    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
774    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
775    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
776    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
777  }
778
779#if H_3D_INTER_SDC
780  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
781  {
782    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
783    assert( !pcCU->isIntra( uiAbsPartIdx) );
784    assert( pcCU->getSlice()->getIsDepth() );
785  }
786#endif
787  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
788  {
789    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
790    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
791 
792    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
793    {
794      for( Int iPart = 0; iPart < iPartNum; iPart++ )
795      {
796        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
797        {
798          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
799        }
800      }
801    }
802    else
803    {
804      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
805      return;
806    }
807  }
808#endif
809
810  if( pcCU->isIntra(uiAbsPartIdx) )
811  {
812  }
813  else
814  {
815    UInt uiQtRootCbf = 1;
816    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
817    {
818      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
819    }
820    if ( !uiQtRootCbf )
821    {
822      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
823      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
824      return;
825    }
826   
827  }
828
829  Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx);
830
831  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU );
832}
833
834#if H_3D_INTER_SDC
835Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
836{
837  pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
838
839#if HHI_TOOL_PARAMETERS_I2_J0107
840  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getInterSdcFlag() ) || 
841    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
842#else
843  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || 
844    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
845#endif
846  {
847    return;
848  }
849
850  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
851  {
852    return;
853  }
854
855  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
856  m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
857}
858#endif
859#if H_3D_DBBP
860Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
861{
862  m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
863}
864#endif
865
866//! \}
Note: See TracBrowser for help on using the repository browser.