MPEG CDVA Experimentation Model (CXM)  1.0
Compact Descriptors for Visual Analisys
cabac.h
Go to the documentation of this file.
1 
2 /*
3 //
4 // Copyright (c) 2002-2015 Joe Bertolami. All Right Reserved.
5 //
6 // cabac.h
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are met:
10 //
11 // * Redistributions of source code must retain the above copyright notice, this
12 // list of conditions and the following disclaimer.
13 //
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 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Additional Information:
30 //
31 // For more information, visit http://www.bertolami.com.
32 //
33 */
34 
35 #ifndef __EV_CABAC_H__
36 #define __EV_CABAC_H__
37 
38 #include "bitstream.h"
39 
40 /*
41 // Entropy Stream Interface
42 //
43 // There are two ways to use this interface:
44 //
45 // o: Stream coding
46 //
47 // To code an entire stream at once, call Encode()/Decode(). This will instruct
48 // the coder to initialize itself, perform the coding operation, perform a flush
49 // if necessary, and clear its internal state.
50 //
51 // o: Incremental coding
52 //
53 // To incrementally code one or more symbols at a time, you must pass FALSE as the
54 // optional parameter to Encode and Decode. Additionally, you must call FinishEncode()
55 // after all encode operations are complete, and StartDecode prior to calling the first
56 // Decode(). This process allows the coder to properly initialize, flush, and reset itself.
57 */
58 
59 namespace evx {
60 
62 {
63  bool adaptive;
64  uint32 e3_count;
65  uint32 history[2];
66  uint32 value;
67 
68  uint32 model;
69  uint32 low;
70  uint32 high;
71  uint32 mid;
72 
73 private:
74 
75  void resolve_model();
76 
77  evx_status flush_encoder(bitstream *dest);
78  evx_status flush_inverse_bits(uint8 value, bitstream *dest);
79 
80  evx_status encode_symbol(uint8 value);
81  evx_status decode_symbol(uint32 value, bitstream *dest);
82 
83  evx_status resolve_encode_scaling(bitstream *dest);
84  evx_status resolve_decode_scaling(uint32 *value, bitstream *source, bitstream *dest);
85 
86 public:
87 
88  entropy_coder();
89  explicit entropy_coder(uint32 input_model);
90  void clear();
91 
92  evx_status encode(bitstream *source, bitstream *dest, bool auto_finish=true);
93  evx_status decode(uint32 symbol_count, bitstream *source, bitstream *dest, bool auto_start=true);
94 
97 
98 private:
99 
100  EVX_DISABLE_COPY_AND_ASSIGN(entropy_coder);
101 };
102 
103 } // namespace EVX
104 
105 #endif // __EVX_CABAC_H__
u_int8_t uint8
Definition: base.h:137
evx_status finish_encode(bitstream *dest)
evx_status encode(bitstream *source, bitstream *dest, bool auto_finish=true)
Definition: base.h:116
evx_status start_decode(bitstream *source)
Definition: bitstream.h:45
evx_status decode(uint32 symbol_count, bitstream *source, bitstream *dest, bool auto_start=true)
u_int32_t uint32
Definition: base.h:135
uint8 evx_status
Definition: base.h:152
Definition: cabac.h:61