source: 3DVCSoftware/branches/HTM-4.0.1-VSP-dev0/source/Lib/TLibDecoder/TDecSbac.cpp @ 166

Last change on this file since 166 was 166, checked in by mitsubishi-htm, 13 years ago

Initial integration of VSP into HTM 4.0.1. The version used for JCT3V-B0102 at Shanghai meeting.

  • VC9 project/solution files updated. Other Visual C++ project/solution files are not updated.
  • Linux make file updated.

TODO

  • A second release is expected to include some bug fix and improvements on the interface, e.g. to move switches from macro definition to the configuration file.
  • A third release is expected after being integrated within HTM 5.x, which is to be used for CE1.h anchor.
  • Property svn:eol-style set to native
File size: 75.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-2012, 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     TDecSbac.cpp
35    \brief    Context-adaptive entropy decoder class
36*/
37
38#include "TDecSbac.h"
39
40//! \ingroup TLibDecoder
41//! \{
42
43//////////////////////////////////////////////////////////////////////
44// Construction/Destruction
45//////////////////////////////////////////////////////////////////////
46
47TDecSbac::TDecSbac() 
48// new structure here
49: m_pcBitstream               ( 0 )
50, m_pcTDecBinIf               ( NULL )
51, m_numContextModels          ( 0 )
52, m_cCUSplitFlagSCModel       ( 1,             1,               NUM_SPLIT_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels )
53, m_cCUSkipFlagSCModel        ( 1,             1,               NUM_SKIP_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
54, m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
55, m_cCUMergeIdxExtSCModel     ( 1,             1,               NUM_MERGE_IDX_EXT_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
56#if HHI_INTER_VIEW_RESIDUAL_PRED
57, m_cResPredFlagSCModel       ( 1,             1,               NUM_RES_PRED_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
58#endif
59, m_cCUPartSizeSCModel        ( 1,             1,               NUM_PART_SIZE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
60, m_cCUPredModeSCModel        ( 1,             1,               NUM_PRED_MODE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
61, m_cCUAlfCtrlFlagSCModel     ( 1,             1,               NUM_ALF_CTRL_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
62, m_cCUIntraPredSCModel       ( 1,             1,               NUM_ADI_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
63, m_cCUChromaPredSCModel      ( 1,             1,               NUM_CHROMA_PRED_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
64, m_cCUDeltaQpSCModel         ( 1,             1,               NUM_DELTA_QP_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
65, m_cCUInterDirSCModel        ( 1,             1,               NUM_INTER_DIR_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
66, m_cCURefPicSCModel          ( 1,             1,               NUM_REF_NO_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
67, m_cCUMvdSCModel             ( 1,             1,               NUM_MV_RES_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
68, m_cCUQtCbfSCModel           ( 1,             2,               NUM_QT_CBF_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
69, m_cCUTransSubdivFlagSCModel ( 1,             1,               NUM_TRANS_SUBDIV_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
70, m_cCUQtRootCbfSCModel       ( 1,             1,               NUM_QT_ROOT_CBF_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
71, m_cCUSigCoeffGroupSCModel   ( 1,             2,               NUM_SIG_CG_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
72, m_cCUSigSCModel             ( 1,             1,               NUM_SIG_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
73, m_cCuCtxLastX               ( 1,             2,               NUM_CTX_LAST_FLAG_XY          , m_contextModels + m_numContextModels, m_numContextModels)
74, m_cCuCtxLastY               ( 1,             2,               NUM_CTX_LAST_FLAG_XY          , m_contextModels + m_numContextModels, m_numContextModels)
75, m_cCUOneSCModel             ( 1,             1,               NUM_ONE_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
76, m_cCUAbsSCModel             ( 1,             1,               NUM_ABS_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
77, m_cMVPIdxSCModel            ( 1,             1,               NUM_MVP_IDX_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
78, m_cALFFlagSCModel           ( 1,             1,               NUM_ALF_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
79, m_cALFUvlcSCModel           ( 1,             1,               NUM_ALF_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
80, m_cALFSvlcSCModel           ( 1,             1,               NUM_ALF_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
81#if AMP_CTX
82, m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
83#else
84, m_cCUXPosiSCModel           ( 1,             1,               NUM_CU_X_POS_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
85, m_cCUYPosiSCModel           ( 1,             1,               NUM_CU_Y_POS_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
86#endif
87, m_cSaoFlagSCModel           ( 1,             1,               NUM_SAO_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
88, m_cSaoUvlcSCModel           ( 1,             1,               NUM_SAO_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
89, m_cSaoSvlcSCModel           ( 1,             1,               NUM_SAO_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
90#if SAO_UNIT_INTERLEAVING
91, m_cSaoMergeLeftSCModel      ( 1,             1,               NUM_SAO_MERGE_LEFT_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
92, m_cSaoMergeUpSCModel        ( 1,             1,               NUM_SAO_MERGE_UP_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
93, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
94#endif
95#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
96, m_cDmmFlagSCModel           ( 1,             1,               NUM_DMM_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
97, m_cDmmModeSCModel           ( 1,             1,               NUM_DMM_MODE_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
98, m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
99#endif
100#if LGE_EDGE_INTRA
101, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
102#if LGE_EDGE_INTRA_DELTA_DC
103, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
104#endif
105#endif
106{
107  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
108  m_iSliceGranularity = 0;
109}
110
111TDecSbac::~TDecSbac()
112{
113}
114
115// ====================================================================================================================
116// Public member functions
117// ====================================================================================================================
118
119#if CABAC_INIT_FLAG
120Void TDecSbac::resetEntropy(TComSlice* pSlice)
121{
122  SliceType sliceType  = pSlice->getSliceType();
123  Int       qp         = pSlice->getSliceQp();
124
125  if (pSlice->getPPS()->getCabacInitPresentFlag() && pSlice->getCabacInitFlag())
126  {
127    switch (sliceType)
128    {
129    case P_SLICE:           // change initialization table to B_SLICE initialization
130      sliceType = B_SLICE; 
131      break;
132    case B_SLICE:           // change initialization table to P_SLICE initialization
133      sliceType = P_SLICE; 
134      break;
135    default     :           // should not occur
136      assert(0);
137    }
138  }
139
140#else
141Void TDecSbac::resetEntropywithQPandInitIDC (Int  qp, Int iID)
142{
143  SliceType sliceType = (SliceType)iID;
144#endif 
145
146  m_cCUSplitFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG );
147  m_cCUSkipFlagSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SKIP_FLAG );
148  m_cCUMergeFlagExtSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
149  m_cCUMergeIdxExtSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
150#if HHI_INTER_VIEW_RESIDUAL_PRED
151  m_cResPredFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_RES_PRED_FLAG );
152#endif
153  m_cCUAlfCtrlFlagSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG );
154  m_cCUPartSizeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PART_SIZE );
155#if AMP_CTX
156  m_cCUAMPSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );
157#else
158  m_cCUXPosiSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_CU_X_POS );
159  m_cCUYPosiSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_CU_Y_POS );
160#endif
161  m_cCUPredModeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PRED_MODE );
162  m_cCUIntraPredSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE );
163  m_cCUChromaPredSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE );
164  m_cCUInterDirSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_INTER_DIR );
165  m_cCUMvdSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_MVD );
166  m_cCURefPicSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_REF_PIC );
167  m_cCUDeltaQpSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_DQP );
168  m_cCUQtCbfSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_QT_CBF );
169  m_cCUQtRootCbfSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF );
170  m_cCUSigCoeffGroupSCModel.initBuffer   ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG );
171  m_cCUSigSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_SIG_FLAG );
172  m_cCuCtxLastX.initBuffer               ( sliceType, qp, (UChar*)INIT_LAST );
173  m_cCuCtxLastY.initBuffer               ( sliceType, qp, (UChar*)INIT_LAST );
174  m_cCUOneSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_ONE_FLAG );
175  m_cCUAbsSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_ABS_FLAG );
176  m_cMVPIdxSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_MVP_IDX );
177  m_cALFFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_FLAG );
178  m_cALFUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_UVLC );
179  m_cALFSvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_SVLC );
180  m_cSaoFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_FLAG );
181  m_cSaoUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_UVLC );
182  m_cSaoSvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_SVLC );
183#if SAO_UNIT_INTERLEAVING
184  m_cSaoMergeLeftSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
185  m_cSaoMergeUpSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
186  m_cSaoTypeIdxSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX );
187#endif
188
189  m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
190#if LGE_EDGE_INTRA
191  m_cEdgeIntraSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_EDGE_INTRA );
192#if LGE_EDGE_INTRA_DELTA_DC
193  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
194#endif
195#endif
196  m_uiLastDQpNonZero  = 0;
197#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
198  m_cDmmFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_FLAG );
199  m_cDmmModeSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_MODE );
200  m_cDmmDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_DATA );
201#endif
202 
203  // new structure
204  m_uiLastQp          = qp;
205 
206  m_pcTDecBinIf->start();
207}
208
209/** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile.
210 *  Intialize CABAC states. Start CABAC.
211 */
212Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp )
213{
214  UInt uiBit;
215  m_pcTDecBinIf->decodeBinTrm(uiBit);
216  m_pcTDecBinIf->finish(); 
217#if !OL_FLUSH_ALIGN
218  // Account for misaligned CABAC.
219  Int iCABACReadAhead = m_pcTDecBinIf->getBitsReadAhead();
220  iCABACReadAhead--;
221  Int iStreamBits = 8-m_pcBitstream->getNumBitsUntilByteAligned();
222  if (iCABACReadAhead >= iStreamBits)
223  {
224    // Misaligned CABAC has read into the 1st byte of the next tile.
225    // Back up a byte prior to alignment.
226    m_pcBitstream->backupByte();
227  }
228#endif
229  m_pcBitstream->readOutTrailingBits();
230  m_cCUSplitFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );
231  m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
232  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );
233  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );
234#if HHI_INTER_VIEW_RESIDUAL_PRED
235  m_cResPredFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG );
236#endif
237  m_cCUAlfCtrlFlagSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG );
238  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
239#if AMP_CTX
240  m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
241#else
242  m_cCUXPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_X_POS );
243  m_cCUYPosiSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_CU_Y_POS );
244#endif
245  m_cCUPredModeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );
246  m_cCUIntraPredSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );
247  m_cCUChromaPredSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE );
248  m_cCUInterDirSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_INTER_DIR );
249  m_cCUMvdSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_MVD );
250  m_cCURefPicSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_REF_PIC );
251  m_cCUDeltaQpSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DQP );
252  m_cCUQtCbfSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_QT_CBF );
253  m_cCUQtRootCbfSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF );
254  m_cCUSigCoeffGroupSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG );
255  m_cCUSigSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG );
256  m_cCuCtxLastX.initBuffer               ( eSliceType, iQp, (UChar*)INIT_LAST );
257  m_cCuCtxLastY.initBuffer               ( eSliceType, iQp, (UChar*)INIT_LAST );
258  m_cCUOneSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG );
259  m_cCUAbsSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG );
260  m_cMVPIdxSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_MVP_IDX );
261  m_cALFFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_FLAG );
262  m_cALFUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC );
263  m_cALFSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC );
264  m_cSaoFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG );
265  m_cSaoUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC );
266  m_cSaoSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC );
267#if SAO_UNIT_INTERLEAVING
268  m_cSaoMergeLeftSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
269  m_cSaoMergeUpSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
270  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
271#endif
272  m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
273#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
274  m_cDmmFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG );
275  m_cDmmModeSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_MODE );
276  m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
277#endif
278
279  m_pcTDecBinIf->start();
280}
281
282Void TDecSbac::readTileMarker( UInt& uiTileIdx, UInt uiBitsUsed )
283{
284  UInt uiSymbol;
285  uiTileIdx = 0;
286  for (Int iShift=uiBitsUsed-1; iShift>=0; iShift--)
287  {
288    m_pcTDecBinIf->decodeBinEP ( uiSymbol );
289    if (uiSymbol)
290    {
291      uiTileIdx |= (1<<iShift);
292    }
293  }
294}
295
296Void TDecSbac::parseTerminatingBit( UInt& ruiBit )
297{
298  m_pcTDecBinIf->decodeBinTrm( ruiBit );
299}
300
301
302Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol )
303{
304  if (uiMaxSymbol == 0)
305  {
306    ruiSymbol = 0;
307    return;
308  }
309 
310  m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] );
311 
312  if( ruiSymbol == 0 || uiMaxSymbol == 1 )
313  {
314    return;
315  }
316 
317  UInt uiSymbol = 0;
318  UInt uiCont;
319 
320  do
321  {
322    m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );
323    uiSymbol++;
324  }
325  while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) );
326 
327  if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) )
328  {
329    uiSymbol++;
330  }
331 
332  ruiSymbol = uiSymbol;
333}
334
335Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount )
336{
337  UInt uiSymbol = 0;
338  UInt uiBit = 1;
339 
340  while( uiBit )
341  {
342    m_pcTDecBinIf->decodeBinEP( uiBit );
343    uiSymbol += uiBit << uiCount++;
344  }
345 
346  if ( --uiCount )
347  {
348    UInt bins;
349    m_pcTDecBinIf->decodeBinsEP( bins, uiCount );
350    uiSymbol += bins;
351  }
352 
353  ruiSymbol = uiSymbol;
354}
355
356Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset )
357{
358  m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] );
359 
360  if( !ruiSymbol )
361  {
362    return;
363  }
364 
365  UInt uiSymbol = 0;
366  UInt uiCont;
367 
368  do
369  {
370    m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );
371    uiSymbol++;
372  }
373  while( uiCont );
374 
375  ruiSymbol = uiSymbol;
376}
377
378/** Parsing of coeff_abs_level_minus3
379 * \param ruiSymbol reference to coeff_abs_level_minus3
380 * \param ruiGoRiceParam reference to Rice parameter
381 * \returns Void
382 */
383Void TDecSbac::xReadGoRiceExGolomb( UInt &ruiSymbol, UInt &ruiGoRiceParam )
384{
385  Bool bExGolomb    = false;
386  UInt uiCodeWord   = 0;
387  UInt uiQuotient   = 0;
388  UInt uiRemainder  = 0;
389  UInt uiMaxVlc     = g_auiGoRiceRange[ ruiGoRiceParam ];
390  UInt uiMaxPreLen  = g_auiGoRicePrefixLen[ ruiGoRiceParam ];
391
392  do
393  {
394    uiQuotient++;
395    m_pcTDecBinIf->decodeBinEP( uiCodeWord );
396  }
397  while( uiCodeWord && uiQuotient < uiMaxPreLen );
398
399  uiCodeWord  = 1 - uiCodeWord;
400  uiQuotient -= uiCodeWord;
401
402  if ( ruiGoRiceParam > 0 )
403  {
404    m_pcTDecBinIf->decodeBinsEP( uiRemainder, ruiGoRiceParam );   
405  }
406
407  ruiSymbol      = uiRemainder + ( uiQuotient << ruiGoRiceParam );
408  bExGolomb      = ruiSymbol == ( uiMaxVlc + 1 );
409
410  if( bExGolomb )
411  {
412    xReadEpExGolomb( uiCodeWord, 0 );
413    ruiSymbol += uiCodeWord;
414  }
415
416#if EIGHT_BITS_RICE_CODE
417  ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 23 ) ];
418#else
419  ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 15 ) ];
420#endif
421
422  return;
423}
424
425
426/** Parse I_PCM information.
427 * \param pcCU
428 * \param uiAbsPartIdx
429 * \param uiDepth
430 * \returns Void
431 *
432 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes.
433 */
434Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
435{
436  UInt uiSymbol;
437#if BURST_IPCM
438  Int numSubseqIPCM = 0;
439  Bool readPCMSampleFlag = false;
440
441  if(pcCU->getNumSucIPCM() > 0) 
442  {
443    readPCMSampleFlag = true;
444  }
445  else
446  {
447    m_pcTDecBinIf->decodeBinTrm(uiSymbol);
448
449    if (uiSymbol)
450    {
451      readPCMSampleFlag = true;
452      m_pcTDecBinIf->decodeNumSubseqIPCM(numSubseqIPCM);
453      pcCU->setNumSucIPCM(numSubseqIPCM + 1);
454      m_pcTDecBinIf->decodePCMAlignBits();
455    }
456  }
457#else
458  m_pcTDecBinIf->decodeBinTrm(uiSymbol);
459#endif
460
461#if BURST_IPCM
462  if (readPCMSampleFlag == true)
463#else
464  if (uiSymbol)
465#endif
466  {
467    Bool bIpcmFlag = true;
468
469#if !BURST_IPCM
470    m_pcTDecBinIf->decodePCMAlignBits();
471#endif
472
473    pcCU->setPartSizeSubParts  ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
474    pcCU->setSizeSubParts      ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
475    pcCU->setIPCMFlagSubParts  ( bIpcmFlag, uiAbsPartIdx, uiDepth );
476
477    UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight();
478    UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
479    UInt uiChromaOffset = uiLumaOffset>>2;
480
481    Pel* piPCMSample;
482    UInt uiWidth;
483    UInt uiHeight;
484    UInt uiSampleBits;
485    UInt uiX, uiY;
486
487    piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset;
488    uiWidth = pcCU->getWidth(uiAbsPartIdx);
489    uiHeight = pcCU->getHeight(uiAbsPartIdx);
490    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
491
492    for(uiY = 0; uiY < uiHeight; uiY++)
493    {
494      for(uiX = 0; uiX < uiWidth; uiX++)
495      {
496        UInt uiSample;
497        m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
498        piPCMSample[uiX] = uiSample;
499      }
500      piPCMSample += uiWidth;
501    }
502
503    piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;
504    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
505    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
506    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
507
508    for(uiY = 0; uiY < uiHeight; uiY++)
509    {
510      for(uiX = 0; uiX < uiWidth; uiX++)
511      {
512        UInt uiSample;
513        m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
514        piPCMSample[uiX] = uiSample;
515      }
516      piPCMSample += uiWidth;
517    }
518
519    piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;
520    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
521    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
522    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
523
524    for(uiY = 0; uiY < uiHeight; uiY++)
525    {
526      for(uiX = 0; uiX < uiWidth; uiX++)
527      {
528        UInt uiSample;
529        m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
530        piPCMSample[uiX] = uiSample;
531      }
532      piPCMSample += uiWidth;
533    }
534
535#if BURST_IPCM
536    pcCU->setNumSucIPCM( pcCU->getNumSucIPCM() - 1);
537    if(pcCU->getNumSucIPCM() == 0)
538    {
539      m_pcTDecBinIf->resetBac();
540    }
541#else
542    m_pcTDecBinIf->resetBac();
543#endif
544  }
545}
546
547/** parse skip flag
548 * \param pcCU
549 * \param uiAbsPartIdx
550 * \param uiDepth
551 * \returns Void
552 */
553Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
554{
555  if( pcCU->getSlice()->isIntra() )
556  {
557    return;
558  }
559 
560  UInt uiSymbol = 0;
561  UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx );
562  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) );
563  DTRACE_CABAC_VL( g_nSymbolCounter++ );
564  DTRACE_CABAC_T( "\tSkipFlag" );
565  DTRACE_CABAC_T( "\tuiCtxSkip: ");
566  DTRACE_CABAC_V( uiCtxSkip );
567  DTRACE_CABAC_T( "\tuiSymbol: ");
568  DTRACE_CABAC_V( uiSymbol );
569  DTRACE_CABAC_T( "\n");
570 
571  if( uiSymbol )
572  {
573    pcCU->setPredModeSubParts( MODE_SKIP,  uiAbsPartIdx, uiDepth );
574    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
575    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
576    pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth );
577  }
578}
579
580#if FORCE_REF_VSP==1
581Void TDecSbac::parseVspFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
582{
583  if( pcCU->getSlice()->isIntra() || pcCU->getSlice()->getViewId()==0 )
584  {
585    return;
586  }
587 
588  UInt uiSymbol = 0;
589  UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx );
590  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) );
591  DTRACE_CABAC_VL( g_nSymbolCounter++ );
592  DTRACE_CABAC_T( "\tVspFlag" );
593  DTRACE_CABAC_T( "\tuiCtxSkip: ");
594  DTRACE_CABAC_V( uiCtxSkip );
595  DTRACE_CABAC_T( "\tuiSymbol: ");
596  DTRACE_CABAC_V( uiSymbol );
597  DTRACE_CABAC_T( "\n");
598 
599  if( uiSymbol )
600  {
601    pcCU->setPredModeSubParts( MODE_SYNTH, uiAbsPartIdx, uiDepth );
602  }
603}
604#endif
605
606/** parse merge flag
607 * \param pcCU
608 * \param uiAbsPartIdx
609 * \param uiDepth
610 * \param uiPUIdx
611 * \returns Void
612 */
613Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
614{
615  UInt uiSymbol;
616  m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) );
617  pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth );
618
619  DTRACE_CABAC_VL( g_nSymbolCounter++ );
620  DTRACE_CABAC_T( "\tMergeFlag: " );
621  DTRACE_CABAC_V( uiSymbol );
622  DTRACE_CABAC_T( "\tAddress: " );
623  DTRACE_CABAC_V( pcCU->getAddr() );
624  DTRACE_CABAC_T( "\tuiAbsPartIdx: " );
625  DTRACE_CABAC_V( uiAbsPartIdx );
626  DTRACE_CABAC_T( "\n" );
627}
628
629Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
630{
631  UInt uiNumCand = MRG_MAX_NUM_CANDS;
632#if !MRG_IDX_CTX_RED 
633  UInt auiCtx[4] = { 0, 1, 2, 3 };
634#endif
635  UInt uiUnaryIdx = 0;
636  uiNumCand = pcCU->getSlice()->getMaxNumMergeCand();
637#if HHI_MPI
638#if VSP_TEXT_ONLY
639  TComDataCU* pcTextCU = pcCU->getSlice()->getSPS()->getUseMVI() ? pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ) : NULL;
640  Int aiRefIdxVsp[2] = { pcTextCU ? pcTextCU->getCUMvField( RefPicList(0) )->getRefIdx( uiAbsPartIdx ) : -1,
641                         pcTextCU ? pcTextCU->getCUMvField( RefPicList(1) )->getRefIdx( uiAbsPartIdx ) : -1 };
642  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE
643    && !( aiRefIdxVsp[0] >= 0 && pcTextCU->getSlice()->getRefViewId( RefPicList(0), aiRefIdxVsp[0] ) == NUM_VIEW_VSP )
644    && !( aiRefIdxVsp[1] >= 0 && pcTextCU->getSlice()->getRefViewId( RefPicList(1), aiRefIdxVsp[1] ) == NUM_VIEW_VSP );
645#else
646  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
647#endif
648  const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : uiNumCand;
649#endif
650  if ( uiNumCand > 1 )
651  {
652    for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx )
653    {
654      UInt uiSymbol = 0;
655#if MRG_IDX_CTX_RED
656      if ( uiUnaryIdx==0 )
657      {
658        m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) );
659      }
660      else
661      {
662        m_pcTDecBinIf->decodeBinEP( uiSymbol );
663      }
664#else
665      m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) );
666#endif
667      if( uiSymbol == 0 )
668      {
669        break;
670      }
671    }
672  }
673  ruiMergeIndex = uiUnaryIdx;
674
675  DTRACE_CABAC_VL( g_nSymbolCounter++ )
676  DTRACE_CABAC_T( "\tparseMergeIndex()" )
677  DTRACE_CABAC_T( "\tuiMRGIdx= " )
678  DTRACE_CABAC_V( ruiMergeIndex )
679  DTRACE_CABAC_T( "\n" )
680#if HHI_MPI
681  if( ruiMergeIndex > uiMviMergePos )
682  {
683    assert( bMVIAvailable );
684    ruiMergeIndex--;
685  }
686  else if( ruiMergeIndex == uiMviMergePos )
687  {
688    assert( bMVIAvailable );
689    pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
690  }
691#endif
692}
693
694#if HHI_INTER_VIEW_RESIDUAL_PRED
695Void
696TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth )
697{
698  UInt uiCtx    = pcCU->getCtxResPredFlag( uiAbsPartIdx );
699  UInt uiSymbol = 0;
700  m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) );
701  rbResPredFlag = ( uiSymbol != 0 );
702}
703#endif
704
705#if HHI_INTER_VIEW_MOTION_PRED
706Void TDecSbac::parseMVPIdx      ( Int& riMVPIdx, Int iNumAMVPCands )
707{
708  UInt uiSymbol;
709  xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iNumAMVPCands-1);
710  riMVPIdx = uiSymbol;
711}
712#else
713Void TDecSbac::parseMVPIdx      ( Int& riMVPIdx )
714{
715  UInt uiSymbol;
716  xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1);
717  riMVPIdx = uiSymbol;
718}
719#endif
720
721Void TDecSbac::parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
722{
723  if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
724  {
725    pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
726    return;
727  }
728 
729  UInt uiSymbol;
730  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) );
731  DTRACE_CABAC_VL( g_nSymbolCounter++ )
732  DTRACE_CABAC_T( "\tSplitFlag\n" )
733  pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx );
734 
735  return;
736}
737
738/** parse partition size
739 * \param pcCU
740 * \param uiAbsPartIdx
741 * \param uiDepth
742 * \returns Void
743 */
744Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
745{
746  UInt uiSymbol, uiMode = 0;
747  PartSize eMode;
748 
749  if ( pcCU->isIntra( uiAbsPartIdx ) )
750  {
751    uiSymbol = 1;
752    if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
753    {
754      m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) );
755    }
756    eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN;
757    UInt uiTrLevel = 0;   
758    UInt uiWidthInBit  = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2;
759    UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2;
760    uiTrLevel          = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0;
761    if( eMode == SIZE_NxN )
762    {
763      pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth );
764    }
765    else
766    {
767      pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth );
768    }
769  }
770  else
771  {
772    UInt uiMaxNumBits = 2;
773    if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
774    {
775      uiMaxNumBits ++;
776    }
777    for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
778    {
779      m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
780      if ( uiSymbol )
781      {
782        break;
783      }
784      uiMode++;
785    }
786    eMode = (PartSize) uiMode;
787    if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
788    {
789      if (eMode == SIZE_2NxN)
790      {
791#if AMP_CTX
792          m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
793#else
794        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 0 ));
795#endif
796        if (uiSymbol == 0)
797        {
798#if AMP_CTX
799          m_pcTDecBinIf->decodeBinEP(uiSymbol);
800#else
801          m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUYPosiSCModel.get( 0, 0, 1 ));
802#endif
803          eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
804        }
805      }
806      else if (eMode == SIZE_Nx2N)
807      {
808#if AMP_CTX
809        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
810#else
811        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 0 ));
812#endif
813        if (uiSymbol == 0)
814        {
815#if AMP_CTX
816          m_pcTDecBinIf->decodeBinEP(uiSymbol);
817#else
818          m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUXPosiSCModel.get( 0, 0, 1 ));
819#endif
820          eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
821        }
822      }
823    }
824  }
825  pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth );
826  pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
827}
828
829/** parse prediction mode
830 * \param pcCU
831 * \param uiAbsPartIdx
832 * \param uiDepth
833 * \returns Void
834 */
835Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
836{
837  if( pcCU->getSlice()->isIntra() )
838  {
839    pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth );
840    return;
841  }
842 
843  UInt uiSymbol;
844  Int  iPredMode = MODE_INTER;
845  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) );
846  iPredMode += uiSymbol;
847  pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth );
848}
849 
850Void TDecSbac::parseIntraDirLumaAng  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
851{
852  UInt uiSymbol;
853  Int  intraPredMode;
854
855#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
856  UInt uiFlag = 0;
857  if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE )
858  {
859    m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) );
860  }
861  if( uiFlag )
862  {
863    UInt uiDMMode;
864
865#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
866    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
867    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1;
868    if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 )
869    {
870      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2;
871    }
872#else
873    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
874    if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 )
875    {
876      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1;
877    }
878#endif
879    intraPredMode = uiDMMode + NUM_INTRA_MODE;
880
881#if HHI_DMM_WEDGE_INTRA
882    if( intraPredMode == DMM_WEDGE_FULL_IDX )          { xParseWedgeFullInfo          ( pcCU, uiAbsPartIdx, uiDepth ); }
883    if( intraPredMode == DMM_WEDGE_FULL_D_IDX )        { xParseWedgeFullDeltaInfo     ( pcCU, uiAbsPartIdx, uiDepth ); }
884    if( intraPredMode == DMM_WEDGE_PREDDIR_IDX )       { xParseWedgePredDirInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
885    if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX )     { xParseWedgePredDirDeltaInfo  ( pcCU, uiAbsPartIdx, uiDepth ); }
886#endif
887#if HHI_DMM_PRED_TEX
888    if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX )     { xParseWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx, uiDepth ); }
889    if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX )   { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); }
890#endif
891  }
892  else
893  {
894#endif
895#if !LOGI_INTRA_NAME_3MPM
896    Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
897#endif
898
899#if LGE_EDGE_INTRA
900    Bool bCodeEdgeIntra = false;
901    if( pcCU->getSlice()->getSPS()->isDepth() )
902    {
903      UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
904      if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
905        bCodeEdgeIntra = true;
906    }
907#endif
908
909#if LOGI_INTRA_NAME_3MPM
910    Int uiPreds[3] = {-1, -1, -1};
911#else
912    Int uiPreds[2] = {-1, -1};
913#endif
914    Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); 
915#if LGE_EDGE_INTRA
916    UInt uiCheckBit = 0;
917#endif
918
919    m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
920
921    if ( uiSymbol )
922    {
923      m_pcTDecBinIf->decodeBinEP( uiSymbol );
924#if LOGI_INTRA_NAME_3MPM
925      if (uiSymbol)
926      {
927        m_pcTDecBinIf->decodeBinEP( uiSymbol );
928        uiSymbol++;
929      }
930#endif
931      intraPredMode = uiPreds[uiSymbol];
932    }
933    else
934    {
935      intraPredMode = 0;
936
937#if LOGI_INTRA_NAME_3MPM
938
939      m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
940#if LGE_EDGE_INTRA
941      if (bCodeEdgeIntra)
942      {
943        if (uiSymbol==31)
944        {
945          m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1);
946          if (uiCheckBit)
947            uiSymbol = EDGE_INTRA_IDX;
948        }
949      }
950#endif
951      intraPredMode = uiSymbol;
952
953      //postponed sorting of MPMs (only in remaining branch)
954      if (uiPreds[0] > uiPreds[1])
955      { 
956        std::swap(uiPreds[0], uiPreds[1]); 
957      }
958      if (uiPreds[0] > uiPreds[2])
959      {
960        std::swap(uiPreds[0], uiPreds[2]);
961      }
962      if (uiPreds[1] > uiPreds[2])
963      {
964        std::swap(uiPreds[1], uiPreds[2]);
965      }
966#else
967      m_pcTDecBinIf->decodeBinsEP( uiSymbol, g_aucIntraModeBitsAng[iIntraIdx] - 1 );
968      intraPredMode = uiSymbol;
969
970      if ( intraPredMode == 31 )
971      {
972        m_pcTDecBinIf->decodeBinEP( uiSymbol );
973        intraPredMode += uiSymbol;     
974      }
975#endif
976#if LGE_EDGE_INTRA
977      if ( intraPredMode != EDGE_INTRA_IDX)
978      {
979#endif
980        for ( Int i = 0; i < uiPredNum; i++ )
981        {
982          intraPredMode += ( intraPredMode >= uiPreds[i] );
983        }
984#if LGE_EDGE_INTRA
985      }
986#endif
987    }
988
989#if LGE_EDGE_INTRA
990    if( intraPredMode == EDGE_INTRA_IDX )
991    {
992      xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth );
993#if LGE_EDGE_INTRA_DELTA_DC
994      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
995      if( uiSymbol )
996      {
997        intraPredMode = EDGE_INTRA_DELTA_IDX;
998        Int iDeltaDC0;
999        Int iDeltaDC1;
1000
1001        xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
1002        if( iDeltaDC0 != 0 )
1003        {
1004          UInt uiSign;
1005          m_pcTDecBinIf->decodeBinEP( uiSign );
1006          if ( uiSign )
1007          {
1008            iDeltaDC0 = -iDeltaDC0;
1009          }
1010        }
1011        xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
1012        if( iDeltaDC1 != 0 )
1013        {
1014          UInt uiSign;
1015          m_pcTDecBinIf->decodeBinEP( uiSign );
1016          if ( uiSign )
1017          {
1018            iDeltaDC1 = -iDeltaDC1;
1019          }
1020        }
1021
1022        pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
1023        pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
1024      }
1025#endif
1026    }
1027#endif
1028
1029#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1030  }
1031#endif
1032
1033  pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth );
1034}
1035
1036Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1037{
1038  UInt uiSymbol;
1039
1040  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) );
1041
1042  if( uiSymbol == 0 )
1043  {
1044    uiSymbol = DM_CHROMA_IDX;
1045  } 
1046  else 
1047  {
1048    if( pcCU->getSlice()->getSPS()->getUseLMChroma() )
1049    {
1050      m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) );
1051    }
1052    else
1053    {
1054      uiSymbol = 1;
1055    }
1056
1057    if( uiSymbol == 0 )
1058    {
1059      uiSymbol = LM_CHROMA_IDX;
1060    } 
1061    else
1062    {
1063      UInt uiIPredMode;
1064#if CHROMA_MODE_CODING
1065      m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 );
1066#else
1067      xReadUnaryMaxSymbol( uiIPredMode, m_cCUChromaPredSCModel.get( 0, 0 ) + 1, 0, 3 );
1068#endif
1069      UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ];
1070      pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir );
1071      uiSymbol = uiAllowedChromaDir[ uiIPredMode ];
1072    }
1073  }
1074  pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth );
1075  return;
1076}
1077
1078Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth )
1079{
1080  UInt uiSymbol;
1081  const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx );
1082  ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 );
1083  m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );
1084
1085  if( uiSymbol )
1086  {
1087    uiSymbol = 2;
1088  }
1089
1090  uiSymbol++;
1091  ruiInterDir = uiSymbol;
1092  return;
1093}
1094
1095Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
1096{
1097  UInt uiSymbol;
1098
1099  if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C)
1100  {
1101    ContextModel *pCtx = m_cCURefPicSCModel.get( 0 );
1102    m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
1103
1104    if( uiSymbol )
1105    {
1106      xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 );
1107      uiSymbol++;
1108    }
1109    riRefFrmIdx = uiSymbol;
1110  }
1111  else
1112  {
1113    ContextModel *pCtx = m_cCURefPicSCModel.get( 0 );
1114    m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
1115
1116    if( uiSymbol )
1117    {
1118      xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 );
1119      uiSymbol++;
1120    }
1121    riRefFrmIdx = uiSymbol;
1122  }
1123
1124  return;
1125}
1126
1127Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList )
1128{
1129  UInt uiSymbol;
1130  UInt uiHorAbs;
1131  UInt uiVerAbs;
1132  UInt uiHorSign = 0;
1133  UInt uiVerSign = 0;
1134  ContextModel *pCtx = m_cCUMvdSCModel.get( 0 );
1135
1136#if H0111_MVD_L1_ZERO
1137  if(pcCU->getSlice()->getMvdL1ZeroFlag() && eRefList == REF_PIC_LIST_1 && pcCU->getInterDir(uiAbsPartIdx)==3)
1138  {
1139    uiHorAbs=0;
1140    uiVerAbs=0;
1141  }
1142  else
1143  {
1144#endif
1145
1146    m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx );
1147    m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx );
1148
1149    const Bool bHorAbsGr0 = uiHorAbs != 0;
1150    const Bool bVerAbsGr0 = uiVerAbs != 0;
1151    pCtx++;
1152
1153    if( bHorAbsGr0 )
1154    {
1155      m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
1156      uiHorAbs += uiSymbol;
1157    }
1158
1159    if( bVerAbsGr0 )
1160    {
1161      m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
1162      uiVerAbs += uiSymbol;
1163    }
1164
1165    if( bHorAbsGr0 )
1166    {
1167      if( 2 == uiHorAbs )
1168      {
1169        xReadEpExGolomb( uiSymbol, 1 );
1170        uiHorAbs += uiSymbol;
1171      }
1172
1173      m_pcTDecBinIf->decodeBinEP( uiHorSign );
1174    }
1175
1176    if( bVerAbsGr0 )
1177    {
1178      if( 2 == uiVerAbs )
1179      {
1180        xReadEpExGolomb( uiSymbol, 1 );
1181        uiVerAbs += uiSymbol;
1182      }
1183
1184      m_pcTDecBinIf->decodeBinEP( uiVerSign );
1185    }
1186
1187#if H0111_MVD_L1_ZERO
1188  }
1189#endif
1190
1191  const TComMv cMv( uiHorSign ? -Int( uiHorAbs ): uiHorAbs, uiVerSign ? -Int( uiVerAbs ) : uiVerAbs );
1192  pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx );
1193  return;
1194}
1195
1196
1197Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize )
1198{
1199  m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) );
1200  DTRACE_CABAC_VL( g_nSymbolCounter++ )
1201  DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" )
1202  DTRACE_CABAC_T( "\tsymbol=" )
1203  DTRACE_CABAC_V( ruiSubdivFlag )
1204  DTRACE_CABAC_T( "\tctx=" )
1205  DTRACE_CABAC_V( uiLog2TransformBlockSize )
1206  DTRACE_CABAC_T( "\n" )
1207}
1208
1209Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf )
1210{
1211  UInt uiSymbol;
1212  const UInt uiCtx = 0;
1213  m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) );
1214  DTRACE_CABAC_VL( g_nSymbolCounter++ )
1215  DTRACE_CABAC_T( "\tparseQtRootCbf()" )
1216  DTRACE_CABAC_T( "\tsymbol=" )
1217  DTRACE_CABAC_V( uiSymbol )
1218  DTRACE_CABAC_T( "\tctx=" )
1219  DTRACE_CABAC_V( uiCtx )
1220  DTRACE_CABAC_T( "\tuiAbsPartIdx=" )
1221  DTRACE_CABAC_V( uiAbsPartIdx )
1222  DTRACE_CABAC_T( "\n" )
1223 
1224  uiQtRootCbf = uiSymbol;
1225}
1226
1227Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1228{
1229#if H0736_AVC_STYLE_QP_RANGE
1230  Int qp;
1231#endif
1232  UInt uiDQp;
1233  Int  iDQp;
1234 
1235  m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) );
1236 
1237  if ( uiDQp == 0 )
1238  {
1239#if H0736_AVC_STYLE_QP_RANGE
1240    qp = pcCU->getRefQP(uiAbsPartIdx);
1241#else
1242    uiDQp = pcCU->getRefQP(uiAbsPartIdx);
1243#endif
1244  }
1245  else
1246  {
1247    UInt uiSign;
1248#if H0736_AVC_STYLE_QP_RANGE
1249    Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY();
1250#else
1251    UInt uiQpBdOffsetY = 6*(g_uiBitIncrement + g_uiBitDepth - 8);
1252#endif
1253    m_pcTDecBinIf->decodeBinEP(uiSign);
1254
1255#if H0736_AVC_STYLE_QP_RANGE
1256    UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign);
1257#else
1258    UInt uiMaxAbsDQpMinus1 = 24 + (uiQpBdOffsetY/2) + (uiSign);
1259#endif
1260    UInt uiAbsDQpMinus1;
1261    xReadUnaryMaxSymbol (uiAbsDQpMinus1,  &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1);
1262
1263    iDQp = uiAbsDQpMinus1 + 1;
1264
1265    if(uiSign)
1266    {
1267      iDQp = -iDQp;
1268    }
1269
1270#if H0736_AVC_STYLE_QP_RANGE
1271    qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY;
1272#else
1273#if LOSSLESS_CODING
1274    uiDQp = (pcCU->getRefQP(uiAbsPartIdx) + iDQp + 52) % 52;
1275#else
1276    uiDQp = pcCU->getRefQP(uiAbsPartIdx) + iDQp;
1277#endif
1278#endif
1279  }
1280 
1281  UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ;
1282  UInt uiQpCUDepth =   min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ;
1283#if H0736_AVC_STYLE_QP_RANGE
1284  pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth );
1285#else
1286  pcCU->setQPSubParts( uiDQp, uiAbsQpCUPartIdx, uiQpCUDepth );
1287#endif
1288}
1289
1290Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth )
1291{
1292  UInt uiSymbol;
1293  const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth );
1294  m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) );
1295 
1296  DTRACE_CABAC_VL( g_nSymbolCounter++ )
1297  DTRACE_CABAC_T( "\tparseQtCbf()" )
1298  DTRACE_CABAC_T( "\tsymbol=" )
1299  DTRACE_CABAC_V( uiSymbol )
1300  DTRACE_CABAC_T( "\tctx=" )
1301  DTRACE_CABAC_V( uiCtx )
1302  DTRACE_CABAC_T( "\tetype=" )
1303  DTRACE_CABAC_V( eType )
1304  DTRACE_CABAC_T( "\tuiAbsPartIdx=" )
1305  DTRACE_CABAC_V( uiAbsPartIdx )
1306  DTRACE_CABAC_T( "\n" )
1307 
1308  pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth );
1309}
1310
1311/** Parse (X,Y) position of the last significant coefficient
1312 * \param uiPosLastX reference to X component of last coefficient
1313 * \param uiPosLastY reference to Y component of last coefficient
1314 * \param width  Block width
1315 * \param height Block height
1316 * \param eTType plane type / luminance or chrominance
1317 * \param uiScanIdx scan type (zig-zag, hor, ver)
1318 *
1319 * This method decodes the X and Y component within a block of the last significant coefficient.
1320 */
1321Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx )
1322{
1323  UInt uiLast;
1324  ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType );
1325  ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType );
1326
1327  // posX
1328#if LAST_CTX_REDUCTION
1329  Int widthCtx = eTType ? 4 : width;
1330  const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) );
1331#else
1332  const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ width ] * ( g_aucConvertToBit[ width ] + 3 ) );
1333#endif
1334  for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ )
1335  {
1336#if LAST_CTX_REDUCTION
1337    if ( eTType  )
1338    {
1339      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ])  ) );
1340    }
1341    else
1342    {
1343#endif
1344      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) );
1345#if LAST_CTX_REDUCTION
1346    }
1347#endif
1348    if( !uiLast )
1349    {
1350      break;
1351    }
1352  }
1353
1354  // posY
1355#if LAST_CTX_REDUCTION
1356  Int heightCtx = eTType? 4 : height;
1357  const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) );
1358#else
1359  const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ height ] * ( g_aucConvertToBit[ height ] + 3 ) );
1360#endif
1361  for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ )
1362  {
1363#if LAST_CTX_REDUCTION
1364    if (eTType)
1365    {
1366      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) );
1367    }
1368    else
1369    {
1370#endif
1371      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) );
1372#if LAST_CTX_REDUCTION
1373    }
1374#endif
1375    if( !uiLast )
1376    {
1377      break;
1378    }
1379  }
1380  if ( uiPosLastX > 3 )
1381  {
1382    UInt uiTemp  = 0;
1383    UInt uiCount = ( uiPosLastX - 2 ) >> 1;
1384    for ( Int i = uiCount - 1; i >= 0; i-- )
1385    {
1386      m_pcTDecBinIf->decodeBinEP( uiLast );
1387      uiTemp += uiLast << i;
1388    }
1389    uiPosLastX = g_uiMinInGroup[ uiPosLastX ] + uiTemp;
1390  }
1391  if ( uiPosLastY > 3 )
1392  {
1393    UInt uiTemp  = 0;
1394    UInt uiCount = ( uiPosLastY - 2 ) >> 1;
1395    for ( Int i = uiCount - 1; i >= 0; i-- )
1396    {
1397      m_pcTDecBinIf->decodeBinEP( uiLast );
1398      uiTemp += uiLast << i;
1399    }
1400    uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp;
1401  }
1402 
1403  if( uiScanIdx == SCAN_VER )
1404  {
1405    swap( uiPosLastX, uiPosLastY );
1406  }
1407}
1408
1409Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType )
1410{
1411  DTRACE_CABAC_VL( g_nSymbolCounter++ )
1412  DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" )
1413  DTRACE_CABAC_V( eTType )
1414  DTRACE_CABAC_T( "\twidth=" )
1415  DTRACE_CABAC_V( uiWidth )
1416  DTRACE_CABAC_T( "\theight=" )
1417  DTRACE_CABAC_V( uiHeight )
1418  DTRACE_CABAC_T( "\tdepth=" )
1419  DTRACE_CABAC_V( uiDepth )
1420  DTRACE_CABAC_T( "\tabspartidx=" )
1421  DTRACE_CABAC_V( uiAbsPartIdx )
1422  DTRACE_CABAC_T( "\ttoCU-X=" )
1423  DTRACE_CABAC_V( pcCU->getCUPelX() )
1424  DTRACE_CABAC_T( "\ttoCU-Y=" )
1425  DTRACE_CABAC_V( pcCU->getCUPelY() )
1426  DTRACE_CABAC_T( "\tCU-addr=" )
1427  DTRACE_CABAC_V(  pcCU->getAddr() )
1428  DTRACE_CABAC_T( "\tinCU-X=" )
1429  DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] )
1430  DTRACE_CABAC_T( "\tinCU-Y=" )
1431  DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] )
1432  DTRACE_CABAC_T( "\tpredmode=" )
1433  DTRACE_CABAC_V(  pcCU->getPredictionMode( uiAbsPartIdx ) )
1434  DTRACE_CABAC_T( "\n" )
1435 
1436  if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() )
1437  {
1438    uiWidth  = pcCU->getSlice()->getSPS()->getMaxTrSize();
1439    uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize();
1440  }
1441 
1442  eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA );
1443 
1444  //----- parse significance map -----
1445  const UInt  uiLog2BlockSize   = g_aucConvertToBit[ uiWidth ] + 2;
1446  const UInt  uiMaxNumCoeff     = uiWidth * uiHeight;
1447  const UInt  uiMaxNumCoeffM1   = uiMaxNumCoeff - 1;
1448  UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
1449  int blockType = uiLog2BlockSize;
1450  if (uiWidth != uiHeight)
1451  {
1452    uiScanIdx = SCAN_DIAG;
1453    blockType = 4;
1454  }
1455 
1456  //===== decode last significant =====
1457  UInt uiPosLastX, uiPosLastY;
1458  parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx );
1459  UInt uiBlkPosLast      = uiPosLastX + (uiPosLastY<<uiLog2BlockSize);
1460  pcCoef[ uiBlkPosLast ] = 1;
1461
1462  //===== decode significance flags =====
1463  UInt uiScanPosLast   = uiBlkPosLast;
1464  if (uiScanIdx == SCAN_ZIGZAG)
1465  {
1466    // Map zigzag to diagonal scan
1467    uiScanIdx = SCAN_DIAG;
1468  }
1469  const UInt * scan;
1470  if (uiWidth == uiHeight)
1471  {
1472    scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
1473  }
1474  else
1475  {
1476    scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ];
1477  }
1478  for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ )
1479  {
1480    UInt uiBlkPos = scan[ uiScanPosLast ];
1481    if( uiBlkPosLast == uiBlkPos )
1482    {
1483      break;
1484    }
1485  }
1486
1487  ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType );
1488  ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA;
1489
1490  const Int  iLastScanSet      = uiScanPosLast >> LOG2_SCAN_SET_SIZE;
1491  UInt uiNumOne                = 0;
1492  UInt uiGoRiceParam           = 0;
1493
1494#if MULTIBITS_DATA_HIDING
1495  UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG();
1496#if LOSSLESS_CODING
1497  Bool beValid; 
1498  if (pcCU->isLosslessCoded(uiAbsPartIdx))
1499  {
1500    beValid = false;
1501  }
1502  else 
1503  {
1504    beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0;
1505  }
1506#else
1507  Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0;
1508#endif
1509  UInt absSum = 0;
1510#endif  // MULTIBITS_DATA_HIDING
1511
1512  UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ];
1513  ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM );
1514  const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1);
1515  const UInt * scanCG;
1516  if (uiWidth == uiHeight)
1517  {
1518    scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0  ];   
1519#if MULTILEVEL_SIGMAP_EXT
1520    if( uiLog2BlockSize == 3 )
1521    {
1522      scanCG = g_sigLastScan8x8[ uiScanIdx ];
1523    }
1524    else if( uiLog2BlockSize == 5 )
1525    {
1526      scanCG = g_sigLastScanCG32x32;
1527    }
1528#endif
1529  }
1530  else
1531  {
1532    scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ];
1533  }
1534  Int  iScanPosSig             = (Int) uiScanPosLast;
1535  for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- )
1536  {
1537    Int  iSubPos     = iSubSet << LOG2_SCAN_SET_SIZE;
1538    uiGoRiceParam    = 0;
1539    Int numNonZero = 0;
1540   
1541#if MULTIBITS_DATA_HIDING
1542    Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE;
1543#endif
1544
1545    Int pos[SCAN_SET_SIZE];
1546    if( iScanPosSig == (Int) uiScanPosLast )
1547    {
1548#if MULTIBITS_DATA_HIDING
1549      lastNZPosInCG  = iScanPosSig;
1550      firstNZPosInCG = iScanPosSig;
1551#endif
1552      iScanPosSig--;
1553      pos[ numNonZero ] = uiBlkPosLast;
1554      numNonZero = 1;
1555    }
1556
1557#if !MULTILEVEL_SIGMAP_EXT
1558    if( blockType > 3 )
1559    {
1560#endif
1561      // decode significant_coeffgroup_flag
1562      Int iCGBlkPos = scanCG[ iSubSet ];
1563      Int iCGPosY   = iCGBlkPos / uiNumBlkSide;
1564      Int iCGPosX   = iCGBlkPos - (iCGPosY * uiNumBlkSide);
1565#if MULTILEVEL_SIGMAP_EXT
1566      if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
1567      {
1568        iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0);
1569        iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0);
1570      }
1571#endif
1572#if !REMOVE_INFER_SIGGRP
1573      Bool bInferredCGFlag = false;
1574#endif
1575#if REMOVE_INFER_SIGGRP
1576      if( iSubSet == iLastScanSet || iSubSet == 0)
1577#else
1578      if( iSubSet == iLastScanSet ) 
1579#endif
1580      {
1581        uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
1582      }
1583      else
1584      {
1585#if !REMOVE_INFER_SIGGRP
1586#if MULTILEVEL_SIGMAP_EXT
1587        if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight) && ( iSubSet ) )
1588#else
1589        if( !TComTrQuant::bothCGNeighboursOne( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight) && ( iSubSet ) )
1590#endif
1591        {
1592#endif
1593          UInt uiSigCoeffGroup;
1594#if MULTILEVEL_SIGMAP_EXT
1595          UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight );
1596#else
1597          UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );
1598#endif
1599          m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );
1600          uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup;
1601#if !REMOVE_INFER_SIGGRP
1602        }
1603        else
1604        {
1605          uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
1606          bInferredCGFlag = true;
1607        }
1608#endif
1609      }
1610
1611      // decode significant_coeff_flag
1612      UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig;
1613      for( ; iScanPosSig >= iSubPos; iScanPosSig-- )
1614      {
1615        uiBlkPos  = scan[ iScanPosSig ];
1616        uiPosY    = uiBlkPos >> uiLog2BlockSize;
1617        uiPosX    = uiBlkPos - ( uiPosY << uiLog2BlockSize );
1618        uiSig     = 0;
1619       
1620        if( uiSigCoeffGroupFlag[ iCGBlkPos ] )
1621        {
1622#if REMOVE_INFER_SIGGRP
1623          if( iScanPosSig > iSubPos || iSubSet == 0  || numNonZero )
1624#else
1625          if( iScanPosSig > iSubPos || bInferredCGFlag || numNonZero )
1626#endif
1627          {
1628            uiCtxSig  = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
1629            m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );
1630          }
1631          else
1632          {
1633            uiSig = 1;
1634          }
1635        }
1636        pcCoef[ uiBlkPos ] = uiSig;
1637        if( uiSig )
1638        {
1639          pos[ numNonZero ] = uiBlkPos;
1640          numNonZero ++;
1641#if MULTIBITS_DATA_HIDING
1642          if( lastNZPosInCG == -1 )
1643          {
1644            lastNZPosInCG = iScanPosSig;
1645          }
1646          firstNZPosInCG = iScanPosSig;
1647#endif
1648        }
1649      }
1650#if !MULTILEVEL_SIGMAP_EXT
1651    }
1652    else
1653    {
1654      for( ; iScanPosSig >= iSubPos; iScanPosSig-- )
1655      {
1656        UInt uiBlkPos   = scan[ iScanPosSig ];
1657        UInt  uiPosY    = uiBlkPos >> uiLog2BlockSize;
1658        UInt  uiPosX    = uiBlkPos - ( uiPosY << uiLog2BlockSize );
1659        UInt  uiSig     = 0;
1660        UInt  uiCtxSig  = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
1661        m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );
1662        pcCoef[ uiBlkPos ] = uiSig;
1663        if( uiSig )
1664        {
1665          pos[ numNonZero ] = uiBlkPos;
1666          numNonZero ++;
1667#if MULTIBITS_DATA_HIDING
1668          if( lastNZPosInCG == -1 )
1669          {
1670            lastNZPosInCG = iScanPosSig;
1671          }
1672          firstNZPosInCG = iScanPosSig;
1673#endif
1674        }
1675      }
1676    }
1677#endif
1678
1679   
1680    if( numNonZero )
1681    {
1682#if MULTIBITS_DATA_HIDING
1683      Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig );
1684      absSum = 0;
1685#endif  // MULTIBITS_DATA_HIDING
1686
1687      UInt c1 = 1;
1688#if !RESTRICT_GR1GR2FLAG_NUMBER
1689      UInt c2 = 0;
1690#endif
1691#if LEVEL_CTX_LUMA_RED
1692      UInt uiCtxSet    = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0;
1693#else
1694      UInt uiCtxSet    = (iSubSet > 0 && eTType==TEXT_LUMA) ? 3 : 0;
1695#endif
1696      UInt uiBin;
1697     
1698      if( uiNumOne > 0 )
1699      {
1700        uiCtxSet++;
1701#if !LEVEL_CTX_LUMA_RED
1702        if(eTType==TEXT_LUMA && uiNumOne > 3)
1703        {
1704          uiCtxSet++;
1705        }
1706#endif
1707      }
1708     
1709      uiNumOne       >>= 1;
1710      ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet;
1711      Int absCoeff[SCAN_SET_SIZE];
1712
1713#if RESTRICT_GR1GR2FLAG_NUMBER
1714      for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1;   
1715      Int numC1Flag = min(numNonZero, C1FLAG_NUMBER);
1716      Int firstC2FlagIdx = -1;
1717
1718      for( Int idx = 0; idx < numC1Flag; idx++ )
1719#else
1720      for( Int idx = 0; idx < numNonZero; idx++ )
1721#endif
1722      {
1723        m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] );
1724        if( uiBin == 1 )
1725        {
1726          c1 = 0;
1727#if RESTRICT_GR1GR2FLAG_NUMBER
1728          if (firstC2FlagIdx == -1)
1729          {
1730            firstC2FlagIdx = idx;
1731          }
1732#endif
1733        }
1734        else if( (c1 < 3) && (c1 > 0) )
1735        {
1736          c1++;
1737        }
1738        absCoeff[ idx ] = uiBin + 1;
1739      }
1740     
1741      if (c1 == 0)
1742      {
1743#if RESTRICT_GR1GR2FLAG_NUMBER
1744        baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet;
1745        if ( firstC2FlagIdx != -1)
1746        {
1747          m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] ); 
1748          absCoeff[ firstC2FlagIdx ] = uiBin + 2;
1749        }
1750#else   
1751        baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + 3 * uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + 3 * uiCtxSet;
1752        for( Int idx = 0; idx < numNonZero; idx++ )
1753        {
1754          if( absCoeff[ idx ] == 2 ) 
1755          {
1756            m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c2] );
1757            absCoeff[ idx ] = uiBin + 2;
1758            c2 += (c2 < 2);
1759            uiNumOne++;
1760          }
1761        }
1762#endif
1763      }
1764
1765#if MULTIBITS_DATA_HIDING
1766      UInt coeffSigns;
1767      if ( signHidden && beValid )
1768      {
1769        m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 );
1770        coeffSigns <<= 32 - (numNonZero-1);
1771      }
1772      else
1773      {
1774        m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero );
1775        coeffSigns <<= 32 - numNonZero;
1776      }
1777#else
1778      UInt coeffSigns;
1779      m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero );
1780      coeffSigns <<= 32 - numNonZero;
1781#endif
1782     
1783#if RESTRICT_GR1GR2FLAG_NUMBER
1784      Int iFirstCoeff2 = 1;   
1785      if (c1 == 0 || numNonZero > C1FLAG_NUMBER)
1786#else
1787      if (c1 == 0)
1788#endif
1789      {
1790        for( Int idx = 0; idx < numNonZero; idx++ )
1791        {
1792#if RESTRICT_GR1GR2FLAG_NUMBER   
1793          UInt baseLevel  = (idx < C1FLAG_NUMBER)? (2 + iFirstCoeff2) : 1;
1794
1795          if( absCoeff[ idx ] == baseLevel)
1796          {
1797            UInt uiLevel;
1798            xReadGoRiceExGolomb( uiLevel, uiGoRiceParam );
1799            absCoeff[ idx ] = uiLevel + baseLevel;
1800          }
1801
1802          if(absCoeff[ idx ] >= 2) 
1803          {
1804            iFirstCoeff2 = 0;
1805            uiNumOne++;
1806          }
1807#else
1808          if( absCoeff[ idx ] == 3 )
1809          {
1810            UInt uiLevel;
1811            xReadGoRiceExGolomb( uiLevel, uiGoRiceParam );
1812            absCoeff[ idx ] = uiLevel + 3;
1813          }
1814#endif
1815        }
1816      }
1817
1818      for( Int idx = 0; idx < numNonZero; idx++ )
1819      {
1820        Int blkPos = pos[ idx ];
1821#if MULTIBITS_DATA_HIDING
1822        // Signs applied later.
1823        pcCoef[ blkPos ] = absCoeff[ idx ];
1824        absSum += absCoeff[ idx ];
1825
1826        if ( idx == numNonZero-1 && signHidden && beValid )
1827        {
1828          // Infer sign of 1st element.
1829          if (absSum&0x1)
1830            pcCoef[ blkPos ] = -pcCoef[ blkPos ];
1831        }
1832        else
1833        {
1834          Int sign = static_cast<Int>( coeffSigns ) >> 31;
1835          pcCoef[ blkPos ] = ( pcCoef[ blkPos ] ^ sign ) - sign;
1836          coeffSigns <<= 1;
1837        }
1838#else
1839        Int sign = static_cast<Int>( coeffSigns ) >> 31;
1840        pcCoef[ blkPos ] = ( absCoeff[ idx ] ^ sign ) - sign;
1841        coeffSigns <<= 1;
1842#endif
1843      }
1844    }
1845    else
1846    {
1847      uiNumOne >>= 1;
1848    }
1849  }
1850 
1851  return;
1852}
1853
1854
1855#if SAO_UNIT_INTERLEAVING
1856Void TDecSbac::parseSaoUvlc (UInt& ruiVal)
1857{
1858  UInt uiCode;
1859  Int  i;
1860
1861  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) );
1862  if ( uiCode == 0 )
1863  {
1864    ruiVal = 0;
1865    return;
1866  }
1867
1868  i=1;
1869  while (1)
1870  {
1871    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) );
1872    if ( uiCode == 0 ) break;
1873    i++;
1874  }
1875
1876  ruiVal = i;
1877}
1878
1879Void TDecSbac::parseSaoSvlc (Int&  riVal)
1880{
1881  UInt uiCode;
1882  Int  iSign;
1883  Int  i;
1884
1885  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) );
1886
1887  if ( uiCode == 0 )
1888  {
1889    riVal = 0;
1890    return;
1891  }
1892
1893  // read sign
1894  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) );
1895
1896  if ( uiCode == 0 )
1897  {
1898    iSign =  1;
1899  }
1900  else
1901  {
1902    iSign = -1;
1903  }
1904
1905  // read magnitude
1906  i=1;
1907  while (1)
1908  {
1909    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) );
1910    if ( uiCode == 0 ) break;
1911    i++;
1912  }
1913
1914  riVal = i*iSign;
1915}
1916
1917Void TDecSbac::parseSaoUflc (UInt&  riVal)
1918{
1919  UInt uiSymbol;
1920  riVal = 0;
1921  for (Int i=0;i<5;i++)
1922  {
1923    m_pcTDecBinIf->decodeBinEP ( uiSymbol );
1924    if (uiSymbol)
1925    {
1926      riVal |= (1<<i);
1927    }
1928  }
1929}
1930Void TDecSbac::parseSaoMergeLeft (UInt&  ruiVal, UInt uiCompIdx)
1931{
1932  UInt uiCode;
1933  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) );
1934  ruiVal = (Int)uiCode;
1935}
1936
1937Void TDecSbac::parseSaoMergeUp (UInt&  ruiVal)
1938{
1939  UInt uiCode;
1940  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) );
1941  ruiVal = (Int)uiCode;
1942}
1943Void TDecSbac::parseSaoTypeIdx (UInt&  ruiVal)
1944{
1945  UInt uiCode;
1946  Int  i;
1947  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
1948  if ( uiCode == 0 )
1949  {
1950    ruiVal = 0;
1951    return;
1952  }
1953  i=1;
1954  while (1)
1955  {
1956    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) );
1957    if ( uiCode == 0 ) break;
1958    i++;
1959  }
1960  ruiVal = i;
1961}
1962
1963inline Void copySaoOneLcuParam(SaoLcuParam* psDst,  SaoLcuParam* psSrc)
1964{
1965  Int i;
1966  psDst->partIdx = psSrc->partIdx;
1967  psDst->typeIdx    = psSrc->typeIdx;
1968  if (psDst->typeIdx != -1)
1969  {
1970    if (psDst->typeIdx == SAO_BO)
1971    {
1972      psDst->bandPosition = psSrc->bandPosition ;
1973    }
1974    else
1975    {
1976      psDst->bandPosition = 0;
1977    }
1978    psDst->length  = psSrc->length;
1979    for (i=0;i<psDst->length;i++)
1980    {
1981      psDst->offset[i] = psSrc->offset[i];
1982    }
1983  }
1984  else
1985  {
1986    psDst->length  = 0;
1987    for (i=0;i<SAO_BO_LEN;i++)
1988    {
1989      psDst->offset[i] = 0;
1990    }
1991  }
1992}
1993Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam)
1994{
1995  UInt uiSymbol;
1996  Int iSymbol;
1997  static Int iTypeLength[MAX_NUM_SAO_TYPE] = {
1998    SAO_EO_LEN,
1999    SAO_EO_LEN,
2000    SAO_EO_LEN,
2001    SAO_EO_LEN,
2002    SAO_BO_LEN
2003  }; 
2004
2005  parseSaoTypeIdx(uiSymbol);
2006  psSaoLcuParam->typeIdx = (Int)uiSymbol - 1;
2007  if (uiSymbol)
2008  {
2009    psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx];
2010    if( psSaoLcuParam->typeIdx == SAO_BO )
2011    {
2012      // Parse Left Band Index
2013      parseSaoUflc( uiSymbol );
2014      psSaoLcuParam->bandPosition = uiSymbol;
2015      for(Int i=0; i< psSaoLcuParam->length; i++)
2016      {
2017        parseSaoSvlc(iSymbol);
2018        psSaoLcuParam->offset[i] = iSymbol;
2019      }   
2020    }
2021    else if( psSaoLcuParam->typeIdx < 4 )
2022    {
2023      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol;
2024      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol;
2025      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
2026      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
2027    }
2028  }
2029  else
2030  {
2031    psSaoLcuParam->length = 0;
2032  }
2033}
2034
2035Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag)
2036{
2037  Int iAddr = pcCU->getAddr();
2038  UInt uiSymbol;
2039  for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
2040  {
2041    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
2042    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
2043    pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition   = 0;
2044    pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        = -1;
2045    pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]     = 0;
2046    pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1]     = 0;
2047    pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2]     = 0;
2048    pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3]     = 0;
2049
2050    if (pSaoParam->bSaoFlag[iCompIdx])
2051    {
2052      if (rx>0 && iCUAddrInSlice!=0)
2053      {
2054        parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol;
2055      }
2056      else
2057      {
2058        pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0;
2059      }
2060
2061      if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0)
2062      {
2063        if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag))
2064        {
2065          parseSaoMergeUp(uiSymbol);  pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol;
2066        }
2067        else
2068        {
2069          pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0;
2070        }
2071        if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag)
2072        {
2073          parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]));
2074        }
2075        else
2076        {
2077          copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]);
2078        }
2079      }
2080      else
2081      {
2082        copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr],  &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]);
2083      }
2084    }
2085    else
2086    {
2087      pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1;
2088      pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0;
2089    }
2090  }
2091}
2092#endif
2093
2094/**
2095 - Initialize our contexts from the nominated source.
2096 .
2097 \param pSrc Contexts to be copied.
2098 */
2099Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc )
2100{
2101  memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0]));
2102}
2103
2104Void TDecSbac::xCopyFrom( TDecSbac* pSrc )
2105{
2106  m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf );
2107
2108  m_uiLastQp           = pSrc->m_uiLastQp;
2109  xCopyContextsFrom( pSrc );
2110
2111}
2112
2113Void TDecSbac::load ( TDecSbac* pScr )
2114{
2115  xCopyFrom(pScr);
2116}
2117
2118Void TDecSbac::loadContexts ( TDecSbac* pScr )
2119{
2120  xCopyContextsFrom(pScr);
2121}
2122
2123#if OL_FLUSH
2124Void TDecSbac::decodeFlush ( )
2125{
2126  UInt uiBit;
2127  m_pcTDecBinIf->decodeBinTrm(uiBit);
2128  m_pcTDecBinIf->flush();
2129
2130}
2131#endif
2132
2133#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
2134Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
2135{
2136  UInt uiSymbol;
2137  UInt uiCount = 0;
2138  do
2139  {
2140    m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel );
2141    uiCount++;
2142  }
2143  while( uiSymbol && ( uiCount != 13 ) );
2144
2145  ruiSymbol = uiCount - 1;
2146
2147  if( uiSymbol )
2148  {
2149    xReadEpExGolomb( uiSymbol, 0 );
2150    ruiSymbol += uiSymbol + 1;
2151  }
2152
2153  return;
2154}
2155#endif
2156#if HHI_DMM_WEDGE_INTRA
2157Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2158{
2159  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
2160  Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx];
2161
2162  UInt uiSymbol, uiTabIdx = 0;
2163  for ( Int i = 0; i < iBits; i++ )
2164  {
2165    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) );
2166    uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0;
2167    uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0;
2168    uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0;
2169    uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0;
2170    uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0;
2171    uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0;
2172    uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0;
2173    uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0;
2174    uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0;
2175    uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0;
2176    uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0;
2177    uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0;
2178    uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0;
2179  }
2180
2181  pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth );
2182}
2183
2184Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2185{
2186  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
2187  Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx];
2188
2189  UInt uiSymbol, uiTabIdx = 0;
2190  for ( Int i = 0; i < iBits; i++ )
2191  {
2192    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) );
2193    uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0;
2194    uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0;
2195    uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0;
2196    uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0;
2197    uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0;
2198    uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0;
2199    uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0;
2200    uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0;
2201    uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0;
2202    uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0;
2203    uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0;
2204    uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0;
2205    uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0;
2206  }
2207
2208  pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth );
2209
2210  UInt uiDC1, uiDC2;
2211  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
2212  Int iDC1 = uiDC1;
2213  if ( uiDC1 )
2214  {
2215    UInt uiSign;
2216    m_pcTDecBinIf->decodeBinEP( uiSign );
2217    if ( uiSign )
2218    {
2219      iDC1 = -iDC1;
2220    }
2221  }
2222  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
2223  Int iDC2 = uiDC2;
2224  if ( uiDC2 )
2225  {
2226    UInt uiSign;
2227    m_pcTDecBinIf->decodeBinEP( uiSign );
2228    if ( uiSign )
2229    {
2230      iDC2 = -iDC2;
2231    }
2232  }
2233
2234  pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
2235  pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
2236}
2237
2238Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2239{
2240  if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 )
2241  {
2242    UInt uiDeltaEnd = 0;
2243    m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) );
2244
2245    Int iDeltaEnd;
2246    if( uiDeltaEnd != 0 )
2247    {
2248      UInt uiAbsValMinus1;
2249      UInt uiSymbol;
2250      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1  = uiSymbol;
2251      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1;
2252      uiDeltaEnd = uiAbsValMinus1 + 1;
2253
2254      iDeltaEnd = uiDeltaEnd;
2255      UInt uiSign;
2256      m_pcTDecBinIf->decodeBinEP( uiSign );
2257      if( uiSign )
2258      {
2259        iDeltaEnd = -iDeltaEnd;
2260      }
2261    }
2262    else
2263    {
2264      iDeltaEnd = 0;
2265    }
2266    pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth );
2267  }
2268}
2269
2270Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2271{
2272  if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 )
2273  {
2274    UInt uiDeltaEnd = 0;
2275    m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) );
2276
2277    Int iDeltaEnd;
2278    if( uiDeltaEnd != 0 )
2279    {
2280      UInt uiAbsValMinus1;
2281      UInt uiSymbol;
2282      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1  = uiSymbol;
2283      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1;
2284      uiDeltaEnd = uiAbsValMinus1 + 1;
2285
2286      iDeltaEnd = uiDeltaEnd;
2287      UInt uiSign;
2288      m_pcTDecBinIf->decodeBinEP( uiSign );
2289      if( uiSign )
2290      {
2291        iDeltaEnd = -iDeltaEnd;
2292      }
2293    }
2294    else
2295    {
2296      iDeltaEnd = 0;
2297    }
2298
2299    pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth );
2300  }
2301
2302  UInt uiDC1, uiDC2;
2303  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
2304  Int iDC1 = uiDC1;
2305  if ( uiDC1 )
2306  {
2307    UInt uiSign;
2308    m_pcTDecBinIf->decodeBinEP( uiSign );
2309    if ( uiSign )
2310    {
2311      iDC1 = -iDC1;
2312    }
2313  }
2314  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
2315  Int iDC2 = uiDC2;
2316  if ( uiDC2 )
2317  {
2318    UInt uiSign;
2319    m_pcTDecBinIf->decodeBinEP( uiSign );
2320    if ( uiSign )
2321    {
2322      iDC2 = -iDC2;
2323    }
2324  }
2325
2326  pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
2327  pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
2328}
2329#endif
2330#if HHI_DMM_PRED_TEX
2331Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2332{
2333  UInt uiDC1, uiDC2;
2334  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
2335  Int iDC1 = uiDC1;
2336  if ( uiDC1 )
2337  {
2338    UInt uiSign;
2339    m_pcTDecBinIf->decodeBinEP( uiSign );
2340    if ( uiSign )
2341    {
2342      iDC1 = -iDC1;
2343    }
2344  }
2345  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
2346  Int iDC2 = uiDC2;
2347  if ( uiDC2 )
2348  {
2349    UInt uiSign;
2350    m_pcTDecBinIf->decodeBinEP( uiSign );
2351    if ( uiSign )
2352    {
2353      iDC2 = -iDC2;
2354    }
2355  }
2356
2357  pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
2358  pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
2359}
2360
2361Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2362{
2363  UInt uiDC1, uiDC2;
2364  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
2365  Int iDC1 = uiDC1;
2366  if ( uiDC1 )
2367  {
2368    UInt uiSign;
2369    m_pcTDecBinIf->decodeBinEP( uiSign );
2370    if ( uiSign )
2371    {
2372      iDC1 = -iDC1;
2373    }
2374  }
2375  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
2376  Int iDC2 = uiDC2;
2377  if ( uiDC2 )
2378  {
2379    UInt uiSign;
2380    m_pcTDecBinIf->decodeBinEP( uiSign );
2381    if ( uiSign )
2382    {
2383      iDC2 = -iDC2;
2384    }
2385  }
2386
2387  pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
2388  pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
2389}
2390#endif
2391
2392#if LGE_EDGE_INTRA
2393Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
2394{
2395  UInt uiSymbol = 0;
2396
2397  // 1. Top(0) or Left(1)
2398  UChar ucLeft;
2399  m_pcTDecBinIf->decodeBinEP( uiSymbol );
2400  ucLeft = uiSymbol;
2401
2402  // 2. Start position (lowest bit first)
2403  UChar ucStart = 0;
2404  for( UInt ui = 0; ui < 6 - uiDepth; ui++ )
2405  {
2406    m_pcTDecBinIf->decodeBinEP( uiSymbol );
2407    ucStart |= (uiSymbol << ui);
2408  }
2409
2410  // 3. Number of edges
2411  UChar ucMax = 0;
2412  for( UInt ui = 0; ui < 7 - uiDepth; ui++ )
2413  {
2414    m_pcTDecBinIf->decodeBinEP( uiSymbol );
2415    ucMax |= (uiSymbol << ui);
2416  }
2417  ucMax++; // +1
2418
2419  // 4. Edges
2420  UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
2421  UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx );
2422  for( Int iPtr = 0; iPtr < ucMax; iPtr++ )
2423  {
2424    UChar ucEdge = 0;
2425    UInt  uiReorderEdge = 0;
2426    // Left-friendly direction
2427    // 0 (   0deg) => 0
2428    // 1 (  45deg) => 10
2429    // 2 ( -45deg) => 110
2430    // 3 (  90deg) => 1110
2431    // 4 ( -90deg) => 11110
2432    // 5 ( 135deg) => 111110
2433    // 6 (-135deg) => 111111
2434    // Right-friendly direction
2435    // 0 (   0deg) => 0
2436    // 1 ( -45deg) => 10
2437    // 2 (  45deg) => 110
2438    // 3 ( -90deg) => 1110
2439    // 4 (  90deg) => 11110
2440    // 5 (-135deg) => 111110
2441    // 6 ( 135deg) => 111111
2442    // refer to a paper "An efficient chain code with Huffman coding"
2443    for( UInt ui = 0; ui < 6; ui++ )
2444    {
2445      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
2446      ucEdge <<= 1;
2447      ucEdge |= uiSymbol;
2448      if( uiSymbol == 0 )
2449        break;
2450    }
2451
2452    switch( ucEdge )
2453    {
2454    case 0 :  // "0"
2455      uiReorderEdge = 0;
2456      break;
2457    case 2 :  // "10"
2458      uiReorderEdge = 1;
2459      break;
2460    case 6 :  // "110"
2461      uiReorderEdge = 2;
2462      break;
2463    case 14 : // "1110"
2464      uiReorderEdge = 3;
2465      break;
2466    case 30 : // "11110"
2467      uiReorderEdge = 4;
2468      break;
2469    case 62 : // "111110"
2470      uiReorderEdge = 5;
2471      break;
2472    case 63 : // "111111"
2473      uiReorderEdge = 6;
2474      break;
2475    default :
2476      printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge);
2477      assert(false);
2478      break;
2479    }
2480    pucSymbolList[iPtr] = uiReorderEdge;
2481  }
2482  /////////////////////
2483  // Edge Reconstruction
2484  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
2485  pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion );
2486  xFree( pucSymbolList );
2487}
2488#endif
2489
2490//! \}
Note: See TracBrowser for help on using the repository browser.