Changeset 56 in 3DVCSoftware for trunk/source/Lib/TLibCommon/ContextModel.h
- Timestamp:
- 11 May 2012, 21:20:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/ContextModel.h
r5 r56 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 1,ISO/IEC6 * Copyright (c) 2010-2012, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 15 15 * this list of conditions and the following disclaimer in the documentation 16 16 * and/or other materials provided with the distribution. 17 * * Neither the name of the I SO/IEC nor the names of its contributors may17 * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may 18 18 * be used to endorse or promote products derived from this software without 19 19 * specific prior written permission. … … 33 33 34 34 35 36 37 35 /** \file ContextModel.h 38 36 \brief context model class (header) … … 48 46 #include "CommonDef.h" 49 47 48 //! \ingroup TLibCommon 49 //! \{ 50 50 51 51 // ==================================================================================================================== … … 57 57 { 58 58 public: 59 #if CABAC_INIT_FLAG 60 ContextModel () { m_ucState = 0; m_binsCoded = 0; } 61 #else 59 62 ContextModel () { m_ucState = 0; } 63 #endif 60 64 ~ContextModel () {} 61 65 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 64 69 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 67 71 68 Void 72 Void updateLPS () 69 73 { 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 ]; 72 75 } 73 76 74 Void 77 Void updateMPS () 75 78 { 76 m_ucState = ( m_aucNextStateMPS[ m_ucState >> 1 ] << 1 ) + ( m_ucState & 1 );79 m_ucState = m_aucNextStateMPS[ m_ucState ]; 77 80 } 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 78 96 79 97 private: 80 98 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 83 113 }; 114 115 //! \} 84 116 85 117 #endif
Note: See TracChangeset for help on using the changeset viewer.