Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibCommon/ContextModel.h


Ignore:
Timestamp:
11 May 2012, 21:20:17 (12 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/ContextModel.h

    r5 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    3333
    3434
    35 
    36 
    3735/** \file     ContextModel.h
    3836    \brief    context model class (header)
     
    4846#include "CommonDef.h"
    4947
     48//! \ingroup TLibCommon
     49//! \{
    5050
    5151// ====================================================================================================================
     
    5757{
    5858public:
     59#if CABAC_INIT_FLAG
     60  ContextModel  ()                        { m_ucState = 0; m_binsCoded = 0; }
     61#else
    5962  ContextModel  ()                        { m_ucState = 0;             }
     63#endif
    6064  ~ContextModel ()                        {}
    6165 
    62   const UChar getState  ()                { return ( m_ucState >> 1 ); }                    ///< get current state
    63   const UChar getMps    ()                { return ( m_ucState  & 1 ); }                    ///< get curret MPS
     66  UChar getState  ()                { return ( m_ucState >> 1 ); }                    ///< get current state
     67  UChar getMps    ()                { return ( m_ucState  & 1 ); }                    ///< get curret MPS
     68  Void  setStateAndMps( UChar ucState, UChar ucMPS) { m_ucState = (ucState << 1) + ucMPS; } ///< set state and MPS
    6469 
    65   Void        init      ( Int   iQp,
    66                          Short asCtxInit[] );                                              ///< initialize state with initial prob.
     70  Void init ( Int qp, Int initValue );   ///< initialize state with initial probability
    6771 
    68   Void        updateLPS ()
     72  Void updateLPS ()
    6973  {
    70     UChar ucMPS = ( m_ucState > 1    ? m_ucState  & 1 :    1   - ( m_ucState & 1 ) );
    71     m_ucState   = ( m_aucNextStateLPS[ m_ucState >> 1 ] << 1 ) + ucMPS;
     74    m_ucState = m_aucNextStateLPS[ m_ucState ];
    7275  }
    7376 
    74   Void        updateMPS ()
     77  Void updateMPS ()
    7578  {
    76     m_ucState   = ( m_aucNextStateMPS[ m_ucState >> 1 ] << 1 ) + ( m_ucState & 1 );
     79    m_ucState = m_aucNextStateMPS[ m_ucState ];
    7780  }
     81 
     82  Int getEntropyBits(Short val) { return m_entropyBits[m_ucState ^ val]; }
     83   
     84#if FAST_BIT_EST
     85  Void update( Int binVal )
     86  {
     87    m_ucState = m_nextState[m_ucState][binVal];
     88  }
     89  static Void buildNextStateTable();
     90  static Int getEntropyBitsTrm( Int val ) { return m_entropyBits[126 ^ val]; }
     91#endif
     92#if CABAC_INIT_FLAG
     93  Void setBinsCoded(UInt val)   { m_binsCoded = val;  }
     94  UInt getBinsCoded()           { return m_binsCoded;   }
     95#endif
    7896 
    7997private:
    8098  UChar         m_ucState;                                                                  ///< internal state variable
    81   static const  UChar m_aucNextStateMPS[ 64 ];
    82   static const  UChar m_aucNextStateLPS[ 64 ];
     99  static const  UChar m_aucNextStateMPS[ 128 ];
     100  static const  UChar m_aucNextStateLPS[ 128 ];
     101  static const Int m_entropyBits[ 128 ];
     102#if FAST_BIT_EST
     103  static UChar m_nextState[128][2];
     104#endif
     105#if !CABAC_LINEAR_INIT
     106  static const Int m_slopes[16];
     107  static const Int m_segOffset[8];
     108  static const Int m_accumulatedSegOffset[8];
     109#endif
     110#if CABAC_INIT_FLAG
     111  UInt          m_binsCoded;
     112#endif
    83113};
     114
     115//! \}
    84116
    85117#endif
Note: See TracChangeset for help on using the changeset viewer.