Skip to content

Commit 2710f7a

Browse files
authored
improve the readme (#25)
1 parent 0098408 commit 2710f7a

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
# Arithmetic Coding
22

3-
A symbolic arithmetic coding library
3+
[![Latest Docs](https://docs.rs/arithmetic-coding/badge.svg)](https://docs.rs/arithmetic-coding/)
4+
![Continuous integration](https://github.com/danieleades/arithmetic-coding/workflows/Continuous%20integration/badge.svg)
5+
[![codecov](https://codecov.io/gh/danieleades/arithmetic-coding/branch/main/graph/badge.svg?token=1qITX2tR0J)](https://codecov.io/gh/danieleades/arithmetic-coding)
6+
7+
8+
A symbolic [arithmetic coding](https://en.wikipedia.org/wiki/Arithmetic_coding) library.
9+
10+
Extending this library is as simple as implementing the `Model` trait for your own type, and then plugging it in the provided `Encoder`/`Decoder`. Supports both fixed-length and variable-length encoding, as well as both adaptive and non-adaptive models.
11+
12+
Take a look at the [API docs](https://docs.rs/arithmetic-coding/) or the [examples](https://github.com/danieleades/arithmetic-coding/tree/main/examples).

arithmetic-coding-core/src/fixed_length.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub struct Wrapper<M>
135135
where
136136
M: Model,
137137
{
138-
inner_model: M,
138+
model: M,
139139
remaining: usize,
140140
}
141141

@@ -146,10 +146,7 @@ where
146146
/// Construct a new wrapper from a [`fixed_length::Model`](Model)
147147
pub fn new(model: M) -> Self {
148148
let remaining = model.length();
149-
Self {
150-
inner_model: model,
151-
remaining,
152-
}
149+
Self { model, remaining }
153150
}
154151
}
155152

@@ -168,9 +165,7 @@ where
168165
if self.remaining > 0 {
169166
if let Some(s) = symbol {
170167
// Expected a symbol and got one. return the probability.
171-
self.inner_model
172-
.probability(s)
173-
.map_err(Self::ValueError::Value)
168+
self.model.probability(s).map_err(Self::ValueError::Value)
174169
} else {
175170
// We are expecting more symbols, but got an EOF
176171
Err(Self::ValueError::UnexpectedEof)
@@ -185,24 +180,24 @@ where
185180
}
186181

187182
fn max_denominator(&self) -> Self::B {
188-
self.inner_model.max_denominator()
183+
self.model.max_denominator()
189184
}
190185

191186
fn symbol(&self, value: Self::B) -> Option<Self::Symbol> {
192187
if self.remaining > 0 {
193-
Some(self.inner_model.symbol(value))
188+
Some(self.model.symbol(value))
194189
} else {
195190
None
196191
}
197192
}
198193

199194
fn denominator(&self) -> Self::B {
200-
self.inner_model.denominator()
195+
self.model.denominator()
201196
}
202197

203198
fn update(&mut self, symbol: Option<&Self::Symbol>) {
204199
if let Some(s) = symbol {
205-
self.inner_model.update(s);
200+
self.model.update(s);
206201
self.remaining -= 1;
207202
}
208203
}

0 commit comments

Comments
 (0)