Last change
on this file was
2,
checked in by hhi, 13 years ago
|
inital import
|
-
Property svn:eol-style set to
native
|
File size:
1.7 KB
|
Line | |
---|
1 | |
---|
2 | |
---|
3 | /** \file TDecBinCoderCABAC.cpp |
---|
4 | \brief binary entropy decoder of CABAC |
---|
5 | */ |
---|
6 | |
---|
7 | #include "TDecBinCoderCABAC.h" |
---|
8 | |
---|
9 | |
---|
10 | TDecBinCABAC::TDecBinCABAC() |
---|
11 | : m_pcTComBitstream( 0 ) |
---|
12 | { |
---|
13 | } |
---|
14 | |
---|
15 | TDecBinCABAC::~TDecBinCABAC() |
---|
16 | { |
---|
17 | } |
---|
18 | |
---|
19 | Void |
---|
20 | TDecBinCABAC::init( TComBitstream* pcTComBitstream ) |
---|
21 | { |
---|
22 | m_pcTComBitstream = pcTComBitstream; |
---|
23 | } |
---|
24 | |
---|
25 | Void |
---|
26 | TDecBinCABAC::uninit() |
---|
27 | { |
---|
28 | m_pcTComBitstream = 0; |
---|
29 | } |
---|
30 | |
---|
31 | Void |
---|
32 | TDecBinCABAC::start() |
---|
33 | { |
---|
34 | m_pcTComBitstream->setModeSbac(); |
---|
35 | |
---|
36 | m_uiRange = 510; |
---|
37 | m_uiValue = 0; |
---|
38 | for( UInt ui = 0; ui < 9; ui++ ) |
---|
39 | { |
---|
40 | xReadBit( m_uiValue ); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | Void |
---|
45 | TDecBinCABAC::finish() |
---|
46 | { |
---|
47 | } |
---|
48 | |
---|
49 | Void |
---|
50 | TDecBinCABAC::decodeBin( UInt& ruiBin, ContextModel &rcCtxModel ) |
---|
51 | { |
---|
52 | UInt uiLPS = TComCABACTables::sm_aucLPSTable[ rcCtxModel.getState() ][ ( m_uiRange >> 6 ) & 3 ]; |
---|
53 | m_uiRange -= uiLPS; |
---|
54 | if( m_uiValue < m_uiRange ) |
---|
55 | { |
---|
56 | ruiBin = rcCtxModel.getMps(); |
---|
57 | rcCtxModel.updateMPS(); |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | m_uiValue -= m_uiRange; |
---|
62 | m_uiRange = uiLPS; |
---|
63 | ruiBin = 1 - rcCtxModel.getMps(); |
---|
64 | rcCtxModel.updateLPS(); |
---|
65 | } |
---|
66 | while( m_uiRange < 256 ) |
---|
67 | { |
---|
68 | m_uiRange += m_uiRange; |
---|
69 | xReadBit( m_uiValue ); |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | Void |
---|
74 | TDecBinCABAC::decodeBinEP( UInt& ruiBin ) |
---|
75 | { |
---|
76 | xReadBit( m_uiValue ); |
---|
77 | if( m_uiValue >= m_uiRange ) |
---|
78 | { |
---|
79 | ruiBin = 1; |
---|
80 | m_uiValue -= m_uiRange; |
---|
81 | } |
---|
82 | else |
---|
83 | { |
---|
84 | ruiBin = 0; |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | Void |
---|
89 | TDecBinCABAC::decodeBinTrm( UInt& ruiBin ) |
---|
90 | { |
---|
91 | m_uiRange -= 2; |
---|
92 | if( m_uiValue >= m_uiRange ) |
---|
93 | { |
---|
94 | ruiBin = 1; |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | ruiBin = 0; |
---|
99 | while( m_uiRange < 256 ) |
---|
100 | { |
---|
101 | m_uiRange += m_uiRange; |
---|
102 | xReadBit( m_uiValue ); |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | Void |
---|
108 | TDecBinCABAC::xReadBit( UInt& ruiVal ) |
---|
109 | { |
---|
110 | UInt uiBit = 0; |
---|
111 | m_pcTComBitstream->read( 1, uiBit ); |
---|
112 | ruiVal = ( ruiVal << 1 ) | uiBit; |
---|
113 | } |
---|
Note: See
TracBrowser for help on using the repository browser.